From d3a553444e5585d91267aa02ce6ed60552b5c727 Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 12 Dec 2024 14:52:00 +0100 Subject: [PATCH 001/329] add support for enforcement of modes/parameters through external binary files --- apps/encoder.c | 59 +++++++++++++++++++++++++++++- lib_com/options.h | 3 +- lib_debug/debug.c | 18 +++++++++ lib_debug/debug.h | 4 ++ lib_enc/ivas_core_pre_proc_front.c | 43 ++++++++++++++++++++++ lib_enc/ivas_cpe_enc.c | 3 ++ lib_enc/ivas_decision_matrix_enc.c | 9 +++++ lib_enc/ivas_stat_enc.h | 6 +++ lib_enc/ivas_stereo_classifier.c | 9 +++++ lib_enc/lib_enc.c | 26 +++++++++++++ lib_enc/lib_enc.h | 3 ++ lib_enc/stat_enc.h | 5 ++- 12 files changed, 184 insertions(+), 4 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 98fb9aaa2..0eae15fc1 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -45,6 +45,20 @@ #include "masa_file_reader.h" #include "wmc_auto.h" +#ifdef DEBUG_FORCE_DIR +/* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. + We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h + in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR, + rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ +#include +#if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) +#define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) +#endif +#if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) +#define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) +#endif +#endif + #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -184,6 +198,9 @@ int main( int16_t *pcmBuf = NULL; #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; +#ifdef DEBUG_FORCE_DIR + bool f_forceModeDir = false; +#endif #endif #ifdef WMOPS @@ -529,15 +546,42 @@ int main( #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode; int32_t force_profile_cnt = 0; +#ifdef DEBUG_FORCE_DIR + struct stat path_stat; +#endif if ( arg.forcedModeFile ) { +#ifdef DEBUG_FORCE_DIR + if ( stat( arg.forcedModeFile, &path_stat ) != 0 ) + { + fprintf( stderr, "\nError: The profile file/dir could not be opened: %s\n\n", arg.forcedModeFile ); + usage_enc(); + goto cleanup; + } + + /* check if it is a directory */ + if ( S_ISDIR( path_stat.st_mode ) ) + { + f_forceModeDir = true; + } + else + { + if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) + { + fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); + usage_enc(); + goto cleanup; + } + } +#else if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) { fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); usage_enc(); goto cleanup; } +#endif } #endif @@ -685,9 +729,17 @@ int main( } /* Force mode not set when configuring, set in first frame even if not reading from file */ - if ( f_forcedModeProfile || frame == 0 ) + if ( f_forcedModeProfile || +#ifdef DEBUG_FORCE_DIR + f_forceModeDir || +#endif + frame == 0 ) { - if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode +#ifdef DEBUG_FORCE_DIR + , arg.forcedModeFile +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; @@ -1798,6 +1850,9 @@ static void usage_enc( void ) #ifdef DEBUGGING fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" ); +#ifdef DEBUG_FORCE_DIR + fprintf( stdout, " or T can be a directory containing external binary files for modes/parameters enforcement\n" ); +#endif #endif #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK diff --git a/lib_com/options.h b/lib_com/options.h index 5ad891b9b..e57bee05d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -49,7 +49,8 @@ #ifdef DEBUGGING #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ #define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ -#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ +#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ +#define DEBUG_FORCE_DIR /* Force modes/parameters by reading from external binary files */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ #endif diff --git a/lib_debug/debug.c b/lib_debug/debug.c index f1cfa928a..2608be30a 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -363,6 +363,13 @@ int16_t dbgread( { index = in_count; in_fileptr[index] = fopen( filename, "rb" ); +#ifdef DEBUG_FORCE_DIR + if ( in_fileptr[index] == NULL ) + { + /* file does not exist or could not be opened -> just return */ + return -1; + } +#endif in_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); strcpy( in_filename[index], filename ); in_count++; @@ -773,8 +780,19 @@ char *fname( { char idd[5] = ".idX"; idd[3] = (char) ( id + '0' ); +#ifdef DEBUG_FORCE_DIR + short len; +#endif strcpy( tmp_fname, dir ); +#ifdef DEBUG_FORCE_DIR + len = strlen( tmp_fname ); + if (tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) + { + /* add trailing '/' slash */ + strcat( tmp_fname, "/" ); + } +#endif strcat( tmp_fname, file ); if ( enc_dec == DEC ) diff --git a/lib_debug/debug.h b/lib_debug/debug.h index e88def922..c1c978bfe 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -66,6 +66,10 @@ extern char debug_dir[6]; char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec ); #endif +#ifdef DEBUG_FORCE_DIR +#define FORCE_DIR_MAX_LENGTH 255 /* maximum length of the directory for modes/parameters enforcement */ +#endif + /*------------------------------------------------------------------------------------------* * Read/write I/O tool *------------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 05848dc4c..5b36b6bad 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1617,6 +1617,15 @@ ivas_error pre_proc_front_ivas_fx( st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), Q_new, NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float move16(); +#ifdef DEBUG_FORCE_DIR + dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); + + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); + } +#endif + test(); IF( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_flag, 1 ) ) { @@ -1694,6 +1703,16 @@ ivas_error pre_proc_front_ivas_fx( move16(); } +#ifdef DEBUG_FORCE_DIR + dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); + + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); + } +#endif + + /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates @@ -2340,6 +2359,15 @@ ivas_error pre_proc_front_ivas_fx( smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); +#ifdef DEBUG_FORCE_DIR + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); + + if ( st->force_dir[0] != '\0' ) + { + dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); + } +#endif + #ifdef DEBUGGING if ( st->idchan == 0 ) { @@ -2533,6 +2561,21 @@ ivas_error pre_proc_front_ivas_fx( ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, Etot_fx, attack_flag, inp_12k8_fx, Q_new, S_map_fx, flag_spitch ); } +#ifdef DEBUG_FORCE_DIR + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); + dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); + dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); + dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); + + if ( st->force_dir[0] != '\0' ) + { + dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); + dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); + dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); + dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); + } +#endif + /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index f40980db9..60cf33e8a 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -210,6 +210,9 @@ ivas_error ivas_cpe_enc_fx( #ifdef DEBUGGING sts[n]->force = hEncoderConfig->force; sts[n]->id_element = cpe_id + st_ivas->nSCE; +#ifdef DEBUG_FORCE_DIR + sts[n]->force_dir = hEncoderConfig->force_dir; +#endif #endif } diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 1da1b2272..d02defa6e 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -559,6 +559,15 @@ void ivas_decision_matrix_enc_fx( } #endif +#ifdef DEBUG_FORCE_DIR + dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core.enf" ); + + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core.enf", -1, -1, -1 ) ); + } +#endif + /* TCX not available at low bitrates -> replace it by GSC */ test(); IF( EQ_16( st->core, TCX_20_CORE ) && LT_32( st->total_brate, STEREO_TCX_MIN_RATE ) ) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 538362f3e..a0e65e586 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -39,6 +39,9 @@ #include "ivas_cnst.h" #include "stat_enc.h" #include "ivas_stat_com.h" +#ifdef DEBUG_FORCE_DIR +#include "debug.h" +#endif /*----------------------------------------------------------------------------------* * DFT Stereo encoder structures @@ -1810,6 +1813,9 @@ typedef struct encoder_config_structure int16_t stereo_mode_cmdl; /* stereo mode forced from the command-line */ int16_t force; /* parameter to force specific "core" of the Core-Coder*/ int16_t mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */ +#ifdef DEBUG_FORCE_DIR + char force_dir[FORCE_DIR_MAX_LENGTH]; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ +#endif #endif diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index b63cf8de3..220c2355c 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -230,6 +230,15 @@ Word16 select_stereo_mode( } } +#ifdef DEBUG_FORCE_DIR + dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); + + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); + } +#endif + /* switch from LRTD to DFT when xtalk_decision goes from 0->1 (note: this special case is not handled in the xtalk classifier) */ test(); test(); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 6c8ec4e29..135d3a8df 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2359,6 +2359,9 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ +#ifdef DEBUG_FORCE_DIR + ,const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ +#endif ) { int16_t newForced; @@ -2370,6 +2373,28 @@ ivas_error IVAS_ENC_SetForcedMode( return error; } +#ifdef DEBUG_FORCE_DIR + if ( forcedModeDir == NULL ) + { + hIvasEnc->st_ivas->hEncoderConfig->force_dir[0] = '\0'; + + if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hIvasEnc->st_ivas->hEncoderConfig->force != newForced ) + { + hIvasEnc->st_ivas->hEncoderConfig->force = newForced; + hIvasEnc->switchingActive = true; + } + } + else + { + strcpy( hIvasEnc->st_ivas->hEncoderConfig->force_dir, forcedModeDir ); + hIvasEnc->st_ivas->hEncoderConfig->force = IVAS_ENC_FORCE_UNFORCED; + } +#else if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) { return error; @@ -2380,6 +2405,7 @@ ivas_error IVAS_ENC_SetForcedMode( hIvasEnc->st_ivas->hEncoderConfig->force = newForced; hIvasEnc->switchingActive = true; } +#endif return IVAS_ERR_OK; } diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 03a0bee9e..41ffa4a10 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -340,6 +340,9 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ +#ifdef DEBUG_FORCE_DIR + ,const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ +#endif ); #endif diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 7a792ae0f..4d517e0bb 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1988,7 +1988,10 @@ typedef struct enc_core_structure int16_t low_rate_mode; /* low-rate mode flag */ int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ #ifdef DEBUGGING - int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ + int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ +#ifdef DEBUG_FORCE_DIR + char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ +#endif #endif Word16 nTimeSlots; /* for CLDFB */ -- GitLab From fbe043f58a61fb23772da24b755b8924a696667d Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 12 Dec 2024 15:44:08 +0100 Subject: [PATCH 002/329] clang format --- apps/encoder.c | 17 +++++++++-------- lib_enc/lib_enc.c | 3 ++- lib_enc/stat_enc.h | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 0eae15fc1..c3ba40381 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -561,7 +561,7 @@ int main( } /* check if it is a directory */ - if ( S_ISDIR( path_stat.st_mode ) ) + if ( S_ISDIR( path_stat.st_mode ) ) { f_forceModeDir = true; } @@ -729,17 +729,18 @@ int main( } /* Force mode not set when configuring, set in first frame even if not reading from file */ - if ( f_forcedModeProfile || + if ( f_forcedModeProfile || #ifdef DEBUG_FORCE_DIR - f_forceModeDir || -#endif - frame == 0 ) + f_forceModeDir || +#endif + frame == 0 ) { if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode #ifdef DEBUG_FORCE_DIR - , arg.forcedModeFile -#endif - ) ) != IVAS_ERR_OK ) + , + arg.forcedModeFile +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 135d3a8df..67b30a97e 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2360,7 +2360,8 @@ ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ #ifdef DEBUG_FORCE_DIR - ,const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ + , + const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ #endif ) { diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 4d517e0bb..9dd9d3346 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1988,9 +1988,9 @@ typedef struct enc_core_structure int16_t low_rate_mode; /* low-rate mode flag */ int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ #ifdef DEBUGGING - int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ + int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ #ifdef DEBUG_FORCE_DIR - char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ + char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ #endif #endif Word16 nTimeSlots; /* for CLDFB */ -- GitLab From 77ac6379f479db5728140d39734d9f15849e86be Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 12 Dec 2024 16:11:48 +0100 Subject: [PATCH 003/329] make fname() visible without DEUBG_MODE_INFO on --- lib_debug/debug.c | 4 ++-- lib_debug/debug.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_debug/debug.c b/lib_debug/debug.c index 2608be30a..8053a7cd9 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -758,7 +758,7 @@ int16_t tweakdbgfolder( const char *filename, char *filename_mod, int16_t *textm #endif -#ifdef DEBUG_MODE_INFO +#ifdef DEBUGGING /*-------------------------------------------------------------------* * fname() * @@ -781,7 +781,7 @@ char *fname( char idd[5] = ".idX"; idd[3] = (char) ( id + '0' ); #ifdef DEBUG_FORCE_DIR - short len; + size_t len; #endif strcpy( tmp_fname, dir ); diff --git a/lib_debug/debug.h b/lib_debug/debug.h index c1c978bfe..92c510147 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -60,7 +60,7 @@ extern int16_t debug_level; #define DEBUG_LINE( level ) if ( 0 ) #endif -#ifdef DEBUG_MODE_INFO +#ifdef DEBUGGING extern char tmp_fname[]; extern char debug_dir[6]; char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec ); -- GitLab From e9efb892b162fba6f6460c736a62c84c0efb8697 Mon Sep 17 00:00:00 2001 From: det Date: Mon, 13 Jan 2025 12:00:06 +0100 Subject: [PATCH 004/329] patched MR1266 into basop. --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a914c8e66..ecfe2d6ab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/ +#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ #define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX #define FIX_ISSUE_987 diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d69fa8525..d4ac66dcf 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3259,7 +3259,11 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); +#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA + if ( EQ_16( num_tc, 3 ) ) +#else if ( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) +#endif { num_tc = add( num_tc, 1 ); } -- GitLab From 388defeea77b1a6b83415d30b027fd742b0856ca Mon Sep 17 00:00:00 2001 From: det Date: Mon, 13 Jan 2025 15:41:26 +0100 Subject: [PATCH 005/329] merged MR1251 into basop. --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a914c8e66..5d8f7fbee 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,5 +101,6 @@ #define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */ #define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */ #define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/ +#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d69fa8525..70b4c2699 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2669,7 +2669,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( hTcBuffer->n_samples_buffered = add( hTcBuffer->n_samples_granularity, n_samples_still_available ); hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_flushed = n_samples_to_render; -#ifdef CR_FIX_JBM_FLUSH_OFFSET +#ifdef NONBE_FIX_855_JBM_FLUSH_OFFSET hTcBuffer->n_samples_rendered = 0; #else hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; @@ -2855,7 +2855,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } -#ifdef CR_FIX_JBM_FLUSH_OFFSET +#ifdef NONBE_FIX_855_JBM_FLUSH_OFFSET hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; #endif } -- GitLab From d9b02f271b8b02363a16bb8ba6a92d8ab25a32c5 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 14 Jan 2025 10:37:45 +0100 Subject: [PATCH 006/329] make read/write operations exclusive --- lib_enc/ivas_core_pre_proc_front.c | 30 +++++++++++++++++++----------- lib_enc/ivas_decision_matrix_enc.c | 6 ++++-- lib_enc/ivas_stereo_classifier.c | 6 ++++-- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index b9e72f8fa..74af17216 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -825,12 +825,14 @@ ivas_error pre_proc_front_ivas_fx( move16(); #ifdef DEBUG_FORCE_DIR - dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); - if ( st->force_dir[0] != '\0' ) { dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); } + else + { + dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); + } #endif test(); @@ -911,12 +913,14 @@ ivas_error pre_proc_front_ivas_fx( } #ifdef DEBUG_FORCE_DIR - dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); - if ( st->force_dir[0] != '\0' ) { dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); } + else + { + dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); + } #endif @@ -1511,12 +1515,14 @@ ivas_error pre_proc_front_ivas_fx( smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ #ifdef DEBUG_FORCE_DIR - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); - if ( st->force_dir[0] != '\0' ) { dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); } + else + { + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); + } #endif #ifdef DEBUGGING @@ -1726,11 +1732,6 @@ ivas_error pre_proc_front_ivas_fx( } #ifdef DEBUG_FORCE_DIR - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); - dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); - dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); - dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); - if ( st->force_dir[0] != '\0' ) { dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); @@ -1738,6 +1739,13 @@ ivas_error pre_proc_front_ivas_fx( dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); } + else + { + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); + dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); + dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); + dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); + } #endif /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index b46361fc2..cb3248b93 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -256,12 +256,14 @@ void ivas_decision_matrix_enc_fx( #endif #ifdef DEBUG_FORCE_DIR - dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core.enf" ); - if ( st->force_dir[0] != '\0' ) { dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core.enf", -1, -1, -1 ) ); } + else + { + dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core.enf" ); + } #endif /* TCX not available at low bitrates -> replace it by GSC */ diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 8391d99a2..96754c97d 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -218,12 +218,14 @@ Word16 select_stereo_mode( } #ifdef DEBUG_FORCE_DIR - dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) { dbgread( &element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); } + else + { + dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); + } #endif /* switch from LRTD to DFT when xtalk_decision goes from 0->1 (note: this special case is not handled in the xtalk classifier) */ -- GitLab From ebc2a47326dd706b0e4b2c7d97306908516a7560 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 14 Jan 2025 10:43:42 +0100 Subject: [PATCH 007/329] force_element_mode.enf - read/write info in frame 0 --- lib_enc/ivas_cpe_enc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index e93d3caa0..7b7ab41bf 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -263,6 +263,19 @@ ivas_error ivas_cpe_enc_fx( { hCPE->element_mode = select_stereo_mode( hCPE, ivas_format ); /* Q0 */ } +#ifdef DEBUG_FORCE_DIR + else + { + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hCPE->element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); + } + } +#endif stereo_mode_combined_format_enc_fx( st_ivas, hCPE ); -- GitLab From 7611d58044dcbc5c657024208c4d55c6801342f2 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 14 Jan 2025 15:56:11 +0100 Subject: [PATCH 008/329] fix the I/O interface --- apps/encoder.c | 3 +++ lib_enc/ivas_decision_matrix_enc.c | 26 ++++++++++++++++++++++++++ lib_enc/lib_enc.c | 4 ++-- lib_enc/lib_enc.h | 4 ++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 4e7d55bce..36ba0bcd7 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -149,6 +149,9 @@ typedef struct #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode; const char *forcedModeFile; +#ifdef DEBUG_FORCE_DIR + const char *forcedModeDir; +#endif #endif bool pca; bool ism_extended_metadata; diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index cb3248b93..08ce3cd21 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -354,6 +354,19 @@ void ivas_decision_matrix_enc_fx( } } } + +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->extl, sizeof( int16_t ), 1, fname( st->force_dir, "force_extl.enf", -1, -1, -1 ) ); + dbgread( &st->extl_brate, sizeof( int32_t ), 1, fname( st->force_dir, "force_extl_brate.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->extl, sizeof( int16_t ), 1, 1, "res/force_extl.enf" ); + dbgwrite( &st->extl_brate, sizeof( int32_t ), 1, 1, "res/force_extl_brate.enf" ); + } +#endif } /* SWB and FB */ @@ -451,6 +464,19 @@ void ivas_decision_matrix_enc_fx( move32(); } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->extl, sizeof( int16_t ), 1, fname( st->force_dir, "force_extl.enf", -1, -1, -1 ) ); + dbgread( &st->extl_brate, sizeof( int32_t ), 1, fname( st->force_dir, "force_extl_brate.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->extl, sizeof( int16_t ), 1, 1, "res/force_extl.enf" ); + dbgwrite( &st->extl_brate, sizeof( int32_t ), 1, 1, "res/force_extl_brate.enf" ); + } +#endif + /* set IC-BWE bitrate */ test(); test(); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 63efaafb8..26fc04a5e 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1888,7 +1888,7 @@ ivas_error IVAS_ENC_SetForcedMode( } #ifdef DEBUG_FORCE_DIR - if ( forcedModeDir == NULL ) + if ( forcedMode < IVAS_ENC_FORCE_FILE ) { hIvasEnc->st_ivas->hEncoderConfig->force_dir[0] = '\0'; @@ -1903,7 +1903,7 @@ ivas_error IVAS_ENC_SetForcedMode( hIvasEnc->switchingActive = true; } } - else + else if ( forcedMode == IVAS_ENC_FORCE_DIR ) { strcpy( hIvasEnc->st_ivas->hEncoderConfig->force_dir, forcedModeDir ); hIvasEnc->st_ivas->hEncoderConfig->force = IVAS_ENC_FORCE_UNFORCED; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 09262079b..69f794b69 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -129,6 +129,10 @@ typedef enum _IVAS_ENC_FORCED_MODE IVAS_ENC_FORCE_GSC, IVAS_ENC_FORCE_TCX, IVAS_ENC_FORCE_HQ, +#ifdef DEBUG_FORCE_DIR + IVAS_ENC_FORCE_FILE, + IVAS_ENC_FORCE_DIR, +#endif IVAS_ENC_FORCE_UNFORCED, IVAS_ENC_FORCE_UNDEFINED = 0xffff } IVAS_ENC_FORCED_MODE; -- GitLab From ffeb27b7a9395e71b2d08ef43af6d9c4373fae0a Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:13:32 +0100 Subject: [PATCH 009/329] increased accuracy for mixing matrix calculation by using seperate scalefactors for ref_power and cx_diag for each freq band (to avoid holes especially in the upper freq band region) --- lib_dec/ivas_ism_param_dec.c | 91 ++++++++++++------------------------ 1 file changed, 31 insertions(+), 60 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 9514e5e2a..5eaae88fe 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -177,25 +177,17 @@ static void ivas_param_ism_collect_slot_fx( Word16 exp_imag, const Word16 ch, Word32 ref_power_fx[], /*Q(31-exp_ref_power)*/ - Word16 *exp_ref_power, + Word16 exp_ref_power[], Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-exp_cx_diag)*/ - Word16 *exp_cx_diag ) + Word16 exp_cx_diag[][PARAM_ISM_MAX_DMX] ) { Word16 band_idx, bin_idx; Word16 brange[2]; Word32 tmp_fx; Word16 exp_tmp; - Word16 i, j; /* loop over parameter bands to collect transport channel energies */ - Word16 exp_ref_power_buf[CLDFB_NO_CHANNELS_MAX]; - Word16 exp_cx_diag_buf[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; - set16_fx( exp_ref_power_buf, *exp_ref_power, CLDFB_NO_CHANNELS_MAX ); - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - set16_fx( exp_cx_diag_buf[i], *exp_cx_diag, PARAM_ISM_MAX_DMX ); - } FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; @@ -216,50 +208,19 @@ static void ivas_param_ism_collect_slot_fx( Word16 exp_cx_diag_new = 0, exp_ref_power_new = 0; move16(); move16(); - cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag_buf[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new ); + cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new ); move32(); - ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], exp_ref_power_buf[bin_idx], tmp_fx, exp_tmp, &exp_ref_power_new ); + ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], exp_ref_power[bin_idx], tmp_fx, exp_tmp, &exp_ref_power_new ); move32(); - exp_cx_diag_buf[bin_idx][ch] = exp_cx_diag_new; + exp_cx_diag[bin_idx][ch] = exp_cx_diag_new; move16(); - exp_ref_power_buf[bin_idx] = exp_ref_power_new; + exp_ref_power[bin_idx] = exp_ref_power_new; move16(); } } - - /*make common exponent*/ - Word16 max_exp_cx_diag = exp_cx_diag_buf[0][0], max_exp_ref_power = exp_ref_power_buf[0]; - move16(); - move16(); - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - FOR( j = 0; j < PARAM_ISM_MAX_DMX; j++ ) - { - max_exp_cx_diag = s_max( max_exp_cx_diag, exp_cx_diag_buf[i][j] ); - } - max_exp_ref_power = s_max( max_exp_ref_power, exp_ref_power_buf[i] ); - } - - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - FOR( j = 0; j < PARAM_ISM_MAX_DMX; j++ ) - { - cx_diag_fx[i][j] = L_shr_r( cx_diag_fx[i][j], sub( max_exp_cx_diag, exp_cx_diag_buf[i][j] ) ); // Q(31-max_exp_cx_diag) - move32(); - } - ref_power_fx[i] = L_shr_r( ref_power_fx[i], sub( max_exp_ref_power, exp_ref_power_buf[i] ) ); // Q(31-max_exp_ref_power) - move16(); - } - - *exp_cx_diag = max_exp_cx_diag; - move16(); - *exp_ref_power = max_exp_ref_power; - move16(); - return; } - static void ivas_param_ism_compute_mixing_matrix_fx( const Word16 nchan_ism, /* i : number of ISM channels */ PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ @@ -268,9 +229,9 @@ static void ivas_param_ism_compute_mixing_matrix_fx( const Word16 nchan_transport, const Word16 nchan_out_woLFE, Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-cx_diag_e)*/ - Word16 cx_diag_e, + Word16 cx_diag_e[][PARAM_ISM_MAX_DMX], Word32 ref_power_fx[], /*Q(31-ref_power_e)*/ - Word16 ref_power_e, + Word16 ref_power_e[], Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-mixing_matrix_e)*/ Word16 mixing_matrix_e[CLDFB_NO_CHANNELS_MAX] ) { @@ -367,10 +328,10 @@ static void ivas_param_ism_compute_mixing_matrix_fx( } ELSE { - direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e) + direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e[bin_idx]) move32(); } - direct_power_e = ref_power_e; + direct_power_e = ref_power_e[bin_idx]; move16(); IF( direct_power_fx[w] != 0 ) { @@ -409,8 +370,20 @@ static void ivas_param_ism_compute_mixing_matrix_fx( move32(); } + /* equal cx diag exponents */ + Word16 max_exp_cx_diag = cx_diag_e[bin_idx][0]; + Word32 cx_diag_eq_exp_fx[PARAM_ISM_MAX_DMX]; + FOR( i = 1; i < PARAM_ISM_MAX_DMX; i++ ) + { + max_exp_cx_diag = s_max( max_exp_cx_diag, cx_diag_e[bin_idx][i] ); + } + FOR( i = 0; i < PARAM_ISM_MAX_DMX; i++ ) + { + cx_diag_eq_exp_fx[i] = L_shr_r( cx_diag_fx[bin_idx][i], sub( max_exp_cx_diag, cx_diag_e[bin_idx][i] ) ); // Q(31-max_exp_cx_diag) + } + /* Compute mixing matrix */ - computeMixingMatricesISM_fx( nchan_transport, num_wave, nchan_out_woLFE, response_matrix_fx, response_matrix_e, direct_power_fx, direct_power_e, cx_diag_fx[bin_idx], cx_diag_e, cy_diag_fx, cy_diag_e, proto_matrix_fx, 1, + computeMixingMatricesISM_fx( nchan_transport, num_wave, nchan_out_woLFE, response_matrix_fx, response_matrix_e, direct_power_fx, direct_power_e, cx_diag_eq_exp_fx, max_exp_cx_diag, cy_diag_fx, cy_diag_e, proto_matrix_fx, 1, PARAM_MC_REG_SX_FX, PARAM_MC_REG_GHAT_FX, mixing_matrix_fx[bin_idx], &mixing_matrix_e[bin_idx] ); } } @@ -1070,7 +1043,6 @@ void ivas_param_ism_dec_digest_tc_fx( Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output q_tc_in*/ Word16 q_tc_in ) { - Word16 exp_ref_power = 31, exp_cx_diag = 31; Word16 exp_real_tmp = 0, exp_imag_tmp = 0; move16(); move16(); @@ -1078,6 +1050,9 @@ void ivas_param_ism_dec_digest_tc_fx( move16(); Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX]; Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 exp_ref_power[CLDFB_NO_CHANNELS_MAX]; + Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 q_tc = q_tc_in; move16(); Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i; @@ -1132,15 +1107,11 @@ void ivas_param_ism_dec_digest_tc_fx( ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); /* set buffers to zero */ - FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) - { - set_zero_fx( cx_diag_fx[bin_idx], PARAM_ISM_MAX_DMX ); - } - exp_cx_diag = 0; - move16(); + set_zero_fx(&cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX); + set16_zero_fx(&exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX); + set_zero_fx( ref_power_fx, CLDFB_NO_CHANNELS_MAX ); - exp_ref_power = 0; - move16(); + set16_zero_fx(&exp_ref_power[0], CLDFB_NO_CHANNELS_MAX); /* Frame-level Processing */ /* De-quantization */ @@ -1269,7 +1240,7 @@ void ivas_param_ism_dec_digest_tc_fx( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], exp_imag_tmp, ch, - ref_power_fx, &exp_ref_power, cx_diag_fx, &exp_cx_diag ); + ref_power_fx, exp_ref_power, cx_diag_fx, exp_cx_diag ); exp_real_tmp = add( exp_real_tmp, scale_factor_real ); exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag ); -- GitLab From d9b2947a16fb0a0730687088c92cfc13f181b001 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:26:20 +0100 Subject: [PATCH 010/329] complexity reductions --- lib_dec/ivas_ism_param_dec.c | 65 +++++++++++++++++------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 5eaae88fe..10f384638 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -176,8 +176,6 @@ static void ivas_param_ism_collect_slot_fx( Word32 *Cldfb_ImagBuffer_in_fx, /*Q(31-exp_imag)*/ Word16 exp_imag, const Word16 ch, - Word32 ref_power_fx[], /*Q(31-exp_ref_power)*/ - Word16 exp_ref_power[], Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-exp_cx_diag)*/ Word16 exp_cx_diag[][PARAM_ISM_MAX_DMX] ) { @@ -205,17 +203,13 @@ static void ivas_param_ism_collect_slot_fx( tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var1, add( exp_real, exp_real ), &exp_tmp ); tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var2, add( exp_imag, exp_imag ), &exp_tmp ); - Word16 exp_cx_diag_new = 0, exp_ref_power_new = 0; + Word16 exp_cx_diag_new; move16(); move16(); cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new ); move32(); - ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], exp_ref_power[bin_idx], tmp_fx, exp_tmp, &exp_ref_power_new ); - move32(); exp_cx_diag[bin_idx][ch] = exp_cx_diag_new; move16(); - exp_ref_power[bin_idx] = exp_ref_power_new; - move16(); } } return; @@ -230,8 +224,6 @@ static void ivas_param_ism_compute_mixing_matrix_fx( const Word16 nchan_out_woLFE, Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-cx_diag_e)*/ Word16 cx_diag_e[][PARAM_ISM_MAX_DMX], - Word32 ref_power_fx[], /*Q(31-ref_power_e)*/ - Word16 ref_power_e[], Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-mixing_matrix_e)*/ Word16 mixing_matrix_e[CLDFB_NO_CHANNELS_MAX] ) { @@ -304,6 +296,27 @@ static void ivas_param_ism_compute_mixing_matrix_fx( set32_fx( cy_diag_fx, 0, nchan_out_woLFE ); set16_fx( cy_diag_e_arr, 0, nchan_out_woLFE ); + + /* equal cx diag exponents, compute ref power from cx_diag*/ + Word16 max_exp_cx_diag; + Word32 cx_diag_eq_exp_fx[PARAM_ISM_MAX_DMX]; + Word32 ref_power_fx; + Word16 ref_power_e, ref_power_e_new; + ref_power_fx = cx_diag_fx[bin_idx][0]; + ref_power_e = cx_diag_e[bin_idx][0]; + + FOR( i = 1; i < PARAM_ISM_MAX_DMX; i++ ) + { + ref_power_fx = BASOP_Util_Add_Mant32Exp( ref_power_fx, ref_power_e, cx_diag_fx[bin_idx][i], cx_diag_e[bin_idx][i], &ref_power_e_new ); + ref_power_e = ref_power_e_new; + } + max_exp_cx_diag = ref_power_e; + FOR( i = 0; i < PARAM_ISM_MAX_DMX; i++ ) + { + cx_diag_eq_exp_fx[i] = L_shr_r( cx_diag_fx[bin_idx][i], sub( max_exp_cx_diag, cx_diag_e[bin_idx][i] ) ); // Q(31-max_exp_cx_diag) + } + + FOR( w = 0; w < num_wave; w++ ) { test(); @@ -313,25 +326,26 @@ static void ivas_param_ism_compute_mixing_matrix_fx( SWITCH( nchan_ism ) { case 2: - direct_power_fx[w] = L_shr_r( ref_power_fx[bin_idx], 1 ); + direct_power_fx[w] = L_shr_r( ref_power_fx, 1 ); move32(); BREAK; case 3: - direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], 10923 ); // 10923 = 1/3f in Q15 + direct_power_fx[w] = Mpy_32_16_1( ref_power_fx, 10923 ); // 10923 = 1/3f in Q15 move32(); BREAK; case 4: - direct_power_fx[w] = L_shr_r( ref_power_fx[bin_idx], 2 ); + direct_power_fx[w] = L_shr_r( ref_power_fx, 2 ); move32(); BREAK; } } ELSE { - direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e[bin_idx]) + direct_power_fx[w] = Mpy_32_16_1( ref_power_fx, hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e[bin_idx]) move32(); } - direct_power_e = ref_power_e[bin_idx]; + //direct_power_e = ref_power_e[bin_idx]; + direct_power_e = ref_power_e; move16(); IF( direct_power_fx[w] != 0 ) { @@ -370,18 +384,6 @@ static void ivas_param_ism_compute_mixing_matrix_fx( move32(); } - /* equal cx diag exponents */ - Word16 max_exp_cx_diag = cx_diag_e[bin_idx][0]; - Word32 cx_diag_eq_exp_fx[PARAM_ISM_MAX_DMX]; - FOR( i = 1; i < PARAM_ISM_MAX_DMX; i++ ) - { - max_exp_cx_diag = s_max( max_exp_cx_diag, cx_diag_e[bin_idx][i] ); - } - FOR( i = 0; i < PARAM_ISM_MAX_DMX; i++ ) - { - cx_diag_eq_exp_fx[i] = L_shr_r( cx_diag_fx[bin_idx][i], sub( max_exp_cx_diag, cx_diag_e[bin_idx][i] ) ); // Q(31-max_exp_cx_diag) - } - /* Compute mixing matrix */ computeMixingMatricesISM_fx( nchan_transport, num_wave, nchan_out_woLFE, response_matrix_fx, response_matrix_e, direct_power_fx, direct_power_e, cx_diag_eq_exp_fx, max_exp_cx_diag, cy_diag_fx, cy_diag_e, proto_matrix_fx, 1, PARAM_MC_REG_SX_FX, PARAM_MC_REG_GHAT_FX, mixing_matrix_fx[bin_idx], &mixing_matrix_e[bin_idx] ); @@ -1048,9 +1050,7 @@ void ivas_param_ism_dec_digest_tc_fx( move16(); move16(); move16(); - Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; - Word16 exp_ref_power[CLDFB_NO_CHANNELS_MAX]; + Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 q_tc = q_tc_in; @@ -1110,9 +1110,6 @@ void ivas_param_ism_dec_digest_tc_fx( set_zero_fx(&cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX); set16_zero_fx(&exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX); - set_zero_fx( ref_power_fx, CLDFB_NO_CHANNELS_MAX ); - set16_zero_fx(&exp_ref_power[0], CLDFB_NO_CHANNELS_MAX); - /* Frame-level Processing */ /* De-quantization */ test(); @@ -1240,7 +1237,7 @@ void ivas_param_ism_dec_digest_tc_fx( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], exp_imag_tmp, ch, - ref_power_fx, exp_ref_power, cx_diag_fx, exp_cx_diag ); + cx_diag_fx, exp_cx_diag ); exp_real_tmp = add( exp_real_tmp, scale_factor_real ); exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag ); @@ -1255,7 +1252,7 @@ void ivas_param_ism_dec_digest_tc_fx( } /* Compute mixing matrix */ - ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, ref_power_fx, exp_ref_power, + ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx ); pop_wmops(); -- GitLab From d86fd6130c852a67591e3fcf320433f11a4a3956 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Thu, 23 Jan 2025 09:20:03 +0100 Subject: [PATCH 011/329] clang format --- lib_dec/ivas_ism_param_dec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 10f384638..c7fce8dd5 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -344,7 +344,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( direct_power_fx[w] = Mpy_32_16_1( ref_power_fx, hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e[bin_idx]) move32(); } - //direct_power_e = ref_power_e[bin_idx]; + // direct_power_e = ref_power_e[bin_idx]; direct_power_e = ref_power_e; move16(); IF( direct_power_fx[w] != 0 ) @@ -1050,8 +1050,8 @@ void ivas_param_ism_dec_digest_tc_fx( move16(); move16(); move16(); - Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; - Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 q_tc = q_tc_in; move16(); @@ -1107,8 +1107,8 @@ void ivas_param_ism_dec_digest_tc_fx( ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); /* set buffers to zero */ - set_zero_fx(&cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX); - set16_zero_fx(&exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX); + set_zero_fx( &cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); + set16_zero_fx( &exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); /* Frame-level Processing */ /* De-quantization */ -- GitLab From b9a68dac1db96f835c597b26b4cc05ce49219174 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 23 Jan 2025 16:49:02 +0100 Subject: [PATCH 012/329] Add manual job for PEAQ encoder passthrough --- .gitlab-ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f62acb284..f9c890019 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,6 +47,7 @@ variables: - 'complexity' - 'coverage' - 'voip-be-test' + - 'peaq-enc-passthrough' default: @@ -95,6 +96,9 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'voip-be-test' variables: IVAS_PIPELINE_NAME: 'Voip BE test on $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough' + variables: + IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch variables: IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH' @@ -1172,6 +1176,16 @@ ivas-pytest-renderer: - LEVEL_SCALING=1.0 <<: *ivas-pytest-anchor +peaq-enc-passthrough: + extends: + - .test-job-linux + rules: + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "peaq-enc-passthrough" + before_script: + - USE_LTV=0 + - TEST_SUITE="tests/test_enc_passthrough.py" + - LEVEL_SCALING=1.0 + <<: *ivas-pytest-anchor # --------------------------------------------------------------- # Various other tests -- GitLab From 5c80b92c1fb1f92bcfa72e03d08e28c7627559bf Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 23 Jan 2025 19:49:19 +0100 Subject: [PATCH 013/329] Fix in peaq-enc-passthrough --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9c890019..9a9e1efb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1183,6 +1183,7 @@ peaq-enc-passthrough: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "peaq-enc-passthrough" before_script: - USE_LTV=0 + - DUT_DECODER_PATH=./$REF_DECODER_PATH - TEST_SUITE="tests/test_enc_passthrough.py" - LEVEL_SCALING=1.0 <<: *ivas-pytest-anchor -- GitLab From b06dc172319fbc2082c1e6b26ccd99f592f72de9 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 28 Jan 2025 12:33:30 +1100 Subject: [PATCH 014/329] SR BASOP ivas decoder and apps, not compiling yet --- Workspace_msvc/isar_post_rend.vcxproj | 179 + Workspace_msvc/lib_isar.vcxproj | 202 + Workspace_msvc/lib_lc3plus.vcxproj | 195 + apps/decoder.c | 485 +- apps/isar_post_rend.c | 1262 ++ apps/renderer.c | 553 +- lib_com/cldfb.c | 1 - lib_com/cnst.h | 3 + lib_com/common_api_types.h | 128 + lib_com/ivas_error.h | 16 + {lib_rend => lib_com}/ivas_limiter.c | 0 lib_com/ivas_prot.h | 1 + lib_com/ivas_prot_fx.h | 101 +- lib_com/ivas_rotation_com.c | 270 + lib_com/options.h | 6 + lib_dec/ivas_binRenderer_internal.c | 95 +- lib_dec/ivas_dirac_dec.c | 116 +- lib_dec/ivas_init_dec.c | 311 +- lib_dec/ivas_ism_dec.c | 31 +- lib_dec/ivas_ism_param_dec.c | 18 +- lib_dec/ivas_jbm_dec.c | 147 +- lib_dec/ivas_masa_dec.c | 48 + lib_dec/ivas_mc_param_dec.c | 52 + lib_dec/ivas_mc_paramupmix_dec.c | 61 + lib_dec/ivas_mct_dec.c | 40 +- lib_dec/ivas_objectRenderer_internal.c | 155 + lib_dec/ivas_omasa_dec.c | 74 +- lib_dec/ivas_osba_dec.c | 73 +- lib_dec/ivas_output_config.c | 42 +- lib_dec/ivas_sba_dec.c | 40 +- lib_dec/ivas_spar_decoder.c | 6 +- lib_dec/ivas_stat_dec.h | 46 +- lib_isar/isar_MSPred.c | 550 + lib_isar/isar_NoiseGen.c | 58 + lib_isar/isar_PerceptualModel.c | 469 + lib_isar/isar_PredDecoder.c | 496 + lib_isar/isar_PredEncoder.c | 1215 + lib_isar/isar_RMSEnvGrouping.c | 964 + lib_isar/isar_cnst.h | 159 + lib_isar/isar_lc3plus_common.c | 89 + lib_isar/isar_lc3plus_common.h | 72 + lib_isar/isar_lc3plus_dec.c | 857 + lib_isar/isar_lc3plus_dec.h | 136 + lib_isar/isar_lc3plus_enc.c | 697 + lib_isar/isar_lc3plus_enc.h | 104 + lib_isar/isar_lc3plus_payload.c | 823 + lib_isar/isar_lc3plus_payload.h | 216 + lib_isar/isar_lcld_decoder.c | 1993 ++ lib_isar/isar_lcld_encoder.c | 2143 ++ lib_isar/isar_lcld_prot.h | 457 + lib_isar/isar_lcld_rom_tables.c | 21207 ++++++++++++++++++ lib_isar/isar_lcld_rom_tables.h | 245 + lib_isar/isar_prot.h | 465 + lib_isar/isar_rom_post_rend.c | 196 + lib_isar/isar_rom_post_rend.h | 82 + lib_isar/isar_splitRend_lcld_dec.c | 284 + lib_isar/isar_splitRend_lcld_enc.c | 239 + lib_isar/isar_splitRendererPLC.c | 1316 ++ lib_isar/isar_splitRendererPost.c | 2131 ++ lib_isar/isar_splitRendererPre.c | 3469 +++ lib_isar/isar_splitRenderer_utils.c | 1741 ++ lib_isar/isar_stat.h | 267 + lib_isar/lib_isar_post_rend.c | 1913 ++ lib_isar/lib_isar_post_rend.h | 225 + lib_isar/lib_isar_pre_rend.c | 626 + lib_isar/lib_isar_pre_rend.h | 92 + lib_lc3plus/.clang-format | 2 + lib_lc3plus/adjust_global_gain_fx.c | 186 + lib_lc3plus/al_fec.c | 2379 ++ lib_lc3plus/apply_global_gain_fx.c | 66 + lib_lc3plus/ari_codec.c | 2465 ++ lib_lc3plus/attack_detector_fx.c | 119 + lib_lc3plus/basop_mpy_lc3plus.c | 99 + lib_lc3plus/basop_mpy_lc3plus.h | 94 + lib_lc3plus/basop_util_lc3plus.c | 1069 + lib_lc3plus/basop_util_lc3plus.h | 377 + lib_lc3plus/constants.c | 5046 +++++ lib_lc3plus/constants.h | 402 + lib_lc3plus/cutoff_bandwidth.c | 26 + lib_lc3plus/dct2_fx.c | 473 + lib_lc3plus/dct4_fx.c | 228 + lib_lc3plus/dec_entropy.c | 387 + lib_lc3plus/dec_lc3.c | 788 + lib_lc3plus/defines.h | 734 + lib_lc3plus/detect_cutoff_warped_fx.c | 124 + lib_lc3plus/dynmem.c | 288 + lib_lc3plus/dynmem.h | 80 + lib_lc3plus/enc_entropy.c | 173 + lib_lc3plus/enc_lc3.c | 680 + lib_lc3plus/estimate_global_gain_fx.c | 506 + lib_lc3plus/fft_lc3plus.c | 4537 ++++ lib_lc3plus/functions.h | 836 + lib_lc3plus/imdct_fx.c | 387 + lib_lc3plus/lc3.c | 426 + lib_lc3plus/lc3.h | 520 + lib_lc3plus/levinson_fx.c | 160 + lib_lc3plus/license.h | 21 + lib_lc3plus/ltpf_coder_fx.c | 323 + lib_lc3plus/ltpf_decoder_fx.c | 394 + lib_lc3plus/makefile | 180 + lib_lc3plus/mdct_fx.c | 223 + lib_lc3plus/mdct_shaping_fx.c | 74 + lib_lc3plus/near_nyquist_detector_fx.c | 141 + lib_lc3plus/noise_factor_fx.c | 252 + lib_lc3plus/noise_filling_fx.c | 149 + lib_lc3plus/olpa_fx.c | 289 + lib_lc3plus/pc_apply_fx.c | 315 + lib_lc3plus/pc_classify_fx.c | 260 + lib_lc3plus/pc_main_fx.c | 57 + lib_lc3plus/pc_update_fx.c | 148 + lib_lc3plus/per_band_energy_fx.c | 275 + lib_lc3plus/plc_apply_fx.c | 419 + lib_lc3plus/plc_classify_fx.c | 424 + lib_lc3plus/plc_damping_scrambling_fx.c | 430 + lib_lc3plus/plc_lpc_scaling_fx.c | 36 + lib_lc3plus/plc_main_fx.c | 85 + lib_lc3plus/plc_noise_substitution_fx.c | 32 + lib_lc3plus/plc_phecu_f0_refine_first_fx.c | 100 + lib_lc3plus/plc_phecu_fec_hq_fx.c | 3157 +++ lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c | 202 + lib_lc3plus/plc_phecu_peak_locator_fx.c | 385 + lib_lc3plus/plc_phecu_setf0hz_fx.c | 60 + lib_lc3plus/plc_phecu_tools_fx.c | 247 + lib_lc3plus/plc_tdac_fx.c | 217 + lib_lc3plus/plc_tdc_inverse_odft_fx.c | 130 + lib_lc3plus/plc_tdc_lagwin_fx.c | 32 + lib_lc3plus/plc_tdc_main_fx.c | 1257 ++ lib_lc3plus/plc_tdc_pre_emphasis_fx.c | 95 + lib_lc3plus/plc_update_aft_imdct_fx.c | 343 + lib_lc3plus/plc_update_fx.c | 224 + lib_lc3plus/plc_xcorr_fx.c | 250 + lib_lc3plus/pvq_dec_fx.c | 153 + lib_lc3plus/pvq_enc_fx.c | 369 + lib_lc3plus/pvq_index_fx.c | 513 + lib_lc3plus/quantize_spec_fx.c | 1167 + lib_lc3plus/reorder_bitstream_fx.c | 56 + lib_lc3plus/resamp12k8_fx.c | 121 + lib_lc3plus/residual_coding_fx.c | 238 + lib_lc3plus/residual_decoding_fx.c | 207 + lib_lc3plus/rom_basop_util.c | 2904 +++ lib_lc3plus/rom_basop_util.h | 172 + lib_lc3plus/scale_signal24_fx.c | 121 + lib_lc3plus/setup_dec_lc3.c | 539 + lib_lc3plus/setup_dec_lc3.h | 185 + lib_lc3plus/setup_enc_lc3.c | 760 + lib_lc3plus/setup_enc_lc3.h | 131 + lib_lc3plus/sns_compute_scf_fx.c | 166 + lib_lc3plus/sns_interpolate_scf_fx.c | 154 + lib_lc3plus/sns_quantize_scf_fx.c | 834 + lib_lc3plus/tinywavein_c.h | 603 + lib_lc3plus/tinywaveout_c.h | 889 + lib_lc3plus/tns_coder_fx.c | 378 + lib_lc3plus/tns_decoder_fx.c | 150 + lib_rend/ivas_prot_rend.h | 66 - lib_rend/ivas_rotation.c | 47 - lib_rend/ivas_stat_rend.h | 7 + lib_rend/lib_rend.h | 14 - 157 files changed, 96362 insertions(+), 218 deletions(-) create mode 100644 Workspace_msvc/isar_post_rend.vcxproj create mode 100644 Workspace_msvc/lib_isar.vcxproj create mode 100644 Workspace_msvc/lib_lc3plus.vcxproj create mode 100644 apps/isar_post_rend.c rename {lib_rend => lib_com}/ivas_limiter.c (100%) create mode 100644 lib_com/ivas_rotation_com.c create mode 100644 lib_isar/isar_MSPred.c create mode 100644 lib_isar/isar_NoiseGen.c create mode 100644 lib_isar/isar_PerceptualModel.c create mode 100644 lib_isar/isar_PredDecoder.c create mode 100644 lib_isar/isar_PredEncoder.c create mode 100644 lib_isar/isar_RMSEnvGrouping.c create mode 100644 lib_isar/isar_cnst.h create mode 100644 lib_isar/isar_lc3plus_common.c create mode 100644 lib_isar/isar_lc3plus_common.h create mode 100644 lib_isar/isar_lc3plus_dec.c create mode 100644 lib_isar/isar_lc3plus_dec.h create mode 100644 lib_isar/isar_lc3plus_enc.c create mode 100644 lib_isar/isar_lc3plus_enc.h create mode 100644 lib_isar/isar_lc3plus_payload.c create mode 100644 lib_isar/isar_lc3plus_payload.h create mode 100644 lib_isar/isar_lcld_decoder.c create mode 100644 lib_isar/isar_lcld_encoder.c create mode 100644 lib_isar/isar_lcld_prot.h create mode 100644 lib_isar/isar_lcld_rom_tables.c create mode 100644 lib_isar/isar_lcld_rom_tables.h create mode 100644 lib_isar/isar_prot.h create mode 100644 lib_isar/isar_rom_post_rend.c create mode 100644 lib_isar/isar_rom_post_rend.h create mode 100644 lib_isar/isar_splitRend_lcld_dec.c create mode 100644 lib_isar/isar_splitRend_lcld_enc.c create mode 100644 lib_isar/isar_splitRendererPLC.c create mode 100644 lib_isar/isar_splitRendererPost.c create mode 100644 lib_isar/isar_splitRendererPre.c create mode 100644 lib_isar/isar_splitRenderer_utils.c create mode 100644 lib_isar/isar_stat.h create mode 100644 lib_isar/lib_isar_post_rend.c create mode 100644 lib_isar/lib_isar_post_rend.h create mode 100644 lib_isar/lib_isar_pre_rend.c create mode 100644 lib_isar/lib_isar_pre_rend.h create mode 100644 lib_lc3plus/.clang-format create mode 100644 lib_lc3plus/adjust_global_gain_fx.c create mode 100644 lib_lc3plus/al_fec.c create mode 100644 lib_lc3plus/apply_global_gain_fx.c create mode 100644 lib_lc3plus/ari_codec.c create mode 100644 lib_lc3plus/attack_detector_fx.c create mode 100644 lib_lc3plus/basop_mpy_lc3plus.c create mode 100644 lib_lc3plus/basop_mpy_lc3plus.h create mode 100644 lib_lc3plus/basop_util_lc3plus.c create mode 100644 lib_lc3plus/basop_util_lc3plus.h create mode 100644 lib_lc3plus/constants.c create mode 100644 lib_lc3plus/constants.h create mode 100644 lib_lc3plus/cutoff_bandwidth.c create mode 100644 lib_lc3plus/dct2_fx.c create mode 100644 lib_lc3plus/dct4_fx.c create mode 100644 lib_lc3plus/dec_entropy.c create mode 100644 lib_lc3plus/dec_lc3.c create mode 100644 lib_lc3plus/defines.h create mode 100644 lib_lc3plus/detect_cutoff_warped_fx.c create mode 100644 lib_lc3plus/dynmem.c create mode 100644 lib_lc3plus/dynmem.h create mode 100644 lib_lc3plus/enc_entropy.c create mode 100644 lib_lc3plus/enc_lc3.c create mode 100644 lib_lc3plus/estimate_global_gain_fx.c create mode 100644 lib_lc3plus/fft_lc3plus.c create mode 100644 lib_lc3plus/functions.h create mode 100644 lib_lc3plus/imdct_fx.c create mode 100644 lib_lc3plus/lc3.c create mode 100644 lib_lc3plus/lc3.h create mode 100644 lib_lc3plus/levinson_fx.c create mode 100644 lib_lc3plus/license.h create mode 100644 lib_lc3plus/ltpf_coder_fx.c create mode 100644 lib_lc3plus/ltpf_decoder_fx.c create mode 100644 lib_lc3plus/makefile create mode 100644 lib_lc3plus/mdct_fx.c create mode 100644 lib_lc3plus/mdct_shaping_fx.c create mode 100644 lib_lc3plus/near_nyquist_detector_fx.c create mode 100644 lib_lc3plus/noise_factor_fx.c create mode 100644 lib_lc3plus/noise_filling_fx.c create mode 100644 lib_lc3plus/olpa_fx.c create mode 100644 lib_lc3plus/pc_apply_fx.c create mode 100644 lib_lc3plus/pc_classify_fx.c create mode 100644 lib_lc3plus/pc_main_fx.c create mode 100644 lib_lc3plus/pc_update_fx.c create mode 100644 lib_lc3plus/per_band_energy_fx.c create mode 100644 lib_lc3plus/plc_apply_fx.c create mode 100644 lib_lc3plus/plc_classify_fx.c create mode 100644 lib_lc3plus/plc_damping_scrambling_fx.c create mode 100644 lib_lc3plus/plc_lpc_scaling_fx.c create mode 100644 lib_lc3plus/plc_main_fx.c create mode 100644 lib_lc3plus/plc_noise_substitution_fx.c create mode 100644 lib_lc3plus/plc_phecu_f0_refine_first_fx.c create mode 100644 lib_lc3plus/plc_phecu_fec_hq_fx.c create mode 100644 lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c create mode 100644 lib_lc3plus/plc_phecu_peak_locator_fx.c create mode 100644 lib_lc3plus/plc_phecu_setf0hz_fx.c create mode 100644 lib_lc3plus/plc_phecu_tools_fx.c create mode 100644 lib_lc3plus/plc_tdac_fx.c create mode 100644 lib_lc3plus/plc_tdc_inverse_odft_fx.c create mode 100644 lib_lc3plus/plc_tdc_lagwin_fx.c create mode 100644 lib_lc3plus/plc_tdc_main_fx.c create mode 100644 lib_lc3plus/plc_tdc_pre_emphasis_fx.c create mode 100644 lib_lc3plus/plc_update_aft_imdct_fx.c create mode 100644 lib_lc3plus/plc_update_fx.c create mode 100644 lib_lc3plus/plc_xcorr_fx.c create mode 100644 lib_lc3plus/pvq_dec_fx.c create mode 100644 lib_lc3plus/pvq_enc_fx.c create mode 100644 lib_lc3plus/pvq_index_fx.c create mode 100644 lib_lc3plus/quantize_spec_fx.c create mode 100644 lib_lc3plus/reorder_bitstream_fx.c create mode 100644 lib_lc3plus/resamp12k8_fx.c create mode 100644 lib_lc3plus/residual_coding_fx.c create mode 100644 lib_lc3plus/residual_decoding_fx.c create mode 100644 lib_lc3plus/rom_basop_util.c create mode 100644 lib_lc3plus/rom_basop_util.h create mode 100644 lib_lc3plus/scale_signal24_fx.c create mode 100644 lib_lc3plus/setup_dec_lc3.c create mode 100644 lib_lc3plus/setup_dec_lc3.h create mode 100644 lib_lc3plus/setup_enc_lc3.c create mode 100644 lib_lc3plus/setup_enc_lc3.h create mode 100644 lib_lc3plus/sns_compute_scf_fx.c create mode 100644 lib_lc3plus/sns_interpolate_scf_fx.c create mode 100644 lib_lc3plus/sns_quantize_scf_fx.c create mode 100644 lib_lc3plus/tinywavein_c.h create mode 100644 lib_lc3plus/tinywaveout_c.h create mode 100644 lib_lc3plus/tns_coder_fx.c create mode 100644 lib_lc3plus/tns_decoder_fx.c diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj new file mode 100644 index 000000000..19cb1aff7 --- /dev/null +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -0,0 +1,179 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + isar_post_rend + {12374ADC-0E5C-4FDD-B903-71D572413831} + isar_post_rend + 10.0.17763.0 + + + + Application + v141 + false + MultiByte + + + Application + v141 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + ISAR_post_rend + + + ..\ + .\Release_$(ProjectName)\ + false + false + ISAR_post_rend + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + true + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + libcmtd.lib + + + + + + + + + + {54509728-928B-44D9-A118-A6F92F08B34F} + false + + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + + + {2FA8F384-0775-F3B7-F8C3-85209222FC70} + false + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj new file mode 100644 index 000000000..c663ef5e7 --- /dev/null +++ b/Workspace_msvc/lib_isar.vcxproj @@ -0,0 +1,202 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + lib_isar + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} + evs_dec + 10.0.17763.0 + + + StaticLibrary + v141 + false + MultiByte + + + + StaticLibrary + v141 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + false + false + libivasrend + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + false + false + libivasrend + + + + + + + .\Debug\$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {54509728-928b-44d9-a118-a6f92f08b34f} + false + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj new file mode 100644 index 000000000..294677fff --- /dev/null +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -0,0 +1,195 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + Win32Proj + LC3_FL + 10.0.17763.0 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + liblc3plus + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + + + LC3plus + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\Obj\ + + + + + + Level3 + ..\lib_com;%(AdditionalIncludeDirectories) + Disabled + MultiThreadedDebug + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4305;4244;4996 + OldStyle + false + false + + + Console + true + + + + + Level3 + + + ..\lib_com;%(AdditionalIncludeDirectories) + MaxSpeed + MultiThreaded + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4244;4305;4996 + false + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/decoder.c b/apps/decoder.c index 058722569..65c949ace 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -43,6 +43,9 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "split_render_file_read_write.h" +#endif #include "vector3_pair_file_reader.h" #include "wmc_auto.h" #include "options.h" @@ -114,6 +117,9 @@ typedef struct Word16 non_diegetic_pan_gain_fx; /* Q15 */ bool renderConfigEnabled; char *renderConfigFilename; +#ifdef SPLIT_REND_WITH_HEAD_ROT + char *outputMdFilename; +#endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; @@ -130,7 +136,11 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); @@ -147,6 +157,10 @@ int main( bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ DecArguments arg; ivas_error error = IVAS_ERR_UNKNOWN; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_BITS_DATA splitRendBits; + uint8_t splitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; +#endif /* Any handles that require cleanup must be declared here and initialized to NULL */ IVAS_DEC_HANDLE hIvasDec = NULL; @@ -166,6 +180,10 @@ int main( reset_mem( USE_BYTES ); #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + splitRendBits.bits_buf = splitRendBitsBuf; +#endif + /*------------------------------------------------------------------------------------------* * Parse command-line arguments *------------------------------------------------------------------------------------------*/ @@ -212,6 +230,18 @@ int main( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + fprintf( stdout, "Output metadata file: %s\n", arg.outputWavFilename ); + } + else if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); + fprintf( stdout, "Output metadata file: %s\n", arg.outputMdFilename ); + } + else +#endif { fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); } @@ -245,7 +275,11 @@ int main( if ( arg.enableHeadRotation ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -345,7 +379,12 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 +#endif + ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -381,10 +420,29 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ + asked_frame_size = arg.renderFramesize; + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + arg.enableHeadRotation = true; + } +#endif /*------------------------------------------------------------------------------------------* * Configure VoIP mode @@ -410,11 +468,21 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && + arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); + goto cleanup; + } +#else if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { fprintf( stderr, "\nExternal Renderer Config is supported only for binaural output configurations. Exiting. \n\n" ); goto cleanup; } +#endif if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) { @@ -422,7 +490,6 @@ int main( goto cleanup; } - if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); @@ -441,6 +508,33 @@ int main( renderConfig.directivity_fx[i * 3 + 2] = (Word16) ( renderConfig.directivity[i * 3 + 2] * ( ( 1u << 15 ) - 1 ) ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && + ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) + { + arg.renderFramesize = asked_frame_size; + } + else + { + arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; + } + + if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( arg.renderFramesize != asked_frame_size ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); + } + } +#endif + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.acousticEnvironmentId, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) @@ -458,6 +552,13 @@ int main( } renderConfig.roomAcoustics.override = true; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; +#endif +#endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { @@ -568,13 +669,18 @@ int main( /*-----------------------------------------------------------------* * Decoding *-----------------------------------------------------------------*/ + if ( arg.voipMode ) { error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); } else { +#ifdef SPLIT_REND_WITH_HEAD_ROT + error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); +#else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); +#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -708,6 +814,16 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CODED" ) == 0 ) + { + output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } + else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_PCM" ) == 0 ) + { + output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; + } +#endif else if ( strcmp( argv_to_upper, "BINAURAL_ROOM_IR" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -775,6 +891,9 @@ static bool parseCmdlIVAS_dec( arg->renderConfigFilename = NULL; arg->Opt_dpid_on = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + arg->outputMdFilename = NULL; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; @@ -1022,6 +1141,19 @@ static bool parseCmdlIVAS_dec( } i += 2; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) + { + arg->outputMdFilename = argv[i + 1]; + if ( arg->outputMdFilename[0] == '\0' ) + { + fprintf( stderr, "Error: output metadata file path not specified\n\n" ); + usage_dec(); + return false; + } + i += 2; + } +#endif else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 ) { i++; @@ -1172,6 +1304,14 @@ static bool parseCmdlIVAS_dec( usage_dec(); return false; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( arg->outputMdFilename != NULL && arg->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + fprintf( stderr, "Error: Output split rendering metadata file is supported for BINAURAL_SPLIT_PCM output config. only\n\n" ); + usage_dec(); + return false; + } +#endif } else { @@ -1248,8 +1388,13 @@ static void usage_dec( void ) fprintf( stdout, "Mandatory parameters:\n" ); fprintf( stdout, "---------------------\n" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); + fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT\n" ); +#else fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); +#endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); fprintf( stdout, " layout file. See readme.txt for details.\n" ); @@ -1289,6 +1434,9 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); +#endif fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); fprintf( stdout, "-exof File : External orientation File for external orientation trajectory\n" ); @@ -1318,7 +1466,12 @@ static ivas_error initOnFirstGoodFrame( IVAS_DEC_HANDLE hIvasDec, /* i/o: */ const DecArguments arg, /* i : */ const int16_t numInitialBadFrames, /* i : */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t *numOutSamples, /* i/o: */ + int16_t *vec_pos_len, /* i/o: */ +#else const uint16_t numOutSamples, /* i : */ +#endif int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ int32_t *delayTimeScale, /* o : */ @@ -1327,7 +1480,12 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + uint16_t *pNumObj, /* o : */ + SplitFileReadWrite **splitRendWriter +#else uint16_t *pNumObj /* o : */ +#endif ) { ivas_error error = IVAS_ERR_UNKNOWN; @@ -1339,6 +1497,12 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + { + pFullDelayNumSamples[0] = 0; + } +#endif if ( !arg.delayCompensationEnabled ) { @@ -1360,22 +1524,149 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + { + /* Open split rendering metadata writer */ + int16_t delayNumSamples_temp[3]; + int32_t delayTimeScale_temp; + ISAR_SPLIT_REND_CODEC splitRendCodec; + int16_t splitRendCodecFrameSizeMs; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t splitRendIsarFrameSizeMs; + int16_t lc3plusHighRes; +#endif + + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + return error; + } + + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, + &splitRendCodec, + &poseCorrection, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + &splitRendIsarFrameSizeMs, +#endif + &splitRendCodecFrameSizeMs +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); + return error; + } + + if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) ) + { + if ( ( error = split_rend_writer_open( splitRendWriter, + arg.outputWavFilename, + delayNumSamples_temp[0], + delayTimeScale_temp, + splitRendCodec, + poseCorrection, + splitRendCodecFrameSizeMs +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + splitRendIsarFrameSizeMs, + arg.output_Fs, + lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); + return error; + } + } + else + { + if ( arg.outputMdFilename == NULL ) + { + fprintf( stderr, "\nOutput split rendering metadata file not specified\n" ); + return IVAS_ERR_INVALID_SPLIT_REND_CONFIG; + } + + if ( ( error = split_rend_writer_open( splitRendWriter, + arg.outputMdFilename, + delayNumSamples_temp[0], + delayTimeScale_temp, + splitRendCodec, + poseCorrection, + splitRendCodecFrameSizeMs +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + splitRendIsarFrameSizeMs, + arg.output_Fs, + lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); + return error; + } + } + } + + if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + { +#endif /* Open audio writer and write all previously skipped bad frames now that frame size is known */ if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *splitRendWriter != NULL ) + { + ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; + splitRendBitsZero.bits_buf = NULL; + splitRendBitsZero.bits_read = 0; + splitRendBitsZero.bits_written = 0; + splitRendBitsZero.buf_len = 0; + splitRendBitsZero.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRendBitsZero.pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + splitRendBitsZero.codec_frame_size_ms = 0; + splitRendBitsZero.isar_frame_size_ms = 20; +#else + splitRendBitsZero.codec_frame_size_ms = 20; +#endif + if ( split_rend_write_bitstream_to_file( *splitRendWriter, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); + return error; + } + } + else + { +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *pRemainingDelayNumSamples < *numOutSamples ) +#else if ( *pRemainingDelayNumSamples < numOutSamples ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nOutput audio file writer error\n" ); return error; @@ -1384,8 +1675,15 @@ static ivas_error initOnFirstGoodFrame( } else { +#ifdef SPLIT_REND_WITH_HEAD_ROT + *pRemainingDelayNumSamples -= *numOutSamples; +#else *pRemainingDelayNumSamples -= numOutSamples; +#endif + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } free( zeroBuf ); @@ -1452,6 +1750,7 @@ static ivas_error initOnFirstGoodFrame( { /* Duplicate good first frame metadata to fill the beginning of stream. */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL; + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -1470,6 +1769,27 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *splitRendWriter != NULL ) + { + if ( numOutSamples == NULL || vec_pos_len == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* real setting of the 5ms mode for split rendering is only known after the decoded first good frame, reset the variables needed in the main decoding loop accordingly here*/ + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, numOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + } +#endif return IVAS_ERR_OK; } @@ -1488,6 +1808,9 @@ static ivas_error decodeG192( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, +#endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -1514,7 +1837,9 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; - +#ifdef SPLIT_REND_WITH_HEAD_ROT + SplitFileReadWrite *splitRendWriter = NULL; +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { @@ -1612,18 +1937,42 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( i = 0; i < num_subframes; i++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( headRotReader == NULL ) { - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + for ( i = 0; i < num_subframes; i++ ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); - goto cleanup; + Quaternions[i].w = -3.0f; + Quaternions[i].x = 0.0f; + Quaternions[i].y = 0.0f; + Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; } } + else + { +#endif + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif for ( i = 0; i < num_subframes; i++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1681,14 +2030,38 @@ static ivas_error decodeG192( goto cleanup; } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + { + if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + } + else + { +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + +#else if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } nSamplesRendered += nSamplesRendered_loop; nSamplesToRender -= nSamplesRendered_loop; +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif if ( needNewFrame ) { @@ -1719,7 +2092,11 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } @@ -1733,6 +2110,19 @@ static ivas_error decodeG192( /* Write current frame */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + { + if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); + goto cleanup; + } + } + + if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + { +#endif if ( delayNumSamples < nOutSamples ) { if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) @@ -1746,6 +2136,9 @@ static ivas_error decodeG192( { delayNumSamples -= nOutSamples; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } /* Write ISm metadata to external file(s) */ @@ -1859,7 +2252,11 @@ static ivas_error decodeG192( goto cleanup; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1867,7 +2264,11 @@ static ivas_error decodeG192( } /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1979,11 +2380,18 @@ static ivas_error decodeG192( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( afWriter != NULL ) { - fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); - goto cleanup; +#endif + if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif /*------------------------------------------------------------------------------------------* * Close files and deallocate resources @@ -1993,6 +2401,9 @@ static ivas_error decodeG192( cleanup: +#ifdef SPLIT_REND_WITH_HEAD_ROT + split_rend_reader_writer_close( &splitRendWriter ); +#endif AudioFileWriter_close( &afWriter ); MasaFileWriter_close( &masaWriter ); for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) @@ -2239,19 +2650,44 @@ static ivas_error decodeVoIP( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( i = 0; i < num_subframes; i++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( headRotReader == NULL ) { - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + for ( i = 0; i < num_subframes; i++ ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( headRotReader ) ); - goto cleanup; + Quaternions[i].w = -3.0f; + Quaternions[i].x = 0.0f; + Quaternions[i].y = 0.0f; + Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; } } + else + { +#endif + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + DEFAULT_AXIS +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2339,10 +2775,18 @@ static ivas_error decodeVoIP( /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif +#else #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2379,8 +2823,15 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + SplitFileReadWrite *splitRendWriter = NULL; + + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, + &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c new file mode 100644 index 000000000..9a8d7c3ba --- /dev/null +++ b/apps/isar_post_rend.c @@ -0,0 +1,1262 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "lib_isar_post_rend.h" +//#undef IVAS_FLOAT_FIXED + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int main( int argc, char **argv ) +{ + (void) argc; + (void) argv; + ISAR_POST_REND_void_func(); + return 0; +} + +#else + +#include +#include +#include +#include "audio_file_reader.h" +#include "audio_file_writer.h" +#include "cmdl_tools.h" +#include "cmdln_parser.h" +#include "render_config_reader.h" +#include "rotation_file_reader.h" +#include "split_render_file_read_write.h" +#include "split_rend_bfi_file_reader.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "stl.h" +#include "wmc_auto.h" + + +#define WMC_TOOL_SKIP + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + +#define POST_REND_MAX_CLI_ARG_LENGTH ( FILENAME_MAX ) + +#define ISAR_MAX16B_FLT 32767.0f +#define ISAR_MIN16B_FLT ( -32768.0f ) +#define ISAR_MAX16B_FX 32767 +#define ISAR_MIN16B_FX ( -32768 ) + +#if !defined( DEBUGGING ) && !defined( WMOPS ) +static +#endif + int32_t frame = 0; + +#ifdef _WIN32 +#define SEP_FOLDER '\\' +#else +#define SEP_FOLDER '/' +#endif + +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ + +typedef struct +{ + IVAS_AUDIO_CONFIG audioConfig; + int32_t inputChannelIndex; + float gain_dB; +} RendererInput; + +typedef struct +{ + RendererInput binBuses[RENDERER_MAX_BIN_INPUTS]; + uint16_t numBinBuses; +} InputConfig; + +typedef struct +{ + IVAS_AUDIO_CONFIG audioConfig; +} OutputConfig; + +typedef struct +{ + char executableName[POST_REND_MAX_CLI_ARG_LENGTH]; + char inputFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + char outputFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + int32_t sampleRate; + InputConfig inConfig; + OutputConfig outConfig; + char inMetadataFilePaths[RENDERER_MAX_ISAR_MD_INPUTS][POST_REND_MAX_CLI_ARG_LENGTH]; + int16_t numInMetadataFiles; + char headRotationFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + char splitRendBFIFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + ISAR_POST_REND_COMPLEXITY_LEVEL complexityLevel; + bool delayCompensationEnabled; + bool quietModeEnabled; + bool sceneDescriptionInput; + IVAS_RENDER_FRAMESIZE render_framesize; +} CmdlnArgs; + +typedef enum +{ + CmdLnOptionId_inputFile = 1, + CmdLnOptionId_inputFormat, + CmdLnOptionId_outputFile, + CmdLnOptionId_sampleRate, + CmdLnOptionId_trajFile, + CmdLnOptionId_orientationTracking, + CmdLnOptionId_complexityLevel, + CmdLnOptionId_noDelayCmp, + CmdLnOptionId_quietModeEnabled, + CmdLnOptionId_inputMetadata, + CmdLnOptionId_listFormats, + CmdLnOptionId_SplitRendBFIFile, + CmdLnOptionId_framing, +} CmdLnOptionId; + +static const CmdLnParser_Option cliOptions[] = { + { + .id = CmdLnOptionId_inputFile, + .match = "input_file", + .matchShort = "i", + .description = "Path to the input file (WAV, raw PCM or scene description file)", + }, + { + .id = CmdLnOptionId_inputFormat, + .match = "input_format", + .matchShort = "if", + .description = "Audio format of input file (e.g. BINAURAL_SPLIT_PCM, use -l for a list)", + }, + { + .id = CmdLnOptionId_inputMetadata, + .match = "input_metadata", + .matchShort = "im", + .description = "Space-separated list of path to metadata files for BINAURAL_SPLIT_PCM input mode", + }, + { + .id = CmdLnOptionId_outputFile, + .match = "output_file", + .matchShort = "o", + .description = "Path to the output file", + }, + { + .id = CmdLnOptionId_sampleRate, + .match = "sample_rate", + .matchShort = "fs", + .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs", + }, + { + .id = CmdLnOptionId_trajFile, + .match = "trajectory_file", + .matchShort = "T", + .description = "Head rotation trajectory file for simulation of head tracking", + }, + { + .id = CmdLnOptionId_SplitRendBFIFile, + .match = "post_rend_bfi_file", + .matchShort = "prbfi", + .description = "Split rendering option: bfi file", + }, + { + .id = CmdLnOptionId_noDelayCmp, + .match = "no_delay_compensation", + .matchShort = "no_delay_cmp", + .description = "[flag] Turn off delay compensation", + }, + { + .id = CmdLnOptionId_complexityLevel, + .match = "complexity_level", + .matchShort = "level", + .description = "Complexity level, level = (1, 2, 3), will be defined after characterisation.", + }, + { + .id = CmdLnOptionId_quietModeEnabled, + .match = "quiet", + .matchShort = "q", + .description = "[flag] Limit printouts to terminal", + }, + { + .id = CmdLnOptionId_listFormats, + .match = "list", + .matchShort = "l", + .description = "List supported audio formats", + }, + { + .id = CmdLnOptionId_framing, + .match = "framing", + .matchShort = "fr", + .description = "Set Render audio framing.", + }, +}; + + +/*------------------------------------------------------------------------------------------* + * Local function prototypes + *------------------------------------------------------------------------------------------*/ + +static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option ); + +static void printSupportedAudioConfigs( void ); + +static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); + +static void convertOutputBuffer( const Word32 *fixedBuffer, Word16 q, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static ISAR_POST_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( + IVAS_REND_AudioBuffer buffer, + const int16_t chBeginIdx, + const int16_t numChannels ) +{ + ISAR_POST_REND_ReadOnlyAudioBuffer subBuffer; + + subBuffer.config = buffer.config; + subBuffer.config.numChannels = numChannels; + subBuffer.data_fx = buffer.data_fx + subBuffer.config.numSamplesPerChannel * chBeginIdx; + + return subBuffer; +} + + +static int16_t getTotalNumInChannels( + ISAR_POST_REND_HANDLE hIsarPostRend, + ISAR_POST_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] ) +{ + int16_t totalNumInChannels = 0; + int16_t i, numInputChannels; + ivas_error error; + + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + if ( splitBinIds[i] == 0 ) + { + /* Skip inactive inputs */ + continue; + } + + if ( ( error = ISAR_POST_REND_GetInputNumChannels( hIsarPostRend, splitBinIds[i], &numInputChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + totalNumInChannels += numInputChannels; + } + + return totalNumInChannels; +} + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static const CmdLnParser_Option *findOptionById( + const int32_t id ) +{ + for ( int32_t i = 0; i < numCliOptions; ++i ) + { + if ( cliOptions[i].id == id ) + { + return &cliOptions[i]; + } + } + + return NULL; +} + +static bool parseInConfig( + const char *inFormatStr, + InputConfig *inConfig, + bool *sceneDescriptionInput ) +{ + char charBuf[FILENAME_MAX]; + + /* Initialize input config struct */ + inConfig->numBinBuses = 0; + + /* First check if input is being set to scene description file - this is not covered by parseAudioConfig(). */ + strncpy( charBuf, inFormatStr, sizeof( charBuf ) - 1 ); + charBuf[sizeof( charBuf ) - 1] = '\0'; + to_upper( charBuf ); + if ( strcmp( charBuf, "META" ) == 0 ) + { + *sceneDescriptionInput = true; + /* Parsing the file will be done later. At this point the actual file path + * may not be known as command line parameters are still being parsed. */ + return true; + } + + /* Check for single-format inputs. The given string should map to a member of AUDIO_CONFIG enum. */ + IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr ); + switch ( audioConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + inConfig->numBinBuses = 1; + inConfig->binBuses[0].audioConfig = audioConfig; + inConfig->binBuses[0].inputChannelIndex = 0; + inConfig->binBuses[0].gain_dB = 0.0f; + break; + default: + { + /* Default case covers formats that are defined in the AUDIO_CONFIG enum, + * but cannot be used at input, e.g. BINAURAL */ + const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); + fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); + return false; + } + } + + return true; +} + + +static bool parseRenderFramesize( + char *value, + IVAS_RENDER_FRAMESIZE *render_framesize ) +{ + int32_t tmp; + + *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN; + if ( !is_digits_only( value ) ) + { + return false; + } + tmp = (int32_t) strtol( value, NULL, 0 ); + switch ( (int16_t) tmp ) + { + case 5: + *render_framesize = IVAS_RENDER_FRAMESIZE_5MS; + break; + case 10: + *render_framesize = IVAS_RENDER_FRAMESIZE_10MS; + break; + case 20: + *render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + break; + default: + return false; + } + + return true; +} + + +static IVAS_AUDIO_CONFIG parseAudioConfig( + const char *configString ) +{ + char charBuf[25]; + charBuf[24] = '\0'; + + strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); + charBuf[sizeof( charBuf ) - 1] = '\0'; + to_upper( charBuf ); + + if ( strcmp( charBuf, "BINAURAL" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL; + } + if ( strcmp( charBuf, "BINAURAL_SPLIT_PCM" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; + } + if ( strcmp( charBuf, "BINAURAL_SPLIT_CODED" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } + return IVAS_AUDIO_CONFIG_INVALID; +} + + +static bool checkRequiredArgs( + CmdlnArgs args ) +{ + const CmdLnParser_Option *tmpOption; + + /* Check required arguments */ + bool missingRequiredArg = false; + if ( isEmptyString( args.inputFilePath ) ) + { + tmpOption = findOptionById( CmdLnOptionId_inputFile ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + + const bool singleInputSpecified = ( args.inConfig.numBinBuses != 0 ); + + if ( !args.sceneDescriptionInput && !singleInputSpecified ) + { + /* Neither scene description input nor single-type input was specified on command line */ + tmpOption = findOptionById( CmdLnOptionId_inputFormat ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + if ( isEmptyString( args.outputFilePath ) ) + { + tmpOption = findOptionById( CmdLnOptionId_outputFile ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + if ( args.sampleRate == 0 ) + { + tmpOption = findOptionById( CmdLnOptionId_sampleRate ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + if ( missingRequiredArg ) + { + CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions ); + } + + return !missingRequiredArg; +} + +static CmdlnArgs defaultArgs( + const char *executableName ) +{ + CmdlnArgs args; + + strncpy( args.executableName, executableName, POST_REND_MAX_CLI_ARG_LENGTH ); + clearString( args.inputFilePath ); + clearString( args.outputFilePath ); + args.sampleRate = 0; + + args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; + + for ( int32_t i = 0; i < RENDERER_MAX_ISAR_MD_INPUTS; ++i ) + { + clearString( args.inMetadataFilePaths[i] ); + } + args.numInMetadataFiles = 0; + + clearString( args.headRotationFilePath ); + clearString( args.splitRendBFIFilePath ); + + args.delayCompensationEnabled = true; + args.quietModeEnabled = false; + args.sceneDescriptionInput = false; + + args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + + return args; +} + +static void parseOption( + const int32_t optionId, + char **optionValues, + const int16_t numOptionValues, + void *pOutputStruct ) +{ + CmdlnArgs *args = pOutputStruct; + + switch ( optionId ) + { + case CmdLnOptionId_listFormats: + assert( numOptionValues == 0 ); + printSupportedAudioConfigs(); + exit( 0 ); + case CmdLnOptionId_inputFile: + assert( numOptionValues == 1 ); + strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_inputFormat: + assert( numOptionValues == 1 ); + if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) + { + exit( -1 ); /* Error printout handled by failing function */ + } + break; + case CmdLnOptionId_inputMetadata: + assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS ); + for ( int16_t i = 0; i < numOptionValues; ++i ) + { + strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + } + args->numInMetadataFiles = numOptionValues; + break; + case CmdLnOptionId_outputFile: + assert( numOptionValues == 1 ); + strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_sampleRate: + assert( numOptionValues == 1 ); + args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); + if ( args->sampleRate == 0 ) + { + fprintf( stderr, "Invalid sampling rate specified\n" ); + exit( -1 ); + } + break; + case CmdLnOptionId_trajFile: + assert( numOptionValues == 1 ); + strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_SplitRendBFIFile: + assert( numOptionValues == 1 ); + strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_complexityLevel: + assert( numOptionValues == 1 ); + args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); + if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) + { + fprintf( stdout, "Invalid complexity level specified.\n" ); + exit( -1 ); + } + else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) + { + fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); + } + break; + case CmdLnOptionId_noDelayCmp: + assert( numOptionValues == 0 ); + args->delayCompensationEnabled = false; + break; + case CmdLnOptionId_quietModeEnabled: + assert( numOptionValues == 0 ); + args->quietModeEnabled = true; + break; + case CmdLnOptionId_framing: + assert( numOptionValues == 1 ); + if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) + { + fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); + exit( -1 ); + } + + break; + default: + assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); + break; + } + + return; +} + +static CmdlnArgs parseCmdlnArgs( + const int argc, + char **argv ) +{ + CmdlnArgs args = defaultArgs( argv[0] ); + + if ( CmdLnParser_parseArgs( argc, argv, cliOptions, numCliOptions, &args, parseOption ) != 0 ) + { + exit( -1 ); /* Error printout handled by failing function */ + } + + if ( !checkRequiredArgs( args ) ) + { + exit( -1 ); /* Error printout handled by failing function */ + } + + return args; +} + + +static void printSupportedAudioConfigs( void ) +{ + uint16_t i; + const char *supportedFormats[] = { + "BINAURAL (output only)", + "BINAURAL_SPLIT_PCM", + "BINAURAL_SPLIT_CODED", + }; + + fprintf( stdout, "Supported audio formats:\n" ); + for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) + { + fprintf( stdout, "%s\n", supportedFormats[i] ); + } + + return; +} + +/*--------------------------------------------------------------------------* + * convertInputBuffer() + * + * Convert input buffer from WAV/PCM file (int16_t, interleaved) to a format + * accepted by the renderer (float, packed) + *--------------------------------------------------------------------------*/ + +static void convertInputBuffer( + const int16_t *intBuffer, + const int16_t numIntSamplesPerChannel, + const int16_t numFloatSamplesPerChannel, + const int16_t numChannels, + Word32 *fixedBuffer ) +{ + int16_t chnl, smpl, i; + + i = 0; + + FOR( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) + { + FOR( chnl = 0; chnl < numChannels; ++chnl ) + { + IF( i < numIntSamplesPerChannel ) + { + fixedBuffer[chnl * numFloatSamplesPerChannel + smpl] = (Word32) intBuffer[i]; + } + ELSE + { + fixedBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0; + } + + ++i; + } + } + + return; +} + +/*--------------------------------------------------------------------------* + * convertOutputBuffer() + * + * Convert output buffer from the renderer (float, packed) to a format ready + * for writing to a WAV/PCM file (int16_t, interleaved) + *--------------------------------------------------------------------------*/ + +static void convertOutputBuffer( + const Word32 *fixedBuffer, + Word16 q, + const int16_t numSamplesPerChannel, + const int16_t numChannels, + int16_t *intBuffer ) +{ + int16_t chnl, smpl, i; + Word32 temp; + + i = 0; + + for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + temp = L_shr_r( fixedBuffer[chnl * numSamplesPerChannel + smpl], q ); + IF( GT_32( temp, ISAR_MAX16B_FX ) ) + { + temp = ISAR_MAX16B_FX; + } + ELSE IF( LT_32( temp, ISAR_MIN16B_FX ) ) + { + temp = ISAR_MIN16B_FX; + } + intBuffer[i] = (int16_t) temp; + + ++i; + } + } + + return; +} + +/*------------------------------------------------------------------------------------------* + * main() + * + * Main ISAR post renderer function for command-line interface + *------------------------------------------------------------------------------------------*/ + +int main( + int argc, + char **argv ) +{ + ISAR_POST_REND_HANDLE hIsarPostRend; + RotFileReader *headRotReader = NULL; + RotFileReader *externalOrientationFileReader = NULL; + SplitRendBFIFileReader *splitRendBFIReader = NULL; + AudioFileReader *audioReader = NULL; + AudioFileWriter *audioWriter; + int32_t inBufferSize; + int32_t outBufferSize; + int32_t bitsBufferSize; + int16_t *inpInt16Buffer; + Word32 *inFloatBuffer_fx; + int16_t *outInt16Buffer; + Word32 *outFloatBuffer_fx; + uint8_t *bitsBufferData = NULL; + IVAS_REND_AudioBuffer inBuffer; + IVAS_REND_AudioBuffer outBuffer; + ISAR_POST_REND_BitstreamBuffer bitsBuffer; + SplitFileReadWrite *hSplitRendFileReadWrite; + char audioFilePath[FILENAME_MAX]; + int16_t numSamplesRead; + int16_t delayNumSamples = -1; + int16_t delayNumSamples_orig = 0; + int16_t zeroPad = 0; + int16_t zeroPadToWrite = 0; + int32_t delayTimeScale = 0; + int16_t i, numChannels; + ivas_error error = IVAS_ERR_OK; + bool splitBinNeedsNewFrame = true; + +#ifdef WMOPS + reset_wmops(); + reset_mem( USE_BYTES ); +#endif + + hSplitRendFileReadWrite = NULL; + bitsBuffer.bits = NULL; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = 0; + bitsBuffer.config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + bitsBuffer.config.codec_frame_size_ms = 5; + bitsBuffer.config.isar_frame_size_ms = 20; + bitsBuffer.config.lc3plusHighRes = 0; +#else + bitsBuffer.config.codec_frame_size_ms = 20; +#endif + + + CmdlnArgs args = parseCmdlnArgs( argc, argv ); + + convert_backslash( args.inputFilePath ); + convert_backslash( args.outputFilePath ); + convert_backslash( args.headRotationFilePath ); + + if ( !isEmptyString( args.headRotationFilePath ) ) + { + if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error opening file: %s\n", args.headRotationFilePath ); + exit( -1 ); + } + } + + if ( !isEmptyString( args.splitRendBFIFilePath ) ) + { + convert_backslash( args.splitRendBFIFilePath ); + SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t inFileSampleRate = 0; +#endif + strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 ); + hSplitRendFileReadWrite = NULL; + if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + error = split_rend_reader_open( &hSplitRendFileReadWrite, + args.inMetadataFilePaths[0], + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms, + &inFileSampleRate, + &bitsBuffer.config.lc3plusHighRes +#endif + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.inMetadataFilePaths[0] ); + exit( -1 ); + } + + if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error opening file: %s\n", audioFilePath ); + exit( -1 ); + } + } + + /*if split renderer is running in post renderer mode*/ + if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + { + error = split_rend_reader_open( &hSplitRendFileReadWrite, + args.inputFilePath, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms, + &inFileSampleRate, + &bitsBuffer.config.lc3plusHighRes +#endif + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.inputFilePath ); + exit( -1 ); + } + audioReader = NULL; + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t inFileSampleRate = 0; +#endif + if ( audioReader != NULL ) + { + error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate ); + } + else +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( hSplitRendFileReadWrite == NULL ) +#endif + { + inFileSampleRate = args.sampleRate; + } + + switch ( error ) + { + case IVAS_ERR_OK: + /* If sampling rate not given on command line, use the one from SR file */ + if ( args.sampleRate == 0 ) + { + args.sampleRate = inFileSampleRate; + } + /* else if sampling rate given on command line, compare with wav file */ + else if ( inFileSampleRate != args.sampleRate ) + { + fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); + exit( -1 ); + } + break; + case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */ + if ( args.sampleRate == 0 ) + { + fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" ); + exit( -1 ); + } + break; + default: + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + int16_t inFileNumChannels = 0; + if ( audioReader != NULL ) + { + error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); + if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); + args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL; + if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + /* === Configure === */ + if ( ( error = ISAR_POST_REND_InitConfig( hIsarPostRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( args.inConfig.numBinBuses > 0 ) + { + if ( ( error = ISAR_REND_SetSplitRendBitstreamHeader( hIsarPostRend, + bitsBuffer.config.codec, + bitsBuffer.config.poseCorrection, + bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + bitsBuffer.config.isar_frame_size_ms, + bitsBuffer.config.lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in getting split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + + ISAR_POST_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS]; + + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ ) + { + splitBinIds[i] = 0u; + } + + for ( i = 0; i < args.inConfig.numBinBuses; ++i ) + { + if ( ( error = ISAR_POST_REND_AddInput( hIsarPostRend, args.inConfig.binBuses[i].audioConfig, &splitBinIds[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + const int16_t totalNumInChannels = getTotalNumInChannels( hIsarPostRend, splitBinIds ); + + if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) + { + fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); + exit( -1 ); + } + + int16_t numOutChannels = 2; + + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); + exit( -1 ); + } + + inBufferSize = frameSize_smpls * totalNumInChannels; + outBufferSize = frameSize_smpls * numOutChannels; + inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); + memset( inpInt16Buffer, 0, inBufferSize * sizeof( int16_t ) ); + + inFloatBuffer_fx = malloc( inBufferSize * sizeof( Word32 ) ); + inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + outFloatBuffer_fx = malloc( outBufferSize * sizeof( Word32 ) ); + outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + + outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); + + inBuffer.config.is_cldfb = 0; + inBuffer.config.numChannels = (int16_t) totalNumInChannels; + inBuffer.data_fx = inFloatBuffer_fx; + inBuffer.q_data_fx = malloc( sizeof( Word16 ) ); + + outBuffer.config.is_cldfb = 0; + outBuffer.config.numChannels = (int16_t) numOutChannels; + outBuffer.data_fx = outFloatBuffer_fx; + outBuffer.q_data_fx = malloc( sizeof( Word16 ) ); + + memset( outBuffer.data_fx, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( Word32 ) ); + + bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + + if ( bitsBufferSize > 0 ) + { + bitsBufferData = malloc( bitsBufferSize * sizeof( uint8_t ) ); + } + else + { + bitsBufferData = NULL; + } + + bitsBuffer.bits = bitsBufferData; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = bitsBufferSize; + +#ifdef WMOPS + reset_stack(); + reset_wmops(); +#endif + + if ( !args.quietModeEnabled ) + { + fprintf( stdout, "\n------ Running the ISAR post renderer ------\n\n" ); + fprintf( stdout, "Frames processed: " ); + } + else + { + fprintf( stdout, "\n\n-- Start the ISAR post renderer (quiet mode) --\n\n" ); + } + + while ( 1 ) + { + int16_t num_in_channels; + num_in_channels = inBuffer.config.numChannels; + + numSamplesRead = 0; + if ( ( hSplitRendFileReadWrite != NULL ) && splitBinNeedsNewFrame ) + { + ivas_error error_tmp; + numSamplesRead = (int16_t) inBufferSize; + error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ); + if ( error_tmp != IVAS_ERR_OK ) + { + if ( error_tmp == IVAS_ERR_END_OF_FILE ) + { + numSamplesRead = 0; + } + else + { + fprintf( stderr, "\nUnable to read from bitstream file!\n" ); + exit( -1 ); + } + } + } + + if ( audioReader != NULL ) + { + /* Read the input data */ + if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError reading from file %s\n", audioFilePath ); + exit( -1 ); + } + } + + if ( numSamplesRead == 0 && splitBinNeedsNewFrame ) + { + /* end of input data */ + break; + } + + /* Convert from int to float and from interleaved to packed */ + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer_fx ); + *inBuffer.q_data_fx = 0; + int16_t num_subframes, sf_idx; + num_subframes = (int16_t) args.render_framesize; + + /* Read from head rotation trajectory file if specified */ + if ( headRotReader != NULL ) + { + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + IVAS_QUATERNION headRot; + IVAS_VECTOR3 Pos; + + IF( ( error = HeadRotationFileReading_fx( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + } + else + { + fprintf( stderr, "Head Rotation should be enabled in post renderer\n" ); + exit( -1 ); + } + + /* Read from split renderer bfi file if specified */ + if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame ) + { + int16_t bfi; + if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + for ( i = 0; i < args.inConfig.numBinBuses; ++i ) + { + if ( numSamplesRead > 0 ) + { + if ( ( error = ISAR_POST_REND_GetInputNumChannels( hIsarPostRend, splitBinIds[i], &numChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + ISAR_POST_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.binBuses[i].inputChannelIndex, numChannels ); + + if ( ( error = ISAR_POST_REND_FeedInputAudio( hIsarPostRend, splitBinIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + if ( splitBinNeedsNewFrame ) + { + if ( ( error = ISAR_POST_REND_FeedSplitBinauralBitstream( hIsarPostRend, splitBinIds[i], &bitsBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + } + + if ( ( error = ISAR_POST_REND_GetSplitBinauralSamples( hIsarPostRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + int16_t num_out_channels; + num_out_channels = outBuffer.config.numChannels; + + /* Convert from float to int and from packed to interleaved. + * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ + convertOutputBuffer( outFloatBuffer_fx, *outBuffer.q_data_fx, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); + + if ( delayNumSamples == -1 ) + { + if ( args.delayCompensationEnabled ) + { + if ( ISAR_POST_REND_GetDelay( hIsarPostRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( hSplitRendFileReadWrite != NULL ) + { + uint32_t pre_rend_delay_ns; + split_rend_read_pre_rend_delay_ns( hSplitRendFileReadWrite, &pre_rend_delay_ns ); + delayNumSamples += (Word16) ( ( ( (Word64) pre_rend_delay_ns * delayTimeScale ) + 500000000 ) / 1000000000 ); + } + + delayNumSamples_orig = delayNumSamples; + } + else + { + delayNumSamples = 0; + } + zeroPad = delayNumSamples; + } + + if ( audioWriter != NULL ) + { + if ( delayNumSamples * num_out_channels < outBufferSize ) + { + if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); + exit( -1 ); + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); + } + } + + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + + frame++; + if ( !args.quietModeEnabled ) + { + fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); + } + +#ifdef WMOPS + update_mem(); + update_wmops(); +#endif + } + + /* add zeros at the end to have equal length of synthesized signals */ + if ( audioWriter != NULL ) + { + for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) + { + memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + exit( -1 ); + } + } + + memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + exit( -1 ); + } + zeroPadToWrite = 0; + } + + if ( !args.quietModeEnabled && args.delayCompensationEnabled ) + { + fprintf( stdout, "\nRenderer delay: %-5u [samples] - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale ); + } + + fprintf( stdout, "\n\nRendering of %d frames finished\n\n", frame ); + +#ifdef DEBUGGING + int32_t cnt_frames_limited, noClipping; + if ( ( cnt_frames_limited = ISAR_POST_REND_GetCntFramesLimited( hIsarPostRend ) ) > 0 ) + { + fprintf( stdout, "Limiter applied in %d frames.\n\n", cnt_frames_limited ); + } + if ( ( noClipping = ISAR_POST_REND_GetNoCLipping( hIsarPostRend ) ) > 0 ) + { + fprintf( stdout, "Clipping (saturation) detected: %d samples clipped!!!\n\n", noClipping ); + } +#endif + + /* === Close === */ + free( inpInt16Buffer ); + free( inFloatBuffer_fx ); + free( inBuffer.q_data_fx ); + free( outInt16Buffer ); + free( outFloatBuffer_fx ); + free( outBuffer.q_data_fx ); + + if ( bitsBufferData != NULL ) + { + free( bitsBufferData ); + } + + split_rend_reader_writer_close( &hSplitRendFileReadWrite ); + SplitRendBFIFileReader_close( &splitRendBFIReader ); + + AudioFileReader_close( &audioReader ); + AudioFileWriter_close( &audioWriter ); + RotationFileReader_close( &headRotReader ); + RotationFileReader_close( &externalOrientationFileReader ); + + ISAR_POST_REND_Close( &hIsarPostRend ); + +#ifdef DEBUGGING + dbgclose(); +#endif +#ifdef WMOPS + print_wmops(); + print_mem( NULL ); +#endif + + return 0; +} + + +#undef WMC_TOOL_SKIP + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/apps/renderer.c b/apps/renderer.c index f5c0a8847..9b64aff93 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -45,6 +45,10 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "split_render_file_read_write.h" +#include "split_rend_bfi_file_reader.h" +#endif #include "vector3_pair_file_reader.h" #include "wmc_auto.h" @@ -148,7 +152,13 @@ typedef struct OutputConfig outConfig; char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH]; int16_t numInMetadataFiles; +#ifdef SPLIT_REND_WITH_HEAD_ROT + char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#endif char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#endif char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -195,6 +205,10 @@ typedef enum CmdLnOptionId_inputMetadata, CmdLnOptionId_listFormats, CmdLnOptionId_inputGain, +#ifdef SPLIT_REND_WITH_HEAD_ROT + CmdLnOptionId_outputMetadata, + CmdLnOptionId_SplitRendBFIFile, +#endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, CmdLnOptionId_framing, @@ -220,7 +234,11 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .matchShort = "im", +#ifdef SPLIT_REND_WITH_HEAD_ROT + .description = "Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode", +#else .description = "Space-separated list of path to metadata files for ISM or MASA inputs", +#endif }, { .id = CmdLnOptionId_outputFile, @@ -246,6 +264,20 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "T", .description = "Head rotation trajectory file for simulation of head tracking (only for binaural outputs)", }, +#ifdef SPLIT_REND_WITH_HEAD_ROT + { + .id = CmdLnOptionId_outputMetadata, + .match = "output_metadata", + .matchShort = "om", + .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode", + }, + { + .id = CmdLnOptionId_SplitRendBFIFile, + .match = "post_rend_bfi_file", + .matchShort = "prbfi", + .description = "Split rendering option: bfi file", + }, +#endif { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", @@ -403,11 +435,19 @@ static void printSupportedAudioConfigs( void ); static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); + +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); +static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, Word16 *intBuffer, Word16 q_factor, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); +static void convertInputBuffer_fx( const Word16 *intBuffer, const Word16 numIntSamplesPerChannel, const Word16 numFloatSamplesPerChannel, const Word16 numChannels, Word32 *Int32Buffer, Word16 in_q_factor, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); +#else static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer ); static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, Word16 *intBuffer, Word16 q_factor ); static void convertInputBuffer_fx( const Word16 *intBuffer, const Word16 numIntSamplesPerChannel, const Word16 numFloatSamplesPerChannel, const Word16 numChannels, Word32 *Int32Buffer, Word16 in_q_factor ); +#endif /*------------------------------------------------------------------------------------------* @@ -593,6 +633,44 @@ static float dBToLin( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static int16_t get_cldfb_in_flag( + const IVAS_AUDIO_CONFIG audioConfig, + const IVAS_RENDER_CONFIG_DATA *renderConfig ) +{ + int16_t cldfb_in_flag; + + cldfb_in_flag = 0; + if ( renderConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { +#ifdef DEBUGGING + cldfb_in_flag = 1; +#endif + if ( audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + cldfb_in_flag = 1; + } + } + + return cldfb_in_flag; +} + +static int16_t is_split_pre_rend_mode( + CmdlnArgs *args ) +{ + int16_t flag; + + flag = 0; + if ( args->outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args->outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + flag = 1; + } + + return flag; +} +#endif + + /*------------------------------------------------------------------------------------------* * main() * @@ -607,6 +685,12 @@ int main( RotFileReader *headRotReader = NULL; RotFileReader *externalOrientationFileReader = NULL; RotFileReader *referenceRotReader = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS]; + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS]; + int16_t cldfb_in_flag, CLDFBframeSize_smpls; + SplitRendBFIFileReader *splitRendBFIReader = NULL; +#endif Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; IsmPositionProvider *positionProvider; @@ -620,6 +704,9 @@ int main( AudioFileWriter *audioWriter; int32_t inBufferSize; int32_t outBufferSize; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int32_t bitsBufferSize; +#endif int16_t *inpInt16Buffer; float *inFloatBuffer; int16_t *outInt16Buffer; @@ -627,8 +714,17 @@ int main( Word32 *inInt32Buffer; Word32 gain_fx; float *outFloatBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + uint8_t *bitsBufferData = NULL; +#endif IVAS_REND_AudioBuffer inBuffer; IVAS_REND_AudioBuffer outBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_REND_BitstreamBuffer bitsBuffer; + SplitFileReadWrite *hSplitRendFileReadWrite; + int16_t delayNumSamples_temp; + int32_t delayTimeScale_temp; +#endif int16_t numSamplesRead; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; @@ -637,7 +733,6 @@ int main( int32_t delayTimeScale = 0; int16_t i, numChannels; ivas_error error = IVAS_ERR_OK; - bool splitBinNeedsNewFrame = true; #ifdef WMOPS reset_wmops(); @@ -650,6 +745,24 @@ int main( hMasaMetadata[i] = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hSplitRendFileReadWrite = NULL; + CLDFBframeSize_smpls = 0; + cldfb_in_flag = 0; + bitsBuffer.bits = NULL; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = 0; + bitsBuffer.config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + bitsBuffer.config.codec_frame_size_ms = 5; + bitsBuffer.config.isar_frame_size_ms = 20; + bitsBuffer.config.lc3plus_highres = 0; +#else + bitsBuffer.config.codec_frame_size_ms = 20; +#endif +#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { lfeRoutingConfigs[i] = NULL; @@ -710,6 +823,13 @@ int main( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !isEmptyString( args.splitRendBFIFilePath ) ) + { + convert_backslash( args.splitRendBFIFilePath ); + SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); + } +#endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -877,16 +997,28 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); + exit( -1 ); + } +#else if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stderr, "\nExternal Renderer Config is only supported for binaural output configurations. Exiting. \n" ); exit( -1 ); } +#endif if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n", ivas_error_to_string( error ) ); +#else fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); +#endif exit( -1 ); } @@ -914,11 +1046,28 @@ int main( renderConfig.roomAcoustics.override = 1; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_framesize /* given in number of 5ms subframes */ * 5; +#endif +#endif + if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n", ivas_error_to_string( error ) ); +#else fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); +#endif exit( -1 ); } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + CLDFBframeSize_smpls = frameSize_smpls * 2; + cldfb_in_flag = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); +#endif } if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientation_tracking ) ) != IVAS_ERR_OK ) @@ -1173,17 +1322,160 @@ int main( exit( -1 ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) + { + if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_openCldfb(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + + IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms +#endif + ); + + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, + args.outputFilePath, + delayNumSamples_temp, + delayTimeScale_temp, + bitsBuffer.config.codec, + bitsBuffer.config.poseCorrection, + bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + bitsBuffer.config.isar_frame_size_ms, + args.sampleRate, + bitsBuffer.config.lc3plus_highres +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); + exit( -1 ); + } + audioWriter = NULL; + } + else + { + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + + IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms +#endif + ); + + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, + args.outMetadataFilePath, + delayNumSamples_temp, + delayTimeScale_temp, + bitsBuffer.config.codec, + bitsBuffer.config.poseCorrection, + bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + bitsBuffer.config.isar_frame_size_ms, + args.sampleRate, + bitsBuffer.config.lc3plus_highres +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); + exit( -1 ); + } + } +#endif if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); exit( -1 ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif inBufferSize = frameSize_smpls * totalNumInChannels; outBufferSize = frameSize_smpls * numOutChannels; inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag == 0 ) + { + inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); + inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + outFloatBuffer = malloc( outBufferSize * sizeof( float ) ); + outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + } + else + { + inFloatBuffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( float ) ); + inBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + outFloatBuffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( float ) ); + outBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + } + outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); + + inBuffer.config.is_cldfb = cldfb_in_flag; + inBuffer.config.numChannels = (int16_t) totalNumInChannels; + inBuffer.data = inFloatBuffer; + + outBuffer.config.is_cldfb = cldfb_in_flag; + outBuffer.config.numChannels = (int16_t) numOutChannels; + outBuffer.data = outFloatBuffer; + + memset( outBuffer.data, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( float ) ); + + if ( is_split_pre_rend_mode( &args ) ) + { + bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + } + else + { + bitsBufferSize = 0; + } + + if ( bitsBufferSize > 0 ) + { + bitsBufferData = malloc( bitsBufferSize * sizeof( uint8_t ) ); + } + else + { + bitsBufferData = NULL; + } + + bitsBuffer.bits = bitsBufferData; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = bitsBufferSize; +#else inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); outInt32Buffer = malloc( outBufferSize * sizeof( Word32 ) ); @@ -1197,6 +1489,8 @@ int main( outBuffer.config.numChannels = (int16_t) numOutChannels; outBuffer.data_fx = outInt32Buffer; inBuffer.data_fx = inInt32Buffer; +#endif + #ifdef WMOPS reset_stack(); reset_wmops(); @@ -1222,6 +1516,8 @@ int main( num_in_channels = inBuffer.config.numChannels; const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; + numSamplesRead = 0; + /* Read the input data */ if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) { @@ -1229,14 +1525,18 @@ int main( exit( -1 ); } - if ( numSamplesRead == 0 && splitBinNeedsNewFrame ) + if ( numSamplesRead == 0 ) { /* end of input data */ break; } /* Convert from int to float and from interleaved to packed */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); +#else convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer ); +#endif *outBuffer.pq_fact = 16 - ( gd_bits ); convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact ); int16_t num_subframes, sf_idx; @@ -1295,7 +1595,11 @@ int main( exit( -1 ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, sf_idx ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1448,19 +1752,43 @@ int main( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + else + { +#endif if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); +#else fprintf( stderr, "Error in getting samples\n" ); +#endif exit( -1 ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif int16_t num_out_channels; num_out_channels = outBuffer.config.numChannels; + /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ if ( *outBuffer.pq_fact == 0 ) { - convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); + #ifdef SPLIT_REND_WITH_HEAD_ROT + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn ); +#else + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); +#endif } else { @@ -1486,6 +1814,20 @@ int main( zeroPad = delayNumSamples; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( is_split_pre_rend_mode( &args ) ) + { + if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, + &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); + exit( -1 ); + } + } + + if ( audioWriter != NULL ) + { +#endif if ( delayNumSamples * num_out_channels < outBufferSize ) { if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) @@ -1500,6 +1842,14 @@ int main( delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } + + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; +#endif + + /* Write MASA metadata for MASA outputs */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) { @@ -1603,6 +1953,10 @@ int main( } /* add zeros at the end to have equal length of synthesized signals */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( audioWriter != NULL ) + { +#endif for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) { memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); @@ -1620,6 +1974,9 @@ int main( exit( -1 ); } zeroPadToWrite = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) @@ -1642,11 +1999,27 @@ int main( free( outFloatBuffer ); free( outInt32Buffer ); free( inInt32Buffer ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( bitsBufferData != NULL ) + { + free( bitsBufferData ); + } +#endif for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { MasaFileReader_close( &masaReaders[i] ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) + { + IVAS_REND_closeCldfb( cldfbAna, cldfbSyn ); + } + + split_rend_reader_writer_close( &hSplitRendFileReadWrite ); + SplitRendBFIFileReader_close( &splitRendBFIReader ); +#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -1946,8 +2319,13 @@ static bool parseOrientationTracking( static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ) { +#ifndef SPLIT_REND_WITH_HEAD_ROT char charBuf[21]; charBuf[20] = '\0'; +#else + char charBuf[25]; + charBuf[24] = '\0'; +#endif strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); charBuf[sizeof( charBuf ) - 1] = '\0'; @@ -2022,6 +2400,16 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( { return IVAS_AUDIO_CONFIG_BINAURAL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( strcmp( charBuf, "BINAURAL_SPLIT_PCM" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; + } + if ( strcmp( charBuf, "BINAURAL_SPLIT_CODED" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } +#endif if ( strcmp( charBuf, "BINAURAL_ROOM_IR" ) == 0 ) { return IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -2154,6 +2542,10 @@ static CmdlnArgs defaultArgs( args.numInMetadataFiles = 0; clearString( args.headRotationFilePath ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + clearString( args.outMetadataFilePath ); + clearString( args.splitRendBFIFilePath ); +#endif clearString( args.referenceVectorFilePath ); clearString( args.referenceRotationFilePath ); clearString( args.customHrtfFilePath ); @@ -2246,6 +2638,16 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case CmdLnOptionId_outputMetadata: + assert( numOptionValues == 1 ); + strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_SplitRendBFIFile: + assert( numOptionValues == 1 ); + strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); + break; +#endif case CmdLnOptionId_referenceVectorFile: assert( numOptionValues == 1 ); strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); @@ -3264,6 +3666,10 @@ static void printSupportedAudioConfigs( void ) "ISMx (input only)", "MASAx", "BINAURAL (output only)", +#ifdef SPLIT_REND_WITH_HEAD_ROT + "BINAURAL_SPLIT_PCM", + "BINAURAL_SPLIT_CODED", +#endif "BINAURAL_ROOM_IR (output only)", "BINAURAL_ROOM_REVERB (output only)", }; @@ -3359,29 +3765,81 @@ static void convertInputBuffer( const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, - float *floatBuffer ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + float *floatBuffer, + const int16_t cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna +#else + float *floatBuffer +#endif +) { int16_t chnl, smpl, i; i = 0; - for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) + { + int16_t slotIdx, numCldfbBands, numFloatPcmSamples; + float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + + numFloatPcmSamples = numFloatSamplesPerChannel >> 1; + numCldfbBands = numFloatPcmSamples / IVAS_CLDFB_NO_COL_MAX; + + /* CLDFB Analysis*/ + assert( numIntSamplesPerChannel <= IVAS_MAX_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE ); + for ( smpl = 0; smpl < numFloatPcmSamples; ++smpl ) { for ( chnl = 0; chnl < numChannels; ++chnl ) { if ( i < numIntSamplesPerChannel ) { - floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; + fIn[chnl][smpl] = (float) intBuffer[i]; } else { - floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; + fIn[chnl][smpl] = 0.f; } ++i; } } + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) + { + IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx], + &floatBuffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + &floatBuffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + numCldfbBands, cldfbAna[chnl] ); + } + } + } + else + { +#endif + for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + if ( i < numIntSamplesPerChannel ) + { + floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; + } + else + { + floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; + } + + ++i; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + return; } @@ -3469,36 +3927,97 @@ static void convertOutputBuffer_fx( * Convert output buffer from the renderer (float, packed) to a format ready * for writing to a WAV/PCM file (int16_t, interleaved) *--------------------------------------------------------------------------*/ + static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, - int16_t *intBuffer ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t *intBuffer, + const int16_t cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn +#else + int16_t *intBuffer +#endif +) { int16_t chnl, smpl, i; float temp; i = 0; - for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) { + int16_t slotIdx, numCldfbBands, numPcmSamples, b; + float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + float re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + float im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + + numPcmSamples = numSamplesPerChannel >> 1; + numCldfbBands = numPcmSamples / IVAS_CLDFB_NO_COL_MAX; + + /* CLDFB Synthesis*/ for ( chnl = 0; chnl < numChannels; ++chnl ) { - temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; - temp = (float) floor( temp + 0.5f ); - if ( temp > IVAS_MAX16B_FLT ) + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - temp = IVAS_MAX16B_FLT; + for ( b = 0; b < numCldfbBands; b++ ) + { + re[chnl][slotIdx][b] = floatBuffer[( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + im[chnl][slotIdx][b] = floatBuffer[numCldfbBands + ( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + } } - else if ( temp < IVAS_MIN16B_FLT ) + } + + /* Implement CLDFB synthesis */ + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + float *RealBuffer[IVAS_CLDFB_NO_COL_MAX]; + float *ImagBuffer[IVAS_CLDFB_NO_COL_MAX]; + + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - temp = IVAS_MIN16B_FLT; + RealBuffer[slotIdx] = re[chnl][slotIdx]; + ImagBuffer[slotIdx] = im[chnl][slotIdx]; } - intBuffer[i] = (int16_t) temp; - ++i; + IVAS_REND_cldfbSynthesis_wrapper( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * IVAS_CLDFB_NO_COL_MAX, cldfbSyn[chnl] ); + } + for ( smpl = 0; smpl < numPcmSamples; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + intBuffer[i] = (int16_t) roundf( fIn[chnl][smpl] ); + ++i; + } } } + else + { +#endif + for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; + temp = (float) floor( temp + 0.5f ); + if ( temp > IVAS_MAX16B_FLT ) + { + temp = IVAS_MAX16B_FLT; + } + else if ( temp < IVAS_MIN16B_FLT ) + { + temp = IVAS_MIN16B_FLT; + } + intBuffer[i] = (int16_t) temp; + + ++i; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif return; } diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 5a3d2e1a2..fe3ed88ea 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -61,7 +61,6 @@ static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ); static void cldfb_init_proto_and_twiddles_enc_fx( HANDLE_CLDFB_FILTER_BANK hs ); - /*-------------------------------------------------------------------* * cplxMult() * diff --git a/lib_com/cnst.h b/lib_com/cnst.h index fe16db670..6cfa7ea41 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -173,6 +173,7 @@ #define MIN16B_FLT_FX_IN_Q15 -1073741824//Q15 #define PCM16_TO_FLT_FAC 32768.0f #define PCM16_TO_FLT_FAC_FX 32768 //Q0 +#define PCM16_TO_FLT_FAC_FX_Q15 1073741824L //16Q15 #define MDFT_NORM_SCALING ( 1.0f / PCM16_TO_FLT_FAC ) #define MDFT_NORM_SCALING_FX 65536 //Q31 #define LOG2_MDFT_NORM_SCALING_FX -503316448 //Q25 @@ -3042,6 +3043,8 @@ enum #define EVS_2PI_FX_Q27 843314856 /* 2 * pi in Q28 */ #define EVS_PI_BY_2_FX (Word16)(0x3244) // Q13 //#define EVS_PI_FX (Word16)(0x6488) +#define EVS_PI_FX16 (Word16)(0x6488) +#define PI2_FX 1686629713 //Q28 #define LG10 24660 /* 10*log10(2) in Q13 */ diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index b98f2e7d1..894b940b7 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -59,6 +59,12 @@ #define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4 #define IVAS_ROOM_ABS_COEFF 6 +/* Maximum buffer length (per channel) in samples */ +#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k ) + +/* Frame size required when rendering to binaural */ +#define BINAURAL_RENDERING_FRAME_SIZE_MS 5 + /*----------------------------------------------------------------------------------* * Common API enum for output audio configurations *----------------------------------------------------------------------------------*/ @@ -210,10 +216,109 @@ typedef struct _IVAS_JBM_TRACE_DATA } IVAS_JBM_TRACE_DATA; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering API constants, structures, and enums + *----------------------------------------------------------------------------------*/ + +#define ISAR_MAX_SPLIT_REND_BITRATE 768000 +#define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) +#define ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ 1 +#define SPLIT_REND_BITS_BUFF_SIZE ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) + +typedef enum +{ + DEFAULT_AXIS, + YAW, + PITCH, + ROLL, + YAW_PITCH, + YAW_ROLL, + PITCH_ROLL + +} ISAR_SPLIT_REND_ROT_AXIS; + +typedef enum +{ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB, + +} ISAR_SPLIT_REND_POSE_CORRECTION_MODE; + +typedef enum +{ + ISAR_SPLIT_REND_CODEC_LCLD, + ISAR_SPLIT_REND_CODEC_LC3PLUS, + ISAR_SPLIT_REND_CODEC_DEFAULT, /* Will use LCLD for CLDFB rendering paths and LC3plus for TD rendering paths */ + ISAR_SPLIT_REND_CODEC_NONE + +} ISAR_SPLIT_REND_CODEC; + +typedef enum +{ + ISAR_SPLIT_REND_RENDERER_SELECTION_CREND, + ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV, + ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN, + ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND, + ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT, + +} ISAR_SPLIT_REND_RENDERER_SELECTION; + +typedef struct _ISAR_SPLIT_REND_BITS_DATA +{ + uint8_t *bits_buf; + int32_t buf_len; /*size of bits_buf in bytes. This field should be set by allocator of bits_buf*/ + int32_t bits_written; + int32_t bits_read; + int16_t codec_frame_size_ms; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + int16_t lc3plus_highres; +#endif + +} ISAR_SPLIT_REND_BITS_DATA, *ISAR_SPLIT_REND_BITS_HANDLE; + +typedef struct _ISAR_SPLIT_REND_CONFIG +{ + int32_t splitRendBitRate; /*Bit rate for split rendering mode, if "pcm_out" is set then "splitRendBitRate" is used as a limit for MD bitrate */ + int16_t hq_mode; /*High quality 3DOF mode with additional side information. Requires more pre-renditions. */ + int16_t dof; /*flag to specify if pose correction is needed for 1, 2 or 3 degree of freedoms*/ + /*The axis can be set dynamically per frame based on a file input */ + /*possible values: + 1 - (1dof correction. By default YAW correction) + 2 - (2dof correction. By default YAW and PITCH correction) + 3 - (3dof correction. By default YAW, PITCH and ROLL correction) + */ + int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ +#endif + int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_RENDERER_SELECTION rendererSelection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t lc3plus_highres; +#endif + +} ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; +#endif + /*----------------------------------------------------------------------------------* * Renderer API structures and enums *----------------------------------------------------------------------------------*/ +#ifdef DEBUGGING +typedef enum +{ + IVAS_RENDER_TYPE_OVERRIDE_NONE, + IVAS_RENDER_TYPE_OVERRIDE_CREND, + IVAS_RENDER_TYPE_OVERRIDE_FASTCONV + +} IVAS_RENDER_TYPE_OVERRIDE; +#endif typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { @@ -242,10 +347,33 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG typedef struct _IVAS_RENDER_CONFIG { +#ifdef DEBUGGING + IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; +#endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcoustics; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; +#endif float directivity[IVAS_MAX_NUM_OBJECTS * 3]; Word16 directivity_fx[IVAS_MAX_NUM_OBJECTS * 3]; // has the following q-factor pattern: {6, 6, 15, 6, 6, 15, 6, 6, 15, 6, 6, 15} } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; +typedef struct +{ + int16_t numSamplesPerChannel; + int16_t numChannels; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t is_cldfb; +#endif +} IVAS_REND_AudioBufferConfig; + +typedef struct +{ + IVAS_REND_AudioBufferConfig config; + Word16 q_factor; + Word16 *pq_fact; + Word32 *data_fx; + // Word16 Q_data; +} IVAS_REND_AudioBuffer; #endif /* COMMON_API_TYPES_H */ diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 1198008f6..8ec9e112b 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -97,6 +97,12 @@ typedef enum * input data errors * *----------------------------------------*/ IVAS_ERR_INVALID_BITSTREAM = 0x2000, +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM, + IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM_CONFIG, +#endif +#endif /*----------------------------------------* * hardware errors * @@ -135,6 +141,10 @@ typedef enum IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING, IVAS_ERR_INVALID_ER_PARAM, IVAS_ERR_DIRECTIVITY_PATTERN_ID_MISSING, +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_ERR_LC3PLUS_INVALID_BITRATE, + IVAS_ERR_INVALID_SPLIT_REND_CONFIG, +#endif /*----------------------------------------* * unknown error * @@ -233,6 +243,12 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Wrong mode"; case IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED: return "Head rotation not supported"; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_ERR_LC3PLUS_INVALID_BITRATE: + return "Specified split rendering bit rate is not supported"; + case IVAS_ERR_INVALID_SPLIT_REND_CONFIG: + return "Specified split rendering configuration is invalid"; +#endif case IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED: return "External orientation not supported"; case IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED: diff --git a/lib_rend/ivas_limiter.c b/lib_com/ivas_limiter.c similarity index 100% rename from lib_rend/ivas_limiter.c rename to lib_com/ivas_limiter.c diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 03bc3d6e5..e7827023b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -42,6 +42,7 @@ #include "stat_com.h" #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" +#include "ivas_stat_rend.h" #include "ivas_stat_com.h" #include "ivas_error_utils.h" diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index e7eaea5b7..cd046cb5b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -42,6 +42,7 @@ #include "stat_com.h" #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" +#include "ivas_stat_rend.h" #include "ivas_stat_com.h" #include "ivas_error_utils.h" @@ -2608,6 +2609,52 @@ Word16 getNumChanAnalysis_fx( Encoder_Struct *st_ivas /* i : IVAS encoder structure */ ); +/*----------------------------------------------------------------------------------* + * Limiter prototypes + *----------------------------------------------------------------------------------*/ + + +ivas_error ivas_limiter_open( + IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ + const int16_t num_channels, /* i : number of I/O channels */ + const int32_t sampling_rate /* i : sampling rate for processing */ +); + +void ivas_limiter_close( + IVAS_LIMITER_HANDLE *phLimiter /* i/o: pointer to limiter handle, can be NULL */ +); + +void ivas_limiter_dec( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + const int16_t num_channels, /* i : number of channels to be processed */ + const int16_t output_frame, /* i : number of samples per channel in the buffer */ + const int16_t BER_detect /* i : BER detect flag */ +); +void ivas_limiter_dec_fx( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + const Word16 num_channels, /* i : number of channels to be processed */ + const Word16 output_frame, /* i : number of samples per channel in the buffer */ + const Word16 BER_detect, /* i : BER detect flag */ + Word16 q_factor /* i : Q factor of the output samples */ +); +void limiter_process( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ + const float threshold, /* i : signal amplitude above which limiting starts to be applied */ + const int16_t BER_detect, /* i : BER detect flag */ + int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ +); +void limiter_process_fx( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + const Word16 output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ + const Word32 threshold, /* i : signal amplitude above which limiting starts to be applied */ + const Word16 BER_detect, /* i : BER detect flag */ + Word16 *strong_saturation_cnt, /* i/o: counter of strong saturations (can be NULL) */ + Word16 q_factor /* i : Q factor of output samples */ +); + ivas_error ivas_limiter_open_fx( IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ const Word16 max_num_channels, /* i : maximum number of I/O channels to be processed */ @@ -3647,14 +3694,22 @@ ivas_error ivas_allocate_binaural_hrtf_fx( ); void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, +#endif + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ +#else Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - Word16 *Q_in /* i : LS signals exp */ +#endif + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + Word16 *Q_in /* i : LS signals exp */ ); void ivas_binaural_add_LFE_fx( @@ -5855,4 +5910,38 @@ void reset_metadata_spatial_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 nb_bits_metadata /* i : number of meatdata bits */ ); + +void Euler2Quat( + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ +); +void Euler2Quat_fx( + const Word32 yaw, /* i : yaw (x) Q22 */ + const Word32 pitch, /* i : pitch (y) Q22 */ + const Word32 roll, /* i : roll (z) Q22 */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ +); +float deg2rad( + float degrees ); + +Word32 deg2rad_fx( + Word32 degrees ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); +void Quat2EulerDegree_fx( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + Word32 *yaw_fx, /* o : yaw */ + Word32 *pitch_fx, /* o : pitch */ + Word32 *roll_fx /* o : roll */ +); +#endif + #endif diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c new file mode 100644 index 000000000..d50eb4304 --- /dev/null +++ b/lib_com/ivas_rotation_com.c @@ -0,0 +1,270 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "ivas_cnst.h" +#include +#include +#include "options.h" +#include +#include "cnst.h" +#include "prot.h" +#include "ivas_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" +#include "prot_fx2.h" +#include "basop_mpy.h" +#include "basop_util.h" +#include "enh64.h" +/*------------------------------------------------------------------------- + * Euler2Quat() + * + * Calculate corresponding Quaternion from Euler angles in radians + *------------------------------------------------------------------------*/ +void Euler2Quat_fx( + const Word32 yaw, /* i : yaw (x) Q22 */ + const Word32 pitch, /* i : pitch (y) Q22 */ + const Word32 roll, /* i : roll (z) Q22 */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation Q19 */ +) +{ + Word16 cr = getCosWord16( extract_l( L_shr_r( roll, 10 ) ) ); // Q14 + Word16 sr = getSinWord16( extract_l( L_shr_r( roll, 10 ) ) ); + Word16 cp = getCosWord16( extract_l( L_shr_r( pitch, 10 ) ) ); + Word16 sp = getSinWord16( extract_l( L_shr_r( pitch, 10 ) ) ); + Word16 cy = getCosWord16( extract_l( L_shr_r( yaw, 10 ) ) ); + Word16 sy = getSinWord16( extract_l( L_shr_r( yaw, 10 ) ) ); + quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); // Q19 + move32(); + quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); // Q19 + move32(); + quat->y_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( sr, cp ), sy ), Mpy_32_16_1( L_mult0( cr, sp ), cy ) ), 5 ); // Q19 + move32(); + quat->z_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( cr, cp ), sy ), Mpy_32_16_1( L_mult0( sr, sp ), cy ) ), 5 ); // Q19 + move32(); + + return; +} +void Euler2Quat( + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ +) +{ + float cr = cosf( roll * 0.5f ); + float sr = sinf( roll * 0.5f ); + float cp = cosf( pitch * 0.5f ); + float sp = sinf( pitch * 0.5f ); + float cy = cosf( yaw * 0.5f ); + float sy = sinf( yaw * 0.5f ); + quat->w = cr * cp * cy + sr * sp * sy; + quat->x = sr * cp * cy - cr * sp * sy; + quat->y = sr * cp * sy + cr * sp * cy; + quat->z = cr * cp * sy - sr * sp * cy; + + return; +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * Quat2EulerDegree() + * + * Quaternion handling: calculate corresponding Euler angles in degrees + *------------------------------------------------------------------------*/ +void Quat2EulerDegree_fx( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + Word32 *yaw_fx, /* o : yaw */ + Word32 *pitch_fx, /* o : pitch */ + Word32 *roll_fx /* o : roll */ +) +{ + IF( NE_32( quat.w_fx, L_negate( 12582912 ) /*3.0f in Q22*/ ) ) + { + Word32 tmp1 = W_extract_l( W_shr( W_mult0_32_32( quat.w_fx, quat.x_fx ), Q22 ) ); // Q22 + Word32 tmp2 = W_extract_l( W_shr( W_mult0_32_32( quat.y_fx, quat.z_fx ), Q22 ) ); // Q22 + Word32 tmp3 = L_shl( L_add( tmp1, tmp2 ), 1 ); // Q22 + + Word32 tmp4 = W_extract_l( W_shr( W_mult0_32_32( quat.x_fx, quat.x_fx ), Q22 ) ); // Q22 + Word32 tmp5 = W_extract_l( W_shr( W_mult0_32_32( quat.y_fx, quat.y_fx ), Q22 ) ); // Q22 + Word32 tmp6 = L_shl( L_add( tmp4, tmp5 ), 1 ); + Word32 tmp7 = L_sub( ONE_IN_Q22, tmp6 ); + + IF( tmp3 >= -2 && tmp3 <= 2 ) + { + tmp3 = 0; + } + IF( tmp7 >= -2 && tmp7 <= 2 ) + { + tmp7 = 0; + } + + Word16 yaw_fx_16 = BASOP_util_atan2( tmp3, tmp7, 0 ); // Q13 + *yaw_fx = Mpy_32_16_1( 961263669 /*_180_OVER_PI in Q24*/, yaw_fx_16 ); + + Word32 p_fx; + Word32 tmp8 = W_extract_l( W_shr( W_mult0_32_32( quat.w_fx, quat.y_fx ), Q22 ) ); // Q22 + Word32 tmp9 = W_extract_l( W_shr( W_mult0_32_32( quat.z_fx, quat.x_fx ), Q22 ) ); // Q22 + p_fx = L_shl( L_sub( tmp8, tmp9 ), 1 ); + p_fx = max( L_negate( ONE_IN_Q22 ), min( ONE_IN_Q22, p_fx ) ); // Q22 + + Word32 p_fx_sq = W_extract_l( W_shr( W_mult0_32_32( p_fx, p_fx ), Q22 ) ); + Word16 res_exp = 0; + Word32 one_minus_p_fx_sq = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( p_fx_sq ), 31 - Q22, &res_exp ); + Word32 sqrt_one_minus_p_fx_sq = Sqrt32( one_minus_p_fx_sq, &res_exp ); + + Word16 pitch_fx_16 = BASOP_util_atan2( p_fx, sqrt_one_minus_p_fx_sq, ( 31 - Q22 ) - res_exp ); + + *pitch_fx = Mpy_32_16_1( 961263669 /*_180_OVER_PI in Q24*/, pitch_fx_16 ); + + Word32 tmp10 = W_extract_l( W_shr( W_mult0_32_32( quat.w_fx, quat.z_fx ), Q22 ) ); // Q22 + Word32 tmp11 = W_extract_l( W_shr( W_mult0_32_32( quat.x_fx, quat.y_fx ), Q22 ) ); // Q22 + Word32 tmp12 = L_shl( L_add( tmp10, tmp11 ), 1 ); // Q22 + + Word32 tmp13 = W_extract_l( W_shr( W_mult0_32_32( quat.y_fx, quat.y_fx ), Q22 ) ); // Q22 + Word32 tmp14 = W_extract_l( W_shr( W_mult0_32_32( quat.z_fx, quat.z_fx ), Q22 ) ); // Q22 + Word32 tmp15 = L_shl( L_add( tmp13, tmp14 ), 1 ); // Q22 + Word32 tmp16 = L_sub( ONE_IN_Q22, tmp15 ); // Q22 + + IF( tmp12 >= -2 && tmp12 <= 2 ) + { + tmp12 = 0; + } + IF( tmp16 >= -2 && tmp16 <= 2 ) + { + tmp16 = 0; + } + Word16 roll_fx_16 = BASOP_util_atan2( tmp12, tmp16, 0 ); // Q13 + *roll_fx = Mpy_32_16_1( 961263669 /*_180_OVER_PI in Q24*/, roll_fx_16 ); + } + ELSE + { + /* Euler angles in R_X(roll)*R_Y(pitch)*R_Z(yaw) convention + * + * yaw: rotate scene counter-clockwise in the horizontal plane + * pitch: rotate scene in the median plane, increase elevation with positive values + * roll: rotate scene from the right ear to the top + */ + *yaw_fx = quat.z_fx; + *pitch_fx = quat.y_fx; + *roll_fx = quat.x_fx; + } + + return; +} + +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +) +{ + if ( quat.w != -3.0 ) + { + float p; + + *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); + + p = 2 * ( quat.w * quat.y - quat.z * quat.x ); + p = max( -1.0f, min( 1.0f, p ) ); + *pitch = asinf( p ); + + *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); + + *yaw *= _180_OVER_PI; + *pitch *= _180_OVER_PI; + *roll *= _180_OVER_PI; + } + else + { + /* Euler angles in R_X(roll)*R_Y(pitch)*R_Z(yaw) convention + * + * yaw: rotate scene counter-clockwise in the horizontal plane + * pitch: rotate scene in the median plane, increase elevation with positive values + * roll: rotate scene from the right ear to the top + */ + *yaw = quat.z; + *pitch = quat.y; + *roll = quat.x; + } + + return; +} +#endif + +/*------------------------------------------------------------------------- + * deg2rad() + * + * Converts degrees to normalized radians + *------------------------------------------------------------------------*/ +#define DEGREE_180 ( Word32 )( 180.0 * ONE_IN_Q22 ) +#define DEGREE_360 ( Word32 )( 360.0 * ONE_IN_Q22 ) +#define PI_OVER_180_FX ( Word32 )( ( EVS_PI / 180.0f ) * ONE_IN_Q31 ) +/*------------------------------------------------------------------------- + * deg2rad() + * + * Converts degrees to normalized radians + *------------------------------------------------------------------------*/ +Word32 deg2rad_fx( + Word32 degrees // Q23 +) +{ + WHILE( GE_32( degrees, DEGREE_180 ) ) + { + degrees = L_sub( degrees, DEGREE_360 ); + } + WHILE( LE_32( degrees, -DEGREE_180 ) ) + { + degrees = L_add( degrees, DEGREE_360 ); + } + + return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q23 +} + +} +float deg2rad( + float degrees ) +{ + while ( degrees >= 180.0f ) + { + degrees = degrees - 360.0f; + } + while ( degrees <= -180.0f ) + { + degrees = degrees + 360.0f; + } + + return PI_OVER_180 * degrees; +} diff --git a/lib_com/options.h b/lib_com/options.h index 250116483..515c576f1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,4 +123,10 @@ #define FIX_ISSUE_1187 /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/ #define FIX_ISSUE_1186 /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */ #define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */ + +#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +#define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +#define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ +#endif #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 36246f739..bc31e32e8 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -63,7 +63,12 @@ static void ivas_binRenderer_filterModule_fx( Word32 CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals Q_curr*/ Word32 CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals Q_curr*/ const Word16 numTimeSlots, /* i : number of time slots to process */ - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 pos_idx, /* i : pose index */ +#else + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ +#endif Word16 Q_curr ) { Word16 bandIdx, k, chIdx, tapIdx; @@ -75,9 +80,15 @@ static void ivas_binRenderer_filterModule_fx( { FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); + filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); + Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx][0] ); +#else filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx][0] ); +#endif filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 @@ -180,9 +191,18 @@ static ivas_error ivas_binRenderer_convModuleOpen( const Word16 renderer_type, const Word16 isLoudspeaker, const AUDIO_CONFIG input_config, - const HRTFS_FASTCONV_HANDLE hHrtf ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses +#else + const HRTFS_FASTCONV_HANDLE hHrtf +#endif +) { Word16 bandIdx, chIdx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; @@ -308,7 +328,77 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } + } + } +#else IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); @@ -359,6 +449,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } } +#endif /* set memories */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 95cca12a0..46cb389bf 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -980,6 +980,9 @@ ivas_error ivas_dirac_dec_config_fx( Word16 need_parambin; Word16 dec_param_estim_old; Word16 dec_param_estim_new; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 num_poses, pos_idx; +#endif error = IVAS_ERR_OK; move32(); @@ -1010,6 +1013,16 @@ ivas_error ivas_dirac_dec_config_fx( move16(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + num_poses = 1; + move16(); + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } +#endif + sparfoa_flag = 0; move16(); test(); @@ -1056,7 +1069,11 @@ ivas_error ivas_dirac_dec_config_fx( IF( !need_parambin ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif } need_dirac_rend = 0; @@ -1129,7 +1146,11 @@ ivas_error ivas_dirac_dec_config_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0] == NULL ) +#else IF( st_ivas->hDiracDecBin == NULL ) +#endif { IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) { @@ -1141,34 +1162,75 @@ ivas_error ivas_dirac_dec_config_fx( /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */ test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params != NULL && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->nSCE > 0 ) ) +#else IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->nSCE > 0 ) ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_decorr_close_fx( &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ); // done +#else ivas_dirac_dec_decorr_close_fx( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); // done +#endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* copy td-decorr flag to split renderer side rendereres */ + FOR( pos_idx = 1; pos_idx < num_poses; pos_idx++ ) + { + st_ivas->hDiracDecBin[pos_idx]->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; + } + IF( !st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else IF( !st_ivas->hDiracDecBin->useTdDecorr ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) +#else IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params == NULL ) +#endif { Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); - +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, frequency_axis_fx, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis_fx, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } +#endif } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + move16(); + } +#else st_ivas->hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); move16(); +#endif } } } @@ -2185,8 +2247,13 @@ void ivas_dirac_dec_render_sf_fx( /*CLDFB: last output channels reserved to LFT for CICPx*/ Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#else Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif Word16 index = 0, num_freq_bands = 0; move16(); move16(); @@ -3712,7 +3779,29 @@ void ivas_dirac_dec_render_sf_fx( input_q = Q6; move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + FOR( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) + { + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); + } + } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); + } + } +#endif + ivas_binRenderer_fx( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, @@ -3721,6 +3810,24 @@ void ivas_dirac_dec_render_sf_fx( Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + Word16 pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[( add( i_mult( pos_idx, BINAURAL_CHANNELS ) ), ch )][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); // Q6 + Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[( add( i_mult( pos_idx, BINAURAL_CHANNELS ) ), ch )][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); // Q6 + } + } + } + } +#endif + /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { @@ -3730,10 +3837,17 @@ void ivas_dirac_dec_render_sf_fx( Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; + move32(); + ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[0][ch][i]; + move32(); +#else RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; move32(); ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; move32(); +#endif } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6-1 diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 35844b5e5..8fe884c3f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -44,6 +44,11 @@ #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_prot_fx.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lib_isar_pre_rend.h" +#include "isar_prot.h" +#include "isar_stat.h" +#endif /*-------------------------------------------------------------------* @@ -55,6 +60,215 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_re static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); + + +/*-------------------------------------------------------------------* + * ivas_dec_reconfig_split_rend() + * + * IVAS decoder split rend reconfig + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + Word16 cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; + SPLIT_REND_WRAPPER *hSplitRendWrapper; + + hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; + move16(); + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + move16(); + cldfb_in_flag = 0; + move16(); + + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + cldfb_in_flag = 1; + move16(); + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + isCldfbNeeded = 0; + move16(); + + IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || + ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) + { + cldfb_in_flag = 0; + move16(); + } + + IF( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) + { + IF( EQ_16( cldfb_in_flag, 0 ) ) + { + isCldfbNeeded = 1; + move16(); + } + ELSE IF( EQ_16( st_ivas->hRenderConfig->split_rend_config.codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) && cldfb_in_flag ) + { + isCldfbNeeded = 1; + move16(); + } + ELSE IF( pcm_out_flag && cldfb_in_flag ) + { + isCldfbNeeded = 1; + move16(); + } + } + ELSE IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + isCldfbNeeded = 1; + move16(); + } + + IF( EQ_16( isCldfbNeeded, 1 ) && hSplitRendWrapper->hCldfbHandles == NULL ) + { + IF( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + + num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS ); + move16(); + FOR( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + move16(); + } + + num_ch = i_mult( hSplitRendWrapper->multiBinPoseData.num_poses, BINAURAL_CHANNELS ); + move16(); + + FOR( ch = 0; ch < num_ch; ch++ ) + { + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + } + } + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + ELSE IF( EQ_16( isCldfbNeeded, 0 ) && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS ); + move16(); + FOR( ch = 0; ch < num_ch; ch++ ) + { + IF( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + move32(); + } + } + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + move32(); + } + } + + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + move32(); + } + + IF( ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) && + ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && + !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) /* td-rend not needed? */ + { + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + IF( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + move32(); + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + } + } + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_dec_init_split_rend() + * + * IVAS decoder split rend init + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + Word16 cldfb_in_flag, pcm_out_flag; + Word16 mixed_td_cldfb_flag; + + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; + move16(); + + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + cldfb_in_flag = 1; + move16(); + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + IF( EQ_16( cldfb_in_flag, 1 ) && ( EQ_16( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) ) + { + IF( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } + + mixed_td_cldfb_flag = 0; + move16(); + IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || + ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) + { + mixed_td_cldfb_flag = 1; + move16(); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + move16(); +#else + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + move16(); +#endif + return error; +} +#endif + /*-------------------------------------------------------------------* * ivas_dec_setup() * @@ -524,6 +738,20 @@ ivas_error ivas_dec_setup( } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * reconfig split rendering as renderer might change after bitrate switching + *-----------------------------------------------------------------*/ + + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + /*----------------------------------------------------------------* * Reset bitstream pointers *----------------------------------------------------------------*/ @@ -958,7 +1186,12 @@ ivas_error ivas_init_decoder_front( *--------------------------------------------------------------------*/ test(); test(); - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) +#endif + ) { IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) { @@ -1133,6 +1366,20 @@ ivas_error ivas_init_decoder_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * Initialize binuaral split rendering + *-----------------------------------------------------------------*/ + + IF( st_ivas->hSplitBinRend != NULL && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && EQ_16( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) ) + { + IF( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles @@ -2071,9 +2318,15 @@ ivas_error ivas_init_decoder_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -2237,6 +2490,9 @@ ivas_error ivas_init_decoder_fx( { IF( st_ivas->hBinRenderer->render_lfe ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif { /* Account for filterbank delay */ binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS ); @@ -2586,7 +2842,14 @@ void ivas_initialize_handles_dec( /* rendering handles */ st_ivas->hBinRenderer = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + st_ivas->hDiracDecBin[i] = NULL; + } +#else st_ivas->hDiracDecBin = NULL; +#endif st_ivas->hDirACRend = NULL; st_ivas->hSpatParamRendCom = NULL; st_ivas->hLsSetUpConversion = NULL; @@ -2611,7 +2874,13 @@ void ivas_initialize_handles_dec( st_ivas->hExtOrientationData = NULL; st_ivas->hCombinedOrientationData = NULL; - +#ifdef SPLIT_REND_WITH_HEAD_ROT + st_ivas->hSplitBinRend = NULL; + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + st_ivas->hTdRendHandles[i] = NULL; + } +#endif /* JBM handles */ st_ivas->hTcBuffer = NULL; st_ivas->hJbmMetadata = NULL; @@ -2748,12 +3017,31 @@ void ivas_destroy_dec_fx( /* Fastconv binaural renderer handle */ ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* TD binaural renderer handles */ + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] ); + } + } +#endif + /* Parametric binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Crend handle */ - +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); +#endif /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); @@ -2919,7 +3207,12 @@ void ivas_init_dec_get_num_cldfb_instances( move16(); } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else IF( st_ivas->hDiracDecBin->useTdDecorr ) +#endif { *numCldfbAnalyses = add( *numCldfbAnalyses, 2 ); move16(); @@ -3206,12 +3499,22 @@ static ivas_error doSanityChecks_IVAS( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_16( output_Fs, 48000 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); + } +#endif IF( st_ivas->hDecoderConfig->Opt_Headrotation ) { test(); test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) ) { return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" ); } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index a5f7f7b06..6f1ae3de8 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -198,10 +198,18 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); test(); - IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { /* close the parametric binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Open the TD Binaural renderer */ test(); IF( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) @@ -234,13 +242,24 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { /* close the parametric binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Open Crend Binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } +#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; move32(); @@ -258,7 +277,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } test(); - IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { /* open the parametric binaural renderer */ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) @@ -303,7 +326,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } /* close the crend binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); +#endif } } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 9514e5e2a..50d1811f6 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -556,7 +556,11 @@ static ivas_error ivas_param_ism_rendering_init_fx( test(); test(); test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) ) { /* computation of proto matrix */ ivas_ism_get_proto_matrix_fx( hOutSetup, nchan_transport, hParamIsmRendering->proto_matrix_fx ); @@ -734,7 +738,11 @@ ivas_error ivas_param_ism_dec_open_fx( test(); test(); IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) ) { /* Initialize efap handle */ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) @@ -757,7 +765,11 @@ ivas_error ivas_param_ism_dec_open_fx( test(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d69fa8525..0f762462c 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1688,11 +1688,19 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( test(); /* delay the objects here for all renderers where it is needed */ IF( - EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || - EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || - EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || - EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || - EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( +#endif + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || + EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + ) && + ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif + ) { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -1872,6 +1880,9 @@ ivas_error ivas_jbm_dec_render_fx( const Word16 output_q_factor = Q11; move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 nchan_out_syn_output; +#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -2064,6 +2075,26 @@ ivas_error ivas_jbm_dec_render_fx( #endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* Binaural rendering */ + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) + { + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural_fx( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + } +#else /* Binaural rendering */ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { @@ -2072,6 +2103,7 @@ ivas_error ivas_jbm_dec_render_fx( return error; } } +#endif ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; @@ -2090,10 +2122,19 @@ ivas_error ivas_jbm_dec_render_fx( { scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 } + +#if defined SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } +#endif + FOR( i = 0; i < nchan_out; i++ ) { scale_sig32( p_output_fx[i], *nSamplesRendered, sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 @@ -2314,14 +2355,40 @@ ivas_error ivas_jbm_dec_render_fx( scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + +#if defined SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } +#endif - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif FOR( i = 0; i < nchan_in; i++ ) { @@ -2345,12 +2412,26 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - return error; + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } } + else + { +#endif + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) @@ -2362,7 +2443,13 @@ ivas_error ivas_jbm_dec_render_fx( /* Rendering */ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { - ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*handled in CLDFB domain already*/ + IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif + { + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); + } } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { @@ -2578,6 +2665,20 @@ ivas_error ivas_jbm_dec_render_fx( move16(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); + move16(); + } + ELSE + { + nchan_out_syn_output = nchan_out; + move16(); + } + + IF( st_ivas->hDecoderConfig->Opt_Limiter ) +#endif { IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) { @@ -2587,7 +2688,11 @@ ivas_error ivas_jbm_dec_render_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out_syn_output, data ); +#else ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out, data ); +#endif *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; move16(); @@ -2713,12 +2818,21 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); +#if defined SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } +#endif } } ELSE @@ -2745,12 +2859,22 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); + +#if defined SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } +#endif ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } @@ -2866,6 +2990,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *nSamplesRendered = n_samples_to_render; move16(); /* Only write out the valid data*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDecoderConfig->Opt_Limiter ) +#endif { IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 983eb3309..e87d5da00 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1581,6 +1581,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; ivas_error error; Word32 ism_total_brate; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif error = IVAS_ERR_OK; move16(); @@ -1611,8 +1614,13 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend == NULL ) || + ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] == NULL ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend == NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin == NULL ) ) +#endif { /* init a new DirAC dec */ if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) @@ -1625,7 +1633,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( st_ivas->hDirAC != NULL ) { /* close all unnecessary parametric decoding and rendering */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); @@ -1676,7 +1688,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) +#endif { if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { @@ -1732,7 +1748,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) +#endif { if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { @@ -1750,7 +1770,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) +#endif { if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1760,12 +1784,24 @@ ivas_error ivas_masa_dec_reconfigure_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + IF( st_ivas->hDiracDecBin[pos_idx] != NULL ) + { + /* regularization factor is bitrate-dependent */ + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + move16(); + } + } +#else IF( st_ivas->hDiracDecBin != NULL ) { /* regularization factor is bitrate-dependent */ st_ivas->hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); move16(); } +#endif test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching within OMASA is handled in ivas_omasa_dec_config() */ @@ -1773,9 +1809,17 @@ ivas_error ivas_masa_dec_reconfigure_fx( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0] != NULL ) +#else IF( st_ivas->hDiracDecBin != NULL ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -2012,7 +2056,11 @@ void ivas_spar_param_to_masa_param_mapping_fx( move16(); hSpatParamRendCom->numSimultaneousDirections = 1; move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; +#else hDiffuseDist = st_ivas->hDiracDecBin->hDiffuseDist; +#endif nchan_transport = st_ivas->nchan_transport; move16(); band_grouping = hDirAC->band_grouping; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 4175d15de..7e96c0717 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1844,8 +1844,13 @@ void ivas_param_mc_dec_render_fx( /*CLDFB*/ Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { @@ -2179,8 +2184,31 @@ void ivas_param_mc_dec_render_fx( { Word16 input_q = 6; move16(); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + FOR( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + } + } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); + } + } +#endif + /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, @@ -2207,6 +2235,25 @@ void ivas_param_mc_dec_render_fx( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + int16_t pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) + { + Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + } + } + } + } +#endif + /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } @@ -2230,8 +2277,13 @@ void ivas_param_mc_dec_render_fx( { IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; // Q6 + ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[0][ch][i]; // Q6 +#else RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; // Q6 ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; // Q6 +#endif } ELSE { diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index c1bf455a5..f998b0d1b 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -723,13 +723,24 @@ static void ivas_mc_paramupmix_dec_sf( Word32 Cldfb_RealBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #endif // MSAN_FIX + +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + int16_t slot_index_start; +#else Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); push_wmops( "ivas_mc_paramupmix_dec_sf" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + slot_index_start = st_ivas->hTcBuffer->slots_rendered; +#endif + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { pPcm_temp_fx[2 * i] = output_fx[i + 4]; /* un-decorrelated Q11*/ @@ -844,14 +855,40 @@ static void ivas_mc_paramupmix_dec_sf( Word16 input_q = 6; move16(); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*LFE handling for split rendering cases*/ + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + { + FOR( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + Copy32( Cldfb_RealBuffer_subfr[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][add( slot_index_start, slot_idx )], maxBand ); + Copy32( Cldfb_ImagBuffer_subfr[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][add( slot_index_start, slot_idx )], maxBand ); + } + } + + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); + } + } +#endif + /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) @@ -860,6 +897,25 @@ static void ivas_mc_paramupmix_dec_sf( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + int16_t pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) + { + FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + Copy32( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); + Copy32( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); + } + } + } + } +#endif + /* Implement CLDFB synthesis */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -868,8 +924,13 @@ static void ivas_mc_paramupmix_dec_sf( FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 + ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 +#else RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; // Q6 ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 +#endif } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); // Q11 -> Q5 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f3afead8f..8e34d6642 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1455,7 +1455,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); test(); test(); - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { /* remove unneeded binaural renderers */ test(); @@ -1470,10 +1474,17 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != NULL ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || NE_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) ) +#else IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || NE_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) ) +#endif { - +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); +#endif } test(); @@ -1486,13 +1497,21 @@ static ivas_error ivas_mc_dec_reconfig_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0] != NULL ) +#else IF( st_ivas->hDiracDecBin != NULL ) +#endif { test(); test(); IF( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif } } @@ -1517,22 +1536,39 @@ static ivas_error ivas_mc_dec_reconfig_fx( } IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) +#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + st_ivas->hCrendWrapper->hCrend[0] = NULL; + st_ivas->hCrendWrapper->hHrtfCrend = NULL; + IF( ( st_ivas->hCrendWrapper->hCrend[0] = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); + } +#else st_ivas->hCrendWrapper->hCrend = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; IF( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } +#endif } } ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 256ce8f96..12ed81e07 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -342,3 +342,158 @@ ivas_error ivas_td_binaural_renderer_sf_fx( return IVAS_ERR_OK; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * ivas_td_binaural_renderer_sf_splitBinaural() + * + * Render to multiple binaural pairs based on relative head positions for split rendering. + *---------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word32 *output[], /* i/o: SCE channels / Binaural synthesis */ + const Word16 nSamplesRendered /* i : number of samples to render */ +) +{ + Word16 i; + Word16 pos_idx; + IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + BINAURAL_TD_OBJECT_RENDERER_HANDLE origTdRendHandle; + ivas_error error; + Word16 original_subframes_rendered; + Word16 original_slots_rendered; + Word32 *p_bin_output[BINAURAL_CHANNELS]; + Word32 output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + + pMultiBinPoseData = &st_ivas->hSplitBinRend->splitrend.multiBinPoseData; + move32(); + + /* If not yet allocated, open additional instances of TD renderer */ + FOR( i = 0; i < pMultiBinPoseData->num_poses - 1; ++i ) + { + IF( st_ivas->hTdRendHandles[i] != NULL ) + { + continue; + } + + IF( ( error = ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, + st_ivas->hDecoderConfig->output_Fs, + st_ivas->nchan_transport, + st_ivas->ivas_format, + st_ivas->transport_config, + st_ivas->hRenderConfig->directivity_fx, + st_ivas->hTransSetup, + &st_ivas->hTdRendHandles[i], + &st_ivas->binaural_latency_ns, + SrcInd ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Save current head positions */ + FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i]; + } + + original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + move16(); + original_slots_rendered = st_ivas->hTcBuffer->slots_rendered; + move16(); + origTdRendHandle = st_ivas->hBinRendererTd; + move32(); + + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + IF( NE_16( pos_idx, 0 ) ) + { + FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + IF( EQ_32( originalHeadRot[i].w_fx, -1610612736 /* -3.0f in Q29 */ ) ) + { + assert( 0 ); + } + else + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -12582912; // Q22 + move32(); + + Quat2EulerDegree( originalHeadRot[i], /* TODO tmu : fix bug with ordering*/ + &st_ivas->hCombinedOrientationData->Quaternions[i].z_fx, + &st_ivas->hCombinedOrientationData->Quaternions[i].y_fx, + &st_ivas->hCombinedOrientationData->Quaternions[i].x_fx ); + + st_ivas->hCombinedOrientationData->Quaternions[i].x_fx = L_add( st_ivas->hCombinedOrientationData->Quaternions[i].x_fx, pMultiBinPoseData->relative_head_poses[pos_idx][0] ); + st_ivas->hCombinedOrientationData->Quaternions[i].y_fx = L_add( st_ivas->hCombinedOrientationData->Quaternions[i].y_fx, pMultiBinPoseData->relative_head_poses[pos_idx][1] ); + st_ivas->hCombinedOrientationData->Quaternions[i].z_fx = L_add( st_ivas->hCombinedOrientationData->Quaternions[i].z_fx, pMultiBinPoseData->relative_head_poses[pos_idx][2] ); + move32(); + move32(); + move32(); + + Euler2Quat_fx( deg2rad_fx( st_ivas->hCombinedOrientationData->Quaternions[i].x_fx ), deg2rad_fx( st_ivas->hCombinedOrientationData->Quaternions[i].y_fx ), deg2rad_fx( st_ivas->hCombinedOrientationData->Quaternions[i].z_fx ), &st_ivas->hCombinedOrientationData->Quaternions[i] ); + } + } + } + + /* set output channels */ + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + p_bin_output[i] = output_local[add( i_mult( pos_idx, BINAURAL_CHANNELS ), i )]; + move32(); + } + st_ivas->hTcBuffer->subframes_rendered = original_subframes_rendered; + move16(); + st_ivas->hTcBuffer->slots_rendered = original_slots_rendered; + move16(); + + /* update combined orientation access index */ + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + + /* Render */ + IF( NE_16( pos_idx, 0 ) ) + { + st_ivas->hBinRendererTd = st_ivas->hTdRendHandles[sub( pos_idx, 1 )]; + move32(); + } + + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_bin_output, nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) + { + Word32 *p_tc[MAX_TRANSPORT_CHANNELS]; + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) + { + p_tc[i] = st_ivas->hTcBuffer->tc[i] + st_ivas->hTcBuffer->n_samples_rendered; + } + ivas_binaural_add_LFE_fx( st_ivas, nSamplesRendered, p_tc, p_bin_output ); + } + } + + FOR( i = 0; i < i_mult( pMultiBinPoseData->num_poses, BINAURAL_CHANNELS ); i++ ) + { + Copy32( output_local[i], output[i], nSamplesRendered ); + } + + /* Restore original head rotation */ + FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + move32(); + } + + /* restore original td renderer handle */ + st_ivas->hBinRendererTd = origTdRendHandle; + move32(); + + return IVAS_ERR_OK; +} +#endif \ No newline at end of file diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 509217616..b4f757025 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -422,10 +422,17 @@ ivas_error ivas_omasa_dec_config_fx( * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0] != NULL ) +#else IF( st_ivas->hDiracDecBin != NULL ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) - +#endif { return error; } @@ -761,6 +768,12 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Word32 *p_sepobj_fx[MAX_NUM_OBJECTS]; // Q11 Word32 data_separated_objects_fx[MAX_NUM_OBJECTS][L_FRAME48k]; move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 slot_idx_start; + + slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; + move16(); +#endif FOR( n = 0; n < MAX_NUM_OBJECTS; n++ ) { @@ -788,15 +801,64 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( /* reset combined orientation access index before calling the td renderer */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - return error; - } + Word16 slot_idx, num_cldfb_bands, nchan_transport_orig, cldfb_slots; + Word32 Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + Word32 *p_rend_obj[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* [8 * 2] */ + Word16 q_cldfb = 11; + move16(); - FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) + FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); n++ ) + { + p_rend_obj[n] = &output_f[n][0]; + move32(); + } + + num_cldfb_bands = st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + move16(); + nchan_transport_orig = st_ivas->nchan_transport; + move16(); + st_ivas->nchan_transport = st_ivas->nchan_ism; + move16(); + + IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_rend_obj, *nSamplesRendered ) ) != IVAS_ERR_OK ) /* objects are read from st_ivas->hTcBuffer->tc[2..(1+n_isms)] */ + { + return error; + } + st_ivas->nchan_transport = nchan_transport_orig; + move16(); + cldfb_slots = *nSamplesRendered / num_cldfb_bands; + + FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); ++n ) + { + FOR( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) + { + cldfbAnalysis_ts_fx_fixed_q( &( p_rend_obj[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n], &q_cldfb ); + + /* note: this intentionally differs from OSBA by: no scaling by 0.5 */ + v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_RealBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); + v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_ImagBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); + } + } + } + else { - v_add_fx( output_fx[n], p_sepobj_fx[n], output_fx[n], *nSamplesRendered ); +#endif + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } + + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + v_add_fx( output_fx[n], p_sepobj_fx[n], output_fx[n], *nSamplesRendered ); + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index f9d14c995..b71b73a6a 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -140,6 +140,12 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; Word16 channel_offset; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 slot_idx_start; + + slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; + move16(); +#endif FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { @@ -154,20 +160,71 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( return error; } - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - return error; - } + Word16 slot_idx, num_cldfb_bands, b, nchan_transport_orig; + Word16 cldfb_slots; + Word32 Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + Word16 q_cldfb = 11; + move16(); + + num_cldfb_bands = st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + move16(); + nchan_transport_orig = st_ivas->nchan_transport; + move16(); + st_ivas->nchan_transport = st_ivas->nchan_ism; + move16(); + IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + st_ivas->nchan_transport = nchan_transport_orig; + move16(); + cldfb_slots = *nSamplesRendered / num_cldfb_bands; - FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) + FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); ++n ) + { + FOR( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) + { + cldfbAnalysis_ts_fx_fixed_q( &( output_f[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n], &q_cldfb ); + + FOR( b = 0; b < num_cldfb_bands; b++ ) + { + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] = + L_add( L_shr( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][add( slot_idx_start, slot_idx )][b], 1 ), + L_shr( Cldfb_RealBuffer[b], 1 ) ); + move32(); + + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] = + L_add( L_shr( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][add(slot_idx_start, slot_idx)][b], 1 ), + L_shrCldfb_ImagBuffer[b], 1) ); + move32(); + } + } + } + } + else { - Word16 i; - FOR( i = 0; i < nSamplesAsked; i++ ) +#endif + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + { + return error; + } + + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { - output_fx[n][i] = L_add( L_shr( output_fx[channel_offset + n][i], 1 ), L_shr( p_sepobj_fx[n][i], 1 ) ); - move32(); + Word16 i; + FOR( i = 0; i < nSamplesAsked; i++ ) + { + output_fx[n][i] = L_add( L_shr( output_fx[channel_offset + n][i], 1 ), L_shr( p_sepobj_fx[n][i], 1 ) ); + move32(); + } } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 64995d8a0..d2aad8218 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -81,7 +81,11 @@ void ivas_renderer_select( test(); test(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { test(); test(); @@ -92,7 +96,11 @@ void ivas_renderer_select( { IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -106,7 +114,11 @@ void ivas_renderer_select( ELSE /* ISM_MODE_DISC */ { test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move16(); @@ -127,7 +139,11 @@ void ivas_renderer_select( *internal_config = output_config; move16(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -144,7 +160,11 @@ void ivas_renderer_select( move16(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; move16(); @@ -199,7 +219,11 @@ void ivas_renderer_select( *internal_config = output_config; move16(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -215,7 +239,11 @@ void ivas_renderer_select( *internal_config = transport_config; move16(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { test(); test(); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e27bc0638..f1ac7fa76 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -185,7 +185,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); test(); test(); - IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) ) { RENDERER_TYPE renderer_type_new; Word16 sba_order_internal; @@ -196,7 +200,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ IF( LE_16( ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_order_internal ), 2 ) ) { - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -210,7 +218,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( ELSE { test(); - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; move16(); @@ -628,6 +640,15 @@ ivas_error ivas_sba_dec_reconfigure_fx( * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0] != NULL ) + { + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + } +#else IF( st_ivas->hDiracDecBin != NULL ) { IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) @@ -635,6 +656,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( return error; } } +#endif /*-----------------------------------------------------------------* * CLDFB instances @@ -784,7 +806,11 @@ void ivas_sba_dec_digest_tc_fx( ivas_spar_dec_digest_tc_fx( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else IF( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) +#endif { Word16 nSamplesLeftForTD, default_frame; Word32 *decorr_signal[BINAURAL_CHANNELS]; @@ -807,9 +833,17 @@ void ivas_sba_dec_digest_tc_fx( { Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); /*Q0*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0]->hTdDecorr ) +#else IF( st_ivas->hDiracDecBin->hTdDecorr ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_td_decorr_process_fx( st_ivas->hDiracDecBin[0]->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#else ivas_td_decorr_process_fx( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#endif } FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index fdace42d8..628a32c2b 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1999,7 +1999,11 @@ void ivas_spar_dec_upmixer_sf_fx( test(); test(); test(); - IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) && + IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) ) && !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, -6 ); /*st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state-6*/ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index cf01ce54f..2d71508f7 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -40,6 +40,7 @@ #include "stat_dec.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" +#include "isar_stat.h" /*----------------------------------------------------------------------------------* @@ -859,6 +860,7 @@ typedef struct renderer_struct } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; +#ifndef SPLIT_REND_WITH_HEAD_ROT /* Fastconv binaural data structure */ typedef struct ivas_binaural_rendering_struct { @@ -882,8 +884,40 @@ typedef struct ivas_binaural_rendering_struct REVERB_STRUCT_HANDLE hReverb; } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * IVAS decoder specific ISAR wrapper structures + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + +} ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; + +typedef struct +{ + Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + IVAS_AUDIO_CONFIG config; + +} ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA, *ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; + +typedef struct +{ + ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ + ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ + SPLIT_REND_WRAPPER splitrend; + ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ + Word16 numTdSamplesPerChannelCached; + +} ISAR_DEC_SPLIT_REND_WRAPPER, *ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE; +#endif + /*----------------------------------------------------------------------------------* * MASA decoder structures *----------------------------------------------------------------------------------*/ @@ -1029,7 +1063,9 @@ typedef struct decoder_config_structure int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; int16_t Opt_delay_comp; /* flag indicating delay compensation active */ - +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t Opt_Limiter; +#endif } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; @@ -1106,7 +1142,11 @@ typedef struct Decoder_Struct BINAURAL_RENDERER_HANDLE hBinRenderer; /* fastconv binaural renderer handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; /* Time domain binaural object renderer handle */ TDREND_HRFILT_FiltSet_t *hHrtfTD; /* pointer to HRTF data for TD renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; /* parametric binaural renderer handle */ +#else DIRAC_DEC_BIN_HANDLE hDiracDecBin; /* parametric binaural renderer handle */ +#endif LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; /* MC LS configuration convertion handle */ EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ @@ -1130,6 +1170,10 @@ typedef struct Decoder_Struct int16_t flag_omasa_brate; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; +#endif /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ diff --git a/lib_isar/isar_MSPred.c b/lib_isar/isar_MSPred.c new file mode 100644 index 000000000..4dea48a9b --- /dev/null +++ b/lib_isar/isar_MSPred.c @@ -0,0 +1,550 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_rom_tables.h" +#include "isar_lcld_prot.h" +#include "isar_prot.h" +#include "wmc_auto.h" +#include "basop_util.h" +#include "enh64.h" +#include +/*-------------------------------------------------------------------* + * Function _round() + * + * + *-------------------------------------------------------------------*/ + +static int32_t _round( + float val ) +{ + return ( val > 0.0f ? (int32_t) ( val + 0.5f ) : (int32_t) ( val - 0.5f ) ); +} + + +/*-------------------------------------------------------------------* + * Function quantPhase() + * + * + *-------------------------------------------------------------------*/ + +Word32 quantPhase_fx( + Word32 phase, + Word16 exp ) // i:31? +{ + Word32 phaseQ; + + // phaseQ = _round(phase * PHASE_QUANT_FACTOR); + phaseQ = L_shr_r( Mpy_32_32( phase, PHASE_QUANT_FACTOR_FX_Q29 ), 29 - exp ); // Q60 + if ( phaseQ == PHASE_MAX_VAL ) + { + phaseQ = PHASE_MIN_VAL; + } + return phaseQ; +} + +int32_t quantPhase( + float phase ) +{ + int32_t phaseQ; + + phaseQ = _round( phase * PHASE_QUANT_FACTOR ); + if ( phaseQ == PHASE_MAX_VAL ) + { + phaseQ = PHASE_MIN_VAL; + } + return phaseQ; +} + + +/*-------------------------------------------------------------------* + * Function cplxmult() + * + * + *-------------------------------------------------------------------*/ +void cplxmult_fx( + Word32 *pr1, + Word32 *pi1, + Word32 r2, + Word32 i2 ) +{ + Word32 r1 = *pr1, i1 = *pi1; + + *pr1 = L_sub( Mpy_32_32( r1, r2 ), Mpy_32_32( i1, i2 ) ); + *pi1 = L_add( Mpy_32_32( r1, i2 ), Mpy_32_32( i1, r2 ) ); + + return; +} +void cplxmult( + float *pr1, + float *pi1, + float r2, + float i2 ) +{ + float r1 = *pr1, i1 = *pi1; + + *pr1 = r1 * r2 - i1 * i2; + *pi1 = r1 * i2 + i1 * r2; + + return; +} +/*-------------------------------------------------------------------* + * Function requantPhase() + * + * + *-------------------------------------------------------------------*/ + +Word32 requantPhase( + Word32 phaseQ ) +{ + + IF( GE_32( phaseQ, PHASE_MAX_VAL ) ) + { + phaseQ = L_add( phaseQ, PHASE_MAX_VAL ); + phaseQ %= ( L_shl( PHASE_MAX_VAL, 1 ) ); + phaseQ = L_sub( phaseQ, PHASE_MAX_VAL ); + } + ELSE IF( LT_32( phaseQ, PHASE_MIN_VAL ) ) + { + phaseQ = L_sub( phaseQ, PHASE_MAX_VAL ); + phaseQ %= ( L_shl( PHASE_MAX_VAL, 1 ) ); + phaseQ = L_add( phaseQ, PHASE_MAX_VAL ); + IF( EQ_32( phaseQ, PHASE_MAX_VAL ) ) + { + phaseQ = PHASE_MIN_VAL; + move32(); + } + } + + return phaseQ; +} + + +/*-------------------------------------------------------------------* + * Function quantPred() + * + * + *-------------------------------------------------------------------*/ + +Word32 quantPred_fx( + const Word32 pred, + Word16 exp ) // i:Q31 +{ + // int32_t predQ = _round(pred * PRED_QUANT_FACTOR); + Word32 predQ = W_round32_s( W_shl( W_mult_32_32( pred, (Word32) PRED_QUANT_FACTOR ), exp ) ); + predQ = predQ > PRED_MAX_VAL ? PRED_MAX_VAL : predQ; + predQ = predQ < PRED_MIN_VAL ? PRED_MIN_VAL : predQ; + + return predQ; +} +int32_t quantPred( + const float pred ) +{ + int32_t predQ = _round( pred * PRED_QUANT_FACTOR ); + predQ = predQ > PRED_MAX_VAL ? PRED_MAX_VAL : predQ; + predQ = predQ < PRED_MIN_VAL ? PRED_MIN_VAL : predQ; + + return predQ; +} + + +/*-------------------------------------------------------------------* + * Function dequantPhase() + * + * + *-------------------------------------------------------------------*/ + +float dequantPhase( + const int32_t phaseQ ) +{ + return (float) phaseQ / PHASE_QUANT_FACTOR; +} + + +/*-------------------------------------------------------------------* + * Function dequantPred() + * + * + *-------------------------------------------------------------------*/ +Word32 dequantPred_fx( Word32 predQ ) +{ + if ( predQ == 12 ) + { + return MAX_32; + } + Word16 tmp_e; + Word32 tmp, value; + if ( predQ == 0 ) + { + return predQ; + } + tmp = BASOP_Util_Divide3216_Scale( predQ, PRED_QUANT_FACTOR_FX, &tmp_e ); + value = L_shl( tmp, sub( 31, negate( add( 1, tmp_e ) ) ) ); // Q31 + return value; +} +float dequantPred( int32_t predQ ) +{ + return (float) predQ / PRED_QUANT_FACTOR; +} + + +/*-------------------------------------------------------------------* + * Function PrepEncode() + * + * + *-------------------------------------------------------------------*/ + +Word32 PrepEncode( + Word32 *piQuant, + const Word32 *piMSFlags, + const Word32 numBands ) +{ + Word32 b, numMSBands; + numMSBands = 0; + move32(); + + FOR( b = 0; b < numBands; b++ ) + { + IF( piMSFlags[b] ) + { + piQuant[numMSBands++] = piQuant[b]; + move32(); + } + } + + FOR( b = numMSBands; b < numBands; b++ ) + { + piQuant[b] = 0; + move32(); + } + + return numMSBands; +} + + +/*-------------------------------------------------------------------* + * Function EncodePhase() + * + * + *-------------------------------------------------------------------*/ + +void EncodePhase( + Word32 *phaseQuant, + const Word32 numMSBands, + const Word32 diffDim ) +{ + Word32 b; + + IF( GT_32( diffDim, 0 ) ) + { + Word32 tmp1, tmp2; + tmp1 = phaseQuant[0]; + move32(); + FOR( b = 1; b < numMSBands; b++ ) + { + tmp2 = phaseQuant[b]; + move32(); + phaseQuant[b] = L_sub( phaseQuant[b], tmp1 ); + tmp1 = tmp2; + move32(); + } + } + + IF( GT_32( diffDim, 1 ) ) + { + Word32 tmp1, tmp2; + tmp1 = phaseQuant[1]; + move32(); + FOR( b = 2; b < numMSBands; b++ ) + { + tmp2 = phaseQuant[b]; + move32(); + phaseQuant[b] = L_sub( phaseQuant[b], tmp1 ); + tmp1 = tmp2; + move32(); + } + } + FOR( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] = requantPhase( phaseQuant[b] ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function DecodePhase() + * + * + *-------------------------------------------------------------------*/ + +void DecodePhase( + Word32 *phaseQuant, + const Word32 numMSBands, + const Word32 diffDim ) +{ + Word32 b; + + IF( GT_32( diffDim, 1 ) ) + { + FOR( b = 2; b < numMSBands; b++ ) + { + phaseQuant[b] = L_add( phaseQuant[b], phaseQuant[b - 1] ); + move32(); + } + } + + IF( GT_32( diffDim, 0 ) ) + { + FOR( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] = L_add( phaseQuant[b], phaseQuant[b - 1] ); + move32(); + } + } + + FOR( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] = requantPhase( phaseQuant[b] ); + move32(); + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function EncodePredCoef() + * + * + *-------------------------------------------------------------------*/ + +Word32 EncodePredCoef( + Word32 *predQuant, + const Word32 numMSBands ) +{ + Word32 b, tmp1, tmp2; + + tmp1 = predQuant[0]; + move32(); + FOR( b = 1; b < numMSBands; b++ ) + { + tmp2 = predQuant[b]; + move32(); + predQuant[b] = L_sub( predQuant[b], tmp1 ); + tmp1 = tmp2; + move32(); + } + + return numMSBands; +} + + +/*-------------------------------------------------------------------* + * Function DecodePredCoef() + * + * + *-------------------------------------------------------------------*/ + +void DecodePredCoef( + Word32 *phaseQuant, + const Word32 numMSBands ) +{ + Word32 b; + + FOR( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] = L_add( phaseQuant[b], phaseQuant[b - 1] ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function CountMSBits() + * + * + *-------------------------------------------------------------------*/ + +Word32 CountMSBits( + Word32 iNumBands, + const Word32 iMSMode, + const Word32 *piMSFlags, + const Word32 *piLRPhaseDiff, + const Word32 *piMSPredCoef ) +{ + Word32 iBitsWritten = 0; + move32(); + Word32 b; + Word32 anyNonZero; + Word32 iNumMSBands = 0; + move32(); + Word32 piPhaseCopy[MAX_BANDS_48]; + Word32 piPredCopy[MAX_BANDS_48]; + + FOR( b = 0; b < MAX_BANDS_48; b++ ) + { + piPhaseCopy[b] = 0; + move32(); + piPredCopy[b] = 0; + move32(); + } + + iBitsWritten = L_add( iBitsWritten, 2 ); /* iMSMode */ + FOR( b = 0; b < iNumBands; b++ ) + { + iNumMSBands = L_add( iNumMSBands, NE_32( piMSFlags[b], 0 ) ); + } + + IF( EQ_32( iNumMSBands, 0 ) ) + { + return iBitsWritten; + } + + IF( LT_32( iNumMSBands, iNumBands ) ) + { + iBitsWritten = L_add( iBitsWritten, iNumBands ); /* piMSFlags */ + } + + IF( LT_32( iMSMode, 3 ) ) + { + return iBitsWritten; + } + + /* prepare arrays for coding evaluation */ + FOR( b = 0; b < iNumBands; b++ ) + { + piPhaseCopy[b] = piLRPhaseDiff[b]; + move32(); + piPredCopy[b] = piMSPredCoef[b]; + move32(); + } + + /* Differential Coding of Phase Data*/ + PrepEncode( piPhaseCopy, piMSFlags, iNumBands ); + PrepEncode( piPredCopy, piMSFlags, iNumBands ); + EncodePhase( piPhaseCopy, iNumMSBands, PHASE_DIFF_DIM ); + EncodePredCoef( piPredCopy, iNumMSBands ); + + iBitsWritten = L_add( iBitsWritten, 1 ); /* iMSPredAll */ + anyNonZero = 0; /* phase */ + move32(); + FOR( b = 0; b < iNumMSBands; b++ ) + { + IF( NE_32( piPhaseCopy[b], 0 ) ) + { + anyNonZero = 1; + move32(); + BREAK; + } + } + iBitsWritten = L_add( iBitsWritten, 1 ); /*anyNonZero Phase*/ + IF( anyNonZero ) + { + iBitsWritten = L_add( iBitsWritten, PHASE_BAND0_BITS ); + FOR( b = 1; b < iNumMSBands; b++ ) + { + Word32 tabIdx = L_sub( piPhaseCopy[b], ENV_DELTA_MIN ); + iBitsWritten = L_add( iBitsWritten, c_aaiRMSEnvHuffEnc[tabIdx][0] ); + } + } + anyNonZero = 0; /* prediction */ + move32(); + FOR( b = 0; b < iNumMSBands; b++ ) + { + IF( NE_32( piPredCopy[b], 0 ) ) + { + anyNonZero = 1; + move32(); + break; + } + } + + iBitsWritten = L_add( iBitsWritten, 1 ); /* any nonZero Pred */ + IF( anyNonZero ) + { + iBitsWritten = L_add( iBitsWritten, PRED_BAND0_BITS ); + FOR( b = 1; b < iNumMSBands; b++ ) + { + Word32 tabIdx = L_sub( piPredCopy[b], ENV_DELTA_MIN ); + iBitsWritten = L_add( iBitsWritten, c_aaiRMSEnvHuffEnc[tabIdx][0] ); + } + } + + return iBitsWritten; +} + + +#ifdef DEBUG_WRITE_MS_PRED +void writeMSPred( + int32_t *phaseQuant, + int32_t *predQuant, + int32_t MSMode, + int32_t numMSBands, + int32_t numBands, + void *fid, + int32_t *piMsFlags ) +{ + int32_t b; + + fid = (FILE *) fid; + fprintf( fid, "%d %d", MSMode, numMSBands ); + for ( b = 0; b < numMSBands; b++ ) + { + fprintf( fid, " %d", phaseQuant[b] ); + } + for ( b = numMSBands; b < numBands; b++ ) + { + fprintf( fid, " %d", 0 ); + } + for ( b = 0; b < numMSBands; b++ ) + { + fprintf( fid, " %d", predQuant[b] ); + } + for ( b = numMSBands; b < numBands; b++ ) + { + fprintf( fid, " %d", 0 ); + } + for ( b = 0; b < numBands; b++ ) + { + fprintf( fid, " %d", piMsFlags[b] ); + } + fprintf( fid, "\n" ); + + return; +} +#endif +#endif diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c new file mode 100644 index 000000000..a61f26fc2 --- /dev/null +++ b/lib_isar/isar_NoiseGen.c @@ -0,0 +1,58 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" +#include "isar_lcld_prot.h" +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------------------------* + * Function DeleteNoiseGen() + * + * + *------------------------------------------------------------------------------------------*/ + +void DeleteNoiseGen( NoiseGen *psNoiseGen ) +{ + free( psNoiseGen->pfNoiseBuffer ); + free( psNoiseGen ); + + return; +} + +extern float GetNoise( NoiseGen *psNoiseGen ); +extern Word32 GetNoise_fx( NoiseGen *psNoiseGen ); +#endif diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c new file mode 100644 index 000000000..85864ae0d --- /dev/null +++ b/lib_isar/isar_PerceptualModel.c @@ -0,0 +1,469 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "prot.h" +#include "isar_lcld_rom_tables.h" +#include +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ +#define PERCEPTUAL_MODEL_SCALE_SHIFT ( 6 ) +#define PERCEPTUAL_MODEL_SCALE ( 64 ) +#define PERCEPTUAL_MODEL_SCALE_SHIFT ( 6 ) +#define PERCEPTUAL_MODEL_ALPHA_SCALE ( 614 ) +#define PERCEPTUAL_MODEL_ALPHA_INV_SCALE ( 6827 ) +#define PERCEPTUAL_MODEL_ALPHA_SHIFT ( 11 ) + +/*------------------------------------------------------------------------------------------* + * Function LogAdd() + * + * + *------------------------------------------------------------------------------------------*/ + +static inline Word16 LogAdd_fx( + const Word16 iVal1, + const Word16 iVal2 ) +{ + Word16 iRetVal; + + IF( iVal1 > iVal2 ) + { + iRetVal = sub( iVal1, iVal2 ); + move16(); + iRetVal = ( iRetVal < sub( LOG_ADD_TABLE_LENGTH, 1 ) ) ? iRetVal : sub( LOG_ADD_TABLE_LENGTH, 1 ); + move16(); + iRetVal = add( iVal1, c_aiLogAddTable_fx[iRetVal] ); + move16(); + } + ELSE + { + iRetVal = sub( iVal2, iVal1 ); + move16(); + iRetVal = ( iRetVal < sub( LOG_ADD_TABLE_LENGTH, 1 ) ) ? iRetVal : sub( LOG_ADD_TABLE_LENGTH, 1 ); + move16(); + iRetVal = add( iVal2, c_aiLogAddTable_fx[iRetVal] ); + move16(); + } + + return iRetVal; +} +/*------------------------------------------------------------------------------------------* + * Function LogAdd() + * + * + *------------------------------------------------------------------------------------------*/ + +static inline int32_t LogAdd( + const int32_t iVal1, + const int32_t iVal2 ) +{ + int32_t iRetVal; + + if ( iVal1 > iVal2 ) + { + iRetVal = iVal1 - iVal2; + iRetVal = ( iRetVal < ( LOG_ADD_TABLE_LENGTH - 1 ) ) ? iRetVal : ( LOG_ADD_TABLE_LENGTH - 1 ); + iRetVal = iVal1 + c_aiLogAddTable[iRetVal]; + } + else + { + iRetVal = iVal2 - iVal1; + iRetVal = ( iRetVal < ( LOG_ADD_TABLE_LENGTH - 1 ) ) ? iRetVal : ( LOG_ADD_TABLE_LENGTH - 1 ); + iRetVal = iVal2 + c_aiLogAddTable[iRetVal]; + } + + return iRetVal; +} +/*------------------------------------------------------------------------------------------* + * Function PerceptualModel() + * + * + *------------------------------------------------------------------------------------------*/ + +void PerceptualModel_fx( + const Word32 iMaxQuantBands, + const Word32 *piRMSEnvelope, + Word32 *piExcitation, + Word32 *piSMR ) +{ + Word16 n; + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + Word16 iSLOffset; + + piExcitation[n] = shl( add( extract_l( piRMSEnvelope[n] ), c_aiBandwidthAdjust48_fx[n] ), PERCEPTUAL_MODEL_SCALE_SHIFT ); // shift instead of multiplying by PERCEPTUAL_MODEL_SCALE + move16(); + /* Calculate sensation level offset */ + iSLOffset = (Word16) extract_l( L_shr( L_mult0( c_aiDefaultTheta48_fx[n], sub( extract_l( piExcitation[n] ), c_aiAbsoluteThresh48_fx[n] ) ), PERCEPTUAL_MODEL_SLGAIN_SHIFT ) ); + // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; + move16(); + /* Offset envelope by sensation level offset */ + piExcitation[n] = sub( extract_l( piExcitation[n] ), iSLOffset ); + move16(); + /* Convert to loudness domain (x^0.3) */ + piExcitation[n] = extract_l( L_shr( L_mult0( PERCEPTUAL_MODEL_ALPHA_SCALE, extract_l( piExcitation[n] ) ), PERCEPTUAL_MODEL_ALPHA_SHIFT ) ); + move16(); + } + + /* Spread excitation function */ + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + Word16 k; + const Word16 *piSpread; + + piSpread = &c_aaiSpreadFunction48_fx[n * MAX_BANDS_48]; + move16(); + piSMR[n] = add( extract_l( piExcitation[n] ), piSpread[n] ); + move16(); + FOR( k = 0; k < iMaxQuantBands; k++ ) + { + IF( NE_16( k, n ) ) + { + piSMR[n] = L_deposit_l( LogAdd_fx( extract_l( piSMR[n] ), add( extract_l( piExcitation[k] ), piSpread[k] ) ) ); + move16(); + } + } + } + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR[n] = extract_l( L_shr( L_mult0( PERCEPTUAL_MODEL_ALPHA_INV_SCALE, extract_l( piSMR[n] ) ), PERCEPTUAL_MODEL_ALPHA_SHIFT ) ); + move16(); + piSMR[n] = shl( sub( add( extract_l( piRMSEnvelope[n] ), c_aiBandwidthAdjust48_fx[n] ), extract_l( piSMR[n] ) ), PERCEPTUAL_MODEL_SCALE_SHIFT ); + move16(); + } + + return; +} +/*------------------------------------------------------------------------------------------* + * Function PerceptualModel() + * + * + *------------------------------------------------------------------------------------------*/ + +void PerceptualModel( + const int32_t iMaxQuantBands, + const int32_t *piRMSEnvelope, + int32_t *piExcitation, + int32_t *piSMR ) +{ + int32_t n; + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t iSLOffset; + + piExcitation[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope[n] + c_aiBandwidthAdjust48[n]; + + /* Calculate sensation level offset */ + iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; + // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; + + /* Offset envelope by sensation level offset */ + piExcitation[n] -= iSLOffset; + + /* Convert to loudness domain (x^0.3) */ + piExcitation[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t k; + const int32_t *piSpread; + + piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; + piSMR[n] = piExcitation[n] + piSpread[n]; + for ( k = 0; k < iMaxQuantBands; k++ ) + { + if ( k != n ) + { + piSMR[n] = LogAdd( piSMR[n], piExcitation[k] + piSpread[k] ); + } + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + piSMR[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope[n] + c_aiBandwidthAdjust48[n] - piSMR[n]; + } + + return; +} +/*------------------------------------------------------------------------------------------* + * Function PerceptualModelStereo() + * + * + *------------------------------------------------------------------------------------------*/ + +void PerceptualModelStereo( + const int32_t iMaxQuantBands, + const int32_t *piMSFlags, + const int32_t *piRMSEnvelope0, + const int32_t *piRMSEnvelope1, + int32_t *piExcitation0, + int32_t *piExcitation1, + int32_t *piSMR0, + int32_t *piSMR1 ) +{ + int32_t n; + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t iMaxRMSEnv; + int32_t iSLOffset; + + iMaxRMSEnv = piRMSEnvelope0[n]; + + piExcitation0[n] = PERCEPTUAL_MODEL_SCALE * iMaxRMSEnv + c_aiBandwidthAdjust48[n]; /* piRMSEnvelope0[n] */ + + /* Calculate sensation level offset */ + iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation0[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; + // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; + + /* Offset envelope by sensation level offset */ + piExcitation0[n] -= iSLOffset; + + /* Convert to loudness domain (x^0.3) */ + piExcitation0[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation0[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t k; + const int32_t *piSpread; + + piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; + piSMR0[n] = piExcitation0[n] + piSpread[n]; + for ( k = 0; k < iMaxQuantBands; k++ ) + { + if ( k != n ) + { + piSMR0[n] = LogAdd( piSMR0[n], piExcitation0[k] + piSpread[k] ); + } + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t iMaxRMSEnv; + int32_t iSLOffset; + + iMaxRMSEnv = piRMSEnvelope1[n]; + + piExcitation1[n] = PERCEPTUAL_MODEL_SCALE * iMaxRMSEnv + c_aiBandwidthAdjust48[n]; /* piRMSEnvelope1[n] */ + + /* Calculate sensation level offset */ + iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation1[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; + // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; + + /* Offset envelope by sensation level offset */ + piExcitation1[n] -= iSLOffset; + + /* Convert to loudness domain (x^0.3) */ + piExcitation1[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation1[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t k; + const int32_t *piSpread; + + piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; + piSMR1[n] = piExcitation1[n] + piSpread[n]; + for ( k = 0; k < iMaxQuantBands; k++ ) + { + if ( k != n ) + { + piSMR1[n] = LogAdd( piSMR1[n], piExcitation1[k] + piSpread[k] ); + } + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + if ( piMSFlags[n] == 1 ) + { + piSMR0[n] = ( piSMR0[n] > piSMR1[n] ) ? piSMR0[n] : piSMR1[n]; + piSMR1[n] = piSMR0[n]; + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR0[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR0[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + piSMR0[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope0[n] + c_aiBandwidthAdjust48[n] - piSMR0[n]; + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR1[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR1[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + piSMR1[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope1[n] + c_aiBandwidthAdjust48[n] - piSMR1[n]; + } + + return; +} +void PerceptualModelStereo_fx( + const Word32 iMaxQuantBands, + const Word32 *piMSFlags, + const Word32 *piRMSEnvelope0, + const Word32 *piRMSEnvelope1, + Word32 *piExcitation0, + Word32 *piExcitation1, + Word32 *piSMR0, + Word32 *piSMR1 ) +{ + Word16 n; + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + Word16 iMaxRMSEnv; + Word16 iSLOffset; + + iMaxRMSEnv = extract_l( piRMSEnvelope0[n] ); + move16(); + piExcitation0[n] = add( shl( iMaxRMSEnv, PERCEPTUAL_MODEL_SCALE_SHIFT ), c_aiBandwidthAdjust48_fx[n] ); /* piRMSEnvelope0[n] */ + move16(); + /* Calculate sensation level offset */ + iSLOffset = extract_l( L_shr( L_mult0( c_aiDefaultTheta48_fx[n], sub( extract_l( piExcitation0[n] ), c_aiAbsoluteThresh48_fx[n] ) ), PERCEPTUAL_MODEL_SLGAIN_SHIFT ) ); + // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; + move16(); + /* Offset envelope by sensation level offset */ + piExcitation0[n] = sub( extract_l( piExcitation0[n] ), iSLOffset ); + move16(); + /* Convert to loudness domain (x^0.3) */ + piExcitation0[n] = extract_l( L_shr( L_mult0( PERCEPTUAL_MODEL_ALPHA_SCALE, extract_l( piExcitation0[n] ) ), PERCEPTUAL_MODEL_ALPHA_SHIFT ) ); + move16(); + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + Word16 k; + const Word16 *piSpread; + + piSpread = &c_aaiSpreadFunction48_fx[n * MAX_BANDS_48]; + move16(); + piSMR0[n] = add( extract_l( piExcitation0[n] ), piSpread[n] ); + move16(); + FOR( k = 0; k < iMaxQuantBands; k++ ) + { + IF( NE_16( k, n ) ) + { + piSMR0[n] = L_deposit_l( LogAdd_fx( extract_l( piSMR0[n] ), add( extract_l( piExcitation0[k] ), piSpread[k] ) ) ); + move16(); + } + } + } + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + Word16 iMaxRMSEnv; + Word16 iSLOffset; + + iMaxRMSEnv = extract_l( piRMSEnvelope1[n] ); + move16(); + piExcitation1[n] = add( shl( iMaxRMSEnv, PERCEPTUAL_MODEL_SCALE_SHIFT ), c_aiBandwidthAdjust48_fx[n] ); /* piRMSEnvelope1[n] */ + move16(); + /* Calculate sensation level offset */ + iSLOffset = extract_l( L_shr( L_mult0( c_aiDefaultTheta48_fx[n], sub( extract_l( piExcitation1[n] ), c_aiAbsoluteThresh48_fx[n] ) ), PERCEPTUAL_MODEL_SLGAIN_SHIFT ) ); + // iSLOffset = (iSLOffset > 0) ? iSLOffset : 0; + move16(); + /* Offset envelope by sensation level offset */ + piExcitation1[n] = sub( extract_l( piExcitation1[n] ), iSLOffset ); + move16(); + /* Convert to loudness domain (x^0.3) */ + piExcitation1[n] = extract_l( L_shr( L_mult0( PERCEPTUAL_MODEL_ALPHA_SCALE, extract_l( piExcitation1[n] ) ), PERCEPTUAL_MODEL_ALPHA_SHIFT ) ); + move16(); + } + + /* Spread excitation function */ + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + Word16 k; + const Word16 *piSpread; + + piSpread = &c_aaiSpreadFunction48_fx[n * MAX_BANDS_48]; + move16(); + piSMR1[n] = add( extract_l( piExcitation1[n] ), piSpread[n] ); + move16(); + FOR( k = 0; k < iMaxQuantBands; k++ ) + { + IF( NE_16( k, n ) ) + { + piSMR1[n] = LogAdd_fx( extract_l( piSMR1[n] ), add( extract_l( piExcitation1[k] ), piSpread[k] ) ); + move16(); + } + } + } + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + IF( EQ_16( extract_l( piMSFlags[n] ), 1 ) ) + { + piSMR0[n] = ( piSMR0[n] > piSMR1[n] ) ? piSMR0[n] : piSMR1[n]; + move16(); + piSMR1[n] = piSMR0[n]; + move16(); + } + } + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR0[n] = extract_l( L_shr( L_mult0( PERCEPTUAL_MODEL_ALPHA_INV_SCALE, extract_l( piSMR0[n] ) ), PERCEPTUAL_MODEL_ALPHA_SHIFT ) ); + move16(); + piSMR0[n] = sub( add( shl( extract_l( piRMSEnvelope0[n] ), PERCEPTUAL_MODEL_SCALE_SHIFT ), c_aiBandwidthAdjust48_fx[n] ), extract_l( piSMR0[n] ) ); + move16(); + } + + FOR( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR1[n] = extract_l( L_shr( L_mult0( PERCEPTUAL_MODEL_ALPHA_INV_SCALE, extract_l( piSMR1[n] ) ), PERCEPTUAL_MODEL_ALPHA_SHIFT ) ); + move16(); + piSMR1[n] = sub( add( shl( extract_l( piRMSEnvelope1[n] ), PERCEPTUAL_MODEL_SCALE_SHIFT ), c_aiBandwidthAdjust48_fx[n] ), extract_l( piSMR1[n] ) ); + move16(); + } + + return; +} +#endif diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c new file mode 100644 index 000000000..3fa9ec877 --- /dev/null +++ b/lib_isar/isar_PredDecoder.c @@ -0,0 +1,496 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" +#include "isar_prot.h" +#include "isar_lcld_prot.h" +#include "isar_lcld_rom_tables.h" +#include "wmc_auto.h" +#include "basop_mpy.h" + +/*-------------------------------------------------------------------* + * Function CreatePredictionDecoder() + * + * + *-------------------------------------------------------------------*/ + +ivas_error CreatePredictionDecoder_fx( + PredictionDecoder **psPredictionDecoder_out, + const Word32 iChannels, + const Word32 iNumBlocks ) +{ + Word16 n; + Word16 m; + PredictionDecoder *psPredictionDecoder = NULL; + + IF( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + psPredictionDecoder->iChannels = iChannels; + move32(); + psPredictionDecoder->iNumBlocks = iNumBlocks; + move32(); + psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks; + move32(); + psPredictionDecoder->iSubSetId = 0; + move32(); + /* PLC_IMPROVEMENT */ + IF( ( psPredictionDecoder->ppiDecodingFailedPrev = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiDecodingFailed = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiDecodingUnresolved = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + FOR( n = 0; n < iChannels; n++ ) + { + Word32 k; + IF( ( psPredictionDecoder->ppiDecodingUnresolved[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiDecodingFailed[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiDecodingFailedPrev[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + FOR( k = 0; k < LCLD_MAX_NUM_PRED_SUBSETS; k++ ) + { + psPredictionDecoder->ppiDecodingUnresolved[n][k] = 0; + move32(); + psPredictionDecoder->ppiDecodingFailed[n][k] = 0; + move32(); + psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0; + move32(); + } + } + IF( ( psPredictionDecoder->piPredChanEnable = (Word32 *) malloc( sizeof( Word32 ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiPredBandEnable = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfA1Real_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfA1Imag_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiA1Mag = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiA1Phase = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfPredStateReal_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfPredStateImag_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + + FOR( n = 0; n < psPredictionDecoder->iChannels; n++ ) + { + psPredictionDecoder->piPredChanEnable[n] = 0; + move32(); + IF( ( psPredictionDecoder->ppiPredBandEnable[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + FOR( m = 0; m < LCLD_BANDS; m++ ) + { + psPredictionDecoder->ppiPredBandEnable[n][m] = 0; + move32(); + } + IF( ( psPredictionDecoder->ppfA1Real_fx[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfA1Imag_fx[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiA1Mag[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppiA1Phase[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfPredStateReal_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) ); + } + IF( ( psPredictionDecoder->ppfPredStateImag_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) ); + } + FOR( m = 0; m < LCLD_BANDS; m++ ) + { + psPredictionDecoder->ppfPredStateReal_fx[n][m] = 0; + move32(); + psPredictionDecoder->ppfPredStateImag_fx[n][m] = 0; + move32(); + } + } + + /* pre-define these tables? */ + + FOR( n = 0; n < ( 1 << PRED_QUNAT_FILTER_MAG_BITS ); n++ ) + { + psPredictionDecoder->pfMagLUT_fx[n] = c_pfMagLUT[n]; /* Q31 */ + move32(); + } + + FOR( n = 0; n < ( 1 << PRED_QUANT_FILTER_PHASE_BITS ); n++ ) + { + psPredictionDecoder->pfP2RRealLUT_fx[n] = c_pfP2RRealLUT[n]; /* Q31 */ + move32(); + psPredictionDecoder->pfP2RImagLUT_fx[n] = c_pfP2RImagLUT[n]; /* Q31 */ + move32(); + } + + *psPredictionDecoder_out = psPredictionDecoder; + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * Function DeletePredictionDecoder() + * + * + *-------------------------------------------------------------------*/ + +void DeletePredictionDecoder_fx( + PredictionDecoder *psPredictionDecoder ) +{ + Word32 n; + + FOR( n = 0; n < psPredictionDecoder->iChannels; n++ ) + { + free( psPredictionDecoder->ppiPredBandEnable[n] ); + free( psPredictionDecoder->ppfA1Real_fx[n] ); + free( psPredictionDecoder->ppfA1Imag_fx[n] ); + free( psPredictionDecoder->ppiA1Mag[n] ); + free( psPredictionDecoder->ppiA1Phase[n] ); + free( psPredictionDecoder->ppfPredStateReal_fx[n] ); + free( psPredictionDecoder->ppfPredStateImag_fx[n] ); + free( psPredictionDecoder->ppiDecodingUnresolved[n] ); + free( psPredictionDecoder->ppiDecodingFailed[n] ); + free( psPredictionDecoder->ppiDecodingFailedPrev[n] ); + } + free( psPredictionDecoder->piPredChanEnable ); + free( psPredictionDecoder->ppiPredBandEnable ); + free( psPredictionDecoder->ppfA1Real_fx ); + free( psPredictionDecoder->ppfA1Imag_fx ); + free( psPredictionDecoder->ppiA1Mag ); + free( psPredictionDecoder->ppiA1Phase ); + free( psPredictionDecoder->ppfPredStateReal_fx ); + free( psPredictionDecoder->ppfPredStateImag_fx ); + /* PLC_IMPROVEMENT */ + free( psPredictionDecoder->ppiDecodingUnresolved ); + free( psPredictionDecoder->ppiDecodingFailed ); + free( psPredictionDecoder->ppiDecodingFailedPrev ); + + free( psPredictionDecoder ); + psPredictionDecoder = NULL; + + return; +} +/*-------------------------------------------------------------------* + * Function ReadPredictors() + * + * + *-------------------------------------------------------------------*/ + +Word32 ReadPredictors_fx( + PredictionDecoder *psPredictionDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word16 iBitsRead = 0; + Word32 c; + Word32 b; + Word16 iNumPredBandBits = 6; + const Word16 iSubSetBits = ( GT_32( LCLD_MAX_NUM_PRED_SUBSETS, 4 ) ? 3 : 2 ); + move16(); + move16(); + move16(); + + psPredictionDecoder->iNumSubSets = L_add( ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ), 1 ); + iBitsRead = add( iBitsRead, iSubSetBits ); + + IF( GT_32( psPredictionDecoder->iNumSubSets, 1 ) ) + { + psPredictionDecoder->iSubSetId = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ); + iBitsRead = add( iBitsRead, iSubSetBits ); + iNumPredBandBits = ( GE_32( psPredictionDecoder->iNumSubSets, 4 ) ? 4 : 5 ); + move16(); + } + ELSE + { + psPredictionDecoder->iSubSetId = 0; + move32(); + } + FOR( c = 0; c < psPredictionDecoder->iChannels; c++ ) + { + psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets ); + move32(); + iBitsRead = add( iBitsRead, (Word16) psPredictionDecoder->iNumSubSets ); + + IF( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) ) + { + Word32 b0 = psPredictionDecoder->iSubSetId; + Word32 bstep = psPredictionDecoder->iNumSubSets; + Word32 iNumPredBands; + move32(); + move32(); + + FOR( b = b0; b < LCLD_BANDS; b = L_add( b, bstep ) ) + { + psPredictionDecoder->ppiPredBandEnable[c][b] = 0; + move32(); + } + iNumPredBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iNumPredBandBits ); + iBitsRead = add( iBitsRead, iNumPredBandBits ); + iNumPredBands = L_add( L_mult0( (Word16) iNumPredBands, (Word16) psPredictionDecoder->iNumSubSets ), b0 ); + + FOR( b = b0; b < iNumPredBands; b = L_add( b, bstep ) ) + { + psPredictionDecoder->ppiPredBandEnable[c][b] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + move32(); + iBitsRead = add( iBitsRead, 1 ); + + IF( EQ_32( psPredictionDecoder->ppiPredBandEnable[c][b], 1 ) ) + { + Word32 iA1Mag; + Word32 iA1Phase; + Word32 fA1Real; + Word32 fA1Imag; + iA1Mag = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS ); + iBitsRead = add( iBitsRead, PRED_QUNAT_FILTER_MAG_BITS ); + iA1Phase = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS ); + iBitsRead = add( iBitsRead, PRED_QUANT_FILTER_PHASE_BITS ); + + psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag; + move32(); + psPredictionDecoder->ppiA1Phase[c][b] = L_add( iA1Phase, PRED_QUANT_FILTER_PHASE_MIN ); + move32(); + + fA1Real = Mpy_32_32( psPredictionDecoder->pfMagLUT_fx[iA1Mag], psPredictionDecoder->pfP2RRealLUT_fx[iA1Phase] ); /* Q31 */ + fA1Imag = Mpy_32_32( psPredictionDecoder->pfMagLUT_fx[iA1Mag], psPredictionDecoder->pfP2RImagLUT_fx[iA1Phase] ); /* Q31 */ + + psPredictionDecoder->ppfA1Real_fx[c][b] = fA1Real; /* Q31 */ + move32(); + psPredictionDecoder->ppfA1Imag_fx[c][b] = fA1Imag; /* Q31 */ + move32(); + } + } + } + } + + /* disable any inactive prediction bands */ + FOR( c = 0; c < psPredictionDecoder->iChannels; c++ ) + { + Word32 set; + FOR( set = 0; set < psPredictionDecoder->iNumSubSets; set++ ) + { + IF( !get_bit( psPredictionDecoder->piPredChanEnable[c], set ) ) + { + FOR( b = set; b < LCLD_BANDS; b = L_add( b, psPredictionDecoder->iNumSubSets ) ) + { + psPredictionDecoder->ppiPredBandEnable[c][b] = 0; + move32(); + } + } + } + } + + return iBitsRead; +} +/* PLC_IMPROVEMENT */ +void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + psPredictionDecoder->ppiDecodingFailed[ch][n] = 0; + } + } +} +int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + if ( psPredictionDecoder->ppiDecodingUnresolved[ch][n] == 1 ) + { + return 1; + } + } + } + return 0; +} + +void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n]; + } + } +} + +void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + + int32_t iCurrentSubSet = psPredictionDecoder->iSubSetId; + + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + /* Prediction data always available for current subset */ + psPredictionDecoder->ppiDecodingUnresolved[ch][iCurrentSubSet] = 0; + + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + int32_t iSubSetActive = get_bit( psPredictionDecoder->piPredChanEnable[ch], n ); + if ( iSubSetActive == 0 ) + { + /* Prediction information available inactive subsets (e.g. no Prediction) */ + psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 0; + } + } + } +} + +/*-------------------------------------------------------------------* + * Function ApplyInversePredictors() + * + * + *-------------------------------------------------------------------*/ + +void ApplyInversePredictors_fx( + PredictionDecoder *psPredictionDecoder, + Word32 ***pppfReal, + Word32 ***pppfImag ) +{ + Word32 c; + FOR( c = 0; c < psPredictionDecoder->iChannels; c++ ) + { + IF( GT_32( psPredictionDecoder->piPredChanEnable[c], 0 ) ) + { + Word32 b; + FOR( b = 0; b < LCLD_BANDS; b++ ) + { + IF( EQ_32( psPredictionDecoder->ppiPredBandEnable[c][b], 1 ) ) + { + Word32 n; + Word32 fA1Real; + Word32 fA1Imag; + Word32 fPrevReal = 0; + move32(); + Word32 fPrevImag = 0; + move32(); + Word32 iSubset = b % psPredictionDecoder->iNumSubSets; + + IF( NE_32( iSubset, psPredictionDecoder->iSubSetId ) ) + { + fPrevReal = psPredictionDecoder->ppfPredStateReal_fx[c][b]; + move32(); + fPrevImag = psPredictionDecoder->ppfPredStateImag_fx[c][b]; + move32(); + } + + fA1Real = psPredictionDecoder->ppfA1Real_fx[c][b]; + move32(); + fA1Imag = psPredictionDecoder->ppfA1Imag_fx[c][b]; + move32(); + FOR( n = 0; n < psPredictionDecoder->iNumBlocks; n++ ) + { + Word32 fReal; + Word32 fImag; + + fReal = L_add( L_sub( pppfReal[c][n][b], Mpy_32_32( fA1Real, fPrevReal ) ), Mpy_32_32( fA1Imag, fPrevImag ) ); + fImag = L_sub( L_sub( pppfImag[c][n][b], Mpy_32_32( fA1Real, fPrevImag ) ), Mpy_32_32( fA1Imag, fPrevReal ) ); + + pppfReal[c][n][b] = fReal; + move32(); + pppfImag[c][n][b] = fImag; + move32(); + + fPrevReal = fReal; + move32(); + fPrevImag = fImag; + move32(); + } + psPredictionDecoder->ppfPredStateReal_fx[c][b] = fPrevReal; + move32(); + psPredictionDecoder->ppfPredStateImag_fx[c][b] = fPrevImag; + move32(); + } + } + } + } + + return; +} +#endif diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c new file mode 100644 index 000000000..0ca4d7add --- /dev/null +++ b/lib_isar/isar_PredEncoder.c @@ -0,0 +1,1215 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "isar_lcld_prot.h" +#include "isar_lcld_rom_tables.h" +#include "prot.h" +#include "isar_prot.h" +#include "wmc_auto.h" +#include "prot_fx2.h" +#include "basop_util.h" +#include "enh64.h" +#include "basop32.h" + + +/*-------------------------------------------------------------------* + * Function activate_bit() + * + * + *-------------------------------------------------------------------*/ +static void activate_bit( + Word32 *state, + const Word32 bit_id ) +{ + ( *state ) = L_or( ( *state ), L_shl( 1, extract_l( bit_id ) ) ); +} + +/*-------------------------------------------------------------------* + * Function deactivate_bit() + * + * + *-------------------------------------------------------------------*/ + +static void deactivate_bit( + Word32 *state, + const Word32 bit_id ) +{ + ( *state ) = L_and( ( *state ), ~L_shl( 1, extract_l( bit_id ) ) ); +} +void UpdatePredictionSubSetId( PredictionEncoder *psPredictionEncoder ) +{ + IF( EQ_32( ++psPredictionEncoder->iSubSetId, psPredictionEncoder->iNumSubSets ) ) + { + psPredictionEncoder->iSubSetId = 0; + move32(); + } +} +/*-------------------------------------------------------------------* + * Function CreatePredictionEncoder() + * + * + *-------------------------------------------------------------------*/ + +ivas_error CreatePredictionEncoder_fx( + PredictionEncoder **psPredictionEncoder_out, + const Word32 iChannels, + const Word32 iNumBlocks, + const Word32 iNumSubSets, + const Word32 iMaxNumPredBands ) +{ + Word32 k, n; + PredictionEncoder *psPredictionEncoder = NULL; + + IF( ( psPredictionEncoder = (PredictionEncoder *) malloc( sizeof( PredictionEncoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + psPredictionEncoder->iChannels = iChannels; + move32(); + psPredictionEncoder->iNumBlocks = iNumBlocks; + move32(); + psPredictionEncoder->iSubSetId = 0; + move32(); + psPredictionEncoder->iMaxNumPredBands = iMaxNumPredBands; + move32(); + psPredictionEncoder->iNumSubSets = iNumSubSets; + move32(); + IF( ( psPredictionEncoder->piPredChanEnable = (Word32 *) malloc( sizeof( Word32 ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + IF( ( psPredictionEncoder->piNumPredBands = (Word32 *) malloc( sizeof( Word32 ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + FOR( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + psPredictionEncoder->piPredChanEnable[n] = 0; + move32(); + psPredictionEncoder->piNumPredBands[n] = 40; // Will need to be set correctly + move32(); + } + + IF( ( psPredictionEncoder->ppiPredBandEnable = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfA1Real_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfA1Imag_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppiA1Mag = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppiA1Phase = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->pppfInpBufReal_fx = (Word32 ***) malloc( sizeof( Word32 ** ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->pppfInpBufImag_fx = (Word32 ***) malloc( sizeof( Word32 ** ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfInpPrevReal_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfInpPrevImag_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfPredStateReal_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfPredStateImag_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfPredStateRealTmp_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfPredStateImagTmp_fx = (Word32 **) malloc( sizeof( Word32 * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + FOR( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + IF( ( psPredictionEncoder->ppiPredBandEnable[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfA1Real_fx[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfA1Imag_fx[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppiA1Mag[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppiA1Phase[n] = (Word32 *) malloc( sizeof( Word32 ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->pppfInpBufReal_fx[n] = (Word32 **) malloc( sizeof( Word32 * ) * LCLD_PRED_WIN_LEN ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->pppfInpBufImag_fx[n] = (Word32 **) malloc( sizeof( Word32 * ) * LCLD_PRED_WIN_LEN ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + FOR( k = 0; k < LCLD_PRED_WIN_LEN; k++ ) + { + IF( ( psPredictionEncoder->pppfInpBufReal_fx[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->pppfInpBufImag_fx[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set32_fx( psPredictionEncoder->pppfInpBufReal_fx[n][k], 0, LCLD_BANDS ); + set32_fx( psPredictionEncoder->pppfInpBufImag_fx[n][k], 0, LCLD_BANDS ); + } + IF( ( psPredictionEncoder->ppfPredStateReal_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfPredStateImag_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set32_fx( psPredictionEncoder->ppfPredStateReal_fx[n], 0, LCLD_BANDS ); + set32_fx( psPredictionEncoder->ppfPredStateImag_fx[n], 0, LCLD_BANDS ); + + IF( ( psPredictionEncoder->ppfInpPrevReal_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfInpPrevImag_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + set32_fx( psPredictionEncoder->ppfInpPrevReal_fx[n], 0, LCLD_BANDS ); + set32_fx( psPredictionEncoder->ppfInpPrevImag_fx[n], 0, LCLD_BANDS ); + + IF( ( psPredictionEncoder->ppfPredStateRealTmp_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + IF( ( psPredictionEncoder->ppfPredStateImagTmp_fx[n] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set32_fx( psPredictionEncoder->ppfPredStateRealTmp_fx[n], 0, LCLD_BANDS ); + set32_fx( psPredictionEncoder->ppfPredStateImagTmp_fx[n], 0, LCLD_BANDS ); + FOR( k = 0; k < LCLD_BANDS; k++ ) + { + psPredictionEncoder->ppiPredBandEnable[n][k] = 0; + move32(); + psPredictionEncoder->ppfA1Real_fx[n][k] = 0; + move32(); + psPredictionEncoder->ppfA1Imag_fx[n][k] = 0; + move32(); + } + } + + *psPredictionEncoder_out = psPredictionEncoder; + + return IVAS_ERR_OK; +} +ivas_error CreatePredictionEncoder( + PredictionEncoder **psPredictionEncoder_out, + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iNumSubSets, + const int32_t iMaxNumPredBands ) +{ + int32_t k, n; + PredictionEncoder *psPredictionEncoder = NULL; + + if ( ( psPredictionEncoder = (PredictionEncoder *) malloc( sizeof( PredictionEncoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + psPredictionEncoder->iChannels = iChannels; + psPredictionEncoder->iNumBlocks = iNumBlocks; + psPredictionEncoder->iSubSetId = 0; + psPredictionEncoder->iMaxNumPredBands = iMaxNumPredBands; + psPredictionEncoder->iNumSubSets = iNumSubSets; + + if ( ( psPredictionEncoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + if ( ( psPredictionEncoder->piNumPredBands = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + for ( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + psPredictionEncoder->piPredChanEnable[n] = 0; + psPredictionEncoder->piNumPredBands[n] = 40; // Will need to be set correctly + } + + if ( ( psPredictionEncoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufReal = (float ***) malloc( sizeof( float ** ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufImag = (float ***) malloc( sizeof( float ** ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfInpPrevReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfInpPrevImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateRealTmp = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImagTmp = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + for ( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + if ( ( psPredictionEncoder->ppiPredBandEnable[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufReal[n] = (float **) malloc( sizeof( float * ) * LCLD_PRED_WIN_LEN ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufImag[n] = (float **) malloc( sizeof( float * ) * LCLD_PRED_WIN_LEN ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + for ( k = 0; k < LCLD_PRED_WIN_LEN; k++ ) + { + if ( ( psPredictionEncoder->pppfInpBufReal[n][k] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufImag[n][k] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set_zero( psPredictionEncoder->pppfInpBufReal[n][k], LCLD_BANDS ); + set_zero( psPredictionEncoder->pppfInpBufImag[n][k], LCLD_BANDS ); + } + if ( ( psPredictionEncoder->ppfPredStateReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set_zero( psPredictionEncoder->ppfPredStateReal[n], LCLD_BANDS ); + set_zero( psPredictionEncoder->ppfPredStateImag[n], LCLD_BANDS ); + + if ( ( psPredictionEncoder->ppfInpPrevReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfInpPrevImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + set_zero( psPredictionEncoder->ppfInpPrevReal[n], LCLD_BANDS ); + set_zero( psPredictionEncoder->ppfInpPrevImag[n], LCLD_BANDS ); + + if ( ( psPredictionEncoder->ppfPredStateRealTmp[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImagTmp[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set_zero( psPredictionEncoder->ppfPredStateRealTmp[n], LCLD_BANDS ); + set_zero( psPredictionEncoder->ppfPredStateImagTmp[n], LCLD_BANDS ); + for ( k = 0; k < LCLD_BANDS; k++ ) + { + psPredictionEncoder->ppiPredBandEnable[n][k] = 0; + psPredictionEncoder->ppfA1Real[n][k] = 0.0f; + psPredictionEncoder->ppfA1Imag[n][k] = 0.0f; + } + } + + *psPredictionEncoder_out = psPredictionEncoder; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function DeletePredictionEncoder() + * + * + *-------------------------------------------------------------------*/ + +void DeletePredictionEncoder_fx( + PredictionEncoder *psPredictionEncoder ) +{ + Word32 n; + FOR( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + Word32 k; + free( psPredictionEncoder->ppiPredBandEnable[n] ); + free( psPredictionEncoder->ppfA1Real_fx[n] ); + free( psPredictionEncoder->ppfA1Imag_fx[n] ); + free( psPredictionEncoder->ppiA1Mag[n] ); + free( psPredictionEncoder->ppiA1Phase[n] ); + FOR( k = 0; k < LCLD_PRED_WIN_LEN; k++ ) + { + free( psPredictionEncoder->pppfInpBufReal_fx[n][k] ); + free( psPredictionEncoder->pppfInpBufImag_fx[n][k] ); + } + free( psPredictionEncoder->pppfInpBufReal_fx[n] ); + free( psPredictionEncoder->pppfInpBufImag_fx[n] ); + free( psPredictionEncoder->ppfInpPrevReal_fx[n] ); + free( psPredictionEncoder->ppfInpPrevImag_fx[n] ); + free( psPredictionEncoder->ppfPredStateReal_fx[n] ); + free( psPredictionEncoder->ppfPredStateImag_fx[n] ); + free( psPredictionEncoder->ppfPredStateRealTmp_fx[n] ); + free( psPredictionEncoder->ppfPredStateImagTmp_fx[n] ); + } + free( psPredictionEncoder->piPredChanEnable ); + free( psPredictionEncoder->piNumPredBands ); + free( psPredictionEncoder->ppiPredBandEnable ); + free( psPredictionEncoder->ppfA1Real_fx ); + free( psPredictionEncoder->ppfA1Imag_fx ); + free( psPredictionEncoder->ppiA1Mag ); + free( psPredictionEncoder->ppiA1Phase ); + free( psPredictionEncoder->pppfInpBufReal_fx ); + free( psPredictionEncoder->pppfInpBufImag_fx ); + free( psPredictionEncoder->ppfInpPrevReal_fx ); + free( psPredictionEncoder->ppfInpPrevImag_fx ); + free( psPredictionEncoder->ppfPredStateReal_fx ); + free( psPredictionEncoder->ppfPredStateImag_fx ); + free( psPredictionEncoder->ppfPredStateRealTmp_fx ); + free( psPredictionEncoder->ppfPredStateImagTmp_fx ); + + + free( psPredictionEncoder ); + + return; +} +void DeletePredictionEncoder( + PredictionEncoder *psPredictionEncoder ) +{ + int32_t n; + for ( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + int32_t k; + free( psPredictionEncoder->ppiPredBandEnable[n] ); + free( psPredictionEncoder->ppfA1Real[n] ); + free( psPredictionEncoder->ppfA1Imag[n] ); + free( psPredictionEncoder->ppiA1Mag[n] ); + free( psPredictionEncoder->ppiA1Phase[n] ); + for ( k = 0; k < LCLD_PRED_WIN_LEN; k++ ) + { + free( psPredictionEncoder->pppfInpBufReal[n][k] ); + free( psPredictionEncoder->pppfInpBufImag[n][k] ); + } + free( psPredictionEncoder->pppfInpBufReal[n] ); + free( psPredictionEncoder->pppfInpBufImag[n] ); + free( psPredictionEncoder->ppfInpPrevReal[n] ); + free( psPredictionEncoder->ppfInpPrevImag[n] ); + free( psPredictionEncoder->ppfPredStateReal[n] ); + free( psPredictionEncoder->ppfPredStateImag[n] ); + free( psPredictionEncoder->ppfPredStateRealTmp[n] ); + free( psPredictionEncoder->ppfPredStateImagTmp[n] ); + } + free( psPredictionEncoder->piPredChanEnable ); + free( psPredictionEncoder->piNumPredBands ); + free( psPredictionEncoder->ppiPredBandEnable ); + free( psPredictionEncoder->ppfA1Real ); + free( psPredictionEncoder->ppfA1Imag ); + free( psPredictionEncoder->ppiA1Mag ); + free( psPredictionEncoder->ppiA1Phase ); + free( psPredictionEncoder->pppfInpBufReal ); + free( psPredictionEncoder->pppfInpBufImag ); + free( psPredictionEncoder->ppfInpPrevReal ); + free( psPredictionEncoder->ppfInpPrevImag ); + free( psPredictionEncoder->ppfPredStateReal ); + free( psPredictionEncoder->ppfPredStateImag ); + free( psPredictionEncoder->ppfPredStateRealTmp ); + free( psPredictionEncoder->ppfPredStateImagTmp ); + + + free( psPredictionEncoder ); + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputePredictors() + * + * + *-------------------------------------------------------------------*/ + +void ComputePredictors( + PredictionEncoder *psPredictionEncoder, + float ***pppfReal, + float ***pppfImag ) +{ + int32_t c; + + int32_t b0 = psPredictionEncoder->iSubSetId; + int32_t bstep = psPredictionEncoder->iNumSubSets; + int32_t iNumBlocks = psPredictionEncoder->iNumBlocks; + float ***pppfRealBuf; + float ***pppfImagBuf; + float pfEstPredBitGain[LCLD_BANDS] = { 0 }; + + if ( iNumBlocks < LCLD_PRED_WIN_LEN ) + { + pppfRealBuf = psPredictionEncoder->pppfInpBufReal; + pppfImagBuf = psPredictionEncoder->pppfInpBufImag; + for ( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + int32_t n; + for ( n = 0; n < LCLD_PRED_WIN_LEN - iNumBlocks; n++ ) + { + mvr2r( pppfRealBuf[c][n + iNumBlocks], pppfRealBuf[c][n], LCLD_BANDS ); + mvr2r( pppfImagBuf[c][n + iNumBlocks], pppfImagBuf[c][n], LCLD_BANDS ); + } + for ( n = 0; n < iNumBlocks; n++ ) + { + mvr2r( pppfReal[c][n], pppfRealBuf[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS ); + mvr2r( pppfImag[c][n], pppfImagBuf[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS ); + } + } + } + else + { + pppfRealBuf = pppfReal; + pppfImagBuf = pppfImag; + } + + for ( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + int32_t b; + for ( b = b0; b < psPredictionEncoder->iMaxNumPredBands; b += bstep ) + { + int32_t n; + float fGain = 0.0; + float fBitGain = 0.0; + float *pfRxxReal; + float *pfRxxImag; + float fA1Real; + float fA1Imag; + int32_t iA1Mag; + int32_t iA1Phase; + + pfRxxReal = psPredictionEncoder->pfRxxReal; + pfRxxImag = psPredictionEncoder->pfRxxImag; + + pfRxxReal[0] = 0.0; + pfRxxImag[0] = 0.0; + for ( n = 0; n < LCLD_PRED_WIN_LEN; n++ ) + { + pfRxxReal[0] += ( pppfRealBuf[c][n][b] * pppfRealBuf[c][n][b] + pppfImagBuf[c][n][b] * pppfImagBuf[c][n][b] ); + } + + pfRxxReal[1] = 0.0; + pfRxxImag[1] = 0.0; + for ( n = 1; n < LCLD_PRED_WIN_LEN; n++ ) + { + pfRxxReal[1] += ( pppfRealBuf[c][n][b] * pppfRealBuf[c][n - 1][b] + pppfImagBuf[c][n][b] * pppfImagBuf[c][n - 1][b] ); + pfRxxImag[1] += ( pppfImagBuf[c][n][b] * pppfRealBuf[c][n - 1][b] - pppfRealBuf[c][n][b] * pppfImagBuf[c][n - 1][b] ); + } + + if ( pfRxxReal[0] > 1e-12f ) + { + float fA1Mag; + float fA1Phase; + float fGain2; + float fBitGain2; + int32_t iNumBlocksPerPredCoef = min( iNumBlocks * psPredictionEncoder->iNumSubSets, LCLD_PRED_WIN_LEN ); + + const float fMagScale = ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f ) / M_PI; + const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f ); + const float fPhaseScale = (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) ) / M_PI; + const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) ); + + /* Compute filter coefficeints */ + fA1Real = -pfRxxReal[1] / pfRxxReal[0]; + fA1Imag = -pfRxxImag[1] / pfRxxReal[0]; + + /* compute these before quant */ + /* Compute est coding gain based on quantized filter coefficients */ + fGain = 1.0f / ( 1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag ); + fBitGain = 0.65f * log2f( fGain ) * (float) ( iNumBlocksPerPredCoef ) - (float) ( PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS ); // Wrong fix (iNumBlocks-1) + fA1Mag = sqrtf( fA1Real * fA1Real + fA1Imag * fA1Imag ); + fA1Mag = fMagScale * asinf( fA1Mag ); + iA1Mag = (int32_t) ( fA1Mag + 0.5f ); + iA1Mag = ( iA1Mag > PRED_QUANT_FILTER_MAG_MIN ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MIN; + iA1Mag = ( iA1Mag < PRED_QUANT_FILTER_MAG_MAX ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MAX; + fA1Mag = sinf( fInvMagScale * (float) iA1Mag ); + + fA1Phase = atan2f( fA1Imag, fA1Real ); + fA1Phase = fPhaseScale * fA1Phase; + iA1Phase = ( fA1Phase > 0.0f ) ? (int32_t) ( fA1Phase + 0.5f ) : (int32_t) ( fA1Phase - 0.5f ); + iA1Phase = ( iA1Phase > PRED_QUANT_FILTER_PHASE_MIN ) ? iA1Phase : PRED_QUANT_FILTER_PHASE_MIN; + iA1Phase = ( iA1Phase < PRED_QUANT_FILTER_PHASE_MAX ) ? iA1Phase : PRED_QUANT_FILTER_PHASE_MAX; // Is this the correct way to deal with this? should wrap? + fA1Phase = fInvPhaseScale * (float) iA1Phase; + + fA1Real = fA1Mag * cosf( fA1Phase ); + fA1Imag = fA1Mag * sinf( fA1Phase ); + + fGain2 = 1.0f / ( 1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag ); + fBitGain2 = 0.65f * log2f( fGain ) * (float) ( iNumBlocksPerPredCoef ) - (float) ( PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS ); // Wrong fix (iNumBlocks-1) + fGain = ( fGain < fGain2 ) ? fGain : fGain2; + fBitGain = ( fBitGain < fBitGain2 ) ? fBitGain : fBitGain2; + } + else + { + fA1Real = 0.0f; + fA1Imag = 0.0f; + iA1Mag = 0; + iA1Phase = 0; + fGain = -10.0f; // Fix this + } + + pfEstPredBitGain[b] = fBitGain; + psPredictionEncoder->ppiPredBandEnable[c][b] = ( fBitGain > 0.0f ); // Initial prediction enable + psPredictionEncoder->ppfA1Real[c][b] = fA1Real; + psPredictionEncoder->ppfA1Imag[c][b] = fA1Imag; + psPredictionEncoder->ppiA1Mag[c][b] = iA1Mag; + psPredictionEncoder->ppiA1Phase[c][b] = iA1Phase; + } + + { + float fBestCost; + int32_t iPredBands; + float fBitGain; + int32_t iPredChanEnable = 0; + + fBestCost = 0.0; + iPredBands = 0; + fBitGain = -7.0; + for ( b = b0; b < psPredictionEncoder->iMaxNumPredBands; b += bstep ) + { // still getting this decision wrong! + fBitGain -= 1.0; + if ( psPredictionEncoder->ppiPredBandEnable[c][b] == 1 ) + { + fBitGain += pfEstPredBitGain[b]; + } + if ( fBitGain > fBestCost ) + { + fBestCost = fBitGain; + iPredBands = b; + iPredChanEnable = 1; + } + } + + if ( iPredChanEnable == 1 ) + { + for ( b = iPredBands + bstep; b < LCLD_BANDS; b += bstep ) + { + psPredictionEncoder->ppiPredBandEnable[c][b] = 0; + } + activate_bit( &psPredictionEncoder->piPredChanEnable[c], psPredictionEncoder->iSubSetId ); + psPredictionEncoder->piNumPredBands[c] = iPredBands + bstep; + } + else + { + for ( b = b0; b < LCLD_BANDS; b += bstep ) + { + psPredictionEncoder->ppiPredBandEnable[c][b] = 0; + } + deactivate_bit( &psPredictionEncoder->piPredChanEnable[c], psPredictionEncoder->iSubSetId ); + psPredictionEncoder->piNumPredBands[c] = 0; + } + } + } +} + +void ComputePredictors_fx( + PredictionEncoder *psPredictionEncoder, + Word32 ***pppfReal_fx, // Q12? + Word32 ***pppfImag_fx ) // Q12? +{ + Word32 c; + + Word32 b0 = psPredictionEncoder->iSubSetId; + Word32 bstep = psPredictionEncoder->iNumSubSets; + Word32 iNumBlocks = psPredictionEncoder->iNumBlocks; + /*float ***pppfRealBuf; + float ***pppfImagBuf;*/ + Word32 ***pppfRealBuf_fx; + Word32 ***pppfImagBuf_fx; + // float pfEstPredBitGain[LCLD_BANDS] = { 0 }; + Word32 pfEstPredBitGain_fx[LCLD_BANDS] = { 0 }; + + IF( LT_32( iNumBlocks, LCLD_PRED_WIN_LEN ) ) + { + /*pppfRealBuf = psPredictionEncoder->pppfInpBufReal; + pppfImagBuf = psPredictionEncoder->pppfInpBufImag;*/ + pppfRealBuf_fx = psPredictionEncoder->pppfInpBufReal_fx; + move32(); + pppfImagBuf_fx = psPredictionEncoder->pppfInpBufImag_fx; + move32(); + FOR( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + Word32 n; + FOR( n = 0; n < L_sub( LCLD_PRED_WIN_LEN, iNumBlocks ); n++ ) + { + /*mvr2r(pppfRealBuf[c][n + iNumBlocks], pppfRealBuf[c][n], LCLD_BANDS); + mvr2r(pppfImagBuf[c][n + iNumBlocks], pppfImagBuf[c][n], LCLD_BANDS);*/ + mvl2l( pppfRealBuf_fx[c][n + iNumBlocks], pppfRealBuf_fx[c][n], LCLD_BANDS ); + mvl2l( pppfImagBuf_fx[c][n + iNumBlocks], pppfImagBuf_fx[c][n], LCLD_BANDS ); + } + FOR( n = 0; n < iNumBlocks; n++ ) + { + /*mvr2r(pppfReal[c][n], pppfRealBuf[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS); + mvr2r(pppfImag[c][n], pppfImagBuf[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS);*/ + mvl2l( pppfReal_fx[c][n], pppfRealBuf_fx[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS ); + mvl2l( pppfImag_fx[c][n], pppfImagBuf_fx[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS ); + } + } + } + ELSE + { + /*pppfRealBuf = pppfReal; + pppfImagBuf = pppfImag;*/ + pppfRealBuf_fx = pppfReal_fx; + move32(); + pppfImagBuf_fx = pppfImag_fx; + move32(); + } + + FOR( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + Word32 b; + FOR( b = b0; b < psPredictionEncoder->iMaxNumPredBands; b += bstep ) + { + Word32 n; + /*float fGain = 0.0; + float fBitGain = 0.0; + float *pfRxxReal; + float *pfRxxImag; + float fA1Real; + float fA1Imag;*/ + Word32 fGain_fx = 0; + Word32 fBitGain_fx = 0; + Word32 *pfRxxReal_fx; + Word32 *pfRxxImag_fx; + Word32 fA1Real_fx; + Word32 fA1Imag_fx; + Word32 L_temp; + Word64 W_temp1, W_temp2; + Word32 iA1Mag; + Word32 iA1Phase; + + /*pfRxxReal = psPredictionEncoder->pfRxxReal; + pfRxxImag = psPredictionEncoder->pfRxxImag;*/ + pfRxxReal_fx = psPredictionEncoder->pfRxxReal_fx; + move32(); + pfRxxImag_fx = psPredictionEncoder->pfRxxImag_fx; + move32(); + /*pfRxxReal[0] = 0.0; + pfRxxImag[0] = 0.0;*/ + pfRxxReal_fx[0] = 0; + move32(); + pfRxxImag_fx[0] = 0; + move32(); + W_temp1 = 0; + FOR( n = 0; n < LCLD_PRED_WIN_LEN; n++ ) + { + // pfRxxReal[0] += (pppfRealBuf[c][n][b] * pppfRealBuf[c][n][b] + pppfImagBuf[c][n][b] * pppfImagBuf[c][n][b]); + W_temp1 = W_add( W_temp1, W_add( W_mult0_32_32( pppfRealBuf_fx[c][n][b], pppfRealBuf_fx[c][n][b] ), + W_mult0_32_32( pppfImagBuf_fx[c][n][b], pppfImagBuf_fx[c][n][b] ) ) ); // Q40 + } + Word16 w_norm1 = W_norm( W_temp1 ); + W_temp1 = W_shr( W_temp1, 32 - w_norm1 ); + pfRxxReal_fx[0] = W_extract_l( W_temp1 ); + /*pfRxxReal[1] = 0.0; + pfRxxImag[1] = 0.0;*/ + pfRxxReal_fx[1] = 0; + move32(); + pfRxxImag_fx[1] = 0; + move32(); + W_temp1 = 0; + W_temp2 = 0; + FOR( n = 1; n < LCLD_PRED_WIN_LEN; n++ ) + { + /*pfRxxReal[1] += (pppfRealBuf[c][n][b] * pppfRealBuf[c][n - 1][b] + pppfImagBuf[c][n][b] * pppfImagBuf[c][n - 1][b]); + pfRxxImag[1] += (pppfImagBuf[c][n][b] * pppfRealBuf[c][n - 1][b] - pppfRealBuf[c][n][b] * pppfImagBuf[c][n - 1][b]);*/ + W_temp1 = W_add( W_temp1, W_add( W_mult0_32_32( pppfRealBuf_fx[c][n][b], pppfRealBuf_fx[c][n - 1][b] ), + W_mult0_32_32( pppfImagBuf_fx[c][n][b], pppfImagBuf_fx[c][n - 1][b] ) ) ); // Q40 + W_temp2 = W_add( W_temp2, W_sub( W_mult0_32_32( pppfImagBuf_fx[c][n][b], pppfRealBuf_fx[c][n - 1][b] ), + W_mult0_32_32( pppfRealBuf_fx[c][n][b], pppfImagBuf_fx[c][n - 1][b] ) ) ); // Q40 + } + + Word16 w_norm2 = W_norm( W_temp1 ); + W_temp1 = W_shr( W_temp1, 32 - w_norm2 ); + pfRxxReal_fx[1] = W_extract_l( W_temp1 ); + Word16 w_norm3 = W_norm( W_temp2 ); + W_temp2 = W_shr( W_temp2, 32 - w_norm3 ); + pfRxxImag_fx[1] = W_extract_l( W_temp2 ); + Word16 final_w_norm = min( w_norm1, min( w_norm2, w_norm3 ) ); + pfRxxReal_fx[0] = L_shr( pfRxxReal_fx[0], w_norm1 - final_w_norm ); // Q8 + final_w_norm + pfRxxReal_fx[1] = L_shr( pfRxxReal_fx[1], w_norm2 - final_w_norm ); // Q8 + final_w_norm + pfRxxImag_fx[1] = L_shr( pfRxxImag_fx[1], w_norm3 - final_w_norm ); // Q8 + final_w_norm + // if (pfRxxReal[0] > 1e-12f) + IF( GT_32( pfRxxReal_fx[0], 0 ) ) + { + /*float fA1Mag; + float fA1Phase; + float fGain2; + float fBitGain2;*/ + Word32 fA1Mag_fx; + Word32 fA1Phase_fx; + Word32 fGain2_fx; + Word32 fBitGain2_fx; + Word32 iNumBlocksPerPredCoef = L_min( iNumBlocks * psPredictionEncoder->iNumSubSets, LCLD_PRED_WIN_LEN ); + const Word32 fMagScale_fx32 = 1452576210; // Q28 + move32(); + // const float fInvMagScale = M_PI / (2.0f * (float)(1 << (PRED_QUNAT_FILTER_MAG_BITS)) + 1.0f); + const Word16 fInvMagScale_fx = 6055; // Q15 + move16(); + // const float fPhaseScale = (float)(1 << (PRED_QUANT_FILTER_PHASE_BITS - 1)) / M_PI + const Word32 fPhaseScale_fx32 = 1367130551; // Q28 + // const float fInvPhaseScale = M_PI / (float)(1 << (PRED_QUANT_FILTER_PHASE_BITS - 1)); + const Word16 fInvPhaseScale_fx = 6434; // Q15 + move16(); + + /* Compute filter coefficeints */ + // fA1Real = -pfRxxReal[1] / pfRxxReal[0]; + Word16 sf_r, sf_i; + fA1Real_fx = BASOP_Util_Divide3232_Scale( -pfRxxReal_fx[1], pfRxxReal_fx[0], &sf_r ); + // fA1Imag = -pfRxxImag[1] / pfRxxReal[0]; + fA1Imag_fx = BASOP_Util_Divide3232_Scale( -pfRxxImag_fx[1], pfRxxReal_fx[0], &sf_i ); + + IF( GT_16( sf_r, sf_i ) ) + { + fA1Imag_fx = L_shr( fA1Imag_fx, sub( sf_r, sf_i ) ); + sf_i = sf_r; + move16(); + } + ELSE IF( LT_16( sf_r, sf_i ) ) + { + fA1Real_fx = L_shr( fA1Real_fx, sub( sf_i, sf_r ) ); + sf_r = sf_i; + move16(); + } + Word32 L_temp_1; + IF( LT_16( sf_r, -7 ) ) + { + fA1Real_fx = L_shr( fA1Real_fx, sub( -8, sf_r ) ); + fA1Imag_fx = L_shr( fA1Imag_fx, sub( -8, sf_i ) ); + sf_r = sf_i = -8; + move16(); + L_temp_1 = MAX_32; + move32(); + } + ELSE + { + L_temp_1 = L_shl( 1, sub( 15, shl( sf_r, 1 ) ) ); + } + /* compute these before quant */ + /* Compute est coding gain based on quantized filter coefficients */ + // fGain = 1.0f / (1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag); + L_temp = L_sub( L_sub( L_temp_1, mult_r( extract_l( fA1Real_fx ), extract_l( fA1Real_fx ) ) ), mult_r( extract_l( fA1Imag_fx ), extract_l( fA1Imag_fx ) ) ); + Word16 exp = norm_l( L_temp ); + IF( LT_16( exp, 16 ) ) + { + L_temp = L_shr( L_temp, sub( 16, exp ) ); + exp = add( sub( 16, exp ), shl( sf_r, 1 ) ); + } + else + { + exp = shl( sf_r, 1 ); + } + // fGain_fx = sub(sub(32767, extract_h(Mpy_32_32(fA1Real_fx, fA1Real_fx))), extract_h(Mpy_32_32(fA1Imag_fx, fA1Imag_fx))); + // fGain_fx = extract_l(L_shl(L_temp, 2*sf_r)); + fGain_fx = extract_l( L_temp ); + fGain_fx = max( 1, fGain_fx ); + fGain_fx = Inv16( extract_l( fGain_fx ), &exp ); // Q15 - exp + // fGain_fx = L_shl(fGain_fx, exp); //Q15 + // fBitGain = 0.65f * log2f(fGain) * (float)(iNumBlocksPerPredCoef)-(float)(PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS); // Wrong fix (iNumBlocks-1) + // fBitGain_fx = L_sub(L_mult0(L_shr(L_mult0(21299, L_shr(L_add(BASOP_Util_Log2(fGain_fx), 335544320), 10)), 15), (Word16)iNumBlocksPerPredCoef), 262144); // Wrong fix (iNumBlocks-1) Q15 + W_temp1 = W_mult0_32_32( L_shr( Mpy_32_32( 1395864371, L_add( BASOP_Util_Log2( fGain_fx ), L_shl( add( 16, exp ), 25 ) ) ), 10 ), iNumBlocksPerPredCoef ); + Word16 w_norm4 = W_norm( W_temp1 ); + IF( LT_16( w_norm4, 32 ) ) + { + W_temp1 = W_shr( W_temp1, 32 - w_norm4 ); + w_norm4 = sub( 32, w_norm4 ); + } + ELSE + { + w_norm4 = 0; + move16(); + } + fBitGain_fx = L_sub( W_extract_l( W_temp1 ), L_shr( 262144, w_norm4 ) ); // Wrong fix (iNumBlocks-1) Q15 + // fA1Mag = sqrtf(fA1Real * fA1Real + fA1Imag * fA1Imag); + fA1Mag_fx = L_add( mult_r( extract_l( fA1Real_fx ), extract_l( fA1Real_fx ) ), mult_r( extract_l( fA1Imag_fx ), extract_l( fA1Imag_fx ) ) ); // Q15 - 2*sf_r + // fA1Mag = fMagScale * asinf(fA1Mag); + exp = 0; + move16(); + L_temp = L_sub( L_temp_1, fA1Mag_fx ); // Q15 - 2*sf_r + IF( NE_32( L_temp, 0 ) ) + { + fA1Mag_fx = BASOP_Util_Divide3232_Scale( fA1Mag_fx, L_temp, &exp ); + } + ELSE + { + fA1Mag_fx = 0; + move32(); + exp = 0; + move16(); + } + fA1Mag_fx = L_shl( fA1Mag_fx, 16 ); + IF( fA1Mag_fx > 0 ) + { + fA1Mag_fx = Sqrt32( fA1Mag_fx, &exp ); + } + ELSE + { + fA1Mag_fx = 0; + move32(); + exp = 0; + move16(); + } + + fA1Mag_fx = BASOP_util_atan( L_shr_r_sat( fA1Mag_fx, 6 - exp ) ); // Q14 + fA1Mag_fx = Mpy_32_16_1( fMagScale_fx32, extract_l( fA1Mag_fx ) ); // Q27 + + // iA1Mag = (int32_t)(fA1Mag + 0.5f); + IF( GE_32( fA1Mag_fx, 0 ) ) + { + iA1Mag = L_shr( L_add( fA1Mag_fx, 67108864 ), Q27 ); // Q27 -> Q0 + } + ELSE + { + fA1Mag_fx = L_negate( fA1Mag_fx ); + iA1Mag = L_shr( L_add( fA1Mag_fx, 67108864 ), Q27 ); // Q27 -> Q0 + iA1Mag = L_negate( iA1Mag ); + } + iA1Mag = ( iA1Mag > PRED_QUANT_FILTER_MAG_MIN ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MIN; + iA1Mag = ( iA1Mag < PRED_QUANT_FILTER_MAG_MAX ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MAX; + // fA1Mag = sinf(fInvMagScale * (float)iA1Mag); + fA1Mag_fx = L_deposit_l( getSinWord16( extract_l( L_shr( L_mult0( extract_l( fInvMagScale_fx ), extract_l( iA1Mag ) ), 2 ) ) ) ); // Q14 + + // fA1Phase = atan2f(fA1Imag, fA1Real); + fA1Phase_fx = BASOP_util_atan2( fA1Imag_fx, fA1Real_fx, 0 ); // Q13 + // fA1Phase = fPhaseScale * fA1Phase; + fA1Phase_fx = Mpy_32_16_1( fPhaseScale_fx32, extract_l( fA1Phase_fx ) ); // Q26 + // iA1Phase = (fA1Phase > 0.0f) ? (int32_t)(fA1Phase + 0.5f) : (int32_t)(fA1Phase - 0.5f); + // iA1Phase = (fA1Phase_fx > 0) ? shr(add(fA1Phase_fx, 512), 10) : shr(sub(fA1Phase_fx, 512), 10); + IF( GE_32( fA1Phase_fx, 0 ) ) + { + iA1Phase = L_shr( L_add( fA1Phase_fx, 33554432 ), Q26 ); // Q26 -> Q0 + } + ELSE + { + fA1Phase_fx = L_negate( fA1Phase_fx ); + iA1Phase = L_shr( L_add( fA1Phase_fx, 33554432 ), Q26 ); // Q26 -> Q0 + iA1Phase = L_negate( iA1Phase ); + } + iA1Phase = ( iA1Phase > PRED_QUANT_FILTER_PHASE_MIN ) ? iA1Phase : PRED_QUANT_FILTER_PHASE_MIN; + iA1Phase = ( iA1Phase < PRED_QUANT_FILTER_PHASE_MAX ) ? iA1Phase : PRED_QUANT_FILTER_PHASE_MAX; // Is this the correct way to deal with this? should wrap? + // fA1Phase = fInvPhaseScale * (float)iA1Phase; + L_temp = L_mult0( fInvPhaseScale_fx, (Word16) iA1Phase ); // Q15 + + // fA1Real = fA1Mag * cosf(fA1Phase); + fA1Real_fx = L_mult0( extract_l( fA1Mag_fx ), getCosWord16( extract_l( L_shr( L_temp, 2 ) ) ) ); // Q28 + // fA1Imag = fA1Mag * sinf(fA1Phase); + fA1Imag_fx = L_mult0( extract_l( fA1Mag_fx ), getSinWord16( extract_l( L_shr( L_temp, 2 ) ) ) ); // Q28 + + // fGain2 = 1.0f / (1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag); + exp = 0; + fGain2_fx = sub( sub( 32767, mult_r( extract_l( L_shr( fA1Real_fx, 13 ) ), extract_l( L_shr( fA1Real_fx, 13 ) ) ) ), mult_r( extract_l( L_shr( fA1Imag_fx, 13 ) ), extract_l( L_shr( fA1Imag_fx, 13 ) ) ) ); + fGain2_fx = L_max( 1, fGain2_fx ); + fGain2_fx = Inv16( extract_l( fGain2_fx ), &exp ); // Q15-exp + fGain2_fx = L_shl( fGain2_fx, exp ); + // fBitGain2 = 0.65f * log2f(fGain) * (float)(iNumBlocksPerPredCoef)-(float)(PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS); // Wrong fix (iNumBlocks-1) + // fBitGain2_fx = L_sub(L_mult0(L_shr(L_mult0(21299, L_shr(L_add(BASOP_Util_Log2(fGain_fx), 335544320), 10)), 15), (Word16)iNumBlocksPerPredCoef), 262144); // Wrong fix (iNumBlocks-1) Q15 + fBitGain2_fx = L_sub( W_extract_l( W_temp1 ), L_shr( 262144, w_norm4 ) ); // Wrong fix (iNumBlocks-1) Q15 + // fGain = (fGain < fGain2) ? fGain : fGain2; + fGain_fx = ( fGain_fx < fGain2_fx ) ? fGain_fx : fGain2_fx; + // fBitGain = (fBitGain < fBitGain2) ? fBitGain : fBitGain2; + fBitGain_fx = ( fBitGain_fx < fBitGain2_fx ) ? fBitGain_fx : fBitGain2_fx; + } + ELSE + { + /*fA1Real = 0.0f; + fA1Imag = 0.0f;*/ + fA1Real_fx = 0; + move32(); + fA1Imag_fx = 0; + move32(); + iA1Mag = 0; + move32(); + iA1Phase = 0; + move32(); + // fGain = -10.0f; // Fix this + fGain_fx = -327680; // Fix this + move32(); + } + + // pfEstPredBitGain[b] = fBitGain; + // psPredictionEncoder->ppiPredBandEnable[c][b] = (fBitGain > 0.0f); // Initial prediction enable + // psPredictionEncoder->ppfA1Real[c][b] = fA1Real; + // psPredictionEncoder->ppfA1Imag[c][b] = fA1Imag; + pfEstPredBitGain_fx[b] = fBitGain_fx; // Q15 + move32(); + // printf("\n %d %d %f %f %f ", iA1Mag, iA1Phase, (float)fBitGain_fx / 32768, (float)fA1Real_fx / ONE_IN_Q28, (float)fA1Imag_fx / ONE_IN_Q28); + psPredictionEncoder->ppiPredBandEnable[c][b] = ( fBitGain_fx > 0 ); // Initial prediction enable + psPredictionEncoder->ppfA1Real_fx[c][b] = L_shl( fA1Real_fx, Q3 ); // Q31 + psPredictionEncoder->ppfA1Imag_fx[c][b] = L_shl( fA1Imag_fx, Q3 ); // Q31 + psPredictionEncoder->ppiA1Mag[c][b] = iA1Mag; + move32(); + psPredictionEncoder->ppiA1Phase[c][b] = iA1Phase; + move32(); + } + + { + // float fBestCost; + Word32 fBestCost_fx; + Word32 iPredBands; + // float fBitGain; + Word32 fBitGain_fx; + Word32 iPredChanEnable = 0; + + // fBestCost = 0.0; + fBestCost_fx = 0; + move32(); + iPredBands = 0; + move32(); + // fBitGain = -7.0; + fBitGain_fx = -229376; // Q15 + move32(); + FOR( b = b0; b < psPredictionEncoder->iMaxNumPredBands; b += bstep ) + { // still getting this decision wrong! + // fBitGain -= 1.0; + fBitGain_fx = L_sub( fBitGain_fx, 32768 ); + IF( EQ_32( psPredictionEncoder->ppiPredBandEnable[c][b], 1 ) ) + { + // fBitGain += pfEstPredBitGain[b]; + fBitGain_fx = L_add( fBitGain_fx, pfEstPredBitGain_fx[b] ); + } + // if (fBitGain > fBestCost) + IF( GT_32( fBitGain_fx, fBestCost_fx ) ) + { + fBestCost_fx = fBitGain_fx; + iPredBands = b; + iPredChanEnable = 1; + } + } + + IF( EQ_32( iPredChanEnable, 1 ) ) + { + FOR( b = iPredBands + bstep; b < LCLD_BANDS; b += bstep ) + { + psPredictionEncoder->ppiPredBandEnable[c][b] = 0; + } + activate_bit( &psPredictionEncoder->piPredChanEnable[c], psPredictionEncoder->iSubSetId ); + psPredictionEncoder->piNumPredBands[c] = iPredBands + bstep; + } + ELSE + { + FOR( b = b0; b < LCLD_BANDS; b += bstep ) + { + psPredictionEncoder->ppiPredBandEnable[c][b] = 0; + } + deactivate_bit( &psPredictionEncoder->piPredChanEnable[c], psPredictionEncoder->iSubSetId ); + psPredictionEncoder->piNumPredBands[c] = 0; + move32(); + } + } + } +} + +/*-------------------------------------------------------------------* + * Function ApplyForwardPredictors() + * + * + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Function WritePredictors() + * + * + *-------------------------------------------------------------------*/ + +Word32 WritePredictors( + PredictionEncoder *psPredictionEncoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsWritten = 0; + Word32 c; + Word32 iNumSubSets = psPredictionEncoder->iNumSubSets; + Word32 iSubSetId = psPredictionEncoder->iSubSetId; + Word32 iNumPredBandBits = 6; + const Word16 iSubSetBits = ( GT_16( LCLD_MAX_NUM_PRED_SUBSETS, 4 ) ? 3 : 2 ); + move32(); + move32(); + move16(); + + /* number of subsets */ + ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( iNumSubSets, 1 ), iSubSetBits ); /* otherwise use default */ + iBitsWritten = L_add( iBitsWritten, iSubSetBits ); + + IF( GT_32( iNumSubSets, 1 ) ) + { + /* write current subset */ + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iSubSetId, iSubSetBits ); + iBitsWritten = L_add( iBitsWritten, iSubSetBits ); + iNumPredBandBits = ( GE_32( iNumSubSets, 4 ) ? 4 : 5 ); + move32(); + } + + FOR( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + Word32 b; + Word32 b0 = iSubSetId; + move32(); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, psPredictionEncoder->piPredChanEnable[c], iNumSubSets ); + iBitsWritten = L_add( iBitsWritten, iNumSubSets ); + + IF( get_bit( psPredictionEncoder->piPredChanEnable[c], iSubSetId ) ) + { + Word32 iNumPredBands = L_sub( psPredictionEncoder->piNumPredBands[c], b0 ) / iNumSubSets; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iNumPredBands, iNumPredBandBits ); + iBitsWritten = L_add( iBitsWritten, iNumPredBandBits ); + + FOR( b = b0; b < psPredictionEncoder->piNumPredBands[c]; b += iNumSubSets ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, psPredictionEncoder->ppiPredBandEnable[c][b], 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + + IF( EQ_32( psPredictionEncoder->ppiPredBandEnable[c][b], 1 ) ) + { + Word32 iA1Mag; + Word32 iA1Phase; + + iA1Mag = psPredictionEncoder->ppiA1Mag[c][b]; + move32(); + iA1Phase = L_sub( psPredictionEncoder->ppiA1Phase[c][b], PRED_QUANT_FILTER_PHASE_MIN ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iA1Mag, PRED_QUNAT_FILTER_MAG_BITS ); + iBitsWritten = L_add( iBitsWritten, PRED_QUNAT_FILTER_MAG_BITS ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iA1Phase, PRED_QUANT_FILTER_PHASE_BITS ); + iBitsWritten = L_add( iBitsWritten, PRED_QUANT_FILTER_PHASE_BITS ); + } + } + } + } + + return iBitsWritten; +} +#endif diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c new file mode 100644 index 000000000..0c24040be --- /dev/null +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -0,0 +1,964 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/* Double check cost function calculation */ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" +#include "isar_lcld_prot.h" +#include "isar_lcld_rom_tables.h" +#include "wmc_auto.h" +#include "prot_fx2.h" +#include "basop_util.h" +#include "enh64.h" +Word32 Inv_grp_length[17] = { + // Q31 + 0, + 2147483647, + 1073741823, + 715827882, + 536870911, + 429496729, + 357913941, + 306783378, + 268435455, + 238609294, + 214748364, + 195225786, + 178956970, + 165191049, + 153391689, + 143165576, + 134217727, + +}; + +/*-------------------------------------------------------------------* + * Local ROM tables + * + * + *-------------------------------------------------------------------*/ +static const Word32 c_afThreshQuiet48_fx[23] = { + // Q23 + -705191424, + -705191424, + -705191424, + -705191424, + -705191424, + -705191424, + -705191424, + -705191424, + -703021824, + -694920256, + -685375488, + -662531840, + -646432768, + -636262784, + -627448000, + -618652544, + -598245120, + -575579520, + -550540736, + -508787360, + -264583456, + -161516096, + -158042848, +}; +static const Word32 c_fiDefaultTheta48_fx[MAX_BANDS_48] = { + // Q31 + 939524096, + 939524096, + 805306368, + 671088640, + 671088640, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, + 536870912, +}; +typedef struct GMNODE +{ + int32_t iGroupStart; + int32_t iGroupLength; + Word32 *pfMergedEnergydB_fx; + int32_t *piQRMSEnvelope; + + int32_t iGroupRMSEnvelopeCost; + Word32 fGroupSNRPenalty_fx; + Word16 fGroupSNRPenalty_exp; + struct GMNODE *psNext; +} GMNode; + +struct RMS_ENVELOPE_GROUPING +{ + int32_t iNumBlocks; + int32_t iMaxGroups; + Word32 **ppfWeight_man; + Word16 **ppfWeight_exp; + Word32 **ppfBandEnergy_man; + Word16 **ppfBandEnergy_exp; + Word32 **ppfBandEnergydB_fx; + // Word32 **ppfWeight_fx; + GMNode *psGMNodes; +}; + + +/*-------------------------------------------------------------------* + * Function CreateRMSEnvelopeGrouping() + * + * + *-------------------------------------------------------------------*/ + +RMSEnvelopeGrouping *CreateRMSEnvelopeGrouping( + const Word32 iNumBlocks ) +{ + Word32 n; + + RMSEnvelopeGrouping *psRMSEnvelopeGrouping; + + psRMSEnvelopeGrouping = (RMSEnvelopeGrouping *) malloc( sizeof( RMSEnvelopeGrouping ) ); + psRMSEnvelopeGrouping->iNumBlocks = iNumBlocks; + + psRMSEnvelopeGrouping->iMaxGroups = iNumBlocks >> 1; + psRMSEnvelopeGrouping->ppfBandEnergy_man = (Word32 **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( Word32 * ) ); + psRMSEnvelopeGrouping->ppfBandEnergy_exp = (Word16 **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( Word16 * ) ); + psRMSEnvelopeGrouping->ppfBandEnergydB_fx = (Word32 **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( Word32 * ) ); + psRMSEnvelopeGrouping->ppfWeight_man = (Word32 **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( Word32 * ) ); + psRMSEnvelopeGrouping->ppfWeight_exp = (Word16 **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( Word16 * ) ); + + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + psRMSEnvelopeGrouping->ppfBandEnergy_man[n] = (Word32 *) malloc( MAX_BANDS * 2 * sizeof( Word32 ) ); /* 2 for stereo joint group calc */ + psRMSEnvelopeGrouping->ppfBandEnergy_exp[n] = (Word16 *) malloc( MAX_BANDS * 2 * sizeof( Word16 ) ); /* 2 for stereo joint group calc */ + psRMSEnvelopeGrouping->ppfBandEnergydB_fx[n] = (Word32 *) malloc( MAX_BANDS * 2 * sizeof( Word32 ) ); + psRMSEnvelopeGrouping->ppfWeight_man[n] = (Word32 *) malloc( MAX_BANDS * 2 * sizeof( Word32 ) ); + psRMSEnvelopeGrouping->ppfWeight_exp[n] = (Word16 *) malloc( MAX_BANDS * 2 * sizeof( Word16 ) ); + } + + psRMSEnvelopeGrouping->psGMNodes = (GMNode *) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( GMNode ) ); + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + psRMSEnvelopeGrouping->psGMNodes[n].pfMergedEnergydB_fx = (Word32 *) malloc( MAX_BANDS * 2 * sizeof( float ) ); + psRMSEnvelopeGrouping->psGMNodes[n].piQRMSEnvelope = (Word32 *) malloc( MAX_BANDS * 2 * sizeof( int32_t ) ); + psRMSEnvelopeGrouping->psGMNodes[n].iGroupRMSEnvelopeCost = -1; + psRMSEnvelopeGrouping->psGMNodes[n].fGroupSNRPenalty_fx = L_negate( ONE_IN_Q30 ); + psRMSEnvelopeGrouping->psGMNodes[n].fGroupSNRPenalty_exp = 1; + } + + return psRMSEnvelopeGrouping; +} + + +/*-------------------------------------------------------------------* + * Function DeleteRMSEnvelopeGrouping() + * + * + *-------------------------------------------------------------------*/ + +void DeleteRMSEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping ) +{ + int32_t n; + + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + free( psRMSEnvelopeGrouping->ppfBandEnergy_man[n] ); + free( psRMSEnvelopeGrouping->ppfBandEnergy_exp[n] ); + free( psRMSEnvelopeGrouping->ppfBandEnergydB_fx[n] ); + free( psRMSEnvelopeGrouping->ppfWeight_man[n] ); + free( psRMSEnvelopeGrouping->ppfWeight_exp[n] ); + } + free( psRMSEnvelopeGrouping->ppfBandEnergy_man ); + free( psRMSEnvelopeGrouping->ppfBandEnergy_exp ); + free( psRMSEnvelopeGrouping->ppfBandEnergydB_fx ); + free( psRMSEnvelopeGrouping->ppfWeight_man ); + free( psRMSEnvelopeGrouping->ppfWeight_exp ); + + + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + free( psRMSEnvelopeGrouping->psGMNodes[n].pfMergedEnergydB_fx ); + free( psRMSEnvelopeGrouping->psGMNodes[n].piQRMSEnvelope ); + } + free( psRMSEnvelopeGrouping->psGMNodes ); + + free( psRMSEnvelopeGrouping ); + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputeBandEnergy() + * + * + *-------------------------------------------------------------------*/ +static void ComputeBandEnergy( + const Word32 iChannels, + const Word32 iNumBlocks, + const Word32 iNumBands, + const Word32 *piBandwidths, + Word32 ***pppfReal_fx, + Word32 ***pppfImag_fx, + Word32 **ppfBandEnergy_man, + Word16 **ppfBandEnergy_exp, + Word32 **ppfBandEnergydB_fx, + Word32 **ppfWeight_man, + Word16 **ppfWeight_exp, + Word16 q_final ) +{ + + Word32 n; + Word32 constant = 1616142483; // Q29 of(1/log2(10))*10 + Word32 const_comp3, const_comp1; + Word16 exp3 = 0, exp1 = 0, Flag1, Flag2, Flag3; + Word16 div_exp; + /*For 0.33f*/ + const_comp3 = 1417339264; + move32(); + exp3 = -1; + move16(); + // f2me( 0.33, &const_comp3, &exp3 );// + // f2me( 1.0, &const_comp1, &exp1 );// + /*For 1.0f*/ + Word32 mul_32; + Word16 mul_exp; + const_comp1 = 1073741824; + move32(); + exp1 = 1; + move16(); + FOR( n = 0; n < iChannels; n++ ) + { + Word32 k; + Word32 iChanOffset; + + iChanOffset = L_mult0( extract_l( n ), extract_l( iNumBands ) ); + FOR( k = 0; k < iNumBlocks; k++ ) + { + Word32 b; + Word32 iFBOffset; + Word32 fMaxWeight_fx = 0; + move32(); + Word16 fMaxWeight_exp = 0; + move16(); + iFBOffset = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 m; + Word16 fEnergy_exp; + Word32 fEnergy_fx, fWeight_temp; + Word16 shift_value; + Word32 fEnergy_log_fx, fEnergy_log_fx1; + fEnergy_exp = 0; + move16(); + /*For 1e-12f in Q63*/ + Word32 fWeight_fx; + Word64 Wmult_value; + Word16 exp_pow = 0; + move16(); + Word16 guard_bits = find_guarded_bits_fx( piBandwidths[b] + 1 ); + // fEnergy_f64 = W_shr( fEnergy_f64, ( 63 - ( 2 * ( q_final - guard_bits ) + 1 ) ) ); + fEnergy_fx = 1180591616; + fEnergy_exp = -39; + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + Wmult_value = W_add( W_mult_32_32( L_shr( pppfReal_fx[n][k][iFBOffset], guard_bits ), L_shr( pppfReal_fx[n][k][iFBOffset], guard_bits ) ), W_mult_32_32( L_shr( pppfImag_fx[n][k][iFBOffset], guard_bits ), L_shr( pppfImag_fx[n][k][iFBOffset], guard_bits ) ) ); + shift_value = W_norm( Wmult_value ); + mul_32 = W_extract_h( W_shl( Wmult_value, shift_value ) ); + mul_exp = 31 - ( 2 * ( q_final - guard_bits ) + 1 + shift_value - 32 ); + fEnergy_fx = BASOP_Util_Add_Mant32Exp( fEnergy_fx, fEnergy_exp, mul_32, mul_exp, &fEnergy_exp ); // Some large number to prevent clipping + iFBOffset++; + } + IF( EQ_32( fEnergy_fx, 0 ) ) + { + // f2me( 1e-12f, &fEnergy_fx, &fEnergy_exp ); // + fEnergy_fx = 1180591616; + fEnergy_exp = -39; + fEnergy_fx = Mpy_32_32( fEnergy_fx, Inv_grp_length[piBandwidths[b]] ); // Correction removed normalization by 2 + ppfBandEnergy_man[k][iChanOffset + b] = fEnergy_fx; + move32(); + ppfBandEnergy_exp[k][iChanOffset + b] = fEnergy_exp; + move16(); + fEnergy_fx = Mpy_32_32( fEnergy_fx, Inv_grp_length[piBandwidths[b]] ); // Correction removed normalization by 2 + ppfBandEnergy_man[k][iChanOffset + b] = fEnergy_fx; + move32(); + ppfBandEnergy_exp[k][iChanOffset + b] = fEnergy_exp; + move16(); + fEnergy_log_fx1 = -1006632960; // Q23 + fWeight_fx = 403727488; // Q31 + exp_pow = 0; + } + ELSE + { + fEnergy_fx = Mpy_32_32( fEnergy_fx, Inv_grp_length[piBandwidths[b]] ); // Correction removed normalization by 2 + ppfBandEnergy_man[k][iChanOffset + b] = fEnergy_fx; + move32(); + ppfBandEnergy_exp[k][iChanOffset + b] = fEnergy_exp; + move16(); + fEnergy_fx = BASOP_Util_Log2( fEnergy_fx ); + move32(); + fEnergy_log_fx = L_add( fEnergy_fx, L_shl( L_deposit_l( fEnergy_exp ), WORD32_BITS - 1 - LD_DATA_SCALE ) ); /*Q25*/ // log2f( fEnergy ) + fEnergy_log_fx1 = Mpy_32_32( fEnergy_log_fx, constant ); + fEnergy_log_fx = L_sub( fEnergy_log_fx1, c_afThreshQuiet48_fx[b] ); // Q23 of ( 10.0f * log10f( fEnergy ) - c_afThreshQuiet48[b] ) ) + fWeight_fx = Mpy_32_32( 48509336, fEnergy_log_fx ); // 0.0068f*3.3219 in Q31, result in Q23 + fWeight_temp = BASOP_util_Pow2( fWeight_fx, 8, &exp_pow ); + fWeight_fx = Mpy_32_32( 708669604, fWeight_temp ); // 708669604 = Q31 0f 0.33 + } + Flag1 = BASOP_Util_Cmp_Mant32Exp( fWeight_fx, exp_pow, const_comp3, exp3 ); + IF( NE_16( Flag1, 1 ) ) + { + fWeight_fx = const_comp3; + move32(); + exp_pow = exp3; + move16(); + } + Flag2 = BASOP_Util_Cmp_Mant32Exp( const_comp1, exp1, fWeight_fx, exp_pow ); + IF( NE_16( Flag2, 1 ) ) + { + fWeight_fx = const_comp1; + move32(); + exp_pow = exp1; + move16(); + } + Flag3 = BASOP_Util_Cmp_Mant32Exp( fMaxWeight_fx, fMaxWeight_exp, fWeight_fx, exp_pow ); + IF( NE_16( Flag3, 1 ) ) + { + fMaxWeight_fx = fWeight_fx; + move32(); + fMaxWeight_exp = exp_pow; + move16(); + } +#ifdef APPLY_TEMPORAL_SMOOTHING + if ( k > 0 ) + { + float fSmoothEnergy; + fSmoothEnergy = 0.7f * ppfBandEnergy[k - 1][iChanOffset + b] + 0.3f * fEnergy; + + fEnergy = ( fEnergy > fSmoothEnergy ) ? fEnergy : fSmoothEnergy; + } +#endif + ppfWeight_man[k][iChanOffset + b] = fWeight_fx; + ppfWeight_exp[k][iChanOffset + b] = exp_pow; + ppfBandEnergydB_fx[k][iChanOffset + b] = fEnergy_log_fx1; // Q23 + } + FOR( b = 0; b < iNumBands; b++ ) + { + ppfWeight_man[k][iChanOffset + b] = L_deposit_h( BASOP_Util_Divide3232_Scale( ppfWeight_man[k][iChanOffset + b], fMaxWeight_fx, &div_exp ) ); + ppfWeight_exp[k][iChanOffset + b] = div_exp + ppfWeight_exp[k][iChanOffset + b] - fMaxWeight_exp; + } + } + } + /* fclose( fp ); + fclose( fp1 );*/ + return; +} +/*-------------------------------------------------------------------* + * Function ComputeMergeRMS() + * + * + *-------------------------------------------------------------------*/ +static void ComputeMergeRMS( + const Word32 iNumBands, + const Word32 iStartBlock, + const Word32 iGroupLength, + Word32 *pfMergedEnergydB, + Word32 *piQRMSEnvelope, + Word32 **ppfBandEnergy_man, + Word16 **ppfBandEnergy_exp ) +{ + Word32 b; + /* FILE *fp = fopen( "float_fGroupEnergy.txt","ab+" ); + FILE *fp1 = fopen( "fixed_fGroupEnergy.txt","ab+" );*/ + Word32 constant = 1616142483; // Q29 of(1/log2(10))*10 // Note epsolon was added when computing BandEnergy; + move32(); + Word32 fGroupEnergy32_fx; + + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 n; + Word32 fGroupEnergy_fx = 0; + move32(); + Word16 fGroupEnergy_exp = 0; + move16(); + Word32 fRMSEnvelope_fx; + Word32 iQRMSEnvelope_fx; + FOR( n = iStartBlock; n < ( iStartBlock + iGroupLength ); n++ ) + { + fGroupEnergy_fx = BASOP_Util_Add_Mant32Exp( ppfBandEnergy_man[n][b], ppfBandEnergy_exp[n][b], fGroupEnergy_fx, fGroupEnergy_exp, &fGroupEnergy_exp ); + } + fGroupEnergy_fx = Mpy_32_32( fGroupEnergy_fx, Inv_grp_length[iGroupLength] ); // Division by iGroupLength + move32(); + IF( NE_32( fGroupEnergy_fx, 0 ) ) + { + fRMSEnvelope_fx = BASOP_Util_Log2( fGroupEnergy_fx ); + move32(); + fRMSEnvelope_fx = L_add( fRMSEnvelope_fx, L_shl( L_deposit_l( fGroupEnergy_exp ), WORD32_BITS - 1 - LD_DATA_SCALE ) ); /*Q25*/ + } + ELSE + { + fRMSEnvelope_fx = 0; + fGroupEnergy_exp = 0; + } + iQRMSEnvelope_fx = ( fRMSEnvelope_fx > 0 ) ? L_add( fRMSEnvelope_fx, ONE_IN_Q24 ) : L_negate( L_add( L_negate( fRMSEnvelope_fx ), ONE_IN_Q24 ) ); + iQRMSEnvelope_fx = L_shr( iQRMSEnvelope_fx, 25 ); + + fGroupEnergy32_fx = fRMSEnvelope_fx; /*Q25*/ // BASOP_Util_Log2( fGroupEnergy_fx ); + fGroupEnergy32_fx = Mpy_32_32( fGroupEnergy32_fx, constant ); // Q23 + pfMergedEnergydB[b] = fGroupEnergy32_fx; // Q23 + piQRMSEnvelope[b] = iQRMSEnvelope_fx; // Q25 + } + return; +} +/*-------------------------------------------------------------------* + * Function ComputeRMSEnvelopeBits() + * + * + *-------------------------------------------------------------------*/ +static Word32 ComputeRMSEnvelopeBits( + const Word32 iChannels, + const Word32 iNumBands, + const Word32 *piQRMSEnevelope ) +{ + Word32 n; + Word32 iRMSEnvelopeBits = 0; + move32(); + Word32 iChanOffset = 0; + move32(); + + FOR( n = 0; n < iChannels; n++ ) + { + Word32 b; + Word32 iLastRMSVal; + + iRMSEnvelopeBits = L_add( iRMSEnvelopeBits, ENV0_BITS ); + iLastRMSVal = piQRMSEnevelope[iChanOffset]; + move32(); + FOR( b = 1; b < iNumBands; b++ ) + { + Word32 iDelta; + + iDelta = L_sub( piQRMSEnevelope[iChanOffset + b], iLastRMSVal ); + iDelta = ( iDelta > ENV_DELTA_MIN ) ? iDelta : ENV_DELTA_MIN; + iDelta = ( iDelta < ENV_DELTA_MAX ) ? iDelta : ENV_DELTA_MAX; + iDelta = L_sub( iDelta, ENV_DELTA_MIN ); + iRMSEnvelopeBits = L_add( iRMSEnvelopeBits, c_aaiRMSEnvHuffEnc[iDelta][0] ); + + iLastRMSVal = piQRMSEnevelope[iChanOffset + b]; + move32(); + } + + iChanOffset = L_add( iChanOffset, iNumBands ); + } + + return iRMSEnvelopeBits; +} +/*-------------------------------------------------------------------* + * Function ComputeSNRPenalty() + * + * + *-------------------------------------------------------------------*/ +static Word32 ComputeSNRPenalty( + const Word32 iChannels, + const Word32 iNumBands, + const Word32 *piBandwidths, + const Word32 iStartBlock, + const Word32 iGroupLength, + Word32 **ppfBandEnergy_dB_fx, + const Word32 *piRMSEnvelope, + Word16 *fSNRPenalty_exp ) +{ + Word32 n; + Word32 iChanOffset; + Word32 temp; + Word32 fSNRPenalty_fx = 0; + move32(); + Word32 fSNRPenaltyconst_fx = 0; + move32(); + Word32 mul_temp; + Word16 fSNRPenaltycnst_exp = 0, exp = 0; + /*FILE *fp = fopen( "float_SNRpenalty.txt", "ab+" ); + FILE *fp1 = fopen( "fixed_SNRpenalty.txt", "ab+" );*/ + // f2me( 1e10f, &fSNRPenaltyconst_fx, &fSNRPenaltycnst_exp );// + /*For 1e10f*/ + fSNRPenaltyconst_fx = 1250000000; + fSNRPenaltycnst_exp = 34; + iChanOffset = 0; + move32(); + FOR( n = 0; n < iChannels; n++ ) + { + Word32 b; + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 k; + Word32 fRMSVal_fx; + Word32 RMS_value_fx; + // RMS_value = piRMSEnvelope[iChanOffset + b]; + RMS_value_fx = L_shl( piRMSEnvelope[iChanOffset + b], 25 ); + move32(); + // fRMSVal = 3.0103f * (float) RMS_value; + fRMSVal_fx = Mpy_32_32( 1616142506, RMS_value_fx ); // Q23 + move32(); + FOR( k = iStartBlock; k < ( iStartBlock + iGroupLength ); k++ ) + { + Word32 fDeltadB_fx; + fDeltadB_fx = L_sub( fRMSVal_fx, ppfBandEnergy_dB_fx[k][iChanOffset + b] ); + IF( LT_32( fDeltadB_fx, -75756680 ) ) + { + fSNRPenalty_fx = BASOP_Util_Add_Mant32Exp( fSNRPenalty_fx, *fSNRPenalty_exp, fSNRPenaltyconst_fx, fSNRPenaltycnst_exp, fSNRPenalty_exp ); // Some large number to prevent clipping + } + ELSE + { + mul_temp = L_abs( L_sub( Mpy_32_32( c_fiDefaultTheta48_fx[b], fDeltadB_fx ), fDeltadB_fx ) ); + temp = Mpy_32_32( mul_temp, Mpy_32_32( 715827883, L_shl( piBandwidths[b], 27 ) ) ); // Q27+23 -31=19 + exp = Q12; // Q31 - Q19 + fSNRPenalty_fx = BASOP_Util_Add_Mant32Exp( fSNRPenalty_fx, *fSNRPenalty_exp, temp, exp, fSNRPenalty_exp ); + } + } + } + + iChanOffset = L_add( iChanOffset, iNumBands ); + } + // fprintf( fp,"%f\n", fSNRPenalty ); + // fprintf( fp1,"%f\n", fSNRPenalty ); + /* fclose( fp ); + fclose( fp1 );*/ + return fSNRPenalty_fx; +} +/*-------------------------------------------------------------------* + * Function TryMerge2() + * + * + *-------------------------------------------------------------------*/ +static Word32 TryMerge2( + const Word32 iChannels, + const Word32 iNumBands, + const Word32 *piBandwidths, + Word32 **ppfBandEnergy_man, + Word16 **ppfBandEnergy_exp, + Word32 **ppfBandEnergydB_fx, + GMNode *psGMNode1, + GMNode *psGMNode2, + Word16 *fMergedCost_exp ) +{ + Word32 iRMSEnvBits1; + Word32 iRMSEnvBits2; + Word32 iRMSEnvBitsMerged; + Word32 temp = 0; + move32(); + Word16 temp_exp = 0; + move16(); + Word32 fMergedCost_fx = 0; + move32(); + Word32 RMSEnvBits_fx; + Word32 fSNRPenalty1_fx; + Word32 fSNRPenalty2_fx; + Word32 fSNRPenaltyMerged_fx; + Word16 fSNRPenalty1_exp = 0; + move16(); + Word16 fSNRPenalty2_exp = 0; + move16(); + Word16 fSNRPenaltyMerged_exp = 0; + move16(); + Word32 one_in_mant = L_negate( ONE_IN_Q30 ); + Word16 one_in_exp = 1; + move16(); + *fMergedCost_exp = 0; + move16(); + Word16 flag = 0; + move16(); + IF( EQ_32( psGMNode1->fGroupSNRPenalty_fx, one_in_mant ) && EQ_16( psGMNode1->fGroupSNRPenalty_exp, one_in_exp ) ) + { + flag = 1; + move16(); + } + /* First compute current RMS Envelope for each group */ + IF( EQ_32( psGMNode1->iGroupRMSEnvelopeCost, -1 ) || flag ) + { + ComputeMergeRMS( iNumBands * iChannels, psGMNode1->iGroupStart, psGMNode1->iGroupLength, psGMNode1->pfMergedEnergydB_fx, psGMNode1->piQRMSEnvelope, ppfBandEnergy_man, ppfBandEnergy_exp ); + iRMSEnvBits1 = ComputeRMSEnvelopeBits( iChannels, iNumBands, psGMNode1->piQRMSEnvelope ); + fSNRPenalty1_fx = ComputeSNRPenalty( iChannels, iNumBands, piBandwidths, psGMNode1->iGroupStart, psGMNode1->iGroupLength, ppfBandEnergydB_fx, psGMNode1->piQRMSEnvelope, &fSNRPenalty1_exp ); + psGMNode1->iGroupRMSEnvelopeCost = iRMSEnvBits1; + move32(); + psGMNode1->fGroupSNRPenalty_fx = fSNRPenalty1_fx; + move32(); + psGMNode1->fGroupSNRPenalty_exp = fSNRPenalty1_exp; + move16(); + } + ELSE + { + iRMSEnvBits1 = psGMNode1->iGroupRMSEnvelopeCost; + move32(); + fSNRPenalty1_fx = psGMNode1->fGroupSNRPenalty_fx; + move32(); + fSNRPenalty1_exp = psGMNode1->fGroupSNRPenalty_exp; + move16(); + } + IF( EQ_32( psGMNode2->fGroupSNRPenalty_fx, one_in_mant ) && EQ_16( psGMNode2->fGroupSNRPenalty_exp, one_in_exp ) ) + { + flag = 1; + move16(); + } + IF( EQ_32( psGMNode2->iGroupRMSEnvelopeCost, -1 ) || flag ) + { + + ComputeMergeRMS( iNumBands * iChannels, psGMNode2->iGroupStart, psGMNode2->iGroupLength, psGMNode2->pfMergedEnergydB_fx, psGMNode2->piQRMSEnvelope, ppfBandEnergy_man, ppfBandEnergy_exp ); + iRMSEnvBits2 = ComputeRMSEnvelopeBits( iChannels, iNumBands, psGMNode2->piQRMSEnvelope ); + fSNRPenalty2_fx = ComputeSNRPenalty( iChannels, iNumBands, piBandwidths, psGMNode2->iGroupStart, psGMNode2->iGroupLength, ppfBandEnergydB_fx, psGMNode2->piQRMSEnvelope, &fSNRPenalty2_exp ); + psGMNode2->iGroupRMSEnvelopeCost = iRMSEnvBits2; + move32(); + psGMNode2->fGroupSNRPenalty_fx = fSNRPenalty2_fx; + move32(); + psGMNode2->fGroupSNRPenalty_exp = fSNRPenalty2_exp; + move16(); + } + ELSE + { + iRMSEnvBits2 = psGMNode2->iGroupRMSEnvelopeCost; + move32(); + fSNRPenalty2_fx = psGMNode2->fGroupSNRPenalty_fx; + move32(); + fSNRPenalty2_exp = psGMNode2->fGroupSNRPenalty_exp; + move16(); + } + ComputeMergeRMS( iNumBands * iChannels, psGMNode1->iGroupStart, psGMNode1->iGroupLength + psGMNode2->iGroupLength, psGMNode1->pfMergedEnergydB_fx, psGMNode1->piQRMSEnvelope, ppfBandEnergy_man, ppfBandEnergy_exp ); + + /* Compute the RMS Envelope cost for merged group */ + iRMSEnvBitsMerged = ComputeRMSEnvelopeBits( iChannels, iNumBands, psGMNode1->piQRMSEnvelope ); + // fSNRPenalty_exp = 0; + /* Compute an approximation of the bit cost based on SNR increase/decrease due to merging */ + fSNRPenaltyMerged_fx = ComputeSNRPenalty( iChannels, iNumBands, piBandwidths, psGMNode1->iGroupStart, psGMNode1->iGroupLength + psGMNode2->iGroupLength, ppfBandEnergydB_fx, psGMNode1->piQRMSEnvelope, &fSNRPenaltyMerged_exp ); + RMSEnvBits_fx = L_sub( L_sub( iRMSEnvBitsMerged, iRMSEnvBits1 ), iRMSEnvBits2 ); + RMSEnvBits_fx = L_shl( RMSEnvBits_fx, 10 ); // Converting to Q10 + temp = BASOP_Util_Add_Mant32Exp( fSNRPenaltyMerged_fx, fSNRPenaltyMerged_exp, L_negate( fSNRPenalty1_fx ), fSNRPenalty1_exp, &temp_exp ); + fMergedCost_fx = BASOP_Util_Add_Mant32Exp( temp, temp_exp, L_negate( fSNRPenalty2_fx ), fSNRPenalty2_exp, fMergedCost_exp ); + fMergedCost_fx = BASOP_Util_Add_Mant32Exp( fMergedCost_fx, *fMergedCost_exp, RMSEnvBits_fx, 21, fMergedCost_exp ); + // fMergedCost = fSNRPenaltyMerged - fSNRPenalty1 - fSNRPenalty2 + (float) iRMSEnvBitsMerged - (float) iRMSEnvBits1 - (float) iRMSEnvBits2; + return fMergedCost_fx; +} + +/*-------------------------------------------------------------------* + * Function ComputeGreedyGroups3() + * + * + *-------------------------------------------------------------------*/ +static void ComputeGreedyGroups3( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping, + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t iMaxGroups ) +{ + + Word32 iDone = 0; + Word32 iNumGroups = psRMSEnvelopeGrouping->iMaxGroups; + WHILE( EQ_32( iDone, 0 ) ) + { + GMNode *psGMNode; + GMNode *psBestGMNode; + /* Instead of 1e20f*/ + Word32 fBestMergeCost_fx = 1455191552; // mantissa of 1e20f + move32(); + Word16 fBestMergeCost_exp = 67; // exp of 1e20f + move16(); + Word16 Flag = 0; + move16(); + psGMNode = &psRMSEnvelopeGrouping->psGMNodes[0]; + psBestGMNode = NULL; + WHILE( psGMNode->psNext != NULL ) + { + Word32 fMergeCost_fx = 0; + move32(); + Word16 fMergeCost_exp = 0; + move16(); + fMergeCost_fx = TryMerge2( iChannels, iNumBands, piBandwidths, psRMSEnvelopeGrouping->ppfBandEnergy_man, psRMSEnvelopeGrouping->ppfBandEnergy_exp, psRMSEnvelopeGrouping->ppfBandEnergydB_fx, psGMNode, psGMNode->psNext, &fMergeCost_exp ); + IF( LT_32( fMergeCost_fx, 0 ) && ( GT_32( fBestMergeCost_fx, 0 ) ) ) + { + + Flag = 1; + move16(); + } + ELSE IF( ( GT_32( fMergeCost_fx, 0 ) && ( LT_32( fBestMergeCost_fx, 0 ) ) ) ) + { + Flag = -1; + move16(); + } + ELSE + { + Flag = BASOP_Util_Cmp_Mant32Exp( fBestMergeCost_fx, fBestMergeCost_exp, fMergeCost_fx, fMergeCost_exp ); + } + IF( EQ_32( Flag, 1 ) ) + { + fBestMergeCost_fx = fMergeCost_fx; + move32(); + fBestMergeCost_exp = fMergeCost_exp; + move16(); + psBestGMNode = psGMNode; + } + + psGMNode = psGMNode->psNext; + } + + IF( ( GT_32( fBestMergeCost_fx, 0 ) && ( LE_32( iNumGroups, iMaxGroups ) ) ) ) + { + iDone++; + } + ELSE IF( ( psBestGMNode != NULL ) && ( psBestGMNode->psNext != NULL ) ) + { + psBestGMNode->iGroupLength = L_add( psBestGMNode->psNext->iGroupLength, psBestGMNode->iGroupLength ); + psBestGMNode->fGroupSNRPenalty_fx = L_negate( ONE_IN_Q30 ); + psBestGMNode->fGroupSNRPenalty_exp = 1; + move16(); + psBestGMNode->psNext = psBestGMNode->psNext->psNext; + iNumGroups--; + } + ELSE + { + iDone++; // This only catches a problem + } + } + return; +} +/*-------------------------------------------------------------------* + * Function ComputeRMSEnvelope() + * + * + *-------------------------------------------------------------------*/ +static void ComputeRMSEnvelope( + const Word32 iChannels, + const Word32 iNumBands, + const Word32 iNumGroups, + const Word32 *piGroupLengths, + Word32 **ppfBandEnergy_man, + Word16 **ppfBandEnergy_exp, + Word32 ***pppiRMSEnvelope ) +{ + Word32 n; + Word32 fGroupEnergy_fx; + Word16 fGroupEnergy_exp; + Word32 temp; + // FILE *fp = fopen( "RmsEnvelope_fixed", "ab+" ); + // FILE *fp1 = fopen( "RmsEnvelope_float", "ab+" ); + FOR( n = 0; n < iChannels; n++ ) + { + Word32 b; + Word32 iChanOffset; + + iChanOffset = L_mult0( extract_l( n ), extract_l( iNumBands ) ); + + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 k; + Word32 iBlockOffset; + iBlockOffset = 0; + FOR( k = 0; k < iNumGroups; k++ ) + { + Word32 m; + fGroupEnergy_exp = 0; + move16(); + fGroupEnergy_fx = 0; + move32(); + FOR( m = 0; m < piGroupLengths[k]; m++ ) + { + fGroupEnergy_fx = BASOP_Util_Add_Mant32Exp( ppfBandEnergy_man[iBlockOffset][b + iChanOffset], ppfBandEnergy_exp[iBlockOffset][b + iChanOffset], fGroupEnergy_fx, fGroupEnergy_exp, &fGroupEnergy_exp ); + iBlockOffset++; + } + fGroupEnergy_fx = Mpy_32_32( fGroupEnergy_fx, Inv_grp_length[piGroupLengths[k]] ); // Division by iGroupLength + fGroupEnergy_fx = BASOP_Util_Log2( fGroupEnergy_fx ); + move32(); + fGroupEnergy_fx = L_add( fGroupEnergy_fx, L_shl( L_deposit_l( fGroupEnergy_exp ), WORD32_BITS - 1 - LD_DATA_SCALE ) ); /*Q25*/ + temp = ( fGroupEnergy_fx > 0 ) ? L_add( fGroupEnergy_fx, ONE_IN_Q24 ) : L_negate( L_add( L_negate( fGroupEnergy_fx ), ONE_IN_Q24 ) ); // Q25 + temp = L_shr( temp, 25 ); + temp = ( temp > ENV_MIN ) ? temp : ENV_MIN; + temp = ( temp < ENV_MAX ) ? temp : ENV_MAX; + pppiRMSEnvelope[n][k][b] = temp; + // fprintf( fp,"%d\n", pppiRMSEnvelope[n][k][b] ); + } + } + } + // fclose( fp ); + /* fclose( fp1 );*/ + return; +} + +/*-------------------------------------------------------------------* + * Function LimitRMSEnvelope() + * + * + *-------------------------------------------------------------------*/ +static void LimitRMSEnvelope( + const Word32 iBandCount, + const Word32 iRMSDeltaMax, + const Word32 iRMSDeltaMin, + Word32 *piRMSEnvelope ) +{ + Word32 iBand; + Word32 iLastSCF; + + /* Increase low envelope values to ensure that the scale factors traces the large values correctly (checking for max deltas) */ + iLastSCF = piRMSEnvelope[iBandCount - 1]; + move32(); + for ( iBand = iBandCount - 2; iBand > -1; iBand-- ) + { + Word32 iDelta; + + iDelta = L_sub( iLastSCF, piRMSEnvelope[iBand] ); + + IF( GT_32( iDelta, iRMSDeltaMax ) ) + { +#ifdef DEBUG_VERBOSE + printf( "WARNING RMS envelope delta limited\n" ); +#endif + piRMSEnvelope[iBand] = L_add( L_sub( iDelta, iRMSDeltaMax ), piRMSEnvelope[iBand] ); + } + + iLastSCF = piRMSEnvelope[iBand]; + move32(); + } + + /* Increase low envelope values to ensure that the envelope traces the large values correctly (checking for min deltas)*/ + iLastSCF = piRMSEnvelope[0]; + FOR( iBand = 1; iBand < iBandCount; iBand++ ) + { + Word32 iDelta; + + iDelta = L_sub( piRMSEnvelope[iBand], iLastSCF ); + + IF( LT_32( iDelta, iRMSDeltaMin ) ) + { +#ifdef DEBUG_VERBOSE + printf( "WARNING RMS envelope delta limited\n" ); +#endif + piRMSEnvelope[iBand] = L_add( piRMSEnvelope[iBand], L_sub( iRMSDeltaMin, iDelta ) ); + } + + iLastSCF = piRMSEnvelope[iBand]; + move32(); + } + + return; +} + +/*-------------------------------------------------------------------* + * Function ComputeEnvelopeGrouping() + * + * + *-------------------------------------------------------------------*/ +void ComputeEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping, + const Word32 iChannels, + const Word32 iNumBands, + const Word32 *piBandwidths, + Word32 ***pppfReal_fx, + Word32 ***pppfImag_fx, + Word32 *piNumGroups, + Word32 *piGroupLengths, + Word32 ***pppiRMSEnvelope, + Word16 q_final ) +{ + Word32 n; + GMNode *psGMNode; + + /* Compute Band Energies */ + ComputeBandEnergy( iChannels, psRMSEnvelopeGrouping->iNumBlocks, iNumBands, piBandwidths, pppfReal_fx, pppfImag_fx, psRMSEnvelopeGrouping->ppfBandEnergy_man, psRMSEnvelopeGrouping->ppfBandEnergy_exp, psRMSEnvelopeGrouping->ppfBandEnergydB_fx, psRMSEnvelopeGrouping->ppfWeight_man, psRMSEnvelopeGrouping->ppfWeight_exp, q_final ); + /* Init GMNodes */ + psRMSEnvelopeGrouping->psGMNodes[0].iGroupStart = 0; + move32(); + psRMSEnvelopeGrouping->psGMNodes[0].iGroupLength = 2; + move32(); + psRMSEnvelopeGrouping->psGMNodes[0].psNext = NULL; + psRMSEnvelopeGrouping->psGMNodes[0].iGroupRMSEnvelopeCost = -1; + move32(); + psRMSEnvelopeGrouping->psGMNodes[0].fGroupSNRPenalty_fx = L_negate( ONE_IN_Q30 ); + psRMSEnvelopeGrouping->psGMNodes[0].fGroupSNRPenalty_exp = 1; + move16(); + FOR( n = 1; n < psRMSEnvelopeGrouping->iMaxGroups; n++ ) + { + psRMSEnvelopeGrouping->psGMNodes[n - 1].psNext = &psRMSEnvelopeGrouping->psGMNodes[n]; + psRMSEnvelopeGrouping->psGMNodes[n].iGroupStart = L_shl( n, 1 ); + move32(); + psRMSEnvelopeGrouping->psGMNodes[n].iGroupLength = 2; + move32(); + psRMSEnvelopeGrouping->psGMNodes[n].iGroupRMSEnvelopeCost = -1; + move32(); + psRMSEnvelopeGrouping->psGMNodes[n].fGroupSNRPenalty_fx = L_negate( ONE_IN_Q30 ); + psRMSEnvelopeGrouping->psGMNodes[n].fGroupSNRPenalty_exp = 1; + move16(); + psRMSEnvelopeGrouping->psGMNodes[n].psNext = NULL; + } + /* Perform grouping via Greedy Merge */ + /* Allows control over max groups can call using 16 if want same as previous call */ + ComputeGreedyGroups3( psRMSEnvelopeGrouping, iChannels, iNumBands, piBandwidths, psRMSEnvelopeGrouping->iNumBlocks ); + /* Calc Groups from Merge Results */ + *piNumGroups = 0; + move32(); + psGMNode = &psRMSEnvelopeGrouping->psGMNodes[0]; + WHILE( psGMNode != NULL ) + { + piGroupLengths[*piNumGroups] = psGMNode->iGroupLength; + move32(); + *piNumGroups = L_add( *piNumGroups, 1 ); + psGMNode = psGMNode->psNext; + } + /* Compute RMS Envelope given group lengths */ + ComputeRMSEnvelope( iChannels, iNumBands, *piNumGroups, piGroupLengths, psRMSEnvelopeGrouping->ppfBandEnergy_man, psRMSEnvelopeGrouping->ppfBandEnergy_exp, pppiRMSEnvelope ); + + /* Envelope Tenting */ + FOR( n = 0; n < iChannels; n++ ) + { + Word32 k; + FOR( k = 0; k < *piNumGroups; k++ ) + { + LimitRMSEnvelope( iNumBands, ENV_DELTA_MAX, ENV_DELTA_MIN, pppiRMSEnvelope[n][k] ); + } + } + + return; +} +#endif diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h new file mode 100644 index 000000000..72ff5b892 --- /dev/null +++ b/lib_isar/isar_cnst.h @@ -0,0 +1,159 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_CNST_H +#define ISAR_CNST_H + +#include +#include "options.h" + +/* clang-format off */ + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +/*----------------------------------------------------------------------------------* + * Split Binaural Rendering Constants + *----------------------------------------------------------------------------------*/ + +typedef enum +{ + PCM_INT16, + PCM_FLOAT32, + PCM_NOT_KNOW = 0xffff +} PCM_RESOLUTION; + +typedef enum +{ + ANY_YAW, + PITCH_ONLY, + ANY_ROLL, + PRED_ONLY, + PRED_ROLL_ONLY, + COM_GAIN_ONLY, + LR_GAIN_ONLY +} ISAR_SPLIT_REND_POSE_TYPE; + + +#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ + +#define SPLIT_REND_MAX_YAW_ONLY_POSES 2 +#define SPLIT_REND_MAX_PITCH_ONLY_POSES 2 +#define SPLIT_REND_MAX_ROLL_ONLY_POSES 2 +#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2 +#define MAX_EXTRAPOLATION_ANGLE 15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ +#define MAX_EXTRAPOLATION_ANGLE_Q22 (62914560) /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ + +#define MAX_HEAD_ROT_POSES ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES ) +#define MAX_SPLIT_REND_MD_BANDS 20 +#define MAX_SPLIT_MD_SUBFRAMES 1 +#define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +#define COMPLEX_MD_BAND_THRESH_LOW 4 +#define COMPLEX_MD_BAND_THRESH_HIGH 10 +#else +#define COMPLEX_MD_BAND_THRESH_LOW 5 +#endif +#define SPLIT_REND_RO_MD_BAND_THRESH 4 + +#define ISAR_SPLIT_REND_PRED_63QUANT_PNTS_LOG2_CEIL 6 +#define ISAR_SPLIT_REND_PRED_31QUANT_PNTS_LOG2_CEIL 5 +#define ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS_LOG2_CEIL 5 +#define ISAR_SPLIT_REND_D_QUANT_PNTS_LOG2_CEIL 4 + +#define ISAR_SPLIT_REND_PRED_MIN_VAL_Q30 -1503238553 //Q30 +#define ISAR_SPLIT_REND_PRED_MAX_VAL_Q30 1503238553 //Q30 + +#define ISAR_SPLIT_REND_NUM_QUANT_STRATS 4 +#define ISAR_SPLIT_REND_PRED_63QUANT_PNTS 63 +#define ISAR_SPLIT_REND_PRED_31QUANT_PNTS 31 +#define ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS 31 +#define ISAR_SPLIT_REND_D_QUANT_PNTS 15 +#define ISAR_SPLIT_REND_PRED_MIN_VAL -1.4f +#define ISAR_SPLIT_REND_PRED_MAX_VAL 1.4f + +#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL 0.5f +#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL 1.5f +#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL_Q30 (1<<29) //0.5f in Q30 +#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL_Q30 1610612736 //1.5f in Q30 +#define ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS ISAR_SPLIT_REND_D_QUANT_PNTS +#define ISAR_SPLIT_REND_D_MIN_VAL 0.0f +#define ISAR_SPLIT_REND_D_MAX_VAL 1.0f +#define ISAR_SPLIT_REND_D_MIN_VAL_FX 0 //Q31 +#define ISAR_SPLIT_REND_D_MAX_VAL_FX MAX_32 //Q31 + +#define ISAR_SPLIT_REND_PRED_ROLL_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PRED_ROLL_Q_STEP_Q31 200431807 +#define ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP_Q26 719023543 +#define ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP ( ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PRED31_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PRED31_1BYQ_STEP ( ( ISAR_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PRED63_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PRED63_1BYQ_STEP ( ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) + +#define ISAR_SPLIT_REND_PRED31_Q_STEP_FX_Q31 200431807 +#define ISAR_SPLIT_REND_PRED31_1BYQ_STEP_FX_Q26 719023543 +#define ISAR_SPLIT_REND_PRED63_Q_STEP_FX_Q31 96983132 +#define ISAR_SPLIT_REND_PRED63_1BYQ_STEP_FX_Q26 1485981989 + +#define ISAR_SPLIT_REND_D_Q_STEP ( ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) / ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_D_1BYQ_STEP ( ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PITCH_G_Q_STEP ( ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) / ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP ( ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ) +#define ISAR_SPLIT_REND_D_Q_STEP_Q31 153391689 +#define ISAR_SPLIT_REND_D_1BYQ_STEP_Q27 (14 << 27) //Q27 +#define ISAR_SPLIT_REND_PITCH_G_Q_STEP_Q31 153391689 +#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP_Q27 (14 << 27) //Q27 + + +#define ISAR_SPLIT_REND_HEAD_POSE_BITS 9 +#define ISAR_SPLIT_REND_DOF_BITS 2 +#define ISAR_SPLIT_REND_HQ_MODE_BITS 1 +#define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 +#define ISAR_SPLIT_REND_RO_FLAG_BITS 1 + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 +#endif +/*----------------------------------------------------------------------------------* + * Split rendering bitrate constants + *----------------------------------------------------------------------------------*/ + +#define SPLIT_REND_256k 256000 +#define SPLIT_REND_320k 320000 +#define SPLIT_REND_384k 384000 +#define SPLIT_REND_512k 512000 +#define SPLIT_REND_768k 768000 + +#endif /*SPLIT_REND_WITH_HEAD_ROT */ + +#endif /*ISAR_CNST_H */ +/* clang-format on */ diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c new file mode 100644 index 000000000..32e30e97c --- /dev/null +++ b/lib_isar/isar_lc3plus_common.c @@ -0,0 +1,89 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include "isar_lc3plus_common.h" +#include "ivas_error.h" +#include "lc3.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-----------------------------------------------------------------------------------------* + * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( + const LC3PLUS_Error lc3PlusError ) +{ + switch ( lc3PlusError ) + { + case LC3PLUS_OK: + return IVAS_ERR_OK; + case LC3PLUS_BITRATE_ERROR: + return IVAS_ERR_LC3PLUS_INVALID_BITRATE; + default: + break; + } + + return IVAS_ERR_INTERNAL; +} +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ) +{ + switch ( lc3PlusRtpError ) + { + case LC3PLUS_RTP_ERR_NO_ERROR: + return IVAS_ERR_OK; + case LC3PLUS_RTP_ERR_NULL_PTR: + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + case LC3PLUS_RTP_ERR_INVALID_PARAMETERS: + return IVAS_ERR_WRONG_PARAMS; + case LC3PLUS_RTP_ERR_NOT_IMPLEMENTED: + return IVAS_ERR_NOT_IMPLEMENTED; + case LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION: + return IVAS_ERR_INTERNAL; + case LC3PLUS_RTP_ERR_INVALID_BITSTREAM: + return IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM; + case LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE: + return IVAS_ERR_INVALID_BUFFER_SIZE; + case LC3PLUS_RTP_ERR_NOT_ENOUGH_FTDS_ALLOCATED: + return IVAS_ERR_INTERNAL; + case LC3PLUS_RTP_ERR_GENERIC_ERROR: + default: + break; + } + + return IVAS_ERR_UNKNOWN; +} +#endif +#endif diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h new file mode 100644 index 000000000..08ffff60a --- /dev/null +++ b/lib_isar/isar_lc3plus_common.h @@ -0,0 +1,72 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_COM_H +#define ISAR_LC3PLUS_COM_H + + +#include +#include "options.h" +#include "ivas_error.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lc3.h" +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#include "isar_lc3plus_payload.h" +#endif + +/*! common configuration parameters between encoder and decoder */ +typedef struct LC3PLUS_CONFIG +{ + /*! frame duration in microseconds [10000, 5000, 2500] */ + int16_t lc3plus_frame_duration_us; + /*! isar frame duration in microseconds [20000, 10000, 5000] */ + int16_t isar_frame_duration_us; + /*! sampling rate*/ + int32_t samplerate; + /*! number of channels */ + int16_t channels; +#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS || defined ISAR_BITSTREAM_UPDATE_LC3PLUS + /*! high resolution mode enabled (1) or disabled (0)*/ + int16_t high_res_mode_enabled; +#endif +} LC3PLUS_CONFIG; + +/*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ +ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( const LC3PLUS_Error lc3PlusError ); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ +ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ); +#endif + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* ISAR_LC3PLUS_COM_H */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c new file mode 100644 index 000000000..1c63158b3 --- /dev/null +++ b/lib_isar/isar_lc3plus_dec.c @@ -0,0 +1,857 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "prot.h" +#include "ivas_prot.h" +#include "isar_lc3plus_dec.h" +#include "isar_lc3plus_common.h" +#include "lc3.h" +#include "ivas_error_utils.h" +#include "wmc_auto.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * isar_LC3PLUS_AllocateSubframeDecodingMatrix() + * + * + *------------------------------------------------------------------------*/ + +static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( + int16_t **subframeChannelMatrix ) +{ + for ( int16_t i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + free( subframeChannelMatrix[i] ); + } + + free( subframeChannelMatrix ); + + return; +} +#endif + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Open() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_Open( + const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ + ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ +) +{ + LC3PLUS_Error err; + int32_t decoder_size; + Word32 scratch_size; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t i; + + if ( 0 == config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); + } +#else + int16_t lc3plusFrameIdx; + int16_t numLC3plusFramesPerIvasFrame; + int16_t i; +#endif + + if ( ( *handle = malloc( sizeof( struct ISAR_LC3PLUS_DEC_HANDLE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( config.channels > IVAS_LC3PLUS_MAX_NUM_DECODERS ) + { + return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds IVAS_LC3PLUS_MAX_NUM_DECODERS\n" ); + } +#else + + if ( 0 == config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); + } + numLC3plusFramesPerIvasFrame = (int16_t) ( config.isar_frame_duration_us / config.lc3plus_frame_duration_us ); +#endif + + + ( *handle )->num_decs = 0; + ( *handle )->pcm_conversion_buffer = NULL; + ( *handle )->handles = NULL; + ( *handle )->selective_decoding_states = NULL; + ( *handle )->bitstream_caches = NULL; + + if ( ( ( *handle )->handles = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_HANDLE ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + + if ( ( ( *handle )->selective_decoding_states = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE * ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->handles[i] = NULL; + ( *handle )->selective_decoding_states[i] = NULL; + } + + if ( ( ( *handle )->bitstream_caches = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_BITSTREAM_CACHE * ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->bitstream_caches[i] = NULL; + } + + ( *handle )->num_decs = config.channels; + for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) + { + ( *handle )->selective_decoding_states[iCh] = NULL; + if ( NULL != ( *handle )->bitstream_caches ) + { + ( *handle )->bitstream_caches[iCh] = NULL; + } + /* allocate and configure LC3plus decoder */ + decoder_size = lc3plus_dec_get_size( config.samplerate, 1, LC3PLUS_PLC_ADVANCED ); + if ( 0 == decoder_size ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_dec_get_size failed\n" ); + } + + if ( ( ( *handle )->handles[iCh] = malloc( decoder_size ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, config.high_res_mode_enabled ); +#else + err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, 0 ); +#endif + if ( LC3PLUS_OK != err ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec_init failed\n" ); + } + + err = lc3plus_dec_set_frame_dms( ( *handle )->handles[iCh], config.lc3plus_frame_duration_us / 100 ); + if ( LC3PLUS_OK != err ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec_set_frame_dms failed\n" ); + } + + /* allocate and configure per LC3plus decoder skip state */ + if ( ( ( *handle )->selective_decoding_states[iCh] = malloc( sizeof( ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( ( *handle )->selective_decoding_states[iCh]->frame_actions = malloc( numLC3plusFramesPerIvasFrame * sizeof( SelectiveDecAction ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } +#endif + + ( *handle )->selective_decoding_states[iCh]->has_skipped_a_frame = 0; + ( *handle )->selective_decoding_states[iCh]->shall_decode_cached_frame = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->selective_decoding_states[iCh]->frame_action = DEC_ACTION_DECODE_AND_USE; +#else + for ( lc3plusFrameIdx = 0; lc3plusFrameIdx < numLC3plusFramesPerIvasFrame; lc3plusFrameIdx++ ) + { + ( *handle )->selective_decoding_states[iCh]->frame_actions[lc3plusFrameIdx] = DEC_ACTION_DECODE_AND_USE; + } +#endif + + /* allocate and configure per LC3plus decoder bitstream cache */ + if ( ( ( *handle )->bitstream_caches[iCh] = malloc( sizeof( ISAR_LC3PLUS_DEC_BITSTREAM_CACHE ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/; +#else + ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; +#endif + if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + ( *handle )->bitstream_caches[iCh]->bitstream_cache_size = 0; + } + + ( *handle )->config = config; + if ( config.isar_frame_duration_us < config.lc3plus_frame_duration_us || config.isar_frame_duration_us % config.lc3plus_frame_duration_us != 0 ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Current pcm_conversion_buffer sizing requires that lc3plus uses a shorter or equal frame duration than ivas\n" ); + } + + if ( ( ( *handle )->pcm_conversion_buffer = malloc( sizeof( int16_t ) * config.samplerate * config.lc3plus_frame_duration_us / 1000000 ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder wrapper pcm_conversion_buffer\n" ); + } + + scratch_size = lc3plus_dec_get_scratch_size( ( *handle )->handles[0] ); + if ( ( ( *handle )->scratch = malloc( sizeof( uint8_t ) * scratch_size ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder wrapper scratch\n" ); + } + + return IVAS_ERR_OK; +} + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( + int16_t ***subframeChannelMatrix, + const uint32_t num_decs ) +{ + int16_t i; + + if ( ( *subframeChannelMatrix = malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t * ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "subframeChannelMatrix allocation failed\n" ); + } + + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + ( *subframeChannelMatrix )[i] = NULL; + } + + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + if ( ( ( *subframeChannelMatrix )[i] = malloc( num_decs * sizeof( int16_t ) ) ) == NULL ) + { + isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( *subframeChannelMatrix ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "subframeChannelMatrix allocation failed\n" ); + } + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ + int16_t *subframeChannelMatrix[MAX_PARAM_SPATIAL_SUBFRAMES] ) +{ + int16_t numIvasSubFramesPerLC3frame; + uint32_t decIdx; + int16_t ivasSubframeIdx; + int16_t effectiveIsarSubframeDuration; + int16_t actual_num_spatial_subframes; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); + } + + if ( NULL == subframeChannelMatrix ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "subframeChannelMatrix is NULL\n" ); + } + + if ( handle->config.lc3plus_frame_duration_us == 0 || handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "invalid isar_frame_duration_us/lc3plus_frame_duration_us values\n" ); + } + + effectiveIsarSubframeDuration = (int16_t) ( handle->config.isar_frame_duration_us == 20000 ? handle->config.isar_frame_duration_us / MAX_PARAM_SPATIAL_SUBFRAMES : handle->config.isar_frame_duration_us ); + numIvasSubFramesPerLC3frame = (int16_t) handle->config.lc3plus_frame_duration_us / effectiveIsarSubframeDuration; + actual_num_spatial_subframes = (int16_t) handle->config.isar_frame_duration_us / effectiveIsarSubframeDuration; + /* 0.5(0) = 10ms lc3plus, 5ms subframe */ + if ( numIvasSubFramesPerLC3frame != 1 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Selective decoding is only implemented for aligned IVAS-Subframes & LC3plus \n" ); + } + + /* map subframeChannelMatrix to lc3plus skip states */ + /* 1st pass: Flag the required frames */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + { + if ( 1 == subframeChannelMatrix[ivasSubframeIdx][decIdx] ) + { + /* subframe needed by the user, definitely decode */ + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_DECODE_AND_USE; + } + else + { + + /* subframe not needed by the user, but might be required to re-initialize a decoder after inactivity */ + if ( + ( ivasSubframeIdx != actual_num_spatial_subframes - 1 ) && 1 == subframeChannelMatrix[ivasSubframeIdx + 1][decIdx] ) + { + /* ... but if the following subframe is required, it needs to be decoded and dropped */ + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_DECODE_AND_DROP; + } + else + { + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_SKIP; + } + } + } + } + + /* if a decoder was paused before, it needs to either: + * - Decode the cached frame (if available) and the first required frame OR + * - Decode the previous LC3plus subframe, even if it isn't needed by the user */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + if ( handle->selective_decoding_states[decIdx]->has_skipped_a_frame ) + { + /* find the first frame required by the user */ + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + { + if ( DEC_ACTION_DECODE_AND_USE == handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] ) + { + /* The first required frame is the first subframe. To flush the decoder, the cached frame must be decoded and dropped */ + if ( 0 == ivasSubframeIdx ) + { + handle->selective_decoding_states[decIdx]->shall_decode_cached_frame = 1; + break; + } + /* The first required frame is not the first frame, so the cache is useless. Instead we decode & drop the previous frame*/ + else + { + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx - 1] = DEC_ACTION_DECODE_AND_DROP; + break; + } + } + } + } + } + + /* if a dec gets paused & caching is activated we need to flag the last useful LC3plus frame for caching */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + { + if ( handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] == DEC_ACTION_SKIP && handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] != DEC_ACTION_DECODE_AND_USE ) + { + handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] = DEC_ACTION_CACHE; + } + } + } + + return IVAS_ERR_OK; +} +#endif + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_GetDelay() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_GetDelay( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ + int32_t *delayInSamples /* o : decoder delay in number of samples per channel */ +) +{ + int32_t tmpDelayInSamples; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); + } + if ( NULL == delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "delayInSamples is NULL\n" ); + } + + *delayInSamples = 0; + /* sanity check whether all encoders are actually configured identically */ + for ( uint32_t iDec = 0; iDec < handle->num_decs; iDec++ ) + { + if ( NULL == handle->handles[iDec] ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus decoder handle is NULL\n" ); + } + + tmpDelayInSamples = lc3plus_dec_get_delay( handle->handles[iDec] ); + if ( 0 != *delayInSamples && tmpDelayInSamples != *delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Not all mono LC3plus decoders are configured identically\n" ); + } + + *delayInSamples = tmpDelayInSamples; + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Close() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_LC3PLUS_DEC_Close( + ISAR_LC3PLUS_DEC_HANDLE *handle /* i/o: Pointer to LC3plus decoder handle */ +) +{ + if ( NULL == handle || NULL == *handle ) + { + return; + } + for ( uint32_t iDec = 0; iDec < ( *handle )->num_decs; iDec++ ) + { + if ( NULL != ( *handle )->handles && NULL != ( *handle )->handles[iDec] ) + { + free( ( *handle )->handles[iDec] ); + } + + if ( NULL != ( *handle )->selective_decoding_states && NULL != ( *handle )->selective_decoding_states[iDec] ) + { +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + free( ( *handle )->selective_decoding_states[iDec]->frame_actions ); +#endif + free( ( *handle )->selective_decoding_states[iDec] ); + } + + if ( NULL != ( *handle )->bitstream_caches && NULL != ( *handle )->bitstream_caches[iDec] ) + { + free( ( *handle )->bitstream_caches[iDec]->bitstream_cache ); + free( ( *handle )->bitstream_caches[iDec] ); + } + } + + if ( NULL != ( *handle )->pcm_conversion_buffer ) + { + free( ( *handle )->pcm_conversion_buffer ); + } + if ( NULL != ( *handle )->scratch ) + { + free( ( *handle )->scratch ); + } + + free( ( *handle )->handles ); + + if ( NULL != ( *handle )->bitstream_caches ) + { + free( ( *handle )->bitstream_caches ); + } + free( ( *handle )->selective_decoding_states ); + + free( *handle ); + *handle = NULL; + + return; +} + + +/*------------------------------------------------------------------------- + * decode_or_conceal_one_lc3plus_frame() + * + * + *------------------------------------------------------------------------*/ + +static ivas_error decode_or_conceal_one_lc3plus_frame( + LC3PLUS_Dec *dec, + uint8_t *bitstream_in, + const int32_t bitstream_in_length, + int16_t **pcm_out_buffer, + const int32_t badFrameIndicator, + uint8_t *scratch ) +{ + LC3PLUS_Error err; + + push_wmops( "lc3plus_dec16" ); + err = lc3plus_dec16( dec, bitstream_in, bitstream_in_length, pcm_out_buffer, scratch, badFrameIndicator ); + pop_wmops(); + + if ( err == LC3PLUS_DECODE_ERROR && 1 == badFrameIndicator ) + { + /* LC3PLUS_DECODE_ERROR && badFrameIndicator means that the decoder has successfully concealed, which is actually OK. */ + err = LC3PLUS_OK; + } + + if ( err != LC3PLUS_OK ) + { + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec16 failed\n" ); + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * isar_LC3PLUS_DEC_Decode_or_Conceal_internal() + * + * + *------------------------------------------------------------------------*/ + +static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder configuration */ + uint8_t *bitstream_in, /* i : pointer to input bitstream */ + int32_t bitstream_in_size, /* i : size of bitstream_in */ + const int16_t badFrameIndicator, /* i : bad frame indicator. If set to 1, triggers concealment */ + Word32 **pcm_out /* o : decoded samples */ +) +{ + uint32_t iDec; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t config_num_media_times; + int32_t iMediaTime; + int32_t iFtd; + LC3PLUS_RTP_PAYLOAD payload; +#else + int32_t iLc3plusFrame; + int32_t lc3framesPerIvasFrame; + int32_t bitstreamOffsetPerCoder; + uint8_t *bitstream_in_iter = bitstream_in; +#endif + int32_t ivasSampleIndex; + int16_t numSamplesPerLC3plusChannel; + ivas_error err; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Dec_Wrap_Handle is NULL\n" ); + } + if ( NULL == bitstream_in ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bitstream_in is NULL\n" ); + } + if ( NULL == pcm_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_out is NULL\n" ); + } + if ( badFrameIndicator != 0 && badFrameIndicator != 1 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "badFrameIndicator must be 1 or 0\n" ); + } + if ( badFrameIndicator == 0 && bitstream_in_size <= 0 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "bitstream_in_size must be positive\n" ); + } + + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config_num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + if ( !badFrameIndicator ) + { + if ( LC3PLUS_RTP_payload_deserialize( &payload, bitstream_in, bitstream_in_size ) != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_payload_deserialize failed\n" ); + } + if ( payload.sampling_rate_hz != handle->config.samplerate ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (samplerate) in bitstream is not supported\n" ); + } + if ( payload.num_channels != handle->config.channels ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (number of channels) in bitstream is not supported\n" ); + } + if ( payload.frame_duration_us != handle->config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (frame duration) in bitstream is not supported\n" ); + } + if ( payload.high_resolution_enabled != handle->config.high_res_mode_enabled ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (high resolution mode) in bitstream is not supported\n" ); + } + if ( payload.num_media_times != config_num_media_times ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (number of media times per frame data block) in bitstream is not supported\n" ); + } + } +#endif + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + numSamplesPerLC3plusChannel = (int16_t) ( handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / config_num_media_times ); + for ( iDec = 0; iDec < handle->num_decs; iDec++ ) + { + for ( iMediaTime = 0; iMediaTime < config_num_media_times; iMediaTime++ ) + { + iFtd = iDec + iMediaTime * handle->num_decs; +#else + lc3framesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + + numSamplesPerLC3plusChannel = (int16_t) ( handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / lc3framesPerIvasFrame ); + bitstreamOffsetPerCoder = bitstream_in_size / handle->num_decs / lc3framesPerIvasFrame; + for ( iDec = 0; iDec < handle->num_decs; iDec++ ) + { + for ( iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) + { +#endif + if ( handle->selective_decoding_states[iDec]->shall_decode_cached_frame ) + { + if ( 0 == handle->bitstream_caches[iDec]->bitstream_cache_size ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "LC3plus cache is empty\n" ); + } + + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], handle->bitstream_caches[iDec]->bitstream_cache, handle->bitstream_caches[iDec]->bitstream_cache_size, &handle->pcm_conversion_buffer, badFrameIndicator, handle->scratch ); + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + handle->selective_decoding_states[iDec]->shall_decode_cached_frame = 0; + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + } + + /* reset cache if caching is enabled - it has either been decoded or is not needed */ + if ( NULL != handle->bitstream_caches ) + { + handle->bitstream_caches[iDec]->bitstream_cache_size = 0; + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + switch ( handle->selective_decoding_states[iDec]->frame_action ) +#else + switch ( handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] ) +#endif + { +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + case DEC_ACTION_DECODE_AND_DROP: + { + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in_iter, bitstreamOffsetPerCoder, &handle->pcm_conversion_buffer, badFrameIndicator, handle->scratch ); + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + break; + } +#endif + case DEC_ACTION_DECODE_AND_USE: + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( badFrameIndicator ) + { + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in, bitstream_in_size, &handle->pcm_conversion_buffer, badFrameIndicator, handle->scratch ); + } + else if ( payload.ftds[iFtd].frame_data_length == LC3PLUS_RTP_FDL_SPEECH_BAD ) + { + return IVAS_ERR_NOT_IMPLEMENTED; + /* Untested therefore disabled. Would probably only need to call concealment, + * but the LC3plus API requires a non-NULL ptr for this which is not available here */ + } + else + { + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], payload.ftds[iFtd].frame_data, payload.ftds[iFtd].frame_data_length, &handle->pcm_conversion_buffer, badFrameIndicator, handle->scratch ); + } + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + + for ( int16_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) + { + ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; + pcm_out[iDec][ivasSampleIndex] = handle->pcm_conversion_buffer[iSampleInt16]; + } + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + break; +#else + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in_iter, bitstreamOffsetPerCoder, &handle->pcm_conversion_buffer, badFrameIndicator ); + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + + for ( int32_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) + { + ivasSampleIndex = iSampleInt16 + iLc3plusFrame * numSamplesPerLC3plusChannel; + pcm_out[iDec][ivasSampleIndex] = handle->pcm_conversion_buffer[iSampleInt16]; + } + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + break; +#endif + } +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + case DEC_ACTION_SKIP: + { + /* log that this instance has skipped a frame and must decode twice once reactivated */ + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; + break; + } +#endif + case DEC_ACTION_CACHE: + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( handle->bitstream_caches[iDec]->bitstream_cache_capacity < (int32_t) payload.ftds[iFtd].frame_data_length ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); + } + /* store bit rate of cached frame */ + mvc2c( payload.ftds[iFtd].frame_data, handle->bitstream_caches[iDec]->bitstream_cache, (int16_t) payload.ftds[iFtd].frame_data_length ); + handle->bitstream_caches[iDec]->bitstream_cache_size = payload.ftds[iFtd].frame_data_length; + /* log that this instance has skipped a frame and must decode twice once reactivated */ + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; + break; +#else + if ( handle->bitstream_caches[iDec]->bitstream_cache_capacity < bitstreamOffsetPerCoder ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); + } + /* store bit rate of cached frame */ + mvc2c( bitstream_in_iter, handle->bitstream_caches[iDec]->bitstream_cache, (int16_t) bitstreamOffsetPerCoder ); + handle->bitstream_caches[iDec]->bitstream_cache_size = bitstreamOffsetPerCoder; + /* log that this instance has skipped a frame and must decode twice once reactivated */ + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; + break; +#endif + } + case DEC_ACTION_NUM_ENUMS: + default: + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid LC3plus decoder state\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + } /* for each media time */ + /* reset skipping state, must be set by the user before each decode call*/ + handle->selective_decoding_states[iDec]->frame_action = DEC_ACTION_DECODE_AND_USE; + } /* for each dec/channel */ +#else + + bitstream_in_iter += bitstreamOffsetPerCoder; + } + + /* reset skipping state, must be set by the user before each decode call*/ + for ( iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) + { + handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] = DEC_ACTION_DECODE_AND_USE; + } + } + +#endif + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Decode() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_Decode( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder configuration */ + uint8_t *bitstream_in, /* i : pointer to input bitstream */ + const int32_t bitstream_in_size, /* i : size of bitstream_in */ + Word32 **pcm_out /* o : decoded samples */ +) +{ + int16_t badFrameIndicator; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Dec_Wrap_Handle is NULL\n" ); + } + if ( NULL == bitstream_in ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bitstream_in is NULL\n" ); + } + if ( NULL == pcm_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_out is NULL\n" ); + } + badFrameIndicator = 0; + + return isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle, bitstream_in, bitstream_in_size, badFrameIndicator, pcm_out ); +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Conceal() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_Conceal( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ + Word32 **pcm_out /* o : decoded samples */ +) +{ + uint8_t bitstream_in[LC3PLUS_MAX_BYTES]; + int16_t badFrameIndicator; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Dec_Wrap_Handle is NULL\n" ); + } + + if ( NULL == pcm_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_out is NULL\n" ); + } + + /* LC3plus API requires a non-NULL bitstream pointer, even when triggering concealment */ + badFrameIndicator = 1; + + return isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle, bitstream_in, 0, badFrameIndicator, pcm_out ); +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h new file mode 100644 index 000000000..309ec4e06 --- /dev/null +++ b/lib_isar/isar_lc3plus_dec.h @@ -0,0 +1,136 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_DEC_H +#define ISAR_LC3PLUS_DEC_H + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lc3.h" +#include "ivas_error.h" +#include "ivas_cnst.h" +#include "isar_lc3plus_common.h" + + +typedef enum +{ +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + DEC_ACTION_DECODE_AND_DROP = 0, +#endif + DEC_ACTION_DECODE_AND_USE, +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + DEC_ACTION_SKIP, +#endif + DEC_ACTION_CACHE, + DEC_ACTION_NUM_ENUMS +} SelectiveDecAction; + + +typedef struct ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE +{ + /*! indicates that the decoder has skipped one or more frames. This means it must decode two frames to flush algorithmic delay when re-activated */ + int16_t has_skipped_a_frame; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /*! action to execute for the next frame */ + SelectiveDecAction frame_action; +#else + /*! if set to 1, decoder will skip decoding for the next frame */ + SelectiveDecAction *frame_actions; +#endif + /*! if set to 1, decoder will decode the cache before decoding any of current frames */ + int16_t shall_decode_cached_frame; +} ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE; + +typedef struct ISAR_LC3PLUS_DEC_BITSTREAM_CACHE +{ + uint8_t *bitstream_cache; + int32_t bitstream_cache_capacity; + int32_t bitstream_cache_size; +} ISAR_LC3PLUS_DEC_BITSTREAM_CACHE; + +/* decoder wrapper */ +typedef struct ISAR_LC3PLUS_DEC_HANDLE +{ + LC3PLUS_Dec **handles; + ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE **selective_decoding_states; + ISAR_LC3PLUS_DEC_BITSTREAM_CACHE **bitstream_caches; + uint32_t num_decs; + int16_t *pcm_conversion_buffer; + uint8_t *scratch; + LC3PLUS_CONFIG config; +} * ISAR_LC3PLUS_DEC_HANDLE; + +ivas_error ISAR_LC3PLUS_DEC_Open( + const LC3PLUS_CONFIG config, /* i : decoder configuration */ + ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ +); + +ivas_error ISAR_LC3PLUS_DEC_GetDelay( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + int32_t *delayInSamples /* o : algorithmic delay of encoding and decoding in number of samples per channel */ +); + +void ISAR_LC3PLUS_DEC_Close( + ISAR_LC3PLUS_DEC_HANDLE *handle /* i/o: pointer to decoder handle */ +); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! Sets a matrix[MAX_PARAM_SPATIAL_SUBFRAMES][numLC3plusDecoders] where all require subframes must be flagged with 1, frames that are not required with 0 */ +ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + int16_t *subframeChannelMatrix[MAX_PARAM_SPATIAL_SUBFRAMES] /* i : */ +); +#endif + +ivas_error ISAR_LC3PLUS_DEC_Decode( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + uint8_t *bitstream_in, /* i : pointer to input bitstream */ + const int32_t bitstream_in_size, /* i : size of bitstream_in */ + Word32 **pcm_out /* o : decoded samples */ +); + +ivas_error ISAR_LC3PLUS_DEC_Conceal( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + Word32 **pcm_out /* o : decoded samples */ +); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( + int16_t ***subframeChannelMatrix, + const uint32_t num_decs ); + +void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( int16_t **subframeChannelMatrix ); +#endif + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* ISAR_LC3PLUS_DEC_H */ diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c new file mode 100644 index 000000000..f6bb0284d --- /dev/null +++ b/lib_isar/isar_lc3plus_enc.c @@ -0,0 +1,697 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "isar_lc3plus_enc.h" +#include "isar_lc3plus_common.h" +#include "lc3.h" +#include "ivas_error_utils.h" +#include "prot.h" +#include "wmc_auto.h" +#include "options.h" + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +static const LC3PLUS_RTP_FDL s_fdl_request = LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA; +#endif + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, + int32_t per_channel_bitrate ) +{ + if ( config.high_res_mode_enabled ) + { + switch ( config.lc3plus_frame_duration_us ) + { + case 10000: + return min( per_channel_bitrate, 500000 ); + case 5000: + return min( per_channel_bitrate, 600000 ); + case 2500: + return min( per_channel_bitrate, 672000 ); + default: + assert( false && "unreachable" ); + } + } + + switch ( config.samplerate ) + { + case 48000: + case 32000: + return min( per_channel_bitrate, 320000 ); + case 24000: + return min( per_channel_bitrate, 314400 ); + case 16000: + return min( per_channel_bitrate, 221600 ); + case 8000: + return min( per_channel_bitrate, 114400 ); + default: + assert( false && "unreachable" ); + } + + assert( false && "unreachable" ); + return -1; +} +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_Open() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_LC3PLUS_ENC_Open( + const LC3PLUS_CONFIG config, /* i : LC3plus encoder configuration */ + const UWord32 bitsPerSecond, /* i : bit rate */ + ISAR_LC3PLUS_ENC_HANDLE *handle /* o : encoder handle */ +) +{ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t num_lc3plus_media_times_per_ivas_frame; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t lc3plus_num_bytes_per_frame; +#endif + bool is_last_media_time, is_last_channel; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_error ivas_err; +#endif +#endif +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t bitsPerSecondPerChannel; +#endif + Word32 scratch_size; + int32_t encoder_size; + LC3PLUS_Error err; + int32_t lfeChans[1]; + int16_t i; + + lfeChans[0] = 0; + + if ( 0U == config.channels ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid number of channels\n" ); + } +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + bitsPerSecondPerChannel = bitsPerSecond / config.channels; +#endif +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( config.lc3plus_frame_duration_us != 2500 && config.lc3plus_frame_duration_us != 5000 && config.lc3plus_frame_duration_us != 10000 ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid lc3plus_frame_duration_us\n" ); + } + if ( config.isar_frame_duration_us != 20000 && config.isar_frame_duration_us != 10000 && config.isar_frame_duration_us != 5000 ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid isar_frame_duration_us\n" ); + } +#endif + encoder_size = lc3plus_enc_get_size( config.samplerate, 1 ); + if ( 0 == encoder_size ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_size failed\n" ); + } + + if ( ( *handle = malloc( sizeof( struct ISAR_LC3PLUS_ENC_HANDLE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->config = config; + ( *handle )->frame_type_descriptors = NULL; +#endif + + ( *handle )->pcm_conversion_buffer = NULL; + ( *handle )->num_encs = 0; + if ( ( ( *handle )->handles = malloc( config.channels * sizeof( ISAR_LC3PLUS_ENC_HANDLE ) ) ) == NULL ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->handles[i] = NULL; + } + ( *handle )->num_encs = config.channels; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + num_lc3plus_media_times_per_ivas_frame = config.isar_frame_duration_us / config.lc3plus_frame_duration_us; + ( *handle )->fdl_request = s_fdl_request; + ( *handle )->num_ftds = config.channels * num_lc3plus_media_times_per_ivas_frame; + ( *handle )->frame_type_descriptors = malloc( ( *handle )->num_ftds * sizeof( LC3PLUS_RTP_FTD ) ); + if ( NULL == ( *handle )->frame_type_descriptors ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus frame_type_descriptors\n" ); + } +#endif + + for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) + { + if ( ( ( *handle )->handles[iCh] = malloc( encoder_size ) ) == NULL ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_enc_init( ( *handle )->handles[iCh], config.samplerate, 1, config.high_res_mode_enabled, lfeChans ); +#else + err = lc3plus_enc_init( ( *handle )->handles[iCh], config.samplerate, 1, 0, lfeChans ); +#endif + if ( err != LC3PLUS_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_init failed\n" ); + } + + err = lc3plus_enc_set_frame_dms( ( *handle )->handles[iCh], config.lc3plus_frame_duration_us / 100 ); + if ( err != LC3PLUS_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_frame_dms failed\n" ); + } +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_enc_set_bitrate( ( *handle )->handles[iCh], bitsPerSecondPerChannel ); + if ( err != LC3PLUS_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_bitrate failed\n" ); + } +#endif + } + + if ( config.isar_frame_duration_us < config.lc3plus_frame_duration_us || config.isar_frame_duration_us % config.lc3plus_frame_duration_us != 0 ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Current pcm_conversion_buffer sizing requires that lc3plus uses a shorter or equal frame duration than ivas\n" ); + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->config = config; +#endif + ( *handle )->pcm_conversion_buffer = malloc( sizeof( int16_t ) * config.samplerate * config.lc3plus_frame_duration_us / 1000000 ); + if ( NULL == ( *handle )->pcm_conversion_buffer ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder wrapper pcm_conversion_buffer\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* update FDI fields */ + for ( int32_t iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) + { + for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; ++iEnc ) + { + int32_t ftd_index = iEnc + iMediaTime * ( *handle )->num_encs; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = 0; /* will be set to the correct value in IVAS_LC3PLUS_ENC_SetBitrate */ +#else + lc3plus_num_bytes_per_frame = lc3plus_enc_get_num_bytes( ( *handle )->handles[iEnc] ); + if ( lc3plus_num_bytes_per_frame <= 0 ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_num_bytes reported invalid result failed\n" ); + } + ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = lc3plus_num_bytes_per_frame; +#endif + if ( 0 != LC3PLUS_RTP_ftd_bwr_from_samplerate( &( *handle )->frame_type_descriptors[ftd_index].bwr, config.samplerate, config.high_res_mode_enabled ) ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_ftd_bwr_from_samplerate failed\n" ); + } + if ( 0 != LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( &( *handle )->frame_type_descriptors[ftd_index].fdi, config.lc3plus_frame_duration_us ) ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_ftd_fdi_from_frame_duration_us failed\n" ); + } + ( *handle )->frame_type_descriptors[ftd_index].h = LC3PLUS_RTP_FTD_H_PRIMARY; + ( *handle )->frame_type_descriptors[ftd_index].frame_data = NULL; + + /* The FTDs in the ToC are included in the following order: + * 1) First the FTD for the first channel of the first FDB (oldest frame) + * 2) Then the FTDs for the remaining channels for the first FDB in increasing CC order + * 3) Then the FTD for the first channel of the second FDB + * 4) Then the FTDs for the remaining channels for the second FDB + * 5) Etc. to the last FDB */ + is_last_media_time = num_lc3plus_media_times_per_ivas_frame - 1 == iMediaTime; + is_last_channel = ( *handle )->num_encs - 1 == iEnc; + if ( is_last_media_time && is_last_channel ) + { + ( *handle )->frame_type_descriptors[ftd_index].fc = LC3PLUS_RTP_FTD_FC_LAST_OVERALL; + } + else if ( !is_last_media_time && is_last_channel ) + { + ( *handle )->frame_type_descriptors[ftd_index].fc = LC3PLUS_RTP_FTD_FC_LAST_IN_MEDIATIME; + } + else + { + ( *handle )->frame_type_descriptors[ftd_index].fc = LC3PLUS_RTP_FTD_FC_SUBSEQUENT_CHANNEL; + } + } + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_err = IVAS_LC3PLUS_ENC_SetBitrate( *handle, bitsPerSecond ); + if ( ivas_err != IVAS_ERR_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return ivas_err; + } +#endif +#endif + scratch_size = lc3plus_enc_get_scratch_size( ( *handle )->handles[0] ); + ( *handle )->scratch = malloc( sizeof( uint8_t ) * scratch_size ); + IF( NULL == ( *handle )->scratch ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder wrapper scratch\n" ); + } + + return IVAS_ERR_OK; +} + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*-------------------------------------------------------------------* + * Function IVAS_LC3PLUS_ENC_SetBitrate() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_LC3PLUS_ENC_SetBitrate( + ISAR_LC3PLUS_ENC_HANDLE handle, /* o : LC3plus encoder handle */ + const uint32_t bitsPerSecond /* i : new target bit rate */ +) +{ + int32_t numLc3plusMediaTimesPerIvasFrame; + int32_t lc3plus_num_bytes_per_frame; + int32_t availableOctetsPerIsarFrame; + int32_t actualOctetsPerFrame; + LC3PLUS_Error err; + int32_t iFtd; + int32_t fdrLength; + int32_t lc3plusPacketRate; + int32_t numSubframes; + int32_t minPayloadOverhead; + int32_t targetLc3PlusBitratePerChannel; + int32_t targetLc3PlusOctetCount; + int32_t lc3plusFdlLength; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + + availableOctetsPerIsarFrame = bitsPerSecond / ( 1000000 / handle->config.isar_frame_duration_us ) / 8; + lc3plusPacketRate = 1000 * 1000 / handle->config.lc3plus_frame_duration_us; + numLc3plusMediaTimesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + numSubframes = numLc3plusMediaTimesPerIvasFrame * handle->config.channels; + + /* subtract minimum required payload bytes & calculate a first per-channel target bit rate */ + if ( LC3PLUS_RTP_frame_data_length_get_size( &fdrLength, s_fdl_request ) != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_frame_data_length_get_size failed\n" ); + } + minPayloadOverhead = fdrLength + ( numSubframes * LC3PLUS_RTP_FTD_MIN_SIZE ); + targetLc3PlusBitratePerChannel = ( availableOctetsPerIsarFrame - minPayloadOverhead ) / handle->config.channels * 8 * lc3plusPacketRate / numLc3plusMediaTimesPerIvasFrame; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( targetLc3PlusBitratePerChannel <= 0 ) + { + return IVAS_ERROR( IVAS_ERR_LC3PLUS_INVALID_BITRATE, "available LC3plus bitrate <= 0\n" ); + } +#endif + targetLc3PlusBitratePerChannel = limit_per_channel_bitrate( handle->config, targetLc3PlusBitratePerChannel ); + targetLc3PlusOctetCount = targetLc3PlusBitratePerChannel / 8 / lc3plusPacketRate; + /* check resulting octet count. If it requires larger than 1-byte length fields, decrease the bitrate by enough to make room for the additional length field */ + if ( LC3PLUS_RTP_frame_data_length_get_size( &lc3plusFdlLength, targetLc3PlusOctetCount ) != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_frame_data_length_get_size failed\n" ); + } + if ( lc3plusFdlLength != LC3PLUS_RTP_FDL_MIN_LENGTH ) + { + /* reduce bitrate to allow for the required fdl field */ + targetLc3PlusBitratePerChannel = ( targetLc3PlusOctetCount - ( lc3plusFdlLength - LC3PLUS_RTP_FDL_MIN_LENGTH ) ) / handle->config.channels * 8 * lc3plusPacketRate; + } + + for ( int32_t iCh = 0; iCh < handle->config.channels; iCh++ ) + { + err = lc3plus_enc_set_bitrate( handle->handles[iCh], targetLc3PlusBitratePerChannel ); + if ( err != LC3PLUS_OK ) + { + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_bitrate failed\n" ); + } + } + + // update FTD settings after bitrate change + for ( int32_t iMediaTime = 0; iMediaTime < numLc3plusMediaTimesPerIvasFrame; ++iMediaTime ) + { + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; ++iEnc ) + { + iFtd = iEnc + iMediaTime * handle->num_encs; + lc3plus_num_bytes_per_frame = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + if ( lc3plus_num_bytes_per_frame <= 0 ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_num_bytes reported invalid result failed\n" ); + } + handle->frame_type_descriptors[iFtd].frame_data_length = lc3plus_num_bytes_per_frame; + } + } + + // TODO: remove sanity checks? + if ( ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( handle, &actualOctetsPerFrame ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "ISAR_LC3PLUS_ENC_GetOutputBitstreamSize failed\n" ); + } + if ( actualOctetsPerFrame > availableOctetsPerIsarFrame ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Bitrate reduction logic failed\n" ); + } + return IVAS_ERR_OK; +} +#endif + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_GetDelay() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_ENC_GetDelay( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *delayInSamples /* o : encoder delay in number of samples per channel */ +) +{ + int32_t tmpDelayInSamples; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + if ( NULL == delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "delayInSamples is NULL\n" ); + } + + *delayInSamples = 0; + /* sanity check whether all encoders are actually configured identically */ + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) + { + if ( NULL == handle->handles[iEnc] ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); + } + + tmpDelayInSamples = lc3plus_enc_get_delay( handle->handles[iEnc] ); + if ( 0 != *delayInSamples && tmpDelayInSamples != *delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Not all mono LC3plus encoders are configured identically\n" ); + } + *delayInSamples = tmpDelayInSamples; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_GetOutputBitstreamSize() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + Word32 *bsSize /* o : size of each bitstream frame in bytes */ +) +{ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + LC3PLUS_RTP_ERR rtp_err; + int32_t num_lc3plus_media_times_per_ivas_frame; + int32_t iMediaTime; + int32_t ftd_frame_data_length_size, lc3plus_frame_data_length; + int32_t ftd_index; +#else + int32_t bitstreamSizeMultiplier; +#endif + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + if ( NULL == bsSize ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bsSize is NULL\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( 0 == handle->config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "lc3plus_frame_duration_us is 0\n" ); + } + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } + + num_lc3plus_media_times_per_ivas_frame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; +#endif + *bsSize = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t fdl_request_length; + rtp_err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, handle->fdl_request ); + if ( rtp_err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid LC3plus frame_data_length request\n" ); + } + *bsSize += fdl_request_length; +#endif + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) + { + if ( NULL == handle->handles[iEnc] ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + lc3plus_frame_data_length = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + for ( iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) + { + ftd_index = iEnc + iMediaTime * handle->num_encs; + if ( lc3plus_frame_data_length != (int32_t) handle->frame_type_descriptors[ftd_index].frame_data_length ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "LC3plus FTD data not synchronised with encoder bitrate\n" ); + } + rtp_err = LC3PLUS_RTP_frame_data_length_get_size( &ftd_frame_data_length_size, handle->frame_type_descriptors[ftd_index].frame_data_length ); + if ( rtp_err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid LC3plus frame_data_length\n" ); + } + *bsSize += LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL; + *bsSize += handle->frame_type_descriptors[ftd_index].frame_data_length; + *bsSize += ftd_frame_data_length_size; + } + } +#else + *bsSize += lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + } + + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } + bitstreamSizeMultiplier = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + + *bsSize *= bitstreamSizeMultiplier; +#endif + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_Close() + * + * + *-------------------------------------------------------------------*/ + +void ISAR_LC3PLUS_ENC_Close( + ISAR_LC3PLUS_ENC_HANDLE *handle /* i/o: pointer to LC3plus encoder handle */ +) +{ + if ( NULL == handle || NULL == *handle ) + { + return; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( NULL != ( *handle )->frame_type_descriptors ) + { + free( ( *handle )->frame_type_descriptors ); + } +#endif + for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; iEnc++ ) + { + if ( NULL != ( *handle )->handles[iEnc] ) + { + free( ( *handle )->handles[iEnc] ); + } + } + if ( NULL != ( *handle )->pcm_conversion_buffer ) + { + free( ( *handle )->pcm_conversion_buffer ); + } + + if ( NULL != ( *handle )->scratch ) + { + free( ( *handle )->scratch ); + } + + free( ( *handle )->handles ); + free( *handle ); + + *handle = NULL; + + return; +} + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_Encode() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_LC3PLUS_ENC_Encode( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + Word32 **pcm_in, /* i : pointer input samples */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + void *bitstream_out, /* o : pointer to bitstream frame */ + const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ +#else + void *bitstream_out /* o : pointer to bitstream frame */ +#endif + Word16 q_in[16] ) +{ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t ftdIndex; + LC3PLUS_RTP_ERR rtpErr; + uint32_t num_media_times; +#else + uint32_t lc3framesPerIvasFrame; + uint8_t *bitstream_out_iter = bitstream_out; +#endif + uint32_t numSamplesPerLC3plusChannel; + int32_t ivasSampleIndex; + int32_t num_bytes = 0; + LC3PLUS_Error err; + + push_wmops( "ISAR_LC3PLUS_ENC_Encode" ); + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + if ( NULL == pcm_in ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_in is NULL\n" ); + } + if ( NULL == bitstream_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bitstream_out is NULL\n" ); + } + + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / num_media_times; + + size_t actual_size; + rtpErr = LC3PLUS_RTP_payload_serialize( bitstream_out, bitstream_out_size, &actual_size, s_fdl_request, handle->frame_type_descriptors, handle->num_ftds ); + if ( rtpErr != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( rtpErr ), "LC3PLUS_RTP_payload_serialize failed\n" ); + } +#else + lc3framesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + + numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / lc3framesPerIvasFrame; +#endif + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + for ( uint32_t iMediaTime = 0; iMediaTime < num_media_times; iMediaTime++ ) +#else + for ( uint32_t iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) +#endif + { + for ( uint32_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; +#else + ivasSampleIndex = iSampleInt16 + iLc3plusFrame * numSamplesPerLC3plusChannel; +#endif + handle->pcm_conversion_buffer[iSampleInt16] = (Word16) max( INT16_MIN, min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ftdIndex = iMediaTime * handle->num_encs + iEnc; +#endif + num_bytes = 0; + push_wmops( "lc3plus_enc16" ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, handle->frame_type_descriptors[ftdIndex].frame_data, &num_bytes, handle->scratch ); +#else + err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, bitstream_out_iter, &num_bytes, NULL ); +#endif + pop_wmops(); + if ( err != LC3PLUS_OK ) + { + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc16 failed\n" ); + } + if ( 0 == num_bytes ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc16 did not produce output\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( num_bytes != (int32_t) handle->frame_type_descriptors[ftdIndex].frame_data_length ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "payload format and lc3plus enc bitrate are not aligned\n" ); + } +#else + + bitstream_out_iter += num_bytes; +#endif + } + } + + pop_wmops(); + + return IVAS_ERR_OK; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h new file mode 100644 index 000000000..a2bc10bfc --- /dev/null +++ b/lib_isar/isar_lc3plus_enc.h @@ -0,0 +1,104 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_ENC_H +#define ISAR_LC3PLUS_ENC_H + +#include +#include "ivas_error.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lc3.h" +#include "isar_lc3plus_common.h" +#include "typedef.h" +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#include "isar_lc3plus_payload.h" +#endif + +/* encoder wrapper */ +typedef struct ISAR_LC3PLUS_ENC_HANDLE +{ + LC3PLUS_CONFIG config; + LC3PLUS_Enc **handles; + uint32_t num_encs; + int16_t *pcm_conversion_buffer; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + LC3PLUS_RTP_FTD *frame_type_descriptors; + int32_t num_ftds; + LC3PLUS_RTP_FDL fdl_request; +#endif + uint8_t *scratch; +} * ISAR_LC3PLUS_ENC_HANDLE; + +ivas_error ISAR_LC3PLUS_ENC_Open( + const LC3PLUS_CONFIG config, /* i : encoder configuration */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const uint32_t initialBitsPerSecond, /* i : initial target bit rate */ +#else + const uint32_t bitsPerSecond, /* i : bit rate */ +#endif + ISAR_LC3PLUS_ENC_HANDLE *handle /* o : LC3plus encoder handle */ +); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error IVAS_LC3PLUS_ENC_SetBitrate( + ISAR_LC3PLUS_ENC_HANDLE handle, /* o : LC3plus encoder handle */ + const uint32_t bitsPerSecond /* i : new target bit rate */ +); +#endif + +ivas_error ISAR_LC3PLUS_ENC_GetDelay( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *delayInSamples /* o : algorithmic delay of encoding and decoding in number of samples per channel */ +); + +ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *bsSize /* o : size of next bitstream frame in bytes */ +); + +void ISAR_LC3PLUS_ENC_Close( + ISAR_LC3PLUS_ENC_HANDLE *handle /* i/o: pointer to LC3plus encoder handle */ +); + +ivas_error ISAR_LC3PLUS_ENC_Encode( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + Word32 **pcm_in, /* i : pointer input samples */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + void *bitstream_out, /* o : pointer to bitstream frame */ + const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ +#else + void *bitstream_out /* o : pointer to bitstream frame */ +#endif + Word16 q_in[16] ); +#endif + +#endif /* ISAR_LC3PLUS_ENC_H */ diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c new file mode 100644 index 000000000..fa47189ca --- /dev/null +++ b/lib_isar/isar_lc3plus_payload.c @@ -0,0 +1,823 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include +#include "isar_lc3plus_payload.h" +#include "options.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, const LC3PLUS_RTP_FTD_FDI fdi ) +{ + if ( NULL == frame_duration_us ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( fdi ) + { + case LC3PLUS_RTP_FTD_FDI_2500_US: + *frame_duration_us = 2500; + break; + case LC3PLUS_RTP_FTD_FDI_5000_US: + *frame_duration_us = 5000; + break; + case LC3PLUS_RTP_FTD_FDI_10000_US: + *frame_duration_us = 10000; + break; + case LC3PLUS_RTP_FTD_FDI_RESERVED: + default: + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( int32_t *sample_rate_hz, const LC3PLUS_RTP_FTD_BWR bwr ) +{ + if ( NULL == sample_rate_hz ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( bwr ) + { + case LC3PLUS_RTP_FTD_BWR_NB: + *sample_rate_hz = 8000; + break; + case LC3PLUS_RTP_FTD_BWR_WB: + *sample_rate_hz = 16000; + break; + case LC3PLUS_RTP_FTD_BWR_SSWB: + *sample_rate_hz = 24000; + break; + case LC3PLUS_RTP_FTD_BWR_SWB: + *sample_rate_hz = 32000; + break; + case LC3PLUS_RTP_FTD_BWR_FBCD: + *sample_rate_hz = 44100; + break; + case LC3PLUS_RTP_FTD_BWR_FB: + *sample_rate_hz = 48000; + break; + case LC3PLUS_RTP_FTD_BWR_FBHR: + *sample_rate_hz = 48000; + break; + case LC3PLUS_RTP_FTD_BWR_UBHR: + *sample_rate_hz = 96000; + break; + default: + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( int16_t *high_resolution_flag, const LC3PLUS_RTP_FTD_BWR bwr ) +{ + if ( NULL == high_resolution_flag ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( bwr ) + { + case LC3PLUS_RTP_FTD_BWR_NB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_WB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_SSWB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_SWB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_FBCD: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_FB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_FBHR: + *high_resolution_flag = 1; + break; + case LC3PLUS_RTP_FTD_BWR_UBHR: + *high_resolution_flag = 1; + break; + default: + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const LC3PLUS_RTP_FDL frameDataLengthValue ) +{ + if ( frameDataLengthValue == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_BAD || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_SID ) + { + *length = 1; + } + else if ( frameDataLengthValue >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && frameDataLengthValue <= LC3PLUS_RTP_FDL_LENGTH_1_MAX ) + { + *length = 1; + } + else if ( frameDataLengthValue >= LC3PLUS_RTP_FDL_LENGTH_2_MIN && frameDataLengthValue <= LC3PLUS_RTP_FDL_LENGTH_2_MAX ) + { + *length = 2; + } + else if ( frameDataLengthValue >= LC3PLUS_RTP_FDL_LENGTH_3_MIN && frameDataLengthValue <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) + { + *length = 3; + } + else + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_frame_data_length_pack( const LC3PLUS_RTP_FDL frameDataLengthValue, uint8_t *dst ) +{ + int32_t frame_data_length_size; + LC3PLUS_RTP_ERR err; + + if ( NULL == dst ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + err = LC3PLUS_RTP_frame_data_length_get_size( &frame_data_length_size, frameDataLengthValue ); + if ( err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return err; + } + if ( 1 == frame_data_length_size ) + { + *dst++ = frameDataLengthValue >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( 2 == frame_data_length_size ) + { + const int32_t frameDataLengthValueToWrite = frameDataLengthValue - LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst = frameDataLengthValueToWrite >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( 3 == frame_data_length_size ) + { + const int32_t frameDataLengthValueToWrite = frameDataLengthValue - ( 2 * LC3PLUS_RTP_FDL_EXTENSION_VALUE ); + *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst = frameDataLengthValueToWrite >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static int32_t s_get_size_from_fdl( const LC3PLUS_RTP_FDL fdl ) +{ + if ( fdl >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) + { + return fdl; + } + return 0; +} + +static bool s_fdl_is_magic_value( const LC3PLUS_RTP_FDL fdl ) +{ + if ( fdl == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || fdl == LC3PLUS_RTP_FDL_SPEECH_SID || fdl == LC3PLUS_RTP_FDL_SPEECH_BAD ) + { + return true; + } + return false; +} + +static bool s_fdl_value_is_valid_request( const LC3PLUS_RTP_FDL fdl_request ) +{ + /* LC3PLUS_RTP_FDL_SPEECH_SID && LC3PLUS_RTP_FDL_SPEECH_SID are not valid values for the FDL request */ + if ( fdl_request == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || ( fdl_request >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl_request <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) ) + { + return true; + } + return false; +} + +static LC3PLUS_RTP_ERR s_frame_data_length_parse( LC3PLUS_RTP_FDL *frame_data_length_value, const uint8_t *src, const size_t remaining_capacity ) +{ + int32_t frame_data_length_size; + LC3PLUS_RTP_ERR err; + if ( NULL == src || NULL == frame_data_length_value || remaining_capacity < 1 ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + if ( remaining_capacity > 2 && LC3PLUS_RTP_FDL_EXTENSION_VALUE == *src && LC3PLUS_RTP_FDL_EXTENSION_VALUE == *( src + 1 ) ) + { + *frame_data_length_value = *( src + 2 ) + 2 * LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( remaining_capacity > 1 && LC3PLUS_RTP_FDL_EXTENSION_VALUE == *src ) + { + *frame_data_length_value = *( src + 1 ) + 1 * LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( remaining_capacity > 0 ) + { + *frame_data_length_value = *src << 0; + } + else + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + + /* sanity check */ + err = LC3PLUS_RTP_frame_data_length_get_size( &frame_data_length_size, *frame_data_length_value ); + if ( err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return err; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_parse_ftd( const uint8_t *p_read, LC3PLUS_RTP_FTD *receiver_ftd, int32_t *num_bytes_read, const size_t remaining_capacity ) +{ + int32_t frame_data_block_size; + LC3PLUS_RTP_FDL fdl; + LC3PLUS_RTP_ERR err; + if ( NULL == p_read || NULL == receiver_ftd || NULL == num_bytes_read || remaining_capacity < LC3PLUS_RTP_FTD_MIN_SIZE ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + *num_bytes_read = 0; + receiver_ftd->fc = 0; + receiver_ftd->fdi = 0; + receiver_ftd->bwr = 0; + receiver_ftd->h = 0; + receiver_ftd->fc |= *p_read & LC3PLUS_RTP_FTD_FC_MASK; + receiver_ftd->fdi |= ( *p_read & LC3PLUS_RTP_FTD_FDI_MASK ); + receiver_ftd->bwr |= ( *p_read & LC3PLUS_RTP_FTD_BWR_MASK ); + receiver_ftd->h |= ( *p_read & LC3PLUS_RTP_FTD_H_MASK ); + p_read++; + *num_bytes_read = 1; + + err = s_frame_data_length_parse( &fdl, p_read, remaining_capacity - *num_bytes_read ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + frame_data_block_size = s_get_size_from_fdl( fdl ); + + receiver_ftd->frame_data_length = frame_data_block_size; + int32_t length_field_size; + err = LC3PLUS_RTP_frame_data_length_get_size( &length_field_size, receiver_ftd->frame_data_length ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + *num_bytes_read += length_field_size; + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( + uint8_t *serialized_buffer, + const size_t serialized_buffer_capacity, + size_t *packed_buffer_actual_size, + const LC3PLUS_RTP_FDL fdl_request, + LC3PLUS_RTP_FTD *sender_ftds, + const size_t sender_ftds_num ) +{ + LC3PLUS_RTP_ERR err; + uint8_t *p_write = serialized_buffer; + uint32_t i; + int32_t bytes_written = 0; + int32_t lc3plus_frame_size_sum; + uint8_t *p_frame_data; + int32_t fdl_request_length; + + if ( NULL == serialized_buffer || NULL == packed_buffer_actual_size || NULL == sender_ftds ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + *packed_buffer_actual_size = 0; + err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, fdl_request ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( !s_fdl_value_is_valid_request( fdl_request ) ) + { + return LC3PLUS_RTP_ERR_INVALID_FDL_REQUEST; + } + if ( (int32_t) serialized_buffer_capacity < bytes_written + fdl_request_length ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + err = s_frame_data_length_pack( fdl_request, p_write ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + bytes_written += fdl_request_length; + p_write += bytes_written; + + for ( i = 0; i < sender_ftds_num; ++i ) + { + /* only the last ftd may have the LC3PLUS_RTP_FTD_FC_LAST_OVERALL value */ + if ( sender_ftds[i].fc == LC3PLUS_RTP_FTD_FC_LAST_OVERALL && i != ( sender_ftds_num - 1 ) ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + /* the last ftd must have the LC3PLUS_RTP_FTD_FC_LAST_OVERALL value */ + if ( sender_ftds[i].fc != LC3PLUS_RTP_FTD_FC_LAST_OVERALL && i == ( sender_ftds_num - 1 ) ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + if ( (int32_t) serialized_buffer_capacity < bytes_written + LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + *p_write = 0x00; + *p_write |= LC3PLUS_RTP_FTD_FC_MASK & (uint8_t) sender_ftds[i].fc; + *p_write |= LC3PLUS_RTP_FTD_FDI_MASK & (uint8_t) sender_ftds[i].fdi; + *p_write |= LC3PLUS_RTP_FTD_BWR_MASK & (uint8_t) sender_ftds[i].bwr; + *p_write |= LC3PLUS_RTP_FTD_H_MASK & (uint8_t) sender_ftds[i].h; + p_write++; + bytes_written += LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL; + + int32_t fdl_length; + err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_length, sender_ftds[i].frame_data_length ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( (int32_t) serialized_buffer_capacity < bytes_written + fdl_length ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + err = s_frame_data_length_pack( sender_ftds[i].frame_data_length, p_write ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + p_write += fdl_length; + bytes_written += fdl_length; + } + + lc3plus_frame_size_sum = 0; + p_frame_data = serialized_buffer + bytes_written; + for ( i = 0; i < sender_ftds_num; ++i ) + { + sender_ftds[i].frame_data = p_frame_data; + p_frame_data += sender_ftds[i].frame_data_length; + lc3plus_frame_size_sum += sender_ftds[i].frame_data_length; + } + *packed_buffer_actual_size = bytes_written + lc3plus_frame_size_sum; + assert( *packed_buffer_actual_size <= serialized_buffer_capacity ); + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_ftds_parse( + LC3PLUS_RTP_FTD *receiver_ftds, + const int32_t receiver_ftds_num_max, + int16_t *receiver_ftds_num, + uint8_t *serialized_buffer, + const size_t serialized_buffer_size ) +{ + int32_t diff; + uint8_t *p_read; + uint32_t ftds_offset_sum = 0; + int16_t i; + LC3PLUS_RTP_ERR error; + int32_t frame_offset_counter; + int32_t size; + + p_read = serialized_buffer; + if ( NULL == receiver_ftds || NULL == receiver_ftds_num || NULL == serialized_buffer ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + if ( 0 == serialized_buffer_size ) + { + return LC3PLUS_RTP_ERR_EMPTY_TOC; + } + if ( receiver_ftds_num_max <= 0 ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + { + int32_t num_bytes_read_sum = 0; + const int32_t min_num_bytes_per_ftd = 2; + int16_t receiver_ftds_index = 0; + bool another_ftd = true; + int32_t num_bytes_read_per_ftd; + + while ( another_ftd ) + { + if ( (int32_t) serialized_buffer_size < min_num_bytes_per_ftd ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + if ( num_bytes_read_sum >= (int32_t) serialized_buffer_size - min_num_bytes_per_ftd ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + num_bytes_read_per_ftd = 0; + error = s_parse_ftd( p_read, &receiver_ftds[receiver_ftds_index], &num_bytes_read_per_ftd, serialized_buffer_size - num_bytes_read_sum ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != error ) + { + return error; + } + p_read += num_bytes_read_per_ftd; + num_bytes_read_sum += num_bytes_read_per_ftd; + + if ( receiver_ftds[receiver_ftds_index].fc == LC3PLUS_RTP_FTD_FC_RESERVED ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM; + } + else if ( receiver_ftds[receiver_ftds_index].fc == LC3PLUS_RTP_FTD_FC_LAST_OVERALL ) + { + another_ftd = false; + } + + if ( another_ftd ) + { + if ( receiver_ftds_index >= receiver_ftds_num_max ) + { + return LC3PLUS_RTP_ERR_NOT_ENOUGH_FTDS_ALLOCATED; + } + ( receiver_ftds_index )++; + } + } + *receiver_ftds_num = receiver_ftds_index + 1; + } + + /* set frame-data pointers into serialized_buffer */ + for ( i = 0; i < *receiver_ftds_num; ++i ) + { + error = LC3PLUS_RTP_frame_data_length_get_size( &size, receiver_ftds[i].frame_data_length ); + if ( error != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return error; + } + ftds_offset_sum += LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL + size; + } + + frame_offset_counter = 0; + for ( i = 0; i < *receiver_ftds_num; ++i ) + { + if ( s_fdl_is_magic_value( receiver_ftds[i].frame_data_length ) ) + { + receiver_ftds[i].frame_data = NULL; + } + else + { + receiver_ftds[i].frame_data = serialized_buffer + ftds_offset_sum + frame_offset_counter; + frame_offset_counter += receiver_ftds[i].frame_data_length; + } + } + + if ( ftds_offset_sum + frame_offset_counter != serialized_buffer_size ) + { + /* parsed content & size n bytes of input buffer do not line up */ + /* if the buffer capacity is larger and the remaining bytes are zero, we don't treat this as an error since it's due to the IVAS-Split rendering zero padding */ + diff = serialized_buffer_size - ( ftds_offset_sum + frame_offset_counter ); + if ( diff < 0 ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + /* verify that all bytes are zero */ + p_read += frame_offset_counter; + for ( i = 0; i < diff; ++i ) + { + if ( *p_read != 0 ) + { + /* non-zero byte in padding region */ + return LC3PLUS_RTP_ERR_NONZERO_PADDING_BYTES; + } + p_read++; + } + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( + LC3PLUS_RTP_PAYLOAD *payload, + uint8_t *serialized_buffer, + const size_t serialized_buffer_size ) +{ + int32_t new_frame_duration_us; + int32_t new_sampling_rate_hz; + int16_t new_high_resolution_flag; + int16_t i = 0; + int16_t channel_id = 0; + int16_t media_time_id = 0; + const int16_t invalid_value = -1; + int16_t media_times_per_channel[LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS]; + int16_t channels_per_media_time[LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES]; + LC3PLUS_RTP_ERR err; + + if ( NULL == payload || NULL == serialized_buffer ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + if ( 0 == serialized_buffer_size ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + + for ( media_time_id = 0; media_time_id < LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES; ++media_time_id ) + { + channels_per_media_time[media_time_id] = invalid_value; + } + media_time_id = 0; + for ( channel_id = 0; channel_id < LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS; ++channel_id ) + { + media_times_per_channel[channel_id] = invalid_value; + } + channel_id = 0; + + err = s_frame_data_length_parse( &payload->fdl_request, serialized_buffer, serialized_buffer_size ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + int32_t fdl_request_length; + err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, payload->fdl_request ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( !s_fdl_value_is_valid_request( payload->fdl_request ) ) + { + return LC3PLUS_RTP_ERR_INVALID_FDL_REQUEST; + } + + err = s_ftds_parse( payload->ftds, sizeof( payload->ftds ) / sizeof( LC3PLUS_RTP_FTD ), &payload->num_ftds, serialized_buffer + fdl_request_length, serialized_buffer_size - fdl_request_length ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( 0 == payload->num_ftds ) + { + return LC3PLUS_RTP_ERR_GENERIC_ERROR; + } + /* verify shared setting between all FTDs [samplerate, frame_duration, channel count] */ + + /* initialize on the first FTD, use this as reference */ + err = s_frame_duration_ms_from_fdi( &payload->frame_duration_us, payload->ftds[0].fdi ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + err = s_sampling_rate_hz_from_bwr( &payload->sampling_rate_hz, payload->ftds[0].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + err = s_high_resolution_flag_from_bwr( &payload->high_resolution_enabled, payload->ftds[0].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + payload->num_channels = 0; + payload->num_media_times = 0; + for ( i = 0; i < payload->num_ftds; ++i ) + { + if ( payload->ftds[i].h != LC3PLUS_RTP_FTD_H_PRIMARY ) + { + /* not implemented */ + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + + err = s_frame_duration_ms_from_fdi( &new_frame_duration_us, payload->ftds[i].fdi ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( payload->frame_duration_us != new_frame_duration_us ) + { + /* mixed frame durations not supported */ + return LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION; + } + + err = s_sampling_rate_hz_from_bwr( &new_sampling_rate_hz, payload->ftds[i].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( payload->sampling_rate_hz != new_sampling_rate_hz ) + { + /* mixed sampling frequencies not supported */ + return LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION; + } + + + err = s_high_resolution_flag_from_bwr( &new_high_resolution_flag, payload->ftds[i].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( payload->high_resolution_enabled != new_high_resolution_flag ) + { + /* mixed high resolution mode not supported */ + return LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION; + } + + switch ( payload->ftds[i].fc ) + { + case LC3PLUS_RTP_FTD_FC_LAST_OVERALL: + channels_per_media_time[media_time_id]++; + media_times_per_channel[channel_id]++; + channel_id = 0; + media_time_id = 0; + break; + case LC3PLUS_RTP_FTD_FC_SUBSEQUENT_CHANNEL: + media_times_per_channel[channel_id]++; + channels_per_media_time[media_time_id]++; + channel_id++; + break; + case LC3PLUS_RTP_FTD_FC_LAST_IN_MEDIATIME: + media_times_per_channel[channel_id]++; + channels_per_media_time[media_time_id]++; + channel_id = 0; + media_time_id++; + break; + case LC3PLUS_RTP_FTD_FC_RESERVED: + default: + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM; + } + } + + { + int32_t valid_num_media_times_per_channel; + int32_t iCh; + /* check whether all channels exist for each media time */ + if ( media_times_per_channel[0] == invalid_value ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + valid_num_media_times_per_channel = media_times_per_channel[0]; + for ( iCh = 0; iCh < LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS; ++iCh ) + { + if ( media_times_per_channel[iCh] == invalid_value ) + { + break; + } + if ( valid_num_media_times_per_channel != media_times_per_channel[iCh] ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + } + } + { + /* whether all media times exist for each channel */ + int32_t iMediaTime; + int32_t valid_num_channels_per_media_time; + if ( channels_per_media_time[0] == invalid_value ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + valid_num_channels_per_media_time = channels_per_media_time[0]; + for ( iMediaTime = 0; iMediaTime < LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES; ++iMediaTime ) + { + if ( channels_per_media_time[iMediaTime] == invalid_value ) + { + break; + } + if ( valid_num_channels_per_media_time != channels_per_media_time[iMediaTime] ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + } + } + + /* convert zero-index to count */ + payload->num_channels = channels_per_media_time[0] + 1; + payload->num_media_times = media_times_per_channel[0] + 1; + + /* verify that all media times have the same number of channels, partial packets are not supported */ + if ( payload->num_ftds != payload->num_channels * payload->num_media_times ) + { + return LC3PLUS_RTP_ERR_GENERIC_ERROR; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, const int32_t sampling_rate, const int32_t high_res_enabled ) +{ + if ( NULL == bwr ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( sampling_rate ) + { + case 8000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_NB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 16000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_WB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 24000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_SSWB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 32000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_SWB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 44100: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_FBCD; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 48000: + if ( 0 == high_res_enabled ) + { + *bwr = LC3PLUS_RTP_FTD_BWR_FB; + return LC3PLUS_RTP_ERR_NO_ERROR; + } + else + { + *bwr = LC3PLUS_RTP_FTD_BWR_FBHR; + return LC3PLUS_RTP_ERR_NO_ERROR; + } + case 96000: + if ( 0 == high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_UBHR; + return LC3PLUS_RTP_ERR_NO_ERROR; + default: + break; + } + + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI *fdi, const int32_t frame_duration_us ) +{ + if ( NULL == fdi ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( frame_duration_us ) + { + case 2500: + *fdi = LC3PLUS_RTP_FTD_FDI_2500_US; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 5000: + *fdi = LC3PLUS_RTP_FTD_FDI_5000_US; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 10000: + *fdi = LC3PLUS_RTP_FTD_FDI_10000_US; + return LC3PLUS_RTP_ERR_NO_ERROR; + default: + break; + } + + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; +} + +#endif /* ISAR_BITSTREAM_UPDATE_LC3PLUS */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h new file mode 100644 index 000000000..3af6757fa --- /dev/null +++ b/lib_isar/isar_lc3plus_payload.h @@ -0,0 +1,216 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_PAYLOAD_H +#define ISAR_LC3PLUS_PAYLOAD_H + +#include +#include +#include "lc3.h" +#include "options.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + +/* Implementation of the "B.2.6 Table of contents" part of the RTP payload format + * for LC3plus as specified in ETSI TS 103 634. */ + +typedef enum LC3PLUS_RTP_ERR +{ + LC3PLUS_RTP_ERR_NO_ERROR, + LC3PLUS_RTP_ERR_NULL_PTR, + LC3PLUS_RTP_ERR_INVALID_PARAMETERS, + LC3PLUS_RTP_ERR_EMPTY_TOC, + LC3PLUS_RTP_ERR_NOT_IMPLEMENTED, + LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION, + LC3PLUS_RTP_ERR_INVALID_BITSTREAM, + LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE, + LC3PLUS_RTP_ERR_NOT_ENOUGH_FTDS_ALLOCATED, + LC3PLUS_RTP_ERR_INVALID_FDL_REQUEST, + LC3PLUS_RTP_ERR_NONZERO_PADDING_BYTES, + LC3PLUS_RTP_ERR_GENERIC_ERROR +} LC3PLUS_RTP_ERR; + +/* + * The content of the FTD is shown in Figure B.6. + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |FC |FDI| BWR |H| FDL1 | (FDL2) | (FDL3) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +/* FC (2 bits): + * Frame and Channel (FC) indicator for subsequent frame data (if available). The meaning of the FC + * indicator is shown in Table B.2. The FC value defines the media time stamp (in integer increments + * of TSI) and the channel counter (CC, starting from 1 for the first channel) for the subsequent + * FTD (if available). */ +typedef enum LC3PLUS_RTP_FTD_FC +{ + LC3PLUS_RTP_FTD_FC_LAST_OVERALL = 0x00, /* Last FDL in ToC, no FDL follows the current FDL */ + LC3PLUS_RTP_FTD_FC_SUBSEQUENT_CHANNEL = 0x01, /* The next FDL is for the next channel for the same media time */ + LC3PLUS_RTP_FTD_FC_LAST_IN_MEDIATIME = 0x02, /* The next FDL is for first channel for next media time, channel counter is reset */ + LC3PLUS_RTP_FTD_FC_RESERVED = 0x03, /* Reserved */ +} LC3PLUS_RTP_FTD_FC; +#define LC3PLUS_RTP_FTD_FC_MASK 0x03 + +/* FDI (2 bits): + * Frame Duration Index, with encoding as shown in Table B.3. The FDI shall be static for a given + * payload type during the session. The FDI also dictates the TSI, needed for deriving the media + * time in case of more than one frame in the payload. */ +typedef enum LC3PLUS_RTP_FTD_FDI +{ + LC3PLUS_RTP_FTD_FDI_2500_US = 0x00, + LC3PLUS_RTP_FTD_FDI_5000_US = 0x04, + LC3PLUS_RTP_FTD_FDI_10000_US = 0x08, + LC3PLUS_RTP_FTD_FDI_RESERVED = 0x0C, +} LC3PLUS_RTP_FTD_FDI; +#define LC3PLUS_RTP_FTD_FDI_MASK 0x0C +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI *fdi, const int32_t frame_duration_us ); + +/* BWR (3 bits): + * Bandwidth and resolution combination used by the codec is jointly encoded into a bandwidth and + * resolution (BWR) index. The BWR index is encoded as shown in Table B.4. The BWR encoding is + * defined in Table B.4. The BWR index shall be static for a given payload type during the session. */ +typedef enum LC3PLUS_RTP_FTD_BWR +{ + LC3PLUS_RTP_FTD_BWR_NB = 0x00, + LC3PLUS_RTP_FTD_BWR_WB = 0x10, + LC3PLUS_RTP_FTD_BWR_SSWB = 0x20, + LC3PLUS_RTP_FTD_BWR_SWB = 0x30, + LC3PLUS_RTP_FTD_BWR_FBCD = 0x40, + LC3PLUS_RTP_FTD_BWR_FB = 0x50, + LC3PLUS_RTP_FTD_BWR_FBHR = 0x60, + LC3PLUS_RTP_FTD_BWR_UBHR = 0x70, +} LC3PLUS_RTP_FTD_BWR; +#define LC3PLUS_RTP_FTD_BWR_MASK 0x70 +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, const int32_t sampling_rate, const int32_t high_res_enabled ); + +/* H (1 bit): + * Indicates whether the corresponding frame is a normal frame (primary encoding) or a helper frame + * (secondary encoding). 0 indicates a primary frame, 1 indicates secondary (redundant) frame */ +typedef enum LC3PLUS_RTP_FTD_H +{ + LC3PLUS_RTP_FTD_H_PRIMARY = 0x00, + LC3PLUS_RTP_FTD_H_SECONDARY = 0x80, +} LC3PLUS_RTP_FTD_H; +#define LC3PLUS_RTP_FTD_H_MASK 0x80 + +typedef enum LC3PLUS_RTP_FDL +{ + LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA = 0, + LC3PLUS_RTP_FDL_SPEECH_BAD = 1, + LC3PLUS_RTP_FDL_SPEECH_SID = 2, + LC3PLUS_RTP_FDL_RESERVED_MIN = 3, + LC3PLUS_RTP_FDL_RESERVED_MAX = 19, + LC3PLUS_RTP_FDL_LENGTH_1_MIN = 20, + LC3PLUS_RTP_FDL_LENGTH_1_MAX = 254, + LC3PLUS_RTP_FDL_LENGTH_2_MIN = 255, + LC3PLUS_RTP_FDL_LENGTH_2_MAX = 509, + LC3PLUS_RTP_FDL_LENGTH_3_MIN = 510, + LC3PLUS_RTP_FDL_LENGTH_3_MAX = 765 +} LC3PLUS_RTP_FDL; +/* value used to indicate that the Frame Data Length (FDL) extends to the next byte */ +#define LC3PLUS_RTP_FDL_EXTENSION_VALUE 0xFF + +typedef struct LC3PLUS_RTP_FTD +{ + LC3PLUS_RTP_FTD_FC fc; + LC3PLUS_RTP_FTD_FDI fdi; + LC3PLUS_RTP_FTD_BWR bwr; + LC3PLUS_RTP_FTD_H h; + uint8_t *frame_data; + LC3PLUS_RTP_FDL frame_data_length; +} LC3PLUS_RTP_FTD; +#define LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL 1 +#define LC3PLUS_RTP_FDL_MIN_LENGTH 1 +#define LC3PLUS_RTP_FTD_MIN_SIZE ( LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL + LC3PLUS_RTP_FDL_MIN_LENGTH ) + +/*! Serialize the sender_ftds structs and fdl_request into a linear compact buffer + * @param[out] serialized_buffer pointer to the start of the memory location where the serialized buffer will be written to + * @param[in] serialized_buffer_capacity capacity of the serialized_buffer in bytes + * @param[out] packed_buffer_actual_size actually used size of in bytes of the packed_buffer (<=serialized_buffer_capacity) + * @param[in] fdl_request frame data length request + * @param[in,out] sender_ftds the function will overwrite the frame_data pointer with the correct memory location in + * the packed_buffer (so it can subsequently be used as input for the LC3plus encode call) + * @param[in] sender_ftds_num number of sender_ftds + * @return LC3PLUS_RTP_ERR_NO_ERROR in case of success */ +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( + uint8_t *serialized_buffer, + const size_t serialized_buffer_capacity, + size_t *packed_buffer_actual_size, + const LC3PLUS_RTP_FDL fdl_request, + LC3PLUS_RTP_FTD *sender_ftds, + const size_t sender_ftds_num ); + +/*! Get size of the frame data length field for a certain frame data length value in bytes. + * @param[out] length size of the frame data length field in bytes [1,2,3] + * @param[in] frameDataLengthValue frame data length value + * @return LC3PLUS_RTP_ERR_NO_ERROR in case of success */ +LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const LC3PLUS_RTP_FDL frameDataLengthValue ); + +#define LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS 16 +#define LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES 8 /* max ivas frame duration/min lc3plus frame duration: 20000/2500 */ +#define LC3PLUS_RTP_PAYLOAD_MAX_NUM_FTDS LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS *LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES + +typedef struct LC3PLUS_RTP_PAYLOAD_CONFIG +{ + /* frame duration in us shared among all FTDs */ + int32_t frame_duration_us; + /* high resolution flag shared among all FTDs */ + int16_t high_resolution_enabled; + /* sampling frequency shared among all FTDs */ + int32_t sampling_rate_hz; + /* number of individual channels in the payload */ + int16_t num_channels; + /* number of individual media times in the payload */ + int16_t num_media_times; + /* frame data length request */ + LC3PLUS_RTP_FDL fdl_request; + /* FTD data with pointer to raw frame data */ + LC3PLUS_RTP_FTD ftds[LC3PLUS_RTP_PAYLOAD_MAX_NUM_FTDS]; + /* actual number of ftds */ + int16_t num_ftds; +} LC3PLUS_RTP_PAYLOAD; + +/*! Deserialized a serialized buffer into a LC3PLUS_RTP_PAYLOAD struct + * @param payload pointer to target LC3PLUS_RTP_PAYLOAD object. Note: frame_data pointers in the struct will point to the respective memory locations in the serialized_buffer. + * @param serialized_buffer pointer to the start of the serialized input buffer + * @param serialized_buffer_size size of the serialized input buffer in bytes + * @return LC3PLUS_RTP_ERR_NO_ERROR in case of success */ +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( + LC3PLUS_RTP_PAYLOAD *payload, + uint8_t *serialized_buffer, + const size_t serialized_buffer_size ); + +#endif /* ISAR_BITSTREAM_UPDATE_LC3PLUS */ +#endif /* #ifdef SPLIT_REND_WITH_HEAD_ROT */ +#endif /* ISAR_LC3PLUS_PAYLOAD_H */ diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c new file mode 100644 index 000000000..c067ad064 --- /dev/null +++ b/lib_isar/isar_lcld_decoder.c @@ -0,0 +1,1993 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "isar_lcld_rom_tables.h" +#include "prot.h" +#include +#include "isar_prot.h" +#include "wmc_auto.h" +#include "basop_util.h" +#include "prot_fx2.h" +// #define DEBUG_WRITE +#include "debug.h" +#include "enh64.h" + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + +#define HUFF_READ_SIZE ( 4 ) + +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ + +typedef struct TableNode +{ + struct TableNode **ppoNextTable; + struct TableNode *poOrderedNext; + + Word32 *piCodeIndex; + Word32 *piDifference; + Word32 *piLength; +} TableNode; + +typedef struct TableList +{ + TableNode *poOrderedTop; + TableNode *poOrderedBottom; + +} TableList; + +struct LCLD_DECODER +{ + Word32 iSampleRate; + Word32 iChannels; + Word32 iNumBlocks; + + Word32 iNumBands; + const Word32 *piBandwidths; + + Word32 iMSMode; + Word32 *piMSFlags; + TableList *ptable_list; + UWord32 ( *c_apauiHuffDecTable_RAM[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE]; + UWord32 num_decode_table[2 * ALLOC_TABLE_SIZE]; + Word32 piMSPredCoefs[MAX_BANDS]; + Word32 piLRPhaseDiffs[MAX_BANDS]; + Word32 iCommonGrouping; + Word32 *piNumGroups; + Word32 **ppiGroupLengths; + + Word32 ***pppiRMSEnvelope; + Word32 ***pppiSMR; + Word32 ***pppiExcitation; + Word32 ***pppiAlloc; + + Word32 iAllocOffset; + Word32 iRealOnlyOut; + + Word32 ***pppiLCLDSignReal; + Word32 ***pppiLCLDSignImag; + Word32 ***pppiQLCLDReal; + Word32 ***pppiQLCLDImag; + + PredictionDecoder *psPredictionDecoder; + + + NoiseGen *psNoiseGen; +}; + +static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ); +static TableNode *CreateTableList( Word32 iReadLength ); +static void DeleteTableList( TableList *ptable_list, Word32 iTables ); +static TableNode *GetNextTable( Word32 iIndex, TableList *table_list, TableNode *poParent, Word32 iReadLength, UWord32 *iTablesCreated ); +static void AddcodeTableList( TableList *ptable_list, Word32 iLength, Word32 iCode, Word32 iCodeIndex, Word32 iReadLength, UWord32 *iTables ); +static void CompleteTables( LCLDDecoder *psLCLDDecoder, Word32 n, TableList *ptable_list, Word32 iReadLength, Word32 iTablesCreated ); + +static TableNode *CreateTableList( Word32 iReadLength ) +{ + Word32 n; + Word32 iMaxTables; + TableNode *ptable_top; + iMaxTables = L_shl( 1, (Word16) iReadLength ); + ptable_top = (TableNode *) malloc( sizeof( TableNode ) ); + ptable_top->ppoNextTable = + (TableNode **) malloc( iMaxTables * sizeof( TableNode * ) ); + ptable_top->piCodeIndex = (Word32 *) malloc( iMaxTables * sizeof( Word32 ) ); + ptable_top->piDifference = (Word32 *) malloc( iMaxTables * sizeof( Word32 ) ); + ptable_top->piLength = (Word32 *) malloc( iMaxTables * sizeof( Word32 ) ); + FOR( n = 0; n < iMaxTables; n++ ) + { + ptable_top->ppoNextTable[n] = NULL; + ptable_top->piCodeIndex[n] = 0xffff; + move32(); + ptable_top->piDifference[n] = 0; + move32(); + ptable_top->piLength[n] = 0; + move32(); + } + + return ptable_top; +} + +static void DeleteTableList( TableList *ptable_list, Word32 iTables ) +{ + + TableNode *node; + node = ptable_list->poOrderedTop; + + WHILE( ( iTables ) ) + { + + TableNode *node1 = node; + node = node1->poOrderedNext; + IF( node1->piCodeIndex != NULL ) + { + free( node1->piCodeIndex ); + } + IF( node1->piLength != NULL ) + { + free( node1->piLength ); + } + IF( node1->piDifference != NULL ) + { + free( node1->piDifference ); + } + IF( node1->ppoNextTable != NULL ) + { + free( node1->ppoNextTable ); + } + IF( node1 != NULL ) + { + free( node1 ); + } + iTables--; + } + IF( ptable_list != NULL ) + { + free( ptable_list ); + } +} + +static TableNode *GetNextTable( Word32 iIndex, TableList *table_list, TableNode *poParent, Word32 iReadLength, UWord32 *iTablesCreated ) +{ + TableNode *poNextNode; + + IF( poParent->ppoNextTable[iIndex] == NULL ) + { + poNextNode = CreateTableList( iReadLength ); + poParent->ppoNextTable[iIndex] = poNextNode; + poParent->piDifference[iIndex] = *iTablesCreated; /* this is a link to the next table rather than the difference */ + move32(); + table_list->poOrderedBottom->poOrderedNext = poNextNode; + table_list->poOrderedBottom = poNextNode; + + ( *iTablesCreated )++; + } + ELSE + { + poNextNode = poParent->ppoNextTable[iIndex]; + } + + return poNextNode; +} + +static void CompleteTables( LCLDDecoder *psLCLDDecoder, Word32 n, TableList *ptable_list, Word32 iReadLength, Word32 iTablesCreated ) +{ + + Word32 iMaxTables; + Word32 j; + TableNode *poNode; + + iMaxTables = L_shl( 1, (Word16) iReadLength ); + psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = + malloc( iTablesCreated * iMaxTables * sizeof( UWord32 * ) ); + + poNode = ptable_list->poOrderedTop; + FOR( j = 0; j < iTablesCreated; j++ ) + { + Word32 k; + IF( poNode != NULL ) + { + FOR( k = 0; k < iMaxTables; k++ ) + { + UWord32 uiCode; + uiCode = poNode->piDifference[k]; + move32(); + uiCode = (UWord32) L_shl( (Word32) uiCode, 16 ); + uiCode = (UWord32) L_or( (Word32) uiCode, poNode->piCodeIndex[k] ); + psLCLDDecoder->c_apauiHuffDecTable_RAM[n][j][k] = uiCode; + move32(); + } + } + poNode = poNode->poOrderedNext; + } +} + +static void AddcodeTableList( TableList *ptable_list, Word32 iLength, Word32 iCode, Word32 iCodeIndex, Word32 iReadLength, UWord32 *iTables ) +{ + Word32 iDifference; + Word32 iMask; + Word32 iCurrentLength; + Word32 iIndex; + Word32 iCodeLow; + Word32 iCodeHigh; + + TableNode *poNode; + poNode = ptable_list->poOrderedTop; + iMask = L_sub( L_shl( 1, (Word16) iReadLength ), 1 ); + iCurrentLength = iLength; + move32(); + WHILE( GT_32( iCurrentLength, iReadLength ) ) + { + iDifference = L_sub( iCurrentLength, iReadLength ); + iIndex = L_shr( iCode, (Word16) iDifference ); + iIndex = L_and( iIndex, iMask ); + poNode = GetNextTable( iIndex, ptable_list, poNode, iReadLength, iTables ); + iCurrentLength = L_sub( iCurrentLength, iReadLength ); + } + + iMask = L_sub( L_shl( 1, (Word16) iCurrentLength ), 1 ); + iDifference = L_sub( iReadLength, iCurrentLength ); + iCodeLow = L_shl( L_and( iCode, iMask ), (Word16) iDifference ); + iMask = L_sub( L_shl( 1, (Word16) iDifference ), 1 ); + iCodeHigh = L_or( iCodeLow, iMask ); + FOR( iIndex = iCodeLow; iIndex <= iCodeHigh; iIndex++ ) + { + poNode->piCodeIndex[iIndex] = iCodeIndex; + move32(); + poNode->piDifference[iIndex] = iDifference; + move32(); + poNode->piLength[iIndex] = iLength; + move32(); + } +} + +static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ) +{ + Word32 n; + UWord32 **ppsort_enc_table; + TableList *ptable_list; + ptable_list = (TableList *) malloc( sizeof( TableList ) ); + + ppsort_enc_table = (UWord32 **) malloc( iSize * sizeof( Word32 * ) ); + FOR( n = 0; n < iSize; n++ ) + { + ppsort_enc_table[n] = (UWord32 *) malloc( 3 * sizeof( Word32 ) ); + ppsort_enc_table[n][0] = (UWord32) ppuiEncTable[n][0]; + move32(); + ppsort_enc_table[n][1] = (UWord32) ppuiEncTable[n][1]; + move32(); + ppsort_enc_table[n][2] = (UWord32) n; + move32(); + } + + FOR( n = 0; n < iSize; n++ ) + { + UWord32 iMin; + Word32 iMinIndex; + Word32 k; + + iMin = ppsort_enc_table[n][0]; + move32(); + iMinIndex = n; + move32(); + FOR( k = n; k < iSize; k++ ) + { + IF( ppsort_enc_table[k][0] < iMin ) + { + iMin = ppsort_enc_table[k][0]; + move32(); + iMinIndex = k; + move32(); + } + } + + IF( NE_32( iMinIndex, n ) ) + { + UWord32 uiLength; + UWord32 uiCode; + UWord32 uiCodeIndex; + + uiLength = ppsort_enc_table[n][0]; + move32(); + uiCode = ppsort_enc_table[n][1]; + move32(); + uiCodeIndex = ppsort_enc_table[n][2]; + move32(); + + ppsort_enc_table[n][0] = ppsort_enc_table[iMinIndex][0]; + move32(); + ppsort_enc_table[n][1] = ppsort_enc_table[iMinIndex][1]; + move32(); + ppsort_enc_table[n][2] = ppsort_enc_table[iMinIndex][2]; + move32(); + + ppsort_enc_table[iMinIndex][0] = uiLength; + move32(); + ppsort_enc_table[iMinIndex][1] = uiCode; + move32(); + ppsort_enc_table[iMinIndex][2] = uiCodeIndex; + move32(); + } + } + ptable_list->poOrderedTop = CreateTableList( iReadLength ); + ptable_list->poOrderedBottom = ptable_list->poOrderedTop; + FOR( n = 0; n < iSize; n++ ) + { + Word32 iLength; + Word32 iCode; + Word32 iCodeIndex; + + iLength = ppsort_enc_table[n][0]; + move32(); + iCode = ppsort_enc_table[n][1]; + move32(); + iCodeIndex = ppsort_enc_table[n][2]; + move32(); + AddcodeTableList( ptable_list, iLength, iCode, iCodeIndex, iReadLength, + iTables ); + } + + CompleteTables( psLCLDDecoder, num, ptable_list, iReadLength, *iTables ); + DeleteTableList( ptable_list, *iTables ); + FOR( n = 0; n < iSize; n++ ) + { + free( ppsort_enc_table[n] ); + } + free( ppsort_enc_table ); +} + + +/*------------------------------------------------------------------------------------------* + * Function CreateLCLDDecoder() + * + * + *------------------------------------------------------------------------------------------*/ + +ivas_error CreateLCLDDecoder( + LCLDDecoder **psLCLDDecoder_out, + const Word32 iSampleRate, + const Word32 iChannels, + const Word32 iNumBlocks, + const Word32 iRealOnlyOut ) +{ + Word32 n; + Word32 read_length; + ivas_error error; + LCLDDecoder *psLCLDDecoder = NULL; + + assert( iSampleRate == 48000 ); + assert( iNumBlocks == 16 || iNumBlocks == 8 || iNumBlocks == 4 ); + IF( ( psLCLDDecoder = (LCLDDecoder *) malloc( sizeof( LCLDDecoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + psLCLDDecoder->iSampleRate = iSampleRate; + move32(); + psLCLDDecoder->iChannels = iChannels; + psLCLDDecoder->iAllocOffset = 0; + psLCLDDecoder->iRealOnlyOut = iRealOnlyOut; + if ( iRealOnlyOut == 1 ) + { + psLCLDDecoder->iNumBlocks = L_shr( iNumBlocks, 1 ); + } + else + { + psLCLDDecoder->iNumBlocks = iNumBlocks; + } + psLCLDDecoder->iNumBands = 0; /* read from bitstream*/ + move32(); + psLCLDDecoder->piBandwidths = c_aiBandwidths48; + + psLCLDDecoder->iMSMode = 0; + move32(); + IF( ( psLCLDDecoder->piMSFlags = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + FOR( n = 0; n < MAX_BANDS; n++ ) + { + psLCLDDecoder->piLRPhaseDiffs[n] = 0; + move32(); + psLCLDDecoder->piMSPredCoefs[n] = 0; + move32(); + } + + psLCLDDecoder->iCommonGrouping = 1; /* Common grouping always on only impacts stereo */ + move32(); + IF( ( psLCLDDecoder->piNumGroups = (Word32 *) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->ppiGroupLengths = (Word32 **) malloc( psLCLDDecoder->iChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiRMSEnvelope = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiSMR = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiExcitation = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiAlloc = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDDecoder->pppiLCLDSignReal = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiLCLDSignImag = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiQLCLDReal = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiQLCLDImag = (Word32 ***) malloc( psLCLDDecoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + FOR( n = 0; n < iChannels; n++ ) + { + Word16 k; + IF( ( psLCLDDecoder->ppiGroupLengths[n] = (Word32 *) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiRMSEnvelope[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiSMR[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiExcitation[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiAlloc[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDDecoder->pppiLCLDSignReal[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiLCLDSignImag[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiQLCLDReal[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiQLCLDImag[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + IF( ( psLCLDDecoder->pppiRMSEnvelope[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiSMR[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiExcitation[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiAlloc[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDDecoder->pppiLCLDSignReal[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiLCLDSignImag[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiQLCLDReal[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( psLCLDDecoder->pppiQLCLDImag[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + } + } + + read_length = READ_LENGTH; + move32(); + FOR( n = 0; n < shl( ALLOC_TABLE_SIZE, 1 ); n++ ) + { + psLCLDDecoder->num_decode_table[n] = 1; + move32(); + IF( c_apauiHuffEncTabels[n] != NULL ) + { + CreateDecodeTable( psLCLDDecoder, n, c_apauiHuffEncTabels[n], num_row_aauiLCLDHuff[n], read_length, &psLCLDDecoder->num_decode_table[n] ); + } + ELSE + { + psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = NULL; + } + } + + IF( ( error = CreatePredictionDecoder_fx( &psLCLDDecoder->psPredictionDecoder, iChannels, psLCLDDecoder->iNumBlocks ) ) != IVAS_ERR_OK ) + { + return error; + } + psLCLDDecoder->psNoiseGen = NULL; /* CreateNoiseGen(); No noise fill for now*/ + *psLCLDDecoder_out = psLCLDDecoder; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------------------------* + * Function DeleteLCLDDecoder() + * + * + *------------------------------------------------------------------------------------------*/ + +void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder ) +{ + Word32 k, n; + + IF( psLCLDDecoder != NULL ) + { + IF( psLCLDDecoder->piMSFlags != NULL ) + { + free( psLCLDDecoder->piMSFlags ); + } + + IF( psLCLDDecoder->piNumGroups != NULL ) + { + free( psLCLDDecoder->piNumGroups ); + } + + IF( psLCLDDecoder->ppiGroupLengths != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + free( psLCLDDecoder->ppiGroupLengths[n] ); + } + free( psLCLDDecoder->ppiGroupLengths ); + } + + IF( psLCLDDecoder->pppiRMSEnvelope != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiRMSEnvelope[n][k] ); + } + free( psLCLDDecoder->pppiRMSEnvelope[n] ); + } + free( psLCLDDecoder->pppiRMSEnvelope ); + } + + IF( psLCLDDecoder->pppiSMR != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiSMR[n][k] ); + } + free( psLCLDDecoder->pppiSMR[n] ); + } + free( psLCLDDecoder->pppiSMR ); + } + + IF( psLCLDDecoder->pppiExcitation != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiExcitation[n][k] ); + } + free( psLCLDDecoder->pppiExcitation[n] ); + } + free( psLCLDDecoder->pppiExcitation ); + } + + + IF( psLCLDDecoder->pppiAlloc != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiAlloc[n][k] ); + } + free( psLCLDDecoder->pppiAlloc[n] ); + } + free( psLCLDDecoder->pppiAlloc ); + } + + IF( psLCLDDecoder->pppiLCLDSignReal != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiLCLDSignReal[n][k] ); + } + free( psLCLDDecoder->pppiLCLDSignReal[n] ); + } + free( psLCLDDecoder->pppiLCLDSignReal ); + } + + IF( psLCLDDecoder->pppiLCLDSignImag != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiLCLDSignImag[n][k] ); + } + free( psLCLDDecoder->pppiLCLDSignImag[n] ); + } + free( psLCLDDecoder->pppiLCLDSignImag ); + } + + IF( psLCLDDecoder->pppiQLCLDReal != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiQLCLDReal[n][k] ); + } + free( psLCLDDecoder->pppiQLCLDReal[n] ); + } + free( psLCLDDecoder->pppiQLCLDReal ); + } + + IF( psLCLDDecoder->pppiQLCLDImag != NULL ) + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiQLCLDImag[n][k] ); + } + free( psLCLDDecoder->pppiQLCLDImag[n] ); + } + free( psLCLDDecoder->pppiQLCLDImag ); + } + + FOR( n = 0; n < ALLOC_TABLE_SIZE * 2; n++ ) + { + IF( psLCLDDecoder->num_decode_table[n] > 1 ) + { + + IF( psLCLDDecoder->c_apauiHuffDecTable_RAM[n] != NULL ) + { + free( psLCLDDecoder->c_apauiHuffDecTable_RAM[n] ); + } + } + } + + IF( psLCLDDecoder->psPredictionDecoder != NULL ) + { + DeletePredictionDecoder_fx( psLCLDDecoder->psPredictionDecoder ); + psLCLDDecoder->psPredictionDecoder = NULL; + } + + IF( psLCLDDecoder->psNoiseGen != NULL ) + { + DeleteNoiseGen( psLCLDDecoder->psNoiseGen ); + } + + free( psLCLDDecoder ); + } +} + +/*------------------------------------------------------------------------------------------* + * Local function declarations + * + * + *------------------------------------------------------------------------------------------*/ + +static void ApplyRMSEnvelope_fx( const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iNumGroups, const int32_t *piGroupLengths, int32_t **ppiRMSEnvelope, Word32 **ppfReal_fx, Word32 **ppfImag_fx ); +static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths ); + +static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag, NoiseGen *psNoiseGen ); +static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag ); +// static void InvMSCoding_fx( const int32_t iNumBlocks, const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, float ***pppfReal, float ***pppfImag, Word32 ***pppfReal_fx, Word32 ***pppfImag_fx,Word16 exp ); + +static Word32 ReadHeaderInformation( Word32 *piNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 ReadMSInformation( const Word32 iNumBands, Word32 *piMSMode, Word32 *piMSFlags, Word32 *piLRPhaseDiffs, Word32 *piMSPredCoefs, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 ReadGroupInformation( const Word32 iChannels, const Word32 iNumBlocks, Word32 *piCommonGrouping, Word32 *piNumGroups, Word32 **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 ReadHuff( const UWord32 ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], Word32 *piSymbol, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 ReadRMSEnvelope( const Word32 iChannels, const Word32 *piNumGroups, const Word32 iNumBands, Word32 ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 ReadAllocInformation( Word32 *piAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +// static int32_t +// ReadLCLDData( const int32_t iNumGroups, const int32_t *piGroupLengths, const int32_t iNumBands, const int32_t *piBandwidths, const int32_t *piPredEnable, int32_t **ppiAlloc, int32_t **ppiSignReal, int32_t **ppiSignImag, int32_t **ppiQReal, int32_t **ppiQImag, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); +static Word32 ReadLCLDData_fx( const Word32 *piNumGroups, Word32 **ppiGroupLengths, const Word32 iNumBands, const Word32 iNumChannels, Word32 **ppiDecodingUnresolved, Word32 **ppiPredEnable, const Word32 iNumSubSets, const Word32 iSubSetId, Word32 ***pppiAlloc, Word32 ***pppiSignReal, Word32 ***pppiSignImag, Word32 ***pppiQReal, Word32 ***pppiQImag, Word32 **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, UWord32 ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); +static void ComputeAllocation( const Word32 iChannels, const Word32 *piNumGroups, const Word32 iNumBands, Word32 ***pppiSMR, const Word32 iAllocOffset, Word32 ***pppiAlloc ); + +void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder ) +{ + int32_t n, ch; + PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 1; + psPredictionDecoder->ppiDecodingFailed[ch][n] = 1; + psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = 1; + } + } +} + +int32_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder ) +{ + int32_t n, ch; + PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + if ( psPredictionDecoder->ppiDecodingFailedPrev[ch][n] == 1 ) + { + return 1; + } + } + } + return 0; +} + +int32_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder ) +{ + int32_t n, ch; + PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + if ( psPredictionDecoder->ppiDecodingFailed[ch][n] == 1 ) + { + return 1; + } + } + } + return 0; +} + +int32_t **GetDecodingFailedStatus( LCLDDecoder *psLCLDDecoder ) +{ + return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed; +} + +int16_t GetNumSubSets( LCLDDecoder *psLCLDDecoder ) +{ + return (int16_t) psLCLDDecoder->psPredictionDecoder->iNumSubSets; +} + +int32_t **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ) +{ + return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailedPrev; +} + +static void UnpackReal_fx( + const Word32 iChannels, + const Word32 iNumBlocks, + Word32 ***pppfReal_fx, + Word32 ***pppfImag_fx ) +{ + Word32 ch, b, n; + FOR( ch = 0; ch < iChannels; ch++ ) + { + FOR( b = 0; b < LCLD_BANDS; b++ ) + { + Word32 iRealBlock = iNumBlocks - 1; + FOR( n = iNumBlocks / 2 - 1; n >= 0; n-- ) + { + pppfReal_fx[ch][iRealBlock][b] = L_shl( pppfImag_fx[ch][n][b], 1 ); + pppfReal_fx[ch][iRealBlock - 1][b] = L_shl( pppfReal_fx[ch][n][b], 1 ); + pppfImag_fx[ch][iRealBlock][b] = 0; + pppfImag_fx[ch][iRealBlock - 1][b] = 0; + iRealBlock -= 2; + } + } + } +} +/*------------------------------------------------------------------------------------------* + * Function DecodeLCLDFrame() + * + * + *------------------------------------------------------------------------------------------*/ + +Word32 DecodeLCLDFrame( + LCLDDecoder *psLCLDDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word32 ***pppfLCLDReal_fx, + Word32 ***pppfLCLDImag_fx, + Word16 Q_in, + Word16 *Q_out ) +{ + Word32 k, n; + // FILE *ptr = fopen( "cldfb_real.txt", "ab+" ); + // FILE *ptr1 = fopen( "cldfb_imag.txt", "ab+" ); + ReadHeaderInformation( &psLCLDDecoder->iNumBands, pBits ); + + IF( EQ_32( psLCLDDecoder->iChannels, 2 ) ) + { + ReadMSInformation( psLCLDDecoder->iNumBands, &psLCLDDecoder->iMSMode, psLCLDDecoder->piMSFlags, psLCLDDecoder->piLRPhaseDiffs, psLCLDDecoder->piMSPredCoefs, pBits ); + } + + Word16 i, j; + + ReadPredictors_fx( psLCLDDecoder->psPredictionDecoder, pBits ); + + UpdateDecodingUnresolved( psLCLDDecoder->psPredictionDecoder ); + UpdateDecodingFailedStatus( psLCLDDecoder->psPredictionDecoder ); + + ReadGroupInformation( psLCLDDecoder->iChannels, psLCLDDecoder->iNumBlocks, &psLCLDDecoder->iCommonGrouping, psLCLDDecoder->piNumGroups, psLCLDDecoder->ppiGroupLengths, pBits ); + + ReadRMSEnvelope( psLCLDDecoder->iChannels, (const Word32 *) psLCLDDecoder->piNumGroups, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiRMSEnvelope, pBits ); + + + ReadAllocInformation( &psLCLDDecoder->iAllocOffset, pBits ); + + IF( EQ_32( psLCLDDecoder->iChannels, 2 ) && EQ_32( psLCLDDecoder->iCommonGrouping, 1 ) ) + { /* MS Mode? */ + FOR( k = 0; k < psLCLDDecoder->piNumGroups[0]; k++ ) + { + PerceptualModelStereo_fx( psLCLDDecoder->iNumBands, psLCLDDecoder->piMSFlags, + psLCLDDecoder->pppiRMSEnvelope[0][k], + psLCLDDecoder->pppiRMSEnvelope[1][k], + psLCLDDecoder->pppiExcitation[0][k], + psLCLDDecoder->pppiExcitation[1][k], + psLCLDDecoder->pppiSMR[0][k], + psLCLDDecoder->pppiSMR[1][k] ); + } + } + ELSE + { + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { /* This will be updated to support multiple sample rates*/ + FOR( k = 0; k < psLCLDDecoder->piNumGroups[n]; k++ ) + { + PerceptualModel_fx( (Word16) psLCLDDecoder->iNumBands, psLCLDDecoder->pppiRMSEnvelope[n][k], psLCLDDecoder->pppiExcitation[n][k], psLCLDDecoder->pppiSMR[n][k] ); + } + } + } + + ComputeAllocation( psLCLDDecoder->iChannels, (const Word32 *) psLCLDDecoder->piNumGroups, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiSMR, psLCLDDecoder->iAllocOffset, psLCLDDecoder->pppiAlloc ); + + ReadLCLDData_fx( + psLCLDDecoder->piNumGroups, + psLCLDDecoder->ppiGroupLengths, + psLCLDDecoder->iNumBands, + psLCLDDecoder->iChannels, + psLCLDDecoder->psPredictionDecoder->ppiDecodingUnresolved, + psLCLDDecoder->psPredictionDecoder->ppiPredBandEnable, + psLCLDDecoder->psPredictionDecoder->iNumSubSets, + psLCLDDecoder->psPredictionDecoder->iSubSetId, + psLCLDDecoder->pppiAlloc, + psLCLDDecoder->pppiLCLDSignReal, + psLCLDDecoder->pppiLCLDSignImag, + psLCLDDecoder->pppiQLCLDReal, + psLCLDDecoder->pppiQLCLDImag, + psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed, + pBits, + psLCLDDecoder->c_apauiHuffDecTable_RAM ); + Word16 q_LCLD = Q_in; + + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + InvQuantizeSpectrum_fx( psLCLDDecoder->piNumGroups[n], + (const Word32 *) psLCLDDecoder->ppiGroupLengths[n], + psLCLDDecoder->iNumBands, psLCLDDecoder->piBandwidths, + psLCLDDecoder->pppiAlloc[n], + psLCLDDecoder->pppiQLCLDReal[n], + psLCLDDecoder->pppiQLCLDImag[n], + pppfLCLDReal_fx[n], pppfLCLDImag_fx[n], + psLCLDDecoder->psNoiseGen ); + + ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, + psLCLDDecoder->pppiLCLDSignReal[n], + psLCLDDecoder->pppiLCLDSignImag[n], + pppfLCLDReal_fx[n], pppfLCLDImag_fx[n], psLCLDDecoder->piBandwidths ); + } +#ifdef DEBUG_WRITE_PREDICTORS + { + static FILE *fid; + if ( !fid ) + fid = fopen( "pred_dec.txt", "wt" ); + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + int16_t b; + for ( b = 0; b < 60; b++ ) + fprintf( fid, "%.5f ", (float) psLCLDDecoder->psPredictionDecoder->ppiPredBandEnable[n][b] * psLCLDDecoder->psPredictionDecoder->ppfA1Imag[n][b] ); + } + fprintf( fid, "%d %d\n", psLCLDDecoder->psPredictionDecoder->iSubSetId, psLCLDDecoder->psPredictionDecoder->piPredChanEnable[n] ); + } +#endif + + ApplyInversePredictors_fx( psLCLDDecoder->psPredictionDecoder, pppfLCLDReal_fx, pppfLCLDImag_fx ); + +#ifdef DEBUG_WRITE + FOR( n = 0; n < psLCLDDecoder->psPredictionDecoder->iChannels; ++n ) + { + FOR( Word16 i = 0; i < psLCLDDecoder->iNumBlocks; i++ ) + { + dbgwrite_txt( pppfLCLDReal[n][i], LCLD_BANDS, "LCLD_real_ApplyInversePredictors_fix.txt", NULL ); + dbgwrite_txt( pppfLCLDImag[n][i], LCLD_BANDS, "LCLD_imag_ApplyInversePredictors_fix.txt", NULL ); + } + } + + FOR( i = 0; i < psLCLDDecoder->psPredictionDecoder->iChannels; ++i ) + { + dbgwrite_txt( psLCLDDecoder->psPredictionDecoder->ppfPredStateReal[i], LCLD_BANDS, "LCLD_Pred_stat_real_ApplyInversePredictors_fix.txt", NULL ); + dbgwrite_txt( psLCLDDecoder->psPredictionDecoder->ppfPredStateImag[i], LCLD_BANDS, "LCLD_Pred_stat_imag_ApplyInversePredictors_fix.txt", NULL ); + } + +#endif + + Word16 Q = 7; + *Q_out = Q; + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + pppfLCLDReal_fx[n][i][j] = L_shl( pppfLCLDReal_fx[n][i][j], Q - q_LCLD ); + pppfLCLDImag_fx[n][i][j] = L_shl( pppfLCLDImag_fx[n][i][j], Q - q_LCLD ); + } + } + ApplyRMSEnvelope_fx( psLCLDDecoder->iNumBands, psLCLDDecoder->piBandwidths, + psLCLDDecoder->piNumGroups[n], + (const Word32 *) psLCLDDecoder->ppiGroupLengths[n], + psLCLDDecoder->pppiRMSEnvelope[n], + pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] ); + } + + IF( EQ_32( psLCLDDecoder->iChannels, 2 ) && GT_32( psLCLDDecoder->iMSMode, 0 ) ) + { + Word16 exp1 = Q31 - *Q_out; + Word16 exp2 = Q31 - *Q_out; + Word32 real_max = 0; + Word32 imag_max = 0; + Word16 exp; + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( i = 0; i < psLCLDDecoder->iNumBlocks; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + real_max = L_max( real_max, L_abs( pppfLCLDReal_fx[n][i][j] ) ); + imag_max = L_max( imag_max, L_abs( pppfLCLDImag_fx[n][i][j] ) ); + } + } + } + IF( NE_32( real_max, 0 ) ) + { + exp1 = s_min( exp1, norm_l( real_max ) ); + } + IF( NE_32( imag_max, 0 ) ) + { + exp2 = s_min( exp2, norm_l( imag_max ) ); + } + IF( NE_32( real_max, 0 ) || NE_32( imag_max, 0 ) ) + { + exp = min( exp2, exp1 ); + *Q_out = add( *Q_out, sub( exp, 3 ) ); + FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + FOR( i = 0; i < psLCLDDecoder->iNumBlocks; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + pppfLCLDReal_fx[n][i][j] = L_shl( pppfLCLDReal_fx[n][i][j], exp - 3 ); + pppfLCLDImag_fx[n][i][j] = L_shl( pppfLCLDImag_fx[n][i][j], exp - 3 ); + } + } + } + } + InvMSCoding_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, + psLCLDDecoder->piBandwidths, psLCLDDecoder->iMSMode, + (const Word32 *) psLCLDDecoder->piMSFlags, + (const Word32 *) psLCLDDecoder->piLRPhaseDiffs, + (const Word32 *) psLCLDDecoder->piMSPredCoefs, + pppfLCLDReal_fx, pppfLCLDImag_fx ); + +#ifdef DEBUG_WRITE + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + Word32 pppfLCLDReal_dbg[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 pppfLCLDImag_dbg[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + for ( i = 0; i < psLCLDDecoder->iNumBlocks; i++ ) + { + for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + pppfLCLDReal_dbg[n][i][j] = (float) pppfLCLDReal_fx[n][i][j] / ( 1 << ( exp - 3 ) ); + pppfLCLDImag_dbg[n][i][j] = (float) pppfLCLDImag_fx[n][i][j] / ( 1 << ( exp - 3 ) ); + } + } + { + for ( Word16 i = 0; i < psLCLDDecoder->iNumBlocks; i++ ) + { + dbgwrite_txt( pppfLCLDReal_dbg[n][i], CLDFB_NO_CHANNELS_MAX, "LCLD_real_Inv_MS.txt", NULL ); + dbgwrite_txt( pppfLCLDImag_dbg[n][i], CLDFB_NO_CHANNELS_MAX, "LCLD_imag_Inv_MS.txt", NULL ); + } + } + } +#endif + } + IF( EQ_32( psLCLDDecoder->iRealOnlyOut, 1 ) ) + { + UnpackReal_fx( psLCLDDecoder->iChannels, + psLCLDDecoder->iNumBlocks * 2, + pppfLCLDReal_fx, + pppfLCLDImag_fx ); + } + + return AnyDecodingUnresolved( psLCLDDecoder->psPredictionDecoder ); +} +/*------------------------------------------------------------------------------------------* + * Local functions + * + * + *------------------------------------------------------------------------------------------*/ +static void ApplyRMSEnvelope_fx( + const Word32 iNumBands, + const Word32 *piBandwidths, + const Word32 iNumGroups, + const Word32 *piGroupLengths, + Word32 **ppiRMSEnvelope, + Word32 **ppfReal_fx, + Word32 **ppfImag_fx ) +{ + Word32 b, k, n; + +#ifdef DEBUG + FILE *fp_real, *fp_imag, *fp_real_fx, *fp_imag_fx, *fp_real_inp, *fp_imag_inp, *fp_real_inp_fx, *fp_imag_inp_fx; + fp_real = fopen( "Float_code_real1.txt", "ab+" ); + fp_imag = fopen( "Float_code_imag1.txt", "ab+" ); + fp_real_fx = fopen( "Fixed_code_real1.txt", "ab+" ); + fp_imag_fx = fopen( "Fixed_code_imag1.txt", "ab+" ); + fp_real_inp = fopen( "real_input.txt", "ab+" ); + fp_imag_inp = fopen( "imag_input.txt", "ab+" ); +#endif + + Word32 iBlockOffset, iFBOffset; + + iBlockOffset = 0; + FOR( n = 0; n < iNumGroups; n++ ) + { + FOR( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 m; + Word32 iRMSEnv; + Word32 fGain_fx; + Word16 fGain_exp; + + iRMSEnv = ppiRMSEnvelope[n][b]; + IF( ( ENV_RECONSTRUCT_TABLE_CENTER + iRMSEnv ) % 2 == 0 ) + { + fGain_fx = 1073741824; // 2 ^ 30 + } + ELSE + { + fGain_fx = 1518500249; // sqrt(2) * 2 ^ 30 + } + fGain_exp = c_afRMSEnvReconstructTable_exp[ENV_RECONSTRUCT_TABLE_CENTER + iRMSEnv]; + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + Word64 tmp; +#ifdef DEBUG + fprintf( fp_real_inp, "%.6f\n", ppfReal[iBlockOffset][iFBOffset] ); + fprintf( fp_imag_inp, "%.6f\n", ppfImag[iBlockOffset][iFBOffset] ); +#endif + +#ifdef DEBUG + fprintf( fp_real, "%.6f\n", ppfReal[iBlockOffset][iFBOffset] ); + fprintf( fp_imag, "%.6f\n", ppfImag[iBlockOffset][iFBOffset] ); +#endif + tmp = W_mult_32_32( fGain_fx, ppfReal_fx[iBlockOffset][iFBOffset] ); + tmp = W_shr( tmp, fGain_exp + 1 ); + ppfReal_fx[iBlockOffset][iFBOffset] = W_extract_l( tmp ); + + tmp = W_mult_32_32( fGain_fx, ppfImag_fx[iBlockOffset][iFBOffset] ); + tmp = W_shr( tmp, fGain_exp + 1 ); + ppfImag_fx[iBlockOffset][iFBOffset] = W_extract_l( tmp ); + +#ifdef DEBUG + fprintf( fp_real_fx, "%.6f\n", (float) ppfReal_fx[iBlockOffset][iFBOffset] / ( 1 << Q ) ); + fprintf( fp_imag_fx, "%.6f\n", (float) ppfImag_fx[iBlockOffset][iFBOffset] / ( 1 << Q ) ); +#endif + + iFBOffset++; + } + } + iBlockOffset++; + } + } +#ifdef DEBUG + fclose( fp_real ); + fclose( fp_imag ); + fclose( fp_imag_fx ); + fclose( fp_real_fx ); + fclose( fp_real_inp ); + fclose( fp_imag_inp ); +#endif + + return; +} + +static void ReplaceSign_fx( + const Word32 iNumBlocks, + const Word32 iNumLCLDBands, + Word32 **ppiSignReal, + Word32 **ppiSignImag, + Word32 **ppfReal, + Word32 **ppfImag, + const Word32 *piBandwidths ) +{ + Word32 b, n; + Word32 m, idx; + + FOR( n = 0; n < iNumBlocks; n++ ) + { + idx = 0; + move32(); + FOR( b = 0; b < iNumLCLDBands; b++ ) + { + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + IF( EQ_32( ppiSignReal[n][idx], 1 ) ) + { + ppfReal[n][idx] = L_negate( ppfReal[n][idx] ); + move32(); + } + + IF( EQ_32( ppiSignImag[n][idx], 1 ) ) + { + ppfImag[n][idx] = L_negate( ppfImag[n][idx] ); + move32(); + } + idx++; + } + } + } + return; +} + +static void InvQuantizeSpectrum_fx( + const Word32 iNumGroups, + const Word32 *piGroupLengths, + const Word32 iNumBands, + const Word32 *piBandwidths, + Word32 **ppiAlloc, + Word32 **ppiQReal, + Word32 **ppiQImag, + Word32 **ppfReal, + Word32 **ppfImag, + NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ +) +{ + Word32 b, k, n; + Word32 iBlockOffest, iFBOffset; + + iBlockOffest = 0; + move32(); + FOR( n = 0; n < iNumGroups; n++ ) + { + FOR( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 m; + Word32 iAlloc; + Word32 fInvSCFGain; + + iAlloc = ppiAlloc[n][b]; + move32(); + fInvSCFGain = c_afInvScaleFactor_fx[iAlloc]; // Q29 + move32(); + IF( GT_32( iAlloc, 0 ) ) + { + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + Word16 iQuantValue; + + iQuantValue = (Word16) ppiQReal[iBlockOffest][iFBOffset]; + move16(); + ppfReal[iBlockOffest][iFBOffset] = Mpy_32_16_1( fInvSCFGain, iQuantValue ); // Q14 + move32(); + iQuantValue = (Word16) ppiQImag[iBlockOffest][iFBOffset]; + move16(); + ppfImag[iBlockOffest][iFBOffset] = Mpy_32_16_1( fInvSCFGain, iQuantValue ); // Q14 + move32(); + iFBOffset++; + } + } + ELSE IF( psNoiseGen != NULL ) + { + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + ppfReal[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14 + 15 -15 )=Q14 + move32(); + ppfImag[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14+ 15 -15 )=Q14 + move32(); + iFBOffset++; + } + } + ELSE + { + iFBOffset = L_add( iFBOffset, piBandwidths[b] ); + move32(); + } + } + + iBlockOffest++; + } + } + + return; +} + +static void InvMSCoding_fx( + const Word32 iNumBlocks, + const Word32 iNumBands, + const Word32 *piBandwidths, + const Word32 iMSMode, + const Word32 *piMSFlags, + const Word32 *piLRPhaseDiffs, + const Word32 *piMSPredCoefs, + Word32 ***pppfReal, + Word32 ***pppfImag ) +{ + + IF( GT_32( iMSMode, 0 ) ) + { + Word32 b; + Word32 iFBOffset; + Word32 bMSPred = 0; + move32(); + + iFBOffset = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + IF( EQ_32( piMSFlags[b], 1 ) ) + { + Word32 n; + Word32 phaseIdx; + + Word32 fPred; + + phaseIdx = piLRPhaseDiffs[bMSPred] - PHASE_MIN_VAL; + move32(); + fPred = dequantPred_fx( piMSPredCoefs[bMSPred] ); + move32(); + FOR( n = 0; n < piBandwidths[b]; n++ ) + { + Word32 k; + FOR( k = 0; k < iNumBlocks; k++ ) + { + Word32 fLeftReal; + Word32 fLeftImag; + Word32 fRightReal; + Word32 fRightImag; + + IF( EQ_32( iMSMode, 3 ) ) + { + pppfReal[1][k][iFBOffset] = L_add( pppfReal[1][k][iFBOffset], Mpy_32_32( fPred, pppfReal[0][k][iFBOffset] ) ); + move32(); + pppfImag[1][k][iFBOffset] = L_add( pppfImag[1][k][iFBOffset], Mpy_32_32( fPred, pppfImag[0][k][iFBOffset] ) ); + move32(); + } + + fLeftReal = L_add( pppfReal[0][k][iFBOffset], pppfReal[1][k][iFBOffset] ); + fLeftImag = L_add( pppfImag[0][k][iFBOffset], pppfImag[1][k][iFBOffset] ); + fRightReal = L_sub( pppfReal[0][k][iFBOffset], pppfReal[1][k][iFBOffset] ); + fRightImag = L_sub( pppfImag[0][k][iFBOffset], pppfImag[1][k][iFBOffset] ); + + IF( EQ_32( iMSMode, 3 ) ) + { + cplxmult_fx( &fRightReal, &fRightImag, c_afRotRealImag_fx[phaseIdx][0], -c_afRotRealImag_fx[phaseIdx][1] ); + } + + pppfReal[0][k][iFBOffset] = fLeftReal; + move32(); + pppfReal[1][k][iFBOffset] = fRightReal; + move32(); + pppfImag[0][k][iFBOffset] = fLeftImag; + move32(); + pppfImag[1][k][iFBOffset] = fRightImag; + move32(); + } + iFBOffset++; + } + bMSPred++; + } + ELSE + { + iFBOffset = L_add( iFBOffset, piBandwidths[b] ); + move32(); + } + } + } + + return; +} + +/* Currently only the number of bands in frame */ +static Word32 ReadHeaderInformation( + Word32 *piNumBands, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsRead; + + iBitsRead = 0; + move32(); + *piNumBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 5 ); + iBitsRead = L_add( iBitsRead, 5 ); + + return iBitsRead; +} + + +static Word32 ReadMSInformation( + const Word32 iNumBands, + Word32 *piMSMode, + Word32 *piMSFlags, + Word32 *piLRPhaseDiffs, + Word32 *piMSPredCoefs, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsRead; + + iBitsRead = 0; + move32(); + *piMSMode = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 2 ); + iBitsRead = L_add( iBitsRead, 2 ); + + IF( EQ_32( *piMSMode, 0 ) ) + { + Word32 n; + FOR( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = 0; + move32(); + } + } + ELSE IF( EQ_32( *piMSMode, 1 ) ) + { + Word32 n; + FOR( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = 1; + move32(); + } + } + ELSE IF( EQ_32( *piMSMode, 2 ) ) + { + Word32 n; + FOR( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + move32(); + iBitsRead = L_add( iBitsRead, 1 ); + } + } + ELSE IF( EQ_32( *piMSMode, 3 ) ) + { + Word32 n; + Word32 iMSPredAll; + Word32 iNumMSPredBands = 0; + Word32 anyNonZero; + move32(); + iMSPredAll = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead = L_add( iBitsRead, 1 ); + IF( iMSPredAll ) + { + iNumMSPredBands = iNumBands; + move32(); + FOR( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = 1; + move32(); + } + } + ELSE + { + FOR( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + move32(); + iBitsRead = L_add( iBitsRead, 1 ); + IF( piMSFlags[n] ) + { + iNumMSPredBands++; + } + } + } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + IF( anyNonZero ) + { + piLRPhaseDiffs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PHASE_BAND0_BITS ); + move32(); + piLRPhaseDiffs[0] = L_add( piLRPhaseDiffs[0], PHASE_MIN_VAL ); + move32(); + iBitsRead = L_add( iBitsRead, PHASE_BAND0_BITS ); + FOR( n = 1; n < iNumMSPredBands; n++ ) + { + Word32 tabIdx; + iBitsRead = L_add( iBitsRead, ReadHuff( c_aaiRMSEnvHuffDec, &tabIdx, pBits ) ); + piLRPhaseDiffs[n] = L_add( tabIdx, ENV_DELTA_MIN ); + move32(); + } + DecodePhase( piLRPhaseDiffs, iNumMSPredBands, PHASE_DIFF_DIM ); + } + ELSE + { + FOR( n = 0; n < iNumMSPredBands; n++ ) + { + piLRPhaseDiffs[n] = 0; + move32(); + } + } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + IF( anyNonZero ) + { + piMSPredCoefs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_BAND0_BITS ); + move32(); + piMSPredCoefs[0] = L_add( piMSPredCoefs[0], PRED_MIN_VAL ); + move32(); + iBitsRead = L_add( iBitsRead, PRED_BAND0_BITS ); + FOR( n = 1; n < iNumMSPredBands; n++ ) + { + Word32 tabIdx; + iBitsRead = L_add( iBitsRead, ReadHuff( c_aaiRMSEnvHuffDec, &tabIdx, pBits ) ); + piMSPredCoefs[n] = L_add( tabIdx, ENV_DELTA_MIN ); + move32(); + } + DecodePredCoef( piMSPredCoefs, iNumMSPredBands ); + } + ELSE + { + FOR( n = 0; n < iNumMSPredBands; n++ ) + { + piMSPredCoefs[n] = 0; + move32(); + } + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + IF( !fid ) + fid = fopen( "ms_pred_dec.txt", "wt" ); + writeMSPred( piLRPhaseDiffs, piMSPredCoefs, *piMSMode, iNumMSPredBands, iNumBands, fid, piMSFlags ); + } +#endif + } + ELSE + { + printf( "ERROR UNSUPPORTED MS MODE\n" ); + } + + return iBitsRead; +} + +static Word32 ReadGroupInformation( + const Word32 iChannels, + const Word32 iNumBlocks, + Word32 *piCommonGrouping, + Word32 *piNumGroups, + Word32 **ppiGroupLengths, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 c, k, iBitsRead; + + iBitsRead = 0; + move32(); + IF( EQ_32( iChannels, 2 ) ) + { + *piCommonGrouping = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + move32(); + iBitsRead = L_add( iBitsRead, 1 ); + + IF( EQ_32( *piCommonGrouping, 1 ) ) + { + piNumGroups[0] = 0; + move32(); + ppiGroupLengths[0][piNumGroups[0]] = 1; + move32(); + FOR( k = 0; k < L_sub( iNumBlocks, 1 ); k++ ) + { + Word32 iGroupStart; + + iGroupStart = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead = L_add( iBitsRead, 1 ); + + IF( EQ_32( iGroupStart, 1 ) ) + { + piNumGroups[0] = L_add( piNumGroups[0], 1 ); + move32(); + ppiGroupLengths[0][piNumGroups[0]] = 1; + move32(); + } + ELSE + { + ppiGroupLengths[0][piNumGroups[0]] = L_add( ppiGroupLengths[0][piNumGroups[0]], 1 ); + move32(); + } + } + piNumGroups[0] = L_add( piNumGroups[0], 1 ); + move32(); + + piNumGroups[1] = piNumGroups[0]; + move32(); + FOR( k = 0; k < piNumGroups[1]; k++ ) + { + ppiGroupLengths[1][k] = ppiGroupLengths[0][k]; + move32(); + } + } + ELSE + { + FOR( c = 0; c < iChannels; c++ ) + { + piNumGroups[c] = 0; + move32(); + ppiGroupLengths[c][piNumGroups[c]] = 1; + move32(); + FOR( k = 0; k < L_sub( iNumBlocks, 1 ); k++ ) + { + Word32 iGroupStart; + + iGroupStart = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead = L_add( iBitsRead, 1 ); + + IF( EQ_32( iGroupStart, 1 ) ) + { + piNumGroups[c] = L_add( piNumGroups[c], 1 ); + move32(); + ppiGroupLengths[c][piNumGroups[c]] = 1; + move32(); + } + ELSE + { + ppiGroupLengths[c][piNumGroups[c]] = L_add( ppiGroupLengths[c][piNumGroups[c]], 1 ); + move32(); + } + } + piNumGroups[c] = L_add( piNumGroups[c], 1 ); + move32(); + } + } + } + ELSE + { + FOR( c = 0; c < iChannels; c++ ) + { + piNumGroups[c] = 0; + move32(); + ppiGroupLengths[c][piNumGroups[c]] = 1; + move32(); + FOR( k = 0; k < L_sub( iNumBlocks, 1 ); k++ ) + { + Word32 iGroupStart; + + iGroupStart = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead = L_add( iBitsRead, 1 ); + + IF( EQ_32( iGroupStart, 1 ) ) + { + piNumGroups[c] = L_add( piNumGroups[c], 1 ); + move32(); + ppiGroupLengths[c][piNumGroups[c]] = 1; + move32(); + } + ELSE + { + ppiGroupLengths[c][piNumGroups[c]] = L_add( ppiGroupLengths[c][piNumGroups[c]], 1 ); + } + } + piNumGroups[c] = L_add( piNumGroups[c], 1 ); + } + } + + return iBitsRead; +} + +static Word32 BSForceBack( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word32 iValue, + Word32 iBitCount ) +{ + pBits->bits_read = L_sub( pBits->bits_read, iBitCount ); + + return ( L_shr( iValue, (Word16) iBitCount ) ); +} + + +static Word32 ReadHuff( + const UWord32 ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], + Word32 *piSymbol, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsRead; + Word32 iSymbol; + Word32 iIndex; + Word32 iVal; + + iVal = 0; + move32(); + iIndex = 0; + move32(); + iSymbol = 0xFFFF; + move32(); + iBitsRead = 0; + move32(); + WHILE( iSymbol == 0xFFFF ) + { + iIndex = ISAR_SPLIT_REND_BITStream_read_int32( pBits, HUFF_READ_SIZE ); + iBitsRead = L_add( iBitsRead, HUFF_READ_SIZE ); + + iIndex = pauiHuffDecTable[iVal][iIndex]; + iSymbol = ( L_and( iIndex, 0xFFFF ) ); + + iVal = ( L_shr( iIndex, 16 ) ); + } + + IF( iVal ) + { + BSForceBack( pBits, iIndex, iVal ); + iBitsRead = L_sub( iBitsRead, iVal ); + } + + *piSymbol = iSymbol; + move32(); + + return iBitsRead; +} + + +static Word32 ReadRMSEnvelope( + const Word32 iChannels, + const Word32 *piNumGroups, + const Word32 iNumBands, + Word32 ***pppiRMSEnvelope, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 b, k, n; + Word32 iBitsRead, iLastRMSVal; + + iBitsRead = 0; + move32(); + FOR( n = 0; n < iChannels; n++ ) + { + FOR( k = 0; k < piNumGroups[n]; k++ ) + { + iLastRMSVal = ISAR_SPLIT_REND_BITStream_read_int32( pBits, ENV0_BITS ); + iBitsRead = L_add( iBitsRead, ENV0_BITS ); + + iLastRMSVal = L_add( iLastRMSVal, ENV_MIN ); + pppiRMSEnvelope[n][k][0] = iLastRMSVal; + move32(); + FOR( b = 1; b < iNumBands; b++ ) + { + Word32 iDelta; + + iBitsRead = L_add( iBitsRead, ReadHuff( c_aaiRMSEnvHuffDec, &iDelta, pBits ) ); + + iDelta = L_add( iDelta, ENV_DELTA_MIN ); + iLastRMSVal = L_add( iDelta, iLastRMSVal ); + pppiRMSEnvelope[n][k][b] = iLastRMSVal; + move32(); + } + } + } + + return iBitsRead; +} + + +static Word32 ReadAllocInformation( + Word32 *piAllocOffset, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsRead; + + iBitsRead = 0; + move32(); + *piAllocOffset = ISAR_SPLIT_REND_BITStream_read_int32( pBits, ALLOC_OFFSET_BITS ); + *piAllocOffset = L_add( *piAllocOffset, MIN_ALLOC_OFFSET ); + iBitsRead = L_add( iBitsRead, ALLOC_OFFSET_BITS ); + + return iBitsRead; +} + +static Word32 ReadLCLDData_fx( + const Word32 *piNumGroups, + Word32 **ppiGroupLengths, + const Word32 iNumBands, + const Word32 iNumChannels, + Word32 **ppiDecodingUnresolved, + Word32 **ppiPredEnable, + const Word32 iNumSubSets, + const Word32 iSubSetId, + Word32 ***pppiAlloc, + Word32 ***pppiSignReal, + Word32 ***pppiSignImag, + Word32 ***pppiQReal, + Word32 ***pppiQImag, + Word32 **ppiDecodingFailed, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + UWord32 ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ) +{ + Word32 iBitsRead; + Word32 iDecodingStopped = 0; + Word32 iNumLcldBands = c_aiNumLcldBandsPerBand[iNumBands - 1]; + Word32 s; + Word32 iSet = iSubSetId; + Word16 tmp, tmp_e; + iBitsRead = 0; + for ( s = 0; s < iNumSubSets; s++, iSet-- ) + { + Word32 ch; + + IF( LT_32( iSet, 0 ) ) + { + iSet = L_sub( iNumSubSets, 1 ); + } + + FOR( ch = 0; ch < iNumChannels; ch++ ) + { + Word32 n; + Word32 iBlockOffest; + + IF( EQ_32( ppiDecodingUnresolved[ch][iSet], 1 ) ) + { + iDecodingStopped = 1; + ppiDecodingFailed[ch][iSet] = 1; /* mark as not decoded (is also initialized like that when a frame is lost */ + } + ELSE + { + ppiDecodingFailed[ch][iSet] = 0; /* mark as correctly decoded */ + } + iBlockOffest = 0; + FOR( n = 0; n < piNumGroups[ch]; n++ ) + { + Word32 k; + FOR( k = 0; k < ppiGroupLengths[ch][n]; k++ ) + { + Word32 iFBOffset; + + FOR( iFBOffset = iSet; iFBOffset < iNumLcldBands; iFBOffset += iNumSubSets ) + { + Word32 b; + Word32 iAlloc; + Word32 iHuffDim; + Word32 iHuffMod; + + b = c_aiBandIdPerLcldBand[iFBOffset]; + + iAlloc = pppiAlloc[ch][n][b]; + + iHuffDim = c_aiHuffmanDim_fx[iAlloc]; + iHuffMod = c_aiHuffmanMod_fx[iAlloc]; + + IF( EQ_32( iDecodingStopped, 1 ) ) + { + pppiQReal[ch][iBlockOffest][iFBOffset] = 0; + pppiQImag[ch][iBlockOffest][iFBOffset] = 0; + pppiSignReal[ch][iBlockOffest][iFBOffset] = 0; + pppiSignImag[ch][iBlockOffest][iFBOffset] = 0; + } + ELSE IF( GT_32( iAlloc, 0 ) ) + { + const UWord32( *pauiHuffmanTable )[HUFF_DEC_TABLE_SIZE] = NULL; + const UWord32( *pauiHuffmanTableDPCM )[HUFF_DEC_TABLE_SIZE] = NULL; + Word32 iQuantValue1 = 0; + Word32 iQuantValue2 = 0; +#ifdef USE_DEMOD_TABLES + const int32_t( *paiDemodTable )[2] = NULL; +#endif + pauiHuffmanTable = (const UWord32( * )[HUFF_DEC_TABLE_SIZE]) c_apauiHuffDecTables[iAlloc]; + pauiHuffmanTableDPCM = (const UWord32( * )[HUFF_DEC_TABLE_SIZE]) c_apauiHuffDecTables[ALLOC_TABLE_SIZE + iAlloc]; +#ifdef USE_DEMOD_TABLES + paiDemodTable = c_apaiDemodTables[iAlloc]; +#endif +#ifdef LCLD_HANDLE_PRED_START_SAMPLE + if ( ppiPredEnable[ch][iFBOffset] == 1 && ( iBlockOffest > 0 || iSet != iSubSetId ) ) +#else + IF( EQ_32( ppiPredEnable[ch][iFBOffset], 1 ) ) +#endif + { + IF( EQ_32( iHuffDim, 2 ) ) + { + Word32 iSymbol; + iBitsRead = L_add( iBitsRead, ReadHuff( pauiHuffmanTableDPCM, &iSymbol, pBits ) ); +#ifdef USE_DEMOD_TABLES + iQuantValue1 = paiDemodTable[iSymbol][0]; + iQuantValue2 = paiDemodTable[iSymbol][1]; +#else + tmp = BASOP_Util_Divide1616_Scale( (Word16) iSymbol, (Word16) iHuffMod, &tmp_e ); + iQuantValue1 = L_deposit_l( shr( tmp, add( 15, negate( tmp_e ) ) ) ); + // iQuantValue1 = iSymbol / iHuffMod; + iQuantValue2 = iSymbol % iHuffMod; +#endif + } + ELSE + { + iBitsRead = L_add( iBitsRead, ReadHuff( pauiHuffmanTableDPCM, &iQuantValue1, pBits ) ); + iBitsRead = L_add( iBitsRead, ReadHuff( pauiHuffmanTableDPCM, &iQuantValue2, pBits ) ); + } + } + ELSE + { + IF( EQ_32( iHuffDim, 2 ) ) + { + Word32 iSymbol; + + iBitsRead = L_add( iBitsRead, ReadHuff( pauiHuffmanTable, &iSymbol, pBits ) ); +#ifdef USE_DEMOD_TABLES + iQuantValue1 = paiDemodTable[iSymbol][0]; + iQuantValue2 = paiDemodTable[iSymbol][1]; +#else + tmp = BASOP_Util_Divide1616_Scale( (Word16) iSymbol, (Word16) iHuffMod, &tmp_e ); + iQuantValue1 = L_deposit_l( shr( tmp, add( 15, negate( tmp_e ) ) ) ); + iQuantValue2 = iSymbol % iHuffMod; +#endif + } + ELSE + { + iBitsRead = L_add( iBitsRead, ReadHuff( pauiHuffmanTable, &iQuantValue1, pBits ) ); + move32(); + iBitsRead = L_add( iBitsRead, ReadHuff( pauiHuffmanTable, &iQuantValue2, pBits ) ); + move32(); + /*iBitsRead += ReadHuff( pauiHuffmanTable, &iQuantValue1, pBits ); + iBitsRead += ReadHuff( pauiHuffmanTable, &iQuantValue2, pBits );*/ + } + } + + pppiQReal[ch][iBlockOffest][iFBOffset] = iQuantValue1; + move32(); + pppiQImag[ch][iBlockOffest][iFBOffset] = iQuantValue2; + move32(); + IF( GT_32( iQuantValue1, 0 ) ) + { + pppiSignReal[ch][iBlockOffest][iFBOffset] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + move32(); + iBitsRead = L_add( iBitsRead, 1 ); + move32(); + } + ELSE + { + pppiSignReal[ch][iBlockOffest][iFBOffset] = 0; + } + IF( GT_32( iQuantValue2, 0 ) ) + { + pppiSignImag[ch][iBlockOffest][iFBOffset] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + move32(); + iBitsRead = L_add( iBitsRead, 1 ); + move32(); + } + ELSE + { + pppiSignImag[ch][iBlockOffest][iFBOffset] = 0; + } + } + ELSE + { + pppiSignReal[ch][iBlockOffest][iFBOffset] = 0; + move32(); + pppiSignImag[ch][iBlockOffest][iFBOffset] = 0; + move32(); + } + } + iBlockOffest++; + } + } + } + } + + return iBitsRead; +} + +static void ComputeAllocation( + const Word32 iChannels, + const Word32 *piNumGroups, + const Word32 iNumBands, + Word32 ***pppiSMR, + const Word32 iAllocOffset, + Word32 ***pppiAlloc ) +{ + Word32 b, k, n, iAlloc; + + FOR( n = 0; n < iChannels; n++ ) + { + FOR( k = 0; k < piNumGroups[n]; k++ ) + { + FOR( b = 0; b < iNumBands; b++ ) + { + iAlloc = L_shr( L_add( pppiSMR[n][k][b], L_mult0( (Word16) iAllocOffset, ALLOC_OFFSET_SCALE ) ), 5 ); + iAlloc = ( iAlloc > MIN_ALLOC ) ? iAlloc : MIN_ALLOC; + iAlloc = ( iAlloc < MAX_ALLOC ) ? iAlloc : MAX_ALLOC; + pppiAlloc[n][k][b] = iAlloc; + move32(); + } + } + } + + return; +} + +#endif diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c new file mode 100644 index 000000000..aa9332c26 --- /dev/null +++ b/lib_isar/isar_lcld_encoder.c @@ -0,0 +1,2143 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include +#include "isar_lcld_prot.h" +#include "isar_lcld_rom_tables.h" +#include "prot.h" +#include "prot_fx2.h" +#include "isar_prot.h" +#include "wmc_auto.h" +#include "basop_util.h" +#include "enh64.h" +#include "basop32.h" +#include "basop_mpy.h" + +#define LOG10_2_FX ( 646456993 ) +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ +struct LCLD_ENCODER +{ + Word32 iSampleRate; + Word32 iChannels; + Word32 iNumBlocks; + + Word32 iTargetBitRate; + + Word32 iNumBands; + const Word32 *piBandwidths; + + Word32 iMSMode; + Word32 *piMSFlags; + Word32 piMSPredCoefs[MAX_BANDS]; + Word32 piLRPhaseDiffs[MAX_BANDS]; + Word32 iAllowSidePred; + + Word32 iRealOnlyOut; + + RMSEnvelopeGrouping *psRMSEnvelopeGrouping; + + Word32 iCommonGrouping; + Word32 *piNumGroups; + Word32 **ppiGroupLengths; + + Word32 ***pppiRMSEnvelope; + Word32 ***pppiSMR; + Word32 ***pppiExcitation; + Word32 ***pppiAlloc; + + Word32 iAllocOffset; + + Word32 ***pppiLCLDSignReal; + Word32 ***pppiLCLDSignImag; + Word32 ***pppiQLCLDReal; + Word32 ***pppiQLCLDImag; + + + PredictionEncoder *psPredictionEncoder; +}; +/*------------------------------------------------------------------------------------------* + * Function Quantize() + * + * + *------------------------------------------------------------------------------------------*/ +static Word32 Quantize_fx( + const Word32 fVal_fx, + const Word32 fScale_fx, + Word32 *iSign, + const Word32 iMaxVal ) +{ + Word32 iVal_fx; + IF( GT_32( fVal_fx, 0 ) ) + { + iVal_fx = (Word32) L_add( Mpy_32_32( fScale_fx, fVal_fx ), ONE_IN_Q20 ); + *iSign = 0; + } + ELSE + { + iVal_fx = (Word32) L_add( Mpy_32_32( -fScale_fx, fVal_fx ), ONE_IN_Q20 ); + *iSign = 1; + } + iVal_fx = ( iVal_fx < iMaxVal ) ? iVal_fx : iMaxVal; + + return iVal_fx; +} +/*------------------------------------------------------------------------------------------* + * Function UnQuantize() + * + * + *------------------------------------------------------------------------------------------*/ +static Word32 UnQuantize_fx( + const Word32 iVal_fx, + const Word32 fScale_fx, + const Word32 iSign ) +{ + + Word32 fVal_fx; + IF( EQ_32( iSign, 0 ) ) + { + fVal_fx = Mpy_32_32( fScale_fx, iVal_fx ); // Q19 + } + ELSE + { + fVal_fx = Mpy_32_32( -fScale_fx, iVal_fx ); // Q19 + } + return fVal_fx; +} +static void PackReal( + const Word32 iChannels, + const Word32 iNumBlocks, + Word32 ***pppfReal, + Word32 ***pppfImag ) +{ + Word32 ch, b, n; + FOR( ch = 0; ch < iChannels; ch++ ) + { + FOR( b = 0; b < LCLD_BANDS; b++ ) + { + Word32 iRealBlock = 0; + move32(); + FOR( n = 0; n < iNumBlocks; n += 2 ) + { + pppfImag[ch][iRealBlock][b] = pppfReal[ch][n + 1][b]; + move32(); + pppfReal[ch][iRealBlock][b] = pppfReal[ch][n][b]; + move32(); + iRealBlock++; + } + } + } +} +/*------------------------------------------------------------------------------------------* + * Function CreateLCLDEncoder() + * + * + *------------------------------------------------------------------------------------------*/ + +ivas_error CreateLCLDEncoder( + LCLDEncoder **psLCLDEncoder_out, + const Word32 iSampleRate, + const Word32 iChannels, + const Word32 iTargetBitRate, + const Word32 iAllowSidePred, + const Word16 iNumBlocks, + const Word16 iNumSubSets, + const Word32 iRealOnlyOut ) +{ + Word32 n; + LCLDEncoder *psLCLDEncoder; + ivas_error error; + Word32 iMaxNumPredBands = 0; + move32(); + + assert( iSampleRate == 48000 ); // Fix + assert( iNumBlocks == 16 || iNumBlocks == 8 || iNumBlocks == 4 ); + assert( iNumSubSets > 0 && iNumSubSets <= LCLD_MAX_NUM_PRED_SUBSETS ); + + IF( ( psLCLDEncoder = (LCLDEncoder *) malloc( sizeof( LCLDEncoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + psLCLDEncoder->iSampleRate = iSampleRate; + move32(); + psLCLDEncoder->iChannels = iChannels; + move32(); + psLCLDEncoder->iRealOnlyOut = iRealOnlyOut; + move32(); + psLCLDEncoder->iAllocOffset = 0; + move32(); + + psLCLDEncoder->iTargetBitRate = iTargetBitRate; + move32(); + + psLCLDEncoder->piBandwidths = c_aiBandwidths48; + psLCLDEncoder->iNumBands = DEF_BANDS_48; /* 22 bands = 50 CLDFB bands (rather than 23 bands) */ + move32(); + iMaxNumPredBands = L_min( c_aiNumLcldBandsPerBand[psLCLDEncoder->iNumBands - 1], 50 ); + IF( EQ_32( iRealOnlyOut, 1 ) ) + { + iMaxNumPredBands = 0; + move32(); + assert( iNumSubSets == 1 ); + psLCLDEncoder->iNumBlocks = L_deposit_l( shr( iNumBlocks, 1 ) ); + } + ELSE + { + psLCLDEncoder->iNumBlocks = iNumBlocks; + move32(); + } + + psLCLDEncoder->iMSMode = 0; + move32(); + IF( ( psLCLDEncoder->piMSFlags = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + FOR( n = 0; n < MAX_BANDS; n++ ) + { + psLCLDEncoder->piLRPhaseDiffs[n] = 0; + move32(); + psLCLDEncoder->piMSPredCoefs[n] = 0; + move32(); + } + psLCLDEncoder->iAllowSidePred = iAllowSidePred; + move32(); + + psLCLDEncoder->psRMSEnvelopeGrouping = CreateRMSEnvelopeGrouping( psLCLDEncoder->iNumBlocks ); + + psLCLDEncoder->iCommonGrouping = 1; //*Common grouping always on only impacts stereo */ + move32(); + IF( ( psLCLDEncoder->piNumGroups = (Word32 *) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->ppiGroupLengths = (Word32 **) malloc( psLCLDEncoder->iChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiRMSEnvelope = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiSMR = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiExcitation = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiAlloc = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + IF( ( psLCLDEncoder->pppiLCLDSignReal = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiLCLDSignImag = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiQLCLDReal = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiQLCLDImag = (Word32 ***) malloc( psLCLDEncoder->iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + FOR( n = 0; n < iChannels; n++ ) + { + Word32 k; + IF( ( psLCLDEncoder->ppiGroupLengths[n] = (Word32 *) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiRMSEnvelope[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiSMR[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiExcitation[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiAlloc[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + IF( ( psLCLDEncoder->pppiLCLDSignReal[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiLCLDSignImag[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiQLCLDReal[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiQLCLDImag[n] = (Word32 **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + IF( ( psLCLDEncoder->pppiRMSEnvelope[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiSMR[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiExcitation[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiAlloc[n][k] = (Word32 *) malloc( MAX_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + IF( ( psLCLDEncoder->pppiLCLDSignReal[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiLCLDSignImag[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiQLCLDReal[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + IF( ( psLCLDEncoder->pppiQLCLDImag[n][k] = (Word32 *) malloc( LCLD_BANDS * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + } + } + + IF( ( error = CreatePredictionEncoder_fx( &( psLCLDEncoder->psPredictionEncoder ), iChannels, psLCLDEncoder->iNumBlocks, L_deposit_l( iNumSubSets ), iMaxNumPredBands ) ) != IVAS_ERR_OK ) + { + return error; + } + + *psLCLDEncoder_out = psLCLDEncoder; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------------------------* + * Function DeleteLCLDEncoder() + * + * + *------------------------------------------------------------------------------------------*/ + +void DeleteLCLDEncoder( + LCLDEncoder *psLCLDEncoder ) +{ + Word32 k, n; + + IF( psLCLDEncoder != NULL ) + { + + IF( psLCLDEncoder->piMSFlags != NULL ) + { + free( psLCLDEncoder->piMSFlags ); + } + + IF( psLCLDEncoder->piNumGroups != NULL ) + { + free( psLCLDEncoder->piNumGroups ); + } + + IF( psLCLDEncoder->psRMSEnvelopeGrouping != NULL ) + { + DeleteRMSEnvelopeGrouping( psLCLDEncoder->psRMSEnvelopeGrouping ); + } + + IF( psLCLDEncoder->ppiGroupLengths != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + free( psLCLDEncoder->ppiGroupLengths[n] ); + } + free( psLCLDEncoder->ppiGroupLengths ); + } + IF( psLCLDEncoder->pppiRMSEnvelope != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiRMSEnvelope[n][k] ); + } + free( psLCLDEncoder->pppiRMSEnvelope[n] ); + } + free( psLCLDEncoder->pppiRMSEnvelope ); + } + + IF( psLCLDEncoder->pppiSMR != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiSMR[n][k] ); + } + free( psLCLDEncoder->pppiSMR[n] ); + } + free( psLCLDEncoder->pppiSMR ); + } + + IF( psLCLDEncoder->pppiExcitation != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiExcitation[n][k] ); + } + free( psLCLDEncoder->pppiExcitation[n] ); + } + free( psLCLDEncoder->pppiExcitation ); + } + + IF( psLCLDEncoder->pppiAlloc != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiAlloc[n][k] ); + } + free( psLCLDEncoder->pppiAlloc[n] ); + } + free( psLCLDEncoder->pppiAlloc ); + } + + IF( psLCLDEncoder->pppiLCLDSignReal != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiLCLDSignReal[n][k] ); + } + free( psLCLDEncoder->pppiLCLDSignReal[n] ); + } + free( psLCLDEncoder->pppiLCLDSignReal ); + } + + IF( psLCLDEncoder->pppiLCLDSignImag != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiLCLDSignImag[n][k] ); + } + free( psLCLDEncoder->pppiLCLDSignImag[n] ); + } + free( psLCLDEncoder->pppiLCLDSignImag ); + } + + IF( psLCLDEncoder->pppiQLCLDReal != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiQLCLDReal[n][k] ); + } + free( psLCLDEncoder->pppiQLCLDReal[n] ); + } + free( psLCLDEncoder->pppiQLCLDReal ); + } + + IF( psLCLDEncoder->pppiQLCLDImag != NULL ) + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + FOR( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiQLCLDImag[n][k] ); + } + free( psLCLDEncoder->pppiQLCLDImag[n] ); + } + free( psLCLDEncoder->pppiQLCLDImag ); + } + + DeletePredictionEncoder_fx( psLCLDEncoder->psPredictionEncoder ); + free( psLCLDEncoder ); + } + + return; +} + +/*------------------------------------------------------------------------------------------* + * Local function declarations + *------------------------------------------------------------------------------------------*/ + +static Word32 MSModeCalculation_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, Word32 ***pppfReal_fx, Word32 ***pppfImag_fx, Word16 Q_in, Word32 *piMSMode, Word32 *piLRPhaseDiff, Word32 *piMSPredCoef, const Word32 iAllowSidePred, const Word32 iRealOnlyOut, Word32 *piMSFlags ); +static void RemoveRMSEnvelope( const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iNumGroups, const Word32 *piGroupLengths, Word32 **ppiRMSEnvelope, Word32 **ppfReal_fx, Word32 **ppfImag_fx ); +static Word32 CountLCLDBits( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 *piPredEnable, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag ); + +static Word32 WriteHeaderInformation( const Word32 iNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 WriteMSInformation( const Word32 iNumBands, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiff, const Word32 *piMSPredCoef, Word32 iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 WriteGroupInformation( const Word32 iChannels, const Word32 iCommonGrouping, const Word32 *piNumGroups, Word32 **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 WriteRMSEnvelope( const Word32 iChannels, const Word32 *piNumGroups, const Word32 iNumBands, Word32 ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 WriteAllocInformation( const Word32 iAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static Word32 WriteLCLDData( const Word32 *piNumGroups, Word32 **ppiGroupLengths, const Word32 iNumBands, const Word32 iNumChannels, Word32 **ppiPredEnable, const Word32 iNumSubSets, const Word32 iSubSetId, Word32 ***pppiAlloc, Word32 ***pppiSignReal, Word32 ***pppiSignImag, Word32 ***pppiQReal, Word32 ***pppiQImag, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static Word32 ComputeAllocation( const Word32 iChannels, const Word32 *piNumGroups, Word32 **ppiGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 ***pppfReal_fx, Word32 ***pppfImag_fx, Word16 q_final, Word32 ***pppiSMR, const Word32 iAvailableBits, Word32 *piAllocOffset, Word32 ***pppiAlloc, Word32 ***pppiQReal, Word32 ***pppiQImag, Word32 ***pppiSignReal, Word32 ***pppiSignImag, PredictionEncoder *psPredictionEncoder ); +/*------------------------------------------------------------------------------------------* + * Function EncodeLCLDFrame() + * + * + *------------------------------------------------------------------------------------------*/ +Word32 EncodeLCLDFrame( + LCLDEncoder *psLCLDEncoder, + Word32 ***pppfLCLDReal_fx, + Word32 ***pppfLCLDImag_fx, + Word32 *piBitsWritten, + const Word32 available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word16 *q_final ) +{ + Word32 n; + Word32 iAvailableBits, iBitsWritten; + Word32 iNumMSBands = 0; + Word32 iAudioBitsWritten; + + iAvailableBits = available_bits; // HCBR for now + iBitsWritten = 0; + assert( available_bits <= pBits->buf_len * 8 ); + IF( EQ_32( psLCLDEncoder->iRealOnlyOut, 1 ) ) + { + PackReal( psLCLDEncoder->iChannels, psLCLDEncoder->iNumBlocks * 2, pppfLCLDReal_fx, pppfLCLDImag_fx ); + } + /* Do MS calc here */ + IF( EQ_32( psLCLDEncoder->iChannels, 2 ) ) + { + iNumMSBands = MSModeCalculation_fx( psLCLDEncoder->iNumBlocks, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + pppfLCLDReal_fx, + pppfLCLDImag_fx, + *q_final, + &psLCLDEncoder->iMSMode, + psLCLDEncoder->piLRPhaseDiffs, + psLCLDEncoder->piMSPredCoefs, + psLCLDEncoder->iAllowSidePred, + psLCLDEncoder->iRealOnlyOut, + psLCLDEncoder->piMSFlags ); + IF( GT_32( psLCLDEncoder->iMSMode, 0 ) ) + { + psLCLDEncoder->iCommonGrouping = 1; // Make sure common grouping is enabled when MS is in use + } + } + /* Compute Grouping and RMS Envelopes */ + IF( EQ_32( psLCLDEncoder->iChannels, 2 ) && EQ_32( psLCLDEncoder->iCommonGrouping, 1 ) ) + { + ComputeEnvelopeGrouping( psLCLDEncoder->psRMSEnvelopeGrouping, + psLCLDEncoder->iChannels, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + pppfLCLDReal_fx, + pppfLCLDImag_fx, + &psLCLDEncoder->piNumGroups[0], + psLCLDEncoder->ppiGroupLengths[0], + psLCLDEncoder->pppiRMSEnvelope, + *q_final ); + psLCLDEncoder->piNumGroups[1] = psLCLDEncoder->piNumGroups[0]; + FOR( n = 0; n < psLCLDEncoder->piNumGroups[0]; n++ ) + { + psLCLDEncoder->ppiGroupLengths[1][n] = psLCLDEncoder->ppiGroupLengths[0][n]; + move32(); + } + } + ELSE + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + ComputeEnvelopeGrouping( psLCLDEncoder->psRMSEnvelopeGrouping, + psLCLDEncoder->iChannels, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + &pppfLCLDReal_fx[n], + &pppfLCLDImag_fx[n], + &psLCLDEncoder->piNumGroups[n], + psLCLDEncoder->ppiGroupLengths[n], + &psLCLDEncoder->pppiRMSEnvelope[n], *q_final ); + } + } + + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + RemoveRMSEnvelope( psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + psLCLDEncoder->piNumGroups[n], + (const Word32 *) psLCLDEncoder->ppiGroupLengths[n], + psLCLDEncoder->pppiRMSEnvelope[n], + pppfLCLDReal_fx[n], + pppfLCLDImag_fx[n] ); + } + *q_final = add( *q_final, 9 ); // Increasing the Q as it has changed inside the RemoveRMSEnvelope + + ComputePredictors_fx( psLCLDEncoder->psPredictionEncoder, pppfLCLDReal_fx, pppfLCLDImag_fx ); + + iBitsWritten = L_add( iBitsWritten, WriteHeaderInformation( psLCLDEncoder->iNumBands, pBits ) ); + + IF( EQ_32( psLCLDEncoder->iChannels, 2 ) ) + { + iBitsWritten = L_add( iBitsWritten, WriteMSInformation( psLCLDEncoder->iNumBands, + psLCLDEncoder->iMSMode, + (const Word32 *) psLCLDEncoder->piMSFlags, + (const Word32 *) psLCLDEncoder->piLRPhaseDiffs, + (const Word32 *) psLCLDEncoder->piMSPredCoefs, + iNumMSBands, + pBits ) ); + } + + + iBitsWritten = L_add( iBitsWritten, WritePredictors( psLCLDEncoder->psPredictionEncoder, pBits ) ); + + iBitsWritten = L_add( iBitsWritten, WriteGroupInformation( psLCLDEncoder->iChannels, psLCLDEncoder->iCommonGrouping, (const Word32 *) psLCLDEncoder->piNumGroups, psLCLDEncoder->ppiGroupLengths, pBits ) ); + + iBitsWritten = L_add( iBitsWritten, WriteRMSEnvelope( psLCLDEncoder->iChannels, (const Word32 *) psLCLDEncoder->piNumGroups, psLCLDEncoder->iNumBands, psLCLDEncoder->pppiRMSEnvelope, pBits ) ); + + + IF( EQ_32( psLCLDEncoder->iChannels, 2 ) && EQ_32( psLCLDEncoder->iCommonGrouping, 1 ) ) + { + Word32 k; + FOR( k = 0; k < psLCLDEncoder->piNumGroups[0]; k++ ) + { + PerceptualModelStereo_fx( psLCLDEncoder->iNumBands, + psLCLDEncoder->piMSFlags, + psLCLDEncoder->pppiRMSEnvelope[0][k], + psLCLDEncoder->pppiRMSEnvelope[1][k], + psLCLDEncoder->pppiExcitation[0][k], + psLCLDEncoder->pppiExcitation[1][k], + psLCLDEncoder->pppiSMR[0][k], + psLCLDEncoder->pppiSMR[1][k] ); + } + } + ELSE + { + FOR( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + Word32 k; + FOR( k = 0; k < psLCLDEncoder->piNumGroups[n]; k++ ) + { + PerceptualModel_fx( psLCLDEncoder->iNumBands, + psLCLDEncoder->pppiRMSEnvelope[n][k], + psLCLDEncoder->pppiExcitation[n][k], + psLCLDEncoder->pppiSMR[n][k] ); + } + } + } +#ifdef DEBUG_WRITE_PREDICTORS + { + static FILE *fid; + if ( !fid ) + fid = fopen( "pred_enc.txt", "wt" ); + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + int16_t b; + for ( b = 0; b < 60; b++ ) + fprintf( fid, "%.5f ", (float) psLCLDEncoder->psPredictionEncoder->ppiPredBandEnable[n][b] * psLCLDEncoder->psPredictionEncoder->ppfA1Imag[n][b] ); + } + fprintf( fid, "%d %d\n", psLCLDEncoder->psPredictionEncoder->iSubSetId, psLCLDEncoder->psPredictionEncoder->piPredChanEnable[n] ); + } +#endif + iAvailableBits = L_sub( iAvailableBits, iBitsWritten ); + + ComputeAllocation( psLCLDEncoder->iChannels, + (const Word32 *) psLCLDEncoder->piNumGroups, + psLCLDEncoder->ppiGroupLengths, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + pppfLCLDReal_fx, + pppfLCLDImag_fx, + *q_final, + psLCLDEncoder->pppiSMR, + iAvailableBits, + &psLCLDEncoder->iAllocOffset, + psLCLDEncoder->pppiAlloc, + psLCLDEncoder->pppiQLCLDReal, + psLCLDEncoder->pppiQLCLDImag, + psLCLDEncoder->pppiLCLDSignReal, + psLCLDEncoder->pppiLCLDSignImag, + psLCLDEncoder->psPredictionEncoder ); + + iBitsWritten = L_add( iBitsWritten, WriteAllocInformation( psLCLDEncoder->iAllocOffset, + pBits ) ); + iAudioBitsWritten = iBitsWritten; + iBitsWritten = L_add( iBitsWritten, WriteLCLDData( psLCLDEncoder->piNumGroups, + psLCLDEncoder->ppiGroupLengths, + psLCLDEncoder->iNumBands, + psLCLDEncoder->iChannels, + psLCLDEncoder->psPredictionEncoder->ppiPredBandEnable, + psLCLDEncoder->psPredictionEncoder->iNumSubSets, + psLCLDEncoder->psPredictionEncoder->iSubSetId, + psLCLDEncoder->pppiAlloc, + psLCLDEncoder->pppiLCLDSignReal, + psLCLDEncoder->pppiLCLDSignImag, + psLCLDEncoder->pppiQLCLDReal, + psLCLDEncoder->pppiQLCLDImag, + pBits ) ); + *piBitsWritten = iBitsWritten; + move32(); + iAudioBitsWritten = L_sub( iBitsWritten, iAudioBitsWritten ); + + UpdatePredictionSubSetId( psLCLDEncoder->psPredictionEncoder ); + + return 0; +} + +/*------------------------------------------------------------------------------------------* + * Function GetNumGroups() + * + * + *------------------------------------------------------------------------------------------*/ + +Word32 GetNumGroups( LCLDEncoder *psLCLDEncoder ) +{ + return psLCLDEncoder->piNumGroups[0]; +} + + +/*------------------------------------------------------------------------------------------* + * Local functions + * + * + *------------------------------------------------------------------------------------------*/ + +enum MSPred_Types +{ + MS_PHASE_AND_PRED = 0, /* LR phase alignment + real-valued M/S prediction */ + MS_PRED_ONLY = 1, /* real-valued M/S prediction */ + MS_PHASE_ONLY = 2 /* LR phase alignment + M/S */ +}; + +enum MS_BS_TYPES +{ + MS_OFF = 0, + MS_ALL = 1, + MS_SOME = 2, + MS_PRED = 3 +}; +static Word32 MSModeCalculation_fx( + const Word32 iNumBlocks, + const Word32 iNumBands, + const Word32 *piBandwidths, + /*float ***pppfReal, + float ***pppfImag,*/ + Word32 ***pppfReal_fx, + Word32 ***pppfImag_fx, + Word16 Q_in, + Word32 *piMSMode, + Word32 *piLRPhaseDiffs, + Word32 *piMSPredCoefs, + const Word32 iAllowSidePred, + const Word32 iRealOnlyOut, + Word32 *piMSFlags ) +{ + Word32 b; + Word32 iFBOffset; + Word32 iNumMSBands; + Word32 iMSPredType; + /*float fMSBitGain = 0.0f; + float pfMSPredBitGain[3] = { 0.0f }; + float fPred;*/ + Word32 fMSBitGain_fx = 0; + Word32 pfMSPredBitGain_fx[3] = { 0 }; + Word32 fPred_fx; + Word32 piMSPredFlags0[MAX_BANDS] = { 0 }; + Word32 piMSPredFlags1[MAX_BANDS] = { 0 }; + Word32 piMSPredFlags2[MAX_BANDS] = { 0 }; + Word32 *ppiMSPredFlags[3]; + Word32 piMSPredCoefs0[MAX_BANDS] = { 0 }; + Word32 piMSPredCoefs1[MAX_BANDS] = { 0 }; + Word32 piMSPredCoefs2[MAX_BANDS] = { 0 }; + Word32 *ppiMSPredCoefs[3]; + Word32 piMSPredPhase0[MAX_BANDS] = { 0 }; + Word32 piMSPredPhase1[MAX_BANDS] = { 0 }; + Word32 piMSPredPhase2[MAX_BANDS] = { 0 }; + Word32 *ppiMSPredPhase[3]; + Word32 iMsInfoBits; + Word32 piMsPredInfoBits[3] = { 0 }; + + // const float feps = 1e-12f; + // float fBitsFactor = 3.32192809488736f; /* = 1/log10(2), from dB/10 to bits assuming 1 bit per log2(SNR) or 1 bit per 3dB SNR */ + const Word32 feps_fx = 1; // is this correct? + move32(); + Word32 fBitsFactor_fx = 1783446565; /* = 1/log10(2) (Q29), from dB/10 to bits assuming 1 bit per log2(SNR) or 1 bit per 3dB SNR */ + move32(); + IF( LT_32( iNumBlocks, LCLD_BLOCKS_PER_FRAME ) ) + { + // fBitsFactor *= ( 0.7f + (float) ( iNumBlocks - 4 ) / (float) ( LCLD_BLOCKS_PER_FRAME - 4 ) * ( 1.0f - 0.7f ) ); /* Tuning for relatively higher side rate due to shorter frame length */ + fBitsFactor_fx = Mpy_32_32( fBitsFactor_fx, L_add( 1503238553, W_extract_l( W_mult0_32_32( L_sub( iNumBlocks, 4 ), 596523235 ) ) ) ); /* Tuning for relatively higher side rate due to shorter frame length */ + } + + ppiMSPredFlags[0] = piMSPredFlags0; + move32(); + ppiMSPredFlags[1] = piMSPredFlags1; + move32(); + ppiMSPredFlags[2] = piMSPredFlags2; + move32(); + ppiMSPredCoefs[0] = piMSPredCoefs0; + move32(); + ppiMSPredCoefs[1] = piMSPredCoefs1; + move32(); + ppiMSPredCoefs[2] = piMSPredCoefs2; + move32(); + ppiMSPredPhase[0] = piMSPredPhase0; + move32(); + ppiMSPredPhase[1] = piMSPredPhase1; + move32(); + ppiMSPredPhase[2] = piMSPredPhase2; + move32(); + *piMSMode = MS_OFF; + move32(); + iFBOffset = 0; + move32(); + iNumMSBands = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 n; + /*float fLeftEnergy; + float fRightEnergy; + float fMidEnergy; + float fSideEnergy; + float fLRRatio; + float fMSRatio; + float pfMSPredRatio[3] = { 0.0f }; + float fMidEnergyPred; + float fSideEnergyPred; + float fLRCovReal = 0.0f; + float fLRCovImag = 0.0f;*/ + Word32 fLeftEnergy_fx; + Word32 fRightEnergy_fx; + Word32 fMidEnergy_fx; + Word32 fSideEnergy_fx; + Word64 fLeftEnergy_fx64; + Word64 fRightEnergy_fx64; + Word64 fMidEnergy_fx64; + Word64 fSideEnergy_fx64; + Word32 fLRRatio_fx; + Word32 fMSRatio_fx; + Word32 pfMSPredRatio_fx[3] = { 0 }; + Word32 fMidEnergyPred_fx; + Word32 fSideEnergyPred_fx; + Word32 fLRCovReal_fx = 0; + Word32 fLRCovImag_fx = 0; + Word64 fLRCovReal_fx64 = 0; + Word64 fLRCovImag_fx64 = 0; + Word32 iPhase; + Word32 iPred; + Word32 tabIdx = 0; + // float fNumLines = (float)(iRealOnlyOut == 1 ? iNumBlocks * piBandwidths[b] * 4 : iNumBlocks * piBandwidths[b] * 2); /* per band per channel */ + // float fLevelToSMRdBFactor = (float) c_aiDefaultTheta48[b] / (float) ( 1 << PERCEPTUAL_MODEL_SLGAIN_SHIFT ); /* frequency dependent SMR slope in psy model */ + Word32 fNumLines_fx = iRealOnlyOut == 1 ? L_shl( iNumBlocks * piBandwidths[b], 2 ) : L_shl( iNumBlocks * piBandwidths[b], 1 ); /* per band per channel */ + Word32 fLevelToSMRdBFactor_fx = L_shl( c_aiDefaultTheta48[b], 23 ); /* frequency dependent SMR slope in psy model Q23:sub(Q31, PERCEPTUAL_MODEL_SLGAIN_SHIFT) */ + fLeftEnergy_fx = 0; + fRightEnergy_fx = 0; + fMidEnergy_fx = 0; + fSideEnergy_fx = 0; + fLeftEnergy_fx64 = 0; + fRightEnergy_fx64 = 0; + fMidEnergy_fx64 = 0; + fSideEnergy_fx64 = 0; + Word16 Q_en_tmp = 63; + + FOR( n = 0; n < piBandwidths[b]; n++ ) + { + Word32 k; + FOR( k = 0; k < iNumBlocks; k++ ) + { + /*float fMidReal; + float fMidImag; + float fSideReal; + float fSideImag;*/ + Word32 fMidReal_fx; + Word32 fMidImag_fx; + Word32 fSideReal_fx; + Word32 fSideImag_fx; + + // fMidReal = 0.5f * ( pppfReal[0][k][iFBOffset] + pppfReal[1][k][iFBOffset] ); + fMidReal_fx = L_shr( L_add( pppfReal_fx[0][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), 1 ); + // fMidImag = 0.5f * ( pppfImag[0][k][iFBOffset] + pppfImag[1][k][iFBOffset] ); + fMidImag_fx = L_shr( L_add( pppfImag_fx[0][k][iFBOffset], pppfImag_fx[1][k][iFBOffset] ), 1 ); + // fSideReal = 0.5f * ( pppfReal[0][k][iFBOffset] - pppfReal[1][k][iFBOffset] ); + fSideReal_fx = L_shr( L_sub( pppfReal_fx[0][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), 1 ); + // fSideImag = 0.5f * ( pppfImag[0][k][iFBOffset] - pppfImag[1][k][iFBOffset] ); + fSideImag_fx = L_shr( L_sub( pppfImag_fx[0][k][iFBOffset], pppfImag_fx[1][k][iFBOffset] ), 1 ); + + // fLeftEnergy += ( pppfReal[0][k][iFBOffset] * pppfReal[0][k][iFBOffset] + pppfImag[0][k][iFBOffset] * pppfImag[0][k][iFBOffset] ); + fLeftEnergy_fx64 = W_add( fLeftEnergy_fx64, W_add( W_mult0_32_32( pppfReal_fx[0][k][iFBOffset], pppfReal_fx[0][k][iFBOffset] ), W_mult0_32_32( pppfImag_fx[0][k][iFBOffset], pppfImag_fx[0][k][iFBOffset] ) ) ); + // fRightEnergy += ( pppfReal[1][k][iFBOffset] * pppfReal[1][k][iFBOffset] + pppfImag[1][k][iFBOffset] * pppfImag[1][k][iFBOffset] ); + fRightEnergy_fx64 = W_add( fRightEnergy_fx64, W_add( W_mult0_32_32( pppfReal_fx[1][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), W_mult0_32_32( pppfImag_fx[1][k][iFBOffset], pppfImag_fx[1][k][iFBOffset] ) ) ); + // fMidEnergy += ( fMidReal * fMidReal + fMidImag * fMidImag ); + fMidEnergy_fx64 = W_add( fMidEnergy_fx64, W_add( W_mult0_32_32( fMidReal_fx, fMidReal_fx ), W_mult0_32_32( fMidImag_fx, fMidImag_fx ) ) ); + // fSideEnergy += ( fSideReal * fSideReal + fSideImag * fSideImag ); + fSideEnergy_fx64 = W_add( fSideEnergy_fx64, W_add( W_mult0_32_32( fSideReal_fx, fSideReal_fx ), W_mult0_32_32( fSideImag_fx, fSideImag_fx ) ) ); + + // fLRCovReal += ( pppfReal[0][k][iFBOffset] * pppfReal[1][k][iFBOffset] + pppfImag[0][k][iFBOffset] * pppfImag[1][k][iFBOffset] ); + fLRCovReal_fx64 = W_add( fLRCovReal_fx64, W_add( W_mult0_32_32( pppfReal_fx[0][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), W_mult0_32_32( pppfImag_fx[0][k][iFBOffset], pppfImag_fx[1][k][iFBOffset] ) ) ); + // fLRCovImag += ( pppfImag[0][k][iFBOffset] * pppfReal[1][k][iFBOffset] - pppfImag[1][k][iFBOffset] * pppfReal[0][k][iFBOffset] ); + fLRCovImag_fx64 = W_add( fLRCovImag_fx64, W_sub( W_mult0_32_32( pppfImag_fx[0][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), W_mult0_32_32( pppfImag_fx[1][k][iFBOffset], pppfReal_fx[0][k][iFBOffset] ) ) ); + } + + iFBOffset++; + } + Q_en_tmp = min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) ); + Q_en_tmp = min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) ); + Q_en_tmp = min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) ); + Q_en_tmp = min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) ); + Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) ); + Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) ); + Q_en_tmp = sub( Q_en_tmp, 2 ); + fLeftEnergy_fx = W_extract_h( W_shl( fLeftEnergy_fx64, Q_en_tmp ) ); + fRightEnergy_fx = W_extract_h( W_shl( fRightEnergy_fx64, Q_en_tmp ) ); + fMidEnergy_fx = W_extract_h( W_shl( fMidEnergy_fx64, Q_en_tmp ) ); + fSideEnergy_fx = W_extract_h( W_shl( fSideEnergy_fx64, Q_en_tmp ) ); + fLRCovReal_fx = W_extract_h( W_shl( fLRCovReal_fx64, Q_en_tmp ) ); + fLRCovImag_fx = W_extract_h( W_shl( fLRCovImag_fx64, Q_en_tmp ) ); + Word16 Q_en = add( shl( Q_in, 1 ), sub( Q_en_tmp, 32 ) ) /*2 * Q_in - 31 - 2*/; + /* M/S prediction without phase alignment*/ + // fPred = 0.25f * ( fLeftEnergy - fRightEnergy ) / ( fMidEnergy + feps ); + // iPred = quantPred(fPred); + // fPred = dequantPred(iPred); + Word16 exp; + fPred_fx = BASOP_Util_Divide3232_Scale( L_sub( fLeftEnergy_fx, fRightEnergy_fx ), L_add( fMidEnergy_fx, feps_fx ), &exp ); + exp = sub( exp, 2 ); //*0.25f + fPred_fx = L_shl( fPred_fx, 16 ); + iPred = quantPred_fx( fPred_fx, exp ); + fPred_fx = dequantPred_fx( iPred ); // Q31 + // fSideEnergyPred = fSideEnergy + ( fPred * fPred * fMidEnergy - 2.0f * fPred * 0.25f * ( fLeftEnergy - fRightEnergy ) ); + fSideEnergyPred_fx = L_add( fSideEnergy_fx, + L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergy_fx ), + L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) ); + fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 ); + + ppiMSPredCoefs[MS_PRED_ONLY][b] = iPred; + move32(); + ppiMSPredPhase[MS_PRED_ONLY][b] = 0; + move32(); + // pfMSPredRatio[MS_PRED_ONLY] = log10f( ( fMidEnergy + feps ) / ( fSideEnergyPred + feps ) ); + pfMSPredRatio_fx[MS_PRED_ONLY] = Mpy_32_32( L_sub( BASOP_Util_Log2( L_add( fMidEnergy_fx, feps_fx ) ), BASOP_Util_Log2( L_add( fSideEnergyPred_fx, feps_fx ) ) ), LOG10_2_FX ); // Q25 + // printf("%f ", (float)pfMSPredRatio_fx[MS_PRED_ONLY] / (1 << 25)); + + /* Phase alignment*/ + iPhase = 0; + move32(); + // if ( fLRCovReal * fLRCovReal + fLRCovImag * fLRCovImag > 0.5f * fLeftEnergy * fRightEnergy ) + IF( GT_32( L_add( Mpy_32_32( fLRCovReal_fx, fLRCovReal_fx ), Mpy_32_32( fLRCovImag_fx, fLRCovImag_fx ) ), L_shr( Mpy_32_32( fLeftEnergy_fx, fRightEnergy_fx ), 1 ) ) ) + { + // float fPhase = atan2f( fLRCovImag, fLRCovReal ); + Word32 fPhase_fx = BASOP_util_atan2( fLRCovImag_fx, fLRCovReal_fx, 0 ); + exp = sub( 18, norm_l( fPhase_fx ) ); + fPhase_fx = L_shl( fPhase_fx, norm_l( fPhase_fx ) ); // Q31 + // iPhase = quantPhase( fPhase ); + iPhase = quantPhase_fx( fPhase_fx, exp ); + } + + /* adjust covariance */ + tabIdx = L_sub( iPhase, PHASE_MIN_VAL ); + // cplxmult( &fLRCovReal, &fLRCovImag, c_afRotRealImag[tabIdx][0], -c_afRotRealImag[tabIdx][1] ); + cplxmult_fx( &fLRCovReal_fx, &fLRCovImag_fx, c_afRotRealImag_fx[tabIdx][0], -c_afRotRealImag_fx[tabIdx][1] ); + + /* compute MS prediction coefficient based on adjusted covariance */ + // fMidEnergyPred = 0.25f * ( fLeftEnergy + fRightEnergy + 2.0f * fLRCovReal ); + fMidEnergyPred_fx = L_add( L_add( L_shr_r( fLeftEnergy_fx, 2 ), L_shr_r( fRightEnergy_fx, 2 ) ), L_shr( fLRCovReal_fx, 1 ) ); // Q_en + // fSideEnergyPred = 0.25f * ( fLeftEnergy + fRightEnergy - 2.0f * fLRCovReal ); + fSideEnergyPred_fx = L_sub( L_add( L_shr_r( fLeftEnergy_fx, 2 ), L_shr_r( fRightEnergy_fx, 2 ) ), L_shr( fLRCovReal_fx, 1 ) ); // Q_en + fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 ); + + /* M/S with LR phase alignment but without prediction */ + ppiMSPredCoefs[MS_PHASE_ONLY][b] = 0; + move32(); + ppiMSPredPhase[MS_PHASE_ONLY][b] = iPhase; + move32(); + // pfMSPredRatio[MS_PHASE_ONLY] = log10f( ( fMidEnergyPred + feps ) / ( fSideEnergyPred + feps ) ); + pfMSPredRatio_fx[MS_PHASE_ONLY] = Mpy_32_32( L_sub( BASOP_Util_Log2( L_add( fMidEnergyPred_fx, feps_fx ) ), BASOP_Util_Log2( L_add( fSideEnergyPred_fx, feps_fx ) ) ), LOG10_2_FX ); // Q25 + // printf("%f ", (float)pfMSPredRatio_fx[MS_PHASE_ONLY] / (1 << 25)); + + /* M/S with LR phase alignment and prediction */ + // fPred = fMidEnergyPred == 0.0f ? 0.0f : 0.25f * ( fLeftEnergy - fRightEnergy ) / fMidEnergyPred; + fPred_fx = fMidEnergyPred_fx == 0 ? 0 : BASOP_Util_Divide3232_Scale( L_sub( fLeftEnergy_fx, fRightEnergy_fx ), fMidEnergyPred_fx, &exp ); + exp = sub( exp, 2 ); //*0.25f + fPred_fx = L_shl( fPred_fx, 16 ); + // iPred = quantPred( fPred ); + iPred = quantPred_fx( fPred_fx, exp ); + // fPred = dequantPred( iPred ); + fPred_fx = dequantPred_fx( iPred ); + // fSideEnergyPred += ( fPred * fPred * fMidEnergyPred - 2.0f * fPred * 0.25f * ( fLeftEnergy - fRightEnergy ) ); + fSideEnergyPred_fx = L_add( fSideEnergyPred_fx, + L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergyPred_fx ), + L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) ); + fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 ); + /* -= fPred * fPred * fMidEnergyPred doesn't work because fPred is quantized and does not match MS/MM exactly */ + ppiMSPredCoefs[MS_PHASE_AND_PRED][b] = iPred; + move32(); + ppiMSPredPhase[MS_PHASE_AND_PRED][b] = iPhase; + move32(); + // pfMSPredRatio[MS_PHASE_AND_PRED] = log10f( ( fMidEnergyPred + feps ) / ( fSideEnergyPred + feps ) ); + pfMSPredRatio_fx[MS_PHASE_AND_PRED] = Mpy_32_32( L_sub( BASOP_Util_Log2( L_add( fMidEnergyPred_fx, feps_fx ) ), BASOP_Util_Log2( L_add( fSideEnergyPred_fx, feps_fx ) ) ), LOG10_2_FX ); // Q25 + // printf("%f ", (float)pfMSPredRatio_fx[MS_PHASE_AND_PRED] / (1 << 25)); + + /* Plain M/S */ + // fLeftEnergy = log10f( fLeftEnergy + feps ); + exp = sub( 31, Q_en ); // 31 - Q + fLeftEnergy_fx = Mpy_32_32( L_add( BASOP_Util_Log2( L_add( fLeftEnergy_fx, feps_fx ) ), L_shl( exp, 25 ) ), LOG10_2_FX ); // Q25 + // fRightEnergy = log10f( fRightEnergy + feps ); + fRightEnergy_fx = Mpy_32_32( L_add( BASOP_Util_Log2( L_add( fRightEnergy_fx, feps_fx ) ), L_shl( exp, 25 ) ), LOG10_2_FX ); // Q25 + // fMidEnergy = log10f( fMidEnergy + feps ); + fMidEnergy_fx = Mpy_32_32( L_add( BASOP_Util_Log2( L_add( fMidEnergy_fx, feps_fx ) ), L_shl( exp, 25 ) ), LOG10_2_FX ); // Q25 + // fSideEnergy = log10f( fSideEnergy + feps ); + fSideEnergy_fx = Mpy_32_32( L_add( BASOP_Util_Log2( L_add( fSideEnergy_fx, feps_fx ) ), L_shl( exp, 25 ) ), LOG10_2_FX ); // Q25 + + // fLRRatio = ( fLeftEnergy > fRightEnergy ? fLeftEnergy - fRightEnergy : fRightEnergy - fLeftEnergy ); + fLRRatio_fx = ( fLeftEnergy_fx > fRightEnergy_fx ? L_sub( fLeftEnergy_fx, fRightEnergy_fx ) : L_sub( fRightEnergy_fx, fLeftEnergy_fx ) ); // Q25 + // fMSRatio = ( fMidEnergy > fSideEnergy ? fMidEnergy - fSideEnergy : fSideEnergy - fMidEnergy ); + fMSRatio_fx = ( fMidEnergy_fx > fSideEnergy_fx ? L_sub( fMidEnergy_fx, fSideEnergy_fx ) : L_sub( fSideEnergy_fx, fMidEnergy_fx ) ); // Q25 + + // if ( fMSRatio > fLRRatio ) + IF( GT_32( fMSRatio_fx, fLRRatio_fx ) ) + { + iNumMSBands++; + piMSFlags[b] = 1; + move32(); + // fMSBitGain += fNumLines * ( fMSRatio - fLRRatio ) * fLevelToSMRdBFactor * fBitsFactor; + fMSBitGain_fx = L_add( fMSBitGain_fx, W_extract_l( W_shr( W_mult0_32_32( fNumLines_fx, Mpy_32_32( Mpy_32_32( L_sub( fMSRatio_fx, fLRRatio_fx ), fLevelToSMRdBFactor_fx ), fBitsFactor_fx ) ), 7 ) ) ); // Q16 + } + ELSE + { + piMSFlags[b] = 0; + move32(); + } + piLRPhaseDiffs[b] = 0; + move32(); + piMSPredCoefs[b] = 0; + move32(); + + /* MSPred bit gains based on increase of level ratio compared to L/R ratio and the level dependent psy-model */ + FOR( iMSPredType = 0; iMSPredType < 3; iMSPredType++ ) + { + // if ( pfMSPredRatio[iMSPredType] > fLRRatio ) + IF( GT_32( pfMSPredRatio_fx[iMSPredType], fLRRatio_fx ) ) + { + ppiMSPredFlags[iMSPredType][b] = 1; + move32(); + // pfMSPredBitGain[iMSPredType] += fNumLines * ( pfMSPredRatio[iMSPredType] - fLRRatio ) * fLevelToSMRdBFactor * fBitsFactor; + pfMSPredBitGain_fx[iMSPredType] = L_add( pfMSPredBitGain_fx[iMSPredType], + W_extract_l( W_shr( W_mult0_32_32( fNumLines_fx, + Mpy_32_32( Mpy_32_32( L_sub( pfMSPredRatio_fx[iMSPredType], fLRRatio_fx ), fLevelToSMRdBFactor_fx ), + fBitsFactor_fx ) ), + 7 ) ) ); // Q16 + } + } + } + Word16 q_fMSBitGain_fx = Q16; + move16(); + Word16 q_pfMSPredBitGain_fx = Q16; // Q23-7 + move16(); + /* remove signalling cost from bit gains */ + FOR( iMSPredType = 0; iMSPredType < 3; iMSPredType++ ) + { + piMsPredInfoBits[iMSPredType] = CountMSBits( iNumBands, MS_PRED, ppiMSPredFlags[iMSPredType], ppiMSPredPhase[iMSPredType], ppiMSPredCoefs[iMSPredType] ); + // pfMSPredBitGain[iMSPredType] = max( pfMSPredBitGain[iMSPredType] - piMsPredInfoBits[iMSPredType], 0.0f ); + pfMSPredBitGain_fx[iMSPredType] = max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 ); + } + + /* find the best M/S Pred type */ + IF( EQ_32( iRealOnlyOut, 1 ) ) + { + iMSPredType = MS_PRED_ONLY; + move32(); + } + ELSE + { + iMSPredType = MS_PHASE_AND_PRED; + move32(); + // iMSPredType = ( pfMSPredBitGain[MS_PRED_ONLY] > pfMSPredBitGain[iMSPredType] ? MS_PRED_ONLY : iMSPredType ); + iMSPredType = ( pfMSPredBitGain_fx[MS_PRED_ONLY] > pfMSPredBitGain_fx[iMSPredType] ? MS_PRED_ONLY : iMSPredType ); + // iMSPredType = ( pfMSPredBitGain[MS_PHASE_ONLY] > pfMSPredBitGain[iMSPredType] ? MS_PHASE_ONLY : iMSPredType ); + iMSPredType = ( pfMSPredBitGain_fx[MS_PHASE_ONLY] > pfMSPredBitGain_fx[iMSPredType] ? MS_PHASE_ONLY : iMSPredType ); + } + + /* plain M/S */ + iMsInfoBits = CountMSBits( iNumBands, MS_SOME, piMSFlags, NULL, NULL ); + // fMSBitGain = max( fMSBitGain - iMsInfoBits, 0.0f ); + fMSBitGain_fx = L_max( L_sub( fMSBitGain_fx, L_shl( iMsInfoBits, q_fMSBitGain_fx ) ), 0 ); // Q_en -2 + // if ( iAllowSidePred && pfMSPredBitGain[iMSPredType] > 1.1f * fMSBitGain ) + test(); + IF( iAllowSidePred && GT_32( L_shr_r( pfMSPredBitGain_fx[iMSPredType], sub( q_pfMSPredBitGain_fx, q_fMSBitGain_fx ) ), L_add( fMSBitGain_fx, Mpy_32_32( fMSBitGain_fx, 214748364 ) ) ) ) + { + *piMSMode = MS_PRED; + move32(); + iNumMSBands = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + piMSFlags[b] = ppiMSPredFlags[iMSPredType][b]; + IF( EQ_32( piMSFlags[b], 1 ) ) + { + piMSPredCoefs[b] = ppiMSPredCoefs[iMSPredType][b]; + move32(); + piLRPhaseDiffs[b] = ppiMSPredPhase[iMSPredType][b]; + move32(); + iNumMSBands++; + } + ELSE + { + piMSPredCoefs[b] = 0; + move32(); + piLRPhaseDiffs[b] = 0; + move32(); + } + } + } + ELSE IF( EQ_32( iNumMSBands, iNumBands ) ) + { + *piMSMode = MS_ALL; + move32(); + } + ELSE IF( GT_32( iNumMSBands, 0 ) ) + { + *piMSMode = MS_SOME; + move32(); + } + ELSE + { + *piMSMode = MS_OFF; + move32(); + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + int32_t iActualInfoBits = CountMSBits( iNumBands, *piMSMode, piMSFlags, piLRPhaseDiffs, piMSPredCoefs ); + if ( !fid ) + fid = fopen( "ms_info_bits.txt", "wt" ); + fprintf( fid, "%d %d %d %d %d\n", iMsInfoBits, piMsPredInfoBits[MS_PHASE_AND_PRED], piMsPredInfoBits[MS_PRED_ONLY], piMsPredInfoBits[MS_PHASE_ONLY], iActualInfoBits ); + } +#endif + IF( NE_32( *piMSMode, MS_OFF ) ) + { + iFBOffset = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + IF( EQ_32( piMSFlags[b], 1 ) ) + { + Word32 n; + Word32 phaseIdx; + phaseIdx = L_sub( piLRPhaseDiffs[b], PHASE_MIN_VAL ); + // fPred = dequantPred( piMSPredCoefs[b] ); + fPred_fx = dequantPred_fx( piMSPredCoefs[b] ); // Q31 + FOR( n = 0; n < piBandwidths[b]; n++ ) + { + Word32 k; + FOR( k = 0; k < iNumBlocks; k++ ) + { + /*float fMidReal; + float fMidImag; + float fSideReal; + float fSideImag;*/ + Word32 fMidReal_fx; + Word32 fMidImag_fx; + Word32 fSideReal_fx; + Word32 fSideImag_fx; + + IF( EQ_32( *piMSMode, MS_PRED ) ) + { + // cplxmult( &pppfReal[1][k][iFBOffset], &pppfImag[1][k][iFBOffset], c_afRotRealImag[phaseIdx][0], c_afRotRealImag[phaseIdx][1] ); + cplxmult_fx( &pppfReal_fx[1][k][iFBOffset], &pppfImag_fx[1][k][iFBOffset], c_afRotRealImag_fx[phaseIdx][0], c_afRotRealImag_fx[phaseIdx][1] ); + } + + // fMidReal = 0.5f * ( pppfReal[0][k][iFBOffset] + pppfReal[1][k][iFBOffset] ); + fMidReal_fx = L_shr( L_add( pppfReal_fx[0][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), 1 ); + // fMidImag = 0.5f * ( pppfImag[0][k][iFBOffset] + pppfImag[1][k][iFBOffset] ); + fMidImag_fx = L_shr( L_add( pppfImag_fx[0][k][iFBOffset], pppfImag_fx[1][k][iFBOffset] ), 1 ); + // fSideReal = 0.5f * ( pppfReal[0][k][iFBOffset] - pppfReal[1][k][iFBOffset] ); + fSideReal_fx = L_shr( L_sub( pppfReal_fx[0][k][iFBOffset], pppfReal_fx[1][k][iFBOffset] ), 1 ); + // fSideImag = 0.5f * ( pppfImag[0][k][iFBOffset] - pppfImag[1][k][iFBOffset] ); + fSideImag_fx = L_shr( L_sub( pppfImag_fx[0][k][iFBOffset], pppfImag_fx[1][k][iFBOffset] ), 1 ); + + IF( EQ_32( *piMSMode, MS_PRED ) ) + { + // fSideReal -= fPred * fMidReal; + fSideReal_fx = L_sub( fSideReal_fx, Mpy_32_32( fPred_fx, fMidReal_fx ) ); + // fSideImag -= fPred * fMidImag; + fSideImag_fx = L_sub( fSideImag_fx, Mpy_32_32( fPred_fx, fMidImag_fx ) ); + } + + pppfReal_fx[0][k][iFBOffset] = fMidReal_fx; + move32(); + pppfReal_fx[1][k][iFBOffset] = fSideReal_fx; + move32(); + pppfImag_fx[0][k][iFBOffset] = fMidImag_fx; + move32(); + pppfImag_fx[1][k][iFBOffset] = fSideImag_fx; + move32(); + } + iFBOffset++; + } + } + ELSE + { + iFBOffset = L_add( iFBOffset, piBandwidths[b] ); + } + } + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + if ( !fid ) + fid = fopen( "ms_enc.txt", "wt" ); + writeMSPred( piLRPhaseDiffs, piMSPredCoefs, *piMSMode, iNumMSBands, iNumBands, fid, piMSFlags ); + } +#endif + IF( EQ_32( *piMSMode, MS_PRED ) ) + { + /* Differential Coding of Phase Data*/ + PrepEncode( piLRPhaseDiffs, piMSFlags, iNumBands ); + PrepEncode( piMSPredCoefs, piMSFlags, iNumBands ); +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + if ( !fid ) + fid = fopen( "ms_pred_enc.txt", "wt" ); + writeMSPred( piLRPhaseDiffs, piMSPredCoefs, *piMSMode, iNumMSBands, iNumBands, fid, piMSFlags ); + } +#endif + /* Differential Coding*/ + EncodePhase( piLRPhaseDiffs, iNumMSBands, PHASE_DIFF_DIM ); + EncodePredCoef( piMSPredCoefs, iNumMSBands ); + } + + return iNumMSBands; +} +static void RemoveRMSEnvelope( + const Word32 iNumBands, + const Word32 *piBandwidths, + const Word32 iNumGroups, + const Word32 *piGroupLengths, + Word32 **ppiRMSEnvelope, + Word32 **ppfReal_fx, + Word32 **ppfImag_fx ) +{ + Word32 k, n, b, iFBOffset, m, iRMSEnv; + Word32 iBlockOffset; + Word32 fGain_fx; + Word16 fGain_exp; + iBlockOffset = 0; + move32(); + Word64 tmp; + FOR( n = 0; n < iNumGroups; n++ ) + { + FOR( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + iRMSEnv = ppiRMSEnvelope[n][b]; + IF( EQ_32( L_add( ENV_RECONSTRUCT_TABLE_CENTER, iRMSEnv ) % 2, 0 ) ) + { + fGain_fx = 1073741824; // 2 ^ 30 + move32(); + } + ELSE + { + fGain_fx = 1518500249; // sqrt(2) * 2 ^ 30 + move32(); + } + fGain_exp = c_afRMSEnvReconstructTable_exp[ENV_RECONSTRUCT_TABLE_CENTER - iRMSEnv]; + move16(); + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + tmp = W_mult_32_32( fGain_fx, ppfReal_fx[iBlockOffset][iFBOffset] ); + tmp = W_shr( tmp, sub( fGain_exp, 8 ) ); // Q to (input_q -9) + ppfReal_fx[iBlockOffset][iFBOffset] = W_extract_l( tmp ); + move32(); + tmp = W_mult_32_32( fGain_fx, ppfImag_fx[iBlockOffset][iFBOffset] ); + tmp = W_shr( tmp, sub( fGain_exp, 8 ) ); // Q to (input_q -9) + ppfImag_fx[iBlockOffset][iFBOffset] = W_extract_l( tmp ); + move32(); + iFBOffset++; + } + } + iBlockOffset++; + } + } + + return; +} +static void QuantizeSpectrumDPCM_Opt( + const Word32 iNumGroups, + const Word32 *piGroupLengths, + const Word32 iNumBands, + const Word32 *piBandwidths, + Word32 **ppiAlloc, + Word32 **ppfReal_fx, + Word32 **ppfImag_fx, + Word16 q_final, + Word32 **ppiQReal, + Word32 **ppiQImag, + Word32 **ppiSignReal, + Word32 **ppiSignImag, + Word32 iNumSubSets, + Word32 iSubSetId, + Word32 *piPredEnable, + Word32 *pfA1Real_fx, + Word32 *pfA1Imag_fx, + Word32 *pfPredStateReal_fx, + Word32 *pfPredStateImag_fx ) +{ + Word32 b, n; + Word32 iFBOffset; + Word32 k, iAlloc; + Word32 iMaxQuantVal_fx; + Word32 fSCFGain_fx, fInvSCFGain_fx; + iFBOffset = 0; + Word32 ppiQReal_fx, ppiQImag_fx; + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 m; + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + Word32 iBlockOffset = 0; + IF( EQ_32( piPredEnable[iFBOffset], 1 ) ) + { + Word32 fReal_fx; + Word32 fImag_fx; + Word32 iSubset = iFBOffset % iNumSubSets; + Word32 fPrevReal_fx = 0; + Word32 fPrevImag_fx = 0; + IF( NE_32( iSubset, iSubSetId ) ) + { + /* run predictors across sub-frames */ + fPrevReal_fx = pfPredStateReal_fx[iFBOffset]; + move32(); + fPrevImag_fx = pfPredStateImag_fx[iFBOffset]; + move32(); + } + FOR( n = 0; n < iNumGroups; n++ ) + { + iAlloc = ppiAlloc[n][b]; + iMaxQuantVal_fx = c_aiQuantMaxValues_fx[iAlloc]; + fSCFGain_fx = c_afScaleFactor_fx[iAlloc]; + fInvSCFGain_fx = c_afInvScaleFactor_fx[iAlloc]; + FOR( k = 0; k < piGroupLengths[n]; k++ ) + { + /* prediction */ + fReal_fx = L_sub( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) ); + fImag_fx = L_add( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevImag_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevReal_fx ) ); + ppiQReal_fx = Quantize_fx( L_add_sat( L_shr_r_sat( ppfReal_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), fReal_fx ), /* quantize residual */ + fSCFGain_fx, + &ppiSignReal[iBlockOffset][iFBOffset], + iMaxQuantVal_fx ); + ppiQImag_fx = Quantize_fx( L_add_sat( L_shr_r_sat( ppfImag_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), fImag_fx ), + fSCFGain_fx, + &ppiSignImag[iBlockOffset][iFBOffset], + iMaxQuantVal_fx ); + ppiQReal[iBlockOffset][iFBOffset] = L_shr( ppiQReal_fx, 21 ); + + ppiQImag[iBlockOffset][iFBOffset] = L_shr( ppiQImag_fx, 21 ); + + ppiQReal_fx = L_shl( ppiQReal[iBlockOffset][iFBOffset], 21 ); + fPrevReal_fx = L_sub( L_shl( UnQuantize_fx( ppiQReal_fx, + fInvSCFGain_fx, + ppiSignReal[iBlockOffset][iFBOffset] ), + 9 ), + fReal_fx ); + /* add prediction to quantized residual = reconstructed sample */ + + ppiQImag_fx = L_shl( ppiQImag[iBlockOffset][iFBOffset], 21 ); + fPrevImag_fx = L_sub( L_shl( UnQuantize_fx( ppiQImag_fx, + fInvSCFGain_fx, + ppiSignImag[iBlockOffset][iFBOffset] ), + 9 ), + fImag_fx ); + iBlockOffset++; + } /* group length */ + } /* groups */ + pfPredStateReal_fx[iFBOffset] = fPrevReal_fx; + move32(); + pfPredStateImag_fx[iFBOffset] = fPrevImag_fx; + move32(); + } /* predEnable */ + ELSE + { /* no prediction */ + FOR( n = 0; n < iNumGroups; n++ ) + { + iAlloc = ppiAlloc[n][b]; + move32(); + iMaxQuantVal_fx = c_aiQuantMaxValues_fx[iAlloc]; + move32(); + fSCFGain_fx = c_afScaleFactor_fx[iAlloc]; + move32(); + fInvSCFGain_fx = c_afInvScaleFactor_fx[iAlloc]; + move32(); + FOR( k = 0; k < piGroupLengths[n]; k++ ) + { + ppiQReal_fx = Quantize_fx( L_shr_r_sat( ppfReal_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), + fSCFGain_fx, + &ppiSignReal[iBlockOffset][iFBOffset], + iMaxQuantVal_fx ); + ppiQImag_fx = Quantize_fx( L_shr_r_sat( ppfImag_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), + fSCFGain_fx, + &ppiSignImag[iBlockOffset][iFBOffset], + iMaxQuantVal_fx ); + + ppiQReal[iBlockOffset][iFBOffset] = L_shr( ppiQReal_fx, 21 ); + + ppiQImag[iBlockOffset][iFBOffset] = L_shr( ppiQImag_fx, 21 ); + + iBlockOffset++; + } /* group length */ + } /* groups */ + } /* predEnable */ + iFBOffset++; + } /* bandwidth */ + } +} +static Word32 CountLCLDBits( + const Word32 iNumGroups, + const Word32 *piGroupLengths, + const Word32 iNumBands, + const Word32 *piBandwidths, + const Word32 *piPredEnable, + Word32 **ppiAlloc, + Word32 **ppiQReal, + Word32 **ppiQImag ) +{ + Word32 k, n, b, iFBOffset; + Word32 iBits, iBlockOffest; + Word32 m, iAlloc, iHuffDim, iHuffMod; + + iBits = 0; + move32(); + iBlockOffest = 0; + move32(); + FOR( n = 0; n < iNumGroups; n++ ) + { + FOR( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + move32(); + FOR( b = 0; b < iNumBands; b++ ) + { + iAlloc = ppiAlloc[n][b]; + move32(); + + iHuffDim = c_aiHuffmanDim[iAlloc]; + move32(); + iHuffMod = c_aiHuffmanMod[iAlloc]; + move32(); + + IF( GT_32( iAlloc, 0 ) ) + { + const UWord16( *pauiHuffmanTable )[2] = NULL; + const UWord16( *pauiHuffmanTableDPCM )[2] = NULL; + pauiHuffmanTable = c_apauiHuffEncTabels[iAlloc]; + pauiHuffmanTableDPCM = c_apauiHuffEncTabels[ALLOC_TABLE_SIZE + iAlloc]; + FOR( m = 0; m < piBandwidths[b]; m++ ) + { + Word32 iQuantValue1; + Word32 iQuantValue2; + + iQuantValue1 = ppiQReal[iBlockOffest][iFBOffset]; + move32(); + iQuantValue2 = ppiQImag[iBlockOffest][iFBOffset]; + move32(); + + iBits = L_add( iBits, GT_32( iQuantValue1, 0 ) ? 1 : 0 ); /* Sign bit for vals > 0 */ + iBits = L_add( iBits, GT_32( iQuantValue2, 0 ) ? 1 : 0 ); /* Sign bit for vals > 0 */ + + IF( EQ_32( piPredEnable[iFBOffset], 1 ) ) + { + IF( EQ_32( iHuffDim, 2 ) ) + { + iQuantValue1 *= iHuffMod; + iQuantValue1 = L_add( iQuantValue1, iQuantValue2 ); + iBits = L_add( iBits, pauiHuffmanTableDPCM[iQuantValue1][0] ); + } + ELSE + { + iBits = L_add( iBits, pauiHuffmanTableDPCM[iQuantValue1][0] ); + iBits = L_add( iBits, pauiHuffmanTableDPCM[iQuantValue2][0] ); + } + } + ELSE + { + IF( EQ_32( iHuffDim, 2 ) ) + { + iQuantValue1 *= iHuffMod; + iQuantValue1 = L_add( iQuantValue1, iQuantValue2 ); + iBits = L_add( iBits, pauiHuffmanTable[iQuantValue1][0] ); + } + ELSE + { + iBits = L_add( iBits, pauiHuffmanTable[iQuantValue1][0] ); + iBits = L_add( iBits, pauiHuffmanTable[iQuantValue2][0] ); + } + } + + iFBOffset++; + } + } + ELSE + { + iFBOffset = L_add( iFBOffset, piBandwidths[b] ); + } + } + + iBlockOffest++; + } + } + + return iBits; +} + + +/* Currently only the number of bands in frame */ +static Word32 WriteHeaderInformation( + const Word32 iNumBands, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsWritten; + + iBitsWritten = 0; + move32(); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iNumBands, 5 ); + iBitsWritten = L_add( iBitsWritten, 5 ); + + return iBitsWritten; +} + + +static Word32 WriteMSInformation( + const Word32 iNumBands, + const Word32 iMSMode, + const Word32 *piMSFlags, + const Word32 *piLRPhaseDiff, + const Word32 *piMSPredCoef, + Word32 iNumMSPredBands, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsWritten; + Word32 iMSPredAll = (Word32) EQ_32( iNumMSPredBands, iNumBands ); + move32(); +#ifdef DEBUG_WRITE_MS_PRED + Word32 iBitsWrittenTmp = 0; + move32(); +#endif + iBitsWritten = 0; + move32(); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iMSMode, 2 ); + iBitsWritten = L_add( iBitsWritten, 2 ); + + IF( EQ_32( iMSMode, 3 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iMSPredAll, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + + test(); + test(); + IF( EQ_32( iMSMode, 2 ) || ( EQ_32( iMSMode, 3 ) && !iMSPredAll ) ) + { + Word32 n; + FOR( n = 0; n < iNumBands; n++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, piMSFlags[n], 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + } + +#ifdef DEBUG_WRITE_MS_PRED + iBitsWrittenTmp = iBitsWritten; +#endif + IF( EQ_32( iMSMode, 3 ) ) + { + Word32 b; + Word32 anyNonZero; + anyNonZero = 0; + move32(); + FOR( b = 0; b < iNumMSPredBands; b++ ) + { + IF( NE_32( piLRPhaseDiff[b], 0 ) ) + { + anyNonZero = 1; + move32(); + BREAK; + } + } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, anyNonZero, 1 ); + iBitsWritten++; + + IF( anyNonZero ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( piLRPhaseDiff[0], PHASE_MIN_VAL ), PHASE_BAND0_BITS ); + iBitsWritten = L_add( iBitsWritten, PHASE_BAND0_BITS ); + FOR( b = 1; b < iNumMSPredBands; b++ ) + { + Word32 tabIdx = L_sub( piLRPhaseDiff[b], ENV_DELTA_MIN ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, c_aaiRMSEnvHuffEnc[tabIdx][1], c_aaiRMSEnvHuffEnc[tabIdx][0] ); + iBitsWritten = L_add( iBitsWritten, c_aaiRMSEnvHuffEnc[tabIdx][0] ); + } + } + + anyNonZero = 0; + move32(); + FOR( b = 0; b < iNumMSPredBands; b++ ) + { + IF( NE_32( piMSPredCoef[b], 0 ) ) + { + anyNonZero = 1; + move32(); + BREAK; + } + } + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, anyNonZero, 1 ); + iBitsWritten++; + + IF( anyNonZero ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( piMSPredCoef[0], PRED_MIN_VAL ), PRED_BAND0_BITS ); + iBitsWritten = L_add( iBitsWritten, PRED_BAND0_BITS ); + FOR( b = 1; b < iNumMSPredBands; b++ ) + { + Word32 tabIdx = L_sub( piMSPredCoef[b], ENV_DELTA_MIN ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, c_aaiRMSEnvHuffEnc[tabIdx][1], c_aaiRMSEnvHuffEnc[tabIdx][0] ); + iBitsWritten = L_add( iBitsWritten, c_aaiRMSEnvHuffEnc[tabIdx][0] ); + } + } + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid = 0; + IF( !fid ) + { + fid = fopen( "ms_pred_bitrate.txt", "wt" ); + } + fprintf( fid, "%f\n", (float) ( ( iBitsWritten - iBitsWrittenTmp ) * ( iMSMode == 3 ) * 50 ) / 1000.0f ); /*kb/s*/ + } +#endif + + return iBitsWritten; +} + + +static Word32 WriteGroupInformation( + const Word32 iChannels, + const Word32 iCommonGrouping, + const Word32 *piNumGroups, + Word32 **ppiGroupLengths, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 c, k, n, iBitsWritten; + + iBitsWritten = 0; + move32(); + test(); + IF( EQ_32( iChannels, 2 ) && EQ_32( iCommonGrouping, 1 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iCommonGrouping, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + + FOR( n = 0; n < piNumGroups[0]; n++ ) + { + FOR( k = 1; k < ppiGroupLengths[0][n]; k++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + IF( LT_32( n, L_sub( piNumGroups[0], 1 ) ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + } + } + ELSE IF( EQ_32( iChannels, 2 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iCommonGrouping, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + + FOR( c = 0; c < iChannels; c++ ) + { + FOR( n = 0; n < piNumGroups[c]; n++ ) + { + FOR( k = 1; k < ppiGroupLengths[c][n]; k++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + IF( LT_32( n, L_sub( piNumGroups[c], 1 ) ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + } + } + } + ELSE + { + FOR( c = 0; c < iChannels; c++ ) + { + FOR( n = 0; n < piNumGroups[c]; n++ ) + { + FOR( k = 1; k < ppiGroupLengths[c][n]; k++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + + IF( LT_32( n, L_sub( piNumGroups[c], 1 ) ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + } + } + } + + return iBitsWritten; +} + + +static Word32 WriteRMSEnvelope( + const Word32 iChannels, + const Word32 *piNumGroups, + const Word32 iNumBands, + Word32 ***pppiRMSEnvelope, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 k, n; + Word32 iBitsWritten; + + iBitsWritten = 0; + move32(); + FOR( n = 0; n < iChannels; n++ ) + { + FOR( k = 0; k < piNumGroups[n]; k++ ) + { + Word32 b; + Word32 iLastRMSVal; + + iLastRMSVal = pppiRMSEnvelope[n][k][0]; + move32(); + iLastRMSVal = GT_32( iLastRMSVal, ENV_MIN ) ? iLastRMSVal : ENV_MIN; + move32(); + iLastRMSVal = LT_32( iLastRMSVal, ENV_MAX ) ? iLastRMSVal : ENV_MAX; + move32(); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( iLastRMSVal, ENV_MIN ), ENV0_BITS ); + iBitsWritten = L_add( iBitsWritten, ENV0_BITS ); + + FOR( b = 1; b < iNumBands; b++ ) + { + Word32 iDelta; + + iDelta = L_sub( pppiRMSEnvelope[n][k][b], iLastRMSVal ); + iDelta = GT_32( iDelta, ENV_DELTA_MIN ) ? iDelta : ENV_DELTA_MIN; + move32(); + iDelta = LT_32( iDelta, ENV_DELTA_MAX ) ? iDelta : ENV_DELTA_MAX; + move32(); + iDelta = L_sub( iDelta, ENV_DELTA_MIN ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, c_aaiRMSEnvHuffEnc[iDelta][1], c_aaiRMSEnvHuffEnc[iDelta][0] ); + iBitsWritten = L_add( iBitsWritten, c_aaiRMSEnvHuffEnc[iDelta][0] ); + + iLastRMSVal = pppiRMSEnvelope[n][k][b]; + move32(); + } + } + } + + return iBitsWritten; +} + + +static Word32 WriteAllocInformation( + const Word32 iAllocOffset, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsWritten; + + iBitsWritten = 0; + move32(); + + IF( LT_32( iAllocOffset, MIN_ALLOC_OFFSET ) || GT_32( iAllocOffset, MAX_ALLOC_OFFSET ) ) + { + printf( "Serious error\n" ); + } + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( iAllocOffset, MIN_ALLOC_OFFSET ), ALLOC_OFFSET_BITS ); + iBitsWritten = L_add( iBitsWritten, ALLOC_OFFSET_BITS ); + + return iBitsWritten; +} + + +static Word32 WriteLCLDData( + const Word32 *piNumGroups, + Word32 **ppiGroupLengths, + const Word32 iNumBands, + const Word32 iNumChannels, + Word32 **ppiPredEnable, + const Word32 iNumSubSets, + const Word32 iSubSetId, + Word32 ***pppiAlloc, + Word32 ***pppiSignReal, + Word32 ***pppiSignImag, + Word32 ***pppiQReal, + Word32 ***pppiQImag, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word32 iBitsWritten; + Word32 iNumLcldBands = c_aiNumLcldBandsPerBand[iNumBands - 1]; + Word32 s; + Word32 iSet = iSubSetId; + + iBitsWritten = 0; + move32(); + FOR( s = 0; s < iNumSubSets; ( s++, iSet-- ) ) + { + Word32 ch; + IF( LT_32( iSet, 0 ) ) + { + iSet = L_sub( iNumSubSets, 1 ); + } + + FOR( ch = 0; ch < iNumChannels; ch++ ) + { + Word32 iBlockOffest = 0; + move32(); + Word32 n; + FOR( n = 0; n < piNumGroups[ch]; n++ ) + { + Word32 k; + FOR( k = 0; k < ppiGroupLengths[ch][n]; k++ ) + { + Word32 iFBOffset; + FOR( iFBOffset = iSet; iFBOffset < iNumLcldBands; iFBOffset += iNumSubSets ) + { + Word32 b; + Word32 iAlloc; + Word32 iHuffDim; + Word32 iHuffMod; + + b = c_aiBandIdPerLcldBand[iFBOffset]; + move32(); + + iAlloc = pppiAlloc[ch][n][b]; + move32(); + + iHuffDim = c_aiHuffmanDim[iAlloc]; + move32(); + iHuffMod = c_aiHuffmanMod[iAlloc]; + move32(); + + IF( GT_32( iAlloc, 0 ) ) + { + const UWord16( *pauiHuffmanTable )[2] = NULL; + const UWord16( *pauiHuffmanTableDPCM )[2] = NULL; + Word32 iQuantValue1; + Word32 iQuantValue2; + pauiHuffmanTable = c_apauiHuffEncTabels[iAlloc]; + pauiHuffmanTableDPCM = c_apauiHuffEncTabels[ALLOC_TABLE_SIZE + iAlloc]; + + iQuantValue1 = pppiQReal[ch][iBlockOffest][iFBOffset]; + move32(); + iQuantValue2 = pppiQImag[ch][iBlockOffest][iFBOffset]; + move32(); +#ifdef LCLD_HANDLE_PRED_START_SAMPLE + IF( ppiPredEnable[ch][iFBOffset] == 1 && ( iBlockOffest > 0 || iSet != iSubSetId ) ) +#else + IF( EQ_32( ppiPredEnable[ch][iFBOffset], 1 ) ) +#endif + { + IF( EQ_32( iHuffDim, 2 ) ) + { + Word32 iSymbol; + iSymbol = iQuantValue1; + move32(); + iSymbol *= iHuffMod; + iSymbol = L_add( iSymbol, iQuantValue2 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTableDPCM[iSymbol][1], pauiHuffmanTableDPCM[iSymbol][0] ); + iBitsWritten = L_add( iBitsWritten, pauiHuffmanTableDPCM[iSymbol][0] ); + } + ELSE + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTableDPCM[iQuantValue1][1], pauiHuffmanTableDPCM[iQuantValue1][0] ); + iBitsWritten = L_add( iBitsWritten, pauiHuffmanTableDPCM[iQuantValue1][0] ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTableDPCM[iQuantValue2][1], pauiHuffmanTableDPCM[iQuantValue2][0] ); + iBitsWritten = L_add( iBitsWritten, pauiHuffmanTableDPCM[iQuantValue2][0] ); + } + } + ELSE + { + IF( EQ_32( iHuffDim, 2 ) ) + { + Word32 iSymbol; + iSymbol = iQuantValue1; + move32(); + iSymbol *= iHuffMod; + iSymbol = L_add( iSymbol, iQuantValue2 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTable[iSymbol][1], pauiHuffmanTable[iSymbol][0] ); + iBitsWritten = L_add( iBitsWritten, pauiHuffmanTable[iSymbol][0] ); + } + ELSE + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTable[iQuantValue1][1], pauiHuffmanTable[iQuantValue1][0] ); + iBitsWritten = L_add( iBitsWritten, pauiHuffmanTable[iQuantValue1][0] ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTable[iQuantValue2][1], pauiHuffmanTable[iQuantValue2][0] ); + iBitsWritten = L_add( iBitsWritten, pauiHuffmanTable[iQuantValue2][0] ); + } + } + + IF( GT_32( iQuantValue1, 0 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pppiSignReal[ch][iBlockOffest][iFBOffset], 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + IF( GT_32( iQuantValue2, 0 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pppiSignImag[ch][iBlockOffest][iFBOffset], 1 ); + iBitsWritten = L_add( iBitsWritten, 1 ); + } + } + } + iBlockOffest++; + } + } + } + } + + return iBitsWritten; +} +static Word32 ComputeAllocation( + const Word32 iChannels, + const Word32 *piNumGroups, + Word32 **ppiGroupLengths, + const Word32 iNumBands, + const Word32 *piBandwidths, + Word32 ***pppfReal_fx, + Word32 ***pppfImag_fx, + Word16 q_final, + Word32 ***pppiSMR, + const Word32 iAvailableBits, + Word32 *piAllocOffset, + Word32 ***pppiAlloc, + Word32 ***pppiQReal, + Word32 ***pppiQImag, + Word32 ***pppiSignReal, + Word32 ***pppiSignImag, + PredictionEncoder *psPredictionEncoder ) +{ + Word32 iBitsUsed, iDone, iDelta; + Word32 b, k, n; + Word32 iLimitAllocOffset; + + iBitsUsed = ALLOC_OFFSET_BITS; /* Bits used for Alloc Offset */ + move32(); + iDone = 0; + move32(); + iDelta = -MIN_ALLOC_OFFSET; + move32(); + *piAllocOffset = 0; + move32(); + WHILE( EQ_32( iDone, 0 ) ) + { + iBitsUsed = ALLOC_OFFSET_BITS; + move32(); + iLimitAllocOffset = *piAllocOffset; + move32(); + iLimitAllocOffset = GT_32( iLimitAllocOffset, MIN_ALLOC_OFFSET ) ? iLimitAllocOffset : MIN_ALLOC_OFFSET; + iLimitAllocOffset = LT_32( iLimitAllocOffset, MAX_ALLOC_OFFSET ) ? iLimitAllocOffset : MAX_ALLOC_OFFSET; + + FOR( n = 0; n < iChannels; n++ ) + { + FOR( k = 0; k < piNumGroups[n]; k++ ) + { + FOR( b = 0; b < iNumBands; b++ ) + { + Word32 iAlloc; + iAlloc = ( L_shr( L_add( pppiSMR[n][k][b], L_mult0( extract_l( iLimitAllocOffset ), ALLOC_OFFSET_SCALE ) ), 5 ) ); + iAlloc = GT_32( iAlloc, MIN_ALLOC ) ? iAlloc : MIN_ALLOC; + iAlloc = LT_32( iAlloc, MAX_ALLOC ) ? iAlloc : MAX_ALLOC; + pppiAlloc[n][k][b] = iAlloc; + move32(); + } + } + IF( psPredictionEncoder->iNumSubSets > 1 ) + { + mvl2l( psPredictionEncoder->ppfPredStateReal_fx[n], psPredictionEncoder->ppfPredStateRealTmp_fx[n], LCLD_BANDS ); + mvl2l( psPredictionEncoder->ppfPredStateImag_fx[n], psPredictionEncoder->ppfPredStateImagTmp_fx[n], LCLD_BANDS ); + } + + QuantizeSpectrumDPCM_Opt( piNumGroups[n], + (const Word32 *) ppiGroupLengths[n], + iNumBands, + piBandwidths, + pppiAlloc[n], + pppfReal_fx[n], + pppfImag_fx[n], + q_final, + pppiQReal[n], + pppiQImag[n], + pppiSignReal[n], + pppiSignImag[n], + psPredictionEncoder->iNumSubSets, + psPredictionEncoder->iSubSetId, + psPredictionEncoder->ppiPredBandEnable[n], + psPredictionEncoder->ppfA1Real_fx[n], + psPredictionEncoder->ppfA1Imag_fx[n], + psPredictionEncoder->ppfPredStateRealTmp_fx[n], + psPredictionEncoder->ppfPredStateImagTmp_fx[n] ); + iBitsUsed = L_add( iBitsUsed, CountLCLDBits( piNumGroups[n], + (const Word32 *) ppiGroupLengths[n], + iNumBands, + piBandwidths, + (const Word32 *) psPredictionEncoder->ppiPredBandEnable[n], + pppiAlloc[n], + pppiQReal[n], + pppiQImag[n] ) ); + } + + IF( LE_32( *piAllocOffset, MIN_ALLOC_OFFSET ) && GT_32( iBitsUsed, iAvailableBits ) ) + { +#ifdef DEBUG_VERBOSE + printf( "Frame can not be coded with the number of bits available\n" ); +#endif + // iLastError = ENC_ERROR_STREAM_FAILURE; + return -1; + } + ELSE IF( GE_32( *piAllocOffset, MAX_ALLOC_OFFSET ) && LT_32( iBitsUsed, iAvailableBits ) ) + { + *piAllocOffset = MAX_ALLOC_OFFSET; + iDone++; + } + ELSE + { + IF( EQ_32( iDelta, 0 ) && GT_32( iBitsUsed, iAvailableBits ) ) + { + iDelta = 1; + } + ELSE IF( EQ_32( iDelta, 0 ) && LT_32( iBitsUsed, iAvailableBits ) ) + { + iDone++; + } + ELSE IF( EQ_32( iBitsUsed, iAvailableBits ) ) + { + iDone++; + } + + IF( GT_32( iBitsUsed, iAvailableBits ) ) + { + *piAllocOffset -= iDelta; + iDelta = L_shr( iDelta, 1 ); + } + ELSE IF( LT_32( iBitsUsed, iAvailableBits ) ) + { + *piAllocOffset += iDelta; + iDelta = L_shr( iDelta, 1 ); + } + } + } + IF( GT_32( psPredictionEncoder->iNumSubSets, 1 ) ) + { + FOR( n = 0; n < iChannels; n++ ) + { + mvl2l( psPredictionEncoder->ppfPredStateRealTmp_fx[n], psPredictionEncoder->ppfPredStateReal_fx[n], LCLD_BANDS ); + mvl2l( psPredictionEncoder->ppfPredStateImagTmp_fx[n], psPredictionEncoder->ppfPredStateImag_fx[n], LCLD_BANDS ); + } + } + return iBitsUsed; +} +#endif diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h new file mode 100644 index 000000000..a37134857 --- /dev/null +++ b/lib_isar/isar_lcld_prot.h @@ -0,0 +1,457 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LCLD_PROT_H +#define ISAR_LCLD_PROT_H + +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "typedef.h" +#include "common_api_types.h" +#include "isar_lcld_rom_tables.h" +// #include "prot.h" +/* clang-format off */ + +typedef struct LCLD_ENCODER LCLDEncoder; + +ivas_error CreateLCLDEncoder( + LCLDEncoder **psLCLDEncoder_out, + const Word32 iSampleRate, + const Word32 iChannels, + const Word32 iTargetBitRate, + const Word32 iAllowSidePred, + const Word16 iNumBlocks, + const Word16 iNumSubSets, + const Word32 iRealOnlyOut); +void DeleteLCLDEncoder( + LCLDEncoder *psLCLDEncoder +); + +Word32 EncodeLCLDFrame( + LCLDEncoder *psLCLDEncoder, + Word32 ***pppfLCLDReal_fx, + Word32 ***pppfLCLDImag_fx, + Word32 *piNumiBites, + const Word32 available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word16 *q_final); + +Word32 GetNumGroups( + LCLDEncoder *psLCLDEncoder +); + + +typedef struct LCLD_DECODER LCLDDecoder; + +ivas_error CreateLCLDDecoder( + LCLDDecoder **psLCLDDecoder_out, + const Word32 iSampleRate, + const Word32 iChannels, + const Word32 iNumBlocks, + const Word32 iRealOnlyOut); + + +void DeleteLCLDDecoder( + LCLDDecoder *psLCLDDecoder +); + +Word32 DecodeLCLDFrame( + LCLDDecoder *psLCLDDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word32 ***pppfLCLDReal_fx, + Word32 ***pppfLCLDImag_fx, + Word16 Q_in, + Word16 *Q_out +); + +/*----------------------------------------------------------------------------------* + * MSPred prototypes + *----------------------------------------------------------------------------------*/ +Word32 quantPhase_fx( + Word32 phase, + Word16 exp); + +int32_t quantPhase( + float phase +); + +void cplxmult( + float *pr1, + float *pi1, + float r2, + float i2 +); +void cplxmult_fx( + Word32 *pr1, + Word32 *pi1, + Word32 r2, + Word32 i2 +); + +Word32 requantPhase( + Word32 phaseQ +); + +Word32 quantPred_fx( + const Word32 pred, + Word16 exp); +int32_t quantPred( + const float pred +); + +float dequantPhase( + const int32_t phaseQ +); + +float dequantPred( + int32_t predQ +); +Word32 dequantPred_fx( + Word32 predQ +); +Word32 PrepEncode( + Word32 *piQuant, + const Word32 *piMSFlags, + const Word32 numBands +); + +void EncodePhase( + Word32 *phaseQuant, + const Word32 numMSBands, + const Word32 diffDim +); + +void DecodePhase( + Word32 *phaseQuant, + const Word32 numMSBands, + const Word32 diffDim +); + +Word32 EncodePredCoef( + Word32 *predQuant, + const Word32 numMSBands +); + +void DecodePredCoef( + Word32 *phaseQuant, + const Word32 numMSBands +); + +void writeMSPred( + int32_t *phaseQuant, + int32_t *predQuant, + const int32_t MSMode, + const int32_t numMSBands, + int32_t numBands, + void *fid, + int32_t *piMsFlags +); + +Word32 CountMSBits( + Word32 iNumBands, + const Word32 iMSMode, + const Word32 *piMSFlags, + const Word32 *piLRPhaseDiff, + const Word32 *piMSPredCoef +); + + +/*----------------------------------------------------------------------------------* + * NoiseGen prototypes + *----------------------------------------------------------------------------------*/ + +typedef struct NOISE_GEN +{ + int32_t iNoiseBufferLength; + int32_t iNoiseBufferMask; + int32_t iNoiseBufferIndex; + float *pfNoiseBuffer; +} NoiseGen; + +void DeleteNoiseGen( + NoiseGen *psNoiseGen +); + +inline float GetNoise( NoiseGen *psNoiseGen ) +{ + float fNoiseSample; + + fNoiseSample = psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex]; + psNoiseGen->iNoiseBufferIndex++; + psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask; + + return fNoiseSample; +} +inline Word32 GetNoise_fx( NoiseGen *psNoiseGen ) +{ + Word32 fNoiseSample; + + fNoiseSample = (Word32) (psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex]* (1<<14)); + psNoiseGen->iNoiseBufferIndex++; + psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask; + + return fNoiseSample; +} + +/*----------------------------------------------------------------------------------* + * PereptualModel prototypes + *----------------------------------------------------------------------------------*/ + +extern void PerceptualModel( + const int32_t iMaxQuantBands, + const int32_t *piRMSEnvelope, + int32_t *piExcitation, + int32_t *piSMR +); +extern void PerceptualModel_fx( + const Word32 iMaxQuantBands, + const Word32 *piRMSEnvelope, + Word32 *piExcitation, + Word32 *piSMR +); + +extern void PerceptualModelStereo_fx( + const Word32 iMaxQuantBands, + const Word32 *piMSFlags, + const Word32 *piRMSEnvelope0, + const Word32 *piRMSEnvelope1, + Word32 *piExcitation0, + Word32 *piExcitation1, + Word32 *piSMR0, + Word32 *piSMR1 +); +extern void PerceptualModelStereo( + const int32_t iMaxQuantBands, + const int32_t *piMSFlags, + const int32_t *piRMSEnvelope0, + const int32_t *piRMSEnvelope1, + int32_t *piExcitation0, + int32_t *piExcitation1, + int32_t *piSMR0, + int32_t *piSMR1 +); + + +/*----------------------------------------------------------------------------------* + * PredEncoder/PredDecoder prototypes + *----------------------------------------------------------------------------------*/ + +typedef struct PREDICTION_ENCODER +{ + int32_t iChannels; + int32_t iNumBlocks; + + int32_t iSubSetId; + int32_t iNumSubSets; + int32_t iMaxNumPredBands; + Word32 ***pppfInpBufReal_fx; /* channels, LCLD_PRED_WIN_LEN, bands */ + Word32 ***pppfInpBufImag_fx; + Word32 **ppfPredStateReal_fx; /* channels, bands */ + Word32 **ppfPredStateImag_fx; + Word32 **ppfPredStateRealTmp_fx; + Word32 **ppfPredStateImagTmp_fx; + Word32 **ppfInpPrevReal_fx; /* channels, bands */ + Word32 **ppfInpPrevImag_fx; + float ***pppfInpBufReal; /* channels, LCLD_PRED_WIN_LEN, bands */ + float ***pppfInpBufImag; + float **ppfPredStateReal; /* channels, bands */ + float **ppfPredStateImag; + float **ppfPredStateRealTmp; + float **ppfPredStateImagTmp; + float **ppfInpPrevReal; /* channels, bands */ + float **ppfInpPrevImag; + Word32 pfRxxReal_fx[2]; + Word32 pfRxxImag_fx[2]; + float pfRxxReal[2]; + float pfRxxImag[2]; + + int32_t *piPredChanEnable; + int32_t *piNumPredBands; + int32_t **ppiPredBandEnable; + + Word32 **ppfA1Real_fx; + Word32 **ppfA1Imag_fx; + float **ppfA1Real; + float **ppfA1Imag; + + int32_t **ppiA1Mag; + int32_t **ppiA1Phase; +} PredictionEncoder; + +ivas_error CreatePredictionEncoder_fx( + PredictionEncoder **psPredictionEncoder_out, + const Word32 iChannels, + const Word32 iNumBlocks, + const Word32 iNumSubSets, + const Word32 iMaxNumPredBands ); + +void DeletePredictionEncoder_fx( + PredictionEncoder *psPredictionEncoder ); +ivas_error CreatePredictionEncoder( + PredictionEncoder **psPredictionEncoder_out, + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iNumSubSets, + const int32_t iMaxNumPredBands +); + +void DeletePredictionEncoder( + PredictionEncoder *psPredictionEncoder +); + +void ComputePredictors( + PredictionEncoder *psPredictionEncoder, + float ***pppfReal, + float ***pppfImag +); +void ComputePredictors_fx( + PredictionEncoder *psPredictionEncoder, + Word32 ***pppfReal_fx, //Q12? + Word32 ***pppfImag_fx); //Q12? + + +Word32 WritePredictors( + PredictionEncoder *psPredictionEncoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +typedef struct PREDICTION_DECODER +{ + int32_t iChannels; + int32_t iNumBlocks; + int32_t iSubSetId; + int32_t iNumSubSets; + Word32 **ppfPredStateReal_fx; + Word32 **ppfPredStateImag_fx; + + int32_t *piPredChanEnable; + int32_t **ppiPredBandEnable; + /* PLC_IMPROVEMENT */ + int32_t **ppiDecodingUnresolved; + int32_t **ppiDecodingFailed; + int32_t **ppiDecodingFailedPrev; + Word32 **ppfA1Real_fx; /* Q31 */ + Word32 **ppfA1Imag_fx; /* Q31 */ + + int32_t **ppiA1Mag; + int32_t **ppiA1Phase; + + Word32 pfMagLUT_fx[1 << PRED_QUNAT_FILTER_MAG_BITS]; /* Q31 */ + Word32 pfP2RRealLUT_fx[1 << PRED_QUANT_FILTER_PHASE_BITS]; /* Q31 */ + Word32 pfP2RImagLUT_fx[1 << PRED_QUANT_FILTER_PHASE_BITS]; /* Q31 */ + +} PredictionDecoder; + + +ivas_error CreatePredictionDecoder_fx( + PredictionDecoder **psPredictionDecoder_out, + const Word32 iChannels, + const Word32 iNumBlocks ); + +void DeletePredictionDecoder_fx( + PredictionDecoder *psPredictionDecoder ); + +Word32 ReadPredictors_fx( + PredictionDecoder *psPredictionDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits +); + +/* PLC_IMPROVEMENT */ +void UpdatePredictionSubSetId( + PredictionEncoder *psPredictionEncoder); + +void SetDecodingUnresolved( + LCLDDecoder *psLCLDDecoder); + +int32_t AnyDecodingFailedPrev( + LCLDDecoder *psLCLDDecoder); + +int32_t AnyDecodingFailed( + LCLDDecoder *psLCLDDecoder); + +int32_t **GetDecodingFailedStatus( + LCLDDecoder *psLCLDDecoder); + +int16_t GetNumSubSets( + LCLDDecoder *psLCLDDecoder); + +int32_t **GetDecodingFailedPrevStatus( + LCLDDecoder *psLCLDDecoder); + +void SetDecodingPassed( + PredictionDecoder *psPredictionDecoder); + +void UpdateDecodingUnresolved( + PredictionDecoder *psPredictionDecoder); + +void UpdateDecodingFailedStatus( + PredictionDecoder *psPredictionDecoder); + +int32_t AnyDecodingUnresolved( + PredictionDecoder *psPredictionDecoder); + +void ApplyInversePredictors_fx( + PredictionDecoder *psPredictionDecoder, + Word32 ***pppfReal, + Word32 ***pppfImag +); + + +/*----------------------------------------------------------------------------------* + * RMSEnvGrouping prototypes + *----------------------------------------------------------------------------------*/ + +typedef struct RMS_ENVELOPE_GROUPING RMSEnvelopeGrouping; + +RMSEnvelopeGrouping *CreateRMSEnvelopeGrouping( + const int32_t iNumBlocks +); + +void DeleteRMSEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping +); +void ComputeEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping, + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + Word32 ***pppfReal_fx, + Word32 ***pppfImag_fx, + int32_t *piNumGroups, + int32_t *piGroupLengths, + int32_t ***pppiRMSEnvelope , + Word16 q_final +); + +#endif +/* clang-format on */ + +#endif /* _LCLD_ENCODER_H_ */ diff --git a/lib_isar/isar_lcld_rom_tables.c b/lib_isar/isar_lcld_rom_tables.c new file mode 100644 index 000000000..d101c0eac --- /dev/null +++ b/lib_isar/isar_lcld_rom_tables.c @@ -0,0 +1,21207 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "isar_lcld_rom_tables.h" +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "wmc_auto.h" +#include "prot.h" +#include "isar_lcld_prot.h" +#include + +/* clang-format off */ +const int32_t c_aiNumLcldBandsPerBand[MAX_BANDS_48] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 24, 27, 31, 37, 43, 50, 60 +}; + +const int32_t c_aiBandIdPerLcldBand[LCLD_BANDS] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, + 18, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22 +}; +/* phi = (-12:12)'/12 *pi; tmp = [cos(phi),sin(phi)]; tmp = tmp';sprintf('{%.8ff, %.8ff},\n',tmp(:)) */ +const float c_afRotRealImag[PHASE_MAX_VAL - PHASE_MIN_VAL + 1][2] = +{ + { -1.00000000f, -0.00000000f }, + { -0.96592583f, -0.25881905f }, + { -0.86602540f, -0.50000000f }, + { -0.70710678f, -0.70710678f }, + { -0.50000000f, -0.86602540f }, + { -0.25881905f, -0.96592583f }, + { 0.00000000f, -1.00000000f }, + { 0.25881905f, -0.96592583f }, + { 0.50000000f, -0.86602540f }, + { 0.70710678f, -0.70710678f }, + { 0.86602540f, -0.50000000f }, + { 0.96592583f, -0.25881905f }, + { 1.00000000f, 0.00000000f }, + { 0.96592583f, 0.25881905f }, + { 0.86602540f, 0.50000000f }, + { 0.70710678f, 0.70710678f }, + { 0.50000000f, 0.86602540f }, + { 0.25881905f, 0.96592583f }, + { 0.00000000f, 1.00000000f }, + { -0.25881905f, 0.96592583f }, + { -0.50000000f, 0.86602540f }, + { -0.70710678f, 0.70710678f }, + { -0.86602540f, 0.50000000f }, + { -0.96592583f, 0.25881905f }, + { -1.00000000f, 0.00000000f } +}; + +const Word32 c_afRotRealImag_fx[PHASE_MAX_VAL - PHASE_MIN_VAL + 1][2] = /*Q31*/ +{ + {-2147483647,0,}, + {-2074309888,-555809664,}, + {-1859775360,-1073741824,}, + {-1518500224,-1518500224,}, + {-1073741824,-1859775360,}, + {-555809664,-2074309888,}, + {0,-2147483647,}, + {555809664,-2074309888,}, + {1073741824,-1859775360,}, + {1518500224,-1518500224,}, + {1859775360,-1073741824,}, + {2074309888,-555809664,}, + {2147483647,0,}, + {2074309888,555809664,}, + {1859775360,1073741824,}, + {1518500224,1518500224,}, + {1073741824,1859775360,}, + {555809664,2074309888,}, + {0,2147483647,}, + {-555809664,2074309888,}, + {-1073741824,1859775360,}, + {-1518500224,1518500224,}, + {-1859775360,1073741824,}, + {-2074309888,555809664,}, + {-2147483647,0,}, + +}; +/* Move this to perceptual model ? */ +const int32_t c_aiBandwidths48[MAX_BANDS_48] = +{ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 3, + 3, + 4, + 6, + 6, + 7, + 10, +}; + + +const float c_afScaleFactor[ALLOC_TABLE_SIZE] = { + 0.0f, + 0.353553390593f, + 0.420448207627f, + 0.500000000000f, + 0.594603557501f, + 0.707106781187f, + 0.840896415254f, + 1.000000000000f, + 1.189207115003f, + 1.414213562373f, + 1.681792830507f, + 2.000000000000f, + 2.378414230005f, + 2.828427124746f, + 3.363585661015f, + 4.0f, + 4.756828460011f, + 5.656854249492f, + 6.727171322030f, + 8.0f, + 9.513656920022f, + 11.31370849898f, + 13.45434264406f, + 16.00000000000f, + 19.02731384004f, + 22.62741699797f, + 26.90868528812f, + 32.000000000000000f, + 38.054627680087073f, + 45.254833995939038f, + 53.817370576237735f, + 64.000000000000000f, +}; +const Word32 c_afScaleFactor_fx[ALLOC_TABLE_SIZE] = { + //Q24 + 0, + 5931641, + 7053950, + 8388608, + 9975792, + 11863283, + 14107901, + 16777216, + 19951584, + 23726566, + 28215802, + 33554432, + 39903168, + 47453132, + 56431604, + 67108864, + 79806336, + 94906264, + 112863208, + 134217728, + 159612672, + 189812528, + 225726416, + 268435456, + 319225344, + 379625056, + 451452832, + 536870912, + 638450688, + 759250112, + 902905664, + 1073741824, +}; +const float c_afInvScaleFactor[ALLOC_TABLE_SIZE] = { + 0.0f, + 2.367513562373095f, + 2.046407115002721f, + 1.775900000000000f, + 1.536446415253715f, + 1.323056781186548f, + 1.132903557501360f, + 0.965800000000000f, + 0.821348207626857f, + 0.695103390593274f, + 0.587801778750680f, + 0.495800000000000f, + 0.418124103813429f, + 0.352176695296637f, + 0.296200889375340f, + 0.249400000000000f, + 0.209812051906714f, + 0.176538347648318f, + 0.148525444687670f, + 0.124900000000000f, + 0.105056025953357f, + 0.088388347648318f, + 0.074325444687670f, + 0.062500000000000f, + 0.052556025953357f, + 0.044194173824159f, + 0.037162722343835f, + 0.031250000000000f, + 0.026278012976679f, + 0.022097086912080f, + 0.018581361171918f, + 0.015625000000000f, +}; +const Word32 c_afInvScaleFactor_fx[ALLOC_TABLE_SIZE] = { + //Q29 + 0, + 1271049216, + 1098656512, + 953429056, + 824873408, + 710310720, + 608222976, + 518509920, + 440957952, + 373180800, + 315573664, + 266180592, + 224478672, + 189073424, + 159021648, + 133895608, + 112641984, + 94778304, + 79738992, + 67055176, + 56401524, + 47453132, + 39903168, + 33554432, + 28215802, + 23726566, + 19951584, + 16777216, + 14107901, + 11863283, + 9975792, + 8388608, +}; +const float c_afRMSEnvReconstructTable[ENV_RECONSTRUCT_TABLE_SIZE] = { + 2.32830644e-10f, + 3.29272254e-10f, + 4.65661287e-10f, + 6.58544508e-10f, + 9.31322575e-10f, + 1.31708902e-09f, + 1.86264515e-09f, + 2.63417803e-09f, + 3.72529030e-09f, + 5.26835606e-09f, + 7.45058060e-09f, + 1.05367121e-08f, + 1.49011612e-08f, + 2.10734243e-08f, + 2.98023224e-08f, + 4.21468485e-08f, + 5.96046448e-08f, + 8.42936970e-08f, + 1.19209290e-07f, + 1.68587394e-07f, + 2.38418579e-07f, + 3.37174788e-07f, + 4.76837158e-07f, + 6.74349576e-07f, + 9.53674316e-07f, + 1.34869915e-06f, + 1.90734863e-06f, + 2.69739830e-06f, + 3.81469727e-06f, + 5.39479661e-06f, + 7.62939453e-06f, + 1.07895932e-05f, + 1.52587891e-05f, + 2.15791864e-05f, + 3.05175781e-05f, + 4.31583729e-05f, + 6.10351562e-05f, + 8.63167458e-05f, + 1.22070312e-04f, + 1.72633492e-04f, + 2.44140625e-04f, + 3.45266983e-04f, + 4.88281250e-04f, + 6.90533966e-04f, + 9.76562500e-04f, + 1.38106793e-03f, + 1.95312500e-03f, + 2.76213586e-03f, + 3.90625000e-03f, + 5.52427173e-03f, + 7.81250000e-03f, + 1.10485435e-02f, + 1.56250000e-02f, + 2.20970869e-02f, + 3.12500000e-02f, + 4.41941738e-02f, + 6.25000000e-02f, + 8.83883476e-02f, + 1.25000000e-01f, + 1.76776695e-01f, + 2.50000000e-01f, + 3.53553391e-01f, + 5.00000000e-01f, + 7.07106781e-01f, + 1.00000000e+00f, + 1.41421356e+00f, + 2.00000000e+00f, + 2.82842712e+00f, + 4.00000000e+00f, + 5.65685425e+00f, + 8.00000000e+00f, + 1.13137085e+01f, + 1.60000000e+01f, + 2.26274170e+01f, + 3.20000000e+01f, + 4.52548340e+01f, + 6.40000000e+01f, + 9.05096680e+01f, + 1.28000000e+02f, + 1.81019336e+02f, + 2.56000000e+02f, + 3.62038672e+02f, + 5.12000000e+02f, + 7.24077344e+02f, + 1.02400000e+03f, + 1.44815469e+03f, + 2.04800000e+03f, + 2.89630938e+03f, + 4.09600000e+03f, + 5.79261875e+03f, + 8.19200000e+03f, + 1.15852375e+04f, + 1.63840000e+04f, + 2.31704750e+04f, + 3.27680000e+04f, + 4.63409500e+04f, + 6.55360000e+04f, + 9.26819000e+04f, + 1.31072000e+05f, + 1.85363800e+05f, + 2.62144000e+05f, + 3.70727600e+05f, + 5.24288000e+05f, + 7.41455200e+05f, + 1.04857600e+06f, + 1.48291040e+06f, + 2.09715200e+06f, + 2.96582080e+06f, + 4.19430400e+06f, + 5.93164160e+06f, + 8.38860800e+06f, + 1.18632832e+07f, + 1.67772160e+07f, + 2.37265664e+07f, + 3.35544320e+07f, + 4.74531328e+07f, + 6.71088640e+07f, + 9.49062656e+07f, + 1.34217728e+08f, + 1.89812531e+08f, + 2.68435456e+08f, + 3.79625062e+08f, + 5.36870912e+08f, + 7.59250125e+08f, + 1.07374182e+09f, + 1.51850025e+09f, + 2.14748365e+09f, + 3.03700050e+09f, + 4.29496730e+09f, +}; + +const int16_t c_afRMSEnvReconstructTable_exp[ENV_RECONSTRUCT_TABLE_SIZE] = +{ + 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2 +}; +const Word32 c_aiQuantMaxValues_fx[ALLOC_TABLE_SIZE] = { + //Q21 + 0, +6291456, +6291456, +8388608, +10485760, +10485760, +12582912, +14680064, +16777216, +18874368, +25165824, +27262976, +33554432, +35651584, +39845888, +48234496, +54525952, +54525952, +56623104, +58720256, +65011712, +75497472, +79691776, +94371840, +113246208, +134217728, +159383552, +188743680, +226492416, +268435456, +318767104, +377487360, +}; +const int32_t c_aiQuantMaxValues[ALLOC_TABLE_SIZE] = { + 0, + 3, + 3, + 4, + 5, + 5, + 6, + 7, + 8, + 9, + 12, + 13, + 16, + 17, + 19, + 23, + 26, + 26, + 27, + 28, + 31, + 36, + 38, + 45, + 54, + 64, + 76, + 90, + 108, + 128, + 152, + 180, +}; +const Word32 c_aiHuffmanDim_fx[ALLOC_TABLE_SIZE] = { + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, +}; + +const Word32 c_aiHuffmanMod_fx[ALLOC_TABLE_SIZE] = { + 0, + 4, + 4, + 5, + 6, + 6, + 7, + 8, + 9, + 10, + 13, + 14, + 17, + 18, + 20, + 24, + 27, + 27, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, +}; + +const int32_t c_aiHuffmanDim[ALLOC_TABLE_SIZE] = { + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, +}; + +const int32_t c_aiHuffmanMod[ALLOC_TABLE_SIZE] = { + 0, + 4, + 4, + 5, + 6, + 6, + 7, + 8, + 9, + 10, + 13, + 14, + 17, + 18, + 20, + 24, + 27, + 27, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, +}; +const int32_t c_aiHuffmanSize[ALLOC_TABLE_SIZE] = { + 1, + 16, + 16, + 25, + 36, + 36, + 49, + 64, + 81, + 100, + 169, + 196, + 289, + 324, + 400, + 576, + 729, + 729, + 28, + 29, + 32, + 37, + 39, + 46, + 55, + 65, + 77, + 91, + 109, + 129, + 153, + 181, +}; + +const uint32_t c_aaiRMSEnvHuffEnc[64][2] = { + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0012, 0x000b }, + { 0x000d, 0x0002 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0007, 0x0004 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0005, 0x0003 }, + { 0x0004, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0003 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, +}; + +const uint32_t c_aaiRMSEnvHuffDec[13][HUFF_DEC_TABLE_SIZE] = { + { + 0x0002ffff, + 0x0001ffff, + 0x0000001d, + 0x00000022, + 0x0001001e, + 0x0001001e, + 0x00010021, + 0x00010021, + 0x0002001f, + 0x0002001f, + 0x0002001f, + 0x0002001f, + 0x00020020, + 0x00020020, + 0x00020020, + 0x00020020, + }, + { + 0x0002001b, + 0x0002001b, + 0x0002001b, + 0x0002001b, + 0x00020023, + 0x00020023, + 0x00020023, + 0x00020023, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + }, + { + 0x0006ffff, + 0x0007ffff, + 0x0003ffff, + 0x0004ffff, + 0x0005ffff, + 0x00000017, + 0x00000018, + 0x00000025, + 0x00010019, + 0x00010019, + 0x00010024, + 0x00010024, + 0x0002001a, + 0x0002001a, + 0x0002001a, + 0x0002001a, + }, + { + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + }, + { + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + }, + { + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + }, + { + 0x0009ffff, + 0x0008ffff, + 0x0000002c, + 0x0000002d, + 0x00010010, + 0x00010010, + 0x0001002b, + 0x0001002b, + 0x0001002e, + 0x0001002e, + 0x0001002f, + 0x0001002f, + 0x00020011, + 0x00020011, + 0x00020011, + 0x00020011, + }, + { + 0x00020012, + 0x00020012, + 0x00020012, + 0x00020012, + 0x00020013, + 0x00020013, + 0x00020013, + 0x00020013, + 0x00020029, + 0x00020029, + 0x00020029, + 0x00020029, + 0x0002002a, + 0x0002002a, + 0x0002002a, + 0x0002002a, + }, + { + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + }, + { + 0x000bffff, + 0x000cffff, + 0x000affff, + 0x00000031, + 0x0002000d, + 0x0002000d, + 0x0002000d, + 0x0002000d, + 0x0002000e, + 0x0002000e, + 0x0002000e, + 0x0002000e, + 0x00020030, + 0x00020030, + 0x00020030, + 0x00020030, + }, + { + 0x0001003a, + 0x0001003a, + 0x0001003b, + 0x0001003b, + 0x0001003c, + 0x0001003c, + 0x0001003d, + 0x0001003d, + 0x0001003e, + 0x0001003e, + 0x0001003f, + 0x0001003f, + 0x0002000b, + 0x0002000b, + 0x0002000b, + 0x0002000b, + }, + { + 0x00000000, + 0x00000001, + 0x00000002, + 0x00000003, + 0x00000004, + 0x00000005, + 0x00010006, + 0x00010006, + 0x00010007, + 0x00010007, + 0x00010008, + 0x00010008, + 0x00010009, + 0x00010009, + 0x0001000a, + 0x0001000a, + }, + { + 0x00010032, + 0x00010032, + 0x00010033, + 0x00010033, + 0x00010034, + 0x00010034, + 0x00010035, + 0x00010035, + 0x00010036, + 0x00010036, + 0x00010037, + 0x00010037, + 0x00010038, + 0x00010038, + 0x00010039, + 0x00010039, + }, +}; + +const uint16_t c_aauiLCLDHuffEnc1[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0005, 0x0001 }, + { 0x000b, 0x0000 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + }; + +const uint16_t c_aauiLCLDHuffEnc2[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0005, 0x0001 }, + { 0x000c, 0x0000 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000b, 0x0003 }, + }; + +const uint16_t c_aauiLCLDHuffEnc3[25][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000d, 0x0000 }, + { 0x000d, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x0009, 0x0001 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc4[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0010, 0x0000 }, + { 0x0010, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000e, 0x0006 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0010, 0x0008 }, + { 0x0010, 0x0009 }, + { 0x0010, 0x000a }, + { 0x0010, 0x000b }, + { 0x0010, 0x000c }, + { 0x0010, 0x000d }, + { 0x0010, 0x000e }, + { 0x0010, 0x000f }, + { 0x0010, 0x0010 }, + { 0x0010, 0x0011 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc5[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000f, 0x0003 }, + { 0x0012, 0x0000 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0011, 0x0008 }, + { 0x0012, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000d, 0x0001 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0011, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0011, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc6[49][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x0010, 0x0003 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x0010, 0x0004 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x0012, 0x0007 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0011, 0x0004 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0010, 0x0005 }, + { 0x000f, 0x0003 }, + { 0x0011, 0x0005 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0013, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc7[64][2] = + { + { 0x0002, 0x0001 }, + { 0x0002, 0x0002 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x0015, 0x0000 }, + { 0x0015, 0x0001 }, + { 0x0015, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0014, 0x0011 }, + { 0x0015, 0x0003 }, + { 0x0015, 0x0004 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0015, 0x0005 }, + { 0x0015, 0x0006 }, + { 0x0015, 0x0007 }, + { 0x000a, 0x0001 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0001 }, + { 0x000f, 0x0004 }, + { 0x0012, 0x0006 }, + { 0x0015, 0x0008 }, + { 0x0015, 0x0009 }, + { 0x0015, 0x000a }, + { 0x000f, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x0012, 0x0007 }, + { 0x0014, 0x0012 }, + { 0x0015, 0x000b }, + { 0x0015, 0x000c }, + { 0x0015, 0x000d }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0013, 0x000b }, + { 0x0014, 0x0015 }, + { 0x0015, 0x000e }, + { 0x0015, 0x000f }, + { 0x0015, 0x0010 }, + { 0x0015, 0x0011 }, + { 0x0015, 0x0012 }, + { 0x0015, 0x0013 }, + { 0x0015, 0x0014 }, + { 0x0015, 0x0015 }, + { 0x0015, 0x0016 }, + { 0x0015, 0x0017 }, + { 0x0015, 0x0018 }, + { 0x0015, 0x0019 }, + { 0x0015, 0x001a }, + { 0x0015, 0x001b }, + { 0x0015, 0x001c }, + { 0x0015, 0x001d }, + { 0x0015, 0x001e }, + { 0x0015, 0x001f }, + { 0x0015, 0x0020 }, + { 0x0015, 0x0021 }, + }; + +const uint16_t c_aauiLCLDHuffEnc8[81][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x0014, 0x0008 }, + { 0x0017, 0x0000 }, + { 0x0017, 0x0001 }, + { 0x0017, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000f, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0015, 0x000d }, + { 0x0017, 0x0003 }, + { 0x0017, 0x0004 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0013, 0x0005 }, + { 0x0017, 0x0005 }, + { 0x0017, 0x0006 }, + { 0x0017, 0x0007 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000b, 0x0001 }, + { 0x000f, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0016, 0x0015 }, + { 0x0017, 0x0008 }, + { 0x0017, 0x0009 }, + { 0x0017, 0x000a }, + { 0x000f, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x0012, 0x0006 }, + { 0x0014, 0x0009 }, + { 0x0017, 0x000b }, + { 0x0017, 0x000c }, + { 0x0017, 0x000d }, + { 0x0017, 0x000e }, + { 0x0013, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0013, 0x0007 }, + { 0x0015, 0x000e }, + { 0x0017, 0x000f }, + { 0x0017, 0x0010 }, + { 0x0017, 0x0011 }, + { 0x0017, 0x0012 }, + { 0x0017, 0x0013 }, + { 0x0016, 0x0016 }, + { 0x0016, 0x0017 }, + { 0x0015, 0x000f }, + { 0x0016, 0x0018 }, + { 0x0017, 0x0014 }, + { 0x0017, 0x0015 }, + { 0x0017, 0x0016 }, + { 0x0017, 0x0017 }, + { 0x0017, 0x0018 }, + { 0x0017, 0x0019 }, + { 0x0017, 0x001a }, + { 0x0017, 0x001b }, + { 0x0017, 0x001c }, + { 0x0017, 0x001d }, + { 0x0017, 0x001e }, + { 0x0017, 0x001f }, + { 0x0017, 0x0020 }, + { 0x0017, 0x0021 }, + { 0x0017, 0x0022 }, + { 0x0017, 0x0023 }, + { 0x0017, 0x0024 }, + { 0x0017, 0x0025 }, + { 0x0017, 0x0026 }, + { 0x0017, 0x0027 }, + { 0x0017, 0x0028 }, + { 0x0017, 0x0029 }, + { 0x0016, 0x0019 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc9[100][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x0011, 0x0004 }, + { 0x0014, 0x000a }, + { 0x0017, 0x0000 }, + { 0x0017, 0x0001 }, + { 0x0017, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0013, 0x0007 }, + { 0x0016, 0x0018 }, + { 0x0017, 0x0003 }, + { 0x0017, 0x0004 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000e, 0x0002 }, + { 0x0011, 0x0005 }, + { 0x0014, 0x000b }, + { 0x0016, 0x0019 }, + { 0x0017, 0x0005 }, + { 0x0017, 0x0006 }, + { 0x0009, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0015, 0x000f }, + { 0x0017, 0x0007 }, + { 0x0017, 0x0008 }, + { 0x0017, 0x0009 }, + { 0x000d, 0x0005 }, + { 0x000c, 0x0003 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0014, 0x000c }, + { 0x0017, 0x000a }, + { 0x0016, 0x001a }, + { 0x0017, 0x000b }, + { 0x0017, 0x000c }, + { 0x0011, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0011, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0015, 0x0010 }, + { 0x0017, 0x000d }, + { 0x0017, 0x000e }, + { 0x0017, 0x000f }, + { 0x0017, 0x0010 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0014, 0x000d }, + { 0x0015, 0x0011 }, + { 0x0017, 0x0011 }, + { 0x0016, 0x001b }, + { 0x0017, 0x0012 }, + { 0x0017, 0x0013 }, + { 0x0017, 0x0014 }, + { 0x0017, 0x0015 }, + { 0x0017, 0x0016 }, + { 0x0015, 0x0012 }, + { 0x0015, 0x0013 }, + { 0x0017, 0x0017 }, + { 0x0016, 0x001c }, + { 0x0017, 0x0018 }, + { 0x0017, 0x0019 }, + { 0x0017, 0x001a }, + { 0x0017, 0x001b }, + { 0x0017, 0x001c }, + { 0x0017, 0x001d }, + { 0x0017, 0x001e }, + { 0x0017, 0x001f }, + { 0x0017, 0x0020 }, + { 0x0017, 0x0021 }, + { 0x0017, 0x0022 }, + { 0x0017, 0x0023 }, + { 0x0017, 0x0024 }, + { 0x0017, 0x0025 }, + { 0x0017, 0x0026 }, + { 0x0017, 0x0027 }, + { 0x0017, 0x0028 }, + { 0x0017, 0x0029 }, + { 0x0017, 0x002a }, + { 0x0017, 0x002b }, + { 0x0017, 0x002c }, + { 0x0017, 0x002d }, + { 0x0017, 0x002e }, + { 0x0017, 0x002f }, + { 0x0016, 0x001d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc10[169][2] = + { + { 0x0001, 0x0001 }, + { 0x0004, 0x0002 }, + { 0x0005, 0x0002 }, + { 0x0007, 0x0002 }, + { 0x000a, 0x0002 }, + { 0x000e, 0x0004 }, + { 0x0011, 0x0007 }, + { 0x0013, 0x0012 }, + { 0x0016, 0x0000 }, + { 0x0016, 0x0001 }, + { 0x0016, 0x0002 }, + { 0x0016, 0x0003 }, + { 0x0016, 0x0004 }, + { 0x0004, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0007, 0x0003 }, + { 0x000a, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0013 }, + { 0x0015, 0x0035 }, + { 0x0016, 0x0005 }, + { 0x0016, 0x0006 }, + { 0x0016, 0x0007 }, + { 0x0016, 0x0008 }, + { 0x0005, 0x0003 }, + { 0x0004, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000e, 0x0005 }, + { 0x0010, 0x0008 }, + { 0x0013, 0x0014 }, + { 0x0014, 0x001d }, + { 0x0016, 0x0009 }, + { 0x0016, 0x000a }, + { 0x0016, 0x000b }, + { 0x0016, 0x000c }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000f, 0x0005 }, + { 0x0011, 0x0008 }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0016, 0x000d }, + { 0x0016, 0x000e }, + { 0x0016, 0x000f }, + { 0x0016, 0x0010 }, + { 0x000a, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000d, 0x0006 }, + { 0x000f, 0x0006 }, + { 0x0011, 0x0009 }, + { 0x0013, 0x0015 }, + { 0x0014, 0x0020 }, + { 0x0016, 0x0011 }, + { 0x0016, 0x0012 }, + { 0x0016, 0x0013 }, + { 0x0016, 0x0014 }, + { 0x0016, 0x0015 }, + { 0x000e, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0007 }, + { 0x000f, 0x0007 }, + { 0x0011, 0x000a }, + { 0x0012, 0x000c }, + { 0x0016, 0x0016 }, + { 0x0016, 0x0017 }, + { 0x0016, 0x0018 }, + { 0x0016, 0x0019 }, + { 0x0016, 0x001a }, + { 0x0016, 0x001b }, + { 0x0016, 0x001c }, + { 0x0011, 0x000b }, + { 0x0010, 0x0009 }, + { 0x0011, 0x000c }, + { 0x0011, 0x000d }, + { 0x0013, 0x0016 }, + { 0x0016, 0x001d }, + { 0x0016, 0x001e }, + { 0x0016, 0x001f }, + { 0x0016, 0x0020 }, + { 0x0016, 0x0021 }, + { 0x0016, 0x0022 }, + { 0x0016, 0x0023 }, + { 0x0016, 0x0024 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0012, 0x000d }, + { 0x0013, 0x0017 }, + { 0x0016, 0x0025 }, + { 0x0016, 0x0026 }, + { 0x0016, 0x0027 }, + { 0x0016, 0x0028 }, + { 0x0016, 0x0029 }, + { 0x0016, 0x002a }, + { 0x0016, 0x002b }, + { 0x0016, 0x002c }, + { 0x0016, 0x002d }, + { 0x0015, 0x0036 }, + { 0x0015, 0x0037 }, + { 0x0014, 0x0023 }, + { 0x0015, 0x0038 }, + { 0x0016, 0x002e }, + { 0x0016, 0x002f }, + { 0x0016, 0x0030 }, + { 0x0016, 0x0031 }, + { 0x0016, 0x0032 }, + { 0x0016, 0x0033 }, + { 0x0016, 0x0034 }, + { 0x0016, 0x0035 }, + { 0x0016, 0x0036 }, + { 0x0016, 0x0037 }, + { 0x0016, 0x0038 }, + { 0x0016, 0x0039 }, + { 0x0016, 0x003a }, + { 0x0016, 0x003b }, + { 0x0016, 0x003c }, + { 0x0016, 0x003d }, + { 0x0016, 0x003e }, + { 0x0016, 0x003f }, + { 0x0016, 0x0040 }, + { 0x0016, 0x0041 }, + { 0x0016, 0x0042 }, + { 0x0016, 0x0043 }, + { 0x0016, 0x0044 }, + { 0x0016, 0x0045 }, + { 0x0016, 0x0046 }, + { 0x0016, 0x0047 }, + { 0x0016, 0x0048 }, + { 0x0016, 0x0049 }, + { 0x0016, 0x004a }, + { 0x0016, 0x004b }, + { 0x0016, 0x004c }, + { 0x0016, 0x004d }, + { 0x0016, 0x004e }, + { 0x0016, 0x004f }, + { 0x0016, 0x0050 }, + { 0x0016, 0x0051 }, + { 0x0016, 0x0052 }, + { 0x0016, 0x0053 }, + { 0x0016, 0x0054 }, + { 0x0016, 0x0055 }, + { 0x0016, 0x0056 }, + { 0x0016, 0x0057 }, + { 0x0016, 0x0058 }, + { 0x0016, 0x0059 }, + { 0x0016, 0x005a }, + { 0x0016, 0x005b }, + { 0x0016, 0x005c }, + { 0x0016, 0x005d }, + { 0x0016, 0x005e }, + { 0x0016, 0x005f }, + { 0x0016, 0x0060 }, + { 0x0016, 0x0061 }, + { 0x0016, 0x0062 }, + { 0x0016, 0x0063 }, + { 0x0016, 0x0064 }, + { 0x0016, 0x0065 }, + { 0x0016, 0x0066 }, + { 0x0016, 0x0067 }, + { 0x0016, 0x0068 }, + { 0x0016, 0x0069 }, + { 0x0015, 0x0039 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc11[196][2] = + { + { 0x0001, 0x0001 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0012, 0x000d }, + { 0x0014, 0x001f }, + { 0x0016, 0x0000 }, + { 0x0016, 0x0001 }, + { 0x0016, 0x0002 }, + { 0x0016, 0x0003 }, + { 0x0016, 0x0004 }, + { 0x0004, 0x0004 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x000b, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x0010, 0x0007 }, + { 0x0012, 0x000e }, + { 0x0014, 0x0020 }, + { 0x0016, 0x0005 }, + { 0x0016, 0x0006 }, + { 0x0016, 0x0007 }, + { 0x0016, 0x0008 }, + { 0x0005, 0x0005 }, + { 0x0004, 0x0005 }, + { 0x0006, 0x0004 }, + { 0x0007, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x0011, 0x000a }, + { 0x0012, 0x000f }, + { 0x0015, 0x003b }, + { 0x0016, 0x0009 }, + { 0x0016, 0x000a }, + { 0x0016, 0x000b }, + { 0x0016, 0x000c }, + { 0x0007, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0005 }, + { 0x000b, 0x0005 }, + { 0x000d, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x0012, 0x0010 }, + { 0x0014, 0x0021 }, + { 0x0016, 0x000d }, + { 0x0016, 0x000e }, + { 0x0016, 0x000f }, + { 0x0016, 0x0010 }, + { 0x0016, 0x0011 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000d, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0011, 0x000b }, + { 0x0013, 0x0017 }, + { 0x0014, 0x0022 }, + { 0x0016, 0x0012 }, + { 0x0016, 0x0013 }, + { 0x0016, 0x0014 }, + { 0x0016, 0x0015 }, + { 0x0016, 0x0016 }, + { 0x000c, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0008 }, + { 0x0012, 0x0011 }, + { 0x0014, 0x0023 }, + { 0x0015, 0x003c }, + { 0x0016, 0x0017 }, + { 0x0016, 0x0018 }, + { 0x0016, 0x0019 }, + { 0x0016, 0x001a }, + { 0x0016, 0x001b }, + { 0x000f, 0x0008 }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0009 }, + { 0x0011, 0x000c }, + { 0x0013, 0x0018 }, + { 0x0014, 0x0024 }, + { 0x0016, 0x001c }, + { 0x0016, 0x001d }, + { 0x0016, 0x001e }, + { 0x0016, 0x001f }, + { 0x0016, 0x0020 }, + { 0x0016, 0x0021 }, + { 0x0016, 0x0022 }, + { 0x0011, 0x000d }, + { 0x0010, 0x0009 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + { 0x0014, 0x0025 }, + { 0x0015, 0x003d }, + { 0x0014, 0x0026 }, + { 0x0016, 0x0023 }, + { 0x0016, 0x0024 }, + { 0x0016, 0x0025 }, + { 0x0016, 0x0026 }, + { 0x0016, 0x0027 }, + { 0x0016, 0x0028 }, + { 0x0016, 0x0029 }, + { 0x0014, 0x0027 }, + { 0x0013, 0x0019 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0016, 0x002a }, + { 0x0016, 0x002b }, + { 0x0016, 0x002c }, + { 0x0016, 0x002d }, + { 0x0016, 0x002e }, + { 0x0016, 0x002f }, + { 0x0016, 0x0030 }, + { 0x0016, 0x0031 }, + { 0x0016, 0x0032 }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0016, 0x0033 }, + { 0x0016, 0x0034 }, + { 0x0016, 0x0035 }, + { 0x0016, 0x0036 }, + { 0x0016, 0x0037 }, + { 0x0016, 0x0038 }, + { 0x0016, 0x0039 }, + { 0x0016, 0x003a }, + { 0x0016, 0x003b }, + { 0x0016, 0x003c }, + { 0x0016, 0x003d }, + { 0x0016, 0x003e }, + { 0x0016, 0x003f }, + { 0x0016, 0x0040 }, + { 0x0016, 0x0041 }, + { 0x0016, 0x0042 }, + { 0x0016, 0x0043 }, + { 0x0016, 0x0044 }, + { 0x0016, 0x0045 }, + { 0x0016, 0x0046 }, + { 0x0016, 0x0047 }, + { 0x0016, 0x0048 }, + { 0x0016, 0x0049 }, + { 0x0016, 0x004a }, + { 0x0016, 0x004b }, + { 0x0016, 0x004c }, + { 0x0016, 0x004d }, + { 0x0016, 0x004e }, + { 0x0016, 0x004f }, + { 0x0016, 0x0050 }, + { 0x0016, 0x0051 }, + { 0x0016, 0x0052 }, + { 0x0016, 0x0053 }, + { 0x0016, 0x0054 }, + { 0x0016, 0x0055 }, + { 0x0016, 0x0056 }, + { 0x0016, 0x0057 }, + { 0x0016, 0x0058 }, + { 0x0016, 0x0059 }, + { 0x0016, 0x005a }, + { 0x0016, 0x005b }, + { 0x0016, 0x005c }, + { 0x0016, 0x005d }, + { 0x0016, 0x005e }, + { 0x0016, 0x005f }, + { 0x0016, 0x0060 }, + { 0x0016, 0x0061 }, + { 0x0016, 0x0062 }, + { 0x0016, 0x0063 }, + { 0x0016, 0x0064 }, + { 0x0016, 0x0065 }, + { 0x0016, 0x0066 }, + { 0x0016, 0x0067 }, + { 0x0016, 0x0068 }, + { 0x0016, 0x0069 }, + { 0x0016, 0x006a }, + { 0x0016, 0x006b }, + { 0x0016, 0x006c }, + { 0x0016, 0x006d }, + { 0x0016, 0x006e }, + { 0x0016, 0x006f }, + { 0x0016, 0x0070 }, + { 0x0016, 0x0071 }, + { 0x0016, 0x0072 }, + { 0x0016, 0x0073 }, + { 0x0016, 0x0074 }, + { 0x0016, 0x0075 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc12[289][2] = + { + { 0x0001, 0x0001 }, + { 0x0004, 0x0004 }, + { 0x0005, 0x0004 }, + { 0x0007, 0x0004 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0004 }, + { 0x000e, 0x0006 }, + { 0x0010, 0x0009 }, + { 0x0012, 0x0014 }, + { 0x0013, 0x001f }, + { 0x0016, 0x0000 }, + { 0x0016, 0x0001 }, + { 0x0016, 0x0002 }, + { 0x0016, 0x0003 }, + { 0x0016, 0x0004 }, + { 0x0016, 0x0005 }, + { 0x0016, 0x0006 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000d, 0x0006 }, + { 0x000f, 0x0008 }, + { 0x0011, 0x000c }, + { 0x0013, 0x0020 }, + { 0x0016, 0x0007 }, + { 0x0015, 0x0063 }, + { 0x0016, 0x0008 }, + { 0x0016, 0x0009 }, + { 0x0016, 0x000a }, + { 0x0016, 0x000b }, + { 0x0016, 0x000c }, + { 0x0005, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000d, 0x0007 }, + { 0x0010, 0x000a }, + { 0x0012, 0x0015 }, + { 0x0015, 0x0064 }, + { 0x0016, 0x000d }, + { 0x0016, 0x000e }, + { 0x0016, 0x000f }, + { 0x0016, 0x0010 }, + { 0x0016, 0x0011 }, + { 0x0016, 0x0012 }, + { 0x0016, 0x0013 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0008, 0x0005 }, + { 0x000a, 0x0005 }, + { 0x000c, 0x0005 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x000b }, + { 0x0012, 0x0016 }, + { 0x0014, 0x0037 }, + { 0x0015, 0x0065 }, + { 0x0016, 0x0014 }, + { 0x0016, 0x0015 }, + { 0x0016, 0x0016 }, + { 0x0016, 0x0017 }, + { 0x0016, 0x0018 }, + { 0x0016, 0x0019 }, + { 0x0008, 0x0006 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0006 }, + { 0x000c, 0x0006 }, + { 0x000e, 0x0008 }, + { 0x0010, 0x000c }, + { 0x0011, 0x000d }, + { 0x0013, 0x0021 }, + { 0x0015, 0x0066 }, + { 0x0016, 0x001a }, + { 0x0016, 0x001b }, + { 0x0016, 0x001c }, + { 0x0016, 0x001d }, + { 0x0016, 0x001e }, + { 0x0016, 0x001f }, + { 0x0016, 0x0020 }, + { 0x000b, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0009 }, + { 0x0011, 0x000e }, + { 0x0013, 0x0022 }, + { 0x0015, 0x0067 }, + { 0x0015, 0x0068 }, + { 0x0016, 0x0021 }, + { 0x0016, 0x0022 }, + { 0x0016, 0x0023 }, + { 0x0016, 0x0024 }, + { 0x0016, 0x0025 }, + { 0x0016, 0x0026 }, + { 0x0016, 0x0027 }, + { 0x000e, 0x000a }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000e, 0x000b }, + { 0x000f, 0x000a }, + { 0x0011, 0x000f }, + { 0x0013, 0x0023 }, + { 0x0014, 0x0038 }, + { 0x0016, 0x0028 }, + { 0x0016, 0x0029 }, + { 0x0016, 0x002a }, + { 0x0016, 0x002b }, + { 0x0016, 0x002c }, + { 0x0016, 0x002d }, + { 0x0016, 0x002e }, + { 0x0016, 0x002f }, + { 0x0016, 0x0030 }, + { 0x0010, 0x000d }, + { 0x000f, 0x000b }, + { 0x0010, 0x000e }, + { 0x0010, 0x000f }, + { 0x0012, 0x0017 }, + { 0x0013, 0x0024 }, + { 0x0014, 0x0039 }, + { 0x0016, 0x0031 }, + { 0x0016, 0x0032 }, + { 0x0016, 0x0033 }, + { 0x0016, 0x0034 }, + { 0x0016, 0x0035 }, + { 0x0016, 0x0036 }, + { 0x0016, 0x0037 }, + { 0x0016, 0x0038 }, + { 0x0016, 0x0039 }, + { 0x0016, 0x003a }, + { 0x0013, 0x0025 }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0016, 0x003b }, + { 0x0016, 0x003c }, + { 0x0016, 0x003d }, + { 0x0016, 0x003e }, + { 0x0016, 0x003f }, + { 0x0016, 0x0040 }, + { 0x0016, 0x0041 }, + { 0x0016, 0x0042 }, + { 0x0016, 0x0043 }, + { 0x0016, 0x0044 }, + { 0x0015, 0x0069 }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0015, 0x006a }, + { 0x0015, 0x006b }, + { 0x0015, 0x006c }, + { 0x0016, 0x0045 }, + { 0x0016, 0x0046 }, + { 0x0016, 0x0047 }, + { 0x0016, 0x0048 }, + { 0x0016, 0x0049 }, + { 0x0016, 0x004a }, + { 0x0016, 0x004b }, + { 0x0016, 0x004c }, + { 0x0016, 0x004d }, + { 0x0016, 0x004e }, + { 0x0016, 0x004f }, + { 0x0016, 0x0050 }, + { 0x0016, 0x0051 }, + { 0x0015, 0x006d }, + { 0x0016, 0x0052 }, + { 0x0016, 0x0053 }, + { 0x0016, 0x0054 }, + { 0x0016, 0x0055 }, + { 0x0016, 0x0056 }, + { 0x0016, 0x0057 }, + { 0x0016, 0x0058 }, + { 0x0016, 0x0059 }, + { 0x0016, 0x005a }, + { 0x0016, 0x005b }, + { 0x0016, 0x005c }, + { 0x0016, 0x005d }, + { 0x0016, 0x005e }, + { 0x0016, 0x005f }, + { 0x0016, 0x0060 }, + { 0x0016, 0x0061 }, + { 0x0016, 0x0062 }, + { 0x0016, 0x0063 }, + { 0x0016, 0x0064 }, + { 0x0016, 0x0065 }, + { 0x0016, 0x0066 }, + { 0x0016, 0x0067 }, + { 0x0016, 0x0068 }, + { 0x0016, 0x0069 }, + { 0x0016, 0x006a }, + { 0x0016, 0x006b }, + { 0x0016, 0x006c }, + { 0x0016, 0x006d }, + { 0x0016, 0x006e }, + { 0x0016, 0x006f }, + { 0x0016, 0x0070 }, + { 0x0016, 0x0071 }, + { 0x0016, 0x0072 }, + { 0x0016, 0x0073 }, + { 0x0016, 0x0074 }, + { 0x0016, 0x0075 }, + { 0x0016, 0x0076 }, + { 0x0016, 0x0077 }, + { 0x0016, 0x0078 }, + { 0x0016, 0x0079 }, + { 0x0016, 0x007a }, + { 0x0016, 0x007b }, + { 0x0016, 0x007c }, + { 0x0016, 0x007d }, + { 0x0016, 0x007e }, + { 0x0016, 0x007f }, + { 0x0016, 0x0080 }, + { 0x0016, 0x0081 }, + { 0x0016, 0x0082 }, + { 0x0016, 0x0083 }, + { 0x0016, 0x0084 }, + { 0x0016, 0x0085 }, + { 0x0016, 0x0086 }, + { 0x0016, 0x0087 }, + { 0x0016, 0x0088 }, + { 0x0016, 0x0089 }, + { 0x0016, 0x008a }, + { 0x0016, 0x008b }, + { 0x0016, 0x008c }, + { 0x0016, 0x008d }, + { 0x0016, 0x008e }, + { 0x0016, 0x008f }, + { 0x0016, 0x0090 }, + { 0x0016, 0x0091 }, + { 0x0016, 0x0092 }, + { 0x0016, 0x0093 }, + { 0x0016, 0x0094 }, + { 0x0016, 0x0095 }, + { 0x0016, 0x0096 }, + { 0x0016, 0x0097 }, + { 0x0016, 0x0098 }, + { 0x0016, 0x0099 }, + { 0x0016, 0x009a }, + { 0x0016, 0x009b }, + { 0x0016, 0x009c }, + { 0x0016, 0x009d }, + { 0x0016, 0x009e }, + { 0x0016, 0x009f }, + { 0x0016, 0x00a0 }, + { 0x0016, 0x00a1 }, + { 0x0016, 0x00a2 }, + { 0x0016, 0x00a3 }, + { 0x0016, 0x00a4 }, + { 0x0016, 0x00a5 }, + { 0x0016, 0x00a6 }, + { 0x0016, 0x00a7 }, + { 0x0016, 0x00a8 }, + { 0x0016, 0x00a9 }, + { 0x0016, 0x00aa }, + { 0x0016, 0x00ab }, + { 0x0016, 0x00ac }, + { 0x0016, 0x00ad }, + { 0x0016, 0x00ae }, + { 0x0016, 0x00af }, + { 0x0016, 0x00b0 }, + { 0x0016, 0x00b1 }, + { 0x0016, 0x00b2 }, + { 0x0016, 0x00b3 }, + { 0x0016, 0x00b4 }, + { 0x0016, 0x00b5 }, + { 0x0016, 0x00b6 }, + { 0x0016, 0x00b7 }, + { 0x0016, 0x00b8 }, + { 0x0016, 0x00b9 }, + { 0x0016, 0x00ba }, + { 0x0016, 0x00bb }, + { 0x0016, 0x00bc }, + { 0x0016, 0x00bd }, + { 0x0016, 0x00be }, + { 0x0016, 0x00bf }, + { 0x0016, 0x00c0 }, + { 0x0016, 0x00c1 }, + { 0x0016, 0x00c2 }, + { 0x0016, 0x00c3 }, + { 0x0016, 0x00c4 }, + { 0x0016, 0x00c5 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc13[324][2] = + { + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x000a, 0x0005 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x000b }, + { 0x0010, 0x0011 }, + { 0x0012, 0x002d }, + { 0x0015, 0x0000 }, + { 0x0014, 0x0035 }, + { 0x0015, 0x0001 }, + { 0x0015, 0x0002 }, + { 0x0015, 0x0003 }, + { 0x0015, 0x0004 }, + { 0x0015, 0x0005 }, + { 0x0004, 0x0008 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0006, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0009, 0x0006 }, + { 0x000c, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x0010, 0x0012 }, + { 0x0011, 0x001a }, + { 0x0015, 0x0006 }, + { 0x0015, 0x0007 }, + { 0x0015, 0x0008 }, + { 0x0015, 0x0009 }, + { 0x0015, 0x000a }, + { 0x0015, 0x000b }, + { 0x0015, 0x000c }, + { 0x0005, 0x0007 }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0005, 0x0008 }, + { 0x0006, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0006 }, + { 0x000c, 0x0009 }, + { 0x000e, 0x000c }, + { 0x0010, 0x0013 }, + { 0x0012, 0x002e }, + { 0x0015, 0x000d }, + { 0x0015, 0x000e }, + { 0x0015, 0x000f }, + { 0x0015, 0x0010 }, + { 0x0015, 0x0011 }, + { 0x0015, 0x0012 }, + { 0x0015, 0x0013 }, + { 0x0005, 0x0009 }, + { 0x0004, 0x000d }, + { 0x0005, 0x000a }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000a }, + { 0x000f, 0x000e }, + { 0x0010, 0x0014 }, + { 0x0011, 0x001b }, + { 0x0014, 0x0036 }, + { 0x0015, 0x0014 }, + { 0x0015, 0x0015 }, + { 0x0015, 0x0016 }, + { 0x0015, 0x0017 }, + { 0x0015, 0x0018 }, + { 0x0015, 0x0019 }, + { 0x0006, 0x0008 }, + { 0x0005, 0x000b }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0008 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x000a }, + { 0x000e, 0x000d }, + { 0x0010, 0x0015 }, + { 0x0011, 0x001c }, + { 0x0013, 0x0053 }, + { 0x0015, 0x001a }, + { 0x0015, 0x001b }, + { 0x0015, 0x001c }, + { 0x0015, 0x001d }, + { 0x0015, 0x001e }, + { 0x0015, 0x001f }, + { 0x0015, 0x0020 }, + { 0x0008, 0x0008 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000b }, + { 0x000d, 0x000b }, + { 0x000f, 0x000f }, + { 0x0010, 0x0016 }, + { 0x0011, 0x001d }, + { 0x0014, 0x0037 }, + { 0x0015, 0x0021 }, + { 0x0015, 0x0022 }, + { 0x0015, 0x0023 }, + { 0x0015, 0x0024 }, + { 0x0015, 0x0025 }, + { 0x0015, 0x0026 }, + { 0x0015, 0x0027 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000b, 0x0009 }, + { 0x000c, 0x000c }, + { 0x000d, 0x000c }, + { 0x000f, 0x0010 }, + { 0x0010, 0x0017 }, + { 0x0012, 0x002f }, + { 0x0015, 0x0028 }, + { 0x0015, 0x0029 }, + { 0x0015, 0x002a }, + { 0x0015, 0x002b }, + { 0x0015, 0x002c }, + { 0x0015, 0x002d }, + { 0x0015, 0x002e }, + { 0x0015, 0x002f }, + { 0x0015, 0x0030 }, + { 0x000c, 0x000d }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000d, 0x000d }, + { 0x000e, 0x000e }, + { 0x000f, 0x0011 }, + { 0x0010, 0x0018 }, + { 0x0011, 0x001e }, + { 0x0014, 0x0038 }, + { 0x0015, 0x0031 }, + { 0x0015, 0x0032 }, + { 0x0015, 0x0033 }, + { 0x0015, 0x0034 }, + { 0x0015, 0x0035 }, + { 0x0015, 0x0036 }, + { 0x0015, 0x0037 }, + { 0x0015, 0x0038 }, + { 0x0015, 0x0039 }, + { 0x000f, 0x0012 }, + { 0x000e, 0x000f }, + { 0x000e, 0x0010 }, + { 0x000e, 0x0011 }, + { 0x000f, 0x0013 }, + { 0x0010, 0x0019 }, + { 0x0011, 0x001f }, + { 0x0013, 0x0054 }, + { 0x0015, 0x003a }, + { 0x0014, 0x0039 }, + { 0x0015, 0x003b }, + { 0x0015, 0x003c }, + { 0x0015, 0x003d }, + { 0x0015, 0x003e }, + { 0x0015, 0x003f }, + { 0x0015, 0x0040 }, + { 0x0015, 0x0041 }, + { 0x0015, 0x0042 }, + { 0x0010, 0x001a }, + { 0x000f, 0x0014 }, + { 0x000f, 0x0015 }, + { 0x0010, 0x001b }, + { 0x0011, 0x0020 }, + { 0x0012, 0x0030 }, + { 0x0013, 0x0055 }, + { 0x0015, 0x0043 }, + { 0x0015, 0x0044 }, + { 0x0014, 0x003a }, + { 0x0015, 0x0045 }, + { 0x0015, 0x0046 }, + { 0x0015, 0x0047 }, + { 0x0015, 0x0048 }, + { 0x0015, 0x0049 }, + { 0x0015, 0x004a }, + { 0x0015, 0x004b }, + { 0x0015, 0x004c }, + { 0x0012, 0x0031 }, + { 0x0011, 0x0021 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0012, 0x0032 }, + { 0x0015, 0x004d }, + { 0x0015, 0x004e }, + { 0x0015, 0x004f }, + { 0x0015, 0x0050 }, + { 0x0015, 0x0051 }, + { 0x0015, 0x0052 }, + { 0x0015, 0x0053 }, + { 0x0015, 0x0054 }, + { 0x0015, 0x0055 }, + { 0x0015, 0x0056 }, + { 0x0015, 0x0057 }, + { 0x0015, 0x0058 }, + { 0x0015, 0x0059 }, + { 0x0015, 0x005a }, + { 0x0014, 0x003b }, + { 0x0012, 0x0033 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0015, 0x005b }, + { 0x0015, 0x005c }, + { 0x0015, 0x005d }, + { 0x0015, 0x005e }, + { 0x0015, 0x005f }, + { 0x0015, 0x0060 }, + { 0x0015, 0x0061 }, + { 0x0015, 0x0062 }, + { 0x0015, 0x0063 }, + { 0x0015, 0x0064 }, + { 0x0015, 0x0065 }, + { 0x0015, 0x0066 }, + { 0x0015, 0x0067 }, + { 0x0015, 0x0068 }, + { 0x0015, 0x0069 }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc14[400][2] = + { + { 0x0005, 0x0007 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0006, 0x0006 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000c }, + { 0x000f, 0x0013 }, + { 0x0010, 0x001b }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x0007 }, + { 0x0008, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x000a }, + { 0x000e, 0x000e }, + { 0x000f, 0x0014 }, + { 0x0011, 0x002a }, + { 0x0012, 0x004a }, + { 0x0013, 0x0084 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0005, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0005, 0x000d }, + { 0x0006, 0x0008 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000b }, + { 0x000e, 0x000f }, + { 0x000f, 0x0015 }, + { 0x0012, 0x004b }, + { 0x0013, 0x0085 }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0005, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0006, 0x0009 }, + { 0x0008, 0x0008 }, + { 0x0009, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000d, 0x000d }, + { 0x000e, 0x0010 }, + { 0x0010, 0x001c }, + { 0x0011, 0x002b }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0006, 0x000a }, + { 0x0005, 0x0011 }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0007, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x000a, 0x0009 }, + { 0x000c, 0x000c }, + { 0x000e, 0x0011 }, + { 0x000f, 0x0016 }, + { 0x0010, 0x001d }, + { 0x0012, 0x004c }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0007, 0x0009 }, + { 0x0006, 0x000d }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0009, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000b, 0x000a }, + { 0x000d, 0x000e }, + { 0x000f, 0x0017 }, + { 0x0011, 0x002c }, + { 0x0010, 0x001e }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0009, 0x000a }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0009, 0x000b }, + { 0x000a, 0x000b }, + { 0x000b, 0x000b }, + { 0x000d, 0x000f }, + { 0x000e, 0x0012 }, + { 0x000f, 0x0018 }, + { 0x0011, 0x002d }, + { 0x0011, 0x002e }, + { 0x0013, 0x0086 }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x000b, 0x000c }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x000d }, + { 0x000c, 0x000d }, + { 0x000d, 0x0010 }, + { 0x000e, 0x0013 }, + { 0x000f, 0x0019 }, + { 0x0010, 0x001f }, + { 0x0013, 0x0087 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0013, 0x0088 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x000d, 0x0011 }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000d, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000e, 0x0014 }, + { 0x0010, 0x0020 }, + { 0x0010, 0x0021 }, + { 0x0012, 0x004d }, + { 0x0011, 0x002f }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x000f, 0x001a }, + { 0x000e, 0x0015 }, + { 0x000e, 0x0016 }, + { 0x000e, 0x0017 }, + { 0x000f, 0x001b }, + { 0x0011, 0x0030 }, + { 0x0011, 0x0031 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0010, 0x0022 }, + { 0x0010, 0x0023 }, + { 0x0010, 0x0024 }, + { 0x0010, 0x0025 }, + { 0x0011, 0x0032 }, + { 0x0011, 0x0033 }, + { 0x0012, 0x004e }, + { 0x0012, 0x004f }, + { 0x0014, 0x0052 }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0011, 0x0034 }, + { 0x0011, 0x0035 }, + { 0x0012, 0x0050 }, + { 0x0012, 0x0051 }, + { 0x0013, 0x008e }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0012, 0x0052 }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0014, 0x006b }, + { 0x0013, 0x0091 }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0013, 0x0092 }, + { 0x0012, 0x0053 }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0013, 0x0093 }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + }; + +const uint16_t c_aauiLCLDHuffEnc15[576][2] = + { + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0007, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0008 }, + { 0x000b, 0x000b }, + { 0x000d, 0x000e }, + { 0x000e, 0x0011 }, + { 0x000f, 0x001a }, + { 0x0012, 0x006e }, + { 0x0014, 0x0000 }, + { 0x0013, 0x00cc }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0005, 0x000d }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0006, 0x000b }, + { 0x0007, 0x0009 }, + { 0x0008, 0x000a }, + { 0x000a, 0x000a }, + { 0x000c, 0x000c }, + { 0x000d, 0x000f }, + { 0x000f, 0x001b }, + { 0x0011, 0x003d }, + { 0x0011, 0x003e }, + { 0x0013, 0x00cd }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0005, 0x0010 }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0006, 0x000c }, + { 0x0007, 0x000a }, + { 0x0009, 0x0009 }, + { 0x000a, 0x000b }, + { 0x000c, 0x000d }, + { 0x000e, 0x0012 }, + { 0x0010, 0x0027 }, + { 0x0011, 0x003f }, + { 0x0012, 0x006f }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0006, 0x000d }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0006, 0x000e }, + { 0x0007, 0x000b }, + { 0x0008, 0x000b }, + { 0x0009, 0x000a }, + { 0x000b, 0x000c }, + { 0x000c, 0x000e }, + { 0x000e, 0x0013 }, + { 0x000f, 0x001c }, + { 0x0011, 0x0040 }, + { 0x0012, 0x0070 }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0006, 0x000f }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0007, 0x000c }, + { 0x0009, 0x000b }, + { 0x000a, 0x000c }, + { 0x000b, 0x000d }, + { 0x000d, 0x0010 }, + { 0x000e, 0x0014 }, + { 0x0010, 0x0028 }, + { 0x0011, 0x0041 }, + { 0x0013, 0x00ce }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0007, 0x000d }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x000c }, + { 0x0009, 0x000c }, + { 0x000b, 0x000e }, + { 0x000c, 0x000f }, + { 0x000e, 0x0015 }, + { 0x0010, 0x0029 }, + { 0x0011, 0x0042 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0008, 0x000d }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x000e }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x000b, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000d, 0x0011 }, + { 0x000f, 0x001d }, + { 0x0010, 0x002a }, + { 0x0011, 0x0043 }, + { 0x0014, 0x003d }, + { 0x0013, 0x00cf }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x0009, 0x000f }, + { 0x0008, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x000d }, + { 0x000b, 0x0010 }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0012 }, + { 0x000e, 0x0016 }, + { 0x0010, 0x002b }, + { 0x0011, 0x0044 }, + { 0x0012, 0x0071 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x000b, 0x0011 }, + { 0x000a, 0x000e }, + { 0x000a, 0x000f }, + { 0x000b, 0x0012 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000e, 0x0017 }, + { 0x0010, 0x002c }, + { 0x0012, 0x0072 }, + { 0x0011, 0x0045 }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x000c, 0x0013 }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000e, 0x0018 }, + { 0x000f, 0x001e }, + { 0x0010, 0x002d }, + { 0x0011, 0x0046 }, + { 0x0011, 0x0047 }, + { 0x0011, 0x0048 }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x000e, 0x0019 }, + { 0x000d, 0x0016 }, + { 0x000d, 0x0017 }, + { 0x000e, 0x001a }, + { 0x000e, 0x001b }, + { 0x000f, 0x001f }, + { 0x0010, 0x002e }, + { 0x0011, 0x0049 }, + { 0x0012, 0x0073 }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0010, 0x002f }, + { 0x000f, 0x0020 }, + { 0x0010, 0x0030 }, + { 0x000f, 0x0021 }, + { 0x0010, 0x0031 }, + { 0x0011, 0x004a }, + { 0x0011, 0x004b }, + { 0x0012, 0x0074 }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0013, 0x00d2 }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0012, 0x0075 }, + { 0x0010, 0x0032 }, + { 0x0010, 0x0033 }, + { 0x0011, 0x004c }, + { 0x0011, 0x004d }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0012, 0x0076 }, + { 0x0013, 0x00d5 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0012, 0x0077 }, + { 0x0012, 0x0078 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0013, 0x00d8 }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0012, 0x0079 }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + { 0x0014, 0x0104 }, + { 0x0014, 0x0105 }, + { 0x0014, 0x0106 }, + { 0x0014, 0x0107 }, + { 0x0014, 0x0108 }, + { 0x0014, 0x0109 }, + { 0x0014, 0x010a }, + { 0x0014, 0x010b }, + { 0x0014, 0x010c }, + { 0x0014, 0x010d }, + { 0x0014, 0x010e }, + { 0x0014, 0x010f }, + { 0x0014, 0x0110 }, + { 0x0014, 0x0111 }, + { 0x0014, 0x0112 }, + { 0x0014, 0x0113 }, + { 0x0014, 0x0114 }, + { 0x0014, 0x0115 }, + { 0x0014, 0x0116 }, + { 0x0014, 0x0117 }, + { 0x0014, 0x0118 }, + { 0x0014, 0x0119 }, + { 0x0014, 0x011a }, + { 0x0014, 0x011b }, + { 0x0014, 0x011c }, + { 0x0014, 0x011d }, + { 0x0014, 0x011e }, + { 0x0014, 0x011f }, + { 0x0014, 0x0120 }, + { 0x0014, 0x0121 }, + { 0x0014, 0x0122 }, + { 0x0014, 0x0123 }, + { 0x0014, 0x0124 }, + { 0x0014, 0x0125 }, + { 0x0014, 0x0126 }, + { 0x0014, 0x0127 }, + { 0x0014, 0x0128 }, + { 0x0014, 0x0129 }, + { 0x0014, 0x012a }, + { 0x0014, 0x012b }, + { 0x0014, 0x012c }, + { 0x0014, 0x012d }, + { 0x0014, 0x012e }, + { 0x0014, 0x012f }, + { 0x0014, 0x0130 }, + { 0x0014, 0x0131 }, + { 0x0014, 0x0132 }, + { 0x0014, 0x0133 }, + { 0x0014, 0x0134 }, + { 0x0014, 0x0135 }, + { 0x0014, 0x0136 }, + { 0x0014, 0x0137 }, + { 0x0014, 0x0138 }, + { 0x0014, 0x0139 }, + { 0x0014, 0x013a }, + { 0x0014, 0x013b }, + { 0x0014, 0x013c }, + { 0x0014, 0x013d }, + { 0x0014, 0x013e }, + { 0x0014, 0x013f }, + { 0x0014, 0x0140 }, + { 0x0014, 0x0141 }, + { 0x0014, 0x0142 }, + { 0x0014, 0x0143 }, + { 0x0014, 0x0144 }, + { 0x0014, 0x0145 }, + { 0x0014, 0x0146 }, + { 0x0014, 0x0147 }, + { 0x0014, 0x0148 }, + { 0x0014, 0x0149 }, + { 0x0014, 0x014a }, + { 0x0014, 0x014b }, + { 0x0014, 0x014c }, + { 0x0014, 0x014d }, + { 0x0014, 0x014e }, + { 0x0014, 0x014f }, + { 0x0014, 0x0150 }, + { 0x0014, 0x0151 }, + { 0x0014, 0x0152 }, + { 0x0014, 0x0153 }, + { 0x0014, 0x0154 }, + { 0x0014, 0x0155 }, + { 0x0014, 0x0156 }, + { 0x0014, 0x0157 }, + { 0x0014, 0x0158 }, + { 0x0014, 0x0159 }, + { 0x0014, 0x015a }, + { 0x0014, 0x015b }, + { 0x0014, 0x015c }, + { 0x0014, 0x015d }, + { 0x0014, 0x015e }, + { 0x0014, 0x015f }, + { 0x0014, 0x0160 }, + { 0x0014, 0x0161 }, + { 0x0014, 0x0162 }, + { 0x0014, 0x0163 }, + { 0x0014, 0x0164 }, + { 0x0014, 0x0165 }, + { 0x0014, 0x0166 }, + { 0x0014, 0x0167 }, + { 0x0014, 0x0168 }, + { 0x0014, 0x0169 }, + { 0x0014, 0x016a }, + { 0x0014, 0x016b }, + { 0x0014, 0x016c }, + { 0x0014, 0x016d }, + { 0x0014, 0x016e }, + { 0x0014, 0x016f }, + { 0x0014, 0x0170 }, + { 0x0014, 0x0171 }, + { 0x0014, 0x0172 }, + { 0x0014, 0x0173 }, + { 0x0014, 0x0174 }, + { 0x0014, 0x0175 }, + { 0x0014, 0x0176 }, + { 0x0014, 0x0177 }, + { 0x0014, 0x0178 }, + { 0x0014, 0x0179 }, + { 0x0014, 0x017a }, + { 0x0014, 0x017b }, + { 0x0014, 0x017c }, + { 0x0014, 0x017d }, + { 0x0014, 0x017e }, + { 0x0014, 0x017f }, + { 0x0014, 0x0180 }, + { 0x0014, 0x0181 }, + { 0x0014, 0x0182 }, + { 0x0014, 0x0183 }, + { 0x0014, 0x0184 }, + { 0x0014, 0x0185 }, + { 0x0014, 0x0186 }, + { 0x0014, 0x0187 }, + { 0x0014, 0x0188 }, + { 0x0014, 0x0189 }, + { 0x0014, 0x018a }, + { 0x0014, 0x018b }, + { 0x0014, 0x018c }, + { 0x0014, 0x018d }, + { 0x0014, 0x018e }, + { 0x0014, 0x018f }, + { 0x0014, 0x0190 }, + { 0x0014, 0x0191 }, + { 0x0014, 0x0192 }, + { 0x0014, 0x0193 }, + { 0x0014, 0x0194 }, + { 0x0014, 0x0195 }, + { 0x0014, 0x0196 }, + { 0x0014, 0x0197 }, + { 0x0013, 0x00db }, + }; + +const uint16_t c_aauiLCLDHuffEnc16[729][2] = + { + { 0x0006, 0x000d }, + { 0x0005, 0x0010 }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x000a }, + { 0x0009, 0x000b }, + { 0x000b, 0x000d }, + { 0x000c, 0x000e }, + { 0x000e, 0x0016 }, + { 0x0010, 0x002d }, + { 0x0011, 0x0051 }, + { 0x0012, 0x008c }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0005, 0x0011 }, + { 0x0004, 0x000f }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0007, 0x000c }, + { 0x0008, 0x000b }, + { 0x000a, 0x000c }, + { 0x000b, 0x000e }, + { 0x000d, 0x0010 }, + { 0x000e, 0x0017 }, + { 0x000f, 0x001c }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0006, 0x0013 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0006, 0x0014 }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0009, 0x000c }, + { 0x000a, 0x000d }, + { 0x000c, 0x000f }, + { 0x000d, 0x0011 }, + { 0x000f, 0x001d }, + { 0x0011, 0x0052 }, + { 0x0012, 0x008d }, + { 0x0012, 0x008e }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0006, 0x0015 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0007, 0x000f }, + { 0x0008, 0x000c }, + { 0x0009, 0x000d }, + { 0x000b, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000d, 0x0012 }, + { 0x000f, 0x001e }, + { 0x0012, 0x008f }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0006, 0x0018 }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x000d }, + { 0x000a, 0x000e }, + { 0x000b, 0x0010 }, + { 0x000c, 0x0011 }, + { 0x000e, 0x0018 }, + { 0x0010, 0x002e }, + { 0x0012, 0x0090 }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0007, 0x0012 }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0008, 0x000e }, + { 0x0009, 0x000e }, + { 0x000b, 0x0011 }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000e, 0x0019 }, + { 0x0010, 0x002f }, + { 0x0012, 0x0091 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0007, 0x0015 }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0008, 0x000f }, + { 0x0009, 0x000f }, + { 0x000a, 0x000f }, + { 0x000b, 0x0012 }, + { 0x000d, 0x0014 }, + { 0x000e, 0x001a }, + { 0x000f, 0x001f }, + { 0x0013, 0x010f }, + { 0x0011, 0x0053 }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x0008, 0x0010 }, + { 0x0007, 0x0018 }, + { 0x0007, 0x0019 }, + { 0x0008, 0x0011 }, + { 0x0008, 0x0012 }, + { 0x0009, 0x0010 }, + { 0x000a, 0x0010 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0013 }, + { 0x000e, 0x001b }, + { 0x000f, 0x0020 }, + { 0x0010, 0x0030 }, + { 0x0012, 0x0092 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0009, 0x0011 }, + { 0x0008, 0x0013 }, + { 0x0009, 0x0012 }, + { 0x0009, 0x0013 }, + { 0x000a, 0x0011 }, + { 0x000a, 0x0012 }, + { 0x000b, 0x0014 }, + { 0x000c, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000e, 0x001c }, + { 0x000f, 0x0021 }, + { 0x0013, 0x0110 }, + { 0x0012, 0x0093 }, + { 0x0012, 0x0094 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x000b, 0x0015 }, + { 0x000a, 0x0013 }, + { 0x000a, 0x0014 }, + { 0x000a, 0x0015 }, + { 0x000b, 0x0016 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0016 }, + { 0x000d, 0x0017 }, + { 0x000f, 0x0022 }, + { 0x0010, 0x0031 }, + { 0x0012, 0x0095 }, + { 0x0012, 0x0096 }, + { 0x0014, 0x006f }, + { 0x0013, 0x0111 }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x000c, 0x0016 }, + { 0x000b, 0x0017 }, + { 0x000c, 0x0017 }, + { 0x000c, 0x0018 }, + { 0x000c, 0x0019 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x001d }, + { 0x000f, 0x0023 }, + { 0x000f, 0x0024 }, + { 0x0011, 0x0054 }, + { 0x0012, 0x0097 }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x000e, 0x001e }, + { 0x000d, 0x0019 }, + { 0x000d, 0x001a }, + { 0x000d, 0x001b }, + { 0x000e, 0x001f }, + { 0x000f, 0x0025 }, + { 0x000f, 0x0026 }, + { 0x0010, 0x0032 }, + { 0x0010, 0x0033 }, + { 0x0012, 0x0098 }, + { 0x0013, 0x0112 }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x000f, 0x0027 }, + { 0x000f, 0x0028 }, + { 0x000f, 0x0029 }, + { 0x000f, 0x002a }, + { 0x0010, 0x0034 }, + { 0x000f, 0x002b }, + { 0x0011, 0x0055 }, + { 0x0012, 0x0099 }, + { 0x0012, 0x009a }, + { 0x0012, 0x009b }, + { 0x0014, 0x009d }, + { 0x0013, 0x0113 }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0011, 0x0056 }, + { 0x0010, 0x0035 }, + { 0x0010, 0x0036 }, + { 0x0010, 0x0037 }, + { 0x0011, 0x0057 }, + { 0x0012, 0x009c }, + { 0x0012, 0x009d }, + { 0x0012, 0x009e }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0012, 0x009f }, + { 0x0011, 0x0058 }, + { 0x0012, 0x00a0 }, + { 0x0014, 0x00c0 }, + { 0x0011, 0x0059 }, + { 0x0013, 0x0114 }, + { 0x0012, 0x00a1 }, + { 0x0014, 0x00c1 }, + { 0x0013, 0x0115 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + { 0x0014, 0x0104 }, + { 0x0014, 0x0105 }, + { 0x0014, 0x0106 }, + { 0x0014, 0x0107 }, + { 0x0014, 0x0108 }, + { 0x0014, 0x0109 }, + { 0x0014, 0x010a }, + { 0x0014, 0x010b }, + { 0x0014, 0x010c }, + { 0x0014, 0x010d }, + { 0x0014, 0x010e }, + { 0x0014, 0x010f }, + { 0x0014, 0x0110 }, + { 0x0014, 0x0111 }, + { 0x0014, 0x0112 }, + { 0x0014, 0x0113 }, + { 0x0014, 0x0114 }, + { 0x0014, 0x0115 }, + { 0x0014, 0x0116 }, + { 0x0014, 0x0117 }, + { 0x0014, 0x0118 }, + { 0x0014, 0x0119 }, + { 0x0014, 0x011a }, + { 0x0014, 0x011b }, + { 0x0014, 0x011c }, + { 0x0014, 0x011d }, + { 0x0014, 0x011e }, + { 0x0014, 0x011f }, + { 0x0014, 0x0120 }, + { 0x0014, 0x0121 }, + { 0x0014, 0x0122 }, + { 0x0014, 0x0123 }, + { 0x0014, 0x0124 }, + { 0x0014, 0x0125 }, + { 0x0013, 0x0116 }, + { 0x0014, 0x0126 }, + { 0x0014, 0x0127 }, + { 0x0014, 0x0128 }, + { 0x0014, 0x0129 }, + { 0x0014, 0x012a }, + { 0x0014, 0x012b }, + { 0x0014, 0x012c }, + { 0x0014, 0x012d }, + { 0x0014, 0x012e }, + { 0x0014, 0x012f }, + { 0x0014, 0x0130 }, + { 0x0014, 0x0131 }, + { 0x0014, 0x0132 }, + { 0x0014, 0x0133 }, + { 0x0014, 0x0134 }, + { 0x0014, 0x0135 }, + { 0x0014, 0x0136 }, + { 0x0014, 0x0137 }, + { 0x0014, 0x0138 }, + { 0x0014, 0x0139 }, + { 0x0014, 0x013a }, + { 0x0014, 0x013b }, + { 0x0014, 0x013c }, + { 0x0014, 0x013d }, + { 0x0014, 0x013e }, + { 0x0014, 0x013f }, + { 0x0014, 0x0140 }, + { 0x0014, 0x0141 }, + { 0x0014, 0x0142 }, + { 0x0014, 0x0143 }, + { 0x0014, 0x0144 }, + { 0x0014, 0x0145 }, + { 0x0014, 0x0146 }, + { 0x0014, 0x0147 }, + { 0x0014, 0x0148 }, + { 0x0014, 0x0149 }, + { 0x0014, 0x014a }, + { 0x0014, 0x014b }, + { 0x0014, 0x014c }, + { 0x0014, 0x014d }, + { 0x0014, 0x014e }, + { 0x0014, 0x014f }, + { 0x0014, 0x0150 }, + { 0x0014, 0x0151 }, + { 0x0014, 0x0152 }, + { 0x0014, 0x0153 }, + { 0x0014, 0x0154 }, + { 0x0014, 0x0155 }, + { 0x0014, 0x0156 }, + { 0x0014, 0x0157 }, + { 0x0014, 0x0158 }, + { 0x0014, 0x0159 }, + { 0x0014, 0x015a }, + { 0x0014, 0x015b }, + { 0x0014, 0x015c }, + { 0x0014, 0x015d }, + { 0x0014, 0x015e }, + { 0x0014, 0x015f }, + { 0x0014, 0x0160 }, + { 0x0014, 0x0161 }, + { 0x0014, 0x0162 }, + { 0x0014, 0x0163 }, + { 0x0014, 0x0164 }, + { 0x0014, 0x0165 }, + { 0x0014, 0x0166 }, + { 0x0014, 0x0167 }, + { 0x0014, 0x0168 }, + { 0x0014, 0x0169 }, + { 0x0014, 0x016a }, + { 0x0014, 0x016b }, + { 0x0014, 0x016c }, + { 0x0014, 0x016d }, + { 0x0014, 0x016e }, + { 0x0014, 0x016f }, + { 0x0014, 0x0170 }, + { 0x0014, 0x0171 }, + { 0x0014, 0x0172 }, + { 0x0014, 0x0173 }, + { 0x0014, 0x0174 }, + { 0x0014, 0x0175 }, + { 0x0014, 0x0176 }, + { 0x0014, 0x0177 }, + { 0x0014, 0x0178 }, + { 0x0014, 0x0179 }, + { 0x0014, 0x017a }, + { 0x0014, 0x017b }, + { 0x0014, 0x017c }, + { 0x0014, 0x017d }, + { 0x0014, 0x017e }, + { 0x0014, 0x017f }, + { 0x0014, 0x0180 }, + { 0x0014, 0x0181 }, + { 0x0014, 0x0182 }, + { 0x0014, 0x0183 }, + { 0x0014, 0x0184 }, + { 0x0014, 0x0185 }, + { 0x0014, 0x0186 }, + { 0x0014, 0x0187 }, + { 0x0014, 0x0188 }, + { 0x0014, 0x0189 }, + { 0x0014, 0x018a }, + { 0x0014, 0x018b }, + { 0x0014, 0x018c }, + { 0x0014, 0x018d }, + { 0x0014, 0x018e }, + { 0x0014, 0x018f }, + { 0x0014, 0x0190 }, + { 0x0014, 0x0191 }, + { 0x0014, 0x0192 }, + { 0x0014, 0x0193 }, + { 0x0014, 0x0194 }, + { 0x0014, 0x0195 }, + { 0x0014, 0x0196 }, + { 0x0014, 0x0197 }, + { 0x0014, 0x0198 }, + { 0x0014, 0x0199 }, + { 0x0014, 0x019a }, + { 0x0014, 0x019b }, + { 0x0014, 0x019c }, + { 0x0014, 0x019d }, + { 0x0014, 0x019e }, + { 0x0014, 0x019f }, + { 0x0014, 0x01a0 }, + { 0x0014, 0x01a1 }, + { 0x0014, 0x01a2 }, + { 0x0014, 0x01a3 }, + { 0x0014, 0x01a4 }, + { 0x0014, 0x01a5 }, + { 0x0014, 0x01a6 }, + { 0x0014, 0x01a7 }, + { 0x0014, 0x01a8 }, + { 0x0014, 0x01a9 }, + { 0x0014, 0x01aa }, + { 0x0014, 0x01ab }, + { 0x0014, 0x01ac }, + { 0x0014, 0x01ad }, + { 0x0014, 0x01ae }, + { 0x0014, 0x01af }, + { 0x0014, 0x01b0 }, + { 0x0014, 0x01b1 }, + { 0x0014, 0x01b2 }, + { 0x0014, 0x01b3 }, + { 0x0014, 0x01b4 }, + { 0x0014, 0x01b5 }, + { 0x0014, 0x01b6 }, + { 0x0014, 0x01b7 }, + { 0x0014, 0x01b8 }, + { 0x0014, 0x01b9 }, + { 0x0014, 0x01ba }, + { 0x0014, 0x01bb }, + { 0x0014, 0x01bc }, + { 0x0014, 0x01bd }, + { 0x0014, 0x01be }, + { 0x0014, 0x01bf }, + { 0x0014, 0x01c0 }, + { 0x0014, 0x01c1 }, + { 0x0014, 0x01c2 }, + { 0x0014, 0x01c3 }, + { 0x0014, 0x01c4 }, + { 0x0014, 0x01c5 }, + { 0x0014, 0x01c6 }, + { 0x0014, 0x01c7 }, + { 0x0014, 0x01c8 }, + { 0x0014, 0x01c9 }, + { 0x0014, 0x01ca }, + { 0x0014, 0x01cb }, + { 0x0014, 0x01cc }, + { 0x0014, 0x01cd }, + { 0x0014, 0x01ce }, + { 0x0014, 0x01cf }, + { 0x0014, 0x01d0 }, + { 0x0014, 0x01d1 }, + { 0x0014, 0x01d2 }, + { 0x0014, 0x01d3 }, + { 0x0014, 0x01d4 }, + { 0x0014, 0x01d5 }, + { 0x0014, 0x01d6 }, + { 0x0014, 0x01d7 }, + { 0x0014, 0x01d8 }, + { 0x0014, 0x01d9 }, + { 0x0014, 0x01da }, + { 0x0014, 0x01db }, + { 0x0014, 0x01dc }, + { 0x0014, 0x01dd }, + { 0x0014, 0x01de }, + { 0x0014, 0x01df }, + { 0x0014, 0x01e0 }, + { 0x0014, 0x01e1 }, + { 0x0014, 0x01e2 }, + { 0x0014, 0x01e3 }, + { 0x0014, 0x01e4 }, + { 0x0014, 0x01e5 }, + { 0x0014, 0x01e6 }, + { 0x0014, 0x01e7 }, + { 0x0014, 0x01e8 }, + { 0x0014, 0x01e9 }, + { 0x0014, 0x01ea }, + { 0x0014, 0x01eb }, + { 0x0014, 0x01ec }, + { 0x0014, 0x01ed }, + { 0x0014, 0x01ee }, + { 0x0014, 0x01ef }, + { 0x0014, 0x01f0 }, + { 0x0014, 0x01f1 }, + { 0x0014, 0x01f2 }, + { 0x0014, 0x01f3 }, + { 0x0014, 0x01f4 }, + { 0x0014, 0x01f5 }, + { 0x0014, 0x01f6 }, + { 0x0014, 0x01f7 }, + { 0x0014, 0x01f8 }, + { 0x0014, 0x01f9 }, + { 0x0014, 0x01fa }, + { 0x0014, 0x01fb }, + { 0x0014, 0x01fc }, + { 0x0014, 0x01fd }, + { 0x0014, 0x01fe }, + { 0x0014, 0x01ff }, + { 0x0014, 0x0200 }, + { 0x0014, 0x0201 }, + { 0x0014, 0x0202 }, + { 0x0014, 0x0203 }, + { 0x0014, 0x0204 }, + { 0x0014, 0x0205 }, + { 0x0014, 0x0206 }, + { 0x0014, 0x0207 }, + { 0x0014, 0x0208 }, + { 0x0014, 0x0209 }, + { 0x0014, 0x020a }, + { 0x0014, 0x020b }, + { 0x0014, 0x020c }, + { 0x0014, 0x020d }, + { 0x0014, 0x020e }, + { 0x0014, 0x020f }, + { 0x0014, 0x0210 }, + { 0x0014, 0x0211 }, + { 0x0014, 0x0212 }, + { 0x0014, 0x0213 }, + { 0x0014, 0x0214 }, + { 0x0014, 0x0215 }, + { 0x0013, 0x0117 }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc17[729][2] = + { + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0009, 0x000f }, + { 0x000a, 0x000f }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0014 }, + { 0x000e, 0x0017 }, + { 0x0010, 0x002d }, + { 0x0011, 0x004c }, + { 0x0012, 0x008a }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0006, 0x0016 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0008, 0x0010 }, + { 0x000a, 0x0010 }, + { 0x000b, 0x0011 }, + { 0x000c, 0x0012 }, + { 0x000e, 0x0018 }, + { 0x000f, 0x0020 }, + { 0x0011, 0x004d }, + { 0x0013, 0x00e4 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0006, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0007, 0x0014 }, + { 0x0008, 0x0011 }, + { 0x0009, 0x0010 }, + { 0x000a, 0x0011 }, + { 0x000b, 0x0012 }, + { 0x000c, 0x0013 }, + { 0x000e, 0x0019 }, + { 0x000f, 0x0021 }, + { 0x0010, 0x002e }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0006, 0x001e }, + { 0x0005, 0x001e }, + { 0x0005, 0x001f }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0007, 0x0015 }, + { 0x0008, 0x0012 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x0012 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0014 }, + { 0x000e, 0x001a }, + { 0x000f, 0x0022 }, + { 0x0010, 0x002f }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0008, 0x0013 }, + { 0x0009, 0x0012 }, + { 0x000a, 0x0013 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0015 }, + { 0x000f, 0x0023 }, + { 0x0010, 0x0030 }, + { 0x0011, 0x004e }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0007, 0x0018 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0007, 0x0019 }, + { 0x0007, 0x001a }, + { 0x0008, 0x0014 }, + { 0x0009, 0x0013 }, + { 0x000a, 0x0014 }, + { 0x000b, 0x0014 }, + { 0x000c, 0x0016 }, + { 0x000d, 0x0016 }, + { 0x000f, 0x0024 }, + { 0x0010, 0x0031 }, + { 0x0011, 0x004f }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0007, 0x001b }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0007, 0x001c }, + { 0x0007, 0x001d }, + { 0x0008, 0x0015 }, + { 0x0009, 0x0014 }, + { 0x000a, 0x0015 }, + { 0x000a, 0x0016 }, + { 0x000c, 0x0017 }, + { 0x000d, 0x0017 }, + { 0x000e, 0x001b }, + { 0x000f, 0x0025 }, + { 0x0011, 0x0050 }, + { 0x0011, 0x0051 }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0008, 0x0016 }, + { 0x0007, 0x001e }, + { 0x0007, 0x001f }, + { 0x0007, 0x0020 }, + { 0x0007, 0x0021 }, + { 0x0008, 0x0017 }, + { 0x0008, 0x0018 }, + { 0x0009, 0x0015 }, + { 0x000a, 0x0017 }, + { 0x000b, 0x0015 }, + { 0x000c, 0x0018 }, + { 0x000e, 0x001c }, + { 0x000e, 0x001d }, + { 0x0010, 0x0032 }, + { 0x0012, 0x008b }, + { 0x0012, 0x008c }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0008, 0x0019 }, + { 0x0007, 0x0022 }, + { 0x0007, 0x0023 }, + { 0x0008, 0x001a }, + { 0x0008, 0x001b }, + { 0x0009, 0x0016 }, + { 0x0009, 0x0017 }, + { 0x000a, 0x0018 }, + { 0x000b, 0x0016 }, + { 0x000c, 0x0019 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x001e }, + { 0x0010, 0x0033 }, + { 0x0011, 0x0052 }, + { 0x0014, 0x0052 }, + { 0x0013, 0x00e9 }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0009, 0x0018 }, + { 0x0008, 0x001c }, + { 0x0008, 0x001d }, + { 0x0009, 0x0019 }, + { 0x0009, 0x001a }, + { 0x000a, 0x0019 }, + { 0x000a, 0x001a }, + { 0x000b, 0x0017 }, + { 0x000c, 0x001a }, + { 0x000d, 0x0019 }, + { 0x000e, 0x001f }, + { 0x000f, 0x0026 }, + { 0x0010, 0x0034 }, + { 0x0012, 0x008d }, + { 0x0013, 0x00ea }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x000b, 0x0018 }, + { 0x0009, 0x001b }, + { 0x000a, 0x001b }, + { 0x000a, 0x001c }, + { 0x000a, 0x001d }, + { 0x000b, 0x0019 }, + { 0x000b, 0x001a }, + { 0x000c, 0x001b }, + { 0x000d, 0x001a }, + { 0x000e, 0x0020 }, + { 0x000f, 0x0027 }, + { 0x0012, 0x008e }, + { 0x0011, 0x0053 }, + { 0x0013, 0x00eb }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x000c, 0x001c }, + { 0x000b, 0x001b }, + { 0x000b, 0x001c }, + { 0x000b, 0x001d }, + { 0x000c, 0x001d }, + { 0x000c, 0x001e }, + { 0x000d, 0x001b }, + { 0x000d, 0x001c }, + { 0x000e, 0x0021 }, + { 0x0010, 0x0035 }, + { 0x0010, 0x0036 }, + { 0x0011, 0x0054 }, + { 0x0013, 0x00ec }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x000d, 0x001d }, + { 0x000c, 0x001f }, + { 0x000c, 0x0020 }, + { 0x000c, 0x0021 }, + { 0x000d, 0x001e }, + { 0x000d, 0x001f }, + { 0x000e, 0x0022 }, + { 0x000f, 0x0028 }, + { 0x0010, 0x0037 }, + { 0x0010, 0x0038 }, + { 0x0010, 0x0039 }, + { 0x0012, 0x008f }, + { 0x0013, 0x00ed }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x000e, 0x0023 }, + { 0x000d, 0x0020 }, + { 0x000d, 0x0021 }, + { 0x000e, 0x0024 }, + { 0x000e, 0x0025 }, + { 0x000e, 0x0026 }, + { 0x000f, 0x0029 }, + { 0x0010, 0x003a }, + { 0x0010, 0x003b }, + { 0x0012, 0x0090 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x000f, 0x002a }, + { 0x000e, 0x0027 }, + { 0x000f, 0x002b }, + { 0x000f, 0x002c }, + { 0x000f, 0x002d }, + { 0x0010, 0x003c }, + { 0x0010, 0x003d }, + { 0x0011, 0x0055 }, + { 0x0011, 0x0056 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0012, 0x0091 }, + { 0x0010, 0x003e }, + { 0x0010, 0x003f }, + { 0x0011, 0x0057 }, + { 0x0011, 0x0058 }, + { 0x0011, 0x0059 }, + { 0x0012, 0x0092 }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0012, 0x0093 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0013, 0x00f0 }, + { 0x0012, 0x0094 }, + { 0x0012, 0x0095 }, + { 0x0012, 0x0096 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0012, 0x0097 }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + { 0x0014, 0x0104 }, + { 0x0014, 0x0105 }, + { 0x0014, 0x0106 }, + { 0x0014, 0x0107 }, + { 0x0014, 0x0108 }, + { 0x0014, 0x0109 }, + { 0x0014, 0x010a }, + { 0x0014, 0x010b }, + { 0x0014, 0x010c }, + { 0x0014, 0x010d }, + { 0x0014, 0x010e }, + { 0x0014, 0x010f }, + { 0x0014, 0x0110 }, + { 0x0014, 0x0111 }, + { 0x0014, 0x0112 }, + { 0x0014, 0x0113 }, + { 0x0014, 0x0114 }, + { 0x0014, 0x0115 }, + { 0x0014, 0x0116 }, + { 0x0014, 0x0117 }, + { 0x0014, 0x0118 }, + { 0x0014, 0x0119 }, + { 0x0014, 0x011a }, + { 0x0014, 0x011b }, + { 0x0014, 0x011c }, + { 0x0014, 0x011d }, + { 0x0014, 0x011e }, + { 0x0014, 0x011f }, + { 0x0014, 0x0120 }, + { 0x0014, 0x0121 }, + { 0x0014, 0x0122 }, + { 0x0014, 0x0123 }, + { 0x0014, 0x0124 }, + { 0x0014, 0x0125 }, + { 0x0014, 0x0126 }, + { 0x0014, 0x0127 }, + { 0x0014, 0x0128 }, + { 0x0014, 0x0129 }, + { 0x0014, 0x012a }, + { 0x0014, 0x012b }, + { 0x0014, 0x012c }, + { 0x0014, 0x012d }, + { 0x0014, 0x012e }, + { 0x0014, 0x012f }, + { 0x0014, 0x0130 }, + { 0x0014, 0x0131 }, + { 0x0014, 0x0132 }, + { 0x0014, 0x0133 }, + { 0x0014, 0x0134 }, + { 0x0014, 0x0135 }, + { 0x0014, 0x0136 }, + { 0x0014, 0x0137 }, + { 0x0014, 0x0138 }, + { 0x0014, 0x0139 }, + { 0x0014, 0x013a }, + { 0x0014, 0x013b }, + { 0x0014, 0x013c }, + { 0x0014, 0x013d }, + { 0x0014, 0x013e }, + { 0x0014, 0x013f }, + { 0x0014, 0x0140 }, + { 0x0014, 0x0141 }, + { 0x0014, 0x0142 }, + { 0x0014, 0x0143 }, + { 0x0014, 0x0144 }, + { 0x0014, 0x0145 }, + { 0x0014, 0x0146 }, + { 0x0014, 0x0147 }, + { 0x0014, 0x0148 }, + { 0x0014, 0x0149 }, + { 0x0014, 0x014a }, + { 0x0014, 0x014b }, + { 0x0014, 0x014c }, + { 0x0014, 0x014d }, + { 0x0014, 0x014e }, + { 0x0014, 0x014f }, + { 0x0014, 0x0150 }, + { 0x0014, 0x0151 }, + { 0x0014, 0x0152 }, + { 0x0014, 0x0153 }, + { 0x0014, 0x0154 }, + { 0x0014, 0x0155 }, + { 0x0014, 0x0156 }, + { 0x0014, 0x0157 }, + { 0x0014, 0x0158 }, + { 0x0014, 0x0159 }, + { 0x0014, 0x015a }, + { 0x0014, 0x015b }, + { 0x0014, 0x015c }, + { 0x0014, 0x015d }, + { 0x0014, 0x015e }, + { 0x0014, 0x015f }, + { 0x0014, 0x0160 }, + { 0x0014, 0x0161 }, + { 0x0014, 0x0162 }, + { 0x0014, 0x0163 }, + { 0x0014, 0x0164 }, + { 0x0014, 0x0165 }, + { 0x0014, 0x0166 }, + { 0x0014, 0x0167 }, + { 0x0014, 0x0168 }, + { 0x0014, 0x0169 }, + { 0x0014, 0x016a }, + { 0x0014, 0x016b }, + { 0x0014, 0x016c }, + { 0x0014, 0x016d }, + { 0x0014, 0x016e }, + { 0x0014, 0x016f }, + { 0x0014, 0x0170 }, + { 0x0014, 0x0171 }, + { 0x0014, 0x0172 }, + { 0x0014, 0x0173 }, + { 0x0014, 0x0174 }, + { 0x0014, 0x0175 }, + { 0x0014, 0x0176 }, + { 0x0014, 0x0177 }, + { 0x0014, 0x0178 }, + { 0x0014, 0x0179 }, + { 0x0014, 0x017a }, + { 0x0014, 0x017b }, + { 0x0014, 0x017c }, + { 0x0014, 0x017d }, + { 0x0014, 0x017e }, + { 0x0014, 0x017f }, + { 0x0014, 0x0180 }, + { 0x0014, 0x0181 }, + { 0x0014, 0x0182 }, + { 0x0014, 0x0183 }, + { 0x0014, 0x0184 }, + { 0x0014, 0x0185 }, + { 0x0014, 0x0186 }, + { 0x0014, 0x0187 }, + { 0x0014, 0x0188 }, + { 0x0014, 0x0189 }, + { 0x0014, 0x018a }, + { 0x0014, 0x018b }, + { 0x0014, 0x018c }, + { 0x0014, 0x018d }, + { 0x0014, 0x018e }, + { 0x0014, 0x018f }, + { 0x0014, 0x0190 }, + { 0x0014, 0x0191 }, + { 0x0014, 0x0192 }, + { 0x0014, 0x0193 }, + { 0x0014, 0x0194 }, + { 0x0014, 0x0195 }, + { 0x0014, 0x0196 }, + { 0x0014, 0x0197 }, + { 0x0014, 0x0198 }, + { 0x0014, 0x0199 }, + { 0x0014, 0x019a }, + { 0x0014, 0x019b }, + { 0x0014, 0x019c }, + { 0x0014, 0x019d }, + { 0x0014, 0x019e }, + { 0x0014, 0x019f }, + { 0x0014, 0x01a0 }, + { 0x0014, 0x01a1 }, + { 0x0014, 0x01a2 }, + { 0x0014, 0x01a3 }, + { 0x0014, 0x01a4 }, + { 0x0014, 0x01a5 }, + { 0x0014, 0x01a6 }, + { 0x0014, 0x01a7 }, + { 0x0014, 0x01a8 }, + { 0x0014, 0x01a9 }, + { 0x0014, 0x01aa }, + { 0x0014, 0x01ab }, + { 0x0014, 0x01ac }, + { 0x0014, 0x01ad }, + { 0x0014, 0x01ae }, + { 0x0014, 0x01af }, + { 0x0014, 0x01b0 }, + { 0x0014, 0x01b1 }, + { 0x0014, 0x01b2 }, + { 0x0014, 0x01b3 }, + { 0x0014, 0x01b4 }, + { 0x0014, 0x01b5 }, + { 0x0014, 0x01b6 }, + { 0x0014, 0x01b7 }, + { 0x0014, 0x01b8 }, + { 0x0014, 0x01b9 }, + { 0x0014, 0x01ba }, + { 0x0014, 0x01bb }, + { 0x0014, 0x01bc }, + { 0x0014, 0x01bd }, + { 0x0014, 0x01be }, + { 0x0014, 0x01bf }, + { 0x0014, 0x01c0 }, + { 0x0014, 0x01c1 }, + { 0x0014, 0x01c2 }, + { 0x0014, 0x01c3 }, + { 0x0014, 0x01c4 }, + { 0x0014, 0x01c5 }, + { 0x0014, 0x01c6 }, + { 0x0014, 0x01c7 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc18[28][2] = + { + { 0x0004, 0x0001 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc19[29][2] = + { + { 0x0004, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0001 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0012, 0x0003 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc20[32][2] = + { + { 0x0004, 0x0002 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + }; + +const uint16_t c_aauiLCLDHuffEnc21[37][2] = + { + { 0x0005, 0x0002 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc22[39][2] = + { + { 0x0005, 0x0002 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000c, 0x0001 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000f, 0x0001 }, + { 0x000e, 0x0003 }, + { 0x0011, 0x0000 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc23[46][2] = + { + { 0x0005, 0x0003 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0012, 0x0000 }, + { 0x0012, 0x0001 }, + { 0x0011, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc24[55][2] = + { + { 0x0005, 0x0004 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + { 0x0013, 0x0000 }, + { 0x0012, 0x0001 }, + { 0x0013, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc25[65][2] = + { + { 0x0005, 0x0005 }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0005, 0x0006 }, + { 0x0004, 0x000f }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000f, 0x0003 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0004 }, + { 0x0010, 0x0001 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0011, 0x0001 }, + { 0x0012, 0x0000 }, + { 0x0012, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc26[77][2] = + { + { 0x0006, 0x0004 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0005, 0x001f }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000e, 0x0002 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000f, 0x0003 }, + { 0x000e, 0x0005 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0011, 0x0002 }, + { 0x0012, 0x0001 }, + { 0x0010, 0x0005 }, + { 0x0012, 0x0002 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc27[91][2] = + { + { 0x0006, 0x0006 }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0005, 0x001f }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000f, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x0010, 0x0003 }, + { 0x000f, 0x0005 }, + { 0x0012, 0x0000 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0011, 0x0004 }, + { 0x0011, 0x0005 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc28[109][2] = + { + { 0x0006, 0x0008 }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0006, 0x0009 }, + { 0x0005, 0x001f }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0010, 0x0006 }, + { 0x0011, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0000 }, + { 0x0010, 0x0008 }, + { 0x0010, 0x0009 }, + { 0x0013, 0x0001 }, + { 0x0011, 0x0007 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc29[129][2] = + { + { 0x0006, 0x0009 }, + { 0x0005, 0x0019 }, + { 0x0006, 0x000a }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0006, 0x000b }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0005, 0x001f }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0006, 0x0030 }, + { 0x0006, 0x0031 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0011, 0x0007 }, + { 0x000f, 0x0008 }, + { 0x0012, 0x0000 }, + { 0x000f, 0x0009 }, + { 0x0010, 0x0005 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x0012, 0x0001 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0011, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0011, 0x0009 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc30[153][2] = + { + { 0x0007, 0x0009 }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0006, 0x0030 }, + { 0x0006, 0x0031 }, + { 0x0006, 0x0032 }, + { 0x0006, 0x0033 }, + { 0x0006, 0x0034 }, + { 0x0006, 0x0035 }, + { 0x0006, 0x0036 }, + { 0x0006, 0x0037 }, + { 0x0006, 0x0038 }, + { 0x0006, 0x0039 }, + { 0x0006, 0x003a }, + { 0x0006, 0x003b }, + { 0x0006, 0x003c }, + { 0x0006, 0x003d }, + { 0x0006, 0x003e }, + { 0x0006, 0x003f }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0007, 0x0015 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0007, 0x0018 }, + { 0x0007, 0x0019 }, + { 0x0007, 0x001a }, + { 0x0007, 0x001b }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x000a, 0x0008 }, + { 0x0009, 0x000f }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000c, 0x0008 }, + { 0x000b, 0x000e }, + { 0x000b, 0x000f }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000d, 0x0008 }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000d, 0x0009 }, + { 0x000c, 0x000d }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000e, 0x0008 }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x000f, 0x0008 }, + { 0x0010, 0x0006 }, + { 0x000e, 0x000d }, + { 0x000e, 0x000e }, + { 0x000e, 0x000f }, + { 0x0010, 0x0007 }, + { 0x000f, 0x0009 }, + { 0x0010, 0x0008 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x000f, 0x000d }, + { 0x0010, 0x0009 }, + { 0x0011, 0x0000 }, + { 0x0011, 0x0001 }, + { 0x0011, 0x0002 }, + { 0x000f, 0x000e }, + { 0x0010, 0x000a }, + { 0x0011, 0x0003 }, + { 0x0011, 0x0004 }, + { 0x0011, 0x0005 }, + { 0x000f, 0x000f }, + { 0x0011, 0x0006 }, + { 0x0011, 0x0007 }, + { 0x0011, 0x0008 }, + { 0x0011, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0011, 0x000b }, + { 0x0010, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc31[181][2] = + { + { 0x0007, 0x000b }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0006, 0x0030 }, + { 0x0006, 0x0031 }, + { 0x0006, 0x0032 }, + { 0x0006, 0x0033 }, + { 0x0006, 0x0034 }, + { 0x0006, 0x0035 }, + { 0x0006, 0x0036 }, + { 0x0006, 0x0037 }, + { 0x0006, 0x0038 }, + { 0x0006, 0x0039 }, + { 0x0006, 0x003a }, + { 0x0006, 0x003b }, + { 0x0006, 0x003c }, + { 0x0006, 0x003d }, + { 0x0006, 0x003e }, + { 0x0007, 0x000c }, + { 0x0006, 0x003f }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0007, 0x0015 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0007, 0x0018 }, + { 0x0007, 0x0019 }, + { 0x0007, 0x001a }, + { 0x0007, 0x001b }, + { 0x0007, 0x001c }, + { 0x0007, 0x001d }, + { 0x0007, 0x001e }, + { 0x0007, 0x001f }, + { 0x0007, 0x0020 }, + { 0x0007, 0x0021 }, + { 0x0007, 0x0022 }, + { 0x0007, 0x0023 }, + { 0x0007, 0x0024 }, + { 0x0007, 0x0025 }, + { 0x0007, 0x0026 }, + { 0x0007, 0x0027 }, + { 0x0007, 0x0028 }, + { 0x0007, 0x0029 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0008, 0x0012 }, + { 0x0008, 0x0013 }, + { 0x0008, 0x0014 }, + { 0x0008, 0x0015 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000a, 0x000e }, + { 0x000a, 0x000f }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000b, 0x000e }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000b, 0x000f }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000c, 0x000d }, + { 0x000d, 0x0008 }, + { 0x000c, 0x000e }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000c, 0x000f }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000e, 0x000d }, + { 0x000e, 0x000e }, + { 0x000e, 0x000f }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x0010, 0x0009 }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x0010, 0x000a }, + { 0x0010, 0x000b }, + { 0x0010, 0x000c }, + { 0x0010, 0x000d }, + { 0x0011, 0x000a }, + { 0x0010, 0x000e }, + { 0x000f, 0x000f }, + { 0x0010, 0x000f }, + { 0x0012, 0x0000 }, + { 0x0012, 0x0001 }, + { 0x0011, 0x000b }, + { 0x0011, 0x000c }, + { 0x0010, 0x0010 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0011, 0x000d }, + { 0x0011, 0x000e }, + { 0x0011, 0x000f }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0010, 0x0011 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0012, 0x0010 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc33[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0008, 0x0000 }, + { 0x0008, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + }; + +const uint16_t c_aauiLCLDHuffEnc34[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0008, 0x0000 }, + { 0x0008, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + }; + +const uint16_t c_aauiLCLDHuffEnc35[25][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0000 }, + { 0x0009, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0007, 0x0007 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc36[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x000b, 0x0000 }, + { 0x000b, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0008, 0x0005 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0003 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000b, 0x000e }, + { 0x000b, 0x000f }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000a, 0x000e }, + { 0x000a, 0x000f }, + { 0x000a, 0x0010 }, + { 0x000a, 0x0011 }, + { 0x000a, 0x0012 }, + { 0x000a, 0x0013 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc37[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000c, 0x0000 }, + { 0x000c, 0x0001 }, + { 0x000c, 0x0002 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000c, 0x000d }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000c, 0x0011 }, + { 0x000c, 0x0012 }, + { 0x000c, 0x0013 }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000c, 0x0016 }, + { 0x000c, 0x0017 }, + { 0x000c, 0x0018 }, + { 0x000c, 0x0019 }, + { 0x000b, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc38[49][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0000 }, + { 0x000d, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x000a }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0003 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000c, 0x0013 }, + { 0x000b, 0x000b }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000d, 0x0010 }, + { 0x000d, 0x0011 }, + { 0x000d, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000d, 0x0016 }, + { 0x000d, 0x0017 }, + { 0x000d, 0x0018 }, + { 0x000d, 0x0019 }, + { 0x000d, 0x001a }, + { 0x000d, 0x001b }, + { 0x000d, 0x001c }, + { 0x000d, 0x001d }, + { 0x000d, 0x001e }, + { 0x000d, 0x001f }, + { 0x000d, 0x0020 }, + { 0x000d, 0x0021 }, + { 0x000d, 0x0022 }, + { 0x000d, 0x0023 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc39[64][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x000f, 0x0000 }, + { 0x000f, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0003 }, + { 0x000d, 0x000e }, + { 0x000f, 0x0008 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000d, 0x000f }, + { 0x000f, 0x000c }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x000f, 0x000f }, + { 0x000f, 0x0010 }, + { 0x000f, 0x0011 }, + { 0x000f, 0x0012 }, + { 0x000f, 0x0013 }, + { 0x000f, 0x0014 }, + { 0x000f, 0x0015 }, + { 0x000f, 0x0016 }, + { 0x000f, 0x0017 }, + { 0x000f, 0x0018 }, + { 0x000f, 0x0019 }, + { 0x000f, 0x001a }, + { 0x000f, 0x001b }, + { 0x000f, 0x001c }, + { 0x000f, 0x001d }, + { 0x000f, 0x001e }, + { 0x000f, 0x001f }, + { 0x000f, 0x0020 }, + { 0x000f, 0x0021 }, + { 0x000f, 0x0022 }, + { 0x000f, 0x0023 }, + { 0x000f, 0x0024 }, + { 0x000f, 0x0025 }, + { 0x000f, 0x0026 }, + { 0x000f, 0x0027 }, + { 0x000f, 0x0028 }, + { 0x000f, 0x0029 }, + { 0x000e, 0x0015 }, + { 0x000e, 0x0016 }, + { 0x000e, 0x0017 }, + { 0x000e, 0x0018 }, + { 0x000e, 0x0019 }, + { 0x000e, 0x001a }, + { 0x000e, 0x001b }, + }; + +const uint16_t c_aauiLCLDHuffEnc40[81][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000f, 0x0011 }, + { 0x0011, 0x0000 }, + { 0x0011, 0x0001 }, + { 0x0011, 0x0002 }, + { 0x0011, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x000e, 0x0009 }, + { 0x0011, 0x0004 }, + { 0x0011, 0x0005 }, + { 0x0011, 0x0006 }, + { 0x0011, 0x0007 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0005 }, + { 0x0011, 0x0008 }, + { 0x0011, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0011, 0x000b }, + { 0x0011, 0x000c }, + { 0x000b, 0x0003 }, + { 0x000a, 0x0003 }, + { 0x000c, 0x0003 }, + { 0x0011, 0x000d }, + { 0x0011, 0x000e }, + { 0x0011, 0x000f }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0011, 0x0012 }, + { 0x0011, 0x0013 }, + { 0x0011, 0x0014 }, + { 0x0011, 0x0015 }, + { 0x0011, 0x0016 }, + { 0x0011, 0x0017 }, + { 0x0011, 0x0018 }, + { 0x0011, 0x0019 }, + { 0x0011, 0x001a }, + { 0x0011, 0x001b }, + { 0x0011, 0x001c }, + { 0x0011, 0x001d }, + { 0x0011, 0x001e }, + { 0x0011, 0x001f }, + { 0x0011, 0x0020 }, + { 0x0011, 0x0021 }, + { 0x0011, 0x0022 }, + { 0x0011, 0x0023 }, + { 0x0011, 0x0024 }, + { 0x0011, 0x0025 }, + { 0x0011, 0x0026 }, + { 0x0011, 0x0027 }, + { 0x0011, 0x0028 }, + { 0x0011, 0x0029 }, + { 0x0011, 0x002a }, + { 0x0011, 0x002b }, + { 0x0011, 0x002c }, + { 0x0011, 0x002d }, + { 0x0011, 0x002e }, + { 0x0011, 0x002f }, + { 0x0011, 0x0030 }, + { 0x0011, 0x0031 }, + { 0x0011, 0x0032 }, + { 0x0011, 0x0033 }, + { 0x0011, 0x0034 }, + { 0x0011, 0x0035 }, + { 0x0011, 0x0036 }, + { 0x0011, 0x0037 }, + { 0x0011, 0x0038 }, + { 0x0011, 0x0039 }, + { 0x0011, 0x003a }, + { 0x0011, 0x003b }, + { 0x0010, 0x001e }, + { 0x0010, 0x001f }, + { 0x0010, 0x0020 }, + { 0x0010, 0x0021 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc41[100][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0011, 0x0014 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x0010, 0x000b }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x0011, 0x0015 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000d, 0x0003 }, + { 0x0010, 0x000c }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0010, 0x000d }, + { 0x000f, 0x0007 }, + { 0x0012, 0x0027 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc42[169][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000e, 0x0006 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000d, 0x0004 }, + { 0x0010, 0x0013 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000f, 0x000b }, + { 0x0011, 0x0025 }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0009, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000d, 0x0005 }, + { 0x0010, 0x0014 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0015 }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0012, 0x0045 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0012, 0x0046 }, + { 0x0012, 0x0047 }, + { 0x0012, 0x0048 }, + { 0x0012, 0x0049 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc43[196][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x0010, 0x0017 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x0010, 0x0018 }, + { 0x0012, 0x0050 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000d, 0x0004 }, + { 0x0011, 0x002a }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000c, 0x0005 }, + { 0x000f, 0x000d }, + { 0x0012, 0x0051 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0005 }, + { 0x000f, 0x000e }, + { 0x0011, 0x002b }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0011, 0x002c }, + { 0x000f, 0x000f }, + { 0x0010, 0x0019 }, + { 0x0012, 0x0052 }, + { 0x0012, 0x0053 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0011, 0x002d }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc44[289][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000f, 0x000a }, + { 0x0011, 0x0022 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000e, 0x0007 }, + { 0x0012, 0x003f }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0006, 0x0003 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000f, 0x000b }, + { 0x0012, 0x0040 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x0010, 0x0013 }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x0011, 0x0023 }, + { 0x0012, 0x0041 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0013, 0x007b }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x000f, 0x000c }, + { 0x000e, 0x0009 }, + { 0x000f, 0x000d }, + { 0x0011, 0x0024 }, + { 0x0012, 0x0042 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0013, 0x007c }, + { 0x0011, 0x0025 }, + { 0x0012, 0x0043 }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0013, 0x007d }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc45[324][2] = + { + { 0x0002, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0005 }, + { 0x0010, 0x0025 }, + { 0x0012, 0x0088 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x000b, 0x0004 }, + { 0x000f, 0x0014 }, + { 0x0011, 0x0048 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0005, 0x0005 }, + { 0x0004, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0007, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000d, 0x0007 }, + { 0x000f, 0x0015 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0007, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0005 }, + { 0x000b, 0x0005 }, + { 0x000d, 0x0008 }, + { 0x0010, 0x0026 }, + { 0x0012, 0x0089 }, + { 0x0012, 0x008a }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000d, 0x0009 }, + { 0x000f, 0x0016 }, + { 0x0011, 0x0049 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x000c, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x000d }, + { 0x0010, 0x0027 }, + { 0x0012, 0x008b }, + { 0x0012, 0x008c }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x000f, 0x0017 }, + { 0x000f, 0x0018 }, + { 0x000f, 0x0019 }, + { 0x0012, 0x008d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0012, 0x008e }, + { 0x0012, 0x008f }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc46[400][2] = + { + { 0x0002, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000d, 0x000a }, + { 0x000f, 0x0018 }, + { 0x0012, 0x00a6 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0004 }, + { 0x000a, 0x0006 }, + { 0x000c, 0x0008 }, + { 0x000e, 0x0011 }, + { 0x0012, 0x00a7 }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000d, 0x000b }, + { 0x000f, 0x0019 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0007, 0x0006 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0005 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x0009 }, + { 0x000e, 0x0012 }, + { 0x000f, 0x001a }, + { 0x0012, 0x00a8 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0009, 0x0007 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000c }, + { 0x000e, 0x0013 }, + { 0x0010, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x000b, 0x0009 }, + { 0x000a, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000d, 0x000d }, + { 0x000f, 0x001b }, + { 0x0010, 0x002d }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x000d, 0x000e }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000d, 0x000f }, + { 0x000f, 0x001c }, + { 0x000f, 0x001d }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x000f, 0x001e }, + { 0x000f, 0x001f }, + { 0x000f, 0x0020 }, + { 0x000f, 0x0021 }, + { 0x0010, 0x002e }, + { 0x0012, 0x00a9 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0012, 0x00aa }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0010, 0x002f }, + { 0x0013, 0x0062 }, + { 0x0011, 0x0057 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0012, 0x00ab }, + { 0x0012, 0x00ac }, + { 0x0012, 0x00ad }, + }; + +const uint16_t c_aauiLCLDHuffEnc47[576][2] = + { + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x000b }, + { 0x000d, 0x000d }, + { 0x0010, 0x0041 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000d, 0x000e }, + { 0x000f, 0x0025 }, + { 0x000f, 0x0026 }, + { 0x0012, 0x00f6 }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0005, 0x0006 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000f }, + { 0x000f, 0x0027 }, + { 0x0012, 0x00f7 }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0008 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000c }, + { 0x000e, 0x0017 }, + { 0x0010, 0x0042 }, + { 0x0012, 0x00f8 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0008, 0x0008 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0009 }, + { 0x000b, 0x0009 }, + { 0x000d, 0x0010 }, + { 0x000f, 0x0028 }, + { 0x000f, 0x0029 }, + { 0x0011, 0x007f }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x000a, 0x000a }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x000b }, + { 0x000b, 0x000a }, + { 0x000d, 0x0011 }, + { 0x000f, 0x002a }, + { 0x0010, 0x0043 }, + { 0x0012, 0x00f9 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000c, 0x000d }, + { 0x000d, 0x0012 }, + { 0x000e, 0x0018 }, + { 0x0010, 0x0044 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x000e, 0x0019 }, + { 0x000d, 0x0013 }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000f, 0x002b }, + { 0x0010, 0x0045 }, + { 0x0013, 0x0066 }, + { 0x0012, 0x00fa }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0010, 0x0046 }, + { 0x000f, 0x002c }, + { 0x000f, 0x002d }, + { 0x0010, 0x0047 }, + { 0x0011, 0x0080 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0010, 0x0048 }, + { 0x0010, 0x0049 }, + { 0x0011, 0x0081 }, + { 0x0013, 0x008b }, + { 0x0012, 0x00fb }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0012, 0x00fc }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0013, 0x014c }, + { 0x0013, 0x014d }, + { 0x0013, 0x014e }, + { 0x0013, 0x014f }, + { 0x0013, 0x0150 }, + { 0x0013, 0x0151 }, + { 0x0013, 0x0152 }, + { 0x0013, 0x0153 }, + { 0x0013, 0x0154 }, + { 0x0013, 0x0155 }, + { 0x0013, 0x0156 }, + { 0x0013, 0x0157 }, + { 0x0013, 0x0158 }, + { 0x0013, 0x0159 }, + { 0x0013, 0x015a }, + { 0x0013, 0x015b }, + { 0x0013, 0x015c }, + { 0x0013, 0x015d }, + { 0x0013, 0x015e }, + { 0x0013, 0x015f }, + { 0x0013, 0x0160 }, + { 0x0013, 0x0161 }, + { 0x0013, 0x0162 }, + { 0x0013, 0x0163 }, + { 0x0013, 0x0164 }, + { 0x0013, 0x0165 }, + { 0x0013, 0x0166 }, + { 0x0013, 0x0167 }, + { 0x0013, 0x0168 }, + { 0x0013, 0x0169 }, + { 0x0013, 0x016a }, + { 0x0013, 0x016b }, + { 0x0013, 0x016c }, + { 0x0013, 0x016d }, + { 0x0013, 0x016e }, + { 0x0013, 0x016f }, + { 0x0013, 0x0170 }, + { 0x0013, 0x0171 }, + { 0x0013, 0x0172 }, + { 0x0013, 0x0173 }, + { 0x0013, 0x0174 }, + { 0x0013, 0x0175 }, + { 0x0013, 0x0176 }, + { 0x0013, 0x0177 }, + { 0x0013, 0x0178 }, + { 0x0013, 0x0179 }, + { 0x0013, 0x017a }, + { 0x0013, 0x017b }, + { 0x0013, 0x017c }, + { 0x0013, 0x017d }, + { 0x0013, 0x017e }, + { 0x0013, 0x017f }, + { 0x0013, 0x0180 }, + { 0x0013, 0x0181 }, + { 0x0013, 0x0182 }, + { 0x0013, 0x0183 }, + { 0x0013, 0x0184 }, + { 0x0013, 0x0185 }, + { 0x0013, 0x0186 }, + { 0x0013, 0x0187 }, + { 0x0013, 0x0188 }, + { 0x0013, 0x0189 }, + { 0x0013, 0x018a }, + { 0x0013, 0x018b }, + { 0x0013, 0x018c }, + { 0x0013, 0x018d }, + { 0x0013, 0x018e }, + { 0x0013, 0x018f }, + { 0x0013, 0x0190 }, + { 0x0013, 0x0191 }, + { 0x0013, 0x0192 }, + { 0x0013, 0x0193 }, + { 0x0013, 0x0194 }, + { 0x0013, 0x0195 }, + { 0x0013, 0x0196 }, + { 0x0013, 0x0197 }, + { 0x0013, 0x0198 }, + { 0x0013, 0x0199 }, + { 0x0013, 0x019a }, + { 0x0013, 0x019b }, + { 0x0013, 0x019c }, + { 0x0013, 0x019d }, + { 0x0013, 0x019e }, + { 0x0013, 0x019f }, + { 0x0013, 0x01a0 }, + { 0x0013, 0x01a1 }, + { 0x0013, 0x01a2 }, + { 0x0013, 0x01a3 }, + { 0x0013, 0x01a4 }, + { 0x0013, 0x01a5 }, + { 0x0013, 0x01a6 }, + { 0x0013, 0x01a7 }, + { 0x0013, 0x01a8 }, + { 0x0013, 0x01a9 }, + { 0x0013, 0x01aa }, + { 0x0013, 0x01ab }, + { 0x0013, 0x01ac }, + { 0x0013, 0x01ad }, + { 0x0013, 0x01ae }, + { 0x0013, 0x01af }, + { 0x0013, 0x01b0 }, + { 0x0013, 0x01b1 }, + { 0x0013, 0x01b2 }, + { 0x0013, 0x01b3 }, + { 0x0013, 0x01b4 }, + { 0x0013, 0x01b5 }, + { 0x0013, 0x01b6 }, + { 0x0013, 0x01b7 }, + { 0x0013, 0x01b8 }, + { 0x0013, 0x01b9 }, + { 0x0013, 0x01ba }, + { 0x0013, 0x01bb }, + { 0x0013, 0x01bc }, + { 0x0013, 0x01bd }, + { 0x0013, 0x01be }, + { 0x0013, 0x01bf }, + { 0x0013, 0x01c0 }, + { 0x0013, 0x01c1 }, + { 0x0013, 0x01c2 }, + { 0x0013, 0x01c3 }, + { 0x0013, 0x01c4 }, + { 0x0013, 0x01c5 }, + { 0x0013, 0x01c6 }, + { 0x0013, 0x01c7 }, + { 0x0013, 0x01c8 }, + { 0x0013, 0x01c9 }, + { 0x0013, 0x01ca }, + { 0x0013, 0x01cb }, + { 0x0013, 0x01cc }, + { 0x0013, 0x01cd }, + { 0x0013, 0x01ce }, + { 0x0013, 0x01cf }, + { 0x0013, 0x01d0 }, + { 0x0013, 0x01d1 }, + { 0x0013, 0x01d2 }, + { 0x0013, 0x01d3 }, + { 0x0013, 0x01d4 }, + { 0x0013, 0x01d5 }, + { 0x0013, 0x01d6 }, + { 0x0013, 0x01d7 }, + { 0x0013, 0x01d8 }, + { 0x0013, 0x01d9 }, + { 0x0013, 0x01da }, + { 0x0013, 0x01db }, + { 0x0013, 0x01dc }, + { 0x0013, 0x01dd }, + { 0x0013, 0x01de }, + { 0x0013, 0x01df }, + { 0x0013, 0x01e0 }, + { 0x0013, 0x01e1 }, + { 0x0013, 0x01e2 }, + { 0x0013, 0x01e3 }, + { 0x0013, 0x01e4 }, + { 0x0013, 0x01e5 }, + { 0x0013, 0x01e6 }, + { 0x0013, 0x01e7 }, + { 0x0013, 0x01e8 }, + { 0x0013, 0x01e9 }, + { 0x0013, 0x01ea }, + { 0x0013, 0x01eb }, + { 0x0012, 0x00fd }, + }; + +const uint16_t c_aauiLCLDHuffEnc48[729][2] = + { + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0006 }, + { 0x0006, 0x0006 }, + { 0x0008, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x000b }, + { 0x000c, 0x000d }, + { 0x000f, 0x0030 }, + { 0x0010, 0x0055 }, + { 0x0012, 0x0136 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000e }, + { 0x000d, 0x0012 }, + { 0x000f, 0x0031 }, + { 0x0011, 0x00a0 }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0005, 0x0008 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0009 }, + { 0x0006, 0x0008 }, + { 0x0007, 0x0008 }, + { 0x0008, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000c, 0x000f }, + { 0x000d, 0x0013 }, + { 0x000f, 0x0032 }, + { 0x0011, 0x00a1 }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0007, 0x0009 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0008 }, + { 0x000b, 0x000c }, + { 0x000d, 0x0014 }, + { 0x000e, 0x001d }, + { 0x000f, 0x0033 }, + { 0x0012, 0x0137 }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0008, 0x000a }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x000b }, + { 0x0009, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000c, 0x0010 }, + { 0x000d, 0x0015 }, + { 0x000f, 0x0034 }, + { 0x0010, 0x0056 }, + { 0x0012, 0x0138 }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0009, 0x000a }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0009, 0x000b }, + { 0x000a, 0x000b }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0016 }, + { 0x000e, 0x001e }, + { 0x0010, 0x0057 }, + { 0x0011, 0x00a2 }, + { 0x0011, 0x00a3 }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x000b, 0x000d }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x000e }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0017 }, + { 0x000e, 0x001f }, + { 0x0010, 0x0058 }, + { 0x0012, 0x0139 }, + { 0x0011, 0x00a4 }, + { 0x0012, 0x013a }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x000c, 0x0013 }, + { 0x000b, 0x000f }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x0020 }, + { 0x000f, 0x0035 }, + { 0x0012, 0x013b }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x000e, 0x0021 }, + { 0x000d, 0x0019 }, + { 0x000e, 0x0022 }, + { 0x000e, 0x0023 }, + { 0x000f, 0x0036 }, + { 0x0010, 0x0059 }, + { 0x0011, 0x00a5 }, + { 0x0013, 0x0083 }, + { 0x0011, 0x00a6 }, + { 0x0012, 0x013c }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0010, 0x005a }, + { 0x000f, 0x0037 }, + { 0x000f, 0x0038 }, + { 0x000f, 0x0039 }, + { 0x0010, 0x005b }, + { 0x0010, 0x005c }, + { 0x0013, 0x0095 }, + { 0x0011, 0x00a7 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0010, 0x005d }, + { 0x0010, 0x005e }, + { 0x0013, 0x00a9 }, + { 0x0010, 0x005f }, + { 0x0013, 0x00aa }, + { 0x0012, 0x013d }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0011, 0x00a8 }, + { 0x0013, 0x00c1 }, + { 0x0011, 0x00a9 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0012, 0x013e }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0013, 0x014c }, + { 0x0013, 0x014d }, + { 0x0013, 0x014e }, + { 0x0013, 0x014f }, + { 0x0013, 0x0150 }, + { 0x0013, 0x0151 }, + { 0x0013, 0x0152 }, + { 0x0013, 0x0153 }, + { 0x0013, 0x0154 }, + { 0x0013, 0x0155 }, + { 0x0013, 0x0156 }, + { 0x0013, 0x0157 }, + { 0x0013, 0x0158 }, + { 0x0013, 0x0159 }, + { 0x0013, 0x015a }, + { 0x0013, 0x015b }, + { 0x0013, 0x015c }, + { 0x0013, 0x015d }, + { 0x0013, 0x015e }, + { 0x0013, 0x015f }, + { 0x0013, 0x0160 }, + { 0x0013, 0x0161 }, + { 0x0013, 0x0162 }, + { 0x0013, 0x0163 }, + { 0x0013, 0x0164 }, + { 0x0013, 0x0165 }, + { 0x0013, 0x0166 }, + { 0x0013, 0x0167 }, + { 0x0013, 0x0168 }, + { 0x0013, 0x0169 }, + { 0x0013, 0x016a }, + { 0x0013, 0x016b }, + { 0x0013, 0x016c }, + { 0x0013, 0x016d }, + { 0x0013, 0x016e }, + { 0x0013, 0x016f }, + { 0x0013, 0x0170 }, + { 0x0013, 0x0171 }, + { 0x0013, 0x0172 }, + { 0x0013, 0x0173 }, + { 0x0013, 0x0174 }, + { 0x0013, 0x0175 }, + { 0x0013, 0x0176 }, + { 0x0013, 0x0177 }, + { 0x0013, 0x0178 }, + { 0x0013, 0x0179 }, + { 0x0013, 0x017a }, + { 0x0013, 0x017b }, + { 0x0013, 0x017c }, + { 0x0013, 0x017d }, + { 0x0013, 0x017e }, + { 0x0013, 0x017f }, + { 0x0013, 0x0180 }, + { 0x0013, 0x0181 }, + { 0x0013, 0x0182 }, + { 0x0013, 0x0183 }, + { 0x0013, 0x0184 }, + { 0x0013, 0x0185 }, + { 0x0013, 0x0186 }, + { 0x0013, 0x0187 }, + { 0x0013, 0x0188 }, + { 0x0013, 0x0189 }, + { 0x0013, 0x018a }, + { 0x0013, 0x018b }, + { 0x0013, 0x018c }, + { 0x0013, 0x018d }, + { 0x0013, 0x018e }, + { 0x0013, 0x018f }, + { 0x0013, 0x0190 }, + { 0x0013, 0x0191 }, + { 0x0013, 0x0192 }, + { 0x0013, 0x0193 }, + { 0x0013, 0x0194 }, + { 0x0013, 0x0195 }, + { 0x0013, 0x0196 }, + { 0x0013, 0x0197 }, + { 0x0013, 0x0198 }, + { 0x0013, 0x0199 }, + { 0x0013, 0x019a }, + { 0x0013, 0x019b }, + { 0x0013, 0x019c }, + { 0x0013, 0x019d }, + { 0x0013, 0x019e }, + { 0x0013, 0x019f }, + { 0x0013, 0x01a0 }, + { 0x0013, 0x01a1 }, + { 0x0013, 0x01a2 }, + { 0x0013, 0x01a3 }, + { 0x0013, 0x01a4 }, + { 0x0013, 0x01a5 }, + { 0x0013, 0x01a6 }, + { 0x0013, 0x01a7 }, + { 0x0013, 0x01a8 }, + { 0x0013, 0x01a9 }, + { 0x0013, 0x01aa }, + { 0x0013, 0x01ab }, + { 0x0013, 0x01ac }, + { 0x0013, 0x01ad }, + { 0x0013, 0x01ae }, + { 0x0013, 0x01af }, + { 0x0013, 0x01b0 }, + { 0x0013, 0x01b1 }, + { 0x0013, 0x01b2 }, + { 0x0013, 0x01b3 }, + { 0x0013, 0x01b4 }, + { 0x0013, 0x01b5 }, + { 0x0013, 0x01b6 }, + { 0x0013, 0x01b7 }, + { 0x0013, 0x01b8 }, + { 0x0013, 0x01b9 }, + { 0x0013, 0x01ba }, + { 0x0013, 0x01bb }, + { 0x0013, 0x01bc }, + { 0x0013, 0x01bd }, + { 0x0013, 0x01be }, + { 0x0013, 0x01bf }, + { 0x0013, 0x01c0 }, + { 0x0013, 0x01c1 }, + { 0x0013, 0x01c2 }, + { 0x0013, 0x01c3 }, + { 0x0013, 0x01c4 }, + { 0x0013, 0x01c5 }, + { 0x0013, 0x01c6 }, + { 0x0013, 0x01c7 }, + { 0x0013, 0x01c8 }, + { 0x0013, 0x01c9 }, + { 0x0013, 0x01ca }, + { 0x0013, 0x01cb }, + { 0x0013, 0x01cc }, + { 0x0013, 0x01cd }, + { 0x0013, 0x01ce }, + { 0x0013, 0x01cf }, + { 0x0013, 0x01d0 }, + { 0x0013, 0x01d1 }, + { 0x0013, 0x01d2 }, + { 0x0013, 0x01d3 }, + { 0x0013, 0x01d4 }, + { 0x0013, 0x01d5 }, + { 0x0013, 0x01d6 }, + { 0x0013, 0x01d7 }, + { 0x0013, 0x01d8 }, + { 0x0013, 0x01d9 }, + { 0x0013, 0x01da }, + { 0x0013, 0x01db }, + { 0x0013, 0x01dc }, + { 0x0013, 0x01dd }, + { 0x0013, 0x01de }, + { 0x0013, 0x01df }, + { 0x0013, 0x01e0 }, + { 0x0013, 0x01e1 }, + { 0x0013, 0x01e2 }, + { 0x0013, 0x01e3 }, + { 0x0013, 0x01e4 }, + { 0x0013, 0x01e5 }, + { 0x0013, 0x01e6 }, + { 0x0013, 0x01e7 }, + { 0x0013, 0x01e8 }, + { 0x0013, 0x01e9 }, + { 0x0013, 0x01ea }, + { 0x0013, 0x01eb }, + { 0x0013, 0x01ec }, + { 0x0013, 0x01ed }, + { 0x0013, 0x01ee }, + { 0x0013, 0x01ef }, + { 0x0013, 0x01f0 }, + { 0x0013, 0x01f1 }, + { 0x0013, 0x01f2 }, + { 0x0013, 0x01f3 }, + { 0x0013, 0x01f4 }, + { 0x0013, 0x01f5 }, + { 0x0013, 0x01f6 }, + { 0x0013, 0x01f7 }, + { 0x0013, 0x01f8 }, + { 0x0013, 0x01f9 }, + { 0x0013, 0x01fa }, + { 0x0013, 0x01fb }, + { 0x0013, 0x01fc }, + { 0x0013, 0x01fd }, + { 0x0013, 0x01fe }, + { 0x0013, 0x01ff }, + { 0x0013, 0x0200 }, + { 0x0013, 0x0201 }, + { 0x0013, 0x0202 }, + { 0x0013, 0x0203 }, + { 0x0013, 0x0204 }, + { 0x0013, 0x0205 }, + { 0x0013, 0x0206 }, + { 0x0013, 0x0207 }, + { 0x0013, 0x0208 }, + { 0x0013, 0x0209 }, + { 0x0013, 0x020a }, + { 0x0013, 0x020b }, + { 0x0013, 0x020c }, + { 0x0013, 0x020d }, + { 0x0013, 0x020e }, + { 0x0013, 0x020f }, + { 0x0013, 0x0210 }, + { 0x0013, 0x0211 }, + { 0x0013, 0x0212 }, + { 0x0013, 0x0213 }, + { 0x0013, 0x0214 }, + { 0x0013, 0x0215 }, + { 0x0013, 0x0216 }, + { 0x0013, 0x0217 }, + { 0x0013, 0x0218 }, + { 0x0013, 0x0219 }, + { 0x0013, 0x021a }, + { 0x0013, 0x021b }, + { 0x0013, 0x021c }, + { 0x0013, 0x021d }, + { 0x0013, 0x021e }, + { 0x0013, 0x021f }, + { 0x0013, 0x0220 }, + { 0x0013, 0x0221 }, + { 0x0013, 0x0222 }, + { 0x0013, 0x0223 }, + { 0x0013, 0x0224 }, + { 0x0013, 0x0225 }, + { 0x0013, 0x0226 }, + { 0x0013, 0x0227 }, + { 0x0013, 0x0228 }, + { 0x0013, 0x0229 }, + { 0x0013, 0x022a }, + { 0x0013, 0x022b }, + { 0x0013, 0x022c }, + { 0x0013, 0x022d }, + { 0x0013, 0x022e }, + { 0x0013, 0x022f }, + { 0x0013, 0x0230 }, + { 0x0013, 0x0231 }, + { 0x0013, 0x0232 }, + { 0x0013, 0x0233 }, + { 0x0013, 0x0234 }, + { 0x0013, 0x0235 }, + { 0x0013, 0x0236 }, + { 0x0013, 0x0237 }, + { 0x0013, 0x0238 }, + { 0x0013, 0x0239 }, + { 0x0013, 0x023a }, + { 0x0013, 0x023b }, + { 0x0013, 0x023c }, + { 0x0013, 0x023d }, + { 0x0013, 0x023e }, + { 0x0013, 0x023f }, + { 0x0013, 0x0240 }, + { 0x0013, 0x0241 }, + { 0x0013, 0x0242 }, + { 0x0013, 0x0243 }, + { 0x0013, 0x0244 }, + { 0x0013, 0x0245 }, + { 0x0013, 0x0246 }, + { 0x0013, 0x0247 }, + { 0x0013, 0x0248 }, + { 0x0013, 0x0249 }, + { 0x0013, 0x024a }, + { 0x0013, 0x024b }, + { 0x0013, 0x024c }, + { 0x0013, 0x024d }, + { 0x0013, 0x024e }, + { 0x0013, 0x024f }, + { 0x0013, 0x0250 }, + { 0x0013, 0x0251 }, + { 0x0013, 0x0252 }, + { 0x0013, 0x0253 }, + { 0x0013, 0x0254 }, + { 0x0013, 0x0255 }, + { 0x0013, 0x0256 }, + { 0x0013, 0x0257 }, + { 0x0013, 0x0258 }, + { 0x0013, 0x0259 }, + { 0x0013, 0x025a }, + { 0x0013, 0x025b }, + { 0x0013, 0x025c }, + { 0x0013, 0x025d }, + { 0x0013, 0x025e }, + { 0x0013, 0x025f }, + { 0x0013, 0x0260 }, + { 0x0013, 0x0261 }, + { 0x0013, 0x0262 }, + { 0x0013, 0x0263 }, + { 0x0013, 0x0264 }, + { 0x0013, 0x0265 }, + { 0x0013, 0x0266 }, + { 0x0013, 0x0267 }, + { 0x0013, 0x0268 }, + { 0x0013, 0x0269 }, + { 0x0013, 0x026a }, + { 0x0013, 0x026b }, + { 0x0012, 0x013f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc49[729][2] = + { + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0007 }, + { 0x0007, 0x000a }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0009, 0x0009 }, + { 0x000b, 0x000d }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x0010, 0x0052 }, + { 0x0011, 0x0098 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0005, 0x0008 }, + { 0x0006, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x000a, 0x000a }, + { 0x000b, 0x000e }, + { 0x000d, 0x0016 }, + { 0x000f, 0x0031 }, + { 0x0010, 0x0053 }, + { 0x0012, 0x012a }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x000b }, + { 0x0007, 0x000c }, + { 0x0008, 0x000d }, + { 0x0009, 0x000a }, + { 0x000a, 0x000b }, + { 0x000c, 0x000f }, + { 0x000d, 0x0017 }, + { 0x000f, 0x0032 }, + { 0x0010, 0x0054 }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0007, 0x000d }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x000e }, + { 0x0009, 0x000b }, + { 0x000b, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000e, 0x001d }, + { 0x000f, 0x0033 }, + { 0x0011, 0x0099 }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0008, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0008, 0x0010 }, + { 0x0009, 0x000c }, + { 0x000a, 0x000c }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x001e }, + { 0x0011, 0x009a }, + { 0x0011, 0x009b }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0008, 0x0011 }, + { 0x0007, 0x0013 }, + { 0x0008, 0x0012 }, + { 0x0008, 0x0013 }, + { 0x0009, 0x000d }, + { 0x000a, 0x000d }, + { 0x000b, 0x0010 }, + { 0x000c, 0x0012 }, + { 0x000e, 0x001f }, + { 0x000e, 0x0020 }, + { 0x0010, 0x0055 }, + { 0x0011, 0x009c }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x000e }, + { 0x000b, 0x0011 }, + { 0x000c, 0x0013 }, + { 0x000d, 0x0019 }, + { 0x000e, 0x0021 }, + { 0x0010, 0x0056 }, + { 0x0010, 0x0057 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x000b, 0x0012 }, + { 0x000a, 0x000f }, + { 0x000a, 0x0010 }, + { 0x000a, 0x0011 }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x001a }, + { 0x000e, 0x0022 }, + { 0x0010, 0x0058 }, + { 0x0010, 0x0059 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x000c, 0x0016 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0017 }, + { 0x000c, 0x0018 }, + { 0x000c, 0x0019 }, + { 0x000e, 0x0023 }, + { 0x000e, 0x0024 }, + { 0x000f, 0x0034 }, + { 0x0010, 0x005a }, + { 0x0011, 0x009d }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x000e, 0x0025 }, + { 0x000d, 0x001b }, + { 0x000d, 0x001c }, + { 0x000d, 0x001d }, + { 0x000e, 0x0026 }, + { 0x000f, 0x0035 }, + { 0x0010, 0x005b }, + { 0x0011, 0x009e }, + { 0x0011, 0x009f }, + { 0x0012, 0x012b }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0010, 0x005c }, + { 0x000f, 0x0036 }, + { 0x000e, 0x0027 }, + { 0x000f, 0x0037 }, + { 0x000f, 0x0038 }, + { 0x0010, 0x005d }, + { 0x0011, 0x00a0 }, + { 0x0013, 0x009c }, + { 0x0012, 0x012c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0010, 0x005e }, + { 0x000f, 0x0039 }, + { 0x0010, 0x005f }, + { 0x0010, 0x0060 }, + { 0x0011, 0x00a1 }, + { 0x0010, 0x0061 }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0012, 0x012d }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0012, 0x012e }, + { 0x0011, 0x00a2 }, + { 0x0011, 0x00a3 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0012, 0x012f }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0013, 0x014c }, + { 0x0013, 0x014d }, + { 0x0013, 0x014e }, + { 0x0013, 0x014f }, + { 0x0013, 0x0150 }, + { 0x0013, 0x0151 }, + { 0x0013, 0x0152 }, + { 0x0013, 0x0153 }, + { 0x0013, 0x0154 }, + { 0x0013, 0x0155 }, + { 0x0013, 0x0156 }, + { 0x0013, 0x0157 }, + { 0x0013, 0x0158 }, + { 0x0013, 0x0159 }, + { 0x0013, 0x015a }, + { 0x0013, 0x015b }, + { 0x0013, 0x015c }, + { 0x0013, 0x015d }, + { 0x0013, 0x015e }, + { 0x0013, 0x015f }, + { 0x0013, 0x0160 }, + { 0x0013, 0x0161 }, + { 0x0013, 0x0162 }, + { 0x0013, 0x0163 }, + { 0x0013, 0x0164 }, + { 0x0013, 0x0165 }, + { 0x0013, 0x0166 }, + { 0x0013, 0x0167 }, + { 0x0013, 0x0168 }, + { 0x0013, 0x0169 }, + { 0x0013, 0x016a }, + { 0x0013, 0x016b }, + { 0x0013, 0x016c }, + { 0x0013, 0x016d }, + { 0x0013, 0x016e }, + { 0x0013, 0x016f }, + { 0x0013, 0x0170 }, + { 0x0013, 0x0171 }, + { 0x0013, 0x0172 }, + { 0x0013, 0x0173 }, + { 0x0013, 0x0174 }, + { 0x0013, 0x0175 }, + { 0x0013, 0x0176 }, + { 0x0013, 0x0177 }, + { 0x0013, 0x0178 }, + { 0x0013, 0x0179 }, + { 0x0013, 0x017a }, + { 0x0013, 0x017b }, + { 0x0013, 0x017c }, + { 0x0013, 0x017d }, + { 0x0013, 0x017e }, + { 0x0013, 0x017f }, + { 0x0013, 0x0180 }, + { 0x0013, 0x0181 }, + { 0x0013, 0x0182 }, + { 0x0013, 0x0183 }, + { 0x0013, 0x0184 }, + { 0x0013, 0x0185 }, + { 0x0013, 0x0186 }, + { 0x0013, 0x0187 }, + { 0x0013, 0x0188 }, + { 0x0013, 0x0189 }, + { 0x0013, 0x018a }, + { 0x0013, 0x018b }, + { 0x0013, 0x018c }, + { 0x0013, 0x018d }, + { 0x0013, 0x018e }, + { 0x0013, 0x018f }, + { 0x0013, 0x0190 }, + { 0x0013, 0x0191 }, + { 0x0013, 0x0192 }, + { 0x0013, 0x0193 }, + { 0x0013, 0x0194 }, + { 0x0013, 0x0195 }, + { 0x0013, 0x0196 }, + { 0x0013, 0x0197 }, + { 0x0013, 0x0198 }, + { 0x0013, 0x0199 }, + { 0x0013, 0x019a }, + { 0x0013, 0x019b }, + { 0x0013, 0x019c }, + { 0x0013, 0x019d }, + { 0x0013, 0x019e }, + { 0x0013, 0x019f }, + { 0x0013, 0x01a0 }, + { 0x0013, 0x01a1 }, + { 0x0013, 0x01a2 }, + { 0x0013, 0x01a3 }, + { 0x0013, 0x01a4 }, + { 0x0013, 0x01a5 }, + { 0x0013, 0x01a6 }, + { 0x0013, 0x01a7 }, + { 0x0013, 0x01a8 }, + { 0x0013, 0x01a9 }, + { 0x0013, 0x01aa }, + { 0x0013, 0x01ab }, + { 0x0013, 0x01ac }, + { 0x0013, 0x01ad }, + { 0x0013, 0x01ae }, + { 0x0013, 0x01af }, + { 0x0013, 0x01b0 }, + { 0x0013, 0x01b1 }, + { 0x0013, 0x01b2 }, + { 0x0013, 0x01b3 }, + { 0x0013, 0x01b4 }, + { 0x0013, 0x01b5 }, + { 0x0013, 0x01b6 }, + { 0x0013, 0x01b7 }, + { 0x0013, 0x01b8 }, + { 0x0013, 0x01b9 }, + { 0x0013, 0x01ba }, + { 0x0013, 0x01bb }, + { 0x0013, 0x01bc }, + { 0x0013, 0x01bd }, + { 0x0013, 0x01be }, + { 0x0013, 0x01bf }, + { 0x0013, 0x01c0 }, + { 0x0013, 0x01c1 }, + { 0x0013, 0x01c2 }, + { 0x0013, 0x01c3 }, + { 0x0013, 0x01c4 }, + { 0x0013, 0x01c5 }, + { 0x0013, 0x01c6 }, + { 0x0013, 0x01c7 }, + { 0x0013, 0x01c8 }, + { 0x0013, 0x01c9 }, + { 0x0013, 0x01ca }, + { 0x0013, 0x01cb }, + { 0x0013, 0x01cc }, + { 0x0013, 0x01cd }, + { 0x0013, 0x01ce }, + { 0x0013, 0x01cf }, + { 0x0013, 0x01d0 }, + { 0x0013, 0x01d1 }, + { 0x0013, 0x01d2 }, + { 0x0013, 0x01d3 }, + { 0x0013, 0x01d4 }, + { 0x0013, 0x01d5 }, + { 0x0013, 0x01d6 }, + { 0x0013, 0x01d7 }, + { 0x0013, 0x01d8 }, + { 0x0013, 0x01d9 }, + { 0x0013, 0x01da }, + { 0x0013, 0x01db }, + { 0x0013, 0x01dc }, + { 0x0013, 0x01dd }, + { 0x0013, 0x01de }, + { 0x0013, 0x01df }, + { 0x0013, 0x01e0 }, + { 0x0013, 0x01e1 }, + { 0x0013, 0x01e2 }, + { 0x0013, 0x01e3 }, + { 0x0013, 0x01e4 }, + { 0x0013, 0x01e5 }, + { 0x0013, 0x01e6 }, + { 0x0013, 0x01e7 }, + { 0x0013, 0x01e8 }, + { 0x0013, 0x01e9 }, + { 0x0013, 0x01ea }, + { 0x0013, 0x01eb }, + { 0x0013, 0x01ec }, + { 0x0013, 0x01ed }, + { 0x0013, 0x01ee }, + { 0x0013, 0x01ef }, + { 0x0013, 0x01f0 }, + { 0x0013, 0x01f1 }, + { 0x0013, 0x01f2 }, + { 0x0013, 0x01f3 }, + { 0x0013, 0x01f4 }, + { 0x0013, 0x01f5 }, + { 0x0013, 0x01f6 }, + { 0x0013, 0x01f7 }, + { 0x0013, 0x01f8 }, + { 0x0013, 0x01f9 }, + { 0x0013, 0x01fa }, + { 0x0013, 0x01fb }, + { 0x0013, 0x01fc }, + { 0x0013, 0x01fd }, + { 0x0013, 0x01fe }, + { 0x0013, 0x01ff }, + { 0x0013, 0x0200 }, + { 0x0013, 0x0201 }, + { 0x0013, 0x0202 }, + { 0x0013, 0x0203 }, + { 0x0013, 0x0204 }, + { 0x0013, 0x0205 }, + { 0x0013, 0x0206 }, + { 0x0013, 0x0207 }, + { 0x0013, 0x0208 }, + { 0x0013, 0x0209 }, + { 0x0013, 0x020a }, + { 0x0013, 0x020b }, + { 0x0013, 0x020c }, + { 0x0013, 0x020d }, + { 0x0013, 0x020e }, + { 0x0013, 0x020f }, + { 0x0013, 0x0210 }, + { 0x0013, 0x0211 }, + { 0x0013, 0x0212 }, + { 0x0013, 0x0213 }, + { 0x0013, 0x0214 }, + { 0x0013, 0x0215 }, + { 0x0013, 0x0216 }, + { 0x0013, 0x0217 }, + { 0x0013, 0x0218 }, + { 0x0013, 0x0219 }, + { 0x0013, 0x021a }, + { 0x0013, 0x021b }, + { 0x0013, 0x021c }, + { 0x0013, 0x021d }, + { 0x0013, 0x021e }, + { 0x0013, 0x021f }, + { 0x0013, 0x0220 }, + { 0x0013, 0x0221 }, + { 0x0013, 0x0222 }, + { 0x0013, 0x0223 }, + { 0x0013, 0x0224 }, + { 0x0013, 0x0225 }, + { 0x0013, 0x0226 }, + { 0x0013, 0x0227 }, + { 0x0013, 0x0228 }, + { 0x0013, 0x0229 }, + { 0x0013, 0x022a }, + { 0x0013, 0x022b }, + { 0x0013, 0x022c }, + { 0x0013, 0x022d }, + { 0x0013, 0x022e }, + { 0x0013, 0x022f }, + { 0x0013, 0x0230 }, + { 0x0013, 0x0231 }, + { 0x0013, 0x0232 }, + { 0x0013, 0x0233 }, + { 0x0013, 0x0234 }, + { 0x0013, 0x0235 }, + { 0x0013, 0x0236 }, + { 0x0013, 0x0237 }, + { 0x0013, 0x0238 }, + { 0x0013, 0x0239 }, + { 0x0013, 0x023a }, + { 0x0013, 0x023b }, + { 0x0013, 0x023c }, + { 0x0013, 0x023d }, + { 0x0013, 0x023e }, + { 0x0013, 0x023f }, + { 0x0013, 0x0240 }, + { 0x0013, 0x0241 }, + { 0x0013, 0x0242 }, + { 0x0013, 0x0243 }, + { 0x0013, 0x0244 }, + { 0x0013, 0x0245 }, + { 0x0013, 0x0246 }, + { 0x0013, 0x0247 }, + { 0x0013, 0x0248 }, + { 0x0013, 0x0249 }, + { 0x0013, 0x024a }, + { 0x0013, 0x024b }, + { 0x0013, 0x024c }, + { 0x0013, 0x024d }, + { 0x0013, 0x024e }, + { 0x0013, 0x024f }, + { 0x0013, 0x0250 }, + { 0x0013, 0x0251 }, + { 0x0013, 0x0252 }, + { 0x0013, 0x0253 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc50[28][2] = + { + { 0x0002, 0x0001 }, + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0005, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc51[29][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0001 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc52[32][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0001 }, + { 0x0011, 0x0002 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0003 }, + { 0x0014, 0x0000 }, + { 0x0013, 0x0003 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + }; + +const uint16_t c_aauiLCLDHuffEnc53[37][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0011, 0x0004 }, + { 0x0010, 0x0003 }, + { 0x0011, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc54[39][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0011, 0x0002 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc55[46][2] = + { + { 0x0003, 0x0003 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0003 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc56[55][2] = + { + { 0x0003, 0x0003 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0000 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0005 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc57[65][2] = + { + { 0x0003, 0x0004 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000d, 0x0003 }, + { 0x000c, 0x0005 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0011, 0x0005 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0012, 0x0007 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc58[77][2] = + { + { 0x0004, 0x0005 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x0010, 0x0004 }, + { 0x000f, 0x0007 }, + { 0x0010, 0x0005 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0012, 0x0006 }, + { 0x0011, 0x0007 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0012, 0x0007 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc59[91][2] = + { + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0011, 0x0008 }, + { 0x0011, 0x0009 }, + { 0x0013, 0x0000 }, + { 0x0011, 0x000a }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0011, 0x000b }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0012, 0x000f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc60[109][2] = + { + { 0x0004, 0x0007 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x000f, 0x0005 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0006 }, + { 0x0010, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x000f, 0x0008 }, + { 0x000f, 0x0009 }, + { 0x0010, 0x0007 }, + { 0x0010, 0x0008 }, + { 0x0010, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0013, 0x0000 }, + { 0x0011, 0x000b }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0012, 0x0013 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc61[129][2] = + { + { 0x0004, 0x0008 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000e, 0x0008 }, + { 0x000d, 0x000b }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x0010, 0x000c }, + { 0x0011, 0x0015 }, + { 0x0010, 0x000d }, + { 0x000f, 0x000f }, + { 0x0010, 0x000e }, + { 0x0010, 0x000f }, + { 0x0012, 0x0000 }, + { 0x0011, 0x0016 }, + { 0x0010, 0x0010 }, + { 0x0010, 0x0011 }, + { 0x0011, 0x0017 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0012, 0x0010 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + { 0x0012, 0x0014 }, + { 0x0012, 0x0015 }, + { 0x0012, 0x0016 }, + { 0x0012, 0x0017 }, + { 0x0012, 0x0018 }, + { 0x0012, 0x0019 }, + { 0x0012, 0x001a }, + { 0x0012, 0x001b }, + { 0x0012, 0x001c }, + { 0x0012, 0x001d }, + { 0x0012, 0x001e }, + { 0x0012, 0x001f }, + { 0x0012, 0x0020 }, + { 0x0012, 0x0021 }, + { 0x0012, 0x0022 }, + { 0x0012, 0x0023 }, + { 0x0012, 0x0024 }, + { 0x0012, 0x0025 }, + { 0x0012, 0x0026 }, + { 0x0012, 0x0027 }, + { 0x0012, 0x0028 }, + { 0x0012, 0x0029 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc62[153][2] = + { + { 0x0004, 0x0009 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000d, 0x0007 }, + { 0x000c, 0x000d }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000e, 0x0008 }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000f, 0x000c }, + { 0x000e, 0x000d }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x000f, 0x000f }, + { 0x0010, 0x000f }, + { 0x0010, 0x0010 }, + { 0x0011, 0x0019 }, + { 0x0010, 0x0011 }, + { 0x0010, 0x0012 }, + { 0x0010, 0x0013 }, + { 0x0010, 0x0014 }, + { 0x0010, 0x0015 }, + { 0x0012, 0x0000 }, + { 0x0010, 0x0016 }, + { 0x0011, 0x001a }, + { 0x0010, 0x0017 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0011, 0x001b }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0012, 0x0010 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + { 0x0012, 0x0014 }, + { 0x0012, 0x0015 }, + { 0x0012, 0x0016 }, + { 0x0012, 0x0017 }, + { 0x0012, 0x0018 }, + { 0x0011, 0x001c }, + { 0x0012, 0x0019 }, + { 0x0012, 0x001a }, + { 0x0012, 0x001b }, + { 0x0012, 0x001c }, + { 0x0012, 0x001d }, + { 0x0012, 0x001e }, + { 0x0012, 0x001f }, + { 0x0012, 0x0020 }, + { 0x0012, 0x0021 }, + { 0x0012, 0x0022 }, + { 0x0012, 0x0023 }, + { 0x0012, 0x0024 }, + { 0x0012, 0x0025 }, + { 0x0012, 0x0026 }, + { 0x0012, 0x0027 }, + { 0x0012, 0x0028 }, + { 0x0012, 0x0029 }, + { 0x0012, 0x002a }, + { 0x0012, 0x002b }, + { 0x0012, 0x002c }, + { 0x0012, 0x002d }, + { 0x0012, 0x002e }, + { 0x0012, 0x002f }, + { 0x0012, 0x0030 }, + { 0x0012, 0x0031 }, + { 0x0011, 0x001d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc63[181][2] = + { + { 0x0004, 0x0008 }, + { 0x0003, 0x0005 }, + { 0x0002, 0x0003 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0007, 0x0015 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0008, 0x0012 }, + { 0x0008, 0x0013 }, + { 0x0008, 0x0014 }, + { 0x0008, 0x0015 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x0009, 0x0012 }, + { 0x0009, 0x0013 }, + { 0x0009, 0x0014 }, + { 0x0009, 0x0015 }, + { 0x000a, 0x0007 }, + { 0x0009, 0x0016 }, + { 0x0009, 0x0017 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000a, 0x000e }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000a, 0x000f }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000c, 0x000d }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000d, 0x0010 }, + { 0x000d, 0x0011 }, + { 0x000e, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000e, 0x000d }, + { 0x000e, 0x000e }, + { 0x000e, 0x000f }, + { 0x000f, 0x0008 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x0010, 0x0009 }, + { 0x0010, 0x000a }, + { 0x000f, 0x000d }, + { 0x0010, 0x000b }, + { 0x0010, 0x000c }, + { 0x0010, 0x000d }, + { 0x0011, 0x000e }, + { 0x0011, 0x000f }, + { 0x0010, 0x000e }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0012, 0x0014 }, + { 0x0014, 0x0000 }, + { 0x0010, 0x000f }, + { 0x0012, 0x0015 }, + { 0x0012, 0x0016 }, + { 0x0014, 0x0001 }, + { 0x0012, 0x0017 }, + { 0x0012, 0x0018 }, + { 0x0012, 0x0019 }, + { 0x0013, 0x0010 }, + { 0x0012, 0x001a }, + { 0x0014, 0x0002 }, + { 0x0012, 0x001b }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0013, 0x0011 }, + { 0x0014, 0x0006 }, + { 0x0013, 0x0012 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0013, 0x0013 }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + + }; + +const uint16_t ( *c_apauiHuffEncTabels[2 * ALLOC_TABLE_SIZE] )[2] = + { + NULL, + c_aauiLCLDHuffEnc1, + c_aauiLCLDHuffEnc2, + c_aauiLCLDHuffEnc3, + c_aauiLCLDHuffEnc4, + c_aauiLCLDHuffEnc5, + c_aauiLCLDHuffEnc6, + c_aauiLCLDHuffEnc7, + c_aauiLCLDHuffEnc8, + c_aauiLCLDHuffEnc9, + c_aauiLCLDHuffEnc10, + c_aauiLCLDHuffEnc11, + c_aauiLCLDHuffEnc12, + c_aauiLCLDHuffEnc13, + c_aauiLCLDHuffEnc14, + c_aauiLCLDHuffEnc15, + c_aauiLCLDHuffEnc16, + c_aauiLCLDHuffEnc17, + c_aauiLCLDHuffEnc18, + c_aauiLCLDHuffEnc19, + c_aauiLCLDHuffEnc20, + c_aauiLCLDHuffEnc21, + c_aauiLCLDHuffEnc22, + c_aauiLCLDHuffEnc23, + c_aauiLCLDHuffEnc24, + c_aauiLCLDHuffEnc25, + c_aauiLCLDHuffEnc26, + c_aauiLCLDHuffEnc27, + c_aauiLCLDHuffEnc28, + c_aauiLCLDHuffEnc29, + c_aauiLCLDHuffEnc30, + c_aauiLCLDHuffEnc31, + NULL, + c_aauiLCLDHuffEnc33, + c_aauiLCLDHuffEnc34, + c_aauiLCLDHuffEnc35, + c_aauiLCLDHuffEnc36, + c_aauiLCLDHuffEnc37, + c_aauiLCLDHuffEnc38, + c_aauiLCLDHuffEnc39, + c_aauiLCLDHuffEnc40, + c_aauiLCLDHuffEnc41, + c_aauiLCLDHuffEnc42, + c_aauiLCLDHuffEnc43, + c_aauiLCLDHuffEnc44, + c_aauiLCLDHuffEnc45, + c_aauiLCLDHuffEnc46, + c_aauiLCLDHuffEnc47, + c_aauiLCLDHuffEnc48, + c_aauiLCLDHuffEnc49, + c_aauiLCLDHuffEnc50, + c_aauiLCLDHuffEnc51, + c_aauiLCLDHuffEnc52, + c_aauiLCLDHuffEnc53, + c_aauiLCLDHuffEnc54, + c_aauiLCLDHuffEnc55, + c_aauiLCLDHuffEnc56, + c_aauiLCLDHuffEnc57, + c_aauiLCLDHuffEnc58, + c_aauiLCLDHuffEnc59, + c_aauiLCLDHuffEnc60, + c_aauiLCLDHuffEnc61, + c_aauiLCLDHuffEnc62, + c_aauiLCLDHuffEnc63, + }; + +const uint32_t num_row_aauiLCLDHuff[2 * ALLOC_TABLE_SIZE] = { 0, 16, 16, 25, 36, 36, 49, 64, 81, 100, + 169, 196, 289, 324, 400, 576, 729, 729, 28, 29, + 32, 37, 39, 46, 55, 65, 77, 91, 109, 129, + 153, 181, 0, 16, 16, 25, 36, 36, 49, 64, 81, + 100, 169, 196, 289, 324, 400, 576, 729, 729, 28, + 29, 32, 37, 39, 46, 55, 65, 77, 91, 109, + 129, 153, 181 }; +#ifdef USE_DEMOD_TABLES +const int32_t c_aaiHuffDemod1[16][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, +}; + +const int32_t c_aaiHuffDemod2[16][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, +}; + +const int32_t c_aaiHuffDemod3[25][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, +}; + +const int32_t c_aaiHuffDemod4[36][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, +}; + +const int32_t c_aaiHuffDemod5[36][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, +}; + +const int32_t c_aaiHuffDemod6[49][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, +}; + +const int32_t c_aaiHuffDemod7[64][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, +}; + +const int32_t c_aaiHuffDemod8[81][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, +}; + +const int32_t c_aaiHuffDemod9[100][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, +}; + +const int32_t c_aaiHuffDemod10[169][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, +}; + +const int32_t c_aaiHuffDemod11[196][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, +}; + +const int32_t c_aaiHuffDemod12[289][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 0, + 14, + 0, + 15, + 0, + 16, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 1, + 14, + 1, + 15, + 1, + 16, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 2, + 14, + 2, + 15, + 2, + 16, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 3, + 14, + 3, + 15, + 3, + 16, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 4, + 14, + 4, + 15, + 4, + 16, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 5, + 14, + 5, + 15, + 5, + 16, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 6, + 14, + 6, + 15, + 6, + 16, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 7, + 14, + 7, + 15, + 7, + 16, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 8, + 14, + 8, + 15, + 8, + 16, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 9, + 14, + 9, + 15, + 9, + 16, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 10, + 14, + 10, + 15, + 10, + 16, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 11, + 14, + 11, + 15, + 11, + 16, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 12, + 14, + 12, + 15, + 12, + 16, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, + 13, + 14, + 13, + 15, + 13, + 16, + 14, + 0, + 14, + 1, + 14, + 2, + 14, + 3, + 14, + 4, + 14, + 5, + 14, + 6, + 14, + 7, + 14, + 8, + 14, + 9, + 14, + 10, + 14, + 11, + 14, + 12, + 14, + 13, + 14, + 14, + 14, + 15, + 14, + 16, + 15, + 0, + 15, + 1, + 15, + 2, + 15, + 3, + 15, + 4, + 15, + 5, + 15, + 6, + 15, + 7, + 15, + 8, + 15, + 9, + 15, + 10, + 15, + 11, + 15, + 12, + 15, + 13, + 15, + 14, + 15, + 15, + 15, + 16, + 16, + 0, + 16, + 1, + 16, + 2, + 16, + 3, + 16, + 4, + 16, + 5, + 16, + 6, + 16, + 7, + 16, + 8, + 16, + 9, + 16, + 10, + 16, + 11, + 16, + 12, + 16, + 13, + 16, + 14, + 16, + 15, + 16, + 16, +}; + +const int32_t c_aaiHuffDemod13[324][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 0, + 14, + 0, + 15, + 0, + 16, + 0, + 17, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 1, + 14, + 1, + 15, + 1, + 16, + 1, + 17, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 2, + 14, + 2, + 15, + 2, + 16, + 2, + 17, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 3, + 14, + 3, + 15, + 3, + 16, + 3, + 17, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 4, + 14, + 4, + 15, + 4, + 16, + 4, + 17, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 5, + 14, + 5, + 15, + 5, + 16, + 5, + 17, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 6, + 14, + 6, + 15, + 6, + 16, + 6, + 17, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 7, + 14, + 7, + 15, + 7, + 16, + 7, + 17, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 8, + 14, + 8, + 15, + 8, + 16, + 8, + 17, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 9, + 14, + 9, + 15, + 9, + 16, + 9, + 17, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 10, + 14, + 10, + 15, + 10, + 16, + 10, + 17, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 11, + 14, + 11, + 15, + 11, + 16, + 11, + 17, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 12, + 14, + 12, + 15, + 12, + 16, + 12, + 17, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, + 13, + 14, + 13, + 15, + 13, + 16, + 13, + 17, + 14, + 0, + 14, + 1, + 14, + 2, + 14, + 3, + 14, + 4, + 14, + 5, + 14, + 6, + 14, + 7, + 14, + 8, + 14, + 9, + 14, + 10, + 14, + 11, + 14, + 12, + 14, + 13, + 14, + 14, + 14, + 15, + 14, + 16, + 14, + 17, + 15, + 0, + 15, + 1, + 15, + 2, + 15, + 3, + 15, + 4, + 15, + 5, + 15, + 6, + 15, + 7, + 15, + 8, + 15, + 9, + 15, + 10, + 15, + 11, + 15, + 12, + 15, + 13, + 15, + 14, + 15, + 15, + 15, + 16, + 15, + 17, + 16, + 0, + 16, + 1, + 16, + 2, + 16, + 3, + 16, + 4, + 16, + 5, + 16, + 6, + 16, + 7, + 16, + 8, + 16, + 9, + 16, + 10, + 16, + 11, + 16, + 12, + 16, + 13, + 16, + 14, + 16, + 15, + 16, + 16, + 16, + 17, + 17, + 0, + 17, + 1, + 17, + 2, + 17, + 3, + 17, + 4, + 17, + 5, + 17, + 6, + 17, + 7, + 17, + 8, + 17, + 9, + 17, + 10, + 17, + 11, + 17, + 12, + 17, + 13, + 17, + 14, + 17, + 15, + 17, + 16, + 17, + 17, +}; + +const int32_t c_aaiHuffDemod14[400][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 0, + 14, + 0, + 15, + 0, + 16, + 0, + 17, + 0, + 18, + 0, + 19, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 1, + 14, + 1, + 15, + 1, + 16, + 1, + 17, + 1, + 18, + 1, + 19, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 2, + 14, + 2, + 15, + 2, + 16, + 2, + 17, + 2, + 18, + 2, + 19, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 3, + 14, + 3, + 15, + 3, + 16, + 3, + 17, + 3, + 18, + 3, + 19, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 4, + 14, + 4, + 15, + 4, + 16, + 4, + 17, + 4, + 18, + 4, + 19, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 5, + 14, + 5, + 15, + 5, + 16, + 5, + 17, + 5, + 18, + 5, + 19, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 6, + 14, + 6, + 15, + 6, + 16, + 6, + 17, + 6, + 18, + 6, + 19, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 7, + 14, + 7, + 15, + 7, + 16, + 7, + 17, + 7, + 18, + 7, + 19, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 8, + 14, + 8, + 15, + 8, + 16, + 8, + 17, + 8, + 18, + 8, + 19, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 9, + 14, + 9, + 15, + 9, + 16, + 9, + 17, + 9, + 18, + 9, + 19, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 10, + 14, + 10, + 15, + 10, + 16, + 10, + 17, + 10, + 18, + 10, + 19, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 11, + 14, + 11, + 15, + 11, + 16, + 11, + 17, + 11, + 18, + 11, + 19, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 12, + 14, + 12, + 15, + 12, + 16, + 12, + 17, + 12, + 18, + 12, + 19, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, + 13, + 14, + 13, + 15, + 13, + 16, + 13, + 17, + 13, + 18, + 13, + 19, + 14, + 0, + 14, + 1, + 14, + 2, + 14, + 3, + 14, + 4, + 14, + 5, + 14, + 6, + 14, + 7, + 14, + 8, + 14, + 9, + 14, + 10, + 14, + 11, + 14, + 12, + 14, + 13, + 14, + 14, + 14, + 15, + 14, + 16, + 14, + 17, + 14, + 18, + 14, + 19, + 15, + 0, + 15, + 1, + 15, + 2, + 15, + 3, + 15, + 4, + 15, + 5, + 15, + 6, + 15, + 7, + 15, + 8, + 15, + 9, + 15, + 10, + 15, + 11, + 15, + 12, + 15, + 13, + 15, + 14, + 15, + 15, + 15, + 16, + 15, + 17, + 15, + 18, + 15, + 19, + 16, + 0, + 16, + 1, + 16, + 2, + 16, + 3, + 16, + 4, + 16, + 5, + 16, + 6, + 16, + 7, + 16, + 8, + 16, + 9, + 16, + 10, + 16, + 11, + 16, + 12, + 16, + 13, + 16, + 14, + 16, + 15, + 16, + 16, + 16, + 17, + 16, + 18, + 16, + 19, + 17, + 0, + 17, + 1, + 17, + 2, + 17, + 3, + 17, + 4, + 17, + 5, + 17, + 6, + 17, + 7, + 17, + 8, + 17, + 9, + 17, + 10, + 17, + 11, + 17, + 12, + 17, + 13, + 17, + 14, + 17, + 15, + 17, + 16, + 17, + 17, + 17, + 18, + 17, + 19, + 18, + 0, + 18, + 1, + 18, + 2, + 18, + 3, + 18, + 4, + 18, + 5, + 18, + 6, + 18, + 7, + 18, + 8, + 18, + 9, + 18, + 10, + 18, + 11, + 18, + 12, + 18, + 13, + 18, + 14, + 18, + 15, + 18, + 16, + 18, + 17, + 18, + 18, + 18, + 19, + 19, + 0, + 19, + 1, + 19, + 2, + 19, + 3, + 19, + 4, + 19, + 5, + 19, + 6, + 19, + 7, + 19, + 8, + 19, + 9, + 19, + 10, + 19, + 11, + 19, + 12, + 19, + 13, + 19, + 14, + 19, + 15, + 19, + 16, + 19, + 17, + 19, + 18, + 19, + 19, +}; + +const int32_t c_aaiHuffDemod15[576][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 0, + 14, + 0, + 15, + 0, + 16, + 0, + 17, + 0, + 18, + 0, + 19, + 0, + 20, + 0, + 21, + 0, + 22, + 0, + 23, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 1, + 14, + 1, + 15, + 1, + 16, + 1, + 17, + 1, + 18, + 1, + 19, + 1, + 20, + 1, + 21, + 1, + 22, + 1, + 23, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 2, + 14, + 2, + 15, + 2, + 16, + 2, + 17, + 2, + 18, + 2, + 19, + 2, + 20, + 2, + 21, + 2, + 22, + 2, + 23, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 3, + 14, + 3, + 15, + 3, + 16, + 3, + 17, + 3, + 18, + 3, + 19, + 3, + 20, + 3, + 21, + 3, + 22, + 3, + 23, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 4, + 14, + 4, + 15, + 4, + 16, + 4, + 17, + 4, + 18, + 4, + 19, + 4, + 20, + 4, + 21, + 4, + 22, + 4, + 23, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 5, + 14, + 5, + 15, + 5, + 16, + 5, + 17, + 5, + 18, + 5, + 19, + 5, + 20, + 5, + 21, + 5, + 22, + 5, + 23, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 6, + 14, + 6, + 15, + 6, + 16, + 6, + 17, + 6, + 18, + 6, + 19, + 6, + 20, + 6, + 21, + 6, + 22, + 6, + 23, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 7, + 14, + 7, + 15, + 7, + 16, + 7, + 17, + 7, + 18, + 7, + 19, + 7, + 20, + 7, + 21, + 7, + 22, + 7, + 23, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 8, + 14, + 8, + 15, + 8, + 16, + 8, + 17, + 8, + 18, + 8, + 19, + 8, + 20, + 8, + 21, + 8, + 22, + 8, + 23, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 9, + 14, + 9, + 15, + 9, + 16, + 9, + 17, + 9, + 18, + 9, + 19, + 9, + 20, + 9, + 21, + 9, + 22, + 9, + 23, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 10, + 14, + 10, + 15, + 10, + 16, + 10, + 17, + 10, + 18, + 10, + 19, + 10, + 20, + 10, + 21, + 10, + 22, + 10, + 23, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 11, + 14, + 11, + 15, + 11, + 16, + 11, + 17, + 11, + 18, + 11, + 19, + 11, + 20, + 11, + 21, + 11, + 22, + 11, + 23, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 12, + 14, + 12, + 15, + 12, + 16, + 12, + 17, + 12, + 18, + 12, + 19, + 12, + 20, + 12, + 21, + 12, + 22, + 12, + 23, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, + 13, + 14, + 13, + 15, + 13, + 16, + 13, + 17, + 13, + 18, + 13, + 19, + 13, + 20, + 13, + 21, + 13, + 22, + 13, + 23, + 14, + 0, + 14, + 1, + 14, + 2, + 14, + 3, + 14, + 4, + 14, + 5, + 14, + 6, + 14, + 7, + 14, + 8, + 14, + 9, + 14, + 10, + 14, + 11, + 14, + 12, + 14, + 13, + 14, + 14, + 14, + 15, + 14, + 16, + 14, + 17, + 14, + 18, + 14, + 19, + 14, + 20, + 14, + 21, + 14, + 22, + 14, + 23, + 15, + 0, + 15, + 1, + 15, + 2, + 15, + 3, + 15, + 4, + 15, + 5, + 15, + 6, + 15, + 7, + 15, + 8, + 15, + 9, + 15, + 10, + 15, + 11, + 15, + 12, + 15, + 13, + 15, + 14, + 15, + 15, + 15, + 16, + 15, + 17, + 15, + 18, + 15, + 19, + 15, + 20, + 15, + 21, + 15, + 22, + 15, + 23, + 16, + 0, + 16, + 1, + 16, + 2, + 16, + 3, + 16, + 4, + 16, + 5, + 16, + 6, + 16, + 7, + 16, + 8, + 16, + 9, + 16, + 10, + 16, + 11, + 16, + 12, + 16, + 13, + 16, + 14, + 16, + 15, + 16, + 16, + 16, + 17, + 16, + 18, + 16, + 19, + 16, + 20, + 16, + 21, + 16, + 22, + 16, + 23, + 17, + 0, + 17, + 1, + 17, + 2, + 17, + 3, + 17, + 4, + 17, + 5, + 17, + 6, + 17, + 7, + 17, + 8, + 17, + 9, + 17, + 10, + 17, + 11, + 17, + 12, + 17, + 13, + 17, + 14, + 17, + 15, + 17, + 16, + 17, + 17, + 17, + 18, + 17, + 19, + 17, + 20, + 17, + 21, + 17, + 22, + 17, + 23, + 18, + 0, + 18, + 1, + 18, + 2, + 18, + 3, + 18, + 4, + 18, + 5, + 18, + 6, + 18, + 7, + 18, + 8, + 18, + 9, + 18, + 10, + 18, + 11, + 18, + 12, + 18, + 13, + 18, + 14, + 18, + 15, + 18, + 16, + 18, + 17, + 18, + 18, + 18, + 19, + 18, + 20, + 18, + 21, + 18, + 22, + 18, + 23, + 19, + 0, + 19, + 1, + 19, + 2, + 19, + 3, + 19, + 4, + 19, + 5, + 19, + 6, + 19, + 7, + 19, + 8, + 19, + 9, + 19, + 10, + 19, + 11, + 19, + 12, + 19, + 13, + 19, + 14, + 19, + 15, + 19, + 16, + 19, + 17, + 19, + 18, + 19, + 19, + 19, + 20, + 19, + 21, + 19, + 22, + 19, + 23, + 20, + 0, + 20, + 1, + 20, + 2, + 20, + 3, + 20, + 4, + 20, + 5, + 20, + 6, + 20, + 7, + 20, + 8, + 20, + 9, + 20, + 10, + 20, + 11, + 20, + 12, + 20, + 13, + 20, + 14, + 20, + 15, + 20, + 16, + 20, + 17, + 20, + 18, + 20, + 19, + 20, + 20, + 20, + 21, + 20, + 22, + 20, + 23, + 21, + 0, + 21, + 1, + 21, + 2, + 21, + 3, + 21, + 4, + 21, + 5, + 21, + 6, + 21, + 7, + 21, + 8, + 21, + 9, + 21, + 10, + 21, + 11, + 21, + 12, + 21, + 13, + 21, + 14, + 21, + 15, + 21, + 16, + 21, + 17, + 21, + 18, + 21, + 19, + 21, + 20, + 21, + 21, + 21, + 22, + 21, + 23, + 22, + 0, + 22, + 1, + 22, + 2, + 22, + 3, + 22, + 4, + 22, + 5, + 22, + 6, + 22, + 7, + 22, + 8, + 22, + 9, + 22, + 10, + 22, + 11, + 22, + 12, + 22, + 13, + 22, + 14, + 22, + 15, + 22, + 16, + 22, + 17, + 22, + 18, + 22, + 19, + 22, + 20, + 22, + 21, + 22, + 22, + 22, + 23, + 23, + 0, + 23, + 1, + 23, + 2, + 23, + 3, + 23, + 4, + 23, + 5, + 23, + 6, + 23, + 7, + 23, + 8, + 23, + 9, + 23, + 10, + 23, + 11, + 23, + 12, + 23, + 13, + 23, + 14, + 23, + 15, + 23, + 16, + 23, + 17, + 23, + 18, + 23, + 19, + 23, + 20, + 23, + 21, + 23, + 22, + 23, + 23, +}; + +const int32_t c_aaiHuffDemod16[729][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 0, + 14, + 0, + 15, + 0, + 16, + 0, + 17, + 0, + 18, + 0, + 19, + 0, + 20, + 0, + 21, + 0, + 22, + 0, + 23, + 0, + 24, + 0, + 25, + 0, + 26, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 1, + 14, + 1, + 15, + 1, + 16, + 1, + 17, + 1, + 18, + 1, + 19, + 1, + 20, + 1, + 21, + 1, + 22, + 1, + 23, + 1, + 24, + 1, + 25, + 1, + 26, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 2, + 14, + 2, + 15, + 2, + 16, + 2, + 17, + 2, + 18, + 2, + 19, + 2, + 20, + 2, + 21, + 2, + 22, + 2, + 23, + 2, + 24, + 2, + 25, + 2, + 26, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 3, + 14, + 3, + 15, + 3, + 16, + 3, + 17, + 3, + 18, + 3, + 19, + 3, + 20, + 3, + 21, + 3, + 22, + 3, + 23, + 3, + 24, + 3, + 25, + 3, + 26, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 4, + 14, + 4, + 15, + 4, + 16, + 4, + 17, + 4, + 18, + 4, + 19, + 4, + 20, + 4, + 21, + 4, + 22, + 4, + 23, + 4, + 24, + 4, + 25, + 4, + 26, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 5, + 14, + 5, + 15, + 5, + 16, + 5, + 17, + 5, + 18, + 5, + 19, + 5, + 20, + 5, + 21, + 5, + 22, + 5, + 23, + 5, + 24, + 5, + 25, + 5, + 26, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 6, + 14, + 6, + 15, + 6, + 16, + 6, + 17, + 6, + 18, + 6, + 19, + 6, + 20, + 6, + 21, + 6, + 22, + 6, + 23, + 6, + 24, + 6, + 25, + 6, + 26, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 7, + 14, + 7, + 15, + 7, + 16, + 7, + 17, + 7, + 18, + 7, + 19, + 7, + 20, + 7, + 21, + 7, + 22, + 7, + 23, + 7, + 24, + 7, + 25, + 7, + 26, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 8, + 14, + 8, + 15, + 8, + 16, + 8, + 17, + 8, + 18, + 8, + 19, + 8, + 20, + 8, + 21, + 8, + 22, + 8, + 23, + 8, + 24, + 8, + 25, + 8, + 26, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 9, + 14, + 9, + 15, + 9, + 16, + 9, + 17, + 9, + 18, + 9, + 19, + 9, + 20, + 9, + 21, + 9, + 22, + 9, + 23, + 9, + 24, + 9, + 25, + 9, + 26, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 10, + 14, + 10, + 15, + 10, + 16, + 10, + 17, + 10, + 18, + 10, + 19, + 10, + 20, + 10, + 21, + 10, + 22, + 10, + 23, + 10, + 24, + 10, + 25, + 10, + 26, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 11, + 14, + 11, + 15, + 11, + 16, + 11, + 17, + 11, + 18, + 11, + 19, + 11, + 20, + 11, + 21, + 11, + 22, + 11, + 23, + 11, + 24, + 11, + 25, + 11, + 26, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 12, + 14, + 12, + 15, + 12, + 16, + 12, + 17, + 12, + 18, + 12, + 19, + 12, + 20, + 12, + 21, + 12, + 22, + 12, + 23, + 12, + 24, + 12, + 25, + 12, + 26, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, + 13, + 14, + 13, + 15, + 13, + 16, + 13, + 17, + 13, + 18, + 13, + 19, + 13, + 20, + 13, + 21, + 13, + 22, + 13, + 23, + 13, + 24, + 13, + 25, + 13, + 26, + 14, + 0, + 14, + 1, + 14, + 2, + 14, + 3, + 14, + 4, + 14, + 5, + 14, + 6, + 14, + 7, + 14, + 8, + 14, + 9, + 14, + 10, + 14, + 11, + 14, + 12, + 14, + 13, + 14, + 14, + 14, + 15, + 14, + 16, + 14, + 17, + 14, + 18, + 14, + 19, + 14, + 20, + 14, + 21, + 14, + 22, + 14, + 23, + 14, + 24, + 14, + 25, + 14, + 26, + 15, + 0, + 15, + 1, + 15, + 2, + 15, + 3, + 15, + 4, + 15, + 5, + 15, + 6, + 15, + 7, + 15, + 8, + 15, + 9, + 15, + 10, + 15, + 11, + 15, + 12, + 15, + 13, + 15, + 14, + 15, + 15, + 15, + 16, + 15, + 17, + 15, + 18, + 15, + 19, + 15, + 20, + 15, + 21, + 15, + 22, + 15, + 23, + 15, + 24, + 15, + 25, + 15, + 26, + 16, + 0, + 16, + 1, + 16, + 2, + 16, + 3, + 16, + 4, + 16, + 5, + 16, + 6, + 16, + 7, + 16, + 8, + 16, + 9, + 16, + 10, + 16, + 11, + 16, + 12, + 16, + 13, + 16, + 14, + 16, + 15, + 16, + 16, + 16, + 17, + 16, + 18, + 16, + 19, + 16, + 20, + 16, + 21, + 16, + 22, + 16, + 23, + 16, + 24, + 16, + 25, + 16, + 26, + 17, + 0, + 17, + 1, + 17, + 2, + 17, + 3, + 17, + 4, + 17, + 5, + 17, + 6, + 17, + 7, + 17, + 8, + 17, + 9, + 17, + 10, + 17, + 11, + 17, + 12, + 17, + 13, + 17, + 14, + 17, + 15, + 17, + 16, + 17, + 17, + 17, + 18, + 17, + 19, + 17, + 20, + 17, + 21, + 17, + 22, + 17, + 23, + 17, + 24, + 17, + 25, + 17, + 26, + 18, + 0, + 18, + 1, + 18, + 2, + 18, + 3, + 18, + 4, + 18, + 5, + 18, + 6, + 18, + 7, + 18, + 8, + 18, + 9, + 18, + 10, + 18, + 11, + 18, + 12, + 18, + 13, + 18, + 14, + 18, + 15, + 18, + 16, + 18, + 17, + 18, + 18, + 18, + 19, + 18, + 20, + 18, + 21, + 18, + 22, + 18, + 23, + 18, + 24, + 18, + 25, + 18, + 26, + 19, + 0, + 19, + 1, + 19, + 2, + 19, + 3, + 19, + 4, + 19, + 5, + 19, + 6, + 19, + 7, + 19, + 8, + 19, + 9, + 19, + 10, + 19, + 11, + 19, + 12, + 19, + 13, + 19, + 14, + 19, + 15, + 19, + 16, + 19, + 17, + 19, + 18, + 19, + 19, + 19, + 20, + 19, + 21, + 19, + 22, + 19, + 23, + 19, + 24, + 19, + 25, + 19, + 26, + 20, + 0, + 20, + 1, + 20, + 2, + 20, + 3, + 20, + 4, + 20, + 5, + 20, + 6, + 20, + 7, + 20, + 8, + 20, + 9, + 20, + 10, + 20, + 11, + 20, + 12, + 20, + 13, + 20, + 14, + 20, + 15, + 20, + 16, + 20, + 17, + 20, + 18, + 20, + 19, + 20, + 20, + 20, + 21, + 20, + 22, + 20, + 23, + 20, + 24, + 20, + 25, + 20, + 26, + 21, + 0, + 21, + 1, + 21, + 2, + 21, + 3, + 21, + 4, + 21, + 5, + 21, + 6, + 21, + 7, + 21, + 8, + 21, + 9, + 21, + 10, + 21, + 11, + 21, + 12, + 21, + 13, + 21, + 14, + 21, + 15, + 21, + 16, + 21, + 17, + 21, + 18, + 21, + 19, + 21, + 20, + 21, + 21, + 21, + 22, + 21, + 23, + 21, + 24, + 21, + 25, + 21, + 26, + 22, + 0, + 22, + 1, + 22, + 2, + 22, + 3, + 22, + 4, + 22, + 5, + 22, + 6, + 22, + 7, + 22, + 8, + 22, + 9, + 22, + 10, + 22, + 11, + 22, + 12, + 22, + 13, + 22, + 14, + 22, + 15, + 22, + 16, + 22, + 17, + 22, + 18, + 22, + 19, + 22, + 20, + 22, + 21, + 22, + 22, + 22, + 23, + 22, + 24, + 22, + 25, + 22, + 26, + 23, + 0, + 23, + 1, + 23, + 2, + 23, + 3, + 23, + 4, + 23, + 5, + 23, + 6, + 23, + 7, + 23, + 8, + 23, + 9, + 23, + 10, + 23, + 11, + 23, + 12, + 23, + 13, + 23, + 14, + 23, + 15, + 23, + 16, + 23, + 17, + 23, + 18, + 23, + 19, + 23, + 20, + 23, + 21, + 23, + 22, + 23, + 23, + 23, + 24, + 23, + 25, + 23, + 26, + 24, + 0, + 24, + 1, + 24, + 2, + 24, + 3, + 24, + 4, + 24, + 5, + 24, + 6, + 24, + 7, + 24, + 8, + 24, + 9, + 24, + 10, + 24, + 11, + 24, + 12, + 24, + 13, + 24, + 14, + 24, + 15, + 24, + 16, + 24, + 17, + 24, + 18, + 24, + 19, + 24, + 20, + 24, + 21, + 24, + 22, + 24, + 23, + 24, + 24, + 24, + 25, + 24, + 26, + 25, + 0, + 25, + 1, + 25, + 2, + 25, + 3, + 25, + 4, + 25, + 5, + 25, + 6, + 25, + 7, + 25, + 8, + 25, + 9, + 25, + 10, + 25, + 11, + 25, + 12, + 25, + 13, + 25, + 14, + 25, + 15, + 25, + 16, + 25, + 17, + 25, + 18, + 25, + 19, + 25, + 20, + 25, + 21, + 25, + 22, + 25, + 23, + 25, + 24, + 25, + 25, + 25, + 26, + 26, + 0, + 26, + 1, + 26, + 2, + 26, + 3, + 26, + 4, + 26, + 5, + 26, + 6, + 26, + 7, + 26, + 8, + 26, + 9, + 26, + 10, + 26, + 11, + 26, + 12, + 26, + 13, + 26, + 14, + 26, + 15, + 26, + 16, + 26, + 17, + 26, + 18, + 26, + 19, + 26, + 20, + 26, + 21, + 26, + 22, + 26, + 23, + 26, + 24, + 26, + 25, + 26, + 26, +}; + +const int32_t c_aaiHuffDemod17[729][2] = { + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 4, + 0, + 5, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 10, + 0, + 11, + 0, + 12, + 0, + 13, + 0, + 14, + 0, + 15, + 0, + 16, + 0, + 17, + 0, + 18, + 0, + 19, + 0, + 20, + 0, + 21, + 0, + 22, + 0, + 23, + 0, + 24, + 0, + 25, + 0, + 26, + 1, + 0, + 1, + 1, + 1, + 2, + 1, + 3, + 1, + 4, + 1, + 5, + 1, + 6, + 1, + 7, + 1, + 8, + 1, + 9, + 1, + 10, + 1, + 11, + 1, + 12, + 1, + 13, + 1, + 14, + 1, + 15, + 1, + 16, + 1, + 17, + 1, + 18, + 1, + 19, + 1, + 20, + 1, + 21, + 1, + 22, + 1, + 23, + 1, + 24, + 1, + 25, + 1, + 26, + 2, + 0, + 2, + 1, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 5, + 2, + 6, + 2, + 7, + 2, + 8, + 2, + 9, + 2, + 10, + 2, + 11, + 2, + 12, + 2, + 13, + 2, + 14, + 2, + 15, + 2, + 16, + 2, + 17, + 2, + 18, + 2, + 19, + 2, + 20, + 2, + 21, + 2, + 22, + 2, + 23, + 2, + 24, + 2, + 25, + 2, + 26, + 3, + 0, + 3, + 1, + 3, + 2, + 3, + 3, + 3, + 4, + 3, + 5, + 3, + 6, + 3, + 7, + 3, + 8, + 3, + 9, + 3, + 10, + 3, + 11, + 3, + 12, + 3, + 13, + 3, + 14, + 3, + 15, + 3, + 16, + 3, + 17, + 3, + 18, + 3, + 19, + 3, + 20, + 3, + 21, + 3, + 22, + 3, + 23, + 3, + 24, + 3, + 25, + 3, + 26, + 4, + 0, + 4, + 1, + 4, + 2, + 4, + 3, + 4, + 4, + 4, + 5, + 4, + 6, + 4, + 7, + 4, + 8, + 4, + 9, + 4, + 10, + 4, + 11, + 4, + 12, + 4, + 13, + 4, + 14, + 4, + 15, + 4, + 16, + 4, + 17, + 4, + 18, + 4, + 19, + 4, + 20, + 4, + 21, + 4, + 22, + 4, + 23, + 4, + 24, + 4, + 25, + 4, + 26, + 5, + 0, + 5, + 1, + 5, + 2, + 5, + 3, + 5, + 4, + 5, + 5, + 5, + 6, + 5, + 7, + 5, + 8, + 5, + 9, + 5, + 10, + 5, + 11, + 5, + 12, + 5, + 13, + 5, + 14, + 5, + 15, + 5, + 16, + 5, + 17, + 5, + 18, + 5, + 19, + 5, + 20, + 5, + 21, + 5, + 22, + 5, + 23, + 5, + 24, + 5, + 25, + 5, + 26, + 6, + 0, + 6, + 1, + 6, + 2, + 6, + 3, + 6, + 4, + 6, + 5, + 6, + 6, + 6, + 7, + 6, + 8, + 6, + 9, + 6, + 10, + 6, + 11, + 6, + 12, + 6, + 13, + 6, + 14, + 6, + 15, + 6, + 16, + 6, + 17, + 6, + 18, + 6, + 19, + 6, + 20, + 6, + 21, + 6, + 22, + 6, + 23, + 6, + 24, + 6, + 25, + 6, + 26, + 7, + 0, + 7, + 1, + 7, + 2, + 7, + 3, + 7, + 4, + 7, + 5, + 7, + 6, + 7, + 7, + 7, + 8, + 7, + 9, + 7, + 10, + 7, + 11, + 7, + 12, + 7, + 13, + 7, + 14, + 7, + 15, + 7, + 16, + 7, + 17, + 7, + 18, + 7, + 19, + 7, + 20, + 7, + 21, + 7, + 22, + 7, + 23, + 7, + 24, + 7, + 25, + 7, + 26, + 8, + 0, + 8, + 1, + 8, + 2, + 8, + 3, + 8, + 4, + 8, + 5, + 8, + 6, + 8, + 7, + 8, + 8, + 8, + 9, + 8, + 10, + 8, + 11, + 8, + 12, + 8, + 13, + 8, + 14, + 8, + 15, + 8, + 16, + 8, + 17, + 8, + 18, + 8, + 19, + 8, + 20, + 8, + 21, + 8, + 22, + 8, + 23, + 8, + 24, + 8, + 25, + 8, + 26, + 9, + 0, + 9, + 1, + 9, + 2, + 9, + 3, + 9, + 4, + 9, + 5, + 9, + 6, + 9, + 7, + 9, + 8, + 9, + 9, + 9, + 10, + 9, + 11, + 9, + 12, + 9, + 13, + 9, + 14, + 9, + 15, + 9, + 16, + 9, + 17, + 9, + 18, + 9, + 19, + 9, + 20, + 9, + 21, + 9, + 22, + 9, + 23, + 9, + 24, + 9, + 25, + 9, + 26, + 10, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 10, + 6, + 10, + 7, + 10, + 8, + 10, + 9, + 10, + 10, + 10, + 11, + 10, + 12, + 10, + 13, + 10, + 14, + 10, + 15, + 10, + 16, + 10, + 17, + 10, + 18, + 10, + 19, + 10, + 20, + 10, + 21, + 10, + 22, + 10, + 23, + 10, + 24, + 10, + 25, + 10, + 26, + 11, + 0, + 11, + 1, + 11, + 2, + 11, + 3, + 11, + 4, + 11, + 5, + 11, + 6, + 11, + 7, + 11, + 8, + 11, + 9, + 11, + 10, + 11, + 11, + 11, + 12, + 11, + 13, + 11, + 14, + 11, + 15, + 11, + 16, + 11, + 17, + 11, + 18, + 11, + 19, + 11, + 20, + 11, + 21, + 11, + 22, + 11, + 23, + 11, + 24, + 11, + 25, + 11, + 26, + 12, + 0, + 12, + 1, + 12, + 2, + 12, + 3, + 12, + 4, + 12, + 5, + 12, + 6, + 12, + 7, + 12, + 8, + 12, + 9, + 12, + 10, + 12, + 11, + 12, + 12, + 12, + 13, + 12, + 14, + 12, + 15, + 12, + 16, + 12, + 17, + 12, + 18, + 12, + 19, + 12, + 20, + 12, + 21, + 12, + 22, + 12, + 23, + 12, + 24, + 12, + 25, + 12, + 26, + 13, + 0, + 13, + 1, + 13, + 2, + 13, + 3, + 13, + 4, + 13, + 5, + 13, + 6, + 13, + 7, + 13, + 8, + 13, + 9, + 13, + 10, + 13, + 11, + 13, + 12, + 13, + 13, + 13, + 14, + 13, + 15, + 13, + 16, + 13, + 17, + 13, + 18, + 13, + 19, + 13, + 20, + 13, + 21, + 13, + 22, + 13, + 23, + 13, + 24, + 13, + 25, + 13, + 26, + 14, + 0, + 14, + 1, + 14, + 2, + 14, + 3, + 14, + 4, + 14, + 5, + 14, + 6, + 14, + 7, + 14, + 8, + 14, + 9, + 14, + 10, + 14, + 11, + 14, + 12, + 14, + 13, + 14, + 14, + 14, + 15, + 14, + 16, + 14, + 17, + 14, + 18, + 14, + 19, + 14, + 20, + 14, + 21, + 14, + 22, + 14, + 23, + 14, + 24, + 14, + 25, + 14, + 26, + 15, + 0, + 15, + 1, + 15, + 2, + 15, + 3, + 15, + 4, + 15, + 5, + 15, + 6, + 15, + 7, + 15, + 8, + 15, + 9, + 15, + 10, + 15, + 11, + 15, + 12, + 15, + 13, + 15, + 14, + 15, + 15, + 15, + 16, + 15, + 17, + 15, + 18, + 15, + 19, + 15, + 20, + 15, + 21, + 15, + 22, + 15, + 23, + 15, + 24, + 15, + 25, + 15, + 26, + 16, + 0, + 16, + 1, + 16, + 2, + 16, + 3, + 16, + 4, + 16, + 5, + 16, + 6, + 16, + 7, + 16, + 8, + 16, + 9, + 16, + 10, + 16, + 11, + 16, + 12, + 16, + 13, + 16, + 14, + 16, + 15, + 16, + 16, + 16, + 17, + 16, + 18, + 16, + 19, + 16, + 20, + 16, + 21, + 16, + 22, + 16, + 23, + 16, + 24, + 16, + 25, + 16, + 26, + 17, + 0, + 17, + 1, + 17, + 2, + 17, + 3, + 17, + 4, + 17, + 5, + 17, + 6, + 17, + 7, + 17, + 8, + 17, + 9, + 17, + 10, + 17, + 11, + 17, + 12, + 17, + 13, + 17, + 14, + 17, + 15, + 17, + 16, + 17, + 17, + 17, + 18, + 17, + 19, + 17, + 20, + 17, + 21, + 17, + 22, + 17, + 23, + 17, + 24, + 17, + 25, + 17, + 26, + 18, + 0, + 18, + 1, + 18, + 2, + 18, + 3, + 18, + 4, + 18, + 5, + 18, + 6, + 18, + 7, + 18, + 8, + 18, + 9, + 18, + 10, + 18, + 11, + 18, + 12, + 18, + 13, + 18, + 14, + 18, + 15, + 18, + 16, + 18, + 17, + 18, + 18, + 18, + 19, + 18, + 20, + 18, + 21, + 18, + 22, + 18, + 23, + 18, + 24, + 18, + 25, + 18, + 26, + 19, + 0, + 19, + 1, + 19, + 2, + 19, + 3, + 19, + 4, + 19, + 5, + 19, + 6, + 19, + 7, + 19, + 8, + 19, + 9, + 19, + 10, + 19, + 11, + 19, + 12, + 19, + 13, + 19, + 14, + 19, + 15, + 19, + 16, + 19, + 17, + 19, + 18, + 19, + 19, + 19, + 20, + 19, + 21, + 19, + 22, + 19, + 23, + 19, + 24, + 19, + 25, + 19, + 26, + 20, + 0, + 20, + 1, + 20, + 2, + 20, + 3, + 20, + 4, + 20, + 5, + 20, + 6, + 20, + 7, + 20, + 8, + 20, + 9, + 20, + 10, + 20, + 11, + 20, + 12, + 20, + 13, + 20, + 14, + 20, + 15, + 20, + 16, + 20, + 17, + 20, + 18, + 20, + 19, + 20, + 20, + 20, + 21, + 20, + 22, + 20, + 23, + 20, + 24, + 20, + 25, + 20, + 26, + 21, + 0, + 21, + 1, + 21, + 2, + 21, + 3, + 21, + 4, + 21, + 5, + 21, + 6, + 21, + 7, + 21, + 8, + 21, + 9, + 21, + 10, + 21, + 11, + 21, + 12, + 21, + 13, + 21, + 14, + 21, + 15, + 21, + 16, + 21, + 17, + 21, + 18, + 21, + 19, + 21, + 20, + 21, + 21, + 21, + 22, + 21, + 23, + 21, + 24, + 21, + 25, + 21, + 26, + 22, + 0, + 22, + 1, + 22, + 2, + 22, + 3, + 22, + 4, + 22, + 5, + 22, + 6, + 22, + 7, + 22, + 8, + 22, + 9, + 22, + 10, + 22, + 11, + 22, + 12, + 22, + 13, + 22, + 14, + 22, + 15, + 22, + 16, + 22, + 17, + 22, + 18, + 22, + 19, + 22, + 20, + 22, + 21, + 22, + 22, + 22, + 23, + 22, + 24, + 22, + 25, + 22, + 26, + 23, + 0, + 23, + 1, + 23, + 2, + 23, + 3, + 23, + 4, + 23, + 5, + 23, + 6, + 23, + 7, + 23, + 8, + 23, + 9, + 23, + 10, + 23, + 11, + 23, + 12, + 23, + 13, + 23, + 14, + 23, + 15, + 23, + 16, + 23, + 17, + 23, + 18, + 23, + 19, + 23, + 20, + 23, + 21, + 23, + 22, + 23, + 23, + 23, + 24, + 23, + 25, + 23, + 26, + 24, + 0, + 24, + 1, + 24, + 2, + 24, + 3, + 24, + 4, + 24, + 5, + 24, + 6, + 24, + 7, + 24, + 8, + 24, + 9, + 24, + 10, + 24, + 11, + 24, + 12, + 24, + 13, + 24, + 14, + 24, + 15, + 24, + 16, + 24, + 17, + 24, + 18, + 24, + 19, + 24, + 20, + 24, + 21, + 24, + 22, + 24, + 23, + 24, + 24, + 24, + 25, + 24, + 26, + 25, + 0, + 25, + 1, + 25, + 2, + 25, + 3, + 25, + 4, + 25, + 5, + 25, + 6, + 25, + 7, + 25, + 8, + 25, + 9, + 25, + 10, + 25, + 11, + 25, + 12, + 25, + 13, + 25, + 14, + 25, + 15, + 25, + 16, + 25, + 17, + 25, + 18, + 25, + 19, + 25, + 20, + 25, + 21, + 25, + 22, + 25, + 23, + 25, + 24, + 25, + 25, + 25, + 26, + 26, + 0, + 26, + 1, + 26, + 2, + 26, + 3, + 26, + 4, + 26, + 5, + 26, + 6, + 26, + 7, + 26, + 8, + 26, + 9, + 26, + 10, + 26, + 11, + 26, + 12, + 26, + 13, + 26, + 14, + 26, + 15, + 26, + 16, + 26, + 17, + 26, + 18, + 26, + 19, + 26, + 20, + 26, + 21, + 26, + 22, + 26, + 23, + 26, + 24, + 26, + 25, + 26, + 26, +}; + +const int32_t ( *c_apaiDemodTables[ALLOC_TABLE_SIZE] )[2] = { + NULL, + c_aaiHuffDemod1, + c_aaiHuffDemod2, + c_aaiHuffDemod3, + c_aaiHuffDemod4, + c_aaiHuffDemod5, + c_aaiHuffDemod6, + c_aaiHuffDemod7, + c_aaiHuffDemod8, + c_aaiHuffDemod9, + c_aaiHuffDemod10, + c_aaiHuffDemod11, + c_aaiHuffDemod12, + c_aaiHuffDemod13, + c_aaiHuffDemod14, + c_aaiHuffDemod15, + c_aaiHuffDemod16, + c_aaiHuffDemod17, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +}; +#endif +const Word16 c_aiLogAddTable_fx[LOG_ADD_TABLE_LENGTH] = { + 0x40, + 0x40, + 0x3F, + 0x3F, + 0x3E, + 0x3E, + 0x3D, + 0x3D, + 0x3C, + 0x3C, + 0x3B, + 0x3B, + 0x3A, + 0x3A, + 0x39, + 0x39, + 0x38, + 0x38, + 0x37, + 0x37, + 0x37, + 0x36, + 0x36, + 0x35, + 0x35, + 0x34, + 0x34, + 0x33, + 0x33, + 0x33, + 0x32, + 0x32, + 0x31, + 0x31, + 0x31, + 0x30, + 0x30, + 0x2F, + 0x2F, + 0x2F, + 0x2E, + 0x2E, + 0x2D, + 0x2D, + 0x2D, + 0x2C, + 0x2C, + 0x2B, + 0x2B, + 0x2B, + 0x2A, + 0x2A, + 0x2A, + 0x29, + 0x29, + 0x29, + 0x28, + 0x28, + 0x27, + 0x27, + 0x27, + 0x26, + 0x26, + 0x26, + 0x25, + 0x25, + 0x25, + 0x24, + 0x24, + 0x24, + 0x23, + 0x23, + 0x23, + 0x23, + 0x22, + 0x22, + 0x22, + 0x21, + 0x21, + 0x21, + 0x20, + 0x20, + 0x20, + 0x20, + 0x1F, + 0x1F, + 0x1F, + 0x1E, + 0x1E, + 0x1E, + 0x1E, + 0x1D, + 0x1D, + 0x1D, + 0x1C, + 0x1C, + 0x1C, + 0x1C, + 0x1B, + 0x1B, + 0x1B, + 0x1B, + 0x1A, + 0x1A, + 0x1A, + 0x1A, + 0x19, + 0x19, + 0x19, + 0x19, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x17, + 0x17, + 0x17, + 0x17, + 0x16, + 0x16, + 0x16, + 0x16, + 0x16, + 0x15, + 0x15, + 0x15, + 0x15, + 0x15, + 0x14, + 0x14, + 0x14, + 0x14, + 0x14, + 0x13, + 0x13, + 0x13, + 0x13, + 0x13, + 0x13, + 0x12, + 0x12, + 0x12, + 0x12, + 0x12, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, +}; +const int32_t c_aiLogAddTable[LOG_ADD_TABLE_LENGTH] = { + 0x40, + 0x40, + 0x3F, + 0x3F, + 0x3E, + 0x3E, + 0x3D, + 0x3D, + 0x3C, + 0x3C, + 0x3B, + 0x3B, + 0x3A, + 0x3A, + 0x39, + 0x39, + 0x38, + 0x38, + 0x37, + 0x37, + 0x37, + 0x36, + 0x36, + 0x35, + 0x35, + 0x34, + 0x34, + 0x33, + 0x33, + 0x33, + 0x32, + 0x32, + 0x31, + 0x31, + 0x31, + 0x30, + 0x30, + 0x2F, + 0x2F, + 0x2F, + 0x2E, + 0x2E, + 0x2D, + 0x2D, + 0x2D, + 0x2C, + 0x2C, + 0x2B, + 0x2B, + 0x2B, + 0x2A, + 0x2A, + 0x2A, + 0x29, + 0x29, + 0x29, + 0x28, + 0x28, + 0x27, + 0x27, + 0x27, + 0x26, + 0x26, + 0x26, + 0x25, + 0x25, + 0x25, + 0x24, + 0x24, + 0x24, + 0x23, + 0x23, + 0x23, + 0x23, + 0x22, + 0x22, + 0x22, + 0x21, + 0x21, + 0x21, + 0x20, + 0x20, + 0x20, + 0x20, + 0x1F, + 0x1F, + 0x1F, + 0x1E, + 0x1E, + 0x1E, + 0x1E, + 0x1D, + 0x1D, + 0x1D, + 0x1C, + 0x1C, + 0x1C, + 0x1C, + 0x1B, + 0x1B, + 0x1B, + 0x1B, + 0x1A, + 0x1A, + 0x1A, + 0x1A, + 0x19, + 0x19, + 0x19, + 0x19, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x17, + 0x17, + 0x17, + 0x17, + 0x16, + 0x16, + 0x16, + 0x16, + 0x16, + 0x15, + 0x15, + 0x15, + 0x15, + 0x15, + 0x14, + 0x14, + 0x14, + 0x14, + 0x14, + 0x13, + 0x13, + 0x13, + 0x13, + 0x13, + 0x13, + 0x12, + 0x12, + 0x12, + 0x12, + 0x12, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, +}; +const Word16 c_aiBandwidthAdjust48_fx[MAX_BANDS_48] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 64, + 64, + 64, + 64, + 64, + 101, + 101, + 128, + 165, + 165, + 180, + 213, +}; +const int32_t c_aiBandwidthAdjust48[MAX_BANDS_48] = { + + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 64, + 64, + 64, + 64, + 64, + 101, + 101, + 128, + 165, + 165, + 180, + 213, +}; + +const Word16 c_aiAbsoluteThresh48_fx[MAX_BANDS_48] = { + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1782, + -1761, + -1737, + -1679, + -1638, + -1613, + -1590, + -1568, + -1516, + -1459, + -1395, + -1289, + -671, + -409, + -401, +}; +const int32_t c_aiAbsoluteThresh48[MAX_BANDS_48] = { + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1782, + -1761, + -1737, + -1679, + -1638, + -1613, + -1590, + -1568, + -1516, + -1459, + -1395, + -1289, + -671, + -409, + -401, +}; +#if PERCEPTUAL_MODEL_SLGAIN_SHIFT == 4 +const int32_t c_aiDefaultTheta48[MAX_BANDS_48] = { + 7, + 7, + 6, + 5, + 5, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, +}; +#elif PERCEPTUAL_MODEL_SLGAIN_SHIFT == 8 +const Word16 c_aiDefaultTheta48_fx[MAX_BANDS_48] = { + + 112, + 112, + 96, + 80, + 80, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, +}; +#endif +const int32_t c_aiDefaultTheta48[MAX_BANDS_48] = { + + 112, + 112, + 96, + 80, + 80, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, +}; +const Word16 c_aaiSpreadFunction48_fx[MAX_BANDS_48 * MAX_BANDS_48] = { + 0, + -1561, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -289, + -4, + -1234, + -2295, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -569, + -229, + -8, + -905, + -1705, + -2324, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -789, + -445, + -173, + -16, + -656, + -1271, + -1765, + -2172, + -2520, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -961, + -616, + -340, + -136, + -28, + -488, + -976, + -1382, + -1729, + -2032, + -2305, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1088, + -743, + -465, + -257, + -148, + -31, + -371, + -769, + -1114, + -1417, + -1689, + -2054, + -2483, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1198, + -852, + -574, + -364, + -209, + -148, + -42, + -300, + -635, + -936, + -1207, + -1572, + -2000, + -2376, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1293, + -948, + -669, + -458, + -301, + -183, + -145, + -56, + -258, + -547, + -816, + -1179, + -1606, + -1982, + -2311, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1375, + -1029, + -750, + -539, + -381, + -260, + -180, + -142, + -68, + -231, + -487, + -846, + -1272, + -1647, + -1976, + -2261, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1444, + -1099, + -820, + -608, + -449, + -328, + -233, + -194, + -138, + -77, + -213, + -555, + -978, + -1352, + -1681, + -1966, + -2268, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1501, + -1155, + -876, + -665, + -505, + -383, + -287, + -210, + -193, + -130, + -79, + -298, + -711, + -1083, + -1411, + -1696, + -1997, + -2288, + -2550, + -2552, + -2552, + -2552, + -2552, + -1567, + -1221, + -942, + -730, + -570, + -448, + -351, + -272, + -206, + -189, + -151, + -72, + -349, + -713, + -1039, + -1324, + -1625, + -1915, + -2177, + -2448, + -2552, + -2552, + -2552, + -1650, + -1304, + -1025, + -813, + -653, + -530, + -432, + -352, + -285, + -227, + -177, + -163, + -69, + -297, + -613, + -895, + -1195, + -1485, + -1746, + -2017, + -2238, + -2401, + -2545, + -1727, + -1381, + -1102, + -890, + -730, + -607, + -509, + -428, + -360, + -301, + -249, + -180, + -153, + -72, + -257, + -527, + -824, + -1112, + -1373, + -1643, + -1865, + -2028, + -2171, + -1798, + -1452, + -1173, + -960, + -800, + -677, + -579, + -498, + -430, + -370, + -317, + -246, + -192, + -145, + -76, + -224, + -505, + -790, + -1050, + -1320, + -1540, + -1703, + -1847, + -1860, + -1514, + -1234, + -1022, + -862, + -738, + -640, + -559, + -490, + -430, + -377, + -306, + -224, + -197, + -136, + -81, + -242, + -515, + -771, + -1040, + -1260, + -1422, + -1566, + -1923, + -1577, + -1297, + -1085, + -925, + -801, + -703, + -621, + -553, + -492, + -439, + -367, + -284, + -213, + -198, + -144, + -83, + -235, + -479, + -744, + -963, + -1125, + -1268, + -1986, + -1640, + -1360, + -1148, + -988, + -864, + -766, + -684, + -615, + -555, + -501, + -429, + -345, + -273, + -211, + -204, + -146, + -89, + -216, + -465, + -680, + -841, + -984, + -2043, + -1697, + -1417, + -1205, + -1044, + -921, + -822, + -741, + -672, + -611, + -557, + -485, + -401, + -328, + -264, + -211, + -205, + -140, + -93, + -227, + -430, + -588, + -729, + -2104, + -1758, + -1479, + -1266, + -1106, + -982, + -884, + -802, + -733, + -673, + -619, + -546, + -461, + -388, + -324, + -269, + -212, + -211, + -151, + -100, + -195, + -336, + -472, + -2163, + -1817, + -1537, + -1324, + -1164, + -1040, + -942, + -860, + -791, + -731, + -676, + -604, + -519, + -445, + -380, + -325, + -268, + -226, + -219, + -147, + -114, + -167, + -280, + -2203, + -1857, + -1577, + -1365, + -1205, + -1081, + -982, + -901, + -831, + -771, + -717, + -644, + -559, + -485, + -420, + -364, + -306, + -252, + -239, + -206, + -132, + -122, + -163, + -2224, + -1878, + -1598, + -1386, + -1225, + -1102, + -1003, + -921, + -852, + -792, + -737, + -665, + -580, + -505, + -441, + -385, + -326, + -271, + -222, + -224, + -176, + -121, + -114, +}; +const int32_t c_aaiSpreadFunction48[MAX_BANDS_48 * MAX_BANDS_48] = { + 0, + -1561, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -289, + -4, + -1234, + -2295, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -569, + -229, + -8, + -905, + -1705, + -2324, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -789, + -445, + -173, + -16, + -656, + -1271, + -1765, + -2172, + -2520, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -961, + -616, + -340, + -136, + -28, + -488, + -976, + -1382, + -1729, + -2032, + -2305, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1088, + -743, + -465, + -257, + -148, + -31, + -371, + -769, + -1114, + -1417, + -1689, + -2054, + -2483, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1198, + -852, + -574, + -364, + -209, + -148, + -42, + -300, + -635, + -936, + -1207, + -1572, + -2000, + -2376, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1293, + -948, + -669, + -458, + -301, + -183, + -145, + -56, + -258, + -547, + -816, + -1179, + -1606, + -1982, + -2311, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1375, + -1029, + -750, + -539, + -381, + -260, + -180, + -142, + -68, + -231, + -487, + -846, + -1272, + -1647, + -1976, + -2261, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1444, + -1099, + -820, + -608, + -449, + -328, + -233, + -194, + -138, + -77, + -213, + -555, + -978, + -1352, + -1681, + -1966, + -2268, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1501, + -1155, + -876, + -665, + -505, + -383, + -287, + -210, + -193, + -130, + -79, + -298, + -711, + -1083, + -1411, + -1696, + -1997, + -2288, + -2550, + -2552, + -2552, + -2552, + -2552, + -1567, + -1221, + -942, + -730, + -570, + -448, + -351, + -272, + -206, + -189, + -151, + -72, + -349, + -713, + -1039, + -1324, + -1625, + -1915, + -2177, + -2448, + -2552, + -2552, + -2552, + -1650, + -1304, + -1025, + -813, + -653, + -530, + -432, + -352, + -285, + -227, + -177, + -163, + -69, + -297, + -613, + -895, + -1195, + -1485, + -1746, + -2017, + -2238, + -2401, + -2545, + -1727, + -1381, + -1102, + -890, + -730, + -607, + -509, + -428, + -360, + -301, + -249, + -180, + -153, + -72, + -257, + -527, + -824, + -1112, + -1373, + -1643, + -1865, + -2028, + -2171, + -1798, + -1452, + -1173, + -960, + -800, + -677, + -579, + -498, + -430, + -370, + -317, + -246, + -192, + -145, + -76, + -224, + -505, + -790, + -1050, + -1320, + -1540, + -1703, + -1847, + -1860, + -1514, + -1234, + -1022, + -862, + -738, + -640, + -559, + -490, + -430, + -377, + -306, + -224, + -197, + -136, + -81, + -242, + -515, + -771, + -1040, + -1260, + -1422, + -1566, + -1923, + -1577, + -1297, + -1085, + -925, + -801, + -703, + -621, + -553, + -492, + -439, + -367, + -284, + -213, + -198, + -144, + -83, + -235, + -479, + -744, + -963, + -1125, + -1268, + -1986, + -1640, + -1360, + -1148, + -988, + -864, + -766, + -684, + -615, + -555, + -501, + -429, + -345, + -273, + -211, + -204, + -146, + -89, + -216, + -465, + -680, + -841, + -984, + -2043, + -1697, + -1417, + -1205, + -1044, + -921, + -822, + -741, + -672, + -611, + -557, + -485, + -401, + -328, + -264, + -211, + -205, + -140, + -93, + -227, + -430, + -588, + -729, + -2104, + -1758, + -1479, + -1266, + -1106, + -982, + -884, + -802, + -733, + -673, + -619, + -546, + -461, + -388, + -324, + -269, + -212, + -211, + -151, + -100, + -195, + -336, + -472, + -2163, + -1817, + -1537, + -1324, + -1164, + -1040, + -942, + -860, + -791, + -731, + -676, + -604, + -519, + -445, + -380, + -325, + -268, + -226, + -219, + -147, + -114, + -167, + -280, + -2203, + -1857, + -1577, + -1365, + -1205, + -1081, + -982, + -901, + -831, + -771, + -717, + -644, + -559, + -485, + -420, + -364, + -306, + -252, + -239, + -206, + -132, + -122, + -163, + -2224, + -1878, + -1598, + -1386, + -1225, + -1102, + -1003, + -921, + -852, + -792, + -737, + -665, + -580, + -505, + -441, + -385, + -326, + -271, + -222, + -224, + -176, + -121, + -114, +}; + +const Word32 c_pfMagLUT[8] = /* Q31 */ +{ + 0, 394599072, 775760576, 1130504448, 1446750336, 1713728896, 1922348544, 2065504896 +}; + +const Word32 c_pfP2RRealLUT[32] = /* Q31 */ +{ + INT_MIN, -2106220416, -1984016384, -1785567488, -1518500224, -1193078272, + -821806592, -418953280, -94, 418953088, 821806400, 1193077888, + 1518500224, 1785567360, 1984016128, 2106220288, 2147483647, 2106220288, + 1984016128, 1785567360, 1518500224, 1193077888, 821806400, 418953088, + -94, -418953280, -821806592, -1193078272, -1518500224, -1785567488, + -1984016384, -2106220416 +}; + +const Word32 c_pfP2RImagLUT[32] = /* Q31 */ +{ + 188, -418953248, -821806080, -1193077888, -1518500224, -1785567232, + -1984016128, -2106220288, INT_MIN, -2106220416, -1984016128, -1785567488, + -1518500224, -1193078016, -821806464, -418953280, 0, 418953280, + 821806464, 1193078016, 1518500224, 1785567488, 1984016128, 2106220416, + 2147483647, 2106220288, 1984016128, 1785567232, 1518500224, 1193077888, + 821806080, 418953248 +}; + +const Word32 c_pfWindowLUT[LCLD_PRED_WIN_LEN] = /* Q31 */ +{ + 190779840, 338280192, 610825408, 966922816, 1352359680, 1708457216, 1981002240, 2128502656, 2128502528, 1981002240, 1708456960, 1352359808, 966922624, 610825152, 338280192, 190779776 +}; +#endif diff --git a/lib_isar/isar_lcld_rom_tables.h b/lib_isar/isar_lcld_rom_tables.h new file mode 100644 index 000000000..4f1e80583 --- /dev/null +++ b/lib_isar/isar_lcld_rom_tables.h @@ -0,0 +1,245 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef _ISAR_LCLD_ROM_TABLES_H_ +#define _ISAR_LCLD_ROM_TABLES_H_ + +#include +#include "options.h" +#include "typedef.h" +#ifndef M_PI + +#define M_PI 3.14159265358979323846264338327950288f // todo: replace by EVS_PI +#define M_ONE_BY_PI_FX 10430 // 1/pi in Q15 + +#endif + +#define LCLD_BLOCKS_PER_FRAME ( 16 ) +#define LCLD_MAX_BLOCKS_PER_FRAME ( 16 ) +#define LCLD_BANDS ( 60 ) +#define LCLD_PRED_WIN_LEN ( 16 ) +#define LCLD_MAX_NUM_PRED_SUBSETS ( 8 ) +#define MAX_BANDS ( 23 ) +#define MAX_BANDS_48 ( 23 ) +#define DEF_BANDS_48 ( 22 ) + +#define ENV_MIN ( -64 ) +#define ENV_MAX ( 64 ) + +#define ENV0_BITS ( 7 ) + +#define ENV_DELTA_MIN ( -32 ) +#define ENV_DELTA_MIN_FX ( -1073741824 ) +#define ENV_DELTA_MAX ( 31 ) +#define ENV_DELTA_MAX_FX ( 1040187392 ) + +#define ENV_RECONSTRUCT_TABLE_SIZE ( 129 ) + +#define ENV_RECONSTRUCT_TABLE_CENTER ( 64 ) + +#define MIN_ALLOC ( 0 ) +#define MAX_ALLOC ( 31 ) + +#define ALLOC_OFFSET_SCALE ( 8 ) + +#define ALLOC_OFFSET_BITS ( 8 ) + +#define MIN_ALLOC_OFFSET ( -128 ) +#define MAX_ALLOC_OFFSET ( 127 ) +#define READ_LENGTH ( 4 ) + +#define ALLOC_TABLE_SIZE ( 32 ) + +#ifndef _PI_ +#define _PI_ ( 3.14159265358979f ) +#endif +#define PRED_MAX_VAL ( 12 ) +#define PRED_MIN_VAL ( -PRED_MAX_VAL ) +#define PRED_QUANT_FACTOR ( (float) PRED_MAX_VAL ) +#define PRED_QUANT_FACTOR_FX ( PRED_MAX_VAL ) +#define PRED_BAND0_BITS ( 5 ) + +#define PHASE_MAX_VAL ( 12 ) +#define PHASE_MIN_VAL ( -PHASE_MAX_VAL ) +#define PHASE_QUANT_FACTOR ( (float) PHASE_MAX_VAL / _PI_ ) +#define PHASE_QUANT_FACTOR_FX_Q29 ( 2050695826 ) +#define PHASE_DIFF_DIM ( 2 ) +#define PHASE_BAND0_BITS ( 5 ) + +#define PERCEPTUAL_MODEL_SLGAIN_SHIFT ( 8 ) + +// #define USE_DEMOD_TABLES + +#define HUFF_DEC_TABLE_SIZE ( 16 ) + +extern const int32_t c_aiNumLcldBandsPerBand[MAX_BANDS_48]; +extern const int32_t c_aiBandIdPerLcldBand[LCLD_BANDS]; +extern const float c_afRotRealImag[PRED_MAX_VAL - PRED_MIN_VAL + 1][2]; +extern const Word32 c_afRotRealImag_fx[PRED_MAX_VAL - PRED_MIN_VAL + 1][2]; +extern const Word16 c_aiDefaultTheta48_fx[MAX_BANDS_48]; +extern const int32_t c_aiDefaultTheta48[MAX_BANDS_48]; + +extern const float c_afScaleFactor[ALLOC_TABLE_SIZE]; +extern const float c_afInvScaleFactor[ALLOC_TABLE_SIZE]; +extern const Word32 c_afInvScaleFactor_fx[ALLOC_TABLE_SIZE]; +extern const float c_afRMSEnvReconstructTable[ENV_RECONSTRUCT_TABLE_SIZE]; +extern const int16_t c_afRMSEnvReconstructTable_exp[ENV_RECONSTRUCT_TABLE_SIZE]; +extern const int32_t c_aiQuantMaxValues[ALLOC_TABLE_SIZE]; +extern const int32_t c_aiHuffmanDim[ALLOC_TABLE_SIZE]; +extern const int32_t c_aiHuffmanMod[ALLOC_TABLE_SIZE]; +extern const Word32 c_aiHuffmanDim_fx[ALLOC_TABLE_SIZE]; +extern const Word32 c_aiHuffmanMod_fx[ALLOC_TABLE_SIZE]; +extern const Word32 c_afScaleFactor_fx[ALLOC_TABLE_SIZE]; +extern const Word32 c_aiQuantMaxValues_fx[ALLOC_TABLE_SIZE]; +extern const int32_t c_aiHuffmanSize[ALLOC_TABLE_SIZE]; + + +#define LOG_ADD_TABLE_LENGTH ( 512 ) + +extern const int32_t c_aiBandwidths48[MAX_BANDS_48]; +extern const Word16 c_aiLogAddTable_fx[LOG_ADD_TABLE_LENGTH]; +extern const Word16 c_aiBandwidthAdjust48_fx[MAX_BANDS_48]; +extern const int32_t c_aiLogAddTable[LOG_ADD_TABLE_LENGTH]; +extern const int32_t c_aiBandwidthAdjust48[MAX_BANDS_48]; + + +extern const Word16 c_aiAbsoluteThresh48_fx[MAX_BANDS_48]; +extern const Word16 c_aiDefaultTheta48_fx[MAX_BANDS_48]; +extern const Word16 c_aaiSpreadFunction48_fx[MAX_BANDS_48 * MAX_BANDS_48]; +extern const int32_t c_aiAbsoluteThresh48[MAX_BANDS_48]; +extern const int32_t c_aiDefaultTheta48[MAX_BANDS_48]; +extern const int32_t c_aaiSpreadFunction48[MAX_BANDS_48 * MAX_BANDS_48]; + + +#define PRED_QUNAT_FILTER_MAG_BITS ( 3 ) +#define PRED_QUANT_FILTER_PHASE_BITS ( 5 ) +#define PRED_QUANT_FILTER_MAG_MIN ( 0 ) +#define PRED_QUANT_FILTER_MAG_MAX ( 7 ) +#define PRED_QUANT_FILTER_PHASE_MIN ( -16 ) +#define PRED_QUANT_FILTER_PHASE_MAX ( 15 ) + +extern const uint16_t c_aauiLCLDHuffEnc1[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc2[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc3[25][2]; +extern const uint16_t c_aauiLCLDHuffEnc4[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc5[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc6[49][2]; +extern const uint16_t c_aauiLCLDHuffEnc7[64][2]; +extern const uint16_t c_aauiLCLDHuffEnc8[81][2]; +extern const uint16_t c_aauiLCLDHuffEnc9[100][2]; +extern const uint16_t c_aauiLCLDHuffEnc10[169][2]; +extern const uint16_t c_aauiLCLDHuffEnc11[196][2]; +extern const uint16_t c_aauiLCLDHuffEnc12[289][2]; +extern const uint16_t c_aauiLCLDHuffEnc13[324][2]; +extern const uint16_t c_aauiLCLDHuffEnc14[400][2]; +extern const uint16_t c_aauiLCLDHuffEnc15[576][2]; +extern const uint16_t c_aauiLCLDHuffEnc16[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc17[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc18[28][2]; +extern const uint16_t c_aauiLCLDHuffEnc19[29][2]; +extern const uint16_t c_aauiLCLDHuffEnc20[32][2]; +extern const uint16_t c_aauiLCLDHuffEnc21[37][2]; +extern const uint16_t c_aauiLCLDHuffEnc22[39][2]; +extern const uint16_t c_aauiLCLDHuffEnc23[46][2]; +extern const uint16_t c_aauiLCLDHuffEnc24[55][2]; +extern const uint16_t c_aauiLCLDHuffEnc25[65][2]; +extern const uint16_t c_aauiLCLDHuffEnc26[77][2]; +extern const uint16_t c_aauiLCLDHuffEnc27[91][2]; +extern const uint16_t c_aauiLCLDHuffEnc28[109][2]; +extern const uint16_t c_aauiLCLDHuffEnc29[129][2]; +extern const uint16_t c_aauiLCLDHuffEnc30[153][2]; +extern const uint16_t c_aauiLCLDHuffEnc31[181][2]; +extern const uint16_t c_aauiLCLDHuffEnc33[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc34[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc35[25][2]; +extern const uint16_t c_aauiLCLDHuffEnc36[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc37[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc38[49][2]; +extern const uint16_t c_aauiLCLDHuffEnc39[64][2]; +extern const uint16_t c_aauiLCLDHuffEnc40[81][2]; +extern const uint16_t c_aauiLCLDHuffEnc41[100][2]; +extern const uint16_t c_aauiLCLDHuffEnc42[169][2]; +extern const uint16_t c_aauiLCLDHuffEnc43[196][2]; +extern const uint16_t c_aauiLCLDHuffEnc44[289][2]; +extern const uint16_t c_aauiLCLDHuffEnc45[324][2]; +extern const uint16_t c_aauiLCLDHuffEnc46[400][2]; +extern const uint16_t c_aauiLCLDHuffEnc47[576][2]; +extern const uint16_t c_aauiLCLDHuffEnc48[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc49[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc50[28][2]; +extern const uint16_t c_aauiLCLDHuffEnc51[29][2]; +extern const uint16_t c_aauiLCLDHuffEnc52[32][2]; +extern const uint16_t c_aauiLCLDHuffEnc53[37][2]; +extern const uint16_t c_aauiLCLDHuffEnc54[39][2]; +extern const uint16_t c_aauiLCLDHuffEnc55[46][2]; +extern const uint16_t c_aauiLCLDHuffEnc56[55][2]; +extern const uint16_t c_aauiLCLDHuffEnc57[65][2]; +extern const uint16_t c_aauiLCLDHuffEnc58[77][2]; +extern const uint16_t c_aauiLCLDHuffEnc59[91][2]; +extern const uint16_t c_aauiLCLDHuffEnc60[109][2]; +extern const uint16_t c_aauiLCLDHuffEnc61[129][2]; +extern const uint16_t c_aauiLCLDHuffEnc62[153][2]; +extern const uint16_t c_aauiLCLDHuffEnc63[181][2]; +extern const uint16_t ( *c_apauiHuffEncTabels[2 * ALLOC_TABLE_SIZE] )[2]; +extern const uint32_t num_row_aauiLCLDHuff[2 * ALLOC_TABLE_SIZE]; + +#ifdef USE_DEMOD_TABLES +extern const int32_t c_aaiHuffDemod1[16][2]; +extern const int32_t c_aaiHuffDemod2[16][2]; +extern const int32_t c_aaiHuffDemod3[25][2]; +extern const int32_t c_aaiHuffDemod4[36][2]; +extern const int32_t c_aaiHuffDemod5[36][2]; +extern const int32_t c_aaiHuffDemod6[49][2]; +extern const int32_t c_aaiHuffDemod7[64][2]; +extern const int32_t c_aaiHuffDemod8[81][2]; +extern const int32_t c_aaiHuffDemod9[100][2]; +extern const int32_t c_aaiHuffDemod10[169][2]; +extern const int32_t c_aaiHuffDemod11[196][2]; +extern const int32_t c_aaiHuffDemod12[289][2]; +extern const int32_t c_aaiHuffDemod13[324][2]; +extern const int32_t c_aaiHuffDemod14[400][2]; +extern const int32_t c_aaiHuffDemod15[576][2]; +extern const int32_t c_aaiHuffDemod16[729][2]; +extern const int32_t c_aaiHuffDemod17[729][2]; +extern const int32_t ( *c_apaiDemodTables[ALLOC_TABLE_SIZE] )[2]; +#endif + +extern const uint32_t c_aaiRMSEnvHuffEnc[64][2]; +extern const uint32_t c_aaiRMSEnvHuffDec[13][HUFF_DEC_TABLE_SIZE]; + +extern const Word32 c_pfMagLUT[8]; /* Q31 */ +extern const Word32 c_pfP2RRealLUT[32]; /* Q31 */ +extern const Word32 c_pfP2RImagLUT[32]; /* Q31 */ +extern const Word32 c_pfWindowLUT[LCLD_PRED_WIN_LEN]; /* Q31 */ + + +#endif /* _TABLES_H_ */ diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h new file mode 100644 index 000000000..24f93b283 --- /dev/null +++ b/lib_isar/isar_prot.h @@ -0,0 +1,465 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_PROT_H +#define ISAR_PROT_H + + +#include "isar_stat.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +#include +#include "options.h" +#include "ivas_error.h" +#include "lib_isar_post_rend.h" +#include "enh64.h" + +Word32 ISAR_SPLIT_REND_BITStream_read_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 bits ); + +void ISAR_SPLIT_REND_BITStream_write_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 val, + const Word32 bits ); + +ivas_error isar_splitBinLCLDEncOpen( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + const int32_t iSampleRate, + const int16_t iChannels, + const int32_t iDataRate, + const int16_t iNumBlocks, + const int16_t iNumIterations ); + +ivas_error isar_splitBinRendPLCOpen( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, + int16_t iNumSubSets ); + +void isar_splitBinRendPLCClose( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ); +ivas_error isar_splitBinLCLDDecOpen( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + const Word32 iSampleRate, + const Word16 iChannels, + const Word16 iNumBlocks, + const Word16 iNumIterations ); +void isar_splitBinLCLDDecClose( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ); + +void isar_splitBinRendPLCsaveState( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations ); + +void isar_splitBinRendPLC_xf_fx( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 num_chs, + const Word16 iNumBlocks, + const Word16 iNumIterations, + Word32 **ppiDecodingFailed, + Word32 **ppiDecodingFailedPrev, + Word16 exp ); + +void isar_splitBinRendPLC( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 num_chs, + const Word16 iNumBlocks, + const Word16 iNumIterations, + Word32 **ppiDecodingFailed, + Word16 exp ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +void isar_log_cldfb2wav_data( + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + HANDLE_CLDFB_FILTER_BANK *cldfbSyn, + const int16_t num_chs, + const int16_t num_freq_bands, + const int32_t output_Fs, + const int16_t start_slot_idx, + const int16_t md_band_idx, + const char *filename ); +#endif + +void isar_SplitRenderer_PostRenderer( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + const IVAS_QUATERNION Quaternion_act ); + +void isar_splitBinLCLDDecProcess( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word32 Cldfb_Out_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 *Q_cldfb_final, + const Word16 bfi ); + +void set_fix_rotation_mat_fx( + Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); +void set_fix_rotation_mat( + float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +void isar_splitBinLCLDEncClose( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); +void isar_splitBinLCLDEncProcess( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word32 available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word16 *q_final ); + +void set_pose_types_fx( + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); +void set_pose_types( + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +void isar_split_rend_init_huff_cfg( + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ); + +ivas_error isar_splitBinPostRendOpen( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs ); + +void isar_splitBinPostRendClose( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ); + +void isar_SplitRenderer_getdiagdiff( + Word16 in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + const Word16 sign, + const Word16 min_val, + const Word16 max_val ); + +void isar_renderSplitGetMultiBinPoseData_fx( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis ); +void isar_renderSplitGetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis ); + +void isar_split_rend_get_quant_params_fx( + const Word16 num_md_bands, + Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word32 pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word32 pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + const Word16 ro_flag, +#endif + Word16 *num_quant_strats +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + , + Word16 *num_complex_bands +#endif +); + +void isar_split_rend_get_quant_params( + const int16_t num_md_bands, + int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t *num_quant_strats, + int16_t *num_complex_bands ); + +void isar_splitBinPostRendMdDec_fx( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend +#endif +); + +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); + +void ivas_mat_mult_2by2_complex( + float in_re1[2][2], + float in_im1[2][2], + float in_re2[2][2], + float in_im2[2][2], + float out_re2[2][2], + float out_im2[2][2] ); + +void isar_mat_mult_2by2_complex_fx( + Word32 in_re1_fx[2][2], + Word16 exp_re1, + Word32 in_im1_fx[2][2], + Word16 exp_im1, + Word32 in_re2_fx[2][2], + Word16 exp_re2, + Word32 in_im2_fx[2][2], + Word16 exp_im2, + Word32 out_re2_fx[2][2], + Word16 *final_exp_re_1, + Word32 out_im2_fx[2][2], + Word16 *final_exp_im_1 ); + +void isar_rend_CldfbSplitPostRendProcess( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION QuaternionPost, + Word32 Cldfb_RealBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word16 Q_cldfb_in, + Word32 output_fx[][L_FRAME48k], + Word16 *Q_out, + const Word16 cldfb_in_flag ); + +void isar_init_multi_bin_pose_data_fx( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +/* Copy for encoder, to be removed */ +void isar_init_multi_bin_pose_data_fx_enc( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); +void isar_init_multi_bin_pose_data( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +void isar_rend_CldfbSplitPreRendProcess( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + const IVAS_QUATERNION headPosition, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re, + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 target_md_bits, + const Word16 low_res_pre_rend_rot, + const Word16 ro_md_flag ); + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +Word16 isar_renderSplitGetRot_axisNumBits( + const Word16 dof ); + +ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( + const Word16 dof, + const Word16 code ); + +Word16 isar_renderSplitGetCodeFromRot_axis( + const Word16 dof, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, + Word16 *num_bits ); +#endif + +void isar_init_split_post_rend_handles( + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); + +ivas_error isar_splitBinPreRendOpen( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs +#else + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#endif +); + +void isar_splitBinPreRendClose( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ); + +void isar_set_split_rend_ht_setup_fx( + SPLIT_REND_WRAPPER *hSplitrend, + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], + Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ); + + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +Word32 isar_get_lc3plus_bitrate( + const Word32 SplitRendBitRate, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const Word16 split_prerender_frame_size_ms ); +#endif + +ivas_error isar_split_rend_validate_config( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const Word16 is_pcm_out ); + +Word32 isar_get_lcld_bitrate( + const Word32 SplitRendBitRate, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +Word8 isar_get_lc3plus_bitrate_id( + const Word32 SplitRendBitRate ); +#endif + +ivas_error splitRendLc3plusEncodeAndWrite( + SPLIT_REND_WRAPPER *hSplitBin, + ISAR_SPLIT_REND_BITS_HANDLE pBits, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int32_t available_bits, +#else + const int32_t SplitRendBitRate, +#endif + Word32 *in[], + Word16 Q_sig ); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error isar_framesize_to_ms( + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + Word16 *ms /* o : frame size in ms */ +); +#endif +Word32 isar_get_split_rend_md_target_brate( + const Word32 SplitRendBitRate, + const Word16 pcm_out_flag ); + +ivas_error isar_split_rend_choose_default_codec( + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ +#endif + Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ + const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ + const Word16 num_subframes /* i : number of subframes */ +); + +void ISAR_SPLIT_REND_BITStream_init( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 buf_len_bytes, + UWord8 *pbuf ); + +void isar_split_rend_huffman_dec_init_min_max_len( + isar_split_rend_huffman_cfg_t *p_huff_cfg ); + +Word16 wrap_a( + Word16 val, + const Word16 min_val, + const Word16 max_val ); +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +Word32 isar_get_lc3plus_size_from_id( + const Word8 SplitRendBitRateId, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const Word16 split_prerender_frame_size_ms ); +#endif + +void isar_renderSplitUpdateNoCorrectionPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +Word32 get_bit( + const Word32 state, + const Word32 bit_id ); + +ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const Word32 OutSampleRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE ivas_frame_size +#else + const int16_t num_subframes +#endif +); + +ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( + const IVAS_AUDIO_CONFIG config ); + +void isar_init_split_rend_handles( + SPLIT_REND_WRAPPER *hSplitRendWrapper ); + +ivas_error isar_renderMultiTDBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const Word32 SplitRendBitRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const Word16 isar_frame_size_ms, +#endif + const Word16 codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word16 max_bands, + // float *in[], + Word32 *in_fx[], // Q11 + Word16 Q_sig, + const Word16 low_res_pre_rend_rot, + const Word16 pcm_out_flag, + const Word16 ro_md_flag ); + +void lc3plusTimeAlignCldfbPoseCorr( SPLIT_REND_WRAPPER *hSplitBin, + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 *Q_in ); + +#endif +void set16_fx( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +Word16 ceil_log_2( + UWord64 val ); +/* clang-format on */ + +#endif /* IVAS_PROT_REND_H */ diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c new file mode 100644 index 000000000..13a786b16 --- /dev/null +++ b/lib_isar/isar_rom_post_rend.c @@ -0,0 +1,196 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "cnst.h" +#include "isar_cnst.h" +#include +#include "wmc_auto.h" + +/* clang-format off */ + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------* + * Binuaral split rendering ROM tables + *-----------------------------------------------------------------------*/ + +/* rotations in this array are relative to ref rotation */ +const Word32 ivas_split_rend_relative_yaw_pos_angles_fx[SPLIT_REND_MAX_YAW_ONLY_POSES] = { -62914560, 62914560 }; /* Q22 */ +const Word32 ivas_split_rend_relative_pitch_pos_angles_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES] = { 41943040, 41943040 }; /* Q22 */ +const Word32 ivas_split_rend_relative_roll_pos_angles_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES] = { 41943040, 41943040 }; /* Q22 */ +const float ivas_split_rend_relative_yaw_pos_angles[SPLIT_REND_MAX_YAW_ONLY_POSES] = {-15.0f, 15.0f}; +const float ivas_split_rend_relative_pitch_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {10.0f, 10.0f}; +const float ivas_split_rend_relative_roll_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {10.0f, 10.0f}; +const float ivas_split_rend_relative_one_axis_pos_angles[SPLIT_REND_MAX_ONE_AXIS_MD_POSES] = {-15.0f, 15.0f}; + +const Word32 ivas_split_rend_relative_yaw_pos_angles_hq_fx[SPLIT_REND_MAX_YAW_ONLY_POSES] = { -62914560, 62914560 }; /* Q22 */ +const Word32 ivas_split_rend_relative_pitch_pos_angles_hq_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES] = { -62914560, 62914560 }; /* Q22 */ +const Word32 ivas_split_rend_relative_roll_pos_angles_hq_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES] = { -62914560, 62914560 }; /* Q22 */ +const float ivas_split_rend_relative_yaw_pos_angles_hq[SPLIT_REND_MAX_YAW_ONLY_POSES] = {-15.0f, 15.0f}; +const float ivas_split_rend_relative_pitch_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {-15.0f, 15.0f}; +const float ivas_split_rend_relative_roll_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {-15.0f, 15.0f}; +const float ivas_split_rend_relative_one_axis_pos_angles_hq[SPLIT_REND_MAX_ONE_AXIS_MD_POSES] = {-15.0f, 15.0f}; + +/* Values in degrees : -30, -22.5, -15, 0, 15, 22.5 and 30 */ +const Word32 ivas_split_rend_fix_pos_rot_mat_cos_fx[4] = { ONE_IN_Q31, 2074309917, 1984016189, 1859775393 }; /* Q31 */ + +const int16_t isar_split_rend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 20, 25, 30, 35, 40, 50, 60 +}; + +const int32_t ivas_split_rend_huff_p_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3] = +{ + {0,8,252},{1,8,253},{2,7,124},{3,6,60},{4,5,28},{5,4,12}, + {6,3,4},{7,1,0},{8,3,5},{9,4,13},{10,5,29},{11,6,61}, + {12,7,125},{13,8,254},{14,8,255} +}; + +const int32_t ivas_split_rend_huff_p_d_diff_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3] = +{ + { 0, 1, 0 },{ 1, 2, 2 },{ 2, 3, 6 },{ 3, 4, 14 }, + { 4, 5, 30 },{ 5, 6, 62 },{ 6, 7, 126 },{ 7, 8, 254 }, + { 8, 9, 510 },{ 9, 10, 1022 },{ 10, 11, 2046 },{ 11, 12, 4094 }, + { 12, 13, 8190 },{ 13, 14, 16382 },{ 14, 14, 16383 } +}; + +const int32_t ivas_split_rend_huff_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3] = +{ + { 0, 1, 0 },{ 1, 2, 2 },{ 2, 3, 6 },{ 3, 4, 14 }, + { 4, 5, 30 },{ 5, 6, 62 },{ 6, 7, 126 },{ 7, 8, 254 }, + { 8, 9, 510 },{ 9, 10, 1022 },{ 10, 11, 2046 },{ 11, 12, 4094 }, + { 12, 13, 8190 },{ 13, 14, 16382 },{ 14, 14, 16383 } +}; + +const int32_t ivas_split_rend_huff_pred63_consts[ISAR_SPLIT_REND_PRED_63QUANT_PNTS][3] = +{ + {-31,11,2040}, + {-30,11,2041}, + {-29,11,2042}, + {-28,11,2043}, + {-27,10,1012}, + {-26,10,1013}, + {-25,10,1014}, + {-24,10,1015}, + {-23,9,498}, + {-22,9,499}, + {-21,9,500}, + {-20,9,501}, + {-19,8,242}, + {-18,8,243}, + {-17,8,244}, + {-16,8,245}, + {-15,7,112}, + {-14,7,113}, + {-13,7,114}, + {-12,7,115}, + {-11,6,48}, + {-10,6,49}, + {-9,6,50}, + {-8,6,51}, + {-7,5,16}, + {-6,5,17}, + {-5,5,18}, + {-4,5,19}, + {-3,4,2}, + {-2,4,3}, + {-1,4,4}, + {0,3,0}, + {1,4,5}, + {2,4,6}, + {3,4,7}, + {4,5,20}, + {5,5,21}, + {6,5,22}, + {7,5,23}, + {8,6,52}, + {9,6,53}, + {10,6,54}, + {11,6,55}, + {12,7,116}, + {13,7,117}, + {14,7,118}, + {15,7,119}, + {16,7,120}, + {17,8,246}, + {18,8,247}, + {19,8,248}, + {20,9,502}, + {21,9,503}, + {22,9,504}, + {23,9,505}, + {24,10,1016}, + {25,10,1017}, + {26,10,1018}, + {27,10,1019}, + {28,11,2044}, + {29,11,2045}, + {30,11,2046}, + {31,11,2047}, +}; + +const int32_t ivas_split_rend_huff_pred31_consts[ISAR_SPLIT_REND_PRED_31QUANT_PNTS][3] = +{ + {-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, + {-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, + {-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, + {-2,4,9},{-1,3,2},{0,2,0},{1,3,3}, + {2,4,10},{3,4,11},{4,5,26},{5,5,27}, + {6,6,58},{7,6,59},{8,7,122},{9,7,123}, + {10,7,124},{11,8,252},{12,9,508},{13,9,509}, + {14,10,1022},{15,10,1023}, +}; + +const int32_t ivas_split_rend_huff_roll_pred_consts[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS][3] = +{ + {-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, + {-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, + {-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, + {-2,4,9},{-1,3,2},{0,2,0},{1,3,3}, + {2,4,10},{3,4,11},{4,5,26},{5,5,27}, + {6,6,58},{7,6,59},{8,7,122},{9,7,123}, + {10,7,124},{11,8,252},{12,9,508},{13,9,509}, +{14,10,1022},{15,10,1023}, +}; + +#endif + +/* Tables for split renderer fixed converison */ +const Word16 fade_table_fx[4] = +{ 8192, 16384, 24576, 32767 }; + +/* clang-format on */ diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h new file mode 100644 index 000000000..2bfac9140 --- /dev/null +++ b/lib_isar/isar_rom_post_rend.h @@ -0,0 +1,82 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_ROM_POST_REND_H +#define ISAR_ROM_POST_REND_H + +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "cnst.h" +#include "isar_cnst.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------* + * Binuaral split rendering ROM tables + *-----------------------------------------------------------------------*/ + +extern const Word32 ivas_split_rend_relative_yaw_pos_angles_fx[SPLIT_REND_MAX_YAW_ONLY_POSES]; +extern const Word32 ivas_split_rend_relative_pitch_pos_angles_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const Word32 ivas_split_rend_relative_roll_pos_angles_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float ivas_split_rend_relative_yaw_pos_angles[SPLIT_REND_MAX_YAW_ONLY_POSES]; +extern const float ivas_split_rend_relative_pitch_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float ivas_split_rend_relative_roll_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float ivas_split_rend_relative_one_axis_pos_angles[SPLIT_REND_MAX_ONE_AXIS_MD_POSES]; +extern const float ivas_split_rend_relative_one_axis_pos_angles_hq[SPLIT_REND_MAX_ONE_AXIS_MD_POSES]; + +extern const Word32 ivas_split_rend_relative_yaw_pos_angles_hq_fx[SPLIT_REND_MAX_YAW_ONLY_POSES]; +extern const Word32 ivas_split_rend_relative_pitch_pos_angles_hq_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const Word32 ivas_split_rend_relative_roll_pos_angles_hq_fx[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float ivas_split_rend_relative_yaw_pos_angles_hq[SPLIT_REND_MAX_YAW_ONLY_POSES]; +extern const float ivas_split_rend_relative_pitch_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float ivas_split_rend_relative_roll_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES]; + +/* Values in degrees : -30, -22.5, -15, 0, 15, 22.5 and 30 */ +extern const Word32 ivas_split_rend_fix_pos_rot_mat_cos_fx[4]; /* Q31 */ + +extern const float ivas_split_rend_relative_pos_angles[MAX_HEAD_ROT_POSES][3]; +extern const int16_t isar_split_rend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1]; +extern const int32_t ivas_split_rend_huff_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; +extern const int32_t ivas_split_rend_huff_pred63_consts[ISAR_SPLIT_REND_PRED_31QUANT_PNTS][3]; +extern const int32_t ivas_split_rend_huff_pred31_consts[ISAR_SPLIT_REND_PRED_31QUANT_PNTS][3]; +extern const int32_t ivas_split_rend_huff_roll_pred_consts[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS][3]; +extern const int32_t ivas_split_rend_huff_p_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; +extern const int32_t ivas_split_rend_huff_p_d_diff_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; +extern const int32_t split_rend_brate_tbl[]; +#endif + +/* Tables for fixed point conversion */ +extern const Word16 fade_table_fx[4]; + +#endif diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c new file mode 100644 index 000000000..7e5c3e2bb --- /dev/null +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -0,0 +1,284 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_prot.h" +#include "ivas_prot.h" +#include "prot.h" +#include "control.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDDecOpen() + * + * + *------------------------------------------------------------------------*/ +ivas_error isar_splitBinLCLDDecOpen( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + const Word32 iSampleRate, + const Word16 iChannels, + const Word16 iNumBlocks, + const Word16 iNumIterations ) +{ + int16_t n; + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE splitBinLCLDDec; + ivas_error error; + + IF( ( splitBinLCLDDec = (ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_LCLD_DEC ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + + splitBinLCLDDec->pLcld_dec = NULL; /* place holder for CLDFB decoder handle */ + + splitBinLCLDDec->iChannels = iChannels; + + IF( ( error = CreateLCLDDecoder( &splitBinLCLDDec->psLCLDDecoder, iSampleRate, iChannels, iNumBlocks, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( ( splitBinLCLDDec->pppfDecLCLDReal_fx = (Word32 ***) malloc( iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( splitBinLCLDDec->pppfDecLCLDImag_fx = (Word32 ***) malloc( iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + + FOR( n = 0; n < splitBinLCLDDec->iChannels; n++ ) + { + IF( ( splitBinLCLDDec->pppfDecLCLDReal_fx[n] = (Word32 **) malloc( CLDFB_NO_COL_MAX * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + IF( ( splitBinLCLDDec->pppfDecLCLDImag_fx[n] = (Word32 **) malloc( CLDFB_NO_COL_MAX * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + } +#ifdef CLDFB_DEBUG + splitBinLCLDDec->numFrame = 0; + char cldfbFilename[50] = "cldfb_out.bin"; + if ( ( splitBinLCLDDec->cldfbOut = fopen( cldfbFilename, "wb" ) ) == NULL ) + { + fprintf( stderr, "Error: CLDFB bitstream file %s could not be opened\n\n", cldfbFilename ); + exit( -1 ); + } + int16_t num_bands = CLDFB_NO_CHANNELS_MAX; + fwrite( &iChannels, sizeof( int16_t ), 1, splitBinLCLDDec->cldfbOut ); + fwrite( &num_bands, sizeof( int16_t ), 1, splitBinLCLDDec->cldfbOut ); +#endif + + IF( ( error = isar_splitBinRendPLCOpen( &splitBinLCLDDec->hSplitRendPLC, GetNumSubSets( splitBinLCLDDec->psLCLDDecoder ) ) ) != IVAS_ERR_OK ) + { + return error; + } + splitBinLCLDDec->iNumBlocks = iNumBlocks; + splitBinLCLDDec->iNumIterations = iNumIterations; + + *hSplitBinLCLDDec = splitBinLCLDDec; + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDDecClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinLCLDDecClose( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ) +{ + Word16 n; + + IF( ( *hSplitBinLCLDDec ) != NULL ) + { + IF( ( *hSplitBinLCLDDec )->psLCLDDecoder != NULL ) + { + DeleteLCLDDecoder( ( *hSplitBinLCLDDec )->psLCLDDecoder ); + } + + FOR( n = 0; n < ( *hSplitBinLCLDDec )->iChannels; n++ ) + { + free( ( *hSplitBinLCLDDec )->pppfDecLCLDReal_fx[n] ); + free( ( *hSplitBinLCLDDec )->pppfDecLCLDImag_fx[n] ); + } + free( ( *hSplitBinLCLDDec )->pppfDecLCLDReal_fx ); + free( ( *hSplitBinLCLDDec )->pppfDecLCLDImag_fx ); + +#ifdef CLDFB_DEBUG + if ( ( *hSplitBinLCLDDec )->cldfbOut != NULL ) + { + fclose( ( *hSplitBinLCLDDec )->cldfbOut ); + } +#endif + isar_splitBinRendPLCClose( &( *hSplitBinLCLDDec )->hSplitRendPLC ); + + free( *hSplitBinLCLDDec ); + *hSplitBinLCLDDec = NULL; + } + + return; +} + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDDecProcess() + * + * + *------------------------------------------------------------------------*/ +void isar_splitBinLCLDDecProcess( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word32 Cldfb_Out_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 *Q_cldfb_final, + const Word16 bfi ) +{ + Word16 k, n; + Word16 itr; + *Q_cldfb_final = 11; + push_wmops( "isar_splitBinLCLDDecProcess" ); + + assert( hSplitBinLCLDDec != NULL ); + assert( Cldfb_Out_Real_fx != NULL ); + assert( Cldfb_Out_Imag_fx != NULL ); + assert( pBits != NULL ); +#ifdef CLDFB_DEBUG + printf( "Bytes read = %d\n", iBytesWritten ); +#endif + IF( !bfi ) + { + FOR( itr = 0; itr < hSplitBinLCLDDec->iNumIterations; itr++ ) + { + /* Initialized with zeros....... */ + FOR( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) + { + FOR( k = 0; k < hSplitBinLCLDDec->iNumBlocks; k++ ) + { + hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k] = Cldfb_Out_Real_fx[n][hSplitBinLCLDDec->iNumBlocks * itr + k]; + hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k] = Cldfb_Out_Imag_fx[n][hSplitBinLCLDDec->iNumBlocks * itr + k]; + set_l( hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k], 0, CLDFB_NO_CHANNELS_MAX ); + set_l( hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + + Word16 Q_in = 14; + DecodeLCLDFrame( hSplitBinLCLDDec->psLCLDDecoder, pBits, hSplitBinLCLDDec->pppfDecLCLDReal_fx, hSplitBinLCLDDec->pppfDecLCLDImag_fx, Q_in, Q_cldfb_final ); + +#ifdef CLDFB_DEBUG + printf( "Frame Decoded = %d\n", ++hSplitBinLCLDDec->numFrame ); + int16_t writeByte = 0; + for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) + { + for ( int16_t b = 0; b < CLDFB_NO_CHANNELS_MAX; b++ ) + { + for ( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) + { + writeByte = fwrite( &hSplitBinLCLDDec->pppfDecLCLDReal[n][k][b], sizeof( float ), 1, hSplitBinLCLDDec->cldfbOut ); + if ( writeByte != 1 ) + exit( -1 ); + writeByte = fwrite( &hSplitBinLCLDDec->pppfDecLCLDImag[n][k][b], sizeof( float ), 1, hSplitBinLCLDDec->cldfbOut ); + if ( writeByte != 1 ) + exit( -1 ); + } + } + } +#endif + IF( AnyDecodingFailed( hSplitBinLCLDDec->psLCLDDecoder ) ) + { + IF( NE_16( *Q_cldfb_final, 11 ) ) + { + FOR( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) + { + FOR( k = 0; k < hSplitBinLCLDDec->iNumBlocks; k++ ) + { + FOR( Word16 j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j], sub( 11, *Q_cldfb_final ) ); // Q11 + hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j], sub( 11, *Q_cldfb_final ) ); // Q11 + } + } + } + *Q_cldfb_final = 11; + } + /* continue concealing */ + isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); + } + IF( AnyDecodingFailedPrev( hSplitBinLCLDDec->psLCLDDecoder ) ) + { + IF( NE_16( *Q_cldfb_final, 11 ) ) + { + FOR( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) + { + FOR( k = 0; k < hSplitBinLCLDDec->iNumBlocks; k++ ) + { + FOR( Word16 j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j], sub( 11, *Q_cldfb_final ) ); // Q11 + hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j], sub( 11, *Q_cldfb_final ) ); // Q11 + } + } + } + *Q_cldfb_final = 11; + } + /* cross-fade recovered frame into good frame */ + isar_splitBinRendPLC_xf_fx( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), GetDecodingFailedPrevStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); + } + } + } + ELSE + { + /* set states in decoder */ + SetDecodingUnresolved( hSplitBinLCLDDec->psLCLDDecoder ); + + /* do PLC for lost split renderer frame */ + isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); + } + + /* save PLC state */ + isar_splitBinRendPLCsaveState( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations ); + hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx = *Q_cldfb_final; + move16(); + pop_wmops(); + + return; +} +#endif diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c new file mode 100644 index 000000000..0f442a2f2 --- /dev/null +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -0,0 +1,239 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_prot.h" +#include "ivas_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDEncOpen() + * + * + *------------------------------------------------------------------------*/ +ivas_error isar_splitBinLCLDEncOpen( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + const Word32 iSampleRate, + const Word16 iChannels, + const Word32 iDataRate, + const Word16 iNumBlocks, + const Word16 iNumIterations ) +{ + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE splitBinLCLDEnc; + ivas_error error; + + IF( ( splitBinLCLDEnc = (ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_LCLD_ENC ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + splitBinLCLDEnc->pLcld_enc = NULL; /* place holder for CLDFB encoder handle*/ + + splitBinLCLDEnc->iChannels = iChannels; + IF( ( error = CreateLCLDEncoder( &( splitBinLCLDEnc->psLCLDEncoder ), iSampleRate, iChannels, iDataRate, 1, iNumBlocks, (Word16) CLDFB_NO_COL_MAX / iNumBlocks, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( ( splitBinLCLDEnc->pppfLCLDReal_fx = (Word32 ***) malloc( iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( splitBinLCLDEnc->pppfLCLDImag_fx = (Word32 ***) malloc( iChannels * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + FOR( Word16 n = 0; n < splitBinLCLDEnc->iChannels; n++ ) + { + IF( ( splitBinLCLDEnc->pppfLCLDReal_fx[n] = (Word32 **) malloc( CLDFB_NO_COL_MAX * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + IF( ( splitBinLCLDEnc->pppfLCLDImag_fx[n] = (Word32 **) malloc( CLDFB_NO_COL_MAX * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + } + + splitBinLCLDEnc->iNumIterations = iNumIterations; + splitBinLCLDEnc->iNumBlocks = iNumBlocks; + +#ifdef CLDFB_DEBUG + splitBinLCLDEnc->numFrame = 0; + char cldfbFilename[50] = "cldfb_in_ref.qmf"; + if ( ( splitBinLCLDEnc->cldfbIn = fopen( cldfbFilename, "rb" ) ) == NULL ) + { + fprintf( stderr, "Error: CLDFB bitstream file %s could not be opened\n\n", cldfbFilename ); + exit( -1 ); + } + int16_t chan, band; + fread( &chan, sizeof( int16_t ), 1, splitBinLCLDEnc->cldfbIn ); + fread( &band, sizeof( int16_t ), 1, splitBinLCLDEnc->cldfbIn ); +#endif + + *hSplitBinLCLDEnc = splitBinLCLDEnc; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDEncClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinLCLDEncClose( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ) +{ + IF( ( *hSplitBinLCLDEnc ) != NULL ) + { + DeleteLCLDEncoder( ( *hSplitBinLCLDEnc )->psLCLDEncoder ); + + FOR( int16_t n = 0; n < ( *hSplitBinLCLDEnc )->iChannels; n++ ) + { + free( ( *hSplitBinLCLDEnc )->pppfLCLDReal_fx[n] ); + free( ( *hSplitBinLCLDEnc )->pppfLCLDImag_fx[n] ); + } + free( ( *hSplitBinLCLDEnc )->pppfLCLDReal_fx ); + free( ( *hSplitBinLCLDEnc )->pppfLCLDImag_fx ); +#ifdef CLDFB_DEBUG + if ( ( *hSplitBinLCLDEnc )->cldfbIn != NULL ) + { + fclose( ( *hSplitBinLCLDEnc )->cldfbIn ); + } +#endif + + free( *hSplitBinLCLDEnc ); + *hSplitBinLCLDEnc = NULL; + } + + return; +} + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDEncProcess() + * + * + *------------------------------------------------------------------------*/ +void isar_splitBinLCLDEncProcess( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + Word32 Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word32 available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word16 *q_final ) +{ + Word32 iBitsWritten, itr, available_bits_itr, rem_itr, available_bits_local; + push_wmops( "isar_splitBinLCLDEncProcess" ); + assert( hSplitBinLCLDEnc != NULL ); + assert( Cldfb_In_Real_fx != NULL ); + assert( Cldfb_In_Imag_fx != NULL ); + assert( pBits != NULL ); + + available_bits_local = available_bits; + move32(); + Word16 tmp, tmp_e; + /* A conversion is needed for the 3d pointer interface here ........ */ + FOR( itr = 0; itr < hSplitBinLCLDEnc->iNumIterations; itr++ ) + { + + rem_itr = L_sub( hSplitBinLCLDEnc->iNumIterations, itr ); + tmp = BASOP_Util_Divide3232_Scale( available_bits_local, rem_itr, &tmp_e ); + available_bits_itr = shr( tmp, sub( 15, tmp_e ) ); // Q0 + // available_bits_itr = available_bits_local / rem_itr; + FOR( Word32 n = 0; n < hSplitBinLCLDEnc->iChannels; n++ ) + { + FOR( Word32 k = 0; k < hSplitBinLCLDEnc->iNumBlocks; k++ ) + { + hSplitBinLCLDEnc->pppfLCLDReal_fx[n][k] = Cldfb_In_Real_fx[n][hSplitBinLCLDEnc->iNumBlocks * itr + k]; + hSplitBinLCLDEnc->pppfLCLDImag_fx[n][k] = Cldfb_In_Imag_fx[n][hSplitBinLCLDEnc->iNumBlocks * itr + k]; + } + } +#ifdef CLDFB_DEBUG + int16_t readByte = 0; + for ( int16_t k = 0; k < hSplitBinLCLDEnc->iNumBlocks; k++ ) + { + for ( int16_t b = 0; b < CLDFB_NO_CHANNELS_MAX; b++ ) + { + for ( int16_t n = 0; n < hSplitBinLCLDEnc->iChannels; n++ ) + { + readByte = fread( &hSplitBinLCLDEnc->pppfLCLDReal[n][k][b], sizeof( float ), 1, hSplitBinLCLDEnc->cldfbIn ); + if ( readByte != 1 ) + break; + readByte = fread( &hSplitBinLCLDEnc->pppfLCLDReal[n][k][b], sizeof( float ), 1, hSplitBinLCLDEnc->cldfbIn ); + } + } + } + + if ( readByte == 1 ) + { + printf( "Frame Read = %d\n", ++hSplitBinLCLDEnc->numFrame ); + } + else + { + printf( "Writing zeroes...\n" ); + for ( int16_T k = 0; k < hSplitBinLCLDEnc->iNumBlocks; k++ ) + { + for ( int16_t b = 0; b < CLDFB_NO_CHANNELS_MAX; b++ ) + { + for ( int16_t n = 0; n < hSplitBinLCLDEnc->iChannels; n++ ) + { + hSplitBinLCLDEnc->pppfLCLDReal[n][k][b] = 0.f; + hSplitBinLCLDEnc->pppfLCLDImag[n][k][b] = 0.f; + } + } + } + } +#endif + EncodeLCLDFrame( hSplitBinLCLDEnc->psLCLDEncoder, hSplitBinLCLDEnc->pppfLCLDReal_fx, hSplitBinLCLDEnc->pppfLCLDImag_fx, &iBitsWritten, available_bits_itr, pBits, q_final ); + + available_bits_local = L_sub( available_bits_local, iBitsWritten ); +#ifdef DEBUGGING + assert( available_bits_local >= 0 ); +#endif + +#ifdef CLDFB_DEBUG + printf( "Bits written = %d\n", iBitsWritten ); +#endif + } + pop_wmops(); + + return; +} +#endif diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c new file mode 100644 index 000000000..152fe52f3 --- /dev/null +++ b/lib_isar/isar_splitRendererPLC.c @@ -0,0 +1,1316 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "ivas_prot.h" +#include "prot.h" +#include "isar_cnst.h" +#include "isar_prot.h" +#include "enh64.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" +#include "prot_fx2.h" +#include "basop_util.h" +#include "basop_mpy.h" +#include "enh64.h" + +/*------------------------------------------------------------------------- + * Local constants + *------------------------------------------------------------------------*/ +#define PI_CONST ( 341782638 ) // Q31 +#define DO_PERTURB 1 +#define PH_PERT_ONLY 1 +#define START_VAL_AVG_LEN 2 +#define SR_PLC_FADE_START 10 /* start fading at this number of bad frames in row */ +#define SR_PLC_MUTE 30 /* Total mute at this number of bad frames in row */ +#define SR_PLC_FADE_DEGREE -3 /* fading degree per frame in dB */ +#define SRHO_THRESH ( 2.f / 3.f * 0.1f ) +#define SRHO_THRESH_FX ( 143165584 ) +#define STH_THRESH_FX ( 749613227 ) +#define STH_THRESH ( 2.f / 3.f * PI2 / 12 ) +#define PLC_FADE_CNST SR_PLC_FADE_START *CLDFB_NO_COL_MAX +#define PLC_MUTE_CNST SR_PLC_MUTE *CLDFB_NO_COL_MAX +Word32 xf_alp_tab[CLDFB_PLC_XF] = { 1431655680, 715827840 }; +static Word16 find_guarded_bits_fx( Word32 n ) +{ + return n <= 1 ? 0 : n <= 2 ? 1 + : n <= 4 ? 2 + : n <= 8 ? 3 + : n <= 16 ? 4 + : n <= 32 ? 5 + : n <= 64 ? 6 + : n <= 128 ? 7 + : n <= 256 ? 8 + : n <= 512 ? 9 + : n <= 1024 ? 10 + : n <= 2048 ? 11 + : n <= 4096 ? 12 + : n <= 8192 ? 13 + : n <= 16384 ? 14 + : 15; +} + +/*------------------------------------------------------------------------- + * Function adaptive_polar_ext_plc() + * + * + *------------------------------------------------------------------------*/ +static void adaptive_polar_ext_plc_fx( + const Word32 *prev_real_fx, + const Word32 *prev_imag_fx, + Word32 *rec_real_fx, + Word32 *rec_imag_fx, + Word16 *rec_real_exp, + Word16 *rec_imag_exp +#if CLDFB_PLC_XF > 0 + , + Word32 xf_alp_fx[CLDFB_PLC_XF], + Word32 xf_bet_fx[CLDFB_PLC_XF] +#endif + , + Word16 exp, + const Word16 iNumCols ) + +{ + /*TODO: Add basops and instrumentation where ever possible*/ + Word32 uth_fx[CLDFB_NO_COL_MAX], urh_fx[CLDFB_NO_COL_MAX]; + Word64 uthu_fx[CLDFB_NO_COL_MAX], drho_fx, srho_fx, diff_fx, dth_fx, sth_fx, ph_adj_fx, rat_real_fx, rat_imag_fx; + Word32 ph_diff_fx, ph_adj_t_fx, quot_fx, dth32, fac_real_fx, fac_imag_fx, rat_real32_fx, rat_imag32_fx, abs2inv_fx; + Word16 srho_q, sth_q, dth16, drho_q, rat_real_q, rat_imag_q, temp_16, rat_real_sum_q, rat_imag_sum_q, start_q, fac_real_q, fac_imag_q; + Word64 Ruu_real_fx[2], Ruu_imag_fx[2], abs_fac_fx; + Word32 Ruu_real_fx_1, Ruu_imag_fx_1, Ruu_real_fx_0, abs_fac_32, abs_fac_powj_32, comp_fac_fx; + Word16 Ruu_real_fx_1_q, Ruu_imag_fx_1_q, Ruu_real_fx_0_q, dth_q, urh_exp[CLDFB_NO_COL_MAX]; + Word32 fac_ph_real_fx, fac_ph_imag_fx, abs_temp_fx; + Word32 start_real_fx, start_imag_fx, fac_powj_real_fx, fac_powj_imag_fx, temp_fx; + Word32 k, j; + Word16 quot_exp[CLDFB_NO_COL_MAX]; + Word16 drho_exp[CLDFB_NO_COL_MAX]; + Word16 srho_exp[CLDFB_NO_COL_MAX]; + /* Word16 rec_real_exp[CLDFB_NO_COL_MAX + CLDFB_PLC_XF]; + Word16 rec_imag_exp[CLDFB_NO_COL_MAX + CLDFB_PLC_XF];*/ + /* reset of accumulators */ + ph_adj_fx = 0; + drho_fx = 0; + srho_fx = 0; + dth_fx = 0; + sth_fx = 0; + Word16 sqrt_exp = 0, sqrt_exp1; + Word32 temp_32; + Word16 lshift; + Word64 temp_64, real_sum, imag_sum; + /* calculate per-sample phase and magnitude evolution in preceding frame */ + FOR( k = 0; k < iNumCols; k++ ) + { + real_sum = W_mult_32_32( prev_real_fx[k], prev_real_fx[k] ); + rat_real_sum_q = add( shl( exp, 1 ), 1 ); + imag_sum = W_mult_32_32( prev_imag_fx[k], prev_imag_fx[k] ); + rat_imag_sum_q = add( shl( exp, 1 ), 1 ); + temp_64 = W_add( real_sum, imag_sum ); + lshift = W_norm( temp_64 ); + temp_32 = W_extract_h( W_shl( temp_64, lshift ) ); + sqrt_exp = sub( add( shl( exp, 1 ), lshift ), 31 ); + sqrt_exp = sub( 31, sqrt_exp ); + urh_fx[k] = Sqrt32( temp_32, &sqrt_exp ); + urh_exp[k] = sub( 31, sqrt_exp ); + // In Float the condition is if ( urh[k] < EPSILON ) + IF( EQ_32( urh_fx[k], 0 ) ) + { + /* zero encountered */ + BREAK; + } + + uth_fx[k] = L_shl( BASOP_util_atan2( prev_imag_fx[k], prev_real_fx[k], 0 ), 15 ); // Q28 + /* phase unwrap */ + IF( EQ_32( k, 0 ) ) + { + uthu_fx[0] = uth_fx[0]; + } + ELSE + { + /* phase unwrap */ + ph_diff_fx = L_sub( uth_fx[k], uth_fx[k - 1] ); + + uthu_fx[k] = uth_fx[k]; + Word32 quot_fx_durho; + Word16 s = 0, s_diff; + Word32 add_fact, quo_sq; + IF( GE_32( L_abs( ph_diff_fx ), L_shr( PI2_FX, 2 ) ) ) + { + temp_32 = L_deposit_h( BASOP_Util_Divide3232_Scale( ph_diff_fx, PI2_FX, &s ) ); // Q(31) + ph_adj_t_fx = ( temp_32 == ONE_IN_Q30 ) ? L_sub( ONE_IN_Q31, 1 ) : L_shl( temp_32, s ); + IF( EQ_32( L_abs( L_sub( L_add( ph_adj_t_fx, 1 ), L_shr( ph_adj_t_fx, 31 ) ) ), ONE_IN_Q30 ) ) + { + ph_adj_t_fx = L_shr( ph_adj_t_fx, 31 ); + } + add_fact = ( L_abs( ph_adj_t_fx ) >= ONE_IN_Q30 ) ? ( ( ph_adj_t_fx < 0 ) ? 1686629713 : -1686629713 ) : 0; + ph_adj_fx = W_add( add_fact, ph_adj_fx ); // Q28 + } + /* unwrapped phase in uthu */ + uthu_fx[k] = W_add( uthu_fx[k], ph_adj_fx ); // Q28 + /* mean and stdev of per-sample magnitude ratios */ + s_diff = sub( urh_exp[k - 1], urh_exp[k] ); + temp_16 = BASOP_Util_Divide3232_Scale( urh_fx[k], urh_fx[k - 1], &s ); + quot_fx = L_shl( temp_16, 16 ); // Q(31-s) + quot_exp[k] = sub( sub( 31, s_diff ), s ); + quot_fx_durho = quot_fx; + drho_exp[k] = quot_exp[k]; + IF( GE_32( k, 2 ) ) + { + IF( LT_16( drho_exp[k - 1], drho_exp[k] ) ) + { + quot_fx_durho = L_shr( quot_fx_durho, sub( drho_exp[k], drho_exp[k - 1] ) ); + drho_exp[k] = drho_exp[k - 1]; + } + ELSE IF( GT_16( drho_exp[k - 1], drho_exp[k] ) ) + { + drho_fx = W_shr( drho_fx, sub( drho_exp[k - 1], drho_exp[k] ) ); + } + } + drho_fx = W_add( quot_fx_durho, drho_fx ); // Q(31-s) + srho_exp[k] = sub( 31, shl( add( s_diff, s ), 1 ) ); + quo_sq = Mpy_32_32( quot_fx, quot_fx ); + IF( GE_32( k, 2 ) ) + { + IF( LT_16( srho_exp[k - 1], srho_exp[k] ) ) + { + quo_sq = L_shr( quo_sq, sub( srho_exp[k], srho_exp[k - 1] ) ); + srho_exp[k] = srho_exp[k - 1]; + } + ELSE IF( GT_16( srho_exp[k - 1], srho_exp[k] ) ) + { + srho_fx = W_shr( srho_fx, sub( srho_exp[k - 1], srho_exp[k] ) ); + } + } + srho_fx = W_add( srho_fx, quo_sq ); // Q(31-s) + diff_fx = W_sub( uthu_fx[k], uthu_fx[k - 1] ); // Q28 /* the mean value calculation could be optimized */ + + dth_fx = W_add( dth_fx, diff_fx ); // Q28 + temp_32 = W_extract_l( diff_fx ); + sth_fx = W_add( sth_fx, (Word64) Mpy_32_32( temp_32, temp_32 ) ); // Q25 + + /* mean and stdev of per-sample phase differences */ + } + } + + Word16 tmp_e, tmp, drho_sqr_q, temp_q; + Word32 divide_fact, drho_32, drho_sqr, dth_sqr; + IF( EQ_32( k, iNumCols ) ) + { + + tmp = BASOP_Util_Divide1616_Scale( 1, sub( iNumCols, 1 ), &tmp_e ); + divide_fact = L_shl( tmp, sub( 31, add( 15, negate( tmp_e ) ) ) ); // Q31 + /* mean and stdev of per-sample magnitude ratios */ + lshift = W_norm( drho_fx ); + tmp_e = drho_exp[k - 1]; + IF( LT_16( lshift, 32 ) ) + { + drho_fx = W_shl( drho_fx, lshift ); + tmp_e = add( tmp_e, lshift ); + } + drho_32 = W_extract_h( drho_fx ); // Qtmp_e-32 + drho_32 = Mpy_32_32( drho_32, divide_fact ); + drho_sqr = Mpy_32_32( drho_32, drho_32 ); // Q(2*(tmp_e -32) - 31) + temp_64 = W_mult_32_32( sub( iNumCols, 1 ), drho_sqr ); // Q(2*(tmp_e -32) - 30) + drho_sqr_q = sub( shl( sub( tmp_e, 32 ), 1 ), 30 ); + temp_q = srho_exp[k - 1]; + IF( GT_16( srho_exp[k - 1], drho_sqr_q ) ) + { + temp_64 = W_shl( temp_64, sub( srho_exp[k - 1], drho_sqr_q ) ); + temp_q = srho_exp[k - 1]; + } + ELSE IF( GT_16( drho_sqr_q, srho_exp[k - 1] ) ) + { + srho_fx = W_shl( srho_fx, sub( drho_sqr_q, srho_exp[k - 1] ) ); + temp_q = drho_sqr_q; + } + temp_64 = W_sub( srho_fx, temp_64 ); + drho_q = sub( tmp_e, 32 ); + IF( GT_64( temp_64, 0 ) ) + { + lshift = W_norm( temp_64 ); + temp_32 = W_extract_h( W_shl( temp_64, lshift ) ); + sqrt_exp = sub( add( temp_q, lshift ), 32 ); + tmp = BASOP_Util_Divide1616_Scale( 1, sub( iNumCols, 2 ), &tmp_e ); + divide_fact = L_shl( tmp, sub( 31, add( 15, negate( tmp_e ) ) ) ); // Q31 + temp_32 = Mpy_32_32( temp_32, divide_fact ); // Qsqrt_exp + sqrt_exp1 = sub( 31, sqrt_exp ); + srho_fx = Sqrt32( temp_32, &sqrt_exp1 ); + srho_q = sub( 31, sqrt_exp1 ); + } + ELSE + { + srho_q = 31; + srho_fx = 0; + } + /* mean and stdev of per-sample phase differences */ + tmp = BASOP_Util_Divide1616_Scale( 1, sub( iNumCols, 1 ), &tmp_e ); + divide_fact = L_shl( tmp, sub( 31, add( 15, negate( tmp_e ) ) ) ); // Q31 + /* mean and stdev of per-sample phase differences */ + lshift = W_norm( dth_fx ); + dth_fx = W_shl( dth_fx, lshift ); // Q28+lshift + dth32 = W_extract_h( dth_fx ); // Q28+lshift-32 + dth_q = sub( add( 28, lshift ), 32 ); + dth32 = Mpy_32_32( dth32, divide_fact ); + dth_sqr = Mpy_32_32( dth32, dth32 ); // Q28+lshift-32 + temp_64 = W_mult_32_32( sub( iNumCols, 1 ), dth_sqr ); // Q(2*lshift-39) + temp_q = sub( sub( shl( lshift, 1 ), 8 ), 30 ); + // printf( "%f \t", temp ); + IF( GT_16( temp_q, 25 ) ) + { + + sth_fx = W_shl( sth_fx, sub( temp_q, 25 ) ); + } + ELSE IF( GT_16( 25, temp_q ) ) + { + temp_64 = W_shl( temp_64, sub( 25, temp_q ) ); + temp_q = 25; + } + + temp_64 = W_sub( sth_fx, temp_64 ); + IF( GT_64( temp_64, 0 ) ) + { + lshift = W_norm( temp_64 ); + temp_32 = W_extract_h( W_shl( temp_64, lshift ) ); + sqrt_exp = sub( add( temp_q, lshift ), 32 ); + tmp = BASOP_Util_Divide1616_Scale( 1, sub( iNumCols, 2 ), &tmp_e ); + divide_fact = L_shl( tmp, sub( 31, add( 15, negate( tmp_e ) ) ) ); // Q31 + temp_32 = Mpy_32_32( temp_32, divide_fact ); // Qsqrt_exp + sqrt_exp1 = sub( 31, sqrt_exp ); + sth_fx = Sqrt32( temp_32, &sqrt_exp1 ); + sth_q = sub( 31, sqrt_exp1 ); + } + ELSE + { + sth_fx = 0; + sth_q = 31; + } + + /* do phase extension only IF the std deviations are small */ + IF( LT_64( srho_fx, W_shl( SRHO_THRESH_FX, sub( srho_q, 31 ) ) ) || LT_64( sth_fx, W_shl( STH_THRESH_FX, sub( sth_q, 31 ) ) ) ) + { + dth32 = L_shl( Mpy_32_32( dth32, PI_CONST ), sub( 31, dth_q ) ); // Q28+lshift-32-16 + dth16 = extract_h( dth32 ); + fac_ph_real_fx = L_deposit_h( getCosWord16R2( dth16 ) ); + fac_ph_imag_fx = L_deposit_h( getSineWord16R2( dth16 ) ); + ///* calculate complex evolution factor */ + fac_real_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp + fac_imag_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp +#if START_VAL_AVG_LEN > 1 + /* Calculate start value FOR evolution from last samples of previous frame */ + fac_powj_real_fx = fac_real_fx; + fac_powj_imag_fx = fac_imag_fx; + start_real_fx = prev_real_fx[iNumCols - 1]; + start_imag_fx = prev_imag_fx[iNumCols - 1]; + FOR( j = 1; j < START_VAL_AVG_LEN; j++ ) + { + start_real_fx = L_add( L_shr( start_real_fx, sub( exp, sub( add( drho_q, exp ), 31 ) ) ), L_sub( Mpy_32_32( fac_powj_real_fx, prev_real_fx[iNumCols - j - 1] ), Mpy_32_32( fac_powj_imag_fx, prev_imag_fx[iNumCols - j - 1] ) ) ); // Q(drho_q+exp-31) + start_imag_fx = L_add( L_shr( start_imag_fx, sub( exp, sub( add( drho_q, exp ), 31 ) ) ), L_add( Mpy_32_32( fac_powj_imag_fx, prev_real_fx[iNumCols - j - 1] ), Mpy_32_32( fac_powj_real_fx, prev_imag_fx[iNumCols - j - 1] ) ) ); // Q(drho_q+exp-31) + temp_fx = L_shl( L_sub( Mpy_32_32( fac_powj_real_fx, fac_real_fx ), Mpy_32_32( fac_powj_imag_fx, fac_imag_fx ) ), sub( sub( drho_q, shl( drho_q, 1 ) ), 31 ) ); // Qdrho_q + fac_powj_imag_fx = L_shl( L_add( Mpy_32_32( fac_powj_imag_fx, fac_real_fx ), Mpy_32_32( fac_powj_real_fx, fac_imag_fx ) ), sub( sub( drho_q, shl( drho_q, 1 ) ), 31 ) ); // Qdrho_q + fac_powj_real_fx = temp_fx; + } + start_q = sub( add( drho_q, exp ), 30 ); +#else + /* take last sample of previous frame as start value */ + start_real = prev_real[iNumCols - 1]; + start_imag = prev_imag[iNumCols - 1]; +#endif + +#if DO_PERTURB != 0 + + /* make evolution less static: apply per samples differences as in preceding frame */ + rat_real_fx = W_add( W_mult_32_32( prev_real_fx[1], prev_real_fx[0] ), W_mult_32_32( prev_imag_fx[1], prev_imag_fx[0] ) ); // 2*exp + rat_imag_fx = W_add( W_mult_32_32( -prev_real_fx[1], prev_imag_fx[0] ), W_mult_32_32( prev_imag_fx[1], prev_real_fx[0] ) ); // 2*exp + +#if PH_PERT_ONLY != 0 + + lshift = W_norm( rat_real_fx ); + temp_64 = W_shl( rat_real_fx, lshift ); // Q2*exp+lshift + rat_real32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_real_q = sub( add( shl( exp, 1 ), lshift ), 31 ); + lshift = W_norm( rat_imag_fx ); + temp_64 = W_shl( rat_imag_fx, lshift ); // Q2*exp+lshift + rat_imag32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_imag_q = sub( add( shl( exp, 1 ), lshift ), 31 ); + real_sum = W_mult_32_32( rat_real32_fx, rat_real32_fx ); + rat_real_sum_q = add( shl( rat_real_q, 1 ), 1 ); + imag_sum = W_mult_32_32( rat_imag32_fx, rat_imag32_fx ); + rat_imag_sum_q = add( shl( rat_imag_q, 1 ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_add( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + temp_32 = W_extract_h( temp_64 ); + sqrt_exp = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + /* only phase perturbation */ + sqrt_exp = sub( 31, sqrt_exp ); + tmp_e = 0; + abs_temp_fx = Sqrt32( temp_32, &sqrt_exp ); // Q(31-sqrt_exp) + + lshift = norm_l( drho_32 ); + drho_32 = L_shl( drho_32, lshift ); + drho_q = add( drho_q, lshift ); + IF( EQ_16( drho_q, 31 ) ) + { + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + } + ELSE + { + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + } + temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); + + rat_real_fx = W_mult_32_32( rat_real32_fx, abs2inv_fx ); + + rat_imag_fx = W_mult_32_32( rat_imag32_fx, abs2inv_fx ); + rat_real_q = add( add( rat_real_q, temp_16 ), 1 ); + + rat_imag_q = add( add( rat_imag_q, temp_16 ), 1 ); + +#else + /* phase and magnitude perturbation */ + abs2inv = 1 / ( max( 1, drho ) * ( SQR( prev_real[0] ) + SQR( prev_imag[0] ) ) ); + rat_real *= abs2inv; + rat_imag *= abs2inv; +#endif + lshift = W_norm( rat_real_fx ); + temp_64 = W_shl( rat_real_fx, lshift ); // Q2*exp+lshift + rat_real32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_real_q = sub( add( rat_real_q, lshift ), 32 ); + lshift = W_norm( rat_imag_fx ); + temp_64 = W_shl( rat_imag_fx, lshift ); // Q2*exp+lshift + rat_imag32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_imag_q = sub( add( rat_imag_q, lshift ), 32 ); + + /* apply complex evolution FOR first substitution sample */ + + real_sum = W_mult_32_32( rat_real32_fx, start_real_fx ); + rat_real_sum_q = add( add( rat_real_q, start_q ), 1 ); + imag_sum = W_mult_32_32( rat_imag32_fx, start_imag_fx ); + rat_imag_sum_q = add( add( rat_imag_q, start_q ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_sub( real_sum, imag_sum ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + rec_real_fx[0] = W_extract_h( temp_64 ); // sqrt_exp + lshift-32 + rec_real_exp[0] = sub( add( sqrt_exp, lshift ), 32 ); + + real_sum = W_mult_32_32( rat_imag32_fx, start_real_fx ); + rat_real_sum_q = add( add( rat_imag_q, start_q ), 1 ); + imag_sum = W_mult_32_32( rat_real32_fx, start_imag_fx ); + rat_imag_sum_q = add( add( rat_real_q, start_q ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_add( real_sum, imag_sum ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + rec_imag_fx[0] = W_extract_h( temp_64 ); // sqrt_exp + lshift-32 + rec_imag_exp[0] = sub( add( sqrt_exp, lshift ), 32 ); + FOR( j = 2; j < iNumCols; j++ ) + { + rat_real_fx = W_add( W_mult_32_32( prev_real_fx[j], prev_real_fx[j - 1] ), W_mult_32_32( prev_imag_fx[j], prev_imag_fx[j - 1] ) ); // 2*exp + rat_imag_fx = W_add( W_mult_32_32( -prev_real_fx[j], prev_imag_fx[j - 1] ), W_mult_32_32( prev_imag_fx[j], prev_real_fx[j - 1] ) ); // 2*exp +#if PH_PERT_ONLY != 0 + lshift = W_norm( rat_real_fx ); + temp_64 = W_shl( rat_real_fx, lshift ); // Q2*exp+lshift + rat_real32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_real_q = sub( add( shl( exp, 1 ), lshift ), 31 ); + lshift = W_norm( rat_imag_fx ); + temp_64 = W_shl( rat_imag_fx, lshift ); // Q2*exp+lshift + rat_imag32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_imag_q = sub( add( shl( exp, 1 ), lshift ), 31 ); + real_sum = W_mult_32_32( rat_real32_fx, rat_real32_fx ); + rat_real_sum_q = add( shl( rat_real_q, 1 ), 1 ); + imag_sum = W_mult_32_32( rat_imag32_fx, rat_imag32_fx ); + rat_imag_sum_q = add( shl( rat_imag_q, 1 ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + + temp_64 = W_add( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + temp_32 = W_extract_h( temp_64 ); + sqrt_exp = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + /* only phase perturbation */ + sqrt_exp = sub( 31, sqrt_exp ); + tmp_e = 0; + abs_temp_fx = Sqrt32( temp_32, &sqrt_exp ); // Q(31-sqrt_exp) + + IF( EQ_16( drho_q, 31 ) ) + { + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + } + ELSE + { + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + } + temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); + + rat_real_fx = W_mult_32_32( rat_real32_fx, abs2inv_fx ); + rat_imag_fx = W_mult_32_32( rat_imag32_fx, abs2inv_fx ); + rat_real_q = add( add( rat_real_q, temp_16 ), 1 ); + rat_imag_q = add( add( rat_imag_q, temp_16 ), 1 ); + +#else + /* phase and magnitude perturbation */ + abs2inv = 1 / ( max( 1, drho ) * ( SQR( prev_real[j - 1] ) + SQR( prev_imag[j - 1] ) ) ); +#endif + + lshift = W_norm( rat_real_fx ); + temp_64 = W_shl( rat_real_fx, lshift ); // Q2*exp+lshift + rat_real32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_real_q = sub( add( rat_real_q, lshift ), 32 ); + lshift = W_norm( rat_imag_fx ); + temp_64 = W_shl( rat_imag_fx, lshift ); // Q2*exp+lshift + rat_imag32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_imag_q = sub( add( rat_imag_q, lshift ), 32 ); + + + real_sum = W_mult_32_32( rat_real32_fx, rec_real_fx[j - 2] ); + rat_real_sum_q = add( add( rat_real_q, rec_real_exp[j - 2] ), 1 ); + imag_sum = W_mult_32_32( rat_imag32_fx, rec_imag_fx[j - 2] ); + rat_imag_sum_q = add( add( rat_imag_q, rec_imag_exp[j - 2] ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_sub( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + rec_real_fx[j - 1] = W_extract_h( temp_64 ); // sqrt_exp + lshift-32 + rec_real_exp[j - 1] = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + + real_sum = W_mult_32_32( rat_imag32_fx, rec_real_fx[j - 2] ); + rat_real_sum_q = add( add( rat_imag_q, rec_real_exp[j - 2] ), 1 ); + imag_sum = W_mult_32_32( rat_real32_fx, rec_imag_fx[j - 2] ); + rat_imag_sum_q = add( add( rat_real_q, rec_imag_exp[j - 2] ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_add( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + rec_imag_fx[j - 1] = W_extract_h( temp_64 ); // sqrt_exp + lshift-32 + rec_imag_exp[j - 1] = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + } + + /* do the same FOR samples of crossfade region */ + FOR( j = 1; j < CLDFB_PLC_XF + 2; j++ ) + { + rat_real_fx = W_add( W_mult_32_32( prev_real_fx[j], prev_real_fx[j - 1] ), W_mult_32_32( prev_imag_fx[j], prev_imag_fx[j - 1] ) ); // 2*exp + rat_imag_fx = W_add( W_mult_32_32( -prev_real_fx[j], prev_imag_fx[j - 1] ), W_mult_32_32( prev_imag_fx[j], prev_real_fx[j - 1] ) ); // 2*exp + +#if PH_PERT_ONLY != 0 + + lshift = W_norm( rat_real_fx ); + temp_64 = W_shl( rat_real_fx, lshift ); // Q2*exp+lshift + rat_real32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_real_q = sub( add( shl( exp, 1 ), lshift ), 31 ); + lshift = W_norm( rat_imag_fx ); + temp_64 = W_shl( rat_imag_fx, lshift ); // Q2*exp+lshift + rat_imag32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_imag_q = sub( add( shl( exp, 1 ), lshift ), 31 ); + real_sum = W_mult_32_32( rat_real32_fx, rat_real32_fx ); + rat_real_sum_q = add( shl( rat_real_q, 1 ), 1 ); + imag_sum = W_mult_32_32( rat_imag32_fx, rat_imag32_fx ); + rat_imag_sum_q = add( shl( rat_imag_q, 1 ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_add( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + temp_32 = W_extract_h( temp_64 ); + sqrt_exp = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + /* only phase perturbation */ + sqrt_exp = sub( 31, sqrt_exp ); + tmp_e = 0; + abs_temp_fx = Sqrt32( temp_32, &sqrt_exp ); // Q(31-sqrt_exp) + + IF( EQ_16( drho_q, 31 ) ) + { + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + } + ELSE + { + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + } + temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); + rat_real_fx = W_mult_32_32( rat_real32_fx, abs2inv_fx ); + rat_imag_fx = W_mult_32_32( rat_imag32_fx, abs2inv_fx ); + rat_real_q = add( add( rat_real_q, temp_16 ), 1 ); + rat_imag_q = add( add( rat_imag_q, temp_16 ), 1 ); +#else + abs2inv = 1 / ( max( 1, drho ) * ( SQR( prev_real[j - 1] ) + SQR( prev_imag[j - 1] ) ) ); +#endif + lshift = W_norm( rat_real_fx ); + temp_64 = W_shl( rat_real_fx, lshift ); // Q2*exp+lshift + rat_real32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_real_q = sub( add( rat_real_q, lshift ), 32 ); + lshift = W_norm( rat_imag_fx ); + temp_64 = W_shl( rat_imag_fx, lshift ); // Q2*exp+lshift + rat_imag32_fx = W_extract_h( temp_64 ); // Q2*exp+lshift-31 + rat_imag_q = sub( add( rat_imag_q, lshift ), 32 ); + + + real_sum = W_mult_32_32( rat_real32_fx, rec_real_fx[j + iNumCols - 3] ); + rat_real_sum_q = add( add( rat_real_q, rec_real_exp[j + iNumCols - 3] ), 1 ); + imag_sum = W_mult_32_32( rat_imag32_fx, rec_imag_fx[j + iNumCols - 3] ); + rat_imag_sum_q = add( add( rat_imag_q, rec_imag_exp[j + iNumCols - 3] ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_sub( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + rec_real_fx[j + iNumCols - 2] = W_extract_h( temp_64 ); // sqrt_exp + lshift-32 + rec_real_exp[j + iNumCols - 2] = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + + real_sum = W_mult_32_32( rat_imag32_fx, rec_real_fx[j + iNumCols - 3] ); + rat_real_sum_q = add( add( rat_imag_q, rec_real_exp[j + iNumCols - 3] ), 1 ); + imag_sum = W_mult_32_32( rat_real32_fx, rec_imag_fx[j + iNumCols - 3] ); + rat_imag_sum_q = add( add( rat_real_q, rec_imag_exp[j + iNumCols - 3] ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + temp_64 = W_add( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( temp_64 ); + temp_64 = W_shl( temp_64, lshift ); + rec_imag_fx[j + iNumCols - 2] = W_extract_h( temp_64 ); // sqrt_exp + lshift-32 + rec_imag_exp[j + iNumCols - 2] = sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ); + } +#else + rec_real[0] = fac_real * start_real - fac_imag * start_imag; + rec_imag[0] = fac_imag * start_real + fac_real * start_imag; + FOR( j = 1; j < iNumCols + CLDFB_PLC_XF; j++ ) + { + rec_real[j] = fac_real * rec_real[j - 1] - fac_imag * rec_imag[j - 1]; + rec_imag[j] = fac_imag * rec_real[j - 1] + fac_real * rec_imag[j - 1]; + } +#endif + +#if CLDFB_PLC_XF > 0 + /* apply crossfade */ + FOR( j = 0; j < CLDFB_PLC_XF; j++ ) + { + rec_real_fx[iNumCols + j] = Mpy_32_32( xf_alp_fx[j], rec_real_fx[iNumCols + j] ); + rec_imag_fx[iNumCols + j] = Mpy_32_32( xf_alp_fx[j], rec_imag_fx[iNumCols + j] ); + xf_bet_fx[j] = L_sub( ONE_IN_Q31, xf_alp_fx[j] ); + } +#endif + } + ELSE + { + Word16 guard_bits = find_guarded_bits_fx( iNumCols ); + /* do complex lpc combined with frame repetition */ + Ruu_real_fx[0] = W_add( W_shr( W_mult_32_32( prev_real_fx[0], prev_real_fx[0] ), guard_bits ), W_shr( W_mult_32_32( prev_imag_fx[0], prev_imag_fx[0] ), guard_bits ) ); + Ruu_real_fx[1] = 0; + Ruu_imag_fx[1] = 0; + FOR( j = 1; j < iNumCols; j++ ) + { + Ruu_real_fx[0] = W_add( Ruu_real_fx[0], W_add( W_shr( W_mult_32_32( prev_real_fx[j], prev_real_fx[j] ), guard_bits ), W_shr( W_mult_32_32( prev_imag_fx[j], prev_imag_fx[j] ), guard_bits ) ) ); + Ruu_real_fx[1] = W_add( Ruu_real_fx[1], W_add( W_shr( W_mult_32_32( prev_real_fx[j], prev_real_fx[j - 1] ), guard_bits ), W_shr( W_mult_32_32( prev_imag_fx[j], prev_imag_fx[j - 1] ), guard_bits ) ) ); + Ruu_imag_fx[1] = W_add( Ruu_imag_fx[1], W_sub( W_shr( W_mult_32_32( prev_imag_fx[j], prev_real_fx[j - 1] ), guard_bits ), W_shr( W_mult_32_32( prev_real_fx[j], prev_imag_fx[j - 1] ), guard_bits ) ) ); + } + // printf( "%.7f \t", Ruu_real[1] + lshift = W_norm( Ruu_real_fx[0] ); + Ruu_real_fx_0 = W_extract_h( W_shl( Ruu_real_fx[0], lshift ) ); + Ruu_real_fx_0_q = sub( add( sub( add( shl( exp, 1 ), 1 ), guard_bits ), lshift ), 32 ); + lshift = W_norm( Ruu_real_fx[0] ); + Ruu_real_fx_1 = W_extract_h( W_shl( Ruu_real_fx[1], lshift ) ); + Ruu_real_fx_1_q = sub( add( sub( add( shl( exp, 1 ), 1 ), guard_bits ), lshift ), 32 ); + lshift = W_norm( Ruu_real_fx[0] ); + Ruu_imag_fx_1 = W_extract_h( W_shl( Ruu_imag_fx[1], lshift ) ); + Ruu_imag_fx_1_q = sub( add( sub( add( shl( exp, 1 ), 1 ), guard_bits ), lshift ), 32 ); + IF( GT_64( Ruu_real_fx[0], 0 ) ) + { + /* prediction coefficient */ + fac_real_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( Ruu_real_fx_1, Ruu_real_fx_0, &tmp_e ) ); + fac_real_q = sub( add( sub( 31, tmp_e ), Ruu_real_fx_1_q ), Ruu_real_fx_0_q ); + fac_imag_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( Ruu_imag_fx_1, Ruu_real_fx_0, &tmp_e ) ); + fac_imag_q = sub( add( sub( 31, tmp_e ), Ruu_imag_fx_1_q ), Ruu_real_fx_0_q ); + } + ELSE + { + fac_imag_fx = 0; + fac_imag_q = 31; + fac_real_fx = 0; + fac_real_q = 31; + } + + /* apply prediction using last sample of preceding frame as start value and combine with previous frame samples */ + fac_powj_real_fx = fac_real_fx; + fac_powj_imag_fx = fac_imag_fx; + + Word16 powj_real_q = fac_real_q; + Word16 powj_imag_q = fac_imag_q; + + real_sum = W_mult_32_32( fac_real_fx, fac_real_fx ); + rat_real_sum_q = add( shl( fac_real_q, 1 ), 1 ); + imag_sum = W_mult_32_32( fac_imag_fx, fac_imag_fx ); + rat_imag_sum_q = add( shl( fac_imag_q, 1 ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + sqrt_exp = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + sqrt_exp = rat_real_sum_q; + } + abs_fac_fx = W_add( W_shr( real_sum, 1 ), W_shr( imag_sum, 1 ) ); + lshift = W_norm( abs_fac_fx ); + abs_fac_32 = W_extract_h( W_shl( abs_fac_fx, lshift ) ); + sqrt_exp = sub( 31, ( sub( add( sub( sqrt_exp, 1 ), lshift ), 32 ) ) ); + abs_fac_32 = Sqrt32( abs_fac_32, &sqrt_exp ); + sqrt_exp = sub( 31, sqrt_exp ); + abs_fac_32 = L_shr( abs_fac_32, sub( sqrt_exp, 31 ) ); // Q31 + sqrt_exp = 31; + abs_fac_powj_32 = L_shr( abs_fac_32, 1 ); // Q30 + sqrt_exp = 30; + + FOR( j = 0; j < iNumCols; j++ ) + { + comp_fac_fx = L_sub( L_shl( 1, sqrt_exp ), abs_fac_powj_32 ); + real_sum = W_mult_32_32( prev_real_fx[iNumCols - 1], fac_powj_real_fx ); + rat_real_sum_q = add( add( exp, powj_real_q ), 1 ); + imag_sum = W_mult_32_32( prev_imag_fx[iNumCols - 1], fac_powj_imag_fx ); + rat_imag_sum_q = add( add( exp, powj_imag_q ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_sub( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + rat_real_sum_q = sub( rat_real_sum_q, guard_bits ); + imag_sum = W_mult_32_32( prev_real_fx[j], comp_fac_fx ); + rat_imag_sum_q = add( add( exp, sqrt_exp ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_add( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + lshift = W_norm( real_sum ); + rec_real_fx[j] = W_extract_h( W_shl( real_sum, lshift ) ); + rec_real_exp[j] = sub( add( sub( rat_real_sum_q, guard_bits ), lshift ), 32 ); + real_sum = W_mult_32_32( prev_real_fx[iNumCols - 1], fac_powj_imag_fx ); + rat_real_sum_q = add( add( exp, powj_imag_q ), 1 ); + imag_sum = W_mult_32_32( prev_imag_fx[iNumCols - 1], fac_powj_real_fx ); + rat_imag_sum_q = add( add( exp, powj_real_q ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_add( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + rat_real_sum_q = sub( rat_real_sum_q, guard_bits ); + imag_sum = W_mult_32_32( prev_imag_fx[j], comp_fac_fx ); + rat_imag_sum_q = add( add( exp, sqrt_exp ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_add( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + + lshift = W_norm( real_sum ); + rec_imag_fx[j] = W_extract_h( W_shl( real_sum, lshift ) ); + rec_imag_exp[j] = sub( add( sub( rat_real_sum_q, guard_bits ), lshift ), 32 ); + + abs_fac_powj_32 = Mpy_32_32( abs_fac_powj_32, abs_fac_32 ); + + + real_sum = W_mult_32_32( fac_powj_real_fx, fac_real_fx ); + rat_real_sum_q = add( add( fac_real_q, powj_real_q ), 1 ); + imag_sum = W_mult_32_32( fac_powj_imag_fx, fac_imag_fx ); + rat_imag_sum_q = add( add( fac_imag_q, powj_imag_q ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_sub( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + // rat_real_sum_q = rat_real_sum_q - 1; + lshift = W_norm( real_sum ); + temp_32 = W_extract_h( W_shl( real_sum, lshift ) ); + temp_16 = sub( add( sub( rat_real_sum_q, guard_bits ), lshift ), 32 ); + + real_sum = W_mult_32_32( fac_powj_real_fx, fac_imag_fx ); + rat_real_sum_q = fac_imag_q + powj_real_q + 1; + imag_sum = W_mult_32_32( fac_powj_imag_fx, fac_real_fx ); + rat_imag_sum_q = fac_real_q + powj_imag_q + 1; + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_add( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + // rat_real_sum_q = rat_real_sum_q - 1; + lshift = W_norm( real_sum ); + fac_powj_imag_fx = W_extract_h( W_shl( real_sum, lshift ) ); + powj_imag_q = sub( add( sub( rat_real_sum_q, guard_bits ), lshift ), 32 ); + + fac_powj_real_fx = temp_32; + powj_real_q = temp_16; + } + + + /* prepare XF to next frame using prediction */ + fac_powj_real_fx = fac_real_fx; + fac_powj_imag_fx = fac_imag_fx; + powj_real_q = fac_real_q; + powj_imag_q = fac_imag_q; + abs_fac_powj_32 = abs_fac_32; // Q30 + sqrt_exp = 31; +#if CLDFB_PLC_XF > 0 + guard_bits = find_guarded_bits_fx( CLDFB_PLC_XF ); + FOR( j = 0; j < CLDFB_PLC_XF; j++ ) + { + + + xf_bet_fx[j] = L_sub( ONE_IN_Q31, abs_fac_powj_32 ); + real_sum = W_mult_32_32( rec_real_fx[iNumCols - 1], fac_powj_real_fx ); + rat_real_sum_q = add( add( rec_real_exp[iNumCols - 1], powj_real_q ), 1 ); + imag_sum = W_mult_32_32( rec_imag_fx[iNumCols - 1], fac_powj_imag_fx ); + rat_imag_sum_q = add( add( rec_imag_exp[iNumCols - 1], powj_imag_q ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_sub( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + rat_real_sum_q = sub( rat_real_sum_q, guard_bits ); + + lshift = W_norm( real_sum ); + rec_real_fx[j + iNumCols] = W_extract_h( W_shl( real_sum, lshift ) ); + rec_real_exp[j + iNumCols] = sub( add( rat_real_sum_q, lshift ), 32 ); + + real_sum = W_mult_32_32( rec_real_fx[iNumCols - 1], fac_powj_imag_fx ); + rat_real_sum_q = add( add( rec_real_exp[iNumCols - 1], powj_imag_q ), 1 ); + imag_sum = W_mult_32_32( rec_imag_fx[iNumCols - 1], fac_powj_real_fx ); + rat_imag_sum_q = add( add( rec_imag_exp[iNumCols - 1], powj_real_q ), 1 ); + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + /*sqrt_exp = rat_real_sum_q;*/ + } + real_sum = W_add( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + rat_real_sum_q = sub( rat_real_sum_q, guard_bits ); + + lshift = W_norm( real_sum ); + rec_imag_fx[j + iNumCols] = W_extract_h( W_shl( real_sum, lshift ) ); + rec_imag_exp[j + iNumCols] = sub( add( rat_real_sum_q, lshift ), 32 ); + + abs_fac_powj_32 = W_extract_h( W_mult_32_32( abs_fac_powj_32, abs_fac_32 ) ); // Q31 + + real_sum = W_mult_32_32( fac_powj_real_fx, fac_real_fx ); + rat_real_sum_q = add( add( fac_real_q, powj_real_q ), 1 ); + imag_sum = W_mult_32_32( fac_powj_imag_fx, fac_imag_fx ); + rat_imag_sum_q = add( add( fac_imag_q, powj_imag_q ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + } + real_sum = W_sub( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + lshift = W_norm( real_sum ); + temp_32 = W_extract_h( W_shl( real_sum, lshift ) ); + temp_16 = sub( add( sub( rat_real_sum_q, guard_bits ), lshift ), 32 ); + + real_sum = W_mult_32_32( fac_powj_real_fx, fac_imag_fx ); + rat_real_sum_q = add( add( fac_imag_q, powj_real_q ), 1 ); + imag_sum = W_mult_32_32( fac_powj_imag_fx, fac_real_fx ); + rat_imag_sum_q = add( add( fac_real_q, powj_imag_q ), 1 ); + + IF( GT_16( rat_real_sum_q, rat_imag_sum_q ) ) + { + real_sum = W_shr( real_sum, sub( rat_real_sum_q, rat_imag_sum_q ) ); + rat_real_sum_q = rat_imag_sum_q; + } + ELSE + { + imag_sum = W_shr( imag_sum, sub( rat_imag_sum_q, rat_real_sum_q ) ); + } + real_sum = W_add( W_shr( real_sum, guard_bits ), W_shr( imag_sum, guard_bits ) ); + lshift = W_norm( real_sum ); + fac_powj_imag_fx = W_extract_h( W_shl( real_sum, lshift ) ); + powj_imag_q = sub( add( sub( rat_real_sum_q, guard_bits ), lshift ), 32 ); + + fac_powj_real_fx = temp_32; + powj_real_q = temp_16; + } +#endif + } + } + ELSE + { + FOR( j = 0; j < iNumCols; j++ ) + { + rec_real_fx[j] = prev_real_fx[j]; + rec_real_exp[j] = exp; + rec_imag_fx[j] = prev_imag_fx[j]; + rec_imag_exp[j] = exp; + } +#if CLDFB_PLC_XF > 0 + FOR( j = 0; j < CLDFB_PLC_XF; j++ ) + { + xf_bet_fx[j] = ONE_IN_Q31; + rec_real_fx[j + iNumCols] = 0; + rec_real_exp[j + iNumCols] = 31; + rec_imag_fx[j + iNumCols] = 0; + rec_imag_exp[j + iNumCols] = 31; + } +#endif + } + return; +} +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLCOpen() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_splitBinRendPLCOpen( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, + Word16 iNumSubSets ) +{ + ivas_error error; + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC; + + error = IVAS_ERR_OK; + IF( ( hSplitRendPLC = (ISAR_SPLIT_REND_PLC_HANDLE) malloc( sizeof( SPLIT_REND_PLC_STRUCT ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split renderer PLC Module \n" ) ); + } + + hSplitRendPLC->prev_bfi = 0; + hSplitRendPLC->bf_count = 0; + hSplitRendPLC->iNumSubSets = iNumSubSets; + + set_l( &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal_fx[0][0][0], 0, 2 * ( CLDFB_NO_COL_MAX + CLDFB_PLC_XF ) * CLDFB_NO_CHANNELS_MAX ); + set_l( &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag_fx[0][0][0], 0, 2 * ( CLDFB_NO_COL_MAX + CLDFB_PLC_XF ) * CLDFB_NO_CHANNELS_MAX ); + + *phSplitRendPLC = hSplitRendPLC; + + return error; +} + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLCClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLCClose( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ) +{ + if ( ( *phSplitRendPLC ) != NULL ) + { + free( ( *phSplitRendPLC ) ); + ( *phSplitRendPLC ) = NULL; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLCsaveState() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLCsaveState( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 num_chs, + const Word16 iNumBlocks, + const Word16 iNumIterations ) +{ + Word16 k, n; + + /* Save Cldfb frame */ + FOR( k = 0; k < ( iNumBlocks * iNumIterations ); k++ ) + { + FOR( n = 0; n < num_chs; n++ ) + { + mvl2l( &Cldfb_RealBuffer_Binaural_fx[n][k][0], &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal_fx[n][k][0], CLDFB_NO_CHANNELS_MAX ); + mvl2l( &Cldfb_ImagBuffer_Binaural_fx[n][k][0], &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag_fx[n][k][0], CLDFB_NO_CHANNELS_MAX ); + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLC_xf() + * + * Cross-fade of preceding bad frame into good frame + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLC_xf_fx( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 num_chs, + const Word16 iNumBlocks, + const Word16 iNumIterations, + Word32 **ppiDecodingFailed, + Word32 **ppiDecodingFailedPrev, + Word16 exp ) +{ + Word16 n, i, k; + /* Indicate that next transition will be from a good frame */ + hSplitRendPLC->prev_bfi = 0; + move16(); + + /* Reset bf conter */ + hSplitRendPLC->bf_count = 0; + move16(); + + /* Do the cross fade */ + FOR( n = 0; n < num_chs; n++ ) + { + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + Word32 iSubSet = i % hSplitRendPLC->iNumSubSets; + test(); + IF( EQ_32( ppiDecodingFailedPrev[n][iSubSet], 1 ) && EQ_32( ppiDecodingFailed[n][iSubSet], 0 ) ) + { +#if CLDFB_PLC_XF > 0 + FOR( k = 0; k < CLDFB_PLC_XF; k++ ) + { + Word32 L_tmp; + Word64 W_tmp; + Word16 shift; + W_tmp = W_shr( W_mult_32_32( hSplitRendPLC->CldfbPLC_state.xf_bet_fx[n][i][k], Cldfb_RealBuffer_Binaural_fx[n][k][i] ), 1 ); + W_tmp = W_add( W_tmp, W_shl( L_shl_r( hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal_fx[n][k + ( iNumBlocks * iNumIterations )][i], exp - hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx ), 31 ) ); + + shift = W_norm( W_tmp ); + W_tmp = W_shl( W_tmp, shift ); + L_tmp = W_extract_h( W_tmp ); + L_tmp = L_shr( L_tmp, 31 + shift - 32 ); + Cldfb_RealBuffer_Binaural_fx[n][k][i] = L_tmp; + + W_tmp = W_shr( W_mult_32_32( hSplitRendPLC->CldfbPLC_state.xf_bet_fx[n][i][k], Cldfb_ImagBuffer_Binaural_fx[n][k][i] ), 1 ); + W_tmp = W_add( W_tmp, W_shl( L_shl_r( hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag_fx[n][k + ( iNumBlocks * iNumIterations )][i], exp - hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx ), 31 ) ); + + shift = W_norm( W_tmp ); + W_tmp = W_shl( W_tmp, shift ); + L_tmp = W_extract_h( W_tmp ); + L_tmp = L_shr( L_tmp, 31 + shift - 32 ); + Cldfb_ImagBuffer_Binaural_fx[n][k][i] = L_tmp; + } +#endif + } + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLC() + * + * Conceal bad frame + *------------------------------------------------------------------------*/ +void isar_splitBinRendPLC( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 num_chs, + const Word16 iNumBlocks, + const Word16 iNumIterations, + int32_t **ppiDecodingFailed, + Word16 exp ) +{ + Word32 i, n, k; + Word32 temp_32, fade_fac_fx; + Word16 div_exp = 0, tmp, exp_fade, frac; + Word32 prev_real_fx[CLDFB_NO_COL_MAX], prev_imag_fx[CLDFB_NO_COL_MAX], rec_real_fx[CLDFB_NO_COL_MAX + CLDFB_PLC_XF], rec_imag_fx[CLDFB_NO_COL_MAX + CLDFB_PLC_XF]; + Word16 rec_real_exp[CLDFB_NO_COL_MAX + CLDFB_PLC_XF], rec_imag_exp[CLDFB_NO_COL_MAX + CLDFB_PLC_XF]; +#if CLDFB_PLC_XF > 0 + Word32 xf_alp_fx[CLDFB_PLC_XF]; +#endif + Word16 iNumCols, fade_start_cntr, mute_cntr, fade_val; + + iNumCols = extract_l( L_mult0( iNumBlocks, iNumIterations ) ); + + /* Indicate that next transition will be from a bad frame */ + hSplitRendPLC->prev_bfi = 1; + + +#if CLDFB_PLC_XF > 0 + FOR( i = 0; i < CLDFB_PLC_XF; i++ ) + { + xf_alp_fx[i] = xf_alp_tab[i]; + } +#endif + Word16 exp1 = exp; + + FOR( n = 0; n < num_chs; n++ ) + { + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + Word32 iSubSet = i % hSplitRendPLC->iNumSubSets; + FOR( k = 0; k < iNumCols; k++ ) + { + prev_real_fx[k] = L_shl_r( hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal_fx[n][k][i], exp - hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx ); + prev_imag_fx[k] = L_shl_r( hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag_fx[n][k][i], exp - hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx ); + } + adaptive_polar_ext_plc_fx( + prev_real_fx, prev_imag_fx, rec_real_fx, rec_imag_fx, + rec_real_exp, rec_imag_exp +#if CLDFB_PLC_XF > 0 + , + xf_alp_fx, hSplitRendPLC->CldfbPLC_state.xf_bet_fx[n][i], +#endif + exp, + iNumCols ); + + Word16 temp16; + + FOR( k = 0; k < iNumCols; k++ ) + { + temp16 = sub( rec_real_exp[k], exp1 ); + rec_real_fx[k] = L_shr_r_sat( rec_real_fx[k], temp16 ); + rec_real_exp[k] = sub( rec_real_exp[k], temp16 ); + + temp16 = sub( rec_imag_exp[k], exp1 ); + rec_imag_fx[k] = L_shr_r_sat( rec_imag_fx[k], temp16 ); + rec_imag_exp[k] = sub( rec_imag_exp[k], temp16 ); + // Cldfb_RealBuffer_Binaural_fx[n][k][i] = rec_real_fx[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal_fx[n][k][i] = rec_real_fx[k]; // exp + // Cldfb_ImagBuffer_Binaural_fx[n][k][i] = rec_imag_fx[k] ; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag_fx[n][k][i] = rec_imag_fx[k]; // exp + if ( ppiDecodingFailed[n][iSubSet] == 1 ) + { /* only then copy to output */ + Cldfb_RealBuffer_Binaural_fx[n][k][i] = rec_real_fx[k]; + Cldfb_ImagBuffer_Binaural_fx[n][k][i] = rec_imag_fx[k]; + } + } + +#if CLDFB_PLC_XF > 0 + FOR( k = iNumCols; k < iNumCols + CLDFB_PLC_XF; k++ ) + { + + temp16 = sub( rec_real_exp[k], exp1 ); + rec_real_fx[k] = L_shr_r_sat( rec_real_fx[k], temp16 ); + rec_real_exp[k] = sub( rec_real_exp[k], temp16 ); + + temp16 = sub( rec_imag_exp[k], exp1 ); + rec_imag_fx[k] = L_shr_r_sat( rec_imag_fx[k], temp16 ); + rec_imag_exp[k] = sub( rec_imag_exp[k], temp16 ); + /*TODO: Will remove the inter conversion later*/ + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal_fx[n][k][i] = rec_real_fx[k]; // exp + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag_fx[n][k][i] = rec_imag_fx[k]; // exp + } +#endif + } + } + + + /* Check bf counter */ + tmp = BASOP_Util_Divide1616_Scale( PLC_FADE_CNST, iNumCols, &div_exp ); + fade_start_cntr = shr( tmp, ( 15 - div_exp ) ); + tmp = BASOP_Util_Divide1616_Scale( PLC_MUTE_CNST, iNumCols, &div_exp ); + mute_cntr = shr( tmp, ( 15 - div_exp ) ); + + IF( GE_16( hSplitRendPLC->bf_count++, fade_start_cntr ) ) + { + IF( LT_16( hSplitRendPLC->bf_count, mute_cntr ) ) + { + fade_val = extract_l( L_shr( L_mult0( sub( hSplitRendPLC->bf_count, fade_start_cntr ), iNumCols ), 4 ) ); // Q0 + temp_32 = L_mult( -16328, fade_val ); // Q15 + temp_32 = L_shl( temp_32, 1 ); // Q16 + + frac = L_Extract_lc( temp_32, &exp_fade ); /* Extract exponent of temp_32 */ + fade_fac_fx = Pow2( 14, frac ); /* Put 14 as exponent so that */ + exp_fade = 31 - add( sub( exp_fade, 14 ), 16 ); + fade_fac_fx = L_shl( fade_fac_fx, 31 - exp_fade ); // Q31 + + FOR( n = 0; n < num_chs; n++ ) + { + FOR( k = 0; k < iNumCols; k++ ) + { + v_multc_fixed( &Cldfb_RealBuffer_Binaural_fx[n][k][0], fade_fac_fx, &Cldfb_RealBuffer_Binaural_fx[n][k][0], (int16_t) CLDFB_NO_CHANNELS_MAX ); + v_multc_fixed( &Cldfb_ImagBuffer_Binaural_fx[n][k][0], fade_fac_fx, &Cldfb_ImagBuffer_Binaural_fx[n][k][0], (int16_t) CLDFB_NO_CHANNELS_MAX ); + } + } + } + ELSE + { + FOR( n = 0; n < num_chs; n++ ) + { + FOR( k = 0; k < iNumCols; k++ ) + { + set_val_Word32( &Cldfb_RealBuffer_Binaural_fx[n][k][0], 0, (int16_t) CLDFB_NO_CHANNELS_MAX ); + set_val_Word32( &Cldfb_ImagBuffer_Binaural_fx[n][k][0], 0, (int16_t) CLDFB_NO_CHANNELS_MAX ); + } + } + hSplitRendPLC->bf_count = mute_cntr; + } + } + + return; +} +#endif diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c new file mode 100644 index 000000000..1bbff0b5c --- /dev/null +++ b/lib_isar/isar_splitRendererPost.c @@ -0,0 +1,2131 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +#include +#endif +#include "ivas_prot.h" +#include "prot.h" +#include "isar_rom_post_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "prot_fx2.h" +#include "wmc_auto.h" +#include "basop_util.h" +#define Q31_BY_360 ( 5965232 ) // Q31 + + +/*------------------------------------------------------------------------- + * isar_splitBinPostRendOpen() + * + * + *------------------------------------------------------------------------*/ +ivas_error isar_splitBinPostRendOpen( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) +{ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinRend; + ivas_error error; + Word16 ch; + + IF( ( hBinRend = (ISAR_BIN_HR_SPLIT_POST_REND_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_POST_REND ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split post renderer Module \n" ) ); + } + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hBinRend->cldfbSyn[ch] = NULL; + hBinRend->cldfbAna[ch] = NULL; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hBinRend->cldfbSynReconsBinDec[i][ch] = NULL; + } + } +#endif + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( ( error = openCldfb_splitRend( &( hBinRend->cldfbSyn[ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + IF( ( error = openCldfb_splitRend( &( hBinRend->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hBinRend->cldfbSynReconsBinDec[i][ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + hBinRend->cf_flag = 0; + set_fix_rotation_mat_fx( hBinRend->fix_pos_rot_mat_fx, pMultiBinPoseData ); + set_pose_types_fx( hBinRend->pose_type, pMultiBinPoseData ); + isar_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); + *hBinHrSplitPostRend = hBinRend; + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * isar_splitBinPostRendClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinPostRendClose( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ) +{ + Word16 ch; + + IF( ( *hBinHrSplitPostRend ) != NULL ) + { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( ( *hBinHrSplitPostRend )->cldfbSyn[ch] != NULL ) + { + deleteCldfb_splitRend( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) ); + ( *hBinHrSplitPostRend )->cldfbSyn[ch] = NULL; + } + IF( ( *hBinHrSplitPostRend )->cldfbAna[ch] != NULL ) + { + deleteCldfb_splitRend( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) ); + ( *hBinHrSplitPostRend )->cldfbAna[ch] = NULL; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] != NULL ) + { + deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] ) ); + ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] = NULL; + } + } + } +#endif + + free( ( *hBinHrSplitPostRend ) ); + ( *hBinHrSplitPostRend ) = NULL; + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_split_rend_huffman_decode_opt() + * + * + *-----------------------------------------------------------------------------------------*/ + +static Word16 ivas_split_rend_huffman_decode_opt( + isar_split_rend_huffman_cfg_t *huff_cfg, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word16 *idx_trav_list ) +{ + Word32 i, ind, code, num_bits, code_b, num_bits_read; + const Word32 *codebook; + + codebook = huff_cfg->codebook; + num_bits_read = 0; + move32(); + ind = L_sub( huff_cfg->codebook[0], 1 ); + code = 0; + move32(); + FOR( i = 0; i < huff_cfg->sym_len; i++ ) + { + codebook = codebook + idx_trav_list[i] * 3; + num_bits = codebook[1]; + move32(); + code_b = codebook[2]; + move32(); + num_bits_read = L_sub( num_bits, num_bits_read ); + code = L_shl( code, extract_l( num_bits_read ) ); + IF( GT_32( num_bits_read, 0 ) ) + { + code = L_or( code, ISAR_SPLIT_REND_BITStream_read_int32( pBits, num_bits_read ) ); + } + + IF( EQ_32( code, code_b ) ) + { + ind = codebook[0]; + move32(); + BREAK; + } + + num_bits_read = num_bits; + move32(); + codebook = huff_cfg->codebook; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + assert( ind >= huff_cfg->codebook[0] ); +#endif + return extract_l( ind ); +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_split_rend_unquant_md() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void ivas_split_rend_unquant_md_fx( + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd, + ISAR_SPLIT_REND_POSE_TYPE pose_type, + Word16 real_only, + Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS], + const Word32 pred_quant_step ) +{ + Word16 ch1, ch2; + Word16 gd_idx_min; + + test(); + IF( EQ_32( pose_type, PRED_ONLY ) || EQ_32( pose_type, PRED_ROLL_ONLY ) ) + { + Word32 quantstep; + + quantstep = pred_quant_step; + move32(); +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_re_fx[ch1][ch2] = Mpy_32_16_1( quantstep, extract_l( L_shl( hMd->pred_mat_re_idx[ch1][ch2], Q9 ) ) ); /* Q25 */ + move32(); + hMd->pred_mat_re_fx[ch1][ch2] = L_add( hMd->pred_mat_re_fx[ch1][ch2], L_shr( fix_pos_rot_mat[ch1][ch2], Q6 ) ); /* Q25 */ + move32(); + } + } +#endif + + IF( real_only ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_re_fx[ch1][ch2] = Mpy_32_16_1( quantstep, extract_l( L_shl( hMd->pred_mat_re_idx[ch1][ch2], Q9 ) ) ); /* Q25 */ + move32(); + hMd->pred_mat_re_fx[ch1][ch2] = L_add( hMd->pred_mat_re_fx[ch1][ch2], L_shr( ( ch1 == ch2 ) ? ONE_IN_Q31 : 0, Q6 ) ); /* Q25 */ + move32(); + } + } +#endif + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_im_fx[ch1][ch2] = 0; /* Q25 */ + move32(); + } + } + } + ELSE + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_re_fx[ch1][ch2] = Mpy_32_16_1( quantstep, extract_l( L_shl( hMd->pred_mat_re_idx[ch1][ch2], Q9 ) ) ); /* Q25 */ + move32(); + hMd->pred_mat_re_fx[ch1][ch2] = L_add( hMd->pred_mat_re_fx[ch1][ch2], L_shr( fix_pos_rot_mat[ch1][ch2], Q6 ) ); /* Q25 */ + move32(); + } + } +#endif + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_im_fx[ch1][ch2] = Mpy_32_16_1( quantstep, extract_l( L_shl( hMd->pred_mat_im_idx[ch1][ch2], Q9 ) ) ); /* Q25 */ + move32(); + } + } + } + } + ELSE IF( EQ_32( pose_type, COM_GAIN_ONLY ) ) + { + gd_idx_min = 0; + move16(); + hMd->gd_idx = add( hMd->gd_idx, gd_idx_min ); + hMd->gd_fx = Mpy_32_16_1( ISAR_SPLIT_REND_D_Q_STEP_Q31, extract_l( L_shl( hMd->gd_idx, Q9 ) ) ); /* Q25 */ + } + ELSE IF( EQ_32( pose_type, LR_GAIN_ONLY ) ) + { + gd_idx_min = 7; + move16(); + hMd->gd_idx = add( hMd->gd_idx, gd_idx_min ); + hMd->gd_fx = Mpy_32_16_1( ISAR_SPLIT_REND_PITCH_G_Q_STEP_Q31, extract_l( L_shl( hMd->gd_idx, Q9 ) ) ); /* Q25 */ + + hMd->gd2_idx = add( hMd->gd2_idx, gd_idx_min ); + hMd->gd2_fx = Mpy_32_16_1( ISAR_SPLIT_REND_PITCH_G_Q_STEP_Q31, extract_l( L_shl( hMd->gd2_idx, Q9 ) ) ); /* Q25 */ + } + ELSE + { + hMd->gd_fx = 0; /* Q25 */ + move32(); + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function isar_splitBinPostRendMdBase2Dec() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void isar_splitBinPostRendMdBase2Dec( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word16 num_subframes, + const Word16 pred_real_bands_yaw, + const Word16 pred_imag_bands_yaw, + const Word16 pred_quant_pnts_yaw, + const Word16 d_bands_yaw, + const Word16 bands_pitch, + const Word16 pred_real_bands_roll, + const Word16 pred_imag_bands_roll ) +{ + Word16 sf_idx, pos_idx, b, ch1, ch2; + Word16 min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len; + Word16 min_pred_roll_idx, pred_roll_code_len; + Word16 pred_cb_idx; + Word16 code; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; + + IF( EQ_16( pred_quant_pnts_yaw, ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) ) + { + pred_cb_idx = 1; + move16(); + } + ELSE + { + pred_cb_idx = 0; + move16(); + } + min_pred_idx = extract_l( pHuff_cfg->pred[pred_cb_idx].codebook[0] ); + min_pred_roll_idx = extract_l( pHuff_cfg->pred_roll.codebook[0] ); + min_gd_idx = extract_l( pHuff_cfg->gd.codebook[0] ); + min_p_gd_idx = extract_l( pHuff_cfg->p_gd.codebook[0] ); + pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx]; + move16(); + pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; + move16(); + gd_code_len = pHuff_cfg->gd_base2_code_len; + move16(); + p_gd_code_len = pHuff_cfg->p_gd_base2_code_len; + move16(); + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( pos_idx = 0; pos_idx < sub( pMultiBinPoseData->num_poses, 1 ); pos_idx++ ) + { + IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], ANY_YAW ) ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); + hMd->pred_mat_re_idx[ch1][ch2] = add( code, min_pred_idx ); + move16(); + } + } + } + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); + hMd->pred_mat_im_idx[ch1][ch2] = add( code, min_pred_idx ); + move16(); + } + } + } +#else + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); + hMd->pred_mat_re_idx[ch1][ch2] = add( code, min_pred_idx ); + move16(); + } + } + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); + hMd->pred_mat_im_idx[ch1][ch2] = add( code, min_pred_idx ); + move16(); + } + } + } + FOR( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); + hMd->pred_mat_re_idx[ch1][ch1] = add( code, min_pred_idx ); + move16(); + } + hMd->pred_mat_re_idx[0][1] = 0; + move16(); + hMd->pred_mat_re_idx[1][0] = 0; + move16(); + } +#endif + FOR( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, gd_code_len ) ); + hMd->gd_idx = add( code, min_gd_idx ); + move16(); + } + } + ELSE IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], PITCH_ONLY ) ) + { + FOR( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, p_gd_code_len ) ); + hMd->gd_idx = add( code, min_p_gd_idx ); + move16(); + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, p_gd_code_len ) ); + hMd->gd2_idx = add( code, min_p_gd_idx ); + move16(); + } + } + ELSE + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); + hMd->pred_mat_re_idx[ch1][ch2] = add( code, min_pred_roll_idx ); + move16(); + } + } + } + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); + hMd->pred_mat_im_idx[ch1][ch2] = add( code, min_pred_roll_idx ); + move16(); + } + } + } +#else + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); + hMd->pred_mat_re_idx[ch1][ch2] = add( code, min_pred_roll_idx ); + move16(); + } + } + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); + hMd->pred_mat_im_idx[ch1][ch2] = add( code, min_pred_roll_idx ); + move16(); + } + } + } + FOR( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); + hMd->pred_mat_re_idx[ch1][ch1] = add( code, min_pred_roll_idx ); + move16(); + } + hMd->pred_mat_re_idx[0][1] = 0; + move16(); + hMd->pred_mat_re_idx[1][0] = 0; + move16(); + } +#endif + } + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function ivas_splitBinPostRendMdHuffDec() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void ivas_splitBinPostRendMdHuffDec( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word16 num_subframes, + const Word16 pred_real_bands_yaw, + const Word16 pred_imag_bands_yaw, + const Word16 pred_quant_pnts_yaw, + const Word16 d_bands_yaw, + const Word16 bands_pitch, + const Word16 pred_real_bands_roll, + const Word16 pred_imag_bands_roll ) +{ + Word16 pos_idx, b, sf_idx; + Word16 ch1, ch2; + Word16 sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 min_pred_idx, max_pred_idx; + Word16 min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; + + IF( EQ_16( pred_quant_pnts_yaw, ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) ) + { + pred_cb_idx = 1; + move16(); + } + ELSE + { + pred_cb_idx = 0; + move16(); + } + min_pred_idx = extract_l( pHuff_cfg->pred[pred_cb_idx].codebook[0] ); + max_pred_idx = extract_l( pHuff_cfg->pred[pred_cb_idx].codebook[( pred_quant_pnts_yaw - 1 ) * 3] ); + + min_pred_roll_idx = extract_l( pHuff_cfg->pred_roll.codebook[0] ); + max_pred_roll_idx = extract_l( pHuff_cfg->pred_roll.codebook[( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3] ); + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( pos_idx = 0; pos_idx < sub( pMultiBinPoseData->num_poses, 1 ); pos_idx++ ) + { + IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], ANY_YAW ) ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_idx, max_pred_idx ); + } + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx ); + } +#else + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_idx, max_pred_idx ); + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx ); + } + FOR( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + sym_adj_idx[ch1][ch1] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + move16(); + } + sym_adj_idx[1][0] = 0; + move16(); + sym_adj_idx[0][1] = 0; + move16(); + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_idx, max_pred_idx ); + } +#endif + FOR( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd_idx = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->gd, pBits, pHuff_cfg->gd_idx_trav ); + // hMd->gd_idx = ivas_split_rend_huffman_decode( &pHuff_cfg->gd, pBits ); + } + } + ELSE IF( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + FOR( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd_idx = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->p_gd, pBits, pHuff_cfg->p_gd_idx_trav ); + // hMd->gd_idx = ivas_split_rend_huffman_decode( &pHuff_cfg->gd, pBits ); + + hMd->gd2_idx = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->p_gd, pBits, pHuff_cfg->p_gd_idx_trav ); + } + } + ELSE + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + } + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } +#else + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + move16(); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } + FOR( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + sym_adj_idx[ch1][ch1] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + move16(); + } + sym_adj_idx[1][0] = 0; + move16(); + sym_adj_idx[0][1] = 0; + move16(); + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } +#endif + } + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_splitBinPostRendMdDec() + * + * + *-----------------------------------------------------------------------------------------*/ + +void isar_splitBinPostRendMdDec_fx( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend +#endif +) +{ + Word16 pos_idx, b, sf_idx, num_subframes, ch1; + Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word16 d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word16 num_quant_strats; +#else + Word16 num_complex_bands, num_quant_strats; +#endif + Word32 quant_strat_bits, is_huff_coding, quant_strat; + Word16 pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word32 pred_1byquantstep_yaw_fx[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; // Q26 + Word32 pred_quantstep_yaw_fx[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; // Q31 +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + Word16 ch1, ch2; +#endif + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; + ISAR_SPLIT_REND_ROT_AXIS rot_axis; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word16 ro_md_flag, num_bits, axis_code; +#endif + + hBinHrSplitPostRend->low_Res = 1; + move16(); + + split_rend_config.dof = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_DOF_BITS ) ); + split_rend_config.hq_mode = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HQ_MODE_BITS ) ); + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + num_bits = isar_renderSplitGetRot_axisNumBits( split_rend_config.dof ); + if ( num_bits > 0 ) + { + axis_code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, (int32_t) num_bits ); + } + else + { + axis_code = 0; + } + rot_axis = isar_renderSplitGetRot_axisFromCode( split_rend_config.dof, axis_code ); + ro_md_flag = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_RO_FLAG_BITS ); +#else + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_ROT_AXIS_BITS ); +#endif + isar_renderSplitGetMultiBinPoseData_fx( &split_rend_config, pMultiBinPoseData, rot_axis ); + + set_fix_rotation_mat_fx( hBinHrSplitPostRend->fix_pos_rot_mat_fx, pMultiBinPoseData ); + set_pose_types_fx( hBinHrSplitPostRend->pose_type, pMultiBinPoseData ); + + num_subframes = EQ_16( hBinHrSplitPostRend->low_Res, 0 ) ? MAX_PARAM_SPATIAL_SUBFRAMES : 1; + move16(); + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + Word16 angle; + + hBinHrSplitPostRend->QuaternionsPre[sf_idx].w_fx = -12582912; /* -3.0f in Q22 */ + move32(); + + angle = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS ) ); + angle = sub( angle, 180 ); + hBinHrSplitPostRend->QuaternionsPre[sf_idx].x_fx = L_shl( angle, Q22 ); /* Q22 */ + move32(); + + angle = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS ) ); + angle = sub( angle, 180 ); + hBinHrSplitPostRend->QuaternionsPre[sf_idx].y_fx = L_shl( angle, Q22 ); /* Q22 */ + move32(); + + angle = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS ) ); + angle = sub( angle, 180 ); + hBinHrSplitPostRend->QuaternionsPre[sf_idx].z_fx = L_shl( angle, Q22 ); /* Q22 */ + move32(); + } + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + isar_split_rend_get_quant_params_fx( + MAX_SPLIT_REND_MD_BANDS, + pred_real_bands_yaw, + pred_imag_bands_yaw, + pred_quant_pnts_yaw, + pred_quantstep_yaw_fx, + pred_1byquantstep_yaw_fx, + d_bands_yaw, + bands_pitch, + pred_real_bands_roll, + pred_imag_bands_roll, + ro_md_flag, + &num_quant_strats ); +#else + isar_split_rend_get_quant_params_fx( + MAX_SPLIT_REND_MD_BANDS, + pred_real_bands_yaw, + pred_imag_bands_yaw, + pred_quant_pnts_yaw, + pred_quantstep_yaw_fx, + pred_1byquantstep_yaw_fx, + d_bands_yaw, + bands_pitch, + pred_real_bands_roll, + pred_imag_bands_roll, + &num_quant_strats, + &num_complex_bands ); +#endif + quant_strat_bits = L_deposit_l( ceil_log_2( num_quant_strats ) ); + is_huff_coding = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + quant_strat = ISAR_SPLIT_REND_BITStream_read_int32( pBits, quant_strat_bits ); + + IF( EQ_32( is_huff_coding, 0 ) ) + { + isar_splitBinPostRendMdBase2Dec( + pBits, hBinHrSplitPostRend, + pMultiBinPoseData, + num_subframes, + pred_real_bands_yaw[quant_strat], + pred_imag_bands_yaw[quant_strat], + pred_quant_pnts_yaw[quant_strat], + d_bands_yaw[quant_strat], + bands_pitch[quant_strat], + pred_real_bands_roll[quant_strat], + pred_imag_bands_roll[quant_strat] ); + } + ELSE + { + ivas_splitBinPostRendMdHuffDec( + pBits, hBinHrSplitPostRend, + pMultiBinPoseData, + num_subframes, + pred_real_bands_yaw[quant_strat], + pred_imag_bands_yaw[quant_strat], + pred_quant_pnts_yaw[quant_strat], + d_bands_yaw[quant_strat], + bands_pitch[quant_strat], + pred_real_bands_roll[quant_strat], + pred_imag_bands_roll[quant_strat] ); + } +#ifdef SPLIT_MD_CODING_DEBUG + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + int16_t val, ch2, val_ref; + char filename[200] = "split_md_debug_indices.bin"; + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd2_idx; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + else + { + for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + } + } + } +#endif + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( pos_idx = 0; pos_idx < sub( pMultiBinPoseData->num_poses, 1 ); pos_idx++ ) + { + IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], ANY_YAW ) ) + { + FOR( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + ivas_split_rend_unquant_md_fx( hMd, PRED_ONLY, 0, hBinHrSplitPostRend->fix_pos_rot_mat_fx[pos_idx], pred_quantstep_yaw_fx[quant_strat] ); + } + FOR( ; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + ivas_split_rend_unquant_md_fx( hMd, PRED_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat_fx[pos_idx], pred_quantstep_yaw_fx[quant_strat] ); + } + FOR( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + set32_fx( hMd->pred_mat_re_fx[ch1], 0, BINAURAL_CHANNELS ); + set32_fx( hMd->pred_mat_im_fx[ch1], 0, BINAURAL_CHANNELS ); + hMd->pred_mat_re_fx[ch1][ch1] = L_shl( 1, Q25 ); /* 1.0f in Q25 */ + move32(); + } + } + FOR( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + ivas_split_rend_unquant_md_fx( hMd, COM_GAIN_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat_fx[pos_idx], 0 ); + } + FOR( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd_fx = 0; + move32(); + } + } + ELSE IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], PITCH_ONLY ) ) + { + FOR( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + ivas_split_rend_unquant_md_fx( hMd, LR_GAIN_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat_fx[pos_idx], 0 ); + } + FOR( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd_fx = L_shl( 1, Q25 ); /* 1.0f in Q25 */ + move32(); + hMd->gd2_fx = L_shl( 1, Q25 ); /* 1.0f in Q25 */ + move32(); + } + } + ELSE + { + FOR( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + ivas_split_rend_unquant_md_fx( hMd, PRED_ROLL_ONLY, 0, hBinHrSplitPostRend->fix_pos_rot_mat_fx[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_Q_STEP_Q31 ); + } + FOR( ; b < pred_real_bands_roll[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + ivas_split_rend_unquant_md_fx( hMd, PRED_ROLL_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat_fx[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_Q_STEP_Q31 ); + } + FOR( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + set32_fx( hMd->pred_mat_re_fx[ch1], 0, BINAURAL_CHANNELS ); + set32_fx( hMd->pred_mat_im_fx[ch1], 0, BINAURAL_CHANNELS ); + hMd->pred_mat_re_fx[ch1][ch1] = L_shl( 1, Q25 ); /* 1.0f in Q25 */ + move32(); + } + } + } + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + float val; + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_re_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_im_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + if ( fabsf( hMd->gd_idx - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + if ( fabsf( hMd->gd_idx - val ) > 1e-20 ) + { + assert( 0 ); + } + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_idx; + if ( fabsf( hMd->gd2_idx - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + else + { + for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_re_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_im_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + } + } + } +#endif + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function wrap_around_angle() + * + * + *-----------------------------------------------------------------------------------------*/ +static void wrap_around_angle_fx( + Word32 *a_fx ) +{ + IF( GT_32( ( *a_fx ), 754974720 /*180.f in Q22*/ ) ) + { + *a_fx = L_sub( ( *a_fx ), 1509949440 /*360.f in Q22*/ ); + } + ELSE IF( LT_32( ( *a_fx ), L_negate( 754974720 /*180.f in Q22*/ ) ) ) + { + *a_fx = L_add( *a_fx, 1509949440 /*360.f in Q22*/ ); + } + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function wrap_around_angle() + * + * + *-----------------------------------------------------------------------------------------*/ +static void wrap_around_ypr_fx( + IVAS_QUATERNION *Quaternions ) +{ + /*only if quat is actually yaw, pitch , roll angles*/ + IF( EQ_32( Quaternions->w_fx, L_negate( 12582912 /*3.0f in Q22*/ ) ) ) + { + wrap_around_angle_fx( &Quaternions->x_fx ); + wrap_around_angle_fx( &Quaternions->y_fx ); + wrap_around_angle_fx( &Quaternions->z_fx ); + } + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function wrap_around_angle() + * + * + *-----------------------------------------------------------------------------------------*/ +static Word32 get_interp_fact_fx( + Word32 p_fx[MAX_HEAD_ROT_POSES], + const Word32 p_t_fx, + const Word16 ind[2], + Word16 *exp ) +{ + Word32 n_fx, d_fx, interp_fact_fx; + *exp = 31; + move16(); + IF( NE_16( ind[0], ind[1] ) ) + { + n_fx = L_sub( p_fx[ind[0]], p_fx[ind[1]] ); + move32(); + d_fx = L_sub( p_fx[ind[0]], p_t_fx ); + move32(); + interp_fact_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( d_fx, n_fx, exp ) ); // Q31-exp + move32(); + IF( LT_32( interp_fact_fx, 0 ) ) + { + d_fx = max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) ); + move32(); + n_fx = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_32( n_fx, Q31_BY_360 ), 7 ) ) ) ); + move32(); + d_fx = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_32( d_fx, Q31_BY_360 ), 7 ) ) ) ); + move32(); + interp_fact_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( d_fx, n_fx, exp ) ); // Q31-exp + move32(); + } + } + ELSE + { + interp_fact_fx = 0; + move32(); + } + return interp_fact_fx; +} + +/*-----------------------------------------------------------------------------------------* + * Function get_nearest_pose_ind() + * + * + *-----------------------------------------------------------------------------------------*/ +static void get_nearest_pose_ind_fx( + Word32 p[MAX_HEAD_ROT_POSES], + const Word32 p_t, + Word16 ind[2], + const Word16 num_poses ) +{ + Word32 min_diff, diff; + Word16 pos_idx; + + ind[0] = 0; + ind[1] = 0; + min_diff = 1509949440; // 360 in Q22 + + /*find the closest pose from assumed poses*/ + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + diff = L_abs( L_sub( p_t, p[pos_idx] ) ); + IF( LT_32( diff, min_diff ) ) + { + ind[0] = pos_idx; + min_diff = diff; + } + } + + min_diff = 1509949440; // 360 in Q22 + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + diff = L_abs( L_sub( p_t, p[pos_idx] ) ); + IF( LT_32( diff, min_diff ) && + GT_32( L_abs( L_sub( p[pos_idx], p[ind[0]] ) ), EPSILON_FX ) ) + { + ind[1] = pos_idx; + min_diff = diff; + } + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function get_interpolation_vars() + * + * + *-----------------------------------------------------------------------------------------*/ +static void get_interpolation_vars( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION *Quaternions_ref, + const IVAS_QUATERNION *Quaternions_act, + int16_t interp_yaw_pose_idx[2], + int16_t interp_pitch_pose_idx[2], + int16_t interp_roll_pose_idx[2], + Word32 *interp_yaw_fact_fx, + Word32 *interp_pitch_fact_fx, + Word32 *interp_roll_fact_fx, + Word16 *q_yaw, + Word16 *q_pitch, + Word16 *q_roll ) +{ + IVAS_QUATERNION quaternions_diff, quaternions_ref_euler, quaternions_act_euler; + Word32 y_fx[MAX_HEAD_ROT_POSES], p_fx[MAX_HEAD_ROT_POSES], r_fx[MAX_HEAD_ROT_POSES]; + + int16_t pos_idx, num_poses; + Word16 exp; + + quaternions_diff.x_fx = 0; + quaternions_diff.y_fx = 0; + quaternions_diff.z_fx = 0; + + num_poses = pMultiBinPoseData->num_poses; + + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + quaternions_diff.x_fx = pMultiBinPoseData->relative_head_poses_fx[pos_idx][0]; + quaternions_diff.y_fx = pMultiBinPoseData->relative_head_poses_fx[pos_idx][1]; + quaternions_diff.z_fx = pMultiBinPoseData->relative_head_poses_fx[pos_idx][2]; + y_fx[pos_idx] = quaternions_diff.x_fx; + p_fx[pos_idx] = quaternions_diff.y_fx; + r_fx[pos_idx] = quaternions_diff.z_fx; + } + + /*interpolation if actual pose is not same as one of assumed poses*/ + /*get the deviation*/ + Quat2EulerDegree_fx( *Quaternions_ref, &quaternions_ref_euler.z_fx, &quaternions_ref_euler.y_fx, &quaternions_ref_euler.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + Quat2EulerDegree_fx( *Quaternions_act, &quaternions_act_euler.z_fx, &quaternions_act_euler.y_fx, &quaternions_act_euler.x_fx ); + + /*order in Quat2Euler seems to be reversed ?*/ + quaternions_diff.w_fx = -12582912; /*euler*/ //-3 in Q22 + quaternions_diff.x_fx = L_sub( quaternions_act_euler.x_fx, quaternions_ref_euler.x_fx ); + quaternions_diff.y_fx = L_sub( quaternions_act_euler.y_fx, quaternions_ref_euler.y_fx ); + quaternions_diff.z_fx = L_sub( quaternions_act_euler.z_fx, quaternions_ref_euler.z_fx ); + wrap_around_ypr_fx( &quaternions_diff ); + interp_yaw_pose_idx[0] = 0; + interp_yaw_pose_idx[1] = 0; + IF( GT_32( L_abs( quaternions_diff.x_fx ), EPSILON_FX ) ) + { + get_nearest_pose_ind_fx( y_fx, quaternions_diff.x_fx, interp_yaw_pose_idx, num_poses ); + } + *interp_yaw_fact_fx = get_interp_fact_fx( y_fx, quaternions_diff.x_fx, interp_yaw_pose_idx, &exp ); + *q_yaw = Q31 - exp; + + interp_pitch_pose_idx[0] = 0; + interp_pitch_pose_idx[1] = 0; + IF( GT_32( L_abs( quaternions_diff.y_fx ), EPSILON_FX ) ) + { + get_nearest_pose_ind_fx( p_fx, quaternions_diff.y_fx, interp_pitch_pose_idx, num_poses ); + } + *interp_pitch_fact_fx = get_interp_fact_fx( p_fx, quaternions_diff.y_fx, interp_pitch_pose_idx, &exp ); + *q_pitch = Q31 - exp; + + interp_roll_pose_idx[0] = 0; + interp_roll_pose_idx[1] = 0; + IF( GT_32( L_abs( quaternions_diff.z_fx ), EPSILON_FX ) ) + { + get_nearest_pose_ind_fx( r_fx, quaternions_diff.z_fx, interp_roll_pose_idx, num_poses ); + } + *interp_roll_fact_fx = get_interp_fact_fx( r_fx, quaternions_diff.z_fx, interp_roll_pose_idx, &exp ); + *q_roll = Q31 - exp; + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function interpolate_pred_matrix() + * + * + *-----------------------------------------------------------------------------------------*/ +static void interpolate_pred_matrix_fx( + ISAR_BIN_HR_SPLIT_REND_MD rot_md[][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS], + const Word16 sf_idx, + const Word16 band_idx, + const Word16 ind[2], + const Word32 interp_fact_fx, + Word16 intrep_norm, + Word32 mat_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *exp_mat_re, + Word32 mat_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *exp_mat_im ) +{ + Word16 ch_idx1, ch_idx2; + ISAR_BIN_HR_SPLIT_REND_MD *pRot_md; + // ord16 intrep_norm = Q_factor_L(interp_fact); + // ord32 interp_fact_fx = floatToFixed(interp_fact, intrep_norm); + Word32 diff_fx; + Word32 mix_mat_re1_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_im1_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_re2_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_im2_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 buff_exp_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], buff_exp_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set32_fx( mix_mat_re1_fx[ch_idx1], 0, BINAURAL_CHANNELS ); + set32_fx( mix_mat_im1_fx[ch_idx1], 0, BINAURAL_CHANNELS ); + mix_mat_re1_fx[ch_idx1][ch_idx1] = ONE_IN_Q25; + + set32_fx( mix_mat_re2_fx[ch_idx1], 0, BINAURAL_CHANNELS ); + set32_fx( mix_mat_im2_fx[ch_idx1], 0, BINAURAL_CHANNELS ); + mix_mat_re2_fx[ch_idx1][ch_idx1] = ONE_IN_Q25; + } + + IF( ind[0] != 0 ) + { + pRot_md = &rot_md[ind[0] - 1][sf_idx][band_idx]; + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + mix_mat_re1_fx[ch_idx1][ch_idx2] = pRot_md->pred_mat_re_fx[ch_idx1][ch_idx2]; + mix_mat_im1_fx[ch_idx1][ch_idx2] = pRot_md->pred_mat_im_fx[ch_idx1][ch_idx2]; + } + } + } + + IF( ind[1] != 0 ) + { + pRot_md = &rot_md[ind[1] - 1][sf_idx][band_idx]; + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + mix_mat_re2_fx[ch_idx1][ch_idx2] = pRot_md->pred_mat_re_fx[ch_idx1][ch_idx2]; + mix_mat_im2_fx[ch_idx1][ch_idx2] = pRot_md->pred_mat_im_fx[ch_idx1][ch_idx2]; + } + } + } + + Word16 final_exp = 0, mat_re_exp = 0, mat_im_exp = 0; + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + final_exp = 0; + diff_fx = BASOP_Util_Add_Mant32Exp( mix_mat_re1_fx[ch_idx1][ch_idx2], 31 - Q25, L_negate( mix_mat_re2_fx[ch_idx1][ch_idx2] ), 31 - Q25, &final_exp ); + Word64 tmp1 = W_mult_32_32( diff_fx, interp_fact_fx ); // final_exp + (31 - intrep_norm) + Word16 tmp1_nrm = W_norm( tmp1 ); + Word32 tmp1_final = W_extract_h( W_shl( tmp1, tmp1_nrm ) ); // final_exp + (31 - intrep_norm) - tmp1_nrm + mat_re_exp = 0; + mat_re_fx[ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( mix_mat_re1_fx[ch_idx1][ch_idx2], 31 - Q25, L_negate( tmp1_final ), final_exp + ( 31 - intrep_norm ) - tmp1_nrm, &mat_re_exp ); + buff_exp_re[ch_idx1][ch_idx2] = mat_re_exp; + + final_exp = 0; + diff_fx = BASOP_Util_Add_Mant32Exp( mix_mat_im1_fx[ch_idx1][ch_idx2], 31 - Q25, L_negate( mix_mat_im2_fx[ch_idx1][ch_idx2] ), 31 - Q25, &final_exp ); + Word64 tmp2 = W_mult_32_32( diff_fx, interp_fact_fx ); // final_exp + (31 - intrep_norm) + Word16 tmp2_nrm = W_norm( tmp2 ); + Word32 tmp2_final = W_extract_h( W_shl( tmp2, tmp2_nrm ) ); // final_exp + (31 - intrep_norm) - tmp1_nrm + mat_im_exp = 0; + mat_im_fx[ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( mix_mat_im1_fx[ch_idx1][ch_idx2], 31 - Q25, L_negate( tmp2_final ), final_exp + ( 31 - intrep_norm ) - tmp2_nrm, &mat_im_exp ); + buff_exp_im[ch_idx1][ch_idx2] = mat_im_exp; + } + } + + Word16 max_exp_re = MIN16B; + Word16 max_exp_im = MIN16B; + FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) + { + max_exp_re = max( max_exp_re, buff_exp_re[i][j] ); + max_exp_im = max( max_exp_im, buff_exp_im[i][j] ); + } + } + FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) + { + mat_re_fx[i][j] = L_shr( mat_re_fx[i][j], max_exp_re - buff_exp_re[i][j] ); + mat_im_fx[i][j] = L_shr( mat_im_fx[i][j], max_exp_im - buff_exp_im[i][j] ); + } + } + + *exp_mat_re = max_exp_re; + *exp_mat_im = max_exp_im; + + return; +} +/*-----------------------------------------------------------------------------------------* + * Function interpolate_rend_md() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void interpolate_rend_md_fx( + ISAR_BIN_HR_SPLIT_REND_MD rot_md[][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS], + Word32 mix_mat_re_fx[][BINAURAL_CHANNELS], + Word16 *exp_mix_mat_re, + Word32 mix_mat_im_fx[][BINAURAL_CHANNELS], + Word16 *exp_mix_mat_im, + Word32 *gd_int_fx, + Word16 *exp_gd_int, + const Word16 sf_idx, + const Word16 band_idx, + const Word16 interp_yaw_pose_idx[2], + const Word16 interp_pitch_pose_idx[2], + const Word16 interp_roll_pose_idx[2], + const Word32 interp_yaw_fact_fx, + Word16 Q_yaw, + const Word32 interp_pitch_fact_fx, + Word16 Q_pitch, + const Word32 interp_roll_fact_fx, + Word16 Q_roll ) +{ + Word16 ch_idx1, idx1, idx2; + + Word32 mix_mat_re1_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_im1_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_re3_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_im3_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + Word16 exp_mix_mat_re1 = 0; + Word16 exp_mix_mat_im1 = 0; + Word16 exp_mix_mat_re3 = 0; + Word16 exp_mix_mat_im3 = 0; + + Word16 ch_idx2; + Word16 exp_pitch_gain_r, exp_pitch_gain_l; + Word32 gd1_fx = 0, gd2_fx = 0; + Word32 gd3_fx = 0, gd4_fx = 0; + Word32 pitch_gain_r_fx, pitch_gain_l_fx; + Word32 diff_fx; + + Word16 exp_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 exp_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + idx1 = interp_yaw_pose_idx[0]; + idx2 = interp_yaw_pose_idx[1]; + + + IF( NE_16( idx1, 0 ) || NE_16( idx2, 0 ) ) + { + interpolate_pred_matrix_fx( rot_md, sf_idx, band_idx, interp_yaw_pose_idx, interp_yaw_fact_fx, Q_yaw, mix_mat_re_fx, exp_mix_mat_re, mix_mat_im_fx, exp_mix_mat_im ); + + IF( NE_16( idx1, 0 ) ) + { + gd1_fx = rot_md[idx1 - 1][sf_idx][band_idx].gd_fx; // Q25 + } + + IF( NE_16( idx2, 0 ) ) + { + gd2_fx = rot_md[idx2 - 1][sf_idx][band_idx].gd_fx; + } + diff_fx = L_sub( gd1_fx, gd2_fx ); // Q25 + Word32 tmp1 = Mpy_32_32( diff_fx, interp_yaw_fact_fx ); // 6+Q_yaw + Word16 exp_tmp2 = 0; + Word32 tmp2 = BASOP_Util_Add_Mant32Exp( diff_fx, 31 - Q25, L_negate( tmp1 ), 6 + Q_yaw, &exp_tmp2 ); + *gd_int_fx = tmp2; + *exp_gd_int = exp_tmp2; + } + ELSE + { + /*P = P'*/ + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) + { + mix_mat_re_fx[ch_idx1][j] = 0; + mix_mat_im_fx[ch_idx1][j] = 0; + mix_mat_re_fx[ch_idx1][ch_idx1] = ONE_IN_Q25; + } + } + + *exp_mix_mat_re = 6; + *exp_mix_mat_im = 6; + + *gd_int_fx = 0; + *exp_gd_int = 0; + } + + idx1 = interp_pitch_pose_idx[0]; + idx2 = interp_pitch_pose_idx[1]; + IF( NE_16( idx1, 0 ) || NE_16( idx2, 0 ) ) + { + gd1_fx = ONE_IN_Q25; + gd2_fx = ONE_IN_Q25; + + gd3_fx = ONE_IN_Q25; + gd4_fx = ONE_IN_Q25; + + IF( NE_16( idx1, 0 ) ) + { + gd1_fx = rot_md[idx1 - 1][sf_idx][band_idx].gd_fx; + gd3_fx = rot_md[idx1 - 1][sf_idx][band_idx].gd2_fx; + } + IF( NE_16( idx2, 0 ) ) + { + gd2_fx = rot_md[idx2 - 1][sf_idx][band_idx].gd_fx; + gd4_fx = rot_md[idx2 - 1][sf_idx][band_idx].gd2_fx; + } + + diff_fx = L_sub( gd1_fx, gd2_fx ); // Q25 + IF( EQ_32( diff_fx, -1 ) ) + { + diff_fx = 0; + } + Word32 tmp = Mpy_32_32( diff_fx, interp_pitch_fact_fx ); // 6 + Q_pitch + Word16 exp_tmp1 = 0; + Word32 tmp1 = BASOP_Util_Add_Mant32Exp( gd1_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 ); + pitch_gain_l_fx = tmp1; + pitch_gain_l_fx = max( 0, pitch_gain_l_fx ); + exp_pitch_gain_l = exp_tmp1; + + diff_fx = L_sub( gd3_fx, gd4_fx ); + IF( EQ_32( diff_fx, -1 ) ) + { + diff_fx = 0; + } + tmp = Mpy_32_32( diff_fx, interp_pitch_fact_fx ); + exp_tmp1 = 0; + tmp1 = BASOP_Util_Add_Mant32Exp( gd3_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 ); + pitch_gain_r_fx = tmp1; + pitch_gain_r_fx = max( 0, pitch_gain_r_fx ); + exp_pitch_gain_r = exp_tmp1; + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + mix_mat_re_fx[ch_idx1][0] = Mpy_32_32( mix_mat_re_fx[ch_idx1][0], pitch_gain_l_fx ); // exp_mix_mat_re + exp_pitch_gain_l + exp_mat_re[ch_idx1][0] = *exp_mix_mat_re + exp_pitch_gain_l; + mix_mat_re_fx[ch_idx1][1] = Mpy_32_32( mix_mat_re_fx[ch_idx1][1], pitch_gain_r_fx ); // exp_mix_mat_re + exp_pitch_gain_r + exp_mat_re[ch_idx1][1] = *exp_mix_mat_re + exp_pitch_gain_r; + mix_mat_im_fx[ch_idx1][0] = Mpy_32_32( mix_mat_im_fx[ch_idx1][0], pitch_gain_l_fx ); // exp_mix_mat_im + exp_pitch_gain_l + exp_mat_im[ch_idx1][0] = *exp_mix_mat_im + exp_pitch_gain_l; + mix_mat_im_fx[ch_idx1][1] = Mpy_32_32( mix_mat_im_fx[ch_idx1][1], pitch_gain_r_fx ); // exp_mix_mat_im + exp_pitch_gain_r + exp_mat_im[ch_idx1][1] = *exp_mix_mat_im + exp_pitch_gain_r; + } + + Word16 max_exp_re = MIN16B, max_exp_im = MIN16B; + FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) + { + max_exp_re = max( max_exp_re, exp_mat_re[i][j] ); + max_exp_im = max( max_exp_im, exp_mat_im[i][j] ); + } + } + + FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) + { + mix_mat_re_fx[i][j] = L_shr( mix_mat_re_fx[i][j], max_exp_re - exp_mat_re[i][j] ); + mix_mat_im_fx[i][j] = L_shr( mix_mat_im_fx[i][j], max_exp_im - exp_mat_im[i][j] ); + } + } + + *exp_mix_mat_re = max_exp_re; + *exp_mix_mat_im = max_exp_im; + } + ELSE + { + pitch_gain_l_fx = ONE_IN_Q25; + pitch_gain_r_fx = ONE_IN_Q25; + } + + + idx1 = interp_roll_pose_idx[0]; + idx2 = interp_roll_pose_idx[1]; + IF( NE_16( idx1, 0 ) || NE_16( idx2, 0 ) ) + { + interpolate_pred_matrix_fx( rot_md, sf_idx, band_idx, interp_roll_pose_idx, interp_roll_fact_fx, Q_roll, mix_mat_re3_fx, &exp_mix_mat_re3, mix_mat_im3_fx, &exp_mix_mat_im3 ); + + isar_mat_mult_2by2_complex_fx( mix_mat_re_fx, *exp_mix_mat_re, mix_mat_im_fx, *exp_mix_mat_im, mix_mat_re3_fx, exp_mix_mat_re3, + mix_mat_im3_fx, exp_mix_mat_im3, mix_mat_re1_fx, &exp_mix_mat_re1, mix_mat_im1_fx, &exp_mix_mat_im1 ); + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + mix_mat_re_fx[ch_idx1][ch_idx2] = mix_mat_re1_fx[ch_idx1][ch_idx2]; + mix_mat_im_fx[ch_idx1][ch_idx2] = mix_mat_im1_fx[ch_idx1][ch_idx2]; + } + } + *exp_mix_mat_re = exp_mix_mat_re1; + *exp_mix_mat_im = exp_mix_mat_im1; + } + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function isar_SplitRenderer_PostRenderer() + * + * + *-----------------------------------------------------------------------------------------*/ +void isar_SplitRenderer_PostRenderer( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + const IVAS_QUATERNION Quaternion_act ) +{ + int16_t pos_idx, b, brange[2], ch_idx1; + int16_t num_md_bands, slot_idx, b2, index_slot, num_slots, sf_idx_md; + Word32 pred_out_re_fx[BINAURAL_CHANNELS], pred_out_im_fx[BINAURAL_CHANNELS], tmp_re_fx, tmp_im_fx, gd_int_fx; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ISAR_BIN_HR_SPLIT_REND_MD rot_md_act[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; +#else + ISAR_BIN_HR_SPLIT_REND_MD rot_md_act[1][MAX_SPLIT_REND_MD_BANDS]; +#endif + int16_t interp_yaw_pose_idx[2], interp_pitch_pose_idx[2], interp_roll_pose_idx[2]; + Word32 interp_yaw_fact_fx, interp_pitch_fact_fx, interp_roll_fact_fx; + Word16 Q_yaw = Q31, Q_pitch = Q31, Q_roll = Q31; + Word32 mix_mat_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mix_mat_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + float Cldfb_RealBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif + Word16 fade_fx; + Word32 *pMix_mat_re_prev_fx[BINAURAL_CHANNELS]; + Word32 *pMix_mat_im_prev_fx[BINAURAL_CHANNELS]; + const int16_t *pBand_grouping = isar_split_rend_band_grouping; + + num_md_bands = MAX_SPLIT_REND_MD_BANDS; + + push_wmops( "isar_SplitRenderer_PostRenderer" ); + + num_slots = MAX_PARAM_SPATIAL_SUBFRAMES; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + pos_idx = MAX_HEAD_ROT_POSES - 1; +#else + pos_idx = 0; +#endif + + sf_idx_md = 0; + + get_interpolation_vars( pMultiBinPoseData, &hBinPostRenderer->QuaternionsPre[sf_idx_md], &Quaternion_act, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, &interp_yaw_fact_fx, &interp_pitch_fact_fx, &interp_roll_fact_fx, &Q_yaw, &Q_pitch, &Q_roll ); + + FOR( b = 0; b < num_md_bands; b++ ) + { + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set_l( mix_mat_re_fx[ch_idx1], 0, BINAURAL_CHANNELS ); + set_l( mix_mat_im_fx[ch_idx1], 0, BINAURAL_CHANNELS ); + mix_mat_re_fx[ch_idx1][ch_idx1] = L_shl( 1, Q25 ); + } + + Word16 exp_gd_int = 0; + + Word16 exp_mix_mat_re = 6, exp_mix_mat_im = 6; + + interpolate_rend_md_fx( hBinPostRenderer->rot_md, mix_mat_re_fx, &exp_mix_mat_re, mix_mat_im_fx, &exp_mix_mat_im, &gd_int_fx, &exp_gd_int, sf_idx_md, b, interp_yaw_pose_idx, + interp_pitch_pose_idx, interp_roll_pose_idx, interp_yaw_fact_fx, Q_yaw, interp_pitch_fact_fx, Q_pitch, interp_roll_fact_fx, Q_roll ); + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + /*update the prediction matrix with interpolated matrix*/ + rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][0] = L_shl( mix_mat_re_fx[ch_idx1][0], exp_mix_mat_re - 6 ); // Q25 + rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][1] = L_shl( mix_mat_re_fx[ch_idx1][1], exp_mix_mat_re - 6 ); // Q25 + rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][0] = L_shl( mix_mat_im_fx[ch_idx1][0], exp_mix_mat_im - 6 ); // Q25 + rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][1] = L_shl( mix_mat_im_fx[ch_idx1][1], exp_mix_mat_im - 6 ); // Q25 + rot_md_act[pos_idx][b].gd_fx = L_shl( gd_int_fx, exp_gd_int - 6 ); // Q25 + } + } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES - 1; pos_idx++ ) + { + for ( b = 0; b < num_md_bands; b++ ) + { + if ( hBinPostRenderer->pose_type[pos_idx] == PITCH_ONLY ) + { + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set_zero( hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1], BINAURAL_CHANNELS ); + set_zero( hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1], BINAURAL_CHANNELS ); + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][ch_idx1] = 1.0f; + } + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[0][0] *= hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd; + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[1][1] *= hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd2; + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd = 0.0f; + } + else if ( hBinPostRenderer->pose_type[pos_idx] == ANY_ROLL ) + { + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd = 0.0f; + } + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + + /*update the prediction matrix with interpolated matrix*/ + rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][0]; + rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][1]; + rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1][0]; + rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1][1]; + rot_md_act[pos_idx][b].gd = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd; + } + } + } + +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) +#else + pos_idx = 0; +#endif + { + FOR( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + index_slot = slot_idx; /* TODO: can be cleaned up */ + fade_fx = fade_table_fx[slot_idx]; + fade_fx = min( fade_fx, MAX_16 ); + FOR( b = 0; b < num_md_bands; b++ ) + { + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + IF( hBinPostRenderer->cf_flag ) + { + pMix_mat_re_prev_fx[ch_idx1] = hBinPostRenderer->mixer_mat_re_fx[pos_idx][b][ch_idx1]; + pMix_mat_im_prev_fx[ch_idx1] = hBinPostRenderer->mixer_mat_im_fx[pos_idx][b][ch_idx1]; + mix_mat_re_fx[ch_idx1][0] = L_add( Mpy_32_16_1( rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][0], fade_fx ), + Mpy_32_16_1( pMix_mat_re_prev_fx[ch_idx1][0], sub( 32767, fade_fx ) ) ); + mix_mat_re_fx[ch_idx1][1] = L_add( Mpy_32_16_1( rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][1], fade_fx ), + Mpy_32_16_1( pMix_mat_re_prev_fx[ch_idx1][1], sub( 32767, fade_fx ) ) ); + + mix_mat_im_fx[ch_idx1][0] = L_add( Mpy_32_16_1( rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][0], fade_fx ), + Mpy_32_16_1( pMix_mat_im_prev_fx[ch_idx1][0], sub( 32767, fade_fx ) ) ); + mix_mat_im_fx[ch_idx1][1] = L_add( Mpy_32_16_1( rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][1], fade_fx ), + Mpy_32_16_1( pMix_mat_im_prev_fx[ch_idx1][1], sub( 32767, fade_fx ) ) ); + } + ELSE + { + mix_mat_re_fx[ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][0]; + mix_mat_re_fx[ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][1]; + mix_mat_im_fx[ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][0]; + mix_mat_im_fx[ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][1]; + } + } + + brange[0] = pBand_grouping[b]; + brange[1] = pBand_grouping[b + 1]; + Word16 exp_tmp1, exp_tmp2; + FOR( b2 = brange[0]; b2 < brange[1]; b2++ ) + { + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + /* Apply prediction matrix */ + ivas_cmult_fix( Cldfb_RealBuffer_Ref_Binaural_fx[0][index_slot][b2], 25, Cldfb_ImagBuffer_Ref_Binaural_fx[0][index_slot][b2], 25, mix_mat_re_fx[0][ch_idx1], 6, mix_mat_im_fx[0][ch_idx1], 6, &tmp_re_fx, &tmp_im_fx, &exp_tmp1, &exp_tmp2 ); + // tmp_re_fx = L_shl(tmp_re_fx, sub(exp_tmp1, 6)); //Q25 + // tmp_im_fx = L_shl(tmp_im_fx, sub(exp_tmp1, 6)); //Q25 + + pred_out_re_fx[ch_idx1] = tmp_re_fx; + pred_out_im_fx[ch_idx1] = tmp_im_fx; + Word16 exp_re = exp_tmp1; + Word16 exp_im = exp_tmp2; + + ivas_cmult_fix( Cldfb_RealBuffer_Ref_Binaural_fx[1][index_slot][b2], 25, Cldfb_ImagBuffer_Ref_Binaural_fx[1][index_slot][b2], 25, mix_mat_re_fx[1][ch_idx1], 6, mix_mat_im_fx[1][ch_idx1], 6, &tmp_re_fx, &tmp_im_fx, &exp_tmp1, &exp_tmp2 ); + // tmp_re_fx = L_shl(tmp_re_fx, sub(exp_tmp1, 6)); //Q25 + // tmp_im_fx = L_shl(tmp_im_fx, sub(exp_tmp1, 6)); //Q25 + + pred_out_re_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( pred_out_re_fx[ch_idx1], exp_re, tmp_re_fx, exp_tmp1, &exp_re ); + pred_out_re_fx[ch_idx1] = L_shl( pred_out_re_fx[ch_idx1], exp_re - 25 ); + pred_out_im_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( pred_out_im_fx[ch_idx1], exp_im, tmp_im_fx, exp_tmp2, &exp_im ); + pred_out_im_fx[ch_idx1] = L_shl( pred_out_im_fx[ch_idx1], exp_im - 25 ); + } + + + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + Cldfb_RealBuffer_Recons_Binaural[pos_idx][ch_idx1][index_slot][b2] = pred_out_re[ch_idx1]; + Cldfb_ImagBuffer_Recons_Binaural[pos_idx][ch_idx1][index_slot][b2] = pred_out_im[ch_idx1]; +#else + Cldfb_RealBuffer_Ref_Binaural_fx[ch_idx1][index_slot][b2] = pred_out_re_fx[ch_idx1]; + Cldfb_ImagBuffer_Ref_Binaural_fx[ch_idx1][index_slot][b2] = pred_out_im_fx[ch_idx1]; +#endif + } + } + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) +#else + pos_idx = 0; +#endif + { + FOR( b = 0; b < num_md_bands; b++ ) + { + FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + hBinPostRenderer->mixer_mat_re_fx[pos_idx][b][ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][0]; // Q25 + hBinPostRenderer->mixer_mat_re_fx[pos_idx][b][ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_re_fx[ch_idx1][1]; // Q25 + hBinPostRenderer->mixer_mat_im_fx[pos_idx][b][ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][0]; // Q25 + hBinPostRenderer->mixer_mat_im_fx[pos_idx][b][ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_im_fx[ch_idx1][1]; // Q25 + } + hBinPostRenderer->gd_mem_fx[pos_idx][b] = rot_md_act[pos_idx][b].gd_fx; // Q25 + } + } + hBinPostRenderer->cf_flag = 1; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + int16_t num_cldfb_bands; + num_cldfb_bands = CLDFB_NO_CHANNELS_MAX; + for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + index_slot = sf_idx * num_slots + slot_idx; + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + mvr2r( Cldfb_RealBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES - 1][ch_idx1][index_slot], Cldfb_RealBuffer_Ref_Binaural[ch_idx1][index_slot], num_cldfb_bands ); + mvr2r( Cldfb_ImagBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES - 1][ch_idx1][index_slot], Cldfb_ImagBuffer_Ref_Binaural[ch_idx1][index_slot], num_cldfb_bands ); + } + } + + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + char fname[200] = "recons_out_pos"; + char tag[2]; + tag[0] = (char) ( '0' + pos_idx ); + tag[1] = '\0'; + strcat( fname, tag ); + strcat( fname, ".wav" ); + isar_log_cldfb2wav_data( + Cldfb_RealBuffer_Recons_Binaural[pos_idx], + Cldfb_ImagBuffer_Recons_Binaural[pos_idx], + hBinPostRenderer->cldfbSynReconsBinDec[pos_idx], + BINAURAL_CHANNELS, + num_cldfb_bands, + 48000, + num_slots, + sf_idx * num_slots, + fname ); + } + } +#endif + + pop_wmops(); + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function isar_rend_CldfbSplitPostRendProcessTdIn() + * + * + *-----------------------------------------------------------------------------------------*/ +static void isar_rend_CldfbSplitPostRendProcessTdIn( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION QuaternionPost, + Word32 output_fx[][L_FRAME48k], + Word16 *Q_out ) +{ + int16_t ch_idx, slot_idx, num_cldfb_bands; + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; + num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels; + Word16 Q_output = 11; + + /* Implement CLDFB analysis */ + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Scale_sig32( output_fx[ch_idx], L_FRAME48k, Q_output - Q_out[ch_idx] ); + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + Word16 Q_cldfb = Q_output; + cldfbAnalysis_ts_fx_fixed_q( &( output_fx[ch_idx][num_cldfb_bands * slot_idx] ), + Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx], + Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx], + num_cldfb_bands, + hBinHrSplitPostRend->cldfbAna[ch_idx], + &Q_cldfb ); // Q_cldfb - 5 + } + } + + isar_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, QuaternionPost ); + + /* Implement CLDFB synthesis */ + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Word32 *RealBuffer_fx[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 scaleFactor = 31, Q_cldfb; + + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; + ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; + scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + } + + scaleFactor = s_min( sub( scaleFactor, 3 ), Q24 ); // guarded bits + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); + } + Q_cldfb = add( scaleFactor, sub( Q_output, Q5 ) ); + Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 + Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); + Q_out[ch_idx] = sub( Q_cldfb, 1 ); + } + + return; +} +/*-----------------------------------------------------------------------------------------* + * Function isar_rend_CldfbSplitPostRendProcess() + * + * + *-----------------------------------------------------------------------------------------*/ +void isar_rend_CldfbSplitPostRendProcess( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION QuaternionPost, + Word32 Cldfb_RealBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_ImagBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word16 Q_cldfb_in, + Word32 output_fx[][L_FRAME48k], + Word16 *Q_out, + const Word16 cldfb_in_flag ) +{ + int16_t ch_idx, slot_idx, num_cldfb_bands; + + push_wmops( "isar_rend_CldfbSplitPostRendProcess" ); + + num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels; + + IF( EQ_16( cldfb_in_flag, 0 ) ) + { + isar_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, QuaternionPost, output_fx, Q_out ); + pop_wmops(); + return; + } + + isar_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, QuaternionPost ); + + /* Implement CLDFB synthesis */ + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Word32 *RealBuffer_fx[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 scaleFactor = 31, Q_cldfb; + + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; + ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; + scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + } + + scaleFactor = s_min( sub( scaleFactor, 3 ), Q24 ); // guarded bits + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); + } + Q_cldfb = scaleFactor + Q_cldfb_in; + Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 + Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); + Q_out[ch_idx] = sub( Q_cldfb, 1 ); + } + + pop_wmops(); + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function isar_init_split_post_rend_handles() + * + * + *-----------------------------------------------------------------------------------------*/ + +void isar_init_split_post_rend_handles( + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ) +{ + hSplitRendWrapper->hBinHrSplitPostRend = NULL; + hSplitRendWrapper->hSplitBinLCLDDec = NULL; + hSplitRendWrapper->hLc3plusDec = NULL; + isar_init_multi_bin_pose_data_fx( &hSplitRendWrapper->multiBinPoseData ); + hSplitRendWrapper->first_good_frame_received = 0; + + return; +} + +#endif diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c new file mode 100644 index 000000000..2e2e19ac4 --- /dev/null +++ b/lib_isar/isar_splitRendererPre.c @@ -0,0 +1,3469 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +#include +#endif +#include "ivas_prot.h" +#include "prot.h" +#include "lib_isar_pre_rend.h" +#include "isar_rom_post_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" +#ifdef DBG_WAV_WRITER +#include "string.h" +#endif +#include "prot_fx2.h" +#include "basop_util.h" + +/*---------------------------------------------------------------------* + * Local function declarations + *---------------------------------------------------------------------*/ +static void isar_SplitRenderer_GetRotMd_fx( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_re, + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_im, + const Word16 low_res, + const Word16 ro_md_flag ); + +/*------------------------------------------------------------------------- + * Local functions + * + * + *------------------------------------------------------------------------*/ + +static void isar_calc_mat_det_2by2_complex_fx( + Word32 in_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 exp_in_re, + Word32 in_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 exp_in_im, + Word32 *det_re, + Word16 *exp_det_re, + Word32 *det_im, + Word16 *exp_det_im ) +{ + Word32 re1_fx, im1_fx, re2_fx, im2_fx; + + Word16 exp_re_1 = 0, exp_re_2 = 0; + Word16 exp_im_1 = 0, exp_im_2 = 0; + ivas_cmult_fix( in_re_fx[0][0], exp_in_re, in_im_fx[0][0], exp_in_im, in_re_fx[1][1], exp_in_re, in_im_fx[1][1], exp_in_im, &re1_fx, &im1_fx, &exp_re_1, &exp_im_1 ); + ivas_cmult_fix( in_re_fx[0][1], exp_in_re, in_im_fx[0][1], exp_in_im, in_re_fx[1][0], exp_in_re, in_im_fx[1][0], exp_in_im, &re2_fx, &im2_fx, &exp_re_2, &exp_im_2 ); + + Word16 exp_re_final = 0, exp_im_final = 0; + *det_re = BASOP_Util_Add_Mant32Exp( re1_fx, exp_re_1, L_negate( re2_fx ), exp_re_2, &exp_re_final ); + *det_im = BASOP_Util_Add_Mant32Exp( im1_fx, exp_im_1, L_negate( im2_fx ), exp_im_2, &exp_im_final ); + *exp_det_re = exp_re_final; + *exp_det_im = exp_im_final; + + return; +} + +static Word16 isar_is_mat_inv_2by2_complex_fx( + Word32 in_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 exp_in_re, + Word32 in_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 exp_in_im ) +{ + Word16 is_det_zero = 1; + Word32 det, det_re, det_im; + Word16 exp_det = 0, exp_det_re = 0, exp_det_im = 0; + isar_calc_mat_det_2by2_complex_fx( in_re, exp_in_re, in_im, exp_in_im, &det_re, &exp_det_re, &det_im, &exp_det_im ); + + Word64 det_re_sq = W_mult_32_32( det_re, det_re ); + Word16 det_sq_re_nrm = W_norm( det_re_sq ); + Word32 tmp1 = W_extract_h( W_shl( det_re_sq, det_sq_re_nrm ) ); + + Word64 det_im_sq = W_mult_32_32( det_im, det_im ); + Word16 det_im_nrm = W_norm( det_im_sq ); + Word32 tmp2 = W_extract_h( W_shl( det_im_sq, det_im_nrm ) ); + + det = BASOP_Util_Add_Mant32Exp( tmp1, exp_det_re + exp_det_re - det_sq_re_nrm, tmp2, exp_det_im + exp_det_im - det_im_nrm, &exp_det ); + + Word16 res = BASOP_Util_Cmp_Mant32Exp( det, exp_det, EPSILON_FX, 31 ); + IF( EQ_16( res, -1 ) ) + { + is_det_zero = 0; + } + + return is_det_zero; +} +static void isar_calc_mat_inv_2by2_complex_fx( + Word32 in_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 exp_in_re, + Word32 in_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 exp_in_im, + Word32 out_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *exp_out_re, + Word32 out_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *exp_out_im ) +{ + Word16 exp_buffer_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], exp_buffer_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + FOR( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + exp_buffer_re[i][j] = MIN16B; + move16(); + exp_buffer_im[i][j] = MIN16B; + move16(); + } + } + Word32 det_re_fx, det_im_fx; + Word16 exp_det_re = 0, exp_det_im = 0; + move16(); + move16(); + Word32 re_fx, im_fx, det_fx; + Word16 exp_re = 0, exp_im = 0; + move16(); + move16(); + + isar_calc_mat_det_2by2_complex_fx( in_re_fx, exp_in_re, in_im_fx, exp_in_im, &det_re_fx, &exp_det_re, &det_im_fx, &exp_det_im ); + + Word16 tmp1 = W_norm( W_mult_32_32( det_re_fx, det_re_fx ) ); + Word32 tmp2 = W_extract_h( W_shl( W_mult_32_32( det_re_fx, det_re_fx ), tmp1 ) ); // 2*exp_det_re - tmp1 + Word16 tmp3 = W_norm( W_mult_32_32( det_im_fx, det_im_fx ) ); + Word32 tmp4 = W_extract_h( W_shl( W_mult_32_32( det_im_fx, det_im_fx ), tmp3 ) ); // 2*exp_im_re - tmp3 + Word16 exp_det = 0; + det_fx = BASOP_Util_Add_Mant32Exp( tmp2, 2 * exp_det_re - tmp1, tmp4, 2 * exp_det_im - tmp3, &exp_det ); + + Word16 exp_tmp5 = 0; + Word16 tmp5 = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, det_fx, &exp_tmp5 ); + exp_det = add( exp_tmp5, sub( 1, exp_det ) ); + det_fx = L_deposit_h( tmp5 ); + +#ifdef DEBUGGING + /* assert to catch cases when input is singular matrix */ + assert( GT_32( det_fx, 0 ) ); +#endif + + exp_re = 0; + exp_im = 0; + move16(); + move16(); + ivas_cmult_fix( det_re_fx, exp_det_re, L_negate( det_im_fx ), exp_det_im, in_re_fx[1][1], exp_in_re, in_im_fx[1][1], exp_in_im, &re_fx, &im_fx, &exp_re, &exp_im ); + + Word64 tmp7 = W_mult_32_32( re_fx, det_fx ); + Word16 tmp7_nrm = W_norm( tmp7 ); + out_re_fx[0][0] = W_extract_h( W_shl( tmp7, tmp7_nrm ) ); // exp_re + exp_det - tmp7_nrm + move32(); + Word64 tmp8 = W_mult_32_32( im_fx, det_fx ); + Word16 tmp8_nrm = W_norm( tmp8 ); + out_im_fx[0][0] = W_extract_h( W_shl( tmp8, tmp8_nrm ) ); // exp_im + exp_det - tmp8_nrm + move32(); + + exp_buffer_re[0][0] = add( exp_re, sub( exp_det, tmp7_nrm ) ); + move16(); + exp_buffer_im[0][0] = add( exp_im, sub( exp_det, tmp8_nrm ) ); + move16(); + + ivas_cmult_fix( det_re_fx, exp_det_re, L_negate( det_im_fx ), exp_det_im, in_re_fx[0][1], exp_in_re, in_im_fx[0][1], exp_in_im, &re_fx, &im_fx, &exp_re, &exp_im ); + + Word64 tmp9 = W_mult_32_32( L_negate( re_fx ), det_fx ); + Word16 tmp9_nrm = W_norm( tmp9 ); + out_re_fx[0][1] = W_extract_h( W_shl( tmp9, tmp9_nrm ) ); + Word64 tmp10 = W_mult_32_32( L_negate( im_fx ), det_fx ); + Word16 tmp10_nrm = W_norm( tmp10 ); + out_im_fx[0][1] = W_extract_h( W_shl( tmp10, tmp10_nrm ) ); + + exp_buffer_re[0][1] = add( exp_re, sub( exp_det, tmp9_nrm ) ); + exp_buffer_im[0][1] = add( exp_im, sub( exp_det, tmp10_nrm ) ); + + ivas_cmult_fix( det_re_fx, exp_det_re, L_negate( det_im_fx ), exp_det_im, in_re_fx[1][0], exp_in_re, in_im_fx[1][0], exp_in_im, &re_fx, &im_fx, &exp_re, &exp_im ); + + + Word64 tmp11 = W_mult_32_32( L_negate( re_fx ), det_fx ); + Word16 tmp11_nrm = W_norm( tmp11 ); + out_re_fx[1][0] = W_extract_h( W_shl( tmp11, tmp11_nrm ) ); + Word64 tmp12 = W_mult_32_32( L_negate( im_fx ), det_fx ); + Word16 tmp12_nrm = W_norm( tmp12 ); + out_im_fx[1][0] = W_extract_h( W_shl( tmp12, tmp12_nrm ) ); + + exp_buffer_re[1][0] = add( exp_re, sub( exp_det, tmp11_nrm ) ); + move16(); + exp_buffer_im[1][0] = add( exp_im, sub( exp_det, tmp12_nrm ) ); + move16(); + + ivas_cmult_fix( det_re_fx, exp_det_re, L_negate( det_im_fx ), exp_det_im, in_re_fx[0][0], exp_in_re, in_im_fx[0][0], exp_in_im, &re_fx, &im_fx, &exp_re, &exp_im ); + + Word64 tmp13 = W_mult_32_32( re_fx, det_fx ); + Word16 tmp13_nrm = W_norm( tmp13 ); + out_re_fx[1][1] = W_extract_h( W_shl( tmp13, tmp13_nrm ) ); + move32(); + + Word64 tmp14 = W_mult_32_32( im_fx, det_fx ); + Word16 tmp14_nrm = W_norm( tmp14 ); + out_im_fx[1][1] = W_extract_h( W_shl( tmp14, tmp14_nrm ) ); + move32(); + + exp_buffer_re[1][1] = add( exp_re, sub( exp_det, tmp13_nrm ) ); + move16(); + exp_buffer_im[1][1] = add( exp_im, sub( exp_det, tmp14_nrm ) ); + move16(); + + Word16 max_exp_re = MIN16B, max_exp_im = MIN16B; + FOR( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + max_exp_re = s_max( max_exp_re, exp_buffer_re[i][j] ); + max_exp_im = s_max( max_exp_im, exp_buffer_im[i][j] ); + } + } + + FOR( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + out_re_fx[i][j] = L_shr( out_re_fx[i][j], max_exp_re - exp_buffer_re[i][j] ); + move32(); + out_im_fx[i][j] = L_shr( out_im_fx[i][j], max_exp_im - exp_buffer_im[i][j] ); + move32(); + } + } + + *exp_out_re = max_exp_re; + move16(); + *exp_out_im = max_exp_im; + move16(); + + return; +} +static void ComputePredMat_fx( + Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_re, + Word32 cov_ii_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_im, + Word32 cov_io_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_io_re, + Word32 cov_io_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_io_im, + Word32 pred_mat_re_fx[][BINAURAL_CHANNELS], + Word16 *exp_pred_mat_re, + Word32 pred_mat_im_fx[][BINAURAL_CHANNELS], + Word16 *exp_pred_mat_im, + const Word16 num_chs, + const Word16 real_only ) +{ + Word32 cov_ii_local_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 cov_ii_inv_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 cov_ii_inv_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 exp_cov_ii_local_re = 0, exp_cov_ii_inv_re = 0, exp_cov_ii_inv_im = 0; + Word32 trace_cov_fx; + + Word16 i, j; + + trace_cov_fx = 0; + Word16 exp_trace_cov = 0; + FOR( i = 0; i < num_chs; i++ ) + { + trace_cov_fx = L_add( trace_cov_fx, L_shr( cov_ii_re_fx[i][i], 1 ) ); + } + exp_trace_cov = add( exp_cov_ii_re, 1 ); + + trace_cov_fx = L_max( 0, trace_cov_fx ); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( trace_cov_fx, exp_cov_ii_re, EPSILON_FX, 0 ); + IF( EQ_16( flag, negate( 1 ) ) ) + { + FOR( i = 0; i < num_chs; i++ ) + { + /* protection from cases when variance of ref channels is very small */ + set32_fx( pred_mat_re_fx[i], 0, BINAURAL_CHANNELS ); + set32_fx( pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); + } + return; + } + + Word16 buff_exp[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + buff_exp[i][j] = 0; + move16(); + } + } + + FOR( i = 0; i < num_chs; i++ ) + { + Copy32( cov_ii_re_fx[i], cov_ii_local_re_fx[i], num_chs ); + set16_fx( buff_exp[i], exp_cov_ii_re, num_chs ); + } + + Word32 tmp = 0; + FOR( i = 0; i < num_chs; i++ ) + { + tmp = Mpy_32_32( trace_cov_fx, 214748 ); // exp_trace_cov + Word16 exp_tmp = 0; + cov_ii_local_re_fx[i][i] = BASOP_Util_Add_Mant32Exp( cov_ii_re_fx[i][i], exp_cov_ii_re, tmp, exp_trace_cov, &exp_tmp ); + move32(); + buff_exp[i][i] = exp_tmp; + move16(); + } + + Word16 max_exp = MIN16B; + FOR( i = 0; i < 2; i++ ) + { + FOR( j = 0; j < 2; j++ ) + { + max_exp = max( max_exp, buff_exp[i][j] ); + } + } + + FOR( i = 0; i < num_chs; i++ ) + { + FOR( j = 0; j < num_chs; j++ ) + { + cov_ii_local_re_fx[i][j] = L_shr( cov_ii_local_re_fx[i][j], max_exp - buff_exp[i][j] ); + move32(); + } + } + + exp_cov_ii_local_re = max_exp; + move16(); + + IF( isar_is_mat_inv_2by2_complex_fx( cov_ii_local_re_fx, exp_cov_ii_local_re, cov_ii_im_fx, exp_cov_ii_im ) ) + { + isar_calc_mat_inv_2by2_complex_fx( cov_ii_local_re_fx, exp_cov_ii_local_re, cov_ii_im_fx, exp_cov_ii_im, cov_ii_inv_re_fx, &exp_cov_ii_inv_re, cov_ii_inv_im_fx, &exp_cov_ii_inv_im ); + isar_mat_mult_2by2_complex_fx( cov_ii_inv_re_fx, exp_cov_ii_inv_re, cov_ii_inv_im_fx, exp_cov_ii_inv_im, cov_io_re_fx, exp_cov_io_re, cov_io_im_fx, exp_cov_io_im, pred_mat_re_fx, exp_pred_mat_re, pred_mat_im_fx, exp_pred_mat_im ); + } + ELSE + { + Word16 max_var_idx; + FOR( i = 0; i < num_chs; i++ ) + { + set32_fx( pred_mat_re_fx[i], 0, BINAURAL_CHANNELS ); + set32_fx( pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); + } + + max_var_idx = 0; + move16(); + IF( GT_32( cov_ii_local_re_fx[1][1], cov_ii_local_re_fx[0][0] ) ) + { + max_var_idx = 1; + } + + Word16 tmp1 = 0, exp_tmp1 = 0; + move16(); + move16(); + Word16 tmp2 = 0, exp_tmp2 = 0; + move16(); + move16(); + Word16 flag1 = BASOP_Util_Cmp_Mant32Exp( cov_ii_local_re_fx[max_var_idx][max_var_idx], exp_cov_ii_local_re, EPSILON_FX, 0 ); + IF( EQ_16( flag1, 1 ) ) + { + Word16 pred_mat_buf_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], pred_mat_buf_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + set16_fx( pred_mat_buf_re[i], *exp_pred_mat_re, BINAURAL_CHANNELS ); + set16_fx( pred_mat_buf_im[i], *exp_pred_mat_im, BINAURAL_CHANNELS ); + } + FOR( j = 0; j < num_chs; j++ ) + { + tmp1 = BASOP_Util_Divide3232_Scale( cov_io_re_fx[max_var_idx][j], cov_ii_local_re_fx[max_var_idx][max_var_idx], &exp_tmp1 ); + exp_tmp1 = exp_tmp1 + ( exp_cov_io_re - exp_cov_ii_local_re ); + tmp2 = BASOP_Util_Divide3232_Scale( cov_io_im_fx[max_var_idx][j], cov_ii_local_re_fx[max_var_idx][max_var_idx], &exp_tmp2 ); + exp_tmp2 = exp_tmp2 + ( exp_cov_io_im - exp_cov_ii_local_re ); + pred_mat_re_fx[max_var_idx][j] = tmp1; + move32(); + pred_mat_im_fx[max_var_idx][j] = tmp2; + move32(); + pred_mat_buf_re[max_var_idx][j] = exp_tmp1; + move16(); + pred_mat_buf_im[max_var_idx][j] = exp_tmp2; + move16(); + } + + Word16 max_re = MIN16B, max_im = MIN16B; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + + max_re = s_max( max_re, pred_mat_buf_re[i][j] ); + move16(); + max_im = s_max( max_im, pred_mat_buf_im[i][j] ); + move16(); + } + } + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + + pred_mat_re_fx[i][j] = L_shr( pred_mat_re_fx[i][j], max_re - pred_mat_buf_re[i][j] ); + move32(); + pred_mat_im_fx[i][j] = L_shr( pred_mat_im_fx[i][j], max_im - pred_mat_buf_im[i][j] ); + move32(); + } + } + + *exp_pred_mat_re = max_re; + move16(); + *exp_pred_mat_im = max_im; + move16(); + } + } + + IF( real_only ) + { + FOR( i = 0; i < num_chs; i++ ) + { + set32_fx( pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); + } + } + + return; +} +static void ComputePostPredCov_fx( + Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_re, + Word32 cov_ii_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_im, + Word32 pred_mat_re_fx[][BINAURAL_CHANNELS], + Word16 exp_pred_mat_re, + Word32 pred_mat_im_fx[][BINAURAL_CHANNELS], + Word16 exp_pred_mat_im, + Word32 postpred_cov_re_fx[][BINAURAL_CHANNELS], + Word16 *exp_postpred_cov_re, + Word16 num_chs ) +{ + Word16 i, j; + Word32 dmx_mat_conj_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 dmx_mat_conj_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 temp_mat_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 temp_mat_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 postpred_cov_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 exp_postpred_cov_im = 0; + Word16 exp_temp_mat_re = 0, exp_temp_mat_im = 0; + + assert( num_chs == BINAURAL_CHANNELS ); + + FOR( i = 0; i < num_chs; i++ ) + { + FOR( j = 0; j < num_chs; j++ ) + { + dmx_mat_conj_re_fx[i][j] = pred_mat_re_fx[j][i]; + move32(); + dmx_mat_conj_im_fx[i][j] = L_negate( pred_mat_im_fx[j][i] ); + move32(); + + temp_mat_re_fx[i][j] = pred_mat_re_fx[i][j]; + move32(); + temp_mat_im_fx[i][j] = pred_mat_im_fx[i][j]; + move32(); + } + set32_fx( postpred_cov_re_fx[i], 0, BINAURAL_CHANNELS ); + } + isar_mat_mult_2by2_complex_fx( dmx_mat_conj_re_fx, exp_pred_mat_re, dmx_mat_conj_im_fx, exp_pred_mat_im, cov_ii_re_fx, exp_cov_ii_re, cov_ii_im_fx, exp_cov_ii_im, temp_mat_re_fx, &exp_temp_mat_re, temp_mat_im_fx, &exp_temp_mat_im ); + isar_mat_mult_2by2_complex_fx( temp_mat_re_fx, exp_temp_mat_re, temp_mat_im_fx, exp_temp_mat_im, pred_mat_re_fx, exp_pred_mat_re, pred_mat_im_fx, exp_pred_mat_im, postpred_cov_re_fx, exp_postpred_cov_re, postpred_cov_im_fx, &exp_postpred_cov_im ); + + /* 2x2 mult */ + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < i; j++ ) + { + postpred_cov_re_fx[i][j] = postpred_cov_re_fx[j][i]; + move32(); + } + } + + return; +} +static void ComputeBandedCrossCov_fx( + Word32 Cldfb_RealBuffer1_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re_1, + Word32 Cldfb_ImagBuffer1_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im_1, + const Word16 ch_start_idx1, + Word32 Cldfb_RealBuffer2_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re_2, + Word32 Cldfb_ImagBuffer2_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im_2, + const Word16 ch_start_idx2, + Word32 out_cov_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *exp_out_cov_re, + Word32 out_cov_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 *exp_out_cov_im, + const Word16 num_chs, + const Word16 *pBand_grouping, + const Word16 num_slots, + const Word16 start_slot_idx, + const Word16 md_band_idx, + const Word16 real_only ) +{ + Word16 sf, cldfb_band_idx, ch_idx1, ch_idx2; + Word16 brange[2]; + + FOR( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + set_l( out_cov_re_fx[ch_idx1], 0, num_chs ); + set_l( out_cov_im_fx[ch_idx1], 0, num_chs ); + } + + brange[0] = pBand_grouping[md_band_idx]; + move16(); + brange[1] = pBand_grouping[md_band_idx + 1]; + move16(); + Word16 exp_buff_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], exp_buff_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + FOR( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 < num_chs; ch_idx2++ ) + { + Word32 tmp_a = out_cov_re_fx[ch_idx1][ch_idx2], tmp_b = out_cov_im_fx[ch_idx1][ch_idx2]; + Word16 exp_tmp_a = 0, exp_tmp_b = 0; + IF( EQ_16( real_only, 0 ) ) + { + FOR( sf = start_slot_idx; sf < add( start_slot_idx, num_slots ); sf++ ) + { + FOR( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + Word64 tmp1 = W_mult_32_32( Cldfb_RealBuffer1_fx[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx], Cldfb_RealBuffer2_fx[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp1_nrm = W_norm( tmp1 ); + Word32 tmp1_final = W_extract_h( W_shl( tmp1, tmp1_nrm ) ); + + Word64 tmp2 = W_mult_32_32( Cldfb_ImagBuffer1_fx[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx], Cldfb_ImagBuffer2_fx[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp2_nrm = W_norm( tmp2 ); + Word32 tmp2_final = W_extract_h( W_shl( tmp2, tmp2_nrm ) ); + + Word16 exp_tmp3 = 0; + Word32 tmp3 = BASOP_Util_Add_Mant32Exp( tmp1_final, exp_cldfb_re_1 + exp_cldfb_re_2 - tmp1_nrm, tmp2_final, exp_cldfb_im_1 + exp_cldfb_im_2 - tmp2_nrm, &exp_tmp3 ); + Word16 exp_tmp_a_tmp = 0; + tmp_a = BASOP_Util_Add_Mant32Exp( tmp_a, exp_tmp_a, tmp3, exp_tmp3, &exp_tmp_a_tmp ); + exp_tmp_a = exp_tmp_a_tmp; + + Word64 tmp4 = W_mult_32_32( Cldfb_RealBuffer1_fx[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx], Cldfb_ImagBuffer2_fx[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp4_nrm = W_norm( tmp4 ); + Word32 tmp4_final = W_extract_h( W_shl( tmp4, tmp4_nrm ) ); // exp_cldfb_re_1 + exp_cldfb_im_2 - tmp4_nrm + + Word64 tmp5 = W_mult_32_32( Cldfb_ImagBuffer1_fx[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx], Cldfb_RealBuffer2_fx[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp5_nrm = W_norm( tmp5 ); + Word32 tmp5_final = W_extract_h( W_shl( tmp5, tmp5_nrm ) ); // exp_cldfb_im_1 + exp_cldfb_re_2 - tmp5_nrm + + Word16 exp_tmp6 = 0; + Word32 tmp6 = BASOP_Util_Add_Mant32Exp( tmp4_final, exp_cldfb_re_1 + exp_cldfb_im_2 - tmp4_nrm, L_negate( tmp5_final ), exp_cldfb_im_1 + exp_cldfb_re_2 - tmp5_nrm, &exp_tmp6 ); + Word16 exp_tmp_b_tmp = 0; + tmp_b = BASOP_Util_Add_Mant32Exp( tmp_b, exp_tmp_b, tmp6, exp_tmp6, &exp_tmp_b_tmp ); + exp_tmp_b = exp_tmp_b_tmp; + } + } + } + ELSE + { + FOR( sf = start_slot_idx; sf < add( start_slot_idx, num_slots ); sf++ ) + { + FOR( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + Word64 tmp1 = W_mult_32_32( Cldfb_RealBuffer1_fx[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx], Cldfb_RealBuffer2_fx[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp1_nrm = W_norm( tmp1 ); + Word32 tmp1_final = W_extract_h( W_shl( tmp1, tmp1_nrm ) ); + + Word64 tmp2 = W_mult_32_32( Cldfb_ImagBuffer1_fx[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx], Cldfb_ImagBuffer2_fx[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp2_nrm = W_norm( tmp2 ); + Word32 tmp2_final = W_extract_h( W_shl( tmp2, tmp2_nrm ) ); + + Word16 exp_tmp3 = 0; + Word32 tmp3 = BASOP_Util_Add_Mant32Exp( tmp1_final, exp_cldfb_re_1 + exp_cldfb_re_2 - tmp1_nrm, tmp2_final, exp_cldfb_im_1 + exp_cldfb_im_2 - tmp2_nrm, &exp_tmp3 ); + Word16 exp_tmp_a_tmp = 0; + tmp_a = BASOP_Util_Add_Mant32Exp( tmp_a, exp_tmp_a, tmp3, exp_tmp3, &exp_tmp_a_tmp ); + exp_tmp_a = exp_tmp_a_tmp; + + tmp_b = 0; + exp_tmp_b = 0; + } + } + } + out_cov_re_fx[ch_idx1][ch_idx2] = tmp_a; + move32(); + out_cov_im_fx[ch_idx1][ch_idx2] = tmp_b; + move32(); + exp_buff_re[ch_idx1][ch_idx2] = exp_tmp_a; + move32(); + exp_buff_im[ch_idx1][ch_idx2] = exp_tmp_b; + move32(); + } + } + /*make common exponent*/ + Word16 max_cov_re = 0, max_cov_im = 0; + FOR( int i = 0; i < num_chs; i++ ) + { + FOR( int j = 0; j < num_chs; j++ ) + { + max_cov_re = max( max_cov_re, exp_buff_re[i][j] ); + max_cov_im = max( max_cov_im, exp_buff_im[i][j] ); + } + } + FOR( int i = 0; i < num_chs; i++ ) + { + FOR( int j = 0; j < num_chs; j++ ) + { + out_cov_re_fx[i][j] = L_shr( out_cov_re_fx[i][j], max_cov_re - exp_buff_re[i][j] ); + move32(); + out_cov_im_fx[i][j] = L_shr( out_cov_im_fx[i][j], max_cov_im - exp_buff_im[i][j] ); + move32(); + } + } + + *exp_out_cov_re = max_cov_re; + *exp_out_cov_im = max_cov_im; + + return; +} +static void ComputeBandedCov_fx( + Word32 Cldfb_RealBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re, + Word32 Cldfb_ImagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im, + const Word16 ch_start_idx, + Word32 out_cov_re_fx[][BINAURAL_CHANNELS], + Word16 *exp_cov_re, + Word32 out_cov_im_fx[][BINAURAL_CHANNELS], + Word16 *exp_cov_im, + const Word16 num_chs, + const Word16 *pBand_grouping, + const Word16 num_slots, + const Word16 start_slot_idx, + const Word16 md_band_idx, + const Word16 real_only ) +{ + Word16 sf, cldfb_band_idx, ch_idx1, ch_idx2; + Word16 brange[2]; + + FOR( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + set32_fx( out_cov_re_fx[ch_idx1], 0, num_chs ); + set32_fx( out_cov_im_fx[ch_idx1], 0, num_chs ); + } + + brange[0] = pBand_grouping[md_band_idx]; + move16(); + brange[1] = pBand_grouping[md_band_idx + 1]; + move16(); + + Word16 exp_buff_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], exp_buff_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + FOR( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + exp_buff_re[i][j] = 0; + move16(); + exp_buff_im[i][j] = 0; + move16(); + } + } + + FOR( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + FOR( ch_idx2 = 0; ch_idx2 <= ch_idx1; ch_idx2++ ) + { + Word32 tmp_a = out_cov_re_fx[ch_idx1][ch_idx2]; + Word32 tmp_b = out_cov_im_fx[ch_idx1][ch_idx2]; + Word16 exp_tmp_a = 0, exp_tmp_b = 0; + test(); + IF( ( NE_16( ch_idx2, ch_idx1 ) ) && ( EQ_16( real_only, 0 ) ) ) + { + FOR( sf = start_slot_idx; sf < add( start_slot_idx, num_slots ); sf++ ) + { + FOR( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + Word64 tmp1 = W_mult_32_32( Cldfb_RealBuffer_fx[ch_start_idx + ch_idx1][sf][cldfb_band_idx], Cldfb_RealBuffer_fx[ch_start_idx + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp1_nrm = W_norm( tmp1 ); + Word32 tmp1_final = W_extract_h( W_shl( tmp1, tmp1_nrm ) ); // exp_cldfb_re + exp_cldfb_re - tmp1_nrm + + Word64 tmp2 = W_mult_32_32( Cldfb_ImagBuffer_fx[ch_start_idx + ch_idx1][sf][cldfb_band_idx], Cldfb_ImagBuffer_fx[ch_start_idx + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp2_nrm = W_norm( tmp2 ); + Word32 tmp2_final = W_extract_h( W_shl( tmp2, tmp2_nrm ) ); // exp_cldfb_im + exp_cldfb_im - tmp2_nrm + + Word16 exp_tmp3 = 0; + Word32 tmp3 = BASOP_Util_Add_Mant32Exp( tmp1_final, exp_cldfb_re + exp_cldfb_re - tmp1_nrm, tmp2_final, exp_cldfb_im + exp_cldfb_im - tmp2_nrm, &exp_tmp3 ); + Word16 exp_tmp_a_tmp = 0; + tmp_a = BASOP_Util_Add_Mant32Exp( tmp_a, exp_tmp_a, tmp3, exp_tmp3, &exp_tmp_a_tmp ); + exp_tmp_a = exp_tmp_a_tmp; + + Word64 tmp4 = W_mult_32_32( Cldfb_RealBuffer_fx[ch_start_idx + ch_idx1][sf][cldfb_band_idx], Cldfb_ImagBuffer_fx[ch_start_idx + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp4_nrm = W_norm( tmp4 ); + Word32 tmp4_final = W_extract_h( W_shl( tmp4, tmp4_nrm ) ); // exp_cldfb_re + exp_cldfb_im - tmp4_nrm + + Word64 tmp5 = W_mult_32_32( Cldfb_ImagBuffer_fx[ch_start_idx + ch_idx1][sf][cldfb_band_idx], Cldfb_RealBuffer_fx[ch_start_idx + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp5_nrm = W_norm( tmp5 ); + Word32 tmp5_final = W_extract_h( W_shl( tmp5, tmp5_nrm ) ); // exp_cldfb_im + exp_cldfb_re - tmp5_nrm + + Word16 exp_tmp6 = 0; + Word32 tmp6 = BASOP_Util_Add_Mant32Exp( tmp4_final, exp_cldfb_re + exp_cldfb_im - tmp4_nrm, L_negate( tmp5_final ), exp_cldfb_im + exp_cldfb_re - tmp5_nrm, &exp_tmp6 ); + Word16 exp_tmp_b_tmp = 0; + tmp_b = BASOP_Util_Add_Mant32Exp( tmp_b, exp_tmp_b, tmp6, exp_tmp6, &exp_tmp_b_tmp ); + exp_tmp_b = exp_tmp_b_tmp; + } + } + } + ELSE + { + FOR( sf = start_slot_idx; sf < add( start_slot_idx, num_slots ); sf++ ) + { + FOR( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + Word64 tmp1 = W_mult_32_32( Cldfb_RealBuffer_fx[ch_start_idx + ch_idx1][sf][cldfb_band_idx], Cldfb_RealBuffer_fx[ch_start_idx + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp1_nrm = W_norm( tmp1 ); + Word32 tmp1_final = W_extract_h( W_shl( tmp1, tmp1_nrm ) ); // exp_cldfb_re + exp_cldfb_re - tmp1_nrm + + Word64 tmp2 = W_mult_32_32( Cldfb_ImagBuffer_fx[ch_start_idx + ch_idx1][sf][cldfb_band_idx], Cldfb_ImagBuffer_fx[ch_start_idx + ch_idx2][sf][cldfb_band_idx] ); + Word16 tmp2_nrm = W_norm( tmp2 ); + Word32 tmp2_final = W_extract_h( W_shl( tmp2, tmp2_nrm ) ); // exp_cldfb_im + exp_cldfb_im - tmp2_nrm + + Word16 exp_tmp3 = 0; + Word32 tmp3 = BASOP_Util_Add_Mant32Exp( tmp1_final, exp_cldfb_re + exp_cldfb_re - tmp1_nrm, tmp2_final, exp_cldfb_im + exp_cldfb_im - tmp2_nrm, &exp_tmp3 ); + + Word16 exp_tmp_a_tmp = 0; + tmp_a = BASOP_Util_Add_Mant32Exp( tmp_a, exp_tmp_a, tmp3, exp_tmp3, &exp_tmp_a_tmp ); + exp_tmp_a = exp_tmp_a_tmp; + + tmp_b = 0; + exp_tmp_b = 0; + } + } + } + out_cov_re_fx[ch_idx1][ch_idx2] = tmp_a; + move32(); + exp_buff_re[ch_idx1][ch_idx2] = exp_tmp_a; + move32(); + + out_cov_im_fx[ch_idx1][ch_idx2] = tmp_b; + move32(); + exp_buff_im[ch_idx1][ch_idx2] = exp_tmp_b; + move32(); + } + } + + Word16 exp_max_re = MIN16B, exp_max_im = MIN16B; + FOR( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + exp_max_re = max( exp_max_re, exp_buff_re[i][j] ); + exp_max_im = max( exp_max_im, exp_buff_im[i][j] ); + } + } + + FOR( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + out_cov_re_fx[i][j] = L_shr( out_cov_re_fx[i][j], exp_max_re - exp_buff_re[i][j] ); + move32(); + out_cov_im_fx[i][j] = L_shr( out_cov_im_fx[i][j], exp_max_im - exp_buff_im[i][j] ); + move32(); + } + } + + FOR( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + FOR( ch_idx2 = add( ch_idx1, 1 ); ch_idx2 < num_chs; ch_idx2++ ) + { + out_cov_re_fx[ch_idx1][ch_idx2] = out_cov_re_fx[ch_idx2][ch_idx1]; + move32(); + out_cov_im_fx[ch_idx1][ch_idx2] = L_negate( out_cov_im_fx[ch_idx2][ch_idx1] ); + move32(); + } + } + + *exp_cov_re = exp_max_re; + *exp_cov_im = exp_max_im; + + return; +} +static Word32 GetNormFact_fx( + Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_re, + Word32 cov_ii_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_im, + Word32 cov_io_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_io_re, + Word32 cov_io_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_io_im, + Word32 cov_oo_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_oo_re, + Word16 *exp_norm_fact_fx ) +{ + Word16 i, j; + Word32 norm_fact_fx = 0, abs_val_fx; + Word16 exp_abs_val = 0, exp_norm_fact = 0; + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + ivas_calculate_abs_fx( cov_ii_re_fx[i][j], exp_cov_ii_re, cov_ii_im_fx[i][j], exp_cov_ii_im, &abs_val_fx, &exp_abs_val ); + Word16 res_1 = BASOP_Util_Cmp_Mant32Exp( norm_fact_fx, exp_norm_fact, abs_val_fx, exp_abs_val ); + IF( EQ_16( res_1, negate( 1 ) ) ) + { + norm_fact_fx = abs_val_fx; + exp_norm_fact = exp_abs_val; + } + + ivas_calculate_abs_fx( cov_io_re_fx[i][j], exp_cov_io_re, cov_io_im_fx[i][j], exp_cov_io_im, &abs_val_fx, &exp_abs_val ); + res_1 = BASOP_Util_Cmp_Mant32Exp( norm_fact_fx, exp_norm_fact, abs_val_fx, exp_abs_val ); + IF( EQ_16( res_1, negate( 1 ) ) ) + { + norm_fact_fx = abs_val_fx; + exp_norm_fact = exp_abs_val; + } + ivas_calculate_rabs_fx( cov_oo_re_fx[i][j], exp_cov_oo_re, &abs_val_fx, &exp_abs_val ); + res_1 = BASOP_Util_Cmp_Mant32Exp( norm_fact_fx, exp_norm_fact, abs_val_fx, exp_abs_val ); + IF( EQ_16( res_1, negate( 1 ) ) ) + { + norm_fact_fx = abs_val_fx; + exp_norm_fact = exp_abs_val; + } + } + } + + Word16 flag = BASOP_Util_Cmp_Mant32Exp( norm_fact_fx, exp_norm_fact, EPSILON_FX, 0 ); + IF( EQ_16( flag, negate( 1 ) ) ) + { + norm_fact_fx = ONE_IN_Q30; + exp_norm_fact = 1; + } + + Word16 exp_tmp = 0; + Word16 tmp = BASOP_Util_Divide3232_Scale( PCM16_TO_FLT_FAC_FX_Q15, norm_fact_fx, &exp_tmp ); + exp_tmp = add( exp_tmp, sub( 16, exp_norm_fact ) ); + norm_fact_fx = L_deposit_h( tmp ); + exp_norm_fact = exp_tmp; + + *exp_norm_fact_fx = exp_norm_fact; + + return norm_fact_fx; +} + +static void isar_split_rend_huffman_encode( + isar_split_rend_huffman_cfg_t *huff_cfg, + const Word16 in, + Word32 *hcode, + Word32 *hlen ) +{ + Word32 min_sym_val; + const Word32 *codebook; + + min_sym_val = huff_cfg->codebook[0]; + move32(); + + codebook = &huff_cfg->codebook[3 * ( in - min_sym_val )]; + *hlen = codebook[1]; + move32(); + *hcode = codebook[2]; + move32(); + + return; +} + +static void isar_split_rend_quant_md_fx( + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd, + const ISAR_SPLIT_REND_POSE_TYPE pose_type, + const int16_t real_only, + Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS], + const Word32 pred_1byquantstep, // Q26 + const Word16 Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + float fix_pos_rot_mat_flt[][BINAURAL_CHANNELS], + const float pred_1byquantstep_flt // Q26 +#endif +) +{ + int16_t ch1, ch2; + int16_t gd_idx_min; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word32 quant_val; +#else + Word32 sign, quant_val; +#endif +#ifdef DEBUG_QUANT_MD_FX + float quant_val_flt; + Word16 tmp; +#endif + if ( pose_type == PRED_ONLY || pose_type == PRED_ROLL_ONLY ) + { + Word32 onebyquantstep; + + onebyquantstep = pred_1byquantstep; +#ifdef DEBUG_QUANT_MD_FX + float onebyquantstep_flt = pred_1byquantstep_flt; +#endif + IF( real_only == 1 ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + hMd->pred_mat_re_fx[ch1][ch1] = hMd->pred_mat_re2[ch1]; + } + hMd->pred_mat_re_fx[1][0] = 0; + hMd->pred_mat_re_fx[0][1] = 0; + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = L_sub( hMd->pred_mat_re_fx[ch1][ch2], L_shr_r( ( ch1 == ch2 ) ? ONE_IN_Q31 : 0, sub( Q31, Q_frame ) ) ); + quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PRED_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( quant_val, L_shr_r( ISAR_SPLIT_REND_PRED_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); + hMd->pred_mat_re_idx[ch1][ch2] = (Word16) L_shr_r( Mpy_32_32( onebyquantstep, quant_val ), sub( Q_frame, 5 ) ); // Q25*Q26 = Q20 -> Q16 -> Q0 + } + } +#else + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sign = GE_32( hMd->pred_mat_re_fx[ch1][ch2], 0 ) ? 1 : -1; + Word16 exp_out; + ivas_calculate_abs_fx( hMd->pred_mat_re_fx[ch1][ch2], Q31 - Q_frame, hMd->pred_mat_im_fx[ch1][ch2], Q31 - Q_frame, &hMd->pred_mat_re_fx[ch1][ch2], &exp_out ); + hMd->pred_mat_re_fx[ch1][ch2] = L_shr_r( hMd->pred_mat_re_fx[ch1][ch2], sub( sub( Q31, Q_frame ), exp_out ) ); // Q_frame + hMd->pred_mat_re_fx[ch1][ch2] = (Word32) W_mult0_32_32( hMd->pred_mat_re_fx[ch1][ch2], sign ); + hMd->pred_mat_im_fx[ch1][ch2] = 0; + } + } +#endif + } +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + else + { +#endif + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = L_sub( hMd->pred_mat_re_fx[ch1][ch2], L_shr_r( fix_pos_rot_mat[ch1][ch2], sub( Q31, Q_frame ) ) ); + quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PRED_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( quant_val, L_shr_r( ISAR_SPLIT_REND_PRED_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); + hMd->pred_mat_re_idx[ch1][ch2] = (Word16) L_shr_r( Mpy_32_32( onebyquantstep, quant_val ), sub( Q_frame, 5 ) ); // Q25*Q26 = Q20 -> Q16 -> Q0 + +#ifdef DEBUG_QUANT_MD_FX + quant_val_flt = hMd->pred_mat_re[ch1][ch2] - fix_pos_rot_mat_flt[ch1][ch2]; + quant_val_flt = min( ISAR_SPLIT_REND_PRED_MAX_VAL, max( quant_val_flt, ISAR_SPLIT_REND_PRED_MIN_VAL ) ); + tmp = (int16_t) roundf( onebyquantstep_flt * quant_val_flt ); + if ( hMd->pred_mat_re_idx[ch1][ch2] != tmp ) + { + printf( "\nUNEQUAL INDEX\n" ); + } +#endif + } + } +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + } +#endif + + if ( real_only == 0 ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PRED_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( hMd->pred_mat_im_fx[ch1][ch2], L_shr_r( ISAR_SPLIT_REND_PRED_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); + hMd->pred_mat_im_idx[ch1][ch2] = (Word16) L_shr_r( Mpy_32_32( onebyquantstep, quant_val ), sub( Q_frame, 5 ) ); + // hMd->pred_mat_im[ch1][ch2] = hMd->pred_mat_im_idx[ch1][ch2] * IVAS_SPLIT_REND_PRED_Q_STEP; + + +#ifdef DEBUG_QUANT_MD_FX + quant_val_flt = min( ISAR_SPLIT_REND_PRED_MAX_VAL, max( hMd->pred_mat_im[ch1][ch2], ISAR_SPLIT_REND_PRED_MIN_VAL ) ); + tmp = (int16_t) roundf( onebyquantstep_flt * quant_val_flt ); + if ( hMd->pred_mat_im_idx[ch1][ch2] != tmp ) + { + printf( "\nUNEQUAL INDEX\n" ); + } +#endif + } + } + } + } + else if ( pose_type == COM_GAIN_ONLY ) + { + quant_val = L_min( L_shl_r( 1, Q_frame ) /*ISAR_SPLIT_REND_D_MAX_VAL_FX*/, L_max( hMd->gd_fx, ISAR_SPLIT_REND_D_MIN_VAL_FX ) ); //_frame + gd_idx_min = 0; //(int16_t)roundf(ISAR_SPLIT_REND_D_1BYQ_STEP * ISAR_SPLIT_REND_D_MIN_VAL) + hMd->gd_idx = (Word16) L_shr_r( Mpy_32_32( ISAR_SPLIT_REND_D_1BYQ_STEP_Q27, quant_val ), sub( Q_frame, 4 ) ); + hMd->gd_fx = W_extract_l( W_shr( W_mult0_32_32( hMd->gd_idx, ISAR_SPLIT_REND_D_Q_STEP_Q31 ), sub( Q31, Q_frame ) ) ); + hMd->gd_idx = sub( hMd->gd_idx, gd_idx_min ); + +#ifdef DEBUG_QUANT_MD_FX + quant_val_flt = min( ISAR_SPLIT_REND_D_MAX_VAL, max( hMd->gd, ISAR_SPLIT_REND_D_MIN_VAL ) ); + gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_D_1BYQ_STEP * ISAR_SPLIT_REND_D_MIN_VAL ); + tmp = (int16_t) roundf( ISAR_SPLIT_REND_D_1BYQ_STEP * quant_val_flt ); + tmp = tmp - gd_idx_min; + if ( hMd->gd_idx != tmp ) + { + printf( "\nUNEQUAL INDEX\n" ); + } +#endif + } + else if ( pose_type == LR_GAIN_ONLY ) + { + quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PITCH_G_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( L_add( hMd->gd_fx, shr( 20, sub( Q30, Q_frame ) ) ), L_shr_r( ISAR_SPLIT_REND_PITCH_G_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); // Q25 + gd_idx_min = 7; // (int16_t)roundf(ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * ISAR_SPLIT_REND_PRED_MAX_VAL) + hMd->gd_idx = (Word16) L_shr_r( Mpy_32_32( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP_Q27, quant_val ), sub( Q_frame, 4 ) ); + hMd->gd_idx = sub( hMd->gd_idx, gd_idx_min ); + +#ifdef DEBUG_QUANT_MD_FX + quant_val_flt = min( ISAR_SPLIT_REND_PITCH_G_MAX_VAL, max( hMd->gd, ISAR_SPLIT_REND_PRED_MAX_VAL ) ); + gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * ISAR_SPLIT_REND_PRED_MAX_VAL ); + tmp = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * quant_val_flt ); + tmp = tmp - gd_idx_min; + if ( hMd->gd_idx != tmp ) + { + printf( "\nUNEQUAL INDEX\n" ); + } +#endif + quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PITCH_G_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( L_add( hMd->gd2_fx, shr( 20, sub( Q30, Q_frame ) ) ), L_shr_r( ISAR_SPLIT_REND_PITCH_G_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); // Q25 + hMd->gd2_idx = (Word16) L_shr_r( Mpy_32_32( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP_Q27, quant_val ), sub( Q_frame, 4 ) ); + hMd->gd2_idx = sub( hMd->gd2_idx, gd_idx_min ); + +#ifdef DEBUG_QUANT_MD_FX + quant_val_flt = min( ISAR_SPLIT_REND_PITCH_G_MAX_VAL, max( hMd->gd2, ISAR_SPLIT_REND_PRED_MAX_VAL ) ); + tmp = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * quant_val_flt ); + tmp = tmp - gd_idx_min; + if ( hMd->gd2_idx != tmp ) + { + printf( "\nUNEQUAL INDEX\n" ); + } +#endif + } + return; +} + + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +static void get_lr_gains( Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], + const Word16 exp_cov_ii_re, + Word32 cov_oo_re_fx[][BINAURAL_CHANNELS], + const Word16 exp_cov_oo_re, + Word32 gains_fx[BINAURAL_CHANNELS], + Word16 *exp_gains_fx ) +{ + Word16 exp_gd_tmp_buf[BINAURAL_CHANNELS] = { 0 }; + Word16 exp_gd_tmp = 0, i; + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gains_fx[i] = cov_ii_re_fx[i][i]; + move32(); + exp_gd_tmp_buf[i] = exp_cov_ii_re; + move16(); + + Word16 flag = BASOP_Util_Cmp_Mant32Exp( gains_fx[i], exp_gd_tmp_buf[i], EPSILON_FX, 0 ); + IF( EQ_16( flag, negate( 1 ) ) ) + { + gains_fx[i] = ONE_IN_Q25; + move32(); + exp_gd_tmp_buf[i] = 6; + move16(); + } + ELSE + { + Word16 tmp, tmp_sqrt, exp_tmp = 0; + tmp = BASOP_Util_Divide3232_Scale( cov_oo_re_fx[i][i], gains_fx[i], &exp_tmp ); + exp_tmp = exp_tmp + ( exp_cov_oo_re - exp_gd_tmp_buf[i] ); + tmp_sqrt = Sqrt16( tmp, &exp_tmp ); + gains_fx[i] = L_deposit_h( tmp_sqrt ); + move32(); + exp_gd_tmp_buf[i] = exp_tmp; + move16(); + } + } + + Word16 max_gd_exp = MIN16B; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + max_gd_exp = max( max_gd_exp, exp_gd_tmp_buf[i] ); + } + exp_gd_tmp = max_gd_exp; + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gains_fx[i] = L_shr( gains_fx[i], max_gd_exp - exp_gd_tmp_buf[i] ); + move32(); + } + + *exp_gains_fx = exp_gd_tmp; + move16(); + return; +} +#endif + +static void ComputeCoeffs_fx( + Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_re, + Word32 cov_ii_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_ii_im, + Word32 cov_io_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_io_re, + Word32 cov_io_im_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_io_im, + Word32 cov_oo_re_fx[][BINAURAL_CHANNELS], + Word16 exp_cov_oo_re, + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd, + const ISAR_SPLIT_REND_POSE_TYPE pose_type, + const Word16 real_only ) +{ + Word16 i, j; + Word32 gd_fx, gl2_fx, gr2_fx, cov_norm_fact_fx; + Word16 exp_gd = 0; + + Word32 postpred_cov_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 exp_postpred_cov_re = 0; + + Word32 cov_ii_norm_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 cov_ii_norm_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 cov_io_norm_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 cov_io_norm_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 cov_oo_norm_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + Word16 exp_cov_ii_norm_re = 0, exp_cov_ii_norm_im = 0, exp_cov_io_norm_re = 0, exp_cov_io_norm_im = 0, exp_cov_oo_norm_re = 0; + Word16 exp_pred_re = 0, exp_pred_im = 0; + + IF( EQ_16( pose_type, PITCH_ONLY ) ) + { + Word32 gd_tmp_fx[BINAURAL_CHANNELS]; + Word16 exp_gd_tmp_buf[BINAURAL_CHANNELS] = { 0 }; + Word16 exp_gd_tmp = 0; + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gd_tmp_fx[i] = cov_ii_re_fx[i][i]; + move32(); + exp_gd_tmp_buf[i] = exp_cov_ii_re; + move16(); + exp_gd_tmp = exp_cov_ii_re; + + Word16 flag = BASOP_Util_Cmp_Mant32Exp( gd_tmp_fx[i], exp_gd_tmp, EPSILON_FX, 0 ); + IF( EQ_16( flag, negate( 1 ) ) ) + { + gd_tmp_fx[i] = ONE_IN_Q25; + move32(); + exp_gd_tmp_buf[i] = 6; + move16(); + } + ELSE + { + Word16 tmp, tmp_sqrt, exp_tmp = 0; + tmp = BASOP_Util_Divide3232_Scale( cov_oo_re_fx[i][i], gd_tmp_fx[i], &exp_tmp ); + exp_tmp = add( exp_tmp, sub( exp_cov_oo_re, exp_gd_tmp ) ); + tmp_sqrt = Sqrt16( tmp, &exp_tmp ); + gd_tmp_fx[i] = L_deposit_h( tmp_sqrt ); + move32(); + exp_gd_tmp_buf[i] = exp_tmp; + move16(); + } + } + + Word16 max_gd_exp = MIN16B; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + max_gd_exp = s_max( max_gd_exp, exp_gd_tmp_buf[i] ); + } + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gd_tmp_fx[i] = L_shr( gd_tmp_fx[i], max_gd_exp - exp_gd_tmp_buf[i] ); + move32(); + } + exp_gd_tmp = max_gd_exp; + move16(); + hMd->gd_fx = gd_tmp_fx[0]; + move16(); + hMd->gd2_fx = gd_tmp_fx[1]; + move16(); + hMd->exp_gd = exp_gd_tmp; + move16(); + hMd->exp_gd2 = exp_gd_tmp; + move16(); + } + ELSE + { + IF( real_only ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word32 gd_tmp_fx[BINAURAL_CHANNELS]; + get_lr_gains( cov_ii_re_fx, exp_cov_ii_re, + cov_oo_re_fx, exp_cov_oo_re, + gd_tmp_fx, &hMd->exp_pred_mat_re2 ); + hMd->pred_mat_re_fx[1][0] = 0; + move32(); + hMd->pred_mat_re_fx[0][1] = 0; + move32(); + hMd->exp_pred_mat_re = hMd->exp_pred_mat_re2; + move16(); + hMd->exp_pred_mat_im = hMd->exp_pred_mat_re; + move16(); + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_re_fx[i][i] = gd_tmp_fx[i]; + hMd->pred_mat_re2[i] = gd_tmp_fx[i]; + set32_fx( hMd->pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); + } + + +#else + Word32 gd_tmp_fx[BINAURAL_CHANNELS]; + Word16 exp_gd_tmp_buf[BINAURAL_CHANNELS] = { 0 }; + Word16 exp_gd_tmp = 0; + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gd_tmp_fx[i] = cov_ii_re_fx[i][i]; + move32(); + exp_gd_tmp_buf[i] = exp_cov_ii_re; + move16(); + + Word16 flag = BASOP_Util_Cmp_Mant32Exp( gd_tmp_fx[i], exp_gd_tmp_buf[i], EPSILON_FX, 0 ); + IF( EQ_16( flag, negate( 1 ) ) ) + { + gd_tmp_fx[i] = ONE_IN_Q25; + move32(); + exp_gd_tmp_buf[i] = 6; + move16(); + } + ELSE + { + Word16 tmp, tmp_sqrt, exp_tmp = 0; + tmp = BASOP_Util_Divide3232_Scale( cov_oo_re_fx[i][i], gd_tmp_fx[i], &exp_tmp ); + exp_tmp = exp_tmp + ( exp_cov_oo_re - exp_gd_tmp_buf[i] ); + tmp_sqrt = Sqrt16( tmp, &exp_tmp ); + gd_tmp_fx[i] = L_deposit_h( tmp_sqrt ); + move32(); + exp_gd_tmp_buf[i] = exp_tmp; + move16(); + } + hMd->pred_mat_re_fx[i][i] = gd_tmp_fx[i]; + move32(); + set32_fx( hMd->pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); + } + hMd->pred_mat_re_fx[1][0] = 0; + move32(); + hMd->pred_mat_re_fx[0][1] = 0; + move32(); + + Word16 max_gd_exp = MIN16B; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + max_gd_exp = max( max_gd_exp, exp_gd_tmp_buf[i] ); + } + exp_gd_tmp = max_gd_exp; + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_re_fx[i][i] = L_shr( hMd->pred_mat_re_fx[i][i], max_gd_exp - exp_gd_tmp_buf[i] ); + move32(); + } + + exp_pred_re = exp_gd_tmp; + move16(); + exp_pred_im = exp_gd_tmp; + move16(); + + hMd->exp_pred_mat_re = exp_pred_re; + move16(); + hMd->exp_pred_mat_im = exp_pred_im; + move16(); +#endif + } + ELSE + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + get_lr_gains( cov_ii_re_fx, exp_cov_ii_re, + cov_oo_re_fx, exp_cov_oo_re, + hMd->pred_mat_re2, &hMd->exp_pred_mat_re2 ); +#endif + Word16 exp_norm_fact = 0; + cov_norm_fact_fx = GetNormFact_fx( cov_ii_re_fx, exp_cov_ii_re, cov_ii_im_fx, exp_cov_ii_im, cov_io_re_fx, exp_cov_io_re, cov_io_im_fx, exp_cov_io_im, cov_oo_re_fx, exp_cov_oo_re, &exp_norm_fact ); + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + cov_ii_norm_re_fx[i][j] = Mpy_32_32( cov_ii_re_fx[i][j], cov_norm_fact_fx ); + move32(); + cov_ii_norm_im_fx[i][j] = Mpy_32_32( cov_ii_im_fx[i][j], cov_norm_fact_fx ); + move32(); + cov_io_norm_re_fx[i][j] = Mpy_32_32( cov_io_re_fx[i][j], cov_norm_fact_fx ); + move32(); + cov_io_norm_im_fx[i][j] = Mpy_32_32( cov_io_im_fx[i][j], cov_norm_fact_fx ); + move32(); + cov_oo_norm_re_fx[i][j] = Mpy_32_32( cov_oo_re_fx[i][j], cov_norm_fact_fx ); + move32(); + } + } + + exp_cov_ii_norm_re = add( exp_cov_ii_re, exp_norm_fact ); + exp_cov_ii_norm_im = add( exp_cov_ii_im, exp_norm_fact ); + exp_cov_io_norm_re = add( exp_cov_io_re, exp_norm_fact ); + exp_cov_io_norm_im = add( exp_cov_io_im, exp_norm_fact ); + exp_cov_oo_norm_re = add( exp_cov_oo_re, exp_norm_fact ); + + ComputePredMat_fx( cov_ii_norm_re_fx, exp_cov_ii_norm_re, cov_ii_norm_im_fx, exp_cov_ii_norm_im, cov_io_norm_re_fx, exp_cov_io_norm_re, cov_io_norm_im_fx, exp_cov_io_norm_im, hMd->pred_mat_re_fx, &exp_pred_re, hMd->pred_mat_im_fx, &exp_pred_im, BINAURAL_CHANNELS, real_only ); + hMd->exp_pred_mat_re = exp_pred_re; + move16(); + hMd->exp_pred_mat_im = exp_pred_im; + move16(); + + /*TODO : change this function to real only as thats what is needed*/ + ComputePostPredCov_fx( cov_ii_norm_re_fx, exp_cov_ii_norm_re, cov_ii_norm_im_fx, exp_cov_ii_norm_im, hMd->pred_mat_re_fx, exp_pred_re, hMd->pred_mat_im_fx, exp_pred_im, postpred_cov_re_fx, &exp_postpred_cov_re, BINAURAL_CHANNELS ); + + /* normalize everything to +-1 range */ + Word16 gd_16_fx = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, PCM16_TO_FLT_FAC_FX_Q15, &exp_gd ); + gd_fx = L_deposit_h( gd_16_fx ); + exp_gd = add( exp_gd, sub( 1, 16 ) ); + + Word16 tmp_buff_2[BINAURAL_CHANNELS][BINAURAL_CHANNELS], tmp_buff_3[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + Word64 tmp_2 = W_mult_32_32( cov_ii_norm_re_fx[i][j], gd_fx ); + Word64 tmp_3 = W_mult_32_32( cov_oo_norm_re_fx[i][j], gd_fx ); + Word16 shift_2 = W_norm( tmp_2 ); + Word16 shift_3 = W_norm( tmp_3 ); + + postpred_cov_re_fx[i][j] = Mpy_32_32( postpred_cov_re_fx[i][j], gd_fx ); + move32(); + cov_ii_norm_re_fx[i][j] = W_extract_h( W_shl( tmp_2, shift_2 ) ); + move32(); + cov_oo_norm_re_fx[i][j] = W_extract_h( W_shl( tmp_3, shift_3 ) ); + move32(); + + tmp_buff_2[i][j] = exp_cov_ii_norm_re + exp_gd - shift_2; + move16(); + tmp_buff_3[i][j] = exp_cov_oo_norm_re + exp_gd - shift_3; + move16(); + } + } + Word16 max_2 = MIN16B, max_3 = MIN16B; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + max_2 = s_max( max_2, tmp_buff_2[i][j] ); + max_3 = s_max( max_3, tmp_buff_3[i][j] ); + } + } + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + cov_ii_norm_re_fx[i][j] = L_shr( cov_ii_norm_re_fx[i][j], max_2 - tmp_buff_2[i][j] ); + move32(); + cov_oo_norm_re_fx[i][j] = L_shr( cov_oo_norm_re_fx[i][j], max_3 - tmp_buff_3[i][j] ); + move32(); + } + } + + exp_postpred_cov_re = add( exp_postpred_cov_re, exp_gd ); + exp_cov_ii_norm_re = max_2; + move16(); + exp_cov_oo_norm_re = max_3; + move16(); + + hMd->gd_fx = 0; + move16(); + Word16 exp_gl2 = 0; + move16(); + Word16 check_postPred = BASOP_Util_Cmp_Mant32Exp( postpred_cov_re_fx[0][0], exp_postpred_cov_re, EPSILON_FX, 0 ); + IF( EQ_16( check_postPred, 1 ) ) + { + Word16 exp_div_res = 0; + Word16 div_res = BASOP_Util_Divide3232_Scale( cov_oo_norm_re_fx[0][0], postpred_cov_re_fx[0][0], &exp_div_res ); + exp_div_res = exp_div_res + ( exp_cov_oo_norm_re - exp_postpred_cov_re ); + gl2_fx = L_deposit_h( div_res ); + exp_gl2 = exp_div_res; + move16(); + + Word16 Cmp1 = BASOP_Util_Cmp_Mant32Exp( gl2_fx, exp_gl2, ONE_IN_Q30, 1 ); + IF( EQ_16( Cmp1, negate( 1 ) ) ) + { + gl2_fx = ONE_IN_Q30; + exp_gl2 = 1; + move16(); + move16(); + } + + gl2_fx = Sqrt32( gl2_fx, &exp_gl2 ); + } + ELSE + { + gl2_fx = ONE_IN_Q30; + exp_gl2 = 1; + move16(); + move16(); + } + + Word16 exp_gr2 = 0; + check_postPred = BASOP_Util_Cmp_Mant32Exp( postpred_cov_re_fx[1][1], exp_postpred_cov_re, EPSILON_FX, 0 ); + IF( EQ_16( check_postPred, 1 ) ) + { + Word16 exp_div_res = 0; + Word16 div_res = BASOP_Util_Divide3232_Scale( cov_oo_norm_re_fx[1][1], postpred_cov_re_fx[1][1], &exp_div_res ); + exp_div_res = exp_div_res + ( exp_cov_oo_norm_re - exp_postpred_cov_re ); + gr2_fx = L_deposit_h( div_res ); + exp_gr2 = exp_div_res; + + Word16 Cmp1 = BASOP_Util_Cmp_Mant32Exp( gr2_fx, exp_gr2, ONE_IN_Q30, 1 ); + IF( EQ_16( Cmp1, negate( 1 ) ) ) + { + gr2_fx = ONE_IN_Q30; + move16(); + exp_gr2 = 1; + move16(); + } + + gr2_fx = Sqrt32( gr2_fx, &exp_gr2 ); + } + ELSE + { + gr2_fx = ONE_IN_Q30; + move16(); + exp_gr2 = 1; + move16(); + } + + Word16 pred_mat_buf_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 pred_mat_buf_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + pred_mat_buf_re[i][j] = exp_pred_re; + move16(); + pred_mat_buf_im[i][j] = exp_pred_im; + move16(); + } + } + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_re_fx[i][0] = Mpy_32_32( hMd->pred_mat_re_fx[i][0], gl2_fx ); + move32(); + hMd->pred_mat_re_fx[i][1] = Mpy_32_32( hMd->pred_mat_re_fx[i][1], gr2_fx ); + move32(); + pred_mat_buf_re[i][0] = add( exp_pred_re, exp_gl2 ); + move16(); + pred_mat_buf_re[i][1] = add( exp_pred_re, exp_gr2 ); + move16(); + } + + IF( EQ_16( real_only, 0 ) ) + { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_im_fx[i][0] = Mpy_32_32( hMd->pred_mat_im_fx[i][0], gl2_fx ); + move32(); + hMd->pred_mat_im_fx[i][1] = Mpy_32_32( hMd->pred_mat_im_fx[i][1], gr2_fx ); + move32(); + + pred_mat_buf_im[i][0] = add( exp_pred_im, exp_gl2 ); + move16(); + pred_mat_buf_im[i][1] = add( exp_pred_im, exp_gr2 ); + move16(); + } + } + + Word16 max_exp_pred_re = MIN16B, max_exp_pred_im = MIN16B; + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + max_exp_pred_re = s_max( max_exp_pred_re, pred_mat_buf_re[i][j] ); + max_exp_pred_im = s_max( max_exp_pred_im, pred_mat_buf_im[i][j] ); + } + } + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + hMd->pred_mat_re_fx[i][j] = L_shr( hMd->pred_mat_re_fx[i][j], max_exp_pred_re - pred_mat_buf_re[i][j] ); + move32(); + hMd->pred_mat_im_fx[i][j] = L_shr( hMd->pred_mat_im_fx[i][j], max_exp_pred_im - pred_mat_buf_im[i][j] ); + move32(); + } + } + + hMd->exp_pred_mat_re = max_exp_pred_re; + move16(); + hMd->exp_pred_mat_im = max_exp_pred_im; + move16(); + } + } + + return; +} + +static void get_base2_bits( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word16 num_subframes, + const Word16 num_quant_strats, + const Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const Word16 d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const Word16 bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word32 base2bits[ISAR_SPLIT_REND_NUM_QUANT_STRATS] ) +{ + Word16 pred_roll_bits; + Word16 d_gain_bits, pitch_gain_bits, pose_idx, q; + Word16 pred_yaw_bits[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word16 bin_ch_2, bin_ch_2_num_sf, bin_ch_num_sf; + + ISAR_SPLIT_REND_POSE_TYPE pose_type; + + FOR( q = 0; q < num_quant_strats; q++ ) + { + pred_yaw_bits[q] = ceil_log_2( pred_quant_pnts_yaw[q] ); + move16(); + } + pred_roll_bits = ceil_log_2( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS ); + + d_gain_bits = ceil_log_2( ISAR_SPLIT_REND_D_QUANT_PNTS ); + pitch_gain_bits = d_gain_bits; + move16(); + + FOR( q = 0; q < num_quant_strats; q++ ) + { + base2bits[q] = 0; + move32(); + } + + bin_ch_2 = DEPR_i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + bin_ch_2_num_sf = DEPR_i_mult( bin_ch_2, num_subframes ); + bin_ch_num_sf = DEPR_i_mult( BINAURAL_CHANNELS, num_subframes ); + + FOR( q = 0; q < num_quant_strats; q++ ) + { + FOR( pose_idx = 0; pose_idx < sub( pMultiBinPoseData->num_poses, 1 ); pose_idx++ ) + { + pose_type = hBinHrSplitPreRend->pose_type[pose_idx]; + IF( EQ_32( pose_type, ANY_YAW ) ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_real_bands_yaw[q] ), bin_ch_2_num_sf ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_imag_bands_yaw[q] ), bin_ch_2_num_sf ) ); + move32(); +#else + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_real_bands_yaw[q] ), bin_ch_num_sf ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_imag_bands_yaw[q] ), bin_ch_num_sf ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_imag_bands_yaw[q] ), bin_ch_2_num_sf ) ); + move32(); +#endif + + + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( d_gain_bits, d_bands_yaw[q] ), num_subframes ) ); + move32(); + } + ELSE IF( EQ_32( pose_type, PITCH_ONLY ) ) + { + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pitch_gain_bits, bands_pitch[q] ), num_subframes ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pitch_gain_bits, bands_pitch[q] ), num_subframes ) ); + move32(); + } + ELSE + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_real_bands_roll[q] ), bin_ch_2_num_sf ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_imag_bands_roll[q] ), bin_ch_2_num_sf ) ); + move32(); +#else + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_real_bands_roll[q] ), bin_ch_num_sf ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_imag_bands_roll[q] ), bin_ch_num_sf ) ); + move32(); + base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_imag_bands_roll[q] ), bin_ch_2_num_sf ) ); + move32(); +#endif + } + } + } + + return; +} + + +static void isar_SplitRenderer_code_md_base2( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word16 num_subframes, + const Word16 pred_real_bands_yaw, + const Word16 pred_imag_bands_yaw, + const Word16 pred_quant_pnts_yaw, + const Word16 d_bands_yaw, + const Word16 bands_pitch, + const Word16 pred_real_bands_roll, + const Word16 pred_imag_bands_roll, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word16 pos_idx, b, ch1, ch2, sf_idx; + Word16 min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len, num_poses; + Word16 min_pred_roll_idx, pred_roll_code_len; + Word16 pred_cb_idx; + Word32 code; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; + IF( EQ_16( pred_quant_pnts_yaw, ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) ) + { + pred_cb_idx = 1; + move16(); + } + ELSE + { + pred_cb_idx = 0; + move16(); + } + min_pred_idx = extract_l( pHuff_cfg->pred[pred_cb_idx].codebook[0] ); + min_pred_roll_idx = extract_l( pHuff_cfg->pred_roll.codebook[0] ); + min_gd_idx = extract_l( pHuff_cfg->gd.codebook[0] ); + min_p_gd_idx = extract_l( pHuff_cfg->p_gd.codebook[0] ); + + pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx]; + move16(); + pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; + move16(); + gd_code_len = pHuff_cfg->gd_base2_code_len; + move16(); + p_gd_code_len = pHuff_cfg->p_gd_base2_code_len; + move16(); + + num_poses = pMultiBinPoseData->num_poses; + move16(); + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( pos_idx = 0; pos_idx < sub( num_poses, 1 ); pos_idx++ ) + { + IF( EQ_32( hBinHrSplitPreRend->pose_type[pos_idx], ANY_YAW ) ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_re_idx[ch1][ch2], min_pred_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + } + + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_im_idx[ch1][ch2], min_pred_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + } +#else + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_re_idx[ch1][ch2], min_pred_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_im_idx[ch1][ch2], min_pred_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + } + FOR( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = L_sub( hMd->pred_mat_re_idx[ch1][ch1], min_pred_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } +#endif + FOR( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + code = L_sub( hMd->gd_idx, min_gd_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, gd_code_len ); + } + } + ELSE IF( EQ_32( hBinHrSplitPreRend->pose_type[pos_idx], PITCH_ONLY ) ) + { + FOR( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + code = L_sub( hMd->gd_idx, min_p_gd_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, p_gd_code_len ); + + code = L_sub( hMd->gd2_idx, min_p_gd_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, p_gd_code_len ); + } + } + ELSE + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_re_idx[ch1][ch2], min_pred_roll_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + } + + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_im_idx[ch1][ch2], min_pred_roll_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + } +#else + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_re_idx[ch1][ch2], min_pred_roll_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = L_sub( hMd->pred_mat_im_idx[ch1][ch2], min_pred_roll_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + } + FOR( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = L_sub( hMd->pred_mat_re_idx[ch1][ch1], min_pred_roll_idx ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } +#endif + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + static int16_t num_bits = 0; + static int16_t cntr = 0; + float fnum_bits; + + cntr++; + + num_bits += pBits->bits_written; + /* collect bits for every second */ + if ( cntr == 50 ) + { + cntr = 0; + fnum_bits = (float) num_bits / 1000.0f; + dbgwrite_txt( &fnum_bits, 1, "split_rend_MD_bitrate.txt", "MD bitrate (kbps)" ); + num_bits = 0; + } + } +#endif + return; +} + + +static void isar_SplitRenderer_code_md_huff( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word16 num_subframes, + const Word16 pred_real_bands_yaw, + const Word16 pred_imag_bands_yaw, + const Word16 pred_quant_pnts_yaw, + const Word16 d_bands_yaw, + const Word16 bands_pitch, + const Word16 pred_real_bands_roll, + const Word16 pred_imag_bands_roll, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + Word16 pos_idx, b, ch1, ch2, sf_idx, num_poses; + Word16 sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 min_pred_idx, max_pred_idx; + Word16 min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx; + Word32 code, len; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; + + IF( EQ_16( pred_quant_pnts_yaw, ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) ) + { + pred_cb_idx = 1; + move16(); + } + ELSE + { + pred_cb_idx = 0; + move16(); + } + + min_pred_idx = extract_l( pHuff_cfg->pred[pred_cb_idx].codebook[0] ); + max_pred_idx = extract_l( pHuff_cfg->pred[pred_cb_idx].codebook[DEPR_i_mult( sub( pred_quant_pnts_yaw, 1 ), 3 )] ); + min_pred_roll_idx = extract_l( pHuff_cfg->pred_roll.codebook[0] ); + max_pred_roll_idx = extract_l( pHuff_cfg->pred_roll.codebook[DEPR_i_mult( sub( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS, 1 ), 3 )] ); + + num_poses = pMultiBinPoseData->num_poses; + move16(); + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( pos_idx = 0; pos_idx < sub( num_poses, 1 ); pos_idx++ ) + { + IF( EQ_32( hBinHrSplitPreRend->pose_type[pos_idx], ANY_YAW ) ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_idx, max_pred_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } +#else + FOR( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_idx, max_pred_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + FOR( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch1], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } +#endif + FOR( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_huffman_encode( &pHuff_cfg->gd, hMd->gd_idx, &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + ELSE IF( EQ_32( hBinHrSplitPreRend->pose_type[pos_idx], PITCH_ONLY ) ) + { + FOR( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_huffman_encode( &pHuff_cfg->p_gd, hMd->gd_idx, &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + + isar_split_rend_huffman_encode( &pHuff_cfg->p_gd, hMd->gd2_idx, &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + ELSE + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + FOR( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } +#else + FOR( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + FOR( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch1], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } +#endif + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + static int16_t num_bits = 0; + static int16_t cntr = 0; + float fnum_bits; + + cntr++; + num_bits += pBits->bits_written; + /* collect bits for every second */ + IF( cntr == 50 ) + { + cntr = 0; + fnum_bits = (float) num_bits / 1000.0f; + dbgwrite_txt( &fnum_bits, 1, "split_rend_MD_bitrate.txt", "MD bitrate (kbps)" ); + num_bits = 0; + } + } +#endif + return; +} + +static void isar_SplitRenderer_quant_code( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + const IVAS_QUATERNION headPosition, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word16 low_res_pre_rend_rot, +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + const int16_t ro_md_flag, +#endif + const Word32 target_md_bits, + Word16 Q_frame ) +{ +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word16 q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; +#else + Word16 num_complex_bands, q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; +#endif + Word32 overhead_bits, quant_strat_bits, huff_bits, start_bit; + Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word16 d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word32 base2bits[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word16 pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word32 pred_1byquantstep_yaw_fx[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + Word32 pred_quantstep_yaw_fx[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; +#ifdef DEBUG_QUANT_MD_FX + float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; +#endif + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word16 rot_axis_code, num_bits; +#endif + + IF( low_res_pre_rend_rot ) + { + num_subframes = 1; + } + ELSE + { + num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; + } + + overhead_bits = pBits->bits_written; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->dof, ISAR_SPLIT_REND_DOF_BITS ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->hq_mode, ISAR_SPLIT_REND_HQ_MODE_BITS ); +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + rot_axis_code = isar_renderSplitGetCodeFromRot_axis( pMultiBinPoseData->dof, pMultiBinPoseData->rot_axis, &num_bits ); + if ( num_bits > 0 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) rot_axis_code, num_bits ); + } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) ro_md_flag, ISAR_SPLIT_REND_RO_FLAG_BITS ); +#else + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) pMultiBinPoseData->rot_axis, ISAR_SPLIT_REND_ROT_AXIS_BITS ); +#endif + + /* code ref pose*/ + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + Word16 angle; + IVAS_QUATERNION head_pos_euler; + + Quat2EulerDegree_fx( headPosition, &head_pos_euler.z_fx, &head_pos_euler.y_fx, &head_pos_euler.x_fx ); + angle = (Word16) L_shr_r( head_pos_euler.x_fx, Q22 ); + angle = add( angle, 180 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + + angle = (Word16) L_shr_r( head_pos_euler.y_fx, Q22 ); + angle = add( angle, 180 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + + angle = (Word16) L_shr_r( head_pos_euler.z_fx, Q22 ); + angle = add( angle, 180 ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + } + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + isar_split_rend_get_quant_params_fx( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, + pred_quant_pnts_yaw, pred_quantstep_yaw_fx, pred_1byquantstep_yaw_fx, + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, ro_md_flag, &num_quant_strats ); +#else + isar_split_rend_get_quant_params_fx( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, + pred_quant_pnts_yaw, pred_quantstep_yaw_fx, pred_1byquantstep_yaw_fx, + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, &num_quant_strats, &num_complex_bands ); +#endif +#ifdef DEBUG_QUANT_MD_FX + fixedToFloat_arrL( pred_quantstep_yaw_fx, pred_quantstep_yaw, Q31, ISAR_SPLIT_REND_NUM_QUANT_STRATS ); + fixedToFloat_arrL( pred_1byquantstep_yaw_fx, pred_1byquantstep_yaw, Q26, ISAR_SPLIT_REND_NUM_QUANT_STRATS ); +#endif + + quant_strat_bits = ceil_log_2( num_quant_strats ); + + overhead_bits = L_add( L_add( L_sub( pBits->bits_written, overhead_bits ), quant_strat_bits ), 1 ); /* 1 for base2 vs huff */ + + get_base2_bits( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, + pred_quant_pnts_yaw, + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); + + FOR( q = 0; q < num_quant_strats; q++ ) + { + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + IF( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_YAW ) + { + FOR( b = 0; b < pred_imag_bands_yaw[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md_fx( hMd, PRED_ONLY, 0, hBinHrSplitPreRend->fix_pos_rot_mat_fx[pos_idx], pred_1byquantstep_yaw_fx[q], Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], pred_1byquantstep_yaw[q] +#endif + ); + } + FOR( ; b < pred_real_bands_yaw[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md_fx( hMd, PRED_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat_fx[pos_idx], pred_1byquantstep_yaw_fx[q], Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], pred_1byquantstep_yaw[q] +#endif + ); + } + + FOR( b = 0; b < d_bands_yaw[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md_fx( hMd, COM_GAIN_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat_fx[pos_idx], 0, Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], 0.0f +#endif + ); + } + } + ELSE IF( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + FOR( b = 0; b < bands_pitch[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md_fx( hMd, LR_GAIN_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat_fx[pos_idx], 0, Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], 0.0f +#endif + ); + } + } + ELSE + { + FOR( b = 0; b < pred_imag_bands_roll[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md_fx( hMd, PRED_ROLL_ONLY, 0, hBinHrSplitPreRend->fix_pos_rot_mat_fx[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP_Q26, Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP +#endif + ); + } + FOR( ; b < pred_real_bands_roll[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md_fx( hMd, PRED_ROLL_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat_fx[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP_Q26, Q_frame +#ifdef DEBUG_QUANT_MD_FX + , + hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP +#endif + ); + } + } + } + } + + /*get base2 bits and check if its within target. if yes then code with base2 to save complexity on post renderer*/ + start_bit = pBits->bits_written; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, q, quant_strat_bits ); + + huff_bits = pBits->bits_written; + isar_SplitRenderer_code_md_huff( + hBinHrSplitPreRend, + pMultiBinPoseData, + num_subframes, + pred_real_bands_yaw[q], + pred_imag_bands_yaw[q], + pred_quant_pnts_yaw[q], + d_bands_yaw[q], + bands_pitch[q], + pred_real_bands_roll[q], + pred_imag_bands_roll[q], + pBits ); + + huff_bits = L_sub( pBits->bits_written, huff_bits ); + test(); + test(); + test(); + IF( GE_32( target_md_bits, ( base2bits[q] + overhead_bits ) ) || GE_32( target_md_bits, ( huff_bits + overhead_bits ) ) || EQ_16( q, sub( num_quant_strats, 1 ) ) ) + { + IF( GT_32( huff_bits, base2bits[q] ) ) + { + pBits->bits_written = start_bit; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, q, quant_strat_bits ); + + isar_SplitRenderer_code_md_base2( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, pred_real_bands_yaw[q], pred_imag_bands_yaw[q], + pred_quant_pnts_yaw[q], + d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); + } + BREAK; + } + + pBits->bits_written = start_bit; + } + +#ifdef SPLIT_MD_CODING_DEBUG + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + int16_t val, quant_strat, ch1, ch2; + char filename[200] = "split_md_debug_indices.bin"; + quant_strat = q; + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + else if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_idx; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + else + { + for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + } + } + } +#endif + + return; +} +/*------------------------------------------------------------------------- + * Function isar_SplitRenderer_GetRotMd() + * + * + *------------------------------------------------------------------------*/ + +static Word16 imult1616( Word16 x, Word16 y ) +{ + assert( (int) x * (int) y < 32768 && (int) x * (int) y >= -32768 ); + return extract_l( L_mult0( x, y ) ); +} + +static void isar_SplitRenderer_GetRotMd_fx( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_re, + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_im, + const Word16 low_res, + const Word16 ro_md_flag ) +{ + Word32 cov_ii_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { 0 }; + Word32 cov_oo_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { 0 }; + Word32 cov_io_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { 0 }; + Word32 cov_ii_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { 0 }; + Word32 cov_oo_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { 0 }; + Word32 cov_io_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] = { 0 }; + Word16 exp_cov_io_re = 0, exp_cov_io_im = 0; + Word16 exp_cov_ii_re = 0, exp_cov_ii_im = 0; + Word16 exp_cov_oo_re = 0, exp_cov_oo_im = 0; + + Word16 real_only = 0; + Word16 pos_idx, b, sf_idx, start_slot_idx, num_slots, num_subframes, ch_s_idx1, ch_s_idx2; + Word16 num_md_bands, num_poses; + const Word16 *pBand_grouping = isar_split_rend_band_grouping; + + push_wmops( "isar_SplitRenderer_GetRotMd_fx" ); + + num_md_bands = MAX_SPLIT_REND_MD_BANDS; + move16(); + num_poses = pMultiBinPoseData->num_poses; + move16(); + + IF( low_res ) + { + num_slots = CLDFB_NO_COL_MAX; + move16(); + num_subframes = 1; + move16(); + } + ELSE + { + num_slots = MAX_PARAM_SPATIAL_SUBFRAMES; + move16(); + num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; + move16(); + } + + /* compute reference signal covariance */ + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + start_slot_idx = imult1616( sf_idx, num_slots ); + FOR( b = 0; b < num_md_bands; b++ ) + { + test(); + IF( LT_16( b, SPLIT_REND_RO_MD_BAND_THRESH ) || ( !ro_md_flag && b < COMPLEX_MD_BAND_THRESH ) ) + { + real_only = 0; + move16(); + } + ELSE + { + real_only = 1; + move16(); + } + + ch_s_idx1 = 0; + + ComputeBandedCov_fx( Cldfb_RealBuffer_Ref_Binaural_fx, exp_cldfb_re, Cldfb_ImagBuffer_Ref_Binaural_fx, exp_cldfb_im, ch_s_idx1, cov_ii_re_fx, &exp_cov_ii_re, cov_ii_im_fx, &exp_cov_ii_im, BINAURAL_CHANNELS, pBand_grouping, num_slots, start_slot_idx, b, real_only ); + + /* compute rotated signal covariance */ + FOR( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + IF( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_ROLL ) + { + IF( GE_16( b, SPLIT_REND_RO_MD_BAND_THRESH ) ) + { + real_only = 1; + } + } + ch_s_idx2 = imult1616( add( pos_idx, 1 ), BINAURAL_CHANNELS ); + + ComputeBandedCrossCov_fx( Cldfb_RealBuffer_Ref_Binaural_fx, exp_cldfb_re, Cldfb_ImagBuffer_Ref_Binaural_fx, exp_cldfb_im, ch_s_idx1, Cldfb_RealBuffer_Ref_Binaural_fx, exp_cldfb_re, Cldfb_ImagBuffer_Ref_Binaural_fx, exp_cldfb_im, ch_s_idx2, cov_io_re_fx, &exp_cov_io_re, cov_io_im_fx, &exp_cov_io_im, BINAURAL_CHANNELS, pBand_grouping, num_slots, start_slot_idx, b, real_only ); + + ComputeBandedCov_fx( Cldfb_RealBuffer_Ref_Binaural_fx, exp_cldfb_re, Cldfb_ImagBuffer_Ref_Binaural_fx, exp_cldfb_im, ch_s_idx2, cov_oo_re_fx, &exp_cov_oo_re, cov_oo_im_fx, &exp_cov_oo_im, BINAURAL_CHANNELS, pBand_grouping, num_slots, start_slot_idx, b, real_only ); + + ComputeCoeffs_fx( cov_ii_re_fx, exp_cov_ii_re, cov_ii_im_fx, exp_cov_ii_im, cov_io_re_fx, exp_cov_io_re, cov_io_im_fx, exp_cov_io_im, cov_oo_re_fx, exp_cov_oo_re, &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b], hBinHrSplitPreRend->pose_type[pos_idx], real_only ); + } + } + } + + pop_wmops(); + return; +} +/*------------------------------------------------------------------------- + * Function isar_rend_CldfbSplitPreRendProcess() + * + * + *------------------------------------------------------------------------*/ +void isar_rend_CldfbSplitPreRendProcess( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + const IVAS_QUATERNION headPosition, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re, + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 target_md_bits, + const Word16 low_res_pre_rend_rot, + const Word16 ro_md_flag ) +{ + push_wmops( "isar_rend_CldfbSplitPreRendProcess" ); + + isar_SplitRenderer_GetRotMd_fx( hBinHrSplitPreRend, pMultiBinPoseData, Cldfb_In_BinReal_fx, exp_cldfb_re, Cldfb_In_BinImag_fx, exp_cldfb_im, low_res_pre_rend_rot, ro_md_flag ); + + Word16 num_md_bands, num_poses; + Word16 pos_idx, b, sf_idx, num_subframes; + + num_md_bands = MAX_SPLIT_REND_MD_BANDS; + num_poses = pMultiBinPoseData->num_poses; + + IF( low_res_pre_rend_rot ) + { + num_subframes = 1; + } + ELSE + { + num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; + } + + /*FILE *filePointer_gd, *filePointer_gd2; + FILE *filePointer_re, *filePointer_im; + filePointer_gd = fopen("Fixed_code_cov_gd_complete.txt", "a"); + filePointer_gd2 = fopen("Fixed_code_cov_gd2_complete.txt", "a"); + filePointer_re = fopen("Fixed_code_re_complete.txt", "a"); + filePointer_im = fopen("Fixed_code_im_complete.txt", "a");*/ + +#ifdef DUMP_GETROTMD_OUTPUT + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( b = 0; b < num_md_bands; b++ ) + { + for ( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd = me2f( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_fx, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_gd ); + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2 = me2f( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_fx, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_gd2 ); + /*fprintf(filePointer_gd, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd); + fprintf(filePointer_gd2, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2);*/ + } + else + { + for ( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( int j = 0; j < BINAURAL_CHANNELS; j++ ) + { + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re[i][j] = me2f( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_fx[i][j], hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re ); + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im[i][j] = me2f( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_fx[i][j], hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_im ); + /*fprintf(filePointer_re, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re[i][j]); + fprintf(filePointer_im, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im[i][j]);*/ + } + } + } + } + } + } +#endif + + /*fclose(filePointer_gd); + fclose(filePointer_gd2); + fclose(filePointer_re); + fclose(filePointer_im);*/ + + /* Check if rescaling can be simplified/avoid */ + + Word16 exp_frame = 0; + // Word32 L_temp_max = 0; + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( b = 0; b < num_md_bands; b++ ) + { + FOR( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + IF( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_gd ); + exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_gd2 ); + } + ELSE + { + exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re ); +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re2 ); +#endif + exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_im ); + } + } + } + } + // exp_frame = s_min( exp_frame, sub( 31, norm_l( L_temp_max ) ) ); + exp_frame = s_min( exp_frame, 15 ); // Considering the max value as of prediction matrices as 300 + + Word16 Q_frame = sub( Q31, exp_frame ); + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( b = 0; b < num_md_bands; b++ ) + { + FOR( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + IF( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_fx = L_shr_r( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_fx, sub( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_gd ) ); + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_fx = L_shr_r( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_fx, sub( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_gd2 ) ); + /*fprintf(filePointer_gd, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd); + fprintf(filePointer_gd2, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2);*/ + } + ELSE + { + FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) + { + Scale_sig32( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_fx[i], BINAURAL_CHANNELS, sub( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re, exp_frame ) ); + Scale_sig32( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_fx[i], BINAURAL_CHANNELS, sub( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_im, exp_frame ) ); + } +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Scale_sig32( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re2, BINAURAL_CHANNELS, sub( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re2, exp_frame ) ); +#endif + } + } + } + } + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + isar_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, ro_md_flag, target_md_bits, Q_frame ); +#else + isar_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, target_md_bits, Q_frame ); +#endif +#ifdef DEBUG_QUANT_CODE_OUT + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( b = 0; b < num_md_bands; b++ ) + { + for ( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd = fixedToFloat( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_fx, Q_frame ); + hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2 = fixedToFloat( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_fx, Q_frame ); + /*fprintf(filePointer_gd, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd); + fprintf(filePointer_gd2, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2);*/ + } + else + { + for ( int i = 0; i < BINAURAL_CHANNELS; i++ ) + { + fixedToFloat_arrL( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_fx[i], hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re[i], Q_frame, BINAURAL_CHANNELS ); + fixedToFloat_arrL( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_fx[i], hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im[i], Q_frame, BINAURAL_CHANNELS ); + // for ( int j = 0; j < BINAURAL_CHANNELS; j++ ) + //{ + // hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re[i][j] = me2f( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_fx[i][j], Q6 ); + // hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im[i][j] = me2f( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_fx[i][j], Q6 ); + // /*fprintf(filePointer_re, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re[i][j]); + // fprintf(filePointer_im, "%f\n", hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im[i][j]);*/ + // } + } + } + } + } + } +#endif +#ifdef SPLIT_POSE_CORRECTION_DEBUG + float tmpCrendBuffer[2][L_FRAME48k], quant_val, step, minv, maxv; + IVAS_QUATERNION QuaternionsPost[MAX_PARAM_SPATIAL_SUBFRAMES], head_pos_euler; + float Cldfb_RealBuffer_Binaural_5ms[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural_5ms[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + int16_t sf_idx, pos_idx, b, ch1, ch2; + int32_t read_off, write_off; + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + QuaternionsPost[sf_idx].w = -3.0f; + QuaternionsPost[sf_idx].x = 0.0f; + QuaternionsPost[sf_idx].y = 0.0f; + QuaternionsPost[sf_idx].z = 0.0f; + } + + hBinHrSplitPreRend->hBinHrSplitPostRend->low_Res = 1; + set_fix_rotation_mat( hBinHrSplitPreRend->hBinHrSplitPostRend->fix_pos_rot_mat, pMultiBinPoseData ); + set_pose_types( hBinHrSplitPreRend->hBinHrSplitPostRend->pose_type, pMultiBinPoseData ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + Quat2EulerDegree( headPosition, &head_pos_euler.z, &head_pos_euler.y, &head_pos_euler.x ); + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].w = -3.0f; + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].x = roundf( head_pos_euler.x ); + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].y = roundf( head_pos_euler.y ); + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].z = roundf( head_pos_euler.z ); + } + for ( sf_idx = 0; sf_idx < 1; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + for ( b = 0; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hBinHrSplitPreRend->hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b] = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + BIN_HR_SPLIT_REND_MD_HANDLE hMd; + hMd = &hBinHrSplitPreRend->hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + minv = -1.4f; + maxv = 1.4f; + step = ( maxv - minv ) / 62.0f; + if ( b >= 20 ) + { + float sign; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sign = ( hMd->pred_mat_re[ch1][ch2] >= 0.0f ) ? 1.0f : -1.0f; + IVAS_CALCULATE_ABS( hMd->pred_mat_re[ch1][ch2], hMd->pred_mat_im[ch1][ch2], hMd->pred_mat_re[ch1][ch2] ); + hMd->pred_mat_re[ch1][ch2] *= sign; + hMd->pred_mat_im[ch1][ch2] = 0.0f; + } + } + } + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = hMd->pred_mat_re[ch1][ch2] - hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx][ch1][ch2]; + quant_val = min( maxv, max( quant_val, minv ) ); + quant_val = (int16_t) roundf( quant_val / step ); + hMd->pred_mat_re[ch1][ch2] = quant_val * step; + hMd->pred_mat_re[ch1][ch2] += hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx][ch1][ch2]; + + quant_val = hMd->pred_mat_im[ch1][ch2]; + quant_val = min( maxv, max( quant_val, minv ) ); + quant_val = (int16_t) roundf( quant_val / step ); + hMd->pred_mat_im[ch1][ch2] = quant_val * step; + } + } + } + } + } + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + mvr2r( (float *) Cldfb_In_BinReal[0][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_RealBuffer_Binaural_5ms[0], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + mvr2r( (float *) Cldfb_In_BinReal[1][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_RealBuffer_Binaural_5ms[1], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + mvr2r( (float *) Cldfb_In_BinImag[0][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_ImagBuffer_Binaural_5ms[0], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + mvr2r( (float *) Cldfb_In_BinImag[1][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_ImagBuffer_Binaural_5ms[1], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + isar_rend_CldfbSplitPostRendProcess( hBinHrSplitPreRend->hBinHrSplitPostRend, pMultiBinPoseData, QuaternionsPost[0], Cldfb_RealBuffer_Binaural_5ms, Cldfb_ImagBuffer_Binaural_5ms, tmpCrendBuffer, 1 ); + + { + float *pOut[2]; + char fname[200] = "ref_act_pos.wav"; + pOut[0] = tmpCrendBuffer[0]; + pOut[1] = tmpCrendBuffer[1]; + dbgwrite_wav( pOut, CLDFB_NO_COL_MAX * hBinHrSplitPreRend->hBinHrSplitPostRend->cldfbSyn[0]->no_channels, fname, 48000, 2 ); + } + } +#endif + + pop_wmops(); + return; +} + +/*------------------------------------------------------------------------- + * Function isar_splitBinPreRendOpen() + * + * + *------------------------------------------------------------------------*/ +ivas_error isar_splitBinPreRendOpen( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + const int32_t output_Fs +#endif +) +{ + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinRend; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_error error; + int16_t ch; +#endif + Word16 pos_idx, sf_idx, bandIdx; + + IF( ( hBinRend = (ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_PRE_REND ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split pre renderer Module \n" ) ); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES + 1; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hBinRend->cldfbSynRotBinDec[i][ch] = NULL; + } + } + + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES + 1; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hBinRend->cldfbSynRotBinDec[i][ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + FOR( sf_idx = 0; sf_idx < MAX_SPLIT_MD_SUBFRAMES; sf_idx++ ) + { + FOR( bandIdx = 0; bandIdx < MAX_SPLIT_REND_MD_BANDS; bandIdx++ ) + { + hBinRend->rot_md[pos_idx][sf_idx][bandIdx].gd_fx = 0; + } + } + } + set_fix_rotation_mat_fx( hBinRend->fix_pos_rot_mat_fx, pMultiBinPoseData ); + set_pose_types_fx( hBinRend->pose_type, pMultiBinPoseData ); + + isar_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + ivas_error error; + if ( ( error = isar_splitBinPostRendOpen( &hBinRend->hBinHrSplitPostRend, pMultiBinPoseData, 48000 ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + *hBinHrSplitPreRend = hBinRend; + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * Function isar_splitBinPreRendClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinPreRendClose( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ) +{ + IF( ( *hBinHrSplitPreRend ) != NULL ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + Word16 i, n; + FOR( i = 0; i < MAX_HEAD_ROT_POSES + 1; i++ ) + { + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + IF( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] != NULL ) + { + deleteCldfb( &( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] ) ); + ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] = NULL; + } + } + } + } +#endif +#ifdef SPLIT_POSE_CORRECTION_DEBUG + isar_splitBinPostRendClose( &( *hBinHrSplitPreRend )->hBinHrSplitPostRend ); +#endif + + free( ( *hBinHrSplitPreRend ) ); + ( *hBinHrSplitPreRend ) = NULL; + } + + return; +} + + +/*-------------------------------------------------------------------------* + * isar_set_split_rend_ht_setup() + * + * + *-------------------------------------------------------------------------*/ +void isar_set_split_rend_ht_setup_fx( + SPLIT_REND_WRAPPER *hSplitrend, + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], + Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ) +{ + Word16 sf, i, j; + IF( hSplitrend->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + FOR( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + Quaternions[sf] = Quaternions[0]; + + FOR( i = 0; i < 3; i++ ) + { + FOR( j = 0; j < 3; j++ ) + { + Rmat_fx[sf][i][j] = Rmat_fx[0][i][j]; + move32(); + } + } + } + } + + return; +} + +/*------------------------------------------------------------------------- + * Function isar_init_split_rend_handles() + * + * + *------------------------------------------------------------------------*/ + +void isar_init_split_rend_handles( + SPLIT_REND_WRAPPER *hSplitRendWrapper ) +{ + Word16 i; + + hSplitRendWrapper->hBinHrSplitPreRend = NULL; + hSplitRendWrapper->hCldfbHandles = NULL; + hSplitRendWrapper->hSplitBinLCLDEnc = NULL; + hSplitRendWrapper->hLc3plusEnc = NULL; + + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + hSplitRendWrapper->lc3plusDelayBuffers[i] = NULL; + hSplitRendWrapper->lc3plusDelayBuffers_fx[i] = NULL; + } + hSplitRendWrapper->lc3plusDelaySamples = 0; + move32(); + + isar_init_multi_bin_pose_data_fx_enc( &hSplitRendWrapper->multiBinPoseData ); + + return; +} + + +/*------------------------------------------------------------------------- + * Function split_renderer_open_lc3plus() + * + * + *------------------------------------------------------------------------*/ + +ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const Word32 OutSampleRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE isar_frame_size +#else + const int16_t num_subframes +#endif +) +{ + ivas_error error; + Word16 i, delayBufferLength; + LC3PLUS_CONFIG config; +#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + + if ( ( error = isar_framesize_to_ms( isar_frame_size, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* Check configuration validity */ + if ( isar_frame_size_ms < pSplitRendConfig->codec_frame_size_ms ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "SR codec frame doesn't fit in one output frame" ); + } +#endif + + config.lc3plus_frame_duration_us = pSplitRendConfig->codec_frame_size_ms * 1000; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.ivas_frame_duration_us = ( pSplitRendConfig->dof == 0 ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; +#endif + config.samplerate = OutSampleRate; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.isar_frame_duration_us = isar_frame_size_ms * 1000; +#endif +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.high_res_mode_enabled = ( pSplitRendConfig->lc3plus_highres != 0 ); +#endif + config.channels = BINAURAL_CHANNELS; + + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), +#else + isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), +#endif + &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* This returns delay of entire LC3plus chain (enc + dec) */ + IF( ( error = ISAR_LC3PLUS_ENC_GetDelay( hSplitRendWrapper->hLc3plusEnc, &hSplitRendWrapper->lc3plusDelaySamples ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Alocate buffers for delay compensation */ + IF( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + delayBufferLength = (Word16) ( OutSampleRate / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); + FOR( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) + { + IF( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); + } + + set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength ); + IF( ( hSplitRendWrapper->lc3plusDelayBuffers_fx[i] = malloc( delayBufferLength * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); + } + + set32_fx( hSplitRendWrapper->lc3plusDelayBuffers_fx[i], 0, delayBufferLength ); + } + hSplitRendWrapper->lc3plusDelayBuffers_q = 31; + } + ELSE + { + /* Delay is always expected to be exactly 2 CLDFB columns */ + assert( hSplitRendWrapper->lc3plusDelaySamples % ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 0 ); + assert( hSplitRendWrapper->lc3plusDelaySamples / ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 2 ); + + delayBufferLength = 2 /* Columns */ * 2 /* real and imag */ * CLDFB_NO_CHANNELS_MAX; + FOR( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) + { + IF( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); + } + + set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength ); + IF( ( hSplitRendWrapper->lc3plusDelayBuffers_fx[i] = malloc( delayBufferLength * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); + } + + set32_fx( hSplitRendWrapper->lc3plusDelayBuffers_fx[i], 0, delayBufferLength ); + } + hSplitRendWrapper->lc3plusDelayBuffers_q = 31; + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function splitRendLc3plusEncodeAndWrite() + * + * + *------------------------------------------------------------------------*/ +ivas_error splitRendLc3plusEncodeAndWrite( + SPLIT_REND_WRAPPER *hSplitBin, + ISAR_SPLIT_REND_BITS_HANDLE pBits, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int32_t available_bits, +#endif +#else + const int32_t SplitRendBitRate, +#endif + Word32 *in[], + Word16 Q_sig ) +{ + ivas_error error; + int16_t i; + int32_t lc3plusBitstreamSize; + Word32 *channel_ptrs[MAX_HEAD_ROT_POSES * 2]; + Word16 Q_in[16]; + assert( hSplitBin->hLc3plusEnc != NULL ); + + /* Find next byte boundary and zero-pad to it */ + while ( pBits->bits_written % 8 != 0 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0L, 1 ); + } + + for ( i = 0; i < BINAURAL_CHANNELS * hSplitBin->multiBinPoseData.num_poses; ++i ) + { + channel_ptrs[i] = in[i]; + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = IVAS_LC3PLUS_ENC_SetBitrate( hSplitBin->hLc3plusEnc, available_bits * FRAMES_PER_SEC ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + if ( ( error = ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( hSplitBin->hLc3plusEnc, &lc3plusBitstreamSize ) ) != IVAS_ERR_OK ) + { + return error; + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ISAR_SPLIT_REND_BITStream_write_int32( pBits, isar_get_lc3plus_bitrate_id( SplitRendBitRate ), 8 ); +#endif + /* Write bitstream */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + set16_fx( Q_in, Q_sig, 16 ); + move16(); + if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8], lc3plusBitstreamSize, Q_in ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8] ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + + pBits->bits_written += 8 * lc3plusBitstreamSize; + pBits->codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.lc3plus_frame_duration_us / 1000 ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + pBits->isar_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000 ); +#endif + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_renderMultiTDBinToSplitBinaural() + * + * + *------------------------------------------------------------------------*/ +ivas_error isar_renderMultiTDBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const Word32 SplitRendBitRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int16_t isar_frame_size_ms, +#endif + const Word16 codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word16 max_bands, + // float *in[], + Word32 *in_fx[], // Q11 + Word16 Q_sig, + const Word16 low_res_pre_rend_rot, + const Word16 pcm_out_flag, + const Word16 ro_md_flag ) +{ + ivas_error error; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t bit_len, available_bits, target_md_bits, tmp_32; +#else + Word32 bit_len, available_bits, target_md_bits, actual_md_bits, tmp_32; +#endif + Word16 num_cldfb_bands, ch, slot_idx, pos_idx, num_poses; + Word16 tmp, tmp_e; + Word32 Cldfb_In_BinReal_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word32 Cldfb_In_BinImag_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word16 Q_in = Q_sig, q_final = 0; + move16(); + move16(); + // float Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + // float Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + UWord8 useLc3plus; + Word32 *in_delayed_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; + Word16 i; + Word32 num_slots; + + push_wmops( "isar_renderMultiTDBinToSplitBinaural" ); + + error = IVAS_ERR_OK; + num_poses = hSplitBin->multiBinPoseData.num_poses; + + useLc3plus = hSplitBin->hLc3plusEnc != NULL; + + IF( useLc3plus ) + { + /*this should always have the time resolution of pose correction MD. Note that this does not change frame size of LC3plus*/ + // Word16 frame_size = (Word16) ( hSplitBin->hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ); + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( hSplitBin->hLc3plusEnc->config.samplerate, FRAMES_PER_SECOND_FX, &tmp_e ); + Word16 frame_size = shr( tmp, sub( 15, tmp_e ) ); // Q0 + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + /* Artificially delay input to head pose correction analysis by LC3plus coding delay, so that audio and metadata are in sync after decoding */ + mvl2l( hSplitBin->lc3plusDelayBuffers_fx[i] + frame_size, hSplitBin->lc3plusDelayBuffers_fx[i], (Word16) hSplitBin->lc3plusDelaySamples ); + // mvr2r( hSplitBin->lc3plusDelayBuffers[i] + frame_size, hSplitBin->lc3plusDelayBuffers[i], (int16_t) hSplitBin->lc3plusDelaySamples ); + in_delayed_fx[i] = hSplitBin->lc3plusDelayBuffers_fx[i]; + // in_delayed[i] = hSplitBin->lc3plusDelayBuffers[i]; + mvl2l( in_fx[i], hSplitBin->lc3plusDelayBuffers_fx[i] + hSplitBin->lc3plusDelaySamples, frame_size ); + // mvr2r(in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, frame_size); + } + } + ELSE + { + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + in_delayed_fx[i] = in_fx[i]; + move32(); + } + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; + move32(); +#endif + + test(); + test(); + IF( ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out_flag ) ) + { + Word32 in_delayed_cldfb[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k] = { 0 }; + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) + { + Copy32( in_delayed_fx[i], in_delayed_cldfb[i], L_FRAME48k ); + Scale_sig32( in_delayed_cldfb[i], L_FRAME48k, -4 ); + } + Q_sig = sub( Q_sig, 4 ); + num_slots = ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ? CLDFB_NO_COL_MAX : ( hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ); + move32(); + num_cldfb_bands = hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels; + move16(); + /* CLDFB Analysis*/ + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { +#ifdef SPLIT_POSE_CORRECTION_DEBUG + { + float *pOut[2]; + char fname[200] = "ref_out_pos"; + char tag[2]; + tag[0] = (char) ( '0' + pos_idx ); + tag[1] = '\0'; + strcat( fname, tag ); + strcat( fname, ".wav" ); + + pOut[0] = in_delayed[2 * pos_idx]; + pOut[1] = in_delayed[2 * pos_idx + 1]; + dbgwrite_wav( pOut, CLDFB_NO_COL_MAX * max_bands, fname, 48000, 2 ); + } + +#endif + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + HANDLE_CLDFB_FILTER_BANK temp_cldfbAna = hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]; + Scale_sig32( temp_cldfbAna->cldfb_state_fx, + sub( temp_cldfbAna->p_filter_length, temp_cldfbAna->no_channels ), sub( Q_sig, temp_cldfbAna->Q_cldfb_state ) ); + temp_cldfbAna->Q_cldfb_state = Q_sig; + move16(); + FOR( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + Word16 Q_cldfb = Q_sig; + // floatToFixed_arrL(hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->cldfb_state, hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->cldfb_state_fx, Q_output, hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->p_filter_length - hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->no_channels); + cldfbAnalysis_ts_fx_fixed_q( &( in_delayed_cldfb[pos_idx * BINAURAL_CHANNELS + ch][num_cldfb_bands * slot_idx] ), + Cldfb_In_BinReal_fx[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], + Cldfb_In_BinImag_fx[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], + max_bands, + temp_cldfbAna, + &Q_cldfb ); + /*fixedToFloat_arrL(hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->cldfb_state, Q_output, hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->p_filter_length - hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch]->no_channels); + fixedToFloat_arrL(Cldfb_In_BinReal_fx[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinReal[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], Q_cldfb, max_bands); + fixedToFloat_arrL(Cldfb_In_BinImag_fx[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinImag[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], Q_cldfb, max_bands);*/ + /*for (int k = 0; k < max_bands; k++) { + printf("\n%f %f ", Cldfb_In_BinReal[pos_idx * BINAURAL_CHANNELS + ch][slot_idx][k], Cldfb_In_BinImag[pos_idx * BINAURAL_CHANNELS + ch][slot_idx][k]); + }*/ + } + } + } + q_final = sub( Q_sig, 5 ); + } + + IF( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + // target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; + target_md_bits = W_extract_l( W_mult0_32_32( isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ), L_FRAME48k ) ); + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( target_md_bits, 48000, &tmp_e ); + target_md_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + /*scaling to max Q*/ + Word16 scale_factor = 31; + move32(); + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ) ); + } + } + scale_factor = sub( scale_factor, 2 ); + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX, scale_factor ); + Scale_sig32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX, scale_factor ); + } + } + q_final = add( q_final, scale_factor ); + Word16 exp_cldfb_re = sub( 31, q_final ); + Word16 exp_cldfb_im = sub( 31, q_final ); + isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal_fx, exp_cldfb_re, Cldfb_In_BinImag_fx, exp_cldfb_im, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); + } + + IF( EQ_16( pcm_out_flag, 0 ) ) + { + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec = useLc3plus ? ISAR_SPLIT_REND_CODEC_LC3PLUS : ISAR_SPLIT_REND_CODEC_LCLD; + + IF( !useLc3plus ) + { + // available_bits = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); + available_bits = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); + available_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits = L_sub( available_bits, pBits->bits_written ); +#else + actual_md_bits = L_sub( pBits->bits_written, actual_md_bits ); + available_bits = L_sub( available_bits, actual_md_bits ); +#endif + pBits->codec_frame_size_ms = codec_frame_size_ms; + move16(); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + pBits->isar_frame_size_ms = isar_frame_size_ms; + move16(); +#endif + isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal_fx, Cldfb_In_BinImag_fx, available_bits, pBits, &q_final ); + } + ELSE + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; + IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, in_fx, Q_in ) ) != IVAS_ERR_OK ) + { + return error; + } +#else + IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, in_flt ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + } + } + ELSE + { + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec = ISAR_SPLIT_REND_CODEC_NONE; + } + + /*zero pad*/ + IF( pcm_out_flag ) + { + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( SplitRendBitRate, FRAMES_PER_SEC, &tmp_e ); + bit_len = L_deposit_l( shr( tmp, sub( 15, tmp_e ) ) ); // Q0 + // bit_len = SplitRendBitRate / FRAMES_PER_SEC; + } + ELSE + { + IF( !useLc3plus ) + { + // bit_len = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); + + bit_len = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); + bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 + } + ELSE + { + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( (Word32) hSplitBin->hLc3plusEnc->config.isar_frame_duration_us, 1000, &tmp_e ); + bit_len = L_deposit_l( shr( tmp, sub( 15, tmp_e ) ) ); // Q0 + // bit_len = hSplitBin->hLc3plusEnc->config.ivas_frame_duration_us / 1000; + // bit_len = SplitRendBitRate * bit_len / 1000; + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( W_extract_l( W_mult0_32_32( SplitRendBitRate, bit_len ) ), 1000, &tmp_e ); + bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 + } + } + + + WHILE( LT_32( pBits->bits_written, bit_len ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0L, 1 ); + } + + pop_wmops(); + + return error; +} + +/*------------------------------------------------------------------------- + * Function lc3plusTimeAlignCldfbPoseCorr() + * + * + *------------------------------------------------------------------------*/ +void lc3plusTimeAlignCldfbPoseCorr( + SPLIT_REND_WRAPPER *hSplitBin, + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 *Q_in ) +{ + Word32 Cldfb_In_BinReal_tmp_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_In_BinImag_tmp_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; + Word16 pose, ch, slot_idx; + Word32 *bufRead_fx, *bufWrite_fx; + + IF( GT_16( hSplitBin->lc3plusDelayBuffers_q, *Q_in ) ) + { + // hSplitBin->lc3plusDelayBuffers_q[0] = *Q_in; + FOR( Word16 i = 0; i < hSplitBin->multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) + { + + Scale_sig32( hSplitBin->lc3plusDelayBuffers_fx[i], 4 * CLDFB_NO_CHANNELS_MAX, sub( *Q_in, hSplitBin->lc3plusDelayBuffers_q ) ); + } + hSplitBin->lc3plusDelayBuffers_q = *Q_in; + } + ELSE + { + FOR( Word16 i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + for ( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( hSplitBin->lc3plusDelayBuffers_q, *Q_in ) ); + Scale_sig32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( hSplitBin->lc3plusDelayBuffers_q, *Q_in ) ); + } + } + *Q_in = hSplitBin->lc3plusDelayBuffers_q; + } + + FOR( pose = 0; pose < hSplitBin->multiBinPoseData.num_poses; ++pose ) + { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ++ch ) + { + bufRead_fx = hSplitBin->lc3plusDelayBuffers_fx[pose * BINAURAL_CHANNELS + ch]; + bufWrite_fx = bufRead_fx; + + /* Save last 2 columns for next frame */ + FOR( slot_idx = 0; slot_idx < 2; ++slot_idx ) + { + Copy32( Cldfb_In_BinReal_fx[pose * BINAURAL_CHANNELS + ch][CLDFB_NO_COL_MAX - 2 + slot_idx], Cldfb_In_BinReal_tmp_fx[pose][ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + Copy32( Cldfb_In_BinImag_fx[pose * BINAURAL_CHANNELS + ch][CLDFB_NO_COL_MAX - 2 + slot_idx], Cldfb_In_BinImag_tmp_fx[pose][ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + } + + /* Delay existing columns by 2 slots */ + /*TODO : shouldnt the delay be 7.5 ms ? 5ms + LC3plus delay */ + FOR( slot_idx = CLDFB_NO_COL_MAX - 2 - 1; slot_idx >= 0; --slot_idx ) + { + Copy32( Cldfb_In_BinReal_fx[pose * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinReal_fx[pose * BINAURAL_CHANNELS + ch][slot_idx + 2], CLDFB_NO_CHANNELS_MAX ); + Copy32( Cldfb_In_BinImag_fx[pose * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinImag_fx[pose * BINAURAL_CHANNELS + ch][slot_idx + 2], CLDFB_NO_CHANNELS_MAX ); + } + + /* Fill 2 first columns from buffer */ + FOR( slot_idx = 0; slot_idx < 2; ++slot_idx ) + { + Copy32( bufRead_fx, Cldfb_In_BinReal_fx[pose * BINAURAL_CHANNELS + ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + bufRead_fx += CLDFB_NO_CHANNELS_MAX; + Copy32( bufRead_fx, Cldfb_In_BinImag_fx[pose * BINAURAL_CHANNELS + ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + bufRead_fx += CLDFB_NO_CHANNELS_MAX; + } + + /* Copy last 2 columns to buffer */ + FOR( slot_idx = 0; slot_idx < 2; ++slot_idx ) + { + Copy32( Cldfb_In_BinReal_tmp_fx[pose][ch][slot_idx], bufWrite_fx, CLDFB_NO_CHANNELS_MAX ); + bufWrite_fx += CLDFB_NO_CHANNELS_MAX; + Copy32( Cldfb_In_BinImag_tmp_fx[pose][ch][slot_idx], bufWrite_fx, CLDFB_NO_CHANNELS_MAX ); + bufWrite_fx += CLDFB_NO_CHANNELS_MAX; + } + } + } + + return; +} + +#endif diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c new file mode 100644 index 000000000..b290ca12a --- /dev/null +++ b/lib_isar/isar_splitRenderer_utils.c @@ -0,0 +1,1741 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "ivas_prot.h" +#include "prot.h" +#include "cnst.h" +#include "isar_cnst.h" +#include "ivas_rom_rend.h" +#include "ivas_rom_com.h" +#include "isar_rom_post_rend.h" +#include "ivas_rom_binauralRenderer.h" +#include "lib_isar_post_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" +#include "basop_settings.h" +#include "prot_fx2.h" + +#include "basop_util.h" + + +/*------------------------------------------------------------------------- + * Function ivas_mat_mult_2by2_complex() + * + * + *------------------------------------------------------------------------*/ +void ivas_cmult_fix( Word32 in1_re_fx, Word16 exp_re1, Word32 in1_im_fx, Word16 exp_im1, Word32 in2_re_fx, Word16 exp_re2, Word32 in2_im_fx, Word16 exp_im2, Word32 *out1_re_fx, Word32 *out1_im_fx, Word16 *exp_out1_re, Word16 *exp_out1_im ) +{ + Word16 shift_1 = W_norm( W_mult_32_32( in1_re_fx, in2_re_fx ) ); + Word16 shift_2 = W_norm( W_mult_32_32( in1_im_fx, in2_im_fx ) ); + Word32 tmp1 = W_extract_h( W_shl( W_mult_32_32( in1_re_fx, in2_re_fx ), shift_1 ) ); + Word32 tmp2 = W_extract_h( W_shl( W_mult_32_32( in1_im_fx, in2_im_fx ), shift_2 ) ); + Word16 exp_tmp1 = 0; + move16(); + *out1_re_fx = BASOP_Util_Add_Mant32Exp( tmp1, exp_re1 + exp_re2 - shift_1, L_negate( tmp2 ), exp_im1 + exp_im2 - shift_2, &exp_tmp1 ); + *exp_out1_re = exp_tmp1; + Word16 shift_3 = W_norm( W_mult_32_32( in1_re_fx, in2_im_fx ) ); + Word16 shift_4 = W_norm( W_mult_32_32( in2_re_fx, in1_im_fx ) ); + Word32 tmp3 = W_extract_h( W_shl( W_mult_32_32( in1_re_fx, in2_im_fx ), shift_3 ) ); + Word32 tmp4 = W_extract_h( W_shl( W_mult_32_32( in2_re_fx, in1_im_fx ), shift_4 ) ); + Word16 exp_tmp2 = 0; + move16(); + *out1_im_fx = BASOP_Util_Add_Mant32Exp( tmp3, exp_re1 + exp_im2 - shift_3, tmp4, exp_re2 + exp_im1 - shift_4, &exp_tmp2 ); + *exp_out1_im = exp_tmp2; + move16(); +} + +void ivas_calculate_abs_fx( Word32 re_fx, Word16 exp_re, Word32 im_fx, Word16 exp_im, Word32 *out_fx, Word16 *exp_out ) +{ + Word16 shift_1 = W_norm( W_mult_32_32( re_fx, re_fx ) ); + Word16 shift_2 = W_norm( W_mult_32_32( im_fx, im_fx ) ); + Word32 tmp1 = W_extract_h( W_shl( W_mult_32_32( re_fx, re_fx ), shift_1 ) ); + Word32 tmp2 = W_extract_h( W_shl( W_mult_32_32( im_fx, im_fx ), shift_2 ) ); + Word16 exp_tmp1 = 0; + Word32 tmp3 = BASOP_Util_Add_Mant32Exp( tmp1, exp_re + exp_re - shift_1, tmp2, exp_im + exp_im - shift_2, &exp_tmp1 ); + *out_fx = Sqrt32( tmp3, &exp_tmp1 ); + *exp_out = exp_tmp1; +} + +void ivas_calculate_rabs_fx( Word32 re_fx, Word16 exp_re, Word32 *out_fx, Word16 *exp_out ) +{ + Word16 shift_1 = W_norm( W_mult_32_32( re_fx, re_fx ) ); + Word32 tmp1 = W_extract_h( W_shl( W_mult_32_32( re_fx, re_fx ), shift_1 ) ); + Word16 exp_tmp1 = exp_re + exp_re - shift_1; + Word32 tmp2 = Sqrt32( tmp1, &exp_tmp1 ); + *out_fx = tmp2; + *exp_out = exp_tmp1; +} + +void isar_mat_mult_2by2_complex_fx( + Word32 in_re1_fx[2][2], + Word16 exp_re1, + Word32 in_im1_fx[2][2], + Word16 exp_im1, + Word32 in_re2_fx[2][2], + Word16 exp_re2, + Word32 in_im2_fx[2][2], + Word16 exp_im2, + Word32 out_re2_fx[2][2], + Word16 *final_exp_re_1, + Word32 out_im2_fx[2][2], + Word16 *final_exp_im_1 ) +{ + Word16 i, j; + Word32 tmp_re_fx, tmp_im_fx; + + Word16 exp_tmp1 = 0, exp_tmp2 = 0, exp_tmp3 = 0, exp_tmp4 = 0; + Word16 final_exp_re = 0, final_exp_im = 0; + Word16 BuffExp_re[2][2]; + Word16 BuffExp_im[2][2]; + + FOR( i = 0; i < 2; i++ ) + { + FOR( j = 0; j < 2; j++ ) + { + ivas_cmult_fix( in_re1_fx[i][0], exp_re1, in_im1_fx[i][0], exp_im1, in_re2_fx[0][j], exp_re2, in_im2_fx[0][j], exp_im2, &tmp_re_fx, &tmp_im_fx, &exp_tmp1, &exp_tmp2 ); + + out_re2_fx[i][j] = tmp_re_fx; + move32(); + out_im2_fx[i][j] = tmp_im_fx; + move32(); + + ivas_cmult_fix( in_re1_fx[i][1], exp_re1, in_im1_fx[i][1], exp_im1, in_re2_fx[1][j], exp_re2, in_im2_fx[1][j], exp_im2, &tmp_re_fx, &tmp_im_fx, &exp_tmp3, &exp_tmp4 ); + + out_re2_fx[i][j] = BASOP_Util_Add_Mant32Exp( out_re2_fx[i][j], exp_tmp1, tmp_re_fx, exp_tmp3, &final_exp_re ); + move32(); + out_im2_fx[i][j] = BASOP_Util_Add_Mant32Exp( out_im2_fx[i][j], exp_tmp2, tmp_im_fx, exp_tmp4, &final_exp_im ); + move32(); + + BuffExp_re[i][j] = final_exp_re; + move16(); + BuffExp_im[i][j] = final_exp_im; + move16(); + } + } + + Word16 max_exp_re = 0; + Word16 max_exp_im = 0; + move16(); + move16(); + FOR( i = 0; i < 2; i++ ) + { + FOR( j = 0; j < 2; j++ ) + { + max_exp_re = s_max( max_exp_re, BuffExp_re[i][j] ); + max_exp_im = s_max( max_exp_im, BuffExp_im[i][j] ); + } + } + + FOR( i = 0; i < 2; i++ ) + { + FOR( j = 0; j < 2; j++ ) + { + out_re2_fx[i][j] = L_shr( out_re2_fx[i][j], max_exp_re - BuffExp_re[i][j] ); + move32(); + out_im2_fx[i][j] = L_shr( out_im2_fx[i][j], max_exp_im - BuffExp_im[i][j] ); + move32(); + } + } + *final_exp_re_1 = max_exp_re; + move16(); + *final_exp_im_1 = max_exp_im; + move16(); + + return; +} + +void ivas_mat_mult_2by2_complex( + float in_re1[2][2], + float in_im1[2][2], + float in_re2[2][2], + float in_im2[2][2], + float out_re2[2][2], + float out_im2[2][2] ) +{ + int16_t i, j; + float tmp_re, tmp_im; + + for ( i = 0; i < 2; i++ ) + { + for ( j = 0; j < 2; j++ ) + { + IVAS_CMULT_FLOAT( in_re1[i][0], in_im1[i][0], in_re2[0][j], in_im2[0][j], tmp_re, tmp_im ); + out_re2[i][j] = tmp_re; + out_im2[i][j] = tmp_im; + + IVAS_CMULT_FLOAT( in_re1[i][1], in_im1[i][1], in_re2[1][j], in_im2[1][j], tmp_re, tmp_im ); + out_re2[i][j] += tmp_re; + out_im2[i][j] += tmp_im; + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function ISAR_SPLIT_REND_BITStream_init() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_SPLIT_REND_BITStream_init( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 buf_len_bytes, + UWord8 *pbuf ) +{ + pBits->bits_buf = pbuf; + pBits->buf_len = buf_len_bytes; + move32(); + pBits->bits_read = 0; + move32(); + pBits->bits_written = 0; + move32(); + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_huffman_dec_init_min_max_len() + * + * + *------------------------------------------------------------------------*/ + +void isar_split_rend_huffman_dec_init_min_max_len( + isar_split_rend_huffman_cfg_t *p_huff_cfg ) +{ + Word16 i, code_len; + const Word32 *codebook; + + codebook = p_huff_cfg->codebook; + + p_huff_cfg->min_len = p_huff_cfg->sym_len; + move16(); + p_huff_cfg->max_len = 0; + move16(); + + FOR( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + code_len = extract_l( codebook[1] ); + IF( GT_16( p_huff_cfg->min_len, code_len ) ) + { + p_huff_cfg->min_len = code_len; + move16(); + } + IF( LT_16( p_huff_cfg->max_len, code_len ) ) + { + p_huff_cfg->max_len = code_len; + move16(); + } + codebook = codebook + 3; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function is_idx_present() + * + * + *------------------------------------------------------------------------*/ + +static Word16 is_idx_present( + Word16 *idx_list, + const Word16 idx, + const Word16 len ) +{ + Word16 i; + + FOR( i = 0; i < len; i++ ) + { + IF( EQ_16( idx_list[i], idx ) ) + { + return 1; + } + } + + return 0; +} + + +/*------------------------------------------------------------------------- + * Function ivas_split_huff_get_idx_trav_list() + * + * + *------------------------------------------------------------------------*/ + +static void ivas_split_huff_get_idx_trav_list( + Word16 *idx_list, + isar_split_rend_huffman_cfg_t *p_huff_cfg ) +{ + Word16 i, j, min_idx; + Word32 min_bits; + const Word32 *codebook; + + FOR( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + idx_list[i] = -1; + move16(); + } + + FOR( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + codebook = p_huff_cfg->codebook; + min_bits = p_huff_cfg->max_len; + move16(); + min_idx = -1; + move16(); + FOR( j = 0; j < p_huff_cfg->sym_len; j++ ) + { + test(); + IF( GE_32( min_bits, codebook[1] ) && EQ_16( is_idx_present( idx_list, j, i + 1 ), 0 ) ) + { + min_bits = codebook[1]; + move16(); + min_idx = j; + move16(); + } + codebook += 3; + } + idx_list[i] = min_idx; + move16(); + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_init_huff_cfg() + * + * + *------------------------------------------------------------------------*/ + +void isar_split_rend_init_huff_cfg( + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ) +{ + pHuff_cfg->pred[0].codebook = &ivas_split_rend_huff_pred31_consts[0][0]; + pHuff_cfg->pred[0].sym_len = ISAR_SPLIT_REND_PRED_31QUANT_PNTS; + move16(); + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[0] ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[0], &pHuff_cfg->pred[0] ); + pHuff_cfg->pred_base2_code_len[0] = ISAR_SPLIT_REND_PRED_31QUANT_PNTS_LOG2_CEIL; + move16(); + + pHuff_cfg->pred[1].codebook = &ivas_split_rend_huff_pred63_consts[0][0]; + pHuff_cfg->pred[1].sym_len = ISAR_SPLIT_REND_PRED_63QUANT_PNTS; + move16(); + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[1] ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[1], &pHuff_cfg->pred[1] ); + pHuff_cfg->pred_base2_code_len[1] = ISAR_SPLIT_REND_PRED_63QUANT_PNTS_LOG2_CEIL; + move16(); + + + pHuff_cfg->pred_roll.codebook = &ivas_split_rend_huff_roll_pred_consts[0][0]; + pHuff_cfg->pred_roll.sym_len = ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS; + move16(); + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred_roll ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_roll_idx_trav, &pHuff_cfg->pred_roll ); + pHuff_cfg->pred_roll_base2_code_len = ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS_LOG2_CEIL; + move16(); + + pHuff_cfg->gd.codebook = &ivas_split_rend_huff_d_consts[0][0]; + pHuff_cfg->gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS; + move16(); + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->gd ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->gd_idx_trav, &pHuff_cfg->gd ); + pHuff_cfg->gd_base2_code_len = ISAR_SPLIT_REND_D_QUANT_PNTS_LOG2_CEIL; + move16(); + + pHuff_cfg->p_gd.codebook = &ivas_split_rend_huff_p_d_consts[0][0]; + pHuff_cfg->p_gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS; + move16(); + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_idx_trav, &pHuff_cfg->p_gd ); + pHuff_cfg->p_gd_base2_code_len = ISAR_SPLIT_REND_D_QUANT_PNTS_LOG2_CEIL; + move16(); + + pHuff_cfg->p_gd_diff.codebook = &ivas_split_rend_huff_p_d_diff_consts[0][0]; + pHuff_cfg->p_gd_diff.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS; + move16(); + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd_diff ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_diff_idx_trav, &pHuff_cfg->p_gd_diff ); + pHuff_cfg->p_gd_diff_base2_code_len = ISAR_SPLIT_REND_D_QUANT_PNTS_LOG2_CEIL; + move16(); + + return; +} + + +/*------------------------------------------------------------------------- + * Function set_fix_rotation_mat() + * + * + *------------------------------------------------------------------------*/ + +void set_fix_rotation_mat_fx( + Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + Word32 cos_yaw, sin_yaw; + Word16 pos_idx; + Word16 ind = 0; + + // pMultiBinPoseData->relative_head_poses can take only take -30, -22.5, -15, 0, 15, 22.5 and 30 degrees. + // cos(180 - theta) = cos(theta). + // Need only 4 values in LUT + + FOR( pos_idx = 0; pos_idx < sub( pMultiBinPoseData->num_poses, 1 ); pos_idx++ ) + { + ind = extract_l( L_shr( L_abs( pMultiBinPoseData->relative_head_poses_fx[pos_idx + 1][0] ), Q22 ) ); + + ind = shr( ind, 3 ); /* Values: 0, 1, 2 and 3 */ + cos_yaw = ivas_split_rend_fix_pos_rot_mat_cos_fx[ind]; /* Q31 */ + sin_yaw = 0; + + fix_pos_rot_mat[pos_idx][0][0] = cos_yaw; /* Q31 */ + fix_pos_rot_mat[pos_idx][1][1] = cos_yaw; /* Q31 */ + fix_pos_rot_mat[pos_idx][0][1] = sin_yaw; /* Q31 */ + fix_pos_rot_mat[pos_idx][1][0] = L_negate( sin_yaw ); /* Q31 */ + } + + return; +} +void set_fix_rotation_mat( + float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + float yaw_a, cos_yaw, sin_yaw; + int16_t pos_idx; + yaw_a = 0.0f; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + yaw_a = pMultiBinPoseData->relative_head_poses[pos_idx + 1][0]; + cos_yaw = cosf( EVS_PI * yaw_a / 180.0f ); + sin_yaw = sinf( EVS_PI * yaw_a / 180.0f ); + sin_yaw = 0.0f; + fix_pos_rot_mat[pos_idx][0][0] = cos_yaw; + fix_pos_rot_mat[pos_idx][1][1] = cos_yaw; + fix_pos_rot_mat[pos_idx][0][1] = sin_yaw; + fix_pos_rot_mat[pos_idx][1][0] = -1.0f * sin_yaw; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function set_pose_types() + * + * + *------------------------------------------------------------------------*/ + +void set_pose_types_fx( + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + Word16 pos_idx; + + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + IF( GT_32( L_abs( pMultiBinPoseData->relative_head_poses_fx[pos_idx + 1][0] ), EPSILON_FX ) ) + { + pose_type[pos_idx] = ANY_YAW; + move32(); + } + ELSE IF( GT_32( L_abs( pMultiBinPoseData->relative_head_poses_fx[pos_idx + 1][2] ), EPSILON_FX ) ) + { + pose_type[pos_idx] = ANY_ROLL; + move32(); + } + ELSE + { + pose_type[pos_idx] = PITCH_ONLY; + move32(); + } + } + + return; +} +void set_pose_types( + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + int16_t pos_idx; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] ) > EPSILON ) + { + pose_type[pos_idx] = ANY_YAW; + } + else if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][2] ) > EPSILON ) + { + pose_type[pos_idx] = ANY_ROLL; + } + else + { + pose_type[pos_idx] = PITCH_ONLY; + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function wrap_a() + * + * + *------------------------------------------------------------------------*/ + +Word16 wrap_a( + Word16 val, + const Word16 min_val, + const Word16 max_val ) +{ + IF( LT_16( val, min_val ) ) + { + val = add( add( sub( max_val, min_val ), val ), 1 ); + } + + IF( GT_16( val, max_val ) ) + { + val = sub( sub( add( min_val, val ), max_val ), 1 ); + } + + return val; +} + + +/*------------------------------------------------------------------------- + * Function isar_SplitRenderer_getdiagdiff() + * + * + *------------------------------------------------------------------------*/ + +void isar_SplitRenderer_getdiagdiff( + Word16 in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + Word16 out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + const Word16 sign, + const Word16 min_val, + const Word16 max_val ) +{ + out_idx[0][0] = in_idx[0][0]; + move16(); + out_idx[0][1] = in_idx[0][1]; + move16(); + // DEPR_i_mult used instead of i_mult becuase it is not available + out_idx[1][1] = add( in_idx[1][1], DEPR_i_mult( sign, out_idx[0][0] ) ); + move16(); + out_idx[1][1] = wrap_a( out_idx[1][1], min_val, max_val ); + move16(); + out_idx[1][0] = add( in_idx[1][0], DEPR_i_mult( sign, out_idx[0][1] ) ); + move16(); + out_idx[1][0] = wrap_a( out_idx[1][0], min_val, max_val ); + move16(); + + return; +} + + +/*------------------------------------------------------------------------- + * Function ISAR_SPLIT_REND_BITStream_read_int32() + * + * + *------------------------------------------------------------------------*/ +Word32 ISAR_SPLIT_REND_BITStream_read_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 bits ) +{ + Word32 val, k, bit_val; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + assert( ( pBits->bits_written - pBits->bits_read ) >= bits ); + assert( bits <= 32 ); +#endif + + /* write bit by bit */ + val = 0; + move32(); + FOR( k = L_sub( bits, 1 ); k >= 0; k-- ) + { + bit_val = NE_32( L_and( pBits->bits_buf[L_shr( pBits->bits_read, 3 )], ( L_shl( 1, (Word16) ( L_and( pBits->bits_read, 7 ) ) ) ) ), 0 ); + val = L_or( val, L_shl( bit_val, (Word16) k ) ); + pBits->bits_read = L_add( pBits->bits_read, 1 ); + } + + return val; +} + + +/*------------------------------------------------------------------------- + * Function ISAR_SPLIT_REND_BITStream_write_int32() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_SPLIT_REND_BITStream_write_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word32 val, + const Word32 bits ) +{ + Word32 mask, k; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + /*protection check*/ + if ( ( pBits->buf_len << 3 ) < ( pBits->bits_written + bits ) ) + { + assert( 0 ); + } +#endif + + mask = L_shl( 1, extract_l( L_sub( bits, 1 ) ) ); + /* write bit by bit */ + FOR( k = 0; k < bits; k++ ) + { + IF( L_and( val, mask ) ) + { + pBits->bits_buf[L_shr( pBits->bits_written, 3 )] = (UWord8) L_or( pBits->bits_buf[L_shr( pBits->bits_written, 3 )], L_shl( 1, extract_l( L_and( pBits->bits_written, 7 ) ) ) ); + } + ELSE + { + pBits->bits_buf[L_shr( pBits->bits_written, 3 )] = (UWord8) L_and( pBits->bits_buf[L_shr( pBits->bits_written, 3 )], ~L_shl( 1, extract_l( L_and( pBits->bits_written, 7 ) ) ) ); + } + pBits->bits_written++; + mask = L_shr( mask, 1 ); + } + + return; +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +/*------------------------------------------------------------------------- + * ivas_mat_mult_2by2_complex() + * + * + *------------------------------------------------------------------------*/ + +void isar_log_cldfb2wav_data( + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + HANDLE_CLDFB_FILTER_BANK *cldfbSyn, + const int16_t num_chs, + const int16_t num_freq_bands, + const int32_t output_Fs, + const int16_t num_slots, + const int16_t start_slot_idx, + const char *filename ) +{ + float *RealBuffer[CLDFB_NO_COL_MAX]; + float *ImagBuffer[CLDFB_NO_COL_MAX]; + float pcm_out[BINAURAL_CHANNELS][L_FRAME48k]; + float *pPcm[BINAURAL_CHANNELS]; + float Cldfb_local_Real[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_local_Imag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t sf, ch; + + assert( num_chs <= BINAURAL_CHANNELS ); + for ( ch = 0; ch < num_chs; ch++ ) + { + for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ ) + { + mvr2r( Cldfb_In_Real[ch][sf], Cldfb_local_Real[ch][sf], num_freq_bands ); + mvr2r( Cldfb_In_Imag[ch][sf], Cldfb_local_Imag[ch][sf], num_freq_bands ); + RealBuffer[sf - start_slot_idx] = Cldfb_local_Real[ch][sf]; + ImagBuffer[sf - start_slot_idx] = Cldfb_local_Imag[ch][sf]; + } + cldfbSynthesis( RealBuffer, ImagBuffer, &( pcm_out[ch][0] ), num_freq_bands * num_slots, cldfbSyn[ch] ); + pPcm[ch] = pcm_out[ch]; + } + dbgwrite_wav( pPcm, num_freq_bands * num_slots, filename, output_Fs, num_chs ); + + return; +} +#endif + + +/*------------------------------------------------------------------------- + * Function isar_get_split_rend_md_target_brate() + * + * + *------------------------------------------------------------------------*/ + +Word32 isar_get_split_rend_md_target_brate( + const Word32 SplitRendBitRate, + const Word16 pcm_out_flag ) +{ + Word32 md_bitrate; + + IF( EQ_16( pcm_out_flag, 1 ) ) + { + md_bitrate = SplitRendBitRate; + move32(); + } + ELSE + { + SWITCH( SplitRendBitRate ) + { + case SPLIT_REND_768k: + { + md_bitrate = 256000; + move32(); + BREAK; + } + case SPLIT_REND_512k: + { + md_bitrate = 128000; + move32(); + BREAK; + } + case SPLIT_REND_384k: + { + md_bitrate = 128000; + move32(); + BREAK; + } + default: + { + return -1; + } + } + } + + return md_bitrate; +} + + +/*------------------------------------------------------------------------- + * Function isar_get_lcld_bitrate() + * + * + *------------------------------------------------------------------------*/ + +Word32 isar_get_lcld_bitrate( + const Word32 SplitRendBitRate, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ) +{ + IF( EQ_32( poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + SWITCH( SplitRendBitRate ) + { + case SPLIT_REND_768k: + { + return IVAS_512k; + } + case SPLIT_REND_512k: + { + return IVAS_384k; + } + case SPLIT_REND_384k: + { + return IVAS_256k; + } + default: + { + assert( 0 ); + } + } + } + ELSE + { + return SplitRendBitRate; + } + + return -1; +} + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * Function isar_get_lc3plus_bitrate() + * + * + *------------------------------------------------------------------------*/ + +Word32 isar_get_lc3plus_bitrate( + const Word32 SplitRendBitRate, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const Word16 split_prerender_frame_size_ms ) +{ + IF( EQ_32( poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + Word32 inBandMdBps = (Word32) ( 8 * 1000 / split_prerender_frame_size_ms ); + return L_sub( isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ), inBandMdBps ); + } + + IF( EQ_32( poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + return SplitRendBitRate; + } + + /* Should not be reached */ + assert( 0 ); + return -1; +} + + +/*------------------------------------------------------------------------- + * Function isar_get_lc3plus_bitrate_id() + * + * + *------------------------------------------------------------------------*/ + +Word8 isar_get_lc3plus_bitrate_id( + const Word32 SplitRendBitRate ) +{ + SWITCH( SplitRendBitRate ) + { + case SPLIT_REND_768k: + { + return 4; + } + case SPLIT_REND_512k: + { + return 3; + } + case SPLIT_REND_384k: + { + return 2; + } + case SPLIT_REND_320k: + { + return 1; + } + case SPLIT_REND_256k: + { + return 0; + } + default: + { + BREAK; + } + } + + return -1; +} + + +/*------------------------------------------------------------------------- + * Function ivas_mat_mult_2by2_complex() + * + * + *------------------------------------------------------------------------*/ + +Word32 isar_get_lc3plus_size_from_id( + const Word8 SplitRendBitRateId, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const Word16 split_prerender_frame_size_ms ) +{ + Word32 bitrate; + + SWITCH( SplitRendBitRateId ) + { + case 4: + { + bitrate = SPLIT_REND_768k; + move32(); + BREAK; + } + case 3: + { + bitrate = SPLIT_REND_512k; + move32(); + BREAK; + } + case 2: + { + bitrate = SPLIT_REND_384k; + move32(); + BREAK; + } + case 1: + { + bitrate = SPLIT_REND_320k; + move32(); + BREAK; + } + case 0: + { + bitrate = SPLIT_REND_256k; + move32(); + BREAK; + } + default: + { + bitrate = -1; + move32(); + BREAK; + } + } + + bitrate = isar_get_lc3plus_bitrate( bitrate, poseCorrectionMode, split_prerender_frame_size_ms ); + + /* Return size in bytes */ + return (Word32) ( bitrate * split_prerender_frame_size_ms / 1000 / 8 ); +} +#endif + +/*------------------------------------------------------------------------- + * Function isar_split_rend_validate_config() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_split_rend_validate_config( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const Word16 is_pcm_out ) +{ + /* Valid DOF range is 0-3 */ + test(); + IF( LT_16( pSplitRendConfig->dof, 0 ) || GT_16( pSplitRendConfig->dof, 3 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Valid DOF range is 0-3" ); + } + + /* Only CLDFB pose correction supports HQ mode */ + test(); + IF( NE_32( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) && NE_16( pSplitRendConfig->hq_mode, 0 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Only CLDFB pose correction supports HQ mode" ); + } + + /* Split rendering with no pose correction - 0 DOF and pose correction NONE must only ever be set together */ + test(); + test(); + test(); + IF( ( EQ_32( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) && NE_16( pSplitRendConfig->dof, 0 ) ) || + ( NE_32( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) && EQ_16( pSplitRendConfig->dof, 0 ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "0 DOF and pose correction NONE must only ever be set together" ); + } + + IF( NE_16( pSplitRendConfig->codec_frame_size_ms, 0 ) ) /* 0 means "default for current codec", will be set to actual value at a later stage */ + { + test(); + test(); + test(); + IF( EQ_32( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LCLD ) && NE_16( pSplitRendConfig->codec_frame_size_ms, 5 ) && NE_16( pSplitRendConfig->codec_frame_size_ms, 10 ) && NE_16( pSplitRendConfig->codec_frame_size_ms, 20 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LCLD codec" ); + } + + test(); + test(); + IF( EQ_32( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) && NE_16( pSplitRendConfig->codec_frame_size_ms, 5 ) && NE_16( pSplitRendConfig->codec_frame_size_ms, 10 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LC3plus codec" ); + } + } + + /* Validate bitrate */ + IF( EQ_16( is_pcm_out, 0 ) ) + { + SWITCH( pSplitRendConfig->splitRendBitRate ) + { + case SPLIT_REND_256k: + IF( NE_16( pSplitRendConfig->dof, 0 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" ); + } + BREAK; + case SPLIT_REND_320k: + /* Only valid with 0 DOF */ + IF( NE_16( pSplitRendConfig->dof, 0 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" ); + } + BREAK; + case SPLIT_REND_384k: + case SPLIT_REND_512k: +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + case SPLIT_REND_768k: +#endif + /* Always valid */ + BREAK; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + case SPLIT_REND_768k: + test(); + IF( EQ_16( pSplitRendConfig->dof, 0 ) && EQ_32( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrate is too high for LC3plus with 0 DOF" ); + } + BREAK; +#endif + default: + return IVAS_ERR_LC3PLUS_INVALID_BITRATE; + } + } + ELSE + { + IF( EQ_16( pSplitRendConfig->dof, 1 ) ){ +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + IF( LT_32( pSplitRendConfig->splitRendBitRate, 34000 ) ){ + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 34 kbps" ); + } +#else + IF( LT_32( pSplitRendConfig->splitRendBitRate, 50000 ) ){ + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 50 kbps" ); + } +#endif +} +ELSE IF( EQ_16( pSplitRendConfig->dof, 2 ) ){ +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + IF( LT_32( pSplitRendConfig->splitRendBitRate, 50000 ) ){ + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 50 kbps" ); +} +#else + IF( LT_32( pSplitRendConfig->splitRendBitRate, 66000 ) ){ + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 66 kbps" ); +} +#endif +} +ELSE IF( EQ_16( pSplitRendConfig->dof, 3 ) ) +{ +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + IF( LT_32( pSplitRendConfig->splitRendBitRate, 82000 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); + } +#else + IF( LT_32( pSplitRendConfig->splitRendBitRate, 128000 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); + } +#endif +} +} + +return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_get_quant_params() + * + * + *------------------------------------------------------------------------*/ + +void isar_split_rend_get_quant_params_fx( + const Word16 num_md_bands, + Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word32 pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word32 pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + const Word16 ro_flag, +#endif + Word16 *num_quant_strats +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + , + Word16 *num_complex_bands +#endif +) +{ + Word16 q; + + *num_quant_strats = ISAR_SPLIT_REND_NUM_QUANT_STRATS; + move16(); +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + *num_complex_bands = COMPLEX_MD_BAND_THRESH_LOW; + move16(); + assert( *num_complex_bands <= num_md_bands ); +#endif + + pred_quant_pnts_yaw[0] = ISAR_SPLIT_REND_PRED_63QUANT_PNTS; + move16(); + pred_quantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_Q_STEP_FX_Q31; + move32(); + pred_1byquantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_1BYQ_STEP_FX_Q26; + move32(); + FOR( q = 1; q < *num_quant_strats; q++ ) + { + pred_quant_pnts_yaw[q] = ISAR_SPLIT_REND_PRED_31QUANT_PNTS; + move16(); + pred_quantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_Q_STEP_FX_Q31; + move32(); + pred_1byquantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_1BYQ_STEP_FX_Q26; + move32(); + } + + FOR( q = 0; q < *num_quant_strats; q++ ) + { + pred_real_bands_yaw[q] = num_md_bands; + move16(); + pred_real_bands_roll[q] = num_md_bands; + move16(); + } + +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + pred_imag_bands_yaw[0] = num_md_bands; + move16(); + pred_imag_bands_roll[0] = num_md_bands; + move16(); + pred_imag_bands_yaw[1] = num_md_bands; + move16(); + pred_imag_bands_roll[1] = num_md_bands; + move16(); + + FOR( q = 2; q < *num_quant_strats; q++ ) + { + pred_imag_bands_yaw[q] = LT_16( q, sub( *num_quant_strats, 1 ) ) ? num_md_bands : *num_complex_bands; + move16(); + pred_imag_bands_roll[q] = *num_complex_bands; + move16(); + } +#else + IF( ro_flag ) + { + FOR( q = 0; q < *num_quant_strats; q++ ) + { + pred_imag_bands_yaw[q] = SPLIT_REND_RO_MD_BAND_THRESH; + move16(); + } + } + ELSE + { + FOR( q = 0; q < *num_quant_strats - 2; q++ ) + { + pred_imag_bands_yaw[q] = num_md_bands; + move16(); + } + pred_imag_bands_yaw[( *num_quant_strats - 2 )] = COMPLEX_MD_BAND_THRESH_HIGH; + move16(); + pred_imag_bands_yaw[( *num_quant_strats - 1 )] = COMPLEX_MD_BAND_THRESH_LOW; + move16(); + } + + FOR( q = 0; q < *num_quant_strats; q++ ) + { + pred_imag_bands_roll[q] = SPLIT_REND_RO_MD_BAND_THRESH; + move16(); + } +#endif + + FOR( q = 0; q < *num_quant_strats; q++ ) + { + d_bands_yaw[q] = 0; + move16(); + bands_pitch[q] = num_md_bands; + move16(); + } + + return; +} + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetRot_axisNumBits() + * + * + *------------------------------------------------------------------------*/ + +Word16 isar_renderSplitGetRot_axisNumBits( + const Word16 dof ) +{ + Word16 num_bits; + IF( dof < 3 ) + { + num_bits = 2; + } + ELSE + { + num_bits = 0; + } + return num_bits; +} + +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetRot_axisFromCode() + * + * + *------------------------------------------------------------------------*/ + +ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( + const Word16 dof, + const Word16 code ) +{ + ISAR_SPLIT_REND_ROT_AXIS rot_axis; + + IF( dof == 1 ) + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code; + } + else if ( dof == 2 ) + { + IF( code == 0 ) + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code; + } + ELSE + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) ( code - 1 ) + YAW_PITCH; + } + } + ELSE + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) DEFAULT_AXIS; + } + + return rot_axis; +} + +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetCodeFromRot_axis() + * + * + *------------------------------------------------------------------------*/ + +Word16 isar_renderSplitGetCodeFromRot_axis( + const Word16 dof, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, + Word16 *num_bits ) +{ + Word16 code = 0; + IF( dof == 1 ) + { + code = (Word16) rot_axis; + } + else if ( dof == 2 ) + { + IF( rot_axis == DEFAULT_AXIS ) + { + code = (Word16) rot_axis; + } + ELSE + { + code = (Word16) ( rot_axis - YAW_PITCH ) + 1; + } + } + ELSE + { + code = (Word16) DEFAULT_AXIS; + } + *num_bits = isar_renderSplitGetRot_axisNumBits( dof ); + + return code; +} +#endif + +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetMultiBinPoseData() + * + * + *------------------------------------------------------------------------*/ + +void isar_renderSplitGetMultiBinPoseData_fx( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis ) +{ + Word16 pos_idx, num_yaw_poses, num_pitch_poses, num_roll_poses; + const Word32 *relative_yaw_angles; + const Word32 *relative_pitch_angles; + const Word32 *relative_roll_angles; + + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] = 0; + move32(); + pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] = 0; + move32(); + pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] = 0; + move32(); + } + + /* 0 DOF defaults */ + num_yaw_poses = 0; + move16(); + num_pitch_poses = 0; + move16(); + num_roll_poses = 0; + move16(); + + /* defaults for all DOF except 3DOF HQ */ + relative_yaw_angles = ivas_split_rend_relative_yaw_pos_angles_hq_fx; + relative_pitch_angles = ivas_split_rend_relative_pitch_pos_angles_hq_fx; + relative_roll_angles = ivas_split_rend_relative_roll_pos_angles_hq_fx; + + IF( EQ_16( pSplit_rend_config->dof, 1 ) ) + { + SWITCH( rot_axis ) + { + case DEFAULT_AXIS: + case YAW: + { + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + move16(); + BREAK; + } + case PITCH: + { + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + move16(); + BREAK; + } + case ROLL: + { + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + move16(); + BREAK; + } + default: + { + assert( 0 && "unsupported rotation axis value" ); + } + } + } + ELSE IF( EQ_16( pSplit_rend_config->dof, 2 ) ) + { + SWITCH( rot_axis ) + { + case DEFAULT_AXIS: +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + case YAW: + case PITCH: +#endif + case YAW_PITCH: + { + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + move16(); + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + move16(); + BREAK; + } +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + case ROLL: +#endif + case YAW_ROLL: + { + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + move16(); + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + move16(); + BREAK; + } + case PITCH_ROLL: + { + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + move16(); + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + move16(); + BREAK; + } + default: + { + assert( 0 && "unsupported rotation axis value" ); + } + } + } + ELSE IF( EQ_16( pSplit_rend_config->dof, 3 ) ) + { + IF( EQ_16( pSplit_rend_config->hq_mode, 1 ) ) + { + relative_yaw_angles = ivas_split_rend_relative_yaw_pos_angles_hq_fx; + relative_pitch_angles = ivas_split_rend_relative_pitch_pos_angles_hq_fx; + relative_roll_angles = ivas_split_rend_relative_roll_pos_angles_hq_fx; + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + move16(); + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + move16(); + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + move16(); + } + ELSE + { + relative_yaw_angles = ivas_split_rend_relative_yaw_pos_angles_fx; + relative_pitch_angles = ivas_split_rend_relative_pitch_pos_angles_fx; + relative_roll_angles = ivas_split_rend_relative_roll_pos_angles_fx; + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + move16(); + num_pitch_poses = 1; + move16(); + num_roll_poses = 1; + move16(); + } + } + + pMultiBinPoseData->num_poses = add( add( num_yaw_poses, num_pitch_poses ), add( num_roll_poses, 1 ) ); + assert( LE_16( pMultiBinPoseData->num_poses, MAX_HEAD_ROT_POSES ) ); + + FOR( pos_idx = 0; pos_idx < num_yaw_poses; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses_fx[pos_idx + 1][0] = relative_yaw_angles[pos_idx]; + move32(); + } + + FOR( pos_idx = 0; pos_idx < num_pitch_poses; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses_fx[pos_idx + num_yaw_poses + 1][1] = relative_pitch_angles[pos_idx]; + move32(); + } + + FOR( pos_idx = 0; pos_idx < num_roll_poses; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses_fx[pos_idx + num_yaw_poses + num_pitch_poses + 1][2] = relative_roll_angles[pos_idx]; + move32(); + } + pMultiBinPoseData->dof = pSplit_rend_config->dof; + move16(); + pMultiBinPoseData->hq_mode = pSplit_rend_config->hq_mode; + move16(); + pMultiBinPoseData->rot_axis = rot_axis; + move32(); + pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode; + move32(); + + return; +} + +/*------------------------------------------------------------------------- + * Function isar_renderSplitUpdateNoCorrectionPoseData() + * + * + *------------------------------------------------------------------------*/ + +void isar_renderSplitUpdateNoCorrectionPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + pMultiBinPoseData->num_poses = 1; + move16(); + assert( pSplit_rend_config->dof == 0 ); + pMultiBinPoseData->dof = pSplit_rend_config->dof; + move16(); + assert( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ); + pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode; + move32(); + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_init_multi_bin_pose_data() + * + * + *------------------------------------------------------------------------*/ + +void isar_init_multi_bin_pose_data_fx( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + Word16 pos_idx; + + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] = 0; + move32(); + pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] = 0; + move32(); + pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] = 0; + move32(); + } + pMultiBinPoseData->num_poses = 1; + move16(); + pMultiBinPoseData->dof = 3; + move16(); + pMultiBinPoseData->hq_mode = 0; + move16(); + pMultiBinPoseData->rot_axis = DEFAULT_AXIS; + move32(); + + return; +} + +/* Copy for encoder, to be removed */ +void isar_init_multi_bin_pose_data_fx_enc( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + Word16 pos_idx; + + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] = 0; + move32(); + pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] = 0; + move32(); + pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] = 0; + move32(); + } + pMultiBinPoseData->num_poses = 1; + move16(); + pMultiBinPoseData->dof = 3; + move16(); + pMultiBinPoseData->hq_mode = 0; + move16(); + pMultiBinPoseData->rot_axis = DEFAULT_AXIS; + move32(); + + return; +} +void isar_init_multi_bin_pose_data( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + int16_t pos_idx; + + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f; + pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f; + pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f; + } + pMultiBinPoseData->num_poses = 1; + pMultiBinPoseData->dof = 3; + pMultiBinPoseData->hq_mode = 0; + pMultiBinPoseData->rot_axis = DEFAULT_AXIS; + + return; +} + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error isar_framesize_to_ms( + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + int16_t *ms /* o : frame size in ms */ +) +{ + switch ( frame_size ) + { + case IVAS_RENDER_FRAMESIZE_5MS: + *ms = 5; + break; + case IVAS_RENDER_FRAMESIZE_10MS: + *ms = 10; + break; + case IVAS_RENDER_FRAMESIZE_20MS: + *ms = 20; + break; + default: + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported ISAR frame size" ); + } + + return IVAS_ERR_OK; +} +#endif + +/*------------------------------------------------------------------------- + * Function isar_split_rend_choose_default_codec() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_split_rend_choose_default_codec( + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ +#endif + Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ + const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ + const Word16 num_subframes /* i : number of subframes */ +) +{ + IF( EQ_16( pcm_out_flag, 0 ) ) + { + IF( EQ_32( *pCodec, ISAR_SPLIT_REND_CODEC_DEFAULT ) ) + { + *pCodec = cldfb_in_flag ? ISAR_SPLIT_REND_CODEC_LCLD : ISAR_SPLIT_REND_CODEC_LC3PLUS; + move32(); + } + } + ELSE + { + *pCodec = ISAR_SPLIT_REND_CODEC_NONE; + move32(); + } + + IF( EQ_16( *pCodec_frame_size_ms, 0 ) ) /* codec frame size hasn't been set yet - use default for current configuration */ + { + SWITCH( *pCodec ) + { + case ISAR_SPLIT_REND_CODEC_LCLD: + *pCodec_frame_size_ms = DEPR_i_mult( num_subframes, 5 ); + BREAK; + case ISAR_SPLIT_REND_CODEC_LC3PLUS: + case ISAR_SPLIT_REND_CODEC_NONE: + *pCodec_frame_size_ms = 5; + move16(); + BREAK; + default: + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" ); + } + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + IF( *pIsar_frame_size_ms == 0 ) /* isar frame size hasn't been set yet - use default for current configuration */ + { + *pIsar_frame_size_ms = 20; + } +#endif + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * Function get_bit() + * + * + *-------------------------------------------------------------------*/ + +Word32 get_bit( + const Word32 state, + const Word32 bit_id ) +{ + return L_and( state, ( L_shl( 1, (Word16) bit_id ) ) ); +} + +void set16_fx( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +) +{ + Word16 i; + + for ( i = 0; i < N; i++ ) + { + y[i] = a; + } + + return; +} + +void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ +) +{ + Word16 i; + + FOR( i = 0; i < N; i++ ) + { + y[i] = a; + move32(); + } + + return; +} + +/*-------------------------------------------------------------------* + * ceil_log_2() + * + * calculates ceil(log2(val)) + *-------------------------------------------------------------------*/ + +Word16 ceil_log_2( + UWord64 val ) +{ + + IF( val <= 0 ) + { + assert( 0 ); + } + return val <= 1 ? 0 : val <= 2 ? 1 + : val <= 4 ? 2 + : val <= 8 ? 3 + : val <= 16 ? 4 + : val <= 32 ? 5 + : val <= 64 ? 6 + : val <= 128 ? 7 + : val <= 256 ? 8 + : val <= 512 ? 9 + : val <= 1024 ? 10 + : val <= 2048 ? 11 + : val <= 4096 ? 12 + : val <= 8192 ? 13 + : val <= 16384 ? 14 + : val <= 32768 ? 15 + : val <= 65536 ? 16 + : val <= 131072 ? 17 + : val <= 262144 ? 18 + : val <= 524288 ? 19 + : val <= 1048576 ? 20 + : val <= 2097152 ? 21 + : val <= 4194304 ? 22 + : val <= 8388608 ? 23 + : val <= 16777216 ? 24 + : val <= 33554432 ? 25 + : val <= 67108864 ? 26 + : val <= 134217728 ? 27 + : val <= 268435456 ? 28 + : val <= 536870912 ? 29 + : val <= 1073741824 ? 30 + : val <= 2147483648 ? 31 + : val <= 4294967296 ? 32 + : val <= 8589934592 ? 33 + : val <= 17179869184 ? 34 + : val <= 34359738368 ? 35 + : val <= 68719476736 ? 36 + : val <= 137438953472 ? 37 + : val <= 274877906944 ? 38 + : val <= 549755813888 ? 39 + : val <= 1099511627776 ? 40 + : val <= 2199023255552 ? 41 + : val <= 4398046511104 ? 42 + : val <= 8796093022208 ? 43 + : val <= 17592186044416 ? 44 + : val <= 35184372088832 ? 45 + : val <= 70368744177664 ? 46 + : val <= 140737488355328 ? 47 + : val <= 281474976710656 ? 48 + : val <= 562949953421312 ? 49 + : val <= 1125899906842624 ? 50 + : val <= 2251799813685248 ? 51 + : val <= 4503599627370496 ? 52 + : val <= 9007199254740992 ? 53 + : val <= 18014398509481984 ? 54 + : val <= 36028797018963968 ? 55 + : val <= 72057594037927936 ? 56 + : val <= 144115188075855872 ? 57 + : val <= 288230376151711744 ? 58 + : val <= 576460752303423488 ? 59 + : val <= 1152921504606846976 ? 60 + : val <= 2305843009213693952 ? 61 + : val <= 4611686018427387904 ? 62 + : val <= 9223372036854775807 ? 63 + : 64; +} +#endif diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h new file mode 100644 index 000000000..e94d23e18 --- /dev/null +++ b/lib_isar/isar_stat.h @@ -0,0 +1,267 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_STAT_H +#define ISAR_STAT_H + + +#include +#include "options.h" +#include "stat_com.h" +#include "ivas_stat_com.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "isar_lc3plus_enc.h" +#include "isar_lc3plus_dec.h" +#include "isar_cnst.h" + + +/*-------------------------------------------------------------------* + * ISAR post rend constants + *-------------------------------------------------------------------*/ + +#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 ) +#define MAX_CLDFB_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) +#define MAX_BIN_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) +#define MAX_CLDFB_BIN_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) + +/*-------------------------------------------------------------------* + * ISAR post rend structs + *-------------------------------------------------------------------*/ + +typedef struct +{ + int8_t headRotEnabled; + IVAS_QUATERNION headPositions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 crossfade_fx[L_FRAME48k / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; + +} ISAR_POST_REND_HeadRotData; + +typedef struct +{ +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbAna[( 1 + MAX_HEAD_ROT_POSES ) * BINAURAL_CHANNELS]; +#else + HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; +#endif + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; + +} CLDFB_HANDLES_WRAPPER, *CLDFB_HANDLES_WRAPPER_HANDLE; + +typedef struct isar_split_rend_huffman_cfg_t +{ + const int32_t *codebook; + int16_t min_len; + int16_t max_len; + int16_t sym_len; + +} isar_split_rend_huffman_cfg_t; + +typedef struct isar_binaural_head_rot_split_rendering_huff_struct +{ + isar_split_rend_huffman_cfg_t pred[2]; + int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; + int16_t pred_base2_code_len[2]; + isar_split_rend_huffman_cfg_t pred_roll; + int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; + int16_t pred_roll_base2_code_len; + isar_split_rend_huffman_cfg_t gd; + int16_t gd_base2_code_len; + int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + isar_split_rend_huffman_cfg_t p_gd; + int16_t p_gd_base2_code_len; + int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + isar_split_rend_huffman_cfg_t p_gd_diff; + int16_t p_gd_diff_base2_code_len; + int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + +} ISAR_BIN_HR_SPLIT_REND_HUFF, *ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE; + +/* binaural split rendering head rotation data structure */ +typedef struct isar_binaural_head_rot_split_rendering_md_struct +{ + Word32 pred_mat_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* Q25 */ + Word16 exp_pred_mat_re; + Word32 pred_mat_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* Q25 */ + Word16 exp_pred_mat_im; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + Word32 pred_mat_re2[BINAURAL_CHANNELS]; + Word16 exp_pred_mat_re2; +#endif + Word32 gd_fx; /* Q25 */ + Word32 gd2_fx; /* Q25 */ + Word16 exp_gd; + Word16 exp_gd2; + int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t gd_idx; + int16_t gd2_idx; + +} ISAR_BIN_HR_SPLIT_REND_MD, *ISAR_BIN_HR_SPLIT_REND_MD_HANDLE; +typedef struct isar_binaural_head_rot_split_pre_rendering_struct +{ + ISAR_BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + Word32 fix_pos_rot_mat_fx[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + ISAR_BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; +#endif + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; +#endif + +} ISAR_BIN_HR_SPLIT_PRE_REND, *ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE; +/*----------------------------------------------------------------------------------* + * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) + *----------------------------------------------------------------------------------*/ + +typedef struct isar_binaural_head_rot_split_rendering_lcld_enc_struct +{ + void *pLcld_enc; + Word16 iChannels; + LCLDEncoder *psLCLDEncoder; + Word32 ***pppfLCLDReal_fx; + Word32 ***pppfLCLDImag_fx; +#ifdef CLDFB_DEBUG + FILE *cldfbIn; + int16_t numFrame; +#endif + Word16 iNumIterations; + Word16 iNumBlocks; + +} ISAR_BIN_HR_SPLIT_LCLD_ENC, *ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE; + +typedef struct +{ + Word32 Cldfb_Prev_BinReal_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_Prev_BinImag_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_Prev_Bin_fx; + Word32 xf_bet_fx[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; + +} ISAR_CLDFB_PLC, *ISAR_CLDFB_PLC_HANDLE; +typedef struct +{ + ISAR_CLDFB_PLC CldfbPLC_state; + Word16 prev_bfi; + Word16 bf_count; + Word16 iNumSubSets; + +} ISAR_SPLIT_REND_PLC_STRUCT, *ISAR_SPLIT_REND_PLC_HANDLE; +typedef struct isar_binaural_head_rot_split_rendering_lcld_dec_struct +{ + void *pLcld_dec; + Word32 iChannels; + LCLDDecoder *psLCLDDecoder; + Word32 ***pppfDecLCLDReal_fx; + Word32 ***pppfDecLCLDImag_fx; +#ifdef CLDFB_DEBUG + FILE *cldfbOut; + int16_t numFrame; +#endif + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC; + + Word16 iNumBlocks; + Word16 iNumIterations; + +} ISAR_BIN_HR_SPLIT_LCLD_DEC, *ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE; +typedef struct isar_binaural_head_rot_split_post_rendering_struct +{ + ISAR_BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t low_Res; + + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 fix_pos_rot_mat_fx[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* Q31 */ + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + ISAR_BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + Word32 mixer_mat_re_fx[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mixer_mat_im_fx[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 gd_mem_fx[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; +#else + Word32 mixer_mat_re_fx[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 mixer_mat_im_fx[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word32 gd_mem_fx[1][MAX_SPLIT_REND_MD_BANDS]; +#endif + int16_t cf_flag; + HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; +#endif + +} ISAR_BIN_HR_SPLIT_POST_REND, *ISAR_BIN_HR_SPLIT_POST_REND_HANDLE; + +typedef struct +{ + int16_t num_poses; + float relative_head_poses[MAX_HEAD_ROT_POSES][3]; + Word32 relative_head_poses_fx[MAX_HEAD_ROT_POSES][3]; /* Q22 */ + int16_t dof; + int16_t hq_mode; + ISAR_SPLIT_REND_ROT_AXIS rot_axis; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; + +} MULTI_BIN_REND_POSE_DATA; + +typedef struct +{ + MULTI_BIN_REND_POSE_DATA multiBinPoseData; + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec; + int16_t first_good_frame_received; + ISAR_LC3PLUS_DEC_HANDLE hLc3plusDec; + +} ISAR_SPLIT_POST_REND_WRAPPER; + + +typedef struct +{ + MULTI_BIN_REND_POSE_DATA multiBinPoseData; + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend; + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc; + CLDFB_HANDLES_WRAPPER_HANDLE hCldfbHandles; + ISAR_LC3PLUS_ENC_HANDLE hLc3plusEnc; + float *lc3plusDelayBuffers[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* Used to time-align head pose correction metadata with LC3plus-coded reference audio */ + Word32 *lc3plusDelayBuffers_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* Used to time-align head pose correction metadata with LC3plus-coded reference audio */ + Word16 lc3plusDelayBuffers_q; + Word32 lc3plusDelaySamples; +} SPLIT_REND_WRAPPER; + +#endif + +#endif /* ISAR_STAT_H */ diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c new file mode 100644 index 000000000..178718a60 --- /dev/null +++ b/lib_isar/lib_isar_post_rend.c @@ -0,0 +1,1913 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +#include "options.h" +#include "lib_isar_post_rend.h" +#include "isar_stat.h" +#include "isar_prot.h" +#include "prot.h" +#include "ivas_prot.h" +#include "prot_fx2.h" +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int32_t ISAR_POST_REND_void_func( void ) +{ + return 0; +} + +#else + +#include "ivas_prot_rend.h" +#include +#include +#include "wmc_auto.h" +#include "prot_fx2.h" + + +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local types + *-------------------------------------------------------------------*/ + +/* EFAP wrapper to simplify writing panning gains to a vector that includes LFE channels */ +typedef struct +{ + EFAP_HANDLE hEfap; + AUDIO_CONFIG speakerConfig; + const LSSETUP_CUSTOM_STRUCT *pCustomLsSetup; /* Pointer to main custom LS struct from renderer handle - doesn't need freeing */ +} EFAP_WRAPPER; + +/* Lightweight helper struct that gathers all information required for rendering + * any config to any other config. Used to simplify signatures of rendering functions. + * + * This struct should store ONLY CONST POINTERS to data existing elsewhere. + * Storing pointers instead of data itself ensures that no additional updates + * are required when any of these are changed in the renderer. Making the pointers + * const ensures that this data is only read, but not modified by the rendering functions. */ +typedef struct +{ + const int32_t *pOutSampleRate; + const AUDIO_CONFIG *pOutConfig; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; + const EFAP_WRAPPER *pEfapOutWrapper; +#endif + const ISAR_POST_REND_HeadRotData *pHeadRotData; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + const RENDER_CONFIG_HANDLE *hhRendererConfig; +#endif + const int16_t *pSplitRendBFI; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRenderConfig; +#endif +} rendering_context; + +/* Common base for input structs */ +typedef struct +{ + AUDIO_CONFIG inConfig; + ISAR_POST_REND_InputId id; + IVAS_REND_AudioBuffer inputBuffer; + Word32 gain_fx; /* Linear, not in dB */ + rendering_context ctx; + int32_t numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ +} input_base; + +typedef struct +{ + input_base base; + ISAR_SPLIT_POST_REND_WRAPPER splitPostRendWrapper; + Word32 *bufferData_fx; + int16_t numCachedSamples; /* Number of decoded samples in bufferData that have not yet been played out */ + ISAR_POST_REND_BitstreamBuffer *hBits; +} input_split_post_rend; + +struct ISAR_POST_REND +{ + int32_t sampleRateOut; + + IVAS_LIMITER_HANDLE hLimiter; +#ifdef DEBUGGING + int32_t numClipping; /* Counter of clipped output samples */ +#endif + + input_split_post_rend inputsSplitPost[RENDERER_MAX_BIN_INPUTS]; + + AUDIO_CONFIG inputConfig; + AUDIO_CONFIG outputConfig; + + ISAR_POST_REND_HeadRotData headRotData; + int16_t splitRendBFI; + + int8_t rendererConfigEnabled; + ISAR_SPLIT_REND_CONFIG_DATA splitRenderConfig; + + int16_t num_subframes; +}; + +/*-------------------------------------------------------------------* + * getAudioConfigType() + * + * + *-------------------------------------------------------------------*/ +ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( + const AUDIO_CONFIG config ) +{ + ISAR_POST_REND_AudioConfigType type; + + SWITCH( config ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + type = ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL; + BREAK; + default: + type = ISAR_POST_REND_AUDIO_CONFIG_TYPE_UNKNOWN; + BREAK; + } + + return type; +} + +/*-------------------------------------------------------------------* + * Local function prototypes + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ +static ivas_error allocateInputBaseBufferData_fx( + Word32 **data, + const Word16 data_size ) +{ + *data = (Word32 *) malloc( data_size * sizeof( Word32 ) ); + IF( *data == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for input base buffer data" ); + } + + return IVAS_ERR_OK; +} +static void freeInputBaseBufferData_fx( + Word32 **data ) +{ + IF( *data != NULL ) + { + free( *data ); + *data = NULL; + } + + return; +} + +static IVAS_QUATERNION quaternionInit( + void ) +{ + IVAS_QUATERNION q; + q.w_fx = ONE_IN_Q22; + q.x_fx = q.y_fx = q.z_fx = 0; + return q; +} + +static void convertBitsBufferToInternalBitsBuff( + const ISAR_POST_REND_BitstreamBuffer outBits, + ISAR_SPLIT_REND_BITS_HANDLE hBits ) +{ + hBits->bits_buf = outBits.bits; + hBits->bits_read = outBits.config.bitsRead; + hBits->bits_written = outBits.config.bitsWritten; + hBits->buf_len = outBits.config.bufLenInBytes; + hBits->codec = outBits.config.codec; + hBits->pose_correction = outBits.config.poseCorrection; + hBits->codec_frame_size_ms = outBits.config.codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hBits->isar_frame_size_ms = outBits.config.isar_frame_size_ms; + hBits->lc3plus_highres = outBits.config.lc3plusHighRes; +#endif + + return; +} + +static void convertInternalBitsBuffToBitsBuffer( + ISAR_POST_REND_BitstreamBuffer *hOutBits, + const ISAR_SPLIT_REND_BITS_DATA bits ) +{ + hOutBits->bits = bits.bits_buf; + hOutBits->config.bitsRead = bits.bits_read; + hOutBits->config.bitsWritten = bits.bits_written; + hOutBits->config.bufLenInBytes = bits.buf_len; + hOutBits->config.codec = bits.codec; + hOutBits->config.poseCorrection = bits.pose_correction; + hOutBits->config.codec_frame_size_ms = bits.codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hOutBits->config.isar_frame_size_ms = bits.isar_frame_size_ms; + hOutBits->config.lc3plusHighRes = bits.lc3plus_highres; +#endif + + return; +} + +static void copyBufferTo2dArray_fx( + const IVAS_REND_AudioBuffer buffer, + Word32 array[][L_FRAME48k] ) +{ + UWord32 smplIdx; + UWord32 chnlIdx; + const Word32 *readPtr; + + assert( ( buffer.config.is_cldfb == 0 ) && "for CLDFB input call copyBufferToCLDFBarray()" ); + readPtr = buffer.data_fx; + + FOR( chnlIdx = 0; chnlIdx < (UWord32) buffer.config.numChannels; ++chnlIdx ) + { + FOR( smplIdx = 0; smplIdx < (UWord32) buffer.config.numSamplesPerChannel; ++smplIdx ) + { + array[chnlIdx][smplIdx] = *readPtr++; + } + } + + return; +} + +static void accumulate2dArrayToBuffer_fx( + Word32 array[][L_FRAME48k], + Word16 Q_out[][BINAURAL_CHANNELS], + Word16 Q_max, + const IVAS_REND_AudioBuffer *buffer, + Word16 num_subframes, + Word16 subframe_length ) +{ + Word16 smplIdx, chnlIdx; + Word32 *writePtr; + + writePtr = buffer->data_fx; + FOR( chnlIdx = 0; chnlIdx < buffer->config.numChannels; ++chnlIdx ) + { + FOR( Word16 sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( smplIdx = 0; smplIdx < subframe_length; ++smplIdx ) + { + //*writePtr++ += (float) array[chnlIdx][( sf_idx * subframe_length ) + smplIdx] / powf( 2, Q_out[sf_idx][chnlIdx] ); + *writePtr++ += L_shl( array[chnlIdx][( sf_idx * subframe_length ) + smplIdx], sub( Q_max, Q_out[sf_idx][chnlIdx] ) ); + } + } + } + + return; +} + +/*-------------------------------------------------------------------* + * limitRendererOutput() + * + * In-place saturation control for multichannel buffers with adaptive release time + *-------------------------------------------------------------------*/ + +#ifndef DISABLE_LIMITER +/*! r: number of clipped output samples */ +static Word32 limitRendererOutput_fx( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + Word32 *output, /* i/o: I/O buffer */ + const Word16 output_frame, /* i : number of samples per channel in the buffer */ + const Word32 threshold, /* i : signal amplitude above which limiting starts to be applied */ + Word16 q_factor ) /* i : q factor of output samples */ +{ + Word16 i; + Word32 **channels; + Word16 num_channels; + Word32 numClipping = 0; + + /* return early if given bad parameters */ + IF( hLimiter == NULL || output == NULL || output_frame <= 0 ) + { + return 0; + } + + channels = hLimiter->channel_ptrs_fx; + num_channels = hLimiter->num_channels; + + FOR( i = 0; i < num_channels; ++i ) + { + channels[i] = output + i * output_frame; + } + + limiter_process_fx( hLimiter, output_frame, threshold, 0, NULL, q_factor ); + + /* Apply clipping to buffer in case the limiter let through some samples > 1.0f */ + FOR( i = 0; i < output_frame * num_channels; ++i ) + { + + output[i] = min( max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) ); + } + + return numClipping; +} + +#endif + + +/*-------------------------------------------------------------------* + * validateOutputSampleRate() + * + * + *-------------------------------------------------------------------*/ +static ivas_error validateOutputSampleRate( + const Word32 sampleRate, + const AUDIO_CONFIG outConfig ) +{ + IF( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && NE_32( sampleRate, 48000 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); + } + ELSE + { + /* Otherwise rendering to binaural, support the same set as IVAS decoder */ + SWITCH( sampleRate ) + { + case 8000: + case 16000: + case 32000: + case 48000: + return IVAS_ERR_OK; + } + + return IVAS_ERR_INVALID_SAMPLING_RATE; + } +} + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ +static ivas_error initLimiter( + IVAS_LIMITER_HANDLE *phLimiter, + const Word16 numChannels, + const Word32 sampleRate ) +{ + ivas_error error; + + /* If re-initializing with unchanged values, return early */ + IF( *phLimiter != NULL && ( *phLimiter )->num_channels == numChannels && ( *phLimiter )->sampling_rate == sampleRate ) + { + return IVAS_ERR_OK; + } + + /* Support re-init: close if already allocated */ + IF( *phLimiter != NULL ) + { + ivas_limiter_close_splitRend( phLimiter ); + } + + IF( ( error = ivas_limiter_open_splitRend( phLimiter, numChannels, sampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + +static ivas_error initHeadRotation( + ISAR_POST_REND_HANDLE hIvasRend ) +{ + Word16 i, crossfade_len; + Word32 tmp; + + /* Head rotation is enabled by default */ + hIvasRend->headRotData.headRotEnabled = 1; + + /* Initialize 5ms crossfade */ + crossfade_len = 240 /*L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES*/; + tmp = 8985287 /*1.f / ( crossfade_len - 1 )*/; + FOR( i = 0; i < crossfade_len; i++ ) + { + hIvasRend->headRotData.crossfade_fx[i] = W_extract_l( W_mult0_32_32( i, tmp ) ); + } + + /* Initialize with unit quaternions */ + FOR( i = 0; i < hIvasRend->num_subframes; ++i ) + { + hIvasRend->headRotData.headPositions[i] = quaternionInit(); + } + + hIvasRend->headRotData.sr_pose_pred_axis = DEFAULT_AXIS; + + return IVAS_ERR_OK; +} +static void initRendInputBase_fx( + input_base *inputBase, + const AUDIO_CONFIG inConfig, + const IVAS_REND_InputId id, + const rendering_context rendCtx, + Word32 *dataBuf, + const Word16 dataBufSize ) +{ + inputBase->inConfig = inConfig; + inputBase->id = id; + inputBase->gain_fx = MAX_32; + inputBase->ctx = rendCtx; + inputBase->numNewSamplesPerChannel = 0; + + inputBase->inputBuffer.config.numSamplesPerChannel = 0; + inputBase->inputBuffer.config.numChannels = 0; + inputBase->inputBuffer.data_fx = dataBuf; + IF( inputBase->inputBuffer.data_fx != NULL ) + { + set_l( inputBase->inputBuffer.data_fx, 0, dataBufSize ); + } + + return; +} + +static rendering_context getRendCtx( + ISAR_POST_REND_HANDLE hIvasRend ) +{ + rendering_context ctx; + + /* Note: when refactoring this, always take the ADDRESS of a member of the + * renderer struct, so that the context stores a POINTER to the member, even + * if the member is a pointer or handle itself. */ + ctx.pOutConfig = &hIvasRend->outputConfig; + ctx.pOutSampleRate = &hIvasRend->sampleRateOut; + ctx.pHeadRotData = &hIvasRend->headRotData; + ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ctx.pSplitRenderConfig = &hIvasRend->splitRenderConfig; +#endif + + return ctx; +} + + +static ivas_error getRendInputNumChannels( + const void *rendInput, + Word16 *numInChannels ) +{ + /* Using a void pointer for this function to be reusable for any input type (input_ism, input_mc, input_sba). + Assumptions: - input_base is always the first member in the input struct */ + (void) rendInput; + + *numInChannels = 2; + + return IVAS_ERR_OK; +} + +static ivas_error updateSplitPostRendPanGains( + input_split_post_rend *inputSplitPostRend, + const AUDIO_CONFIG outConfig, + ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t num_subframes +#endif +) +{ + ivas_error error; + rendering_context rendCtx; + LC3PLUS_CONFIG config; + Word16 iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; + + (void) outConfig; + + rendCtx = inputSplitPostRend->base.ctx; + isar_renderSplitGetMultiBinPoseData_fx( hRendCfg, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, rendCtx.pHeadRotData->sr_pose_pred_axis ); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.high_res_mode_enabled = ( hRendCfg->lc3plus_highres != 0 ); +#endif + config.lc3plus_frame_duration_us = hRendCfg->codec_frame_size_ms * 1000; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.isar_frame_duration_us = hRendCfg->isar_frame_size_ms * 1000; +#else + IF( NE_16( num_subframes, MAX_PARAM_SPATIAL_SUBFRAMES ) ) + { + IF( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + config.ivas_frame_duration_us = ( hRendCfg->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; + } + ELSE + { + config.ivas_frame_duration_us = ( hRendCfg->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ? config.lc3plus_frame_duration_us : 20000; + } + iNumLCLDIterationsPerFrame = 1; + } + ELSE + { + config.ivas_frame_duration_us = 20000; + } +#endif + + IF( GT_16( hRendCfg->codec_frame_size_ms, 0 ) ) + { + iNumLCLDIterationsPerFrame = (Word16) config.isar_frame_duration_us / ( 1000 * hRendCfg->codec_frame_size_ms ); + iNumLCLDIterationsPerFrame = max( 1, iNumLCLDIterationsPerFrame ); + iNumBlocksPerFrame = CLDFB_NO_COL_MAX * hRendCfg->codec_frame_size_ms / 20; + } + ELSE + { + iNumLCLDIterationsPerFrame = 1; + iNumBlocksPerFrame = CLDFB_NO_COL_MAX; + } + + config.channels = BINAURAL_CHANNELS; + config.samplerate = *inputSplitPostRend->base.ctx.pOutSampleRate; + + IF( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + IF( ( error = isar_splitBinLCLDDecOpen( &inputSplitPostRend->splitPostRendWrapper.hSplitBinLCLDDec, *inputSplitPostRend->base.ctx.pOutSampleRate, BINAURAL_CHANNELS, iNumBlocksPerFrame, iNumLCLDIterationsPerFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE IF( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + IF( ( error = ISAR_LC3PLUS_DEC_Open( config, + &inputSplitPostRend->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + IF( ( error = isar_splitBinPostRendOpen( &inputSplitPostRend->splitPostRendWrapper.hBinHrSplitPostRend, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + +static ivas_error setRendInputActiveSplitPostRend( + void *input, + const AUDIO_CONFIG inConfig, + const IVAS_REND_InputId id, + ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t num_subframes +#endif +) +{ + ivas_error error; + rendering_context rendCtx; + AUDIO_CONFIG outConfig; + input_split_post_rend *inputSplitPostRend; + + inputSplitPostRend = (input_split_post_rend *) input; + rendCtx = inputSplitPostRend->base.ctx; + outConfig = *rendCtx.pOutConfig; + + IF( ( error = allocateInputBaseBufferData_fx( &inputSplitPostRend->bufferData_fx, MAX_CLDFB_BIN_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + { + return error; + } + + initRendInputBase_fx( &inputSplitPostRend->base, inConfig, id, rendCtx, inputSplitPostRend->bufferData_fx, MAX_CLDFB_BIN_BUFFER_LENGTH ); + + inputSplitPostRend->numCachedSamples = 0; + + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + +static void clearInputSplitRend( + input_split_post_rend *inputSplitRend ) +{ + rendering_context rendCtx; + + rendCtx = inputSplitRend->base.ctx; + + freeInputBaseBufferData_fx( &inputSplitRend->bufferData_fx ); + + initRendInputBase_fx( &inputSplitRend->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); + + IF( inputSplitRend->splitPostRendWrapper.hBinHrSplitPostRend != NULL ) + { + isar_splitBinPostRendClose( &inputSplitRend->splitPostRendWrapper.hBinHrSplitPostRend ); + } + + IF( inputSplitRend->splitPostRendWrapper.hSplitBinLCLDDec != NULL ) + { + isar_splitBinLCLDDecClose( &inputSplitRend->splitPostRendWrapper.hSplitBinLCLDDec ); + } + + IF( inputSplitRend->splitPostRendWrapper.hLc3plusDec != NULL ) + { + ISAR_LC3PLUS_DEC_Close( &inputSplitRend->splitPostRendWrapper.hLc3plusDec ); + } + + return; +} + + +/*------------------------------------------------------------------------- + * ISAR_POST_REND_open() + * + * + *------------------------------------------------------------------------*/ +ivas_error ISAR_POST_REND_open( + ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const Word32 outputSampleRate, /* i : output sampling rate */ + const AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const Word16 nonDiegeticPan, /* i : non-diegetic object flag */ + const Word32 nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const Word16 num_subframes ) /* i : number of subframes */ +{ + Word16 i; + ISAR_POST_REND_HANDLE hIvasRend; + ivas_error error; + Word16 numOutChannels; + + (void) asHrtfBinary; + (void) nonDiegeticPan; + (void) nonDiegeticPanGain; + + /* Validate function arguments */ + IF( phIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF( ( error = validateOutputSampleRate( outputSampleRate, outConfig ) ) != IVAS_ERR_OK ) + { + return error; + } + + *phIvasRend = (ISAR_POST_REND_HANDLE) malloc( sizeof( struct ISAR_POST_REND ) ); + IF( *phIvasRend == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + hIvasRend = *phIvasRend; + hIvasRend->sampleRateOut = outputSampleRate; + hIvasRend->outputConfig = outConfig; + hIvasRend->hLimiter = NULL; + hIvasRend->num_subframes = 1; +#ifdef DEBUGGING + hIvasRend->numClipping = 0; +#endif + hIvasRend->num_subframes = num_subframes; + + /* Initialize limiter */ + IF( ( error = ISAR_POST_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( ( error = initLimiter( &hIvasRend->hLimiter, numOutChannels, outputSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Initialize headrotation data */ + IF( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Initialize inputs */ + + FOR( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + initRendInputBase_fx( &hIvasRend->inputsSplitPost[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); + + isar_init_split_post_rend_handles( &hIvasRend->inputsSplitPost[i].splitPostRendWrapper ); + + hIvasRend->splitRendBFI = 0; + hIvasRend->inputsSplitPost[i].bufferData_fx = NULL; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_NumOutChannels() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_POST_REND_NumOutChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + Word16 *numOutChannels /* o : number of output channels */ +) +{ + /* Validate function arguments */ + IF( hIvasRend == NULL || numOutChannels == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *numOutChannels = 2; + + return IVAS_ERR_OK; +} + +static IVAS_REND_InputId makeInputId( + AUDIO_CONFIG config, + const Word32 inputIndex ) +{ + /* Put config type in second byte (from LSB), put index + 1 in first byte + * + * Index is incremented here so that a valid ID can never be 0. */ + return (IVAS_REND_InputId) ( ( ( (UWord32) isar_getAudioConfigType( config ) ) << 8 ) | ( inputIndex + 1 ) ); +} + +static ivas_error getInputById( + ISAR_POST_REND_HANDLE hIvasRend, + const IVAS_REND_InputId inputId, + void **ppInput ) +{ + Word32 inputIndex; + IVAS_REND_AudioConfigType configType; + input_base *pInputBase; + + /* Reverse makeInputId() */ + inputIndex = ( inputId & 0xFF ) - 1; + configType = ( inputId & 0xFF00 ) >> 8; + + /* Validate values derived from input ID */ + IF( inputIndex < 0 ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + SWITCH( configType ) + { + case ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL: + if ( inputIndex > RENDERER_MAX_BIN_INPUTS ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + pInputBase = &hIvasRend->inputsSplitPost[inputIndex].base; + BREAK; + default: + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Ensure input ID matches and that input is active */ + IF( pInputBase->id != inputId || pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Validation done, set value via output parameter */ + *ppInput = pInputBase; + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_SetInputGain() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_POST_REND_SetInputGain( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const Word32 gain /* i : linear gain (not in dB) */ +) +{ + input_base *inputBase; + ivas_error error; + + /* Validate function arguments */ + IF( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + { + printf( "Hoo\n" ); + return error; + } + + inputBase->gain_fx = gain; + + return IVAS_ERR_OK; +} + +static ivas_error getConstInputById( + ISAR_POST_REND_CONST_HANDLE hIvasRend, + const ISAR_POST_REND_InputId inputId, + const void **ppInput ) +{ + Word32 inputIndex; + IVAS_REND_AudioConfigType configType; + const input_base *pInputBase; + + /* Reverse makeInputId() */ + inputIndex = ( inputId & 0xFF ) - 1; + configType = ( inputId & 0xFF00 ) >> 8; + + /* Validate values derived from input ID */ + IF( inputIndex < 0 ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + SWITCH( configType ) + { + case ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL: + IF( inputIndex > RENDERER_MAX_BIN_INPUTS ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + pInputBase = &hIvasRend->inputsSplitPost[inputIndex].base; + BREAK; + default: + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Ensure input ID matches and that input is active */ + IF( pInputBase->id != inputId || pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Validation done, set value via output parameter */ + *ppInput = pInputBase; + + return IVAS_ERR_OK; +} + +static ivas_error findFreeInputSlot( + const void *inputs, + const Word32 inputStructSize, + const Word32 maxInputs, + Word32 *inputIndex ) +{ + /* Using a void pointer and a separately provided size is a hack for this function + to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). + Assumptions: + - input_base is always the first member in the input struct + - provided size is correct + */ + + Word32 i; + bool canAddInput; + const UWord8 *pByte; + const input_base *pInputBase; + + canAddInput = false; + pByte = inputs; + /* Find first unused input in array */ + FOR( i = 0; i < maxInputs; ++i ) + { + pInputBase = (const input_base *) pByte; + + IF( pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + *inputIndex = i; + canAddInput = true; + BREAK; + } + pByte += inputStructSize; + } + + IF( !canAddInput ) + { + return IVAS_ERR_TOO_MANY_INPUTS; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_AddInput() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_AddInput( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_AUDIO_CONFIG inConfig, /* i : audio config for a new input */ + ISAR_POST_REND_InputId *inputId /* o : ID of the new input */ +) +{ + ivas_error error; + Word32 maxNumInputsOfType; + void *inputsArray; + Word32 inputStructSize; + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t +#endif + ); + Word32 inputIndex; + + /* Validate function arguments */ + IF( hIvasRend == NULL || inputId == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + SWITCH( isar_getAudioConfigType( inConfig ) ) + { + case ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL: + maxNumInputsOfType = RENDERER_MAX_BIN_INPUTS; + inputsArray = hIvasRend->inputsSplitPost; + inputStructSize = sizeof( *hIvasRend->inputsSplitPost ); + activateInput = setRendInputActiveSplitPostRend; + BREAK; + default: + return IVAS_ERR_INVALID_INPUT_FORMAT; + } + + /* Find first free input in array corresponding to input type */ + IF( ( error = findFreeInputSlot( inputsArray, inputStructSize, maxNumInputsOfType, &inputIndex ) ) != IVAS_ERR_OK ) + { + return error; + } + + *inputId = makeInputId( inConfig, inputIndex ); + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + hIvasRend->num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetInputNumChannels() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_GetInputNumChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + Word16 *numChannels /* o : number of channels of the input */ +) +{ + ivas_error error; + const input_base *pInput; + + /* Validate function arguments */ + IF( hIvasRend == NULL || numChannels == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF( ( error = getConstInputById( hIvasRend, inputId, (const void **) &pInput ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( ( error = getRendInputNumChannels( pInput, numChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetDelay() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_GetDelay( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + Word16 *nSamples, /* o : Renderer delay in samples */ + Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +) +{ + Word16 i; + Word32 latency_ns; + Word32 max_latency_ns; + + /* Validate function arguments */ + IF( hIvasRend == NULL || nSamples == NULL || timeScale == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *timeScale = hIvasRend->sampleRateOut; + *nSamples = 0; + max_latency_ns = 0; + + /* Compute the maximum delay across all inputs */ + FOR( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ ){ + IF( hIvasRend->inputsSplitPost[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ){ + latency_ns = 0; + IF( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hLc3plusDec != NULL ) + { + int32_t lc3plusDelaySamples; + ISAR_LC3PLUS_DEC_GetDelay( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hLc3plusDec, &lc3plusDelaySamples ); + latency_ns = (Word32) ( ( ( (Word64) lc3plusDelaySamples * 1000000000 ) + ( *timeScale / 2 ) ) / *timeScale ); + } + IF( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + latency_ns += IVAS_FB_DEC_DELAY_NS; + } + ELSE IF( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hSplitBinLCLDDec != NULL ) + { + latency_ns += IVAS_FB_DEC_DELAY_NS; + } + max_latency_ns = max( max_latency_ns, latency_ns ); +} +} + +*nSamples = (Word16) ( ( ( (Word64) max_latency_ns * *timeScale ) + 500000000 ) / 1000000000 ); + +return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_FeedInputAudio() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_POST_REND_FeedInputAudio( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const ISAR_POST_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ +) +{ + ivas_error error; + input_base *inputBase; + Word16 numInputChannels; + Word16 cldfb2tdSampleFact; + + /* Validate function arguments */ + IF( hIvasRend == NULL || inputAudio.data_fx == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; + + IF( LE_16( inputAudio.config.numSamplesPerChannel, 0 ) || ( LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, inputAudio.config.numSamplesPerChannel ) && EQ_16( inputAudio.config.is_cldfb, 0 ) ) || + ( LT_16( DEPR_i_mult( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdSampleFact ), inputAudio.config.numSamplesPerChannel ) && EQ_16( inputAudio.config.is_cldfb, 1 ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); + } + + IF( LE_16( inputAudio.config.numChannels, 0 ) || LT_16( MAX_INPUT_CHANNELS, inputAudio.config.numChannels ) ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + IF( isar_getAudioConfigType( hIvasRend->outputConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); + } + + IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + { + printf( "Foo\n" ); + return error; + } + + IF( ( error = getRendInputNumChannels( inputBase, &numInputChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( numInputChannels != inputAudio.config.numChannels ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + inputBase->inputBuffer.config = inputAudio.config; + + mvl2l( inputAudio.data_fx, inputBase->inputBuffer.data_fx, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); + + inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel / cldfb2tdSampleFact; + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_InitConfig() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_POST_REND_InitConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ +) +{ + bool rendererConfigEnabled; + + rendererConfigEnabled = ( isar_getAudioConfigType( outAudioConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL ); + + IF( rendererConfigEnabled ) + { + hIvasRend->rendererConfigEnabled = 1; + } + ELSE + { + hIvasRend->rendererConfigEnabled = 0; + } + + IF( rendererConfigEnabled ) + { + hIvasRend->splitRenderConfig.splitRendBitRate = SPLIT_REND_768k; + hIvasRend->splitRenderConfig.dof = 3; + hIvasRend->splitRenderConfig.hq_mode = 0; + hIvasRend->splitRenderConfig.codec_delay_ms = 0; + hIvasRend->splitRenderConfig.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->splitRenderConfig.isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#endif + hIvasRend->splitRenderConfig.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + hIvasRend->splitRenderConfig.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hIvasRend->splitRenderConfig.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetRenderConfig() + * + * + *-------------------------------------------------------------------*/ +Word16 ISAR_POST_REND_GetRenderConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + const ISAR_SPLIT_REND_CONFIG_HANDLE splitRenderConfig /* o : Render configuration handle */ +) +{ + ISAR_SPLIT_REND_CONFIG_DATA hRCin; + + IF( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hRCin = hIvasRend->splitRenderConfig; + + splitRenderConfig->splitRendBitRate = SPLIT_REND_768k; + splitRenderConfig->dof = 3; + splitRenderConfig->hq_mode = 0; + splitRenderConfig->codec_delay_ms = 0; + splitRenderConfig->codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + splitRenderConfig->isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#endif + splitRenderConfig->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRenderConfig->poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + splitRenderConfig->rendererSelection = hRCin.rendererSelection; + + return IVAS_ERR_OK; +} +/*-------------------------------------------------------------------* + * ISAR_POST_REND_FeedSplitBinauralBitstream() + * + * + *-------------------------------------------------------------------*/ +ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + ISAR_POST_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ +) +{ + ivas_error error; + input_base *inputBase; + input_split_post_rend *inputSplitPostRend; + + /* Validate function arguments */ + IF( hIvasRend == NULL || hBits == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + { + printf( "Goo\n" ); + return error; + } + + inputSplitPostRend = (input_split_post_rend *) inputBase; + inputSplitPostRend->hBits = hBits; + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_SetHeadRotation() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_SetHeadRotation( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ + const Word16 sf_idx /* i : subframe index */ +) +{ + IVAS_QUATERNION rotQuat; + + /* Validate function arguments */ + IF( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF( isar_getAudioConfigType( hIvasRend->outputConfig ) != ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL ) + { + /* Head rotation can be set only with binaural output */ + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + hIvasRend->headRotData.headRotEnabled = 1; + + /* check for Euler angle signaling */ + IF( EQ_32( headRot.w_fx, -12582912 ) ) + { + Euler2Quat_fx( deg2rad_fx( headRot.x_fx ), deg2rad_fx( headRot.y_fx ), deg2rad_fx( headRot.z_fx ), &rotQuat ); + } + ELSE + { + rotQuat = headRot; + } + + hIvasRend->headRotData.headPositions[sf_idx] = rotQuat; + hIvasRend->headRotData.Pos[sf_idx] = Pos; + hIvasRend->headRotData.sr_pose_pred_axis = rot_axis; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_SetSplitRendBFI() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_SetSplitRendBFI( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const Word16 bfi /* i: BFI flag */ +) +{ + hIvasRend->splitRendBFI = bfi; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + +static ivas_error splitBinLc3plusDecode( + ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin, + ISAR_SPLIT_REND_BITS_HANDLE bits, + Word32 outputBuffer[BINAURAL_CHANNELS][L_FRAME48k], +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction, +#endif + const int16_t SplitRendBFI ) +{ + ivas_error error; + Word32 *channel_ptrs[MAX_HEAD_ROT_POSES * 2]; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word32 lc3plusBitstreamSize; +#else + Word32 lc3plusBitrateId, lc3plusBitstreamSize; +#endif + + push_wmops( "splitBinLc3plusDecode" ); + assert( hSplitBin->hLc3plusDec != NULL ); + + for ( Word16 i = 0; i < BINAURAL_CHANNELS * hSplitBin->multiBinPoseData.num_poses; ++i ) + { + channel_ptrs[i] = outputBuffer[i]; + } + + if ( SplitRendBFI == 0 ) + { + /* Find next byte boundary */ + while ( bits->bits_read % 8 != 0 ) + { + ++bits->bits_read; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* Size is in bytes */ + assert( ( bits->bits_written - bits->bits_read ) % 8 == 0 ); + lc3plusBitstreamSize = ( bits->bits_written - bits->bits_read ) / 8; +#else + /* Read LC3plus bitstream size info */ + lc3plusBitrateId = ISAR_SPLIT_REND_BITStream_read_int32( bits, 8 ); + lc3plusBitstreamSize = isar_get_lc3plus_size_from_id( (Word8) lc3plusBitrateId, pose_correction, (Word16) ( hSplitBin->hLc3plusDec->config.ivas_frame_duration_us / 1000 ) ); +#endif + + if ( ( error = ISAR_LC3PLUS_DEC_Decode( hSplitBin->hLc3plusDec, &bits->bits_buf[bits->bits_read / 8], lc3plusBitstreamSize, channel_ptrs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + if ( ( error = ISAR_LC3PLUS_DEC_Conceal( hSplitBin->hLc3plusDec, channel_ptrs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + pop_wmops(); + return IVAS_ERR_OK; +} + +static ivas_error renderSplitBinauralWithPostRot( + input_split_post_rend *splitBinInput, + IVAS_REND_AudioBuffer outAudio, + const Word16 SplitRendBFI, + const Word16 num_subframes ) +{ + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + ivas_error error; + Word32 Cldfb_RealBuffer_Binaural_5ms_fx[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word32 Cldfb_ImagBuffer_Binaural_5ms_fx[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; + + IVAS_QUATERNION QuaternionsPost[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t sf_idx, ch_idx; + ISAR_SPLIT_REND_BITS_DATA bits; + Word32 tmpCrendBuffer_fx[BINAURAL_CHANNELS][L_FRAME48k] = { 0 }; + Word32 tmpCrendBuffer_sf_fx[BINAURAL_CHANNELS][L_FRAME48k] = { 0 }; + + ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin; + Word8 isPostRendInputCldfb; + Word16 chnlIdx, slotIdx, smplIdx; + Word16 preRendFrameSize_ms; + Word16 outBufNumSamplesPerChannel, outBufNumColPerChannel; + Word16 numSamplesPerChannelCacheSize, numColPerChannelCacheSize; + + Word32 *readPtr_fx, *writePtr_fx; + Word16 Q_cldfb_final[MAX_PARAM_SPATIAL_SUBFRAMES] = { 0 }; + Word16 Q_out[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS] = { 0 }; + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + uint32_t ivas_frame_duration_us; +#endif + Word16 iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; + const ISAR_POST_REND_HeadRotData *pHeadRotData; + + isPostRendInputCldfb = 0; + push_wmops( "renderSplitBinauralWithPostRot" ); + error = IVAS_ERR_OK; + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( outAudio.config.numSamplesPerChannel / *splitBinInput->base.ctx.pOutSampleRate > splitBinInput->hBits->config.isar_frame_size_ms ) + { + return IVAS_ERR_INTERNAL_FATAL; + } +#endif + + pHeadRotData = splitBinInput->base.ctx.pHeadRotData; + hSplitBin = &splitBinInput->splitPostRendWrapper; + convertBitsBufferToInternalBitsBuff( *splitBinInput->hBits, &bits ); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_frame_duration_us = 20000; + if ( splitBinInput->splitPostRendWrapper.hLc3plusDec != NULL ) + { + ivas_frame_duration_us = splitBinInput->splitPostRendWrapper.hLc3plusDec->config.isar_frame_duration_us; + } +#endif + + iNumLCLDIterationsPerFrame = 1; + iNumBlocksPerFrame = CLDFB_NO_COL_MAX; + IF( splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec != NULL ) + { + iNumBlocksPerFrame = splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec->iNumBlocks; + iNumLCLDIterationsPerFrame = splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec->iNumIterations; + } + + outBufNumSamplesPerChannel = outAudio.config.numSamplesPerChannel / num_subframes; + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + QuaternionsPost[sf_idx] = pHeadRotData->headPositions[sf_idx]; + } + + IF( !SplitRendBFI ) + { + hSplitBin->first_good_frame_received = 1; + } + + IF( EQ_16( hSplitBin->first_good_frame_received, 1 ) ) + { + IF( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + IF( !SplitRendBFI ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + isar_splitBinPostRendMdDec_fx( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, hSplitBin->hBinHrSplitPreRend ); +#else + isar_splitBinPostRendMdDec_fx( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData ); +#endif + } + } + + /*copy pose correction after MD is parsed*/ + hSplitBin->multiBinPoseData.poseCorrectionMode = bits.pose_correction; + + /* decode audio */ + IF( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + IF( bits.codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + isPostRendInputCldfb = 1; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outBufNumSamplesPerChannel; +#else + preRendFrameSize_ms = (int16_t) ( ivas_frame_duration_us ) / 1000; + + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * ( preRendFrameSize_ms - bits.codec_frame_size_ms ) / 1000 ); +#endif + + outBufNumColPerChannel = MAX_PARAM_SPATIAL_SUBFRAMES; + numColPerChannelCacheSize = sub( DEPR_i_mult( iNumBlocksPerFrame, iNumLCLDIterationsPerFrame ), outBufNumColPerChannel ); + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + IF( splitBinInput->numCachedSamples == 0 ) + { + IF( bits.codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + isar_splitBinLCLDDecProcess( hSplitBin->hSplitBinLCLDDec, &bits, Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, &Q_cldfb_final[sf_idx], SplitRendBFI ); // Q_cldfb_final + + /* copy data over to 5ms buffer */ + FOR( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + FOR( slotIdx = 0; slotIdx < 4 /*CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES*/; ++slotIdx ) + { + mvl2l( Cldfb_RealBuffer_Binaural_fx[chnlIdx][slotIdx], Cldfb_RealBuffer_Binaural_5ms_fx[sf_idx][chnlIdx][slotIdx], CLDFB_NO_CHANNELS_MAX ); + mvl2l( Cldfb_ImagBuffer_Binaural_fx[chnlIdx][slotIdx], Cldfb_ImagBuffer_Binaural_5ms_fx[sf_idx][chnlIdx][slotIdx], CLDFB_NO_CHANNELS_MAX ); + } + } + + /* cache the remaining 15ms */ + splitBinInput->numCachedSamples = numColPerChannelCacheSize; + writePtr_fx = splitBinInput->bufferData_fx; + FOR( slotIdx = 4 /*CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES*/; slotIdx < DEPR_i_mult( iNumBlocksPerFrame, iNumLCLDIterationsPerFrame ); ++slotIdx ) + { + FOR( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + FOR( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + *writePtr_fx++ = Cldfb_RealBuffer_Binaural_fx[chnlIdx][slotIdx][smplIdx]; + } + FOR( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + *writePtr_fx++ = Cldfb_ImagBuffer_Binaural_fx[chnlIdx][slotIdx][smplIdx]; + } + } + } + } + ELSE + { + Q_out[sf_idx][0] = 0; + Q_out[sf_idx][1] = 0; + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer_fx, +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + bits.pose_correction, +#endif + SplitRendBFI ) ) != IVAS_ERR_OK ) // Q0 + { + return error; + } + + /* cache the remaining 15ms */ + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + mvl2l( &tmpCrendBuffer_fx[0][outBufNumSamplesPerChannel], splitBinInput->bufferData_fx, numSamplesPerChannelCacheSize ); + mvl2l( &tmpCrendBuffer_fx[1][outBufNumSamplesPerChannel], splitBinInput->bufferData_fx + numSamplesPerChannelCacheSize, numSamplesPerChannelCacheSize ); + } + } + ELSE + { + /* copy from cache */ + IF( bits.codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + Word16 readOffset = sub( numColPerChannelCacheSize, splitBinInput->numCachedSamples ); + readPtr_fx = splitBinInput->bufferData_fx; + Q_cldfb_final[sf_idx] = Q_cldfb_final[sf_idx - 1]; + isPostRendInputCldfb = 1; + + readPtr_fx += 2 * readOffset * CLDFB_NO_CHANNELS_MAX * BINAURAL_CHANNELS; + FOR( slotIdx = 0; slotIdx < 4 /*CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES*/; ++slotIdx ) + { + FOR( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + FOR( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + Cldfb_RealBuffer_Binaural_5ms_fx[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr_fx++; + } + FOR( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + Cldfb_ImagBuffer_Binaural_5ms_fx[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr_fx++; + } + } + } + + splitBinInput->numCachedSamples -= outBufNumColPerChannel; + } + ELSE + { + Word16 readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; + mvl2l( splitBinInput->bufferData_fx + readOffset, &tmpCrendBuffer_fx[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvl2l( splitBinInput->bufferData_fx + readOffset + numSamplesPerChannelCacheSize, &tmpCrendBuffer_fx[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + Q_out[sf_idx][0] = Q_out[sf_idx - 1][0]; + Q_out[sf_idx][1] = Q_out[sf_idx - 1][1]; + splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; + } + } + } + } + ELSE + { + copyBufferTo2dArray_fx( splitBinInput->base.inputBuffer, tmpCrendBuffer_fx ); + IF( splitBinInput->numCachedSamples == 0 ) + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + preRendFrameSize_ms = splitBinInput->base.ctx.pSplitRenderConfig->isar_frame_size_ms; +#else + preRendFrameSize_ms = (int16_t) ( ivas_frame_duration_us ) / 1000; +#endif + numSamplesPerChannelCacheSize = (Word16) ( *splitBinInput->base.ctx.pOutSampleRate * preRendFrameSize_ms / 1000 ); + numSamplesPerChannelCacheSize -= outAudio.config.numSamplesPerChannel; + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + } + ELSE + { + splitBinInput->numCachedSamples -= outAudio.config.numSamplesPerChannel; + } + } + + /* apply pose correction if enabled */ + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + IF( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) + { + /* 0DOF with LCLD codec requires CLDFB synthesis */ + Word16 slot_idx; + + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Word32 *RealBuffer_fx[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 scaleFactor = 31, Q_cldfb; + + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_5ms_fx[sf_idx][ch_idx][slot_idx]; + ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_5ms_fx[sf_idx][ch_idx][slot_idx]; + + scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + } + scaleFactor = sub( scaleFactor, 3 ); // guarded bits + + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); + } + Q_cldfb = scaleFactor + Q_cldfb_final[sf_idx]; + Scale_sig32( hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, + ImagBuffer_fx, + &( tmpCrendBuffer_fx[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), + hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, + hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 + Scale_sig32( hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); + Q_out[sf_idx][ch_idx] = sub( Q_cldfb, 1 ); + } + } + ELSE IF( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + mvl2l( &tmpCrendBuffer_fx[0][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf_fx[0], outBufNumSamplesPerChannel ); + mvl2l( &tmpCrendBuffer_fx[1][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf_fx[1], outBufNumSamplesPerChannel ); + + isar_rend_CldfbSplitPostRendProcess( hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, QuaternionsPost[sf_idx], Cldfb_RealBuffer_Binaural_5ms_fx[sf_idx], Cldfb_ImagBuffer_Binaural_5ms_fx[sf_idx], Q_cldfb_final[sf_idx], tmpCrendBuffer_sf_fx, Q_out[sf_idx], isPostRendInputCldfb ); // Q_out[2] + + mvl2l( tmpCrendBuffer_sf_fx[0], &tmpCrendBuffer_fx[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvl2l( tmpCrendBuffer_sf_fx[1], &tmpCrendBuffer_fx[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + } + } + } + ELSE + { + IF( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + set_l( tmpCrendBuffer_fx[ch_idx], 0, outAudio.config.numSamplesPerChannel ); + } + } + ELSE + { + copyBufferTo2dArray_fx( splitBinInput->base.inputBuffer, tmpCrendBuffer_fx ); + } + } + + convertInternalBitsBuffToBitsBuffer( splitBinInput->hBits, bits ); + + Word16 Q_max = 0, Q_temp; + FOR( Word16 i = 0; i < num_subframes; i++ ) + { + maximum_s( Q_out[i], BINAURAL_CHANNELS, &Q_temp ); + Q_max = s_max( Q_max, Q_temp ); + } + Q_max = s_min( Q_max, Q13 ); + accumulate2dArrayToBuffer_fx( tmpCrendBuffer_fx, Q_out, Q_max, &outAudio, num_subframes, outBufNumSamplesPerChannel ); + *outAudio.q_data_fx = Q_max; + + pop_wmops(); + return error; +} + +static ivas_error renderInputSplitBin( + input_split_post_rend *splitBinInput, + const AUDIO_CONFIG outConfig, + IVAS_REND_AudioBuffer outAudio, + const Word16 SplitRendBFI, + const Word16 num_subframes ) +{ + ivas_error error; + IVAS_REND_AudioBuffer inAudio; + + inAudio = splitBinInput->base.inputBuffer; + + splitBinInput->base.numNewSamplesPerChannel = 0; + + /* Apply input gain to new audio */ + v_multc_fixed( inAudio.data_fx, + splitBinInput->base.gain_fx, + inAudio.data_fx, + inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + + SWITCH( outConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + error = renderSplitBinauralWithPostRot( splitBinInput, outAudio, SplitRendBFI, num_subframes ); + BREAK; + default: + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + return error; +} + +static ivas_error renderActiveInputsSplitBin( + ISAR_POST_REND_HANDLE hIvasRend, + IVAS_REND_AudioBuffer outAudio ) +{ + int16_t i; + input_split_post_rend *pCurrentInput; + ivas_error error; + pCurrentInput = hIvasRend->inputsSplitPost; + FOR( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + IF( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + /* Skip inactive inputs */ + ++pCurrentInput; + continue; + } + + IF( ( error = renderInputSplitBin( pCurrentInput, hIvasRend->outputConfig, outAudio, hIvasRend->splitRendBFI, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + ++pCurrentInput; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_getSamples() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_getSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +) +{ + ivas_error error; + Word16 numOutChannels; + Word16 cldfb2tdSampleFact; + + /* Validate function arguments */ + IF( hIvasRend == NULL || outAudio.data_fx == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; + + IF( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) + { + return IVAS_ERR_INVALID_BUFFER_SIZE; + } + + IF( LT_16( outAudio.config.numChannels, 0 ) || LT_16( MAX_OUTPUT_CHANNELS, outAudio.config.numChannels ) ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + IF( isar_getAudioConfigType( hIvasRend->outputConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL && + ( outAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); + } + + IF( ( error = ISAR_POST_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( numOutChannels != outAudio.config.numChannels && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + /* Clear original output buffer */ + set_l( outAudio.data_fx, 0, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); + + IF( ( error = renderActiveInputsSplitBin( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + +#ifndef DISABLE_LIMITER +#ifdef DEBUGGING + hIvasRend->numClipping += +#endif + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.q_data_fx ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.q_data_fx ); +#endif + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetSplitBinauralSamples() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_GetSplitBinauralSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + bool *needNewFrame ) +{ + ivas_error error; + + IF( ( error = ISAR_POST_REND_getSamples( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + *needNewFrame = hIvasRend->inputsSplitPost[0].numCachedSamples == 0; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_Close() + * + * + *-------------------------------------------------------------------*/ +void ISAR_POST_REND_Close( + ISAR_POST_REND_HANDLE *phIvasRend /* i/o: Pointer to renderer handle */ +) +{ + UWord16 i; + ISAR_POST_REND_HANDLE hIvasRend; + + /* Validate function arguments */ + IF( phIvasRend == NULL || *phIvasRend == NULL ) + { + return; + } + hIvasRend = *phIvasRend; + + FOR( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + clearInputSplitRend( &hIvasRend->inputsSplitPost[i] ); + } + + ivas_limiter_close_splitRend( &hIvasRend->hLimiter ); + + free( hIvasRend ); + *phIvasRend = NULL; + + return; +} + + +ivas_error ISAR_REND_SetSplitRendBitstreamHeader( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ + const int16_t codec_frame_size_ms /* i: codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, /* i: isar codec frame size setting */ + const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ +#endif +) +{ + IF( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hIvasRend->splitRenderConfig.codec = codec; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->splitRenderConfig.isar_frame_size_ms = isar_frame_size_ms; +#endif + hIvasRend->splitRenderConfig.codec_frame_size_ms = codec_frame_size_ms; + hIvasRend->splitRenderConfig.poseCorrectionMode = poseCorrection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->splitRenderConfig.lc3plus_highres = lc3plus_highres; +#endif + return IVAS_ERR_OK; +} + +#ifdef DEBUGGING +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetNoCLipping() + * + * + *-------------------------------------------------------------------*/ + +int32_t ISAR_POST_REND_GetNoCLipping( + ISAR_POST_REND_HANDLE hIvasRend ) +{ + return hIvasRend->numClipping; +} + +int32_t ISAR_POST_REND_GetCntFramesLimited( + ISAR_POST_REND_CONST_HANDLE hIvasRend ) +{ + if ( hIvasRend->hLimiter == NULL ) + { + return 0; + } + + return hIvasRend->hLimiter->cnt_frames_limited; +} +#endif + + +#endif diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h new file mode 100644 index 000000000..cc32086fa --- /dev/null +++ b/lib_isar/lib_isar_post_rend.h @@ -0,0 +1,225 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef LIB_ISAR_POST_REND_H +#define LIB_ISAR_POST_REND_H + +#include "common_api_types.h" +#include + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int32_t ISAR_POST_REND_void_func( void ); + +#else + +/*---------------------------------------------------------------------* + * Renderer constants + *---------------------------------------------------------------------*/ + +#define RENDERER_MAX_ISAR_MD_INPUTS 1 +#define RENDERER_MAX_BIN_INPUTS 1 + +/*---------------------------------------------------------------------* + * Renderer structures + *---------------------------------------------------------------------*/ + +typedef struct +{ + int32_t bufLenInBytes; + int32_t bitsWritten; + int32_t bitsRead; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; + int16_t codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + int16_t lc3plusHighRes; +#endif +} ISAR_POST_REND_BitstreamBufferConfig; + +typedef struct +{ + ISAR_POST_REND_BitstreamBufferConfig config; + uint8_t *bits; +} ISAR_POST_REND_BitstreamBuffer; + +typedef enum +{ + ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL = 0, + ISAR_POST_REND_AUDIO_CONFIG_TYPE_UNKNOWN, +} ISAR_POST_REND_AudioConfigType; + +typedef struct +{ + IVAS_REND_AudioBufferConfig config; + const Word32 *data_fx; +} ISAR_POST_REND_ReadOnlyAudioBuffer; + +typedef struct ISAR_POST_REND *ISAR_POST_REND_HANDLE; +typedef struct ISAR_POST_REND const *ISAR_POST_REND_CONST_HANDLE; + +typedef uint16_t ISAR_POST_REND_InputId; + +typedef enum _ISAR_POST_REND_COMPLEXITY_LEVEL +{ + ISAR_POST_REND_COMPLEXITY_LEVEL_ONE = 1, + ISAR_POST_REND_COMPLEXITY_LEVEL_TWO = 2, + ISAR_POST_REND_COMPLEXITY_LEVEL_THREE = 3 +} ISAR_POST_REND_COMPLEXITY_LEVEL; + + +/* clang-format off */ +/*----------------------------------------------------------------------------------* + * Renderer function prototypes + *----------------------------------------------------------------------------------*/ + +/* Functions to be called before rendering */ +ivas_error ISAR_POST_REND_open( + ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const Word32 outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const Word16 nonDiegeticPan, /* i : non-diegetic object flag */ + const Word32 nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const Word16 num_subframes /* i : number of subframes */ +); + +/* Functions to be called before/during rendering */ +ivas_error ISAR_POST_REND_NumOutChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + Word16 *numOutChannels /* o : number of output channels */ +); + +ivas_error ISAR_POST_REND_AddInput( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_AUDIO_CONFIG inConfig, /* i : audio config for a new input */ + ISAR_POST_REND_InputId *inputId /* o : ID of the new input */ +); + +ivas_error ISAR_POST_REND_SetInputGain( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const Word32 gain /* i : linear gain (not in dB) */ +); + +ivas_error ISAR_POST_REND_GetInputNumChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + Word16 *numChannels /* o : number of channels of the input */ +); +ivas_error ISAR_POST_REND_GetDelay( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + Word16 *nSamples, /* o : Renderer delay in samples */ + Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +); + +/* Functions to be called during rendering */ + +ivas_error ISAR_POST_REND_FeedInputAudio( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const ISAR_POST_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ +); + +ivas_error ISAR_POST_REND_InitConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ +); +Word16 ISAR_POST_REND_GetRenderConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + const ISAR_SPLIT_REND_CONFIG_HANDLE splitRenderConfig /* o : Render configuration handle */ +); +ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + ISAR_POST_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ +); + +ivas_error ISAR_POST_REND_GetSplitBinauralSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + bool* needNewFrame +); + +ivas_error ISAR_POST_REND_SetHeadRotation( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ + const Word16 sf_idx /* i : subframe index */ +); + +ivas_error ISAR_POST_REND_SetSplitRendBFI( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const Word16 bfi /* i: BFI flag */ +); + +ivas_error ISAR_POST_REND_getSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +); + +/* Functions to be called after rendering */ + +void ISAR_POST_REND_Close( + ISAR_POST_REND_HANDLE* phIvasRend /* i/o: Pointer to renderer handle */ +); + +ivas_error ISAR_REND_SetSplitRendBitstreamHeader( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ + const int16_t codec_frame_size_ms /* i: codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, /* i: isar frame size setting */ + const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ +#endif +); + + +#ifdef DEBUGGING +int32_t ISAR_POST_REND_GetNoCLipping( + ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ +); + +int32_t ISAR_POST_REND_GetCntFramesLimited( + ISAR_POST_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ +); +#endif + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ + +/* clang-format on */ + +#endif /* LIB_ISAR_POST_REND_H */ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c new file mode 100644 index 000000000..2149d2225 --- /dev/null +++ b/lib_isar/lib_isar_pre_rend.c @@ -0,0 +1,626 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +#include +#include "options.h" +#include +#include "ivas_prot.h" +#include "prot.h" +#include "isar_cnst.h" +#include "isar_rom_post_rend.h" +#include "lib_isar_pre_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +#ifndef SPLIT_REND_WITH_HEAD_ROT +int32_t ISAR_PRE_REND_void_func( void ) +{ + return 0; +} + +#else + +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local types + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local function prototypes + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Function ISAR_PRE_REND_open() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_PRE_REND_open( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const Word32 OutSampleRate, + const Word16 cldfb_in_flag, + const Word16 pcm_out_flag, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ +#else + const int16_t num_subframes, /* i: number of subframes */ +#endif + const int16_t mixed_td_cldfb_flag ) +{ + ivas_error error, ch, num_ch; + UWord8 isCldfbNeeded = 0; + Word16 cldfb_in_flag_local = cldfb_in_flag; + + if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + &pSplitRendConfig->isar_frame_size_ms, +#endif + &pSplitRendConfig->codec_frame_size_ms, + cldfb_in_flag_local, + pcm_out_flag, (int16_t) +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_frame_size +#else + num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( mixed_td_cldfb_flag ) + { + cldfb_in_flag_local = 0; + } + + IF( ( error = isar_split_rend_validate_config( pSplitRendConfig, pcm_out_flag ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( EQ_16( cldfb_in_flag_local, 0 ) ) + { + isCldfbNeeded = 1; + } + ELSE IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) && cldfb_in_flag_local ) + { + isCldfbNeeded = 1; + } + ELSE IF( pcm_out_flag && cldfb_in_flag_local ) + { + isCldfbNeeded = 1; + } + + hSplitRendWrapper->hCldfbHandles = NULL; + + IF( isCldfbNeeded ) + { + IF( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + FOR( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } + + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + FOR( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), + CLDFB_ANALYSIS, + OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + IF( EQ_16( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + if ( ( error = isar_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + OutSampleRate +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + IF( EQ_16( pcm_out_flag, 0 ) ) + { + IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) + { + if ( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_frame_size +#else + num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + Word16 iNumBlocksPerFrame; + iNumBlocksPerFrame = ( CLDFB_NO_COL_MAX * pSplitRendConfig->codec_frame_size_ms ) / 20; + + IF( ( error = isar_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ), iNumBlocksPerFrame, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * Function ISAR_PRE_REND_close() + * + * + *------------------------------------------------------------------------*/ +void ISAR_PRE_REND_close( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ +) +{ + Word16 i; + + IF( hSplitBinRend->hBinHrSplitPreRend != NULL ) + { + isar_splitBinPreRendClose( &hSplitBinRend->hBinHrSplitPreRend ); + } + + IF( hSplitBinRend->hSplitBinLCLDEnc != NULL ) + { + isar_splitBinLCLDEncClose( &hSplitBinRend->hSplitBinLCLDEnc ); + } + + IF( hSplitBinRend->hCldfbHandles != NULL ) + { + Word16 num_ch, ch; + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + FOR( ch = 0; ch < num_ch; ch++ ) + { + IF( hSplitBinRend->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitBinRend->hCldfbHandles->cldfbAna[ch] ); + hSplitBinRend->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitBinRend->hCldfbHandles->cldfbSyn[ch] ); + hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } +#endif + + free( hSplitBinRend->hCldfbHandles ); + hSplitBinRend->hCldfbHandles = NULL; + } + + IF( hSplitBinRend->hLc3plusEnc != NULL ) + { + ISAR_LC3PLUS_ENC_Close( &hSplitBinRend->hLc3plusEnc ); + } + + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + IF( hSplitBinRend->lc3plusDelayBuffers[i] != NULL ) + { + free( hSplitBinRend->lc3plusDelayBuffers[i] ); + hSplitBinRend->lc3plusDelayBuffers[i] = NULL; + } + if ( hSplitBinRend->lc3plusDelayBuffers_fx[i] != NULL ) + { + free( hSplitBinRend->lc3plusDelayBuffers_fx[i] ); + hSplitBinRend->lc3plusDelayBuffers_fx[i] = NULL; + } + } + + IF( pSplitRendEncBuffer != NULL ) + { + + IF( pSplitRendEncBuffer->data != NULL ) + { + free( pSplitRendEncBuffer->data ); + pSplitRendEncBuffer->data = NULL; + } + + pSplitRendEncBuffer->config.numChannels = 0; + pSplitRendEncBuffer->config.numSamplesPerChannel = 0; + } + + return; +} + + +/*-------------------------------------------------------------------------* + * ISAR_PRE_REND_GetMultiBinPoseData() + * + * + *-------------------------------------------------------------------------*/ + +void ISAR_PRE_REND_GetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ +) +{ + isar_renderSplitGetMultiBinPoseData_fx( pSplit_rend_config, pMultiBinPoseData, rot_axis ); +} + +/*------------------------------------------------------------------------- + * Function ISAR_PRE_REND_MultiBinToSplitBinaural() + * + * + *------------------------------------------------------------------------*/ +ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const Word32 SplitRendBitRate, + ISAR_SPLIT_REND_CODEC splitCodec, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const Word16 isar_frame_size_ms, /* i: ISAR framesize */ +#endif + Word16 codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 max_bands, + float *output[], + Word32 *pOutput_fx[], + const Word16 low_res_pre_rend_rot, + const Word16 cldfb_in_flag, + const Word16 pcm_out_flag, + const Word16 ro_md_flag, + Word16 Q_buff, + Word16 *Q_out ) +{ + ivas_error error; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t bit_len, target_md_bits, available_bits, tmp_32; +#else + Word32 bit_len, target_md_bits, actual_md_bits, available_bits, tmp_32; +#endif + Word16 q1 = 31, q2 = 31, q_final, Q_cldfb, tmp, tmp_e; + Word16 i, j; + error = IVAS_ERR_OK; + Word16 Q_buff_re, Q_buff_im; + push_wmops( "ISAR_PRE_REND_MultiBinToSplitBinaural" ); +#ifdef CLDFB_SYNTH_DEBUG + /* FILE *fp = fopen( "Fixed_code_output.txt", "ab+" ); + FILE *fp1 = fopen( "Fixed_code_cldfb_state.txt", "ab+" ); + FILE *fp = fopen( "Float_code_output.txt", "ab+" ); + FILE *fp1 = fopen( "Float_code_cldfb_state.txt", "ab+" );*/ +#endif + output; + Q_buff_re = Q_buff; + move16(); + Q_buff_im = Q_buff; + move16(); + IF( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + set_fix_rotation_mat_fx( hSplitBin->hBinHrSplitPreRend->fix_pos_rot_mat_fx, &hSplitBin->multiBinPoseData ); + set_pose_types_fx( hSplitBin->hBinHrSplitPreRend->pose_type, &hSplitBin->multiBinPoseData ); + } + + IF( EQ_16( cldfb_in_flag, 0 ) ) + { + error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + isar_frame_size_ms, +#endif + codec_frame_size_ms, pBits, max_bands, pOutput_fx, Q_out[0], low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); + + pop_wmops(); + return error; + } + + IF( splitCodec == ISAR_SPLIT_REND_CODEC_LC3PLUS && hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + /* Time-align pose correction to delay of LC3plus */ + lc3plusTimeAlignCldfbPoseCorr( hSplitBin, Cldfb_In_BinReal_fx, Cldfb_In_BinImag_fx, &Q_buff ); + Q_buff_re = Q_buff; + move16(); + Q_buff_im = Q_buff; + move16(); + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + IF( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + /*float2fix, to be removed*/ + Word16 Q_Cldfb_re = 31, Q_Cldfb_im = 31; + move16(); + move16(); + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Q_Cldfb_re = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX ), Q_Cldfb_re ); + Q_Cldfb_im = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX ), Q_Cldfb_im ); + } + } + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX, Q_Cldfb_re ); + Scale_sig32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX, Q_Cldfb_im ); + } + } + Q_buff_re = add( Q_Cldfb_re, Q_buff ); + Q_buff_im = add( Q_Cldfb_im, Q_buff ); + Word16 exp_cldfb_re = sub( 31, Q_buff_re ); + Word16 exp_cldfb_im = sub( 31, Q_buff_im ); + isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal_fx, exp_cldfb_re, Cldfb_In_BinImag_fx, exp_cldfb_im, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); + } + + IF( EQ_16( pcm_out_flag, 0 ) ) + { + pBits->codec = splitCodec; + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + + IF( splitCodec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + // available_bits = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); + available_bits = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); + available_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits = L_sub( available_bits, pBits->bits_written ); +#else + actual_md_bits = L_sub( pBits->bits_written, actual_md_bits ); + available_bits = L_sub( available_bits, actual_md_bits ); +#endif + pBits->codec_frame_size_ms = codec_frame_size_ms; + q_final = sub( s_min( Q_buff_re, Q_buff_im ), 2 ); + FOR( i = 0; i < hSplitBin->hSplitBinLCLDEnc->iChannels; i++ ) + { + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); + Scale_sig32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); + } + } + isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal_fx, Cldfb_In_BinImag_fx, available_bits, pBits, &q_final ); + Q_buff_re = q_final; + move16(); + Q_buff_im = q_final; + move16(); + } + ELSE + { + Word16 ch, slot_idx, num_slots, ivas_fs; + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us, 1000, &tmp_e ); + ivas_fs = shr( tmp, sub( 15, tmp_e ) ); // Q0 + // ivas_fs = (Word16) hSplitBin->hLc3plusEnc->config.ivas_frame_duration_us / 1000; + + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( L_mult0( CLDFB_NO_COL_MAX, ivas_fs ), 20, &tmp_e ); + num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 + // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs / 20; + /* CLDFB synthesis of main pose */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Word32 *Cldfb_In_BinReal_p_fx[CLDFB_NO_COL_MAX]; + Word32 *Cldfb_In_BinImag_p_fx[CLDFB_NO_COL_MAX]; + q1 = 31; + q2 = 31; + move16(); + move16(); + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); + q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); + } + q_final = s_min( q1, q2 ); + q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); + q_final = sub( q_final, 3 ); // guard bits + q_final = s_min( q_final, Q25 ); + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); + Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); + } + + FOR( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + Cldfb_In_BinReal_p_fx[slot_idx] = Cldfb_In_BinReal_fx[ch][slot_idx]; + move32(); + Cldfb_In_BinImag_p_fx[slot_idx] = Cldfb_In_BinImag_fx[ch][slot_idx]; + move32(); + } + + Q_cldfb = q_final; + move16(); + Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split ) ); + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + Q_out[ch] = sub( Q_cldfb, 1 ); + move16(); + hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split = Q_out[ch]; + move16(); + fixedToFloat_arrL( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state, hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; + IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, pOutput_fx, Q_out[0] ) ) != IVAS_ERR_OK ) +#else + IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, pOutput_fx ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + } + } + ELSE + { + Word16 ch, slot_idx; + /* CLDFB synthesis of main pose */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Word32 *Cldfb_In_BinReal_p_fx[CLDFB_NO_COL_MAX]; + Word32 *Cldfb_In_BinImag_p_fx[CLDFB_NO_COL_MAX]; + q1 = 31; + move16(); + q2 = 31; + move16(); + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); + q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); + } + q_final = s_min( q1, q2 ); + q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); + q_final = sub( q_final, 3 ); // guard bits + q_final = s_min( q_final, Q25 ); + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); + Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); + } + + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + Cldfb_In_BinReal_p_fx[slot_idx] = Cldfb_In_BinReal_fx[ch][slot_idx]; + move32(); + Cldfb_In_BinImag_p_fx[slot_idx] = Cldfb_In_BinImag_fx[ch][slot_idx]; + move32(); + } + + Q_cldfb = q_final; + move16(); + Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split ) ); + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + Q_out[ch] = sub( Q_cldfb, 1 ); + move16(); + hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split = Q_out[ch]; + move16(); + } + + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec = ISAR_SPLIT_REND_CODEC_NONE; + } + + /*zero pad*/ + IF( pcm_out_flag ) + { + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( SplitRendBitRate, FRAMES_PER_SEC, &tmp_e ); + bit_len = L_deposit_l( shr( tmp, sub( 15, tmp_e ) ) ); // Q0 + // bit_len = SplitRendBitRate / FRAMES_PER_SEC; + } + ELSE + { + IF( splitCodec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + // bit_len = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); + + bit_len = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); + bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 + } + ELSE + { + tmp_e = 0; + tmp = BASOP_Util_Divide3232_Scale( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us, 1000, &tmp_e ); + bit_len = L_deposit_l( shr( tmp, sub( 15, tmp_e ) ) ); // Q0 + // bit_len = hSplitBin->hLc3plusEnc->config.ivas_frame_duration_us / 1000; + // bit_len = SplitRendBitRate * bit_len / 1000; + tmp_e = 0; + tmp_32 = BASOP_Util_Divide3232_Scale_cadence( W_extract_l( W_mult0_32_32( SplitRendBitRate, bit_len ) ), 1000, &tmp_e ); + bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 + } + } + + WHILE( LT_32( pBits->bits_written, bit_len ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0L, 1 ); + } + + pop_wmops(); + /* fclose(fp); + fclose(fp1);*/ + return error; +} + +#endif diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h new file mode 100644 index 000000000..fe64e4911 --- /dev/null +++ b/lib_isar/lib_isar_pre_rend.h @@ -0,0 +1,92 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef LIB_ISAR_PRE_REND_H +#define LIB_ISAR_PRE_REND_H + +#include "isar_stat.h" +#include "isar_prot.h" + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int32_t ISAR_PRE_REND_void_func( void ); + +#else +ivas_error ISAR_PRE_REND_open( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + const int32_t output_Fs, /* i: output sampling rate */ + const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ +#else + const int16_t num_subframes, /* i: number of subframes */ +#endif + const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ +); + +void ISAR_PRE_REND_close( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ +); + +void ISAR_PRE_REND_GetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ +); + +ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ + const Word32 SplitRendBitRate, /* i: Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const Word16 isar_frame_size_ms, /* i: ISAR framesize */ +#endif + Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const Word16 max_bands, /* i: CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + Word32 *pOutput_fx[], /* i: low time resolution pre-renderer flag */ + const Word16 low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ + const Word16 cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ + const Word16 pcm_out_flag, /* i: Flag to indicate PCM output */ + const Word16 ro_md_flag, /* i: Flag to indicate real only metadata for yaw */ + Word16 Q_buff, + Word16 *Q_out ); + +#endif +#endif /* LIB_ISAR_PRE_REND_H */ diff --git a/lib_lc3plus/.clang-format b/lib_lc3plus/.clang-format new file mode 100644 index 000000000..47a38a93f --- /dev/null +++ b/lib_lc3plus/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/lib_lc3plus/adjust_global_gain_fx.c b/lib_lc3plus/adjust_global_gain_fx.c new file mode 100644 index 000000000..c6067b591 --- /dev/null +++ b/lib_lc3plus/adjust_global_gain_fx.c @@ -0,0 +1,186 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + + + +void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx_off, +#ifdef ENABLE_HR_MODE + Word32 *gain, +#else + Word16 *gain, +#endif + Word16 *gain_e, + Word16 target, Word16 nBits, Word16 *gainChange, Word16 fs_idx +#ifdef ENABLE_HR_MODE + , Word16 hrmode, Word16 frame_dms +#endif + ) +{ + + Word32 L_tmp; + Word16 delta, delta2; +#ifdef ENABLE_HR_MODE + Word16 gg_idx_inc; + Word16 gg_idx_inc_max; + Word16 gg_idx_inc_s; +# ifdef CR8_G_ADD_75MS + Word32 factor; +# else + Word16 factor; +# endif +#endif + +#ifdef DYNMEM_COUNT +#if defined(ENABLE_HR_MODE) + Dyn_Mem_In("processAdjustGlobalGain_fx", sizeof(struct { + Word32 L_tmp; + Word16 delta, delta2; + Word16 gg_idx_inc; + Word16 gg_idx_inc_max; + Word16 gg_idx_inc_s; + Word16 factor; + })); +#else + Dyn_Mem_In("processAdjustGlobalGain_fx", sizeof(struct { + Word32 L_tmp; + Word16 delta, delta2; + })); +#endif /* ENABLE_HR_MODE */ +#endif /* DYNMEM_COUNT */ + +#ifdef ENABLE_HR_MODE + IF (sub(frame_dms, 25) == 0) + { + IF (sub(target, 520) < 0) + { + factor = 3; move16(); + gg_idx_inc_max = 30; move16(); + } ELSE { + factor = 4; move16(); + gg_idx_inc_max = 40; move16(); + } + } + ELSE IF (sub(frame_dms, 50) == 0) + { + factor = 2; move16(); + gg_idx_inc_max = 20; move16(); + } +#ifdef CR8_G_ADD_75MS + ELSE IF (sub(frame_dms, 75) == 0) + { + factor = 40265318; move16(); // factor = 1.2 * 2^25 + gg_idx_inc_max = 12 ; move16(); + } +#endif + ELSE + { + factor = 1; move16(); + gg_idx_inc_max = 10; move16(); + } +#endif + + IF (sub(nBits, adjust_global_gain_tables[0][fs_idx]) < 0) + { + delta = mult_r(add(nBits, 48), 2048); + } + ELSE IF (sub(nBits, adjust_global_gain_tables[1][fs_idx]) < 0) + { + delta = mult_r(add(nBits, adjust_global_gain_tables[4][fs_idx]), adjust_global_gain_tables[3][fs_idx]); + } + ELSE IF (sub(nBits, adjust_global_gain_tables[2][fs_idx]) < 0) + { + delta = mult_r(nBits, 683); + } + ELSE + { + delta = mult_r(adjust_global_gain_tables[2][fs_idx], 683); + } + delta2 = add(delta, 2); + + *gainChange = 0; move16(); + + test(); + IF (sub(*gg_idx, 255) == 0 && sub(nBits, target) > 0) + { + *gainChange = 1; move16(); + } + + test(); test(); test(); + IF ((sub(*gg_idx, 255) < 0 && sub(nBits, target) > 0) || (*gg_idx > 0 && sub(nBits, sub(target, delta2)) < 0)) + { +#ifdef ENABLE_HR_MODE + IF (hrmode) + { + IF (sub(nBits, target) > 0) + { + gg_idx_inc = sub(nBits, target); +#ifdef CR8_G_ADD_75MS + IF (sub(frame_dms, 75) == 0) + { + gg_idx_inc = extract_l(L_shr_pos(Mpy_32_16_lc3plus(factor, gg_idx_inc), 10)); // Mpy_32_16_lc3plus(1.2*2^25, gg_idx_inc), 25 - 15) + gg_idx_inc = BASOP_Util_Divide1616_Scale_lc3plus(gg_idx_inc, delta, &gg_idx_inc_s); + gg_idx_inc = shr_sat(gg_idx_inc, sub(15, gg_idx_inc_s)); + gg_idx_inc = add(gg_idx_inc, 1); // adding 1 instead of 1.2 + } + ELSE +#endif + { + gg_idx_inc = extract_l(L_mult0(gg_idx_inc, factor)); + gg_idx_inc = BASOP_Util_Divide1616_Scale_lc3plus(gg_idx_inc, delta, &gg_idx_inc_s); + gg_idx_inc = shr_sat(gg_idx_inc, sub(15, gg_idx_inc_s)); + gg_idx_inc = add(gg_idx_inc, factor); + } + gg_idx_inc = s_min(gg_idx_inc, gg_idx_inc_max); + + *gg_idx = add(*gg_idx, gg_idx_inc); move16(); + } + + *gg_idx = s_min(*gg_idx, 255); move16(); + } + ELSE +#endif + { + test(); + IF (sub(nBits, sub(target, delta2)) < 0) + { + *gg_idx = sub(*gg_idx, 1); move16(); + } + ELSE IF (sub(*gg_idx, 254) == 0 || sub(nBits, add(target, delta)) < 0) + { + *gg_idx = add(*gg_idx, 1); move16(); + } + ELSE + { + *gg_idx = add(*gg_idx, 2); move16(); + } + } + + *gg_idx = s_max(*gg_idx, sub(gg_idx_min, gg_idx_off)); move16(); + +#ifdef ENABLE_HR_MODE + L_tmp = Mpy_32_16_lc3plus(0x3CBE6B83, L_shl_pos(add(*gg_idx, gg_idx_off), 7)); +#else + L_tmp = L_shl_pos(L_mult0(add(*gg_idx, gg_idx_off), 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ +#endif + *gain_e = add(extract_l(L_shr_pos(L_tmp, 25)), 1); /* get exponent */ +#ifdef ENABLE_HR_MODE + *gain = BASOP_Util_InvLog2_lc3plus(L_or(L_tmp, (Word32)0xFE000000)); +#else + *gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(L_tmp, (Word32)0xFE000000))); +#endif + *gainChange = 1; move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/al_fec.c b/lib_lc3plus/al_fec.c new file mode 100644 index 000000000..7579a21b0 --- /dev/null +++ b/lib_lc3plus/al_fec.c @@ -0,0 +1,2379 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" + + +#include "functions.h" +#include "rom_basop_util.h" +#include +#include +#include +#include + +/* channel coder specific constants and macros */ +#define RS16_CW_LEN_MAX 15 + +#define FEC_N_MODES 4 +#define FEC_N_SYNDROMES_MAX 6 +#define FEC_N_ERR_POS_MAX 3 +#define FEC_N_ELP_COEFF_MAX 4 +#define FEC_N_ERR_SYMB_MAX 3 +#define FEC_N_MODE_DETECTION_CW 6 + +#define SYNDROME_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_SYNDROMES_MAX) +#define ELP_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ELP_COEFF_MAX) +#define ERR_POS_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_POS_MAX) +#define ERR_SYMB_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_SYMB_MAX) +#define DEG_ELP_IDX(mode_index, cw_index) ((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) + +#define FEC_TOTAL_SYNDROME_SIZE (FEC_N_SYNDROMES_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ELP_SIZE (FEC_N_ELP_COEFF_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ERR_POS_SIZE (FEC_N_ERR_POS_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ERROR_SIZE (FEC_N_ERR_SYMB_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_DEG_ELP_SIZE (FEC_N_MODES * FEC_N_MODE_DETECTION_CW) + +#define ERROR_REPORT_BEC_MASK ((0x0FFF)>>1) +#define ERROR_REPORT_EP1_OK ((0x1000)>>1) +#define ERROR_REPORT_EP2_OK ((0x2000)>>1) +#define ERROR_REPORT_EP3_OK ((0x4000)>>1) +#define ERROR_REPORT_EP4_OK ((0x8000)>>1) +#define ERROR_REPORT_ALL_OK (ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK) + +/* debugging switches */ + +/* constants concerning mode detection */ +#define EP_RISK_THRESH_NS_M 21990 +#define EP_RISK_THRESH_NS_E -23 +#define EP_RISK_THRESH_OS_M 25166 +#define EP_RISK_THRESH_OS_E -10 + +#define SIMPLE_FLOAT_1_MANTISSA 16384 + +#define FEC_STATIC static + +/* DISCLAIMER: Strict instrumentation of GF16 arithmetic would have to take into account + * the initial conversion of the arguments from UWord8 to Word16 (one move16() per argument). + * Behind this is the assumption that one would store GF16 elements in Word16 for strict BASOP + * implementation. + */ + +#define GF16_MUL(a, b) (UWord8)(move16(), gf16_mult_table[s_or((a), shl((b), 4))]) +#define GF16_MUL0(a, b) (UWord8)(move16(), gf16_mult_table[s_or((a), (b))]) +#define GF16_ADD(a, b) (UWord8) s_xor((a), (b)) + +/* tables for finite field arithmetic */ +/* tables for arithmetic in GF(16) * + * generator polynomial: 19 + * unit group generator (g): 2 + */ + +static const UWord8 gf16_g_pow[16] = {1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1}; +/* g_pow[i] contains g^i*/ + +static const UWord8 gf16_log_g[16] = {255, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12}; +/* log_g[n] contains contains the value i such that g^i = n for n=1, 2, ..., 15, log_g[0] is set to 255 */ + +static const UWord8 gf16_inv_table[16] = {255, 1, 9, 14, 13, 11, 7, 6, 15, 2, 12, 5, 10, 4, 3, 8}; +/* gf16_inv_table[n] contains the multiplicative inverse of n in GF(16) (1/0 is set to 255)*/ + +/* RS16 generating polynomials (from lowest to highest coefficient without leading 1)*/ + +static const UWord8 rs16_gp_d3[] = {8, 6}; +static const UWord8 rs16_gp_d5[] = {7, 8, 12, 13}; +static const UWord8 rs16_gp_d7[] = {12, 10, 12, 3, 9, 7}; + +/* FEC mode signaling polynomials */ + +#define EP_SIG_POLY_DEG 12 + +static const UWord8 sig_polys[4][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {7, 15, 5, 6, 14, 9, 1, 3, 12, 10, 13, 3, 2, 0, 0}, + {7, 11, 14, 1, 2, 3, 12, 11, 6, 15, 7, 6, 12, 0, 0}, + {6, 15, 12, 2, 9, 15, 2, 8, 12, 3, 10, 5, 4, 0, 0}}; + +static const UWord8 sig_poly_syndr[4][6] = { + {0, 0, 0, 0, 0, 0}, {0, 4, 5, 11, 5, 8}, {0, 5, 9, 0, 1, 7}, {0, 12, 5, 12, 9, 8}}; + +/* bit count table for error report (0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111) */ + +static const UWord8 rs16_bit_count_table[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; + +/* List of RS16 generators by Hamming distance */ + +static const UWord8 *const rs16_gp_by_hd[8] = {NULL, NULL, NULL, rs16_gp_d3, NULL, rs16_gp_d5, NULL, rs16_gp_d7}; + +/* fec config data */ + +static const UWord8 hamming_distance_by_mode0[] = {1, 3, 3, 5, 7}; +static const UWord8 hamming_distance_by_mode1[] = {1, 1, 3, 5, 7}; + +static const UWord8 crc1_bytes_by_mode0[] = {0, 3, 2, 2, 2}; +static const UWord8 crc1_bytes_by_mode1[] = {0, 3, 3, 3, 3}; +static const UWord8 crc2_bytes_by_mode[] = {0, 0, 2, 2, 2}; + +/* fec mode risk table */ +typedef struct +{ + UWord32 mantissa; + Word16 exponent; +} simple_float; + +static const simple_float risk_table_f[4][4] = {{{16384, 0}, {16384, 0}, {16384, 0}, {16384, 0}}, + {{16384, -8}, {26880, -1}, {16384, 0}, {16384, 0}}, + {{16384, -16}, {26880, -9}, {20475, -2}, {16384, 0}}, + {{16384, -24}, {26880, -17}, {20475, -10}, {19195, -4}}}; +/* bit error limits for slot size 40 */ +static Word16 const low_br_max_bit_errors_by_mode[] = {0, 0, 3, 9, 18}; + +/* +corresponding float values: + {1.f, 1.f, 1.f, 1.f}, + {0.00390625f, 0.820312f, 1.f, 1.f}, + {1.52588e-05f, 0.00320435f, 0.312424f, 1.f}, + {5.96046e-08f, 1.2517e-05f, 0.00122041f, 0.0732243f} +*/ + +/* internal encoder routines */ + +FEC_STATIC void fec_interleave_pack(UWord8 *out, UWord8 *in, Word16 n_nibbles, Word16 n_codewords); + +FEC_STATIC void rs16_enc(UWord8 *iobuf, Word16 codeword_length, Word16 hamming_distance, Word16 fec_mode, + Word16 signal_mode); + +/* internal decoder routines */ + +FEC_STATIC void fec_deinterleave_unpack(UWord8 *out, UWord8 *in, Word16 n_nibbles, Word16 n_codewords); + +FEC_STATIC Word16 fec_data_preproc(Word16 mode, Word16 epmr, UWord8 *iobuf, UWord8 *cw_buf, Word16 data_bytes, + Word16 slot_bytes, Word16 pc_split); + +FEC_STATIC void fec_data_postproc(Word16 mode, Word16 *epmr, UWord8 *iobuf, Word16 data_bytes, UWord8 *cw_buf, + Word16 slot_bytes, Word16 pc_split, int *bfi); + +FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codewords, Word16 *epmr, Word16 *error_report, + int *bfi, UWord8 *array_of_trust, int ccc_flag_flag, Word16 *n_pccw, void *scratch); + +FEC_STATIC void rs16_calculate_six_syndromes(UWord8 *syndromes, UWord8 *cw, int cw_poly_deg); + +FEC_STATIC void rs16_calculate_four_syndromes(UWord8 *syndromes, UWord8 *cw, int cw_poly_deg); + +FEC_STATIC void rs16_calculate_two_syndromes(UWord8 *syndromes, UWord8 *cw, int cw_poly_deg); + +FEC_STATIC Word8 rs16_calculate_elp(UWord8 *elp, UWord8 *syndromes, Word16 hamming_distance); + +FEC_STATIC Word16 rs16_factorize_elp(UWord8 *error_locations, UWord8 *elp, Word16 deg_elp, Word16 max_pos); + +FEC_STATIC void rs16_calculate_errors(UWord8 *errors, UWord8 *err_pos, UWord8 *syndromes, Word8 deg_elp, Word8 t); + +/* auxiliary routines */ + +FEC_STATIC Word16 crc1(UWord8 *data, Word16 data_size, Word16 epmr, UWord8 *hash, Word16 hash_size, Word16 check); + +FEC_STATIC Word16 fec_estimate_epmr_from_cw0(UWord8 *cw0, Word8 *t, UWord8 *syndromes, UWord8 *elp, Word8 *deg_elp, + UWord8 *err_pos, UWord8 *err_symb, Word16 n_codewords, Word16 n_symb); + +FEC_STATIC void dw0_bitswap(UWord8 *dw0, Word16 mode, Word16 slot_bytes); + +FEC_STATIC Word16 cw0_get_epmr(UWord8 *cw0, Word16 epmr_position); + +FEC_STATIC Word16 dw0_get_epmr(UWord8 *dw0, Word16 mode, Word16 slot_size); + +FEC_STATIC Word16 crc2(UWord8 *data, Word16 data_size, UWord8 *hash, Word16 hash_size, Word16 check); + +FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2); + +FEC_STATIC Word16 simple_float_cmp(simple_float op1, simple_float op2); + +FEC_STATIC Word16 get_total_crc_size(Word16 slot_bytes, Word16 fec_mode, Word16 pc_split); + +FEC_STATIC Word16 get_n_codewords(Word16 slot_bytes); + +FEC_STATIC Word16 get_codeword_length(Word16 n_codewords, Word16 slot_nibbles, Word16 codeword_index); + + + +Word16 fec_get_n_pccw(Word16 slot_bytes, Word16 fec_mode, Word16 ccc_flag) +{ + Dyn_Mem_Deluxe_In( + Word16 n_pccw; + ); + + IF (sub(fec_mode, 3) == 0) + { + n_pccw = round_fx(L_sub(L_mult(2636, slot_bytes), 117377)); + } + ELSE IF (sub(fec_mode, 4) == 0) + { + n_pccw = round_fx(L_sub(L_mult(2178, slot_bytes), 129115)); + } + ELSE + { + n_pccw = 0; move16(); + } + + if (ccc_flag == 1 || sub(slot_bytes, 80) < 0) + { + n_pccw = 0; move16(); + } + + Dyn_Mem_Deluxe_Out(); + return n_pccw; +} + +FEC_STATIC Word16 get_total_crc_size(Word16 slot_bytes, Word16 fec_mode, Word16 pc_split) +{ + Dyn_Mem_Deluxe_In( + Word16 n_crc; + ); + + n_crc = crc1_bytes_by_mode1[fec_mode]; move16(); + if (sub(slot_bytes, 40) == 0) + { + n_crc = crc1_bytes_by_mode0[fec_mode]; move16(); + } + + IF (pc_split > 0) + { + n_crc = add(n_crc, crc2_bytes_by_mode[fec_mode]); + } + Dyn_Mem_Deluxe_Out(); + return n_crc; +} + +FEC_STATIC Word16 get_n_codewords(Word16 slot_bytes) +{ + Dyn_Mem_Deluxe_In( + Word16 i; + ); + + slot_bytes = shl(slot_bytes, 1); + + FOR (i = 0; slot_bytes > 0; i++) + { + slot_bytes = sub(slot_bytes, RS16_CW_LEN_MAX); + } + + Dyn_Mem_Deluxe_Out(); + return i; +} + +FEC_STATIC Word16 get_codeword_length(Word16 n_codewords, Word16 slot_nibbles, Word16 codeword_index) +{ + Dyn_Mem_Deluxe_In( + Word16 i; + ); + + slot_nibbles = sub(slot_nibbles, add(codeword_index, 1)); + slot_nibbles = sub(slot_nibbles, DEPR_i_mult(n_codewords, 13)); + + FOR (i = 12; slot_nibbles >= 0; i++) + { + slot_nibbles = sub(slot_nibbles, n_codewords); + } + + Dyn_Mem_Deluxe_Out(); + return add(i, 1); +} + +/* Encoder */ + +Word16 fec_get_data_size(Word16 fec_mode, Word16 ccc_flag, Word16 slot_bytes) +/* not time critical */ +{ + Dyn_Mem_Deluxe_In( + Word16 n_codewords, payload_size; + ); + + n_codewords = get_n_codewords(slot_bytes); + + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + payload_size = slot_bytes; move16(); + + IF (fec_mode > 0) + { + IF (fec_mode == 1) + { + payload_size = sub(payload_size, 1); + } + ELSE + { + payload_size = sub(payload_size, DEPR_i_mult(sub(fec_mode, 1), n_codewords)); + } + IF (slot_bytes == 40) + { + payload_size = sub(payload_size, crc1_bytes_by_mode0[fec_mode]); move16(); + } + ELSE + { + payload_size = sub(payload_size, crc1_bytes_by_mode1[fec_mode]); move16(); + } + + IF (ccc_flag == 0 && fec_mode > 2 && slot_bytes >= 80) + { + payload_size = sub(payload_size, crc2_bytes_by_mode[fec_mode]); + } + } + + Dyn_Mem_Deluxe_Out(); + return payload_size; +} + +Word16 fec_get_n_pc(Word16 fec_mode, Word16 n_pccw, Word16 slot_bytes) +/* not time critical */ +{ + Dyn_Mem_Deluxe_In( + Word16 n_codewords, pc_split, tmp; + int i; + ); + + n_codewords = get_n_codewords(slot_bytes); + + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + pc_split = DEPR_i_mult(DEPR_i_mult(n_pccw, -2), sub(fec_mode, 1)); + + IF (fec_mode == 1 || slot_bytes < 80) + { + pc_split = 0; move16(); + } + ELSE + { + FOR (i = 0; i < n_pccw; i++) + { + tmp = get_codeword_length(n_codewords, add(slot_bytes, slot_bytes), sub(n_codewords, i + 1)); + assert(tmp == (2 * slot_bytes + i) / n_codewords); + pc_split = add(pc_split, tmp); + } + } + + Dyn_Mem_Deluxe_Out(); + return pc_split; +} + +/* functions for EPMR handling */ +FEC_STATIC void dw0_bitswap(UWord8 *dw0, Word16 mode, Word16 slot_bytes) +/* swap epmr bits with bits that will be positioned at 30 and 32 in code word 0 */ +{ + Dyn_Mem_Deluxe_In( + UWord8 tmp; + int ind0, ind1, position; + ); + + position = sub(get_codeword_length(get_n_codewords(slot_bytes), shl(slot_bytes, 1), 0), 1); + + IF (sub(slot_bytes, 40) == 0) + { + ind0 = sub(shl(crc1_bytes_by_mode0[mode], 1), 1); + } + ELSE + { + ind0 = sub(shl(crc1_bytes_by_mode1[mode], 1), 1); + } + + ind1 = sub(position, sub(hamming_distance_by_mode0[mode], 1)); + + /* swap bits 2 and 3 of dw0[ind0] with bits 0 and 1 of dw0[ind1] */ + tmp = (UWord8) s_and(shr(dw0[ind0],2), 3); + dw0[ind0] = (UWord8) s_and(dw0[ind0], 3); + dw0[ind0] = (UWord8) s_or(dw0[ind0], shl(s_and(dw0[ind1], 3),2)); + dw0[ind1] = (UWord8) s_and(dw0[ind1], 12); + dw0[ind1] = (UWord8) s_or(dw0[ind1], tmp); + + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC Word16 cw0_get_epmr(UWord8 *cw0, Word16 position) +{ + Dyn_Mem_Deluxe_In( + Word16 epmr; + ); + epmr = s_and(cw0[position], 3); + + Dyn_Mem_Deluxe_Out(); + return epmr; +} + +FEC_STATIC Word16 dw0_get_epmr(UWord8 *dw0, Word16 mode, Word16 slot_size) +{ + Dyn_Mem_Deluxe_In( + int ncrc1; + Word16 epmr; + ); + + ncrc1 = crc1_bytes_by_mode1[mode]; + + if (sub(slot_size, 40) == 0) + { + ncrc1 = crc1_bytes_by_mode0[mode]; + } + + epmr = shr(dw0[2 * ncrc1 - 1], 2); + + Dyn_Mem_Deluxe_Out(); + return epmr; +} + + +FEC_STATIC Word16 fec_data_preproc(Word16 mode, Word16 epmr, UWord8 *iobuf, UWord8 *cw_buf, Word16 data_bytes, + Word16 slot_bytes, Word16 pc_split) +{ + Dyn_Mem_Deluxe_In( + Word16 data_offset, n_crc1, n_crc2, tmp; + int i, j; + ); + + tmp = sub(slot_bytes, data_bytes); + data_offset = add(tmp, tmp); + + /* extract and reverse data*/ + j = sub(add(slot_bytes, slot_bytes), 1); + FOR (i = 0; i < data_bytes; i++) + { + cw_buf[j--] = (UWord8)s_and(iobuf[i], 15); move16(); + cw_buf[j--] = (UWord8)shr(iobuf[i], 4); move16(); + } + + /* add crc hashes */ + IF (sub(slot_bytes, 40) == 0) + { + n_crc1 = crc1_bytes_by_mode0[mode]; move16(); + } + ELSE + { + n_crc1 = crc1_bytes_by_mode1[mode]; move16(); + } + + IF (pc_split > 0 && sub(mode, 1) > 0) + { + n_crc2 = crc2_bytes_by_mode[mode]; move16(); + } + ELSE + { + n_crc2 = 0; move16(); + } + + IF (n_crc2) + { + crc2(cw_buf + data_offset + 2 * data_bytes - pc_split, pc_split, cw_buf + data_offset - 2 * n_crc2, n_crc2, 0); + } + IF (n_crc1) + { + crc1(cw_buf + data_offset, 2 * data_bytes - pc_split, epmr, cw_buf + data_offset - 2 * (n_crc1 + n_crc2), n_crc1, + 0); + } + + tmp = add(n_crc1, n_crc2); + data_offset = sub(data_offset, add(tmp, tmp)); + + dw0_bitswap(cw_buf + data_offset, mode, slot_bytes); + + Dyn_Mem_Deluxe_Out(); + return data_offset; +} + +void fec_encoder(Word16 mode, Word16 epmr, UWord8 *iobuf, Word16 data_bytes, Word16 slot_bytes, Word16 n_pccw, + void *scratch) +{ + Dyn_Mem_Deluxe_In( + Word16 n_codewords, codeword_length, hd, redundancy_nibbles, cw_offset, dw_offset, pc_split; + int i, j; + UWord8 *cw_buf; + ); + + cw_offset = 0; move16(); + dw_offset = 0; move16(); + pc_split = 0; move16(); + cw_buf = scratch; + + n_codewords = get_n_codewords(slot_bytes); + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + + /* some sanity checks */ + { + int tmp = slot_bytes; + assert((slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX) && + "fec_encoder: slot_bytes out of range"); + tmp -= mode == 1 ? 1 : n_codewords * (mode - 1); // reed solomon redundancy + tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; // crc1 + tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0; // crc2 + assert(data_bytes == tmp && "fec_encoder: inconsistent payload size"); + assert(n_codewords - n_pccw >= 6); + } + + /* data preproc: re-ordering and hash extension */ + pc_split = fec_get_n_pc(mode, n_pccw, slot_bytes); + + dw_offset = fec_data_preproc(mode, epmr, iobuf, cw_buf, data_bytes, slot_bytes, pc_split); + + /* encoding of first data word*/ + hd = hamming_distance_by_mode0[mode]; move16(); + redundancy_nibbles = sub(hd, 1); + codeword_length = get_codeword_length(n_codewords, add(slot_bytes, slot_bytes), 0); + + assert(codeword_length == (2 * slot_bytes - 1) / n_codewords + 1); + + FOR (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) + { + cw_buf[j] = cw_buf[dw_offset]; move16(); + } + + rs16_enc(cw_buf, codeword_length, hd, mode, 1); + + cw_offset = add(cw_offset, codeword_length); + + /* encoding of remaining data words */ + hd = hamming_distance_by_mode1[mode]; move16(); + redundancy_nibbles = sub(hd, 1); + + FOR (i = 1; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, add(slot_bytes, slot_bytes), i); + + assert(codeword_length == (2 * slot_bytes - i - 1) / n_codewords + 1); + FOR (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) + { + cw_buf[cw_offset + j] = cw_buf[dw_offset]; move16(); + } + + rs16_enc(cw_buf + cw_offset, codeword_length, hd, mode, sub(i, 6) < 0); + + cw_offset = add(cw_offset, codeword_length); + } + + assert(cw_offset == 2 * slot_bytes && dw_offset == 2 * slot_bytes); + + fec_interleave_pack(iobuf, cw_buf, add(slot_bytes, slot_bytes), n_codewords); + + + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC void rs16_enc(UWord8 *iobuf, Word16 codeword_length, Word16 hamming_distance, Word16 fec_mode, + Word16 signal_mode) +/* expects (data polynomial) * x^(hamming_distance - 1) in iobuf */ +{ + + Dyn_Mem_Deluxe_In( + UWord8 const *gp; + UWord8 shift_buffer[RS16_CW_LEN_MAX + 1], lc; + int i, j, deg_gp; + ); + + basop_memset(shift_buffer, 0, sizeof(shift_buffer)); + gp = rs16_gp_by_hd[hamming_distance]; move16(); + deg_gp = sub(hamming_distance, 1); + + IF (sub(hamming_distance, 1) > 0) + { + assert(codeword_length > deg_gp); + + /* initialize redundancy part to zero */ + basop_memset(iobuf, 0, deg_gp); + + /* initialize shift_buffer */ + basop_memmove(shift_buffer + 1, iobuf + codeword_length - deg_gp, deg_gp); + + /* calculate remainder */ + FOR (i = codeword_length - deg_gp - 1; i >= 0; i--) + { + shift_buffer[0] = iobuf[i]; move16(); + lc = (UWord8)shl(shift_buffer[deg_gp], 4); move16(); + FOR (j = deg_gp - 1; j >= 0; j--) + { + shift_buffer[j + 1] = GF16_ADD(shift_buffer[j], GF16_MUL0(gp[j], lc)); move16(); + } + } + + /* add remainder to shifted data polynomial */ + FOR (i = 0; i < deg_gp; i++) + { + iobuf[i] = shift_buffer[i + 1]; move16(); + } + + /* add signaling polynomial */ + IF (signal_mode) + { + assert(codeword_length > EP_SIG_POLY_DEG); + FOR (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[i] = GF16_ADD(iobuf[i], sig_polys[fec_mode - 1][i]); move16(); + } + } + } + + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC void fec_interleave_pack(UWord8 *out, UWord8 *in, Word16 n_nibbles, Word16 n_codewords) +{ + Dyn_Mem_Deluxe_In( + Word16 out_offset, cw_offset, codeword_length; + int i, j; + ); + + out_offset = 0; move16(); + cw_offset = 0; move16(); + + /* initialize output buffer to zero */ + basop_memset(out, 0, shr(n_nibbles, 1)); + + /* interleave and pack codewords */ + FOR (i = 0; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, n_nibbles, i); + + assert(codeword_length == (n_nibbles - i - 1) / n_codewords + 1); + FOR (j = 0; j < codeword_length; j++) + { + out_offset = add(DEPR_i_mult(j, n_codewords), i); + out_offset = sub(n_nibbles, add(out_offset, 1)); + out[out_offset >> 1] = + (UWord8)s_or(out[out_offset >> 1], shl(in[cw_offset], shl(s_and(out_offset, 1), 2))); move16(); + cw_offset = add(cw_offset, 1); + } + } + + assert(cw_offset == n_nibbles); + Dyn_Mem_Deluxe_Out(); +} + +/* Decoder */ +FEC_STATIC void fec_data_postproc(Word16 mode, Word16 *epmr, UWord8 *obuf, Word16 data_bytes, UWord8 *cw_buf, + Word16 slot_bytes, Word16 pc_split, int *bfi) +{ + Dyn_Mem_Deluxe_In( + Word16 i; + Word16 n_crc1, n_crc2; + Word16 cw_buf_len; + Word16 tmp_epmr; + ); + + n_crc1 = crc1_bytes_by_mode1[mode]; move16(); + if (sub(slot_bytes, 40) == 0) + { + n_crc1 = crc1_bytes_by_mode0[mode]; move16(); + } + + n_crc2 = 0; move16(); + if (pc_split > 0) + { + n_crc2 = crc2_bytes_by_mode[mode]; move16(); + } + + assert(n_crc1 == (slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode])); + assert(n_crc2 == ((pc_split > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0)); + + cw_buf_len = 2 * (data_bytes + n_crc1 + n_crc2); + + IF (sub(mode, 1)) + { + /* reverse bit-swap */ + dw0_bitswap(cw_buf, mode, slot_bytes); + tmp_epmr = dw0_get_epmr(cw_buf, mode, slot_bytes); + + IF (crc1(cw_buf + shl(add(n_crc1, n_crc2), 1), sub(shl(data_bytes, 1), pc_split), tmp_epmr, cw_buf, n_crc1, 1)) + { + *bfi = 1; move32(); + + Dyn_Mem_Deluxe_Out(); + return; + } + else + { + *epmr = tmp_epmr; + } + } + + test(); + IF (pc_split > 0 && sub(*bfi, 2) != 0) + { + IF (crc2(cw_buf + sub(shl(add(data_bytes, add(n_crc1, n_crc2)), 1), pc_split), pc_split, + cw_buf + shl(n_crc1, 1), n_crc2, 1)) + { + *bfi = 2; move32(); + } + } + + FOR (i = 0; i < data_bytes; i++) + { + obuf[i] = (UWord8)s_or(cw_buf[cw_buf_len - 2 * i - 1], shl(cw_buf[cw_buf_len - 2 * i - 2], 4)); move16(); + } + Dyn_Mem_Deluxe_Out(); +} + +int fec_decoder(UWord8 *iobuf, Word16 slot_bytes, int *data_bytes, Word16 *epmr, Word16 ccc_flag, Word16 *n_pccw, + int *bfi, Word16 *be_bp_left, Word16 *be_bp_right, Word16 *n_pc, Word16 *m_fec, void *scratch) +{ + Dyn_Mem_Deluxe_In( + UWord8 *my_scratch; + UWord8 *cw_buf; + UWord8 *array_of_trust; + Word16 i, j; + Word16 cw_offset, dw_offset; + Word16 n_codewords, redundancy_nibbles, codeword_length; + Word16 mode, error_report; + Word16 n_crc; + Word16 first_bad_cw; + Word16 pc_split; + ); + + IF (*bfi == 1) + { + Dyn_Mem_Deluxe_Out(); + return ERROR_REPORT_BEC_MASK; + } + + if (slot_bytes < FEC_SLOT_BYTES_MIN || slot_bytes > FEC_SLOT_BYTES_MAX) + { + *bfi = 1; + return ERROR_REPORT_BEC_MASK; + } + + my_scratch = (UWord8 *)scratch; move32(); + cw_buf = my_scratch; move32(); + my_scratch += 2 * slot_bytes; + + IF (ccc_flag == 0) + { + *be_bp_left = -1; move16(); + *be_bp_right = -1; move16(); + } + + n_codewords = get_n_codewords(slot_bytes); + + array_of_trust = my_scratch; move32(); + my_scratch += n_codewords; + + /* extract and de-interleave nibbles */ + fec_deinterleave_unpack(cw_buf, iobuf, 2 * slot_bytes, n_codewords); + + /* mode detection and error correction */ + mode = rs16_detect_and_correct(cw_buf, 2 * slot_bytes, n_codewords, epmr, &error_report, bfi, array_of_trust, + ccc_flag, n_pccw, (void *)my_scratch); + + /* for normal slots the maximal number of bit errors is limited */ + test(); +#ifndef APPLY_MAX_ERRORS + IF (sub(slot_bytes, 40) == 0 && mode > 0) + { + IF (sub(error_report & ERROR_REPORT_BEC_MASK, low_br_max_bit_errors_by_mode[mode]) > 0) + { + error_report &= ERROR_REPORT_BEC_MASK; + mode = -1; move16(); + *bfi = 1; move32(); + } + ELSE + { + IF (sub(error_report & ERROR_REPORT_BEC_MASK, low_br_max_bit_errors_by_mode[2]) > 0) + { + error_report &= ~ERROR_REPORT_EP2_OK; + } + IF (sub(error_report & ERROR_REPORT_BEC_MASK, low_br_max_bit_errors_by_mode[3])>0) + { + error_report &= ~ERROR_REPORT_EP3_OK; + } + } + } +#endif + + IF (sub(*bfi, 1) == 0) + { + *data_bytes = 0; move16(); + + Dyn_Mem_Deluxe_Out(); + return error_report; + } + + /* initialization for decoding */ + *data_bytes = fec_get_data_size(mode, ccc_flag, slot_bytes); move32(); + pc_split = fec_get_n_pc(mode, *n_pccw, slot_bytes); + n_crc = get_total_crc_size(slot_bytes, mode, pc_split); + + /* decoding of first code word */ + redundancy_nibbles = sub(hamming_distance_by_mode0[mode], 1); + codeword_length = get_codeword_length(n_codewords, add(slot_bytes, slot_bytes), 0); + + dw_offset = 0; move16(); + cw_offset = 0; move16(); + + FOR (j = redundancy_nibbles; j < codeword_length; j++) + { + cw_buf[dw_offset++] = cw_buf[j]; move16(); + } + cw_offset = add(cw_offset, codeword_length); + + /* decoding of remaining code words */ + redundancy_nibbles = sub(hamming_distance_by_mode1[mode], 1); + + FOR (i = 1; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, add(slot_bytes, slot_bytes), i); + + FOR (j = redundancy_nibbles; j < codeword_length; j++) + { + cw_buf[dw_offset++] = cw_buf[j + cw_offset]; move16(); + } + + cw_offset = add(cw_offset, codeword_length); + } + + assert(2 * (*data_bytes + n_crc) == dw_offset && 2 * slot_bytes == cw_offset); + + /* data postproc: hash validation and re-ordering */ + + fec_data_postproc(mode, epmr, iobuf, *data_bytes, cw_buf, slot_bytes, pc_split, bfi); + + IF (sub(*bfi, 1) == 0) + { + *data_bytes = 0; move32(); + error_report &= ERROR_REPORT_BEC_MASK; + Dyn_Mem_Deluxe_Out(); + return error_report; + } + + IF (*bfi == 2) + { + first_bad_cw = 0; move16(); + array_of_trust[*n_pccw] = 0; move16(); + WHILE (array_of_trust[first_bad_cw] != 0) + { + first_bad_cw = add(first_bad_cw, 1); + } + IF (sub(first_bad_cw, *n_pccw) == 0) + { + /* this is the case when CRC failed */ + *be_bp_left = 0; move16(); + } + ELSE + { + *be_bp_left = extract_l(L_mult0(fec_get_n_pc(mode, first_bad_cw, slot_bytes), 4)); move16(); + } + + FOR (i = *n_pccw - 1; i >= 0; i--) + { + if (!array_of_trust[i]) + { + BREAK; + } + } + IF (i < 0) + { + i = sub(*n_pccw, 1); + } + *be_bp_right = sub(extract_l(L_mult0(fec_get_n_pc(mode, i+1, slot_bytes), 4)), 1); move16(); + + } + + IF (ccc_flag == 0) + { + *n_pc = pc_split; move16(); + *m_fec = mode; move16(); + } + + + Dyn_Mem_Deluxe_Out(); + return error_report; +} + +FEC_STATIC void fec_deinterleave_unpack(UWord8 *out, UWord8 *in, Word16 n_nibbles, Word16 n_codewords) +{ + Dyn_Mem_Deluxe_In( + Word16 in_offset, out_offset, codeword_length; + int i, j; + ); + + in_offset = 0; move16(); + out_offset = 0; move16(); + + /* unpack nibbles in input buffer and deinterleave codewords */ + FOR (i = 0; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, n_nibbles, i); + FOR (j = 0; j < codeword_length; (j++, out_offset++)) + { + in_offset = add(DEPR_i_mult(j, n_codewords), i); + in_offset = sub(n_nibbles, add(in_offset, 1)); + out[out_offset] = (UWord8)s_and(shr(in[in_offset >> 1], shl(s_and(in_offset, 1), 2)), 15); move16(); + } + } + + assert(out_offset == n_nibbles); + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC Word16 fec_estimate_epmr_from_cw0(UWord8 *cw0, Word8 *t, UWord8 *syndromes, UWord8 *elp, Word8 *deg_elp, + UWord8 *err_pos, UWord8 *err_symb, Word16 n_codewords, Word16 n_symb) +{ + Dyn_Mem_Deluxe_In( + int epmr_lowest_risk_exp; + int start, inc, i, n_candidates; + int first_codeword_length; + int mode_counter; + Word16 epmr; + ); + + epmr_lowest_risk_exp = 0; + first_codeword_length = get_codeword_length(n_codewords, n_symb, 0); + start = 2; + inc = 1; + n_candidates = 0; + + /* test if first code word decodes in mode 0 or 1 without error correction */ + test(); + IF (s_or(syndromes[SYNDROME_IDX(0, 0)], syndromes[SYNDROME_IDX(0, 0) + 1]) == 0 || + s_or(syndromes[SYNDROME_IDX(1, 0)], syndromes[SYNDROME_IDX(1, 0) + 1]) == 0) + { + epmr_lowest_risk_exp = risk_table_f[1][0].exponent; move16(); + } + /* test if first code word decodes in mode 2 or 3 with lower risk */ + IF (sub(deg_elp[DEG_ELP_IDX(2, 0)], t[2]) <= 0) + { + IF (add(risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]].exponent, 8) <= 0) + { + n_candidates++; + start = 2; + } + } + + IF (sub(deg_elp[DEG_ELP_IDX(3, 0)], t[3]) <= 0) + { + IF (add(risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]].exponent, 8) <= 0) + { + n_candidates++; + start = 3; + } + } + + IF (sub(n_candidates, 1) > 0) + { + /* decide on order if mode 2 and 3 are considered */ + IF (simple_float_cmp(risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]], risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]]) < + 0) + { + start = 2; + inc = 1; + } + ELSE + { + start = 3; + inc = -1; + } + } + + FOR ((mode_counter = start, i = 0); i < n_candidates; (mode_counter += inc, i++)) + { + IF (sub(risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent, epmr_lowest_risk_exp) < 0) + { + IF (!rs16_factorize_elp(err_pos + ERR_POS_IDX(mode_counter, 0), elp + ELP_IDX(mode_counter, 0), + deg_elp[DEG_ELP_IDX(mode_counter, 0)], sub(first_codeword_length, 1))) + { + /* code word is decodable with error correction */ + epmr_lowest_risk_exp = risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent; + + rs16_calculate_errors(err_symb + ERR_SYMB_IDX(mode_counter, 0), err_pos + ERR_POS_IDX(mode_counter, 0), + syndromes + SYNDROME_IDX(mode_counter, 0), deg_elp[DEG_ELP_IDX(mode_counter, 0)], + t[mode_counter]); + + FOR (i = 0; i < deg_elp[DEG_ELP_IDX(mode_counter, 0)]; i++) + { + cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]] = GF16_ADD( + cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]], err_symb[ERR_SYMB_IDX(mode_counter, 0) + i]); + } + BREAK; + } + } + } + + epmr = cw0_get_epmr(cw0, sub(first_codeword_length, 1)); + + IF (add(epmr_lowest_risk_exp, 16) > 0) + { + epmr = add(epmr, 4); move16(); + } + IF (add(epmr_lowest_risk_exp, 8) > 0) + { + epmr = add(epmr, 4); move16(); + } + + Dyn_Mem_Deluxe_Out(); + return epmr; +} + +FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codewords, Word16 *epmr, Word16 *error_report, + int *bfi, UWord8 *array_of_trust, int ccc_flag, Word16 *n_pccw, void *scratch) +{ + Dyn_Mem_Deluxe_In( + UWord8 * syndromes; + UWord8 * elp; + UWord8 * err_pos; + UWord8 * err_symb; + Word8 t[FEC_N_MODES]; + Word8 * deg_elp; + UWord8 * my_scratch; + UWord8 blacklist[FEC_N_MODES]; + UWord8 const *hamming_distance; + + Word16 i, cw_counter, mode_counter, cw_offset; + Word16 codeword_length; + Word16 mode; + Word16 mode_candidates[4]; + Word16 mode_broken[4]; + Word16 error_report_ep_ok[4]; + Word16 n_mode_candidates; + Word16 broken_cw, n_broken_cw; + Word16 j, idx_min; + Word16 n_pccw0; + simple_float val_min_f; + Word16 tmp; + Word16 epmr_position; + simple_float dec_risk_f[FEC_N_MODES]; + simple_float risk_min_f; + simple_float ep_risk_thresh; + + int epmr_dec_fail_increment; + + void (*syndr_calc[3])(UWord8 *, UWord8 *, int); + ); + + /* initialization */ + blacklist[0] = 0; move16(); + blacklist[1] = 0; move16(); + blacklist[2] = 0; move16(); + blacklist[3] = 0; move16(); + mode_broken[0] = 0; move16(); + mode_broken[1] = 0; move16(); + mode_broken[2] = 0; move16(); + mode_broken[3] = 0; move16(); + error_report_ep_ok[0] = ERROR_REPORT_EP1_OK; + error_report_ep_ok[1] = ERROR_REPORT_EP2_OK; + error_report_ep_ok[2] = ERROR_REPORT_EP3_OK; + error_report_ep_ok[3] = ERROR_REPORT_EP4_OK; + my_scratch = (UWord8 *)scratch; + hamming_distance = &hamming_distance_by_mode0[1]; + mode = -1; move16(); + n_mode_candidates = 0; move16(); + risk_min_f.mantissa = SIMPLE_FLOAT_1_MANTISSA; move16(); + risk_min_f.exponent = 0; move16(); + + IF (n_symb <= 80) + { + ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; move16(); + ep_risk_thresh.exponent = EP_RISK_THRESH_NS_E; move16(); + } + ELSE + { + ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; move16(); + ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; move16(); + } + + syndr_calc[0] = &rs16_calculate_two_syndromes; + syndr_calc[1] = &rs16_calculate_four_syndromes; + syndr_calc[2] = &rs16_calculate_six_syndromes; + + FOR (i = 0; i < FEC_N_MODES; i++) + { + t[i] = (Word8)shr(sub(hamming_distance[i], 1), 1); move16(); + } + + syndromes = my_scratch; + my_scratch += FEC_TOTAL_SYNDROME_SIZE; + elp = my_scratch; + my_scratch += FEC_TOTAL_ELP_SIZE; + err_pos = my_scratch; + my_scratch += FEC_TOTAL_ERR_POS_SIZE; + err_symb = my_scratch; + my_scratch += FEC_TOTAL_ERROR_SIZE; + deg_elp = (Word8 *)my_scratch; + my_scratch += FEC_TOTAL_DEG_ELP_SIZE; + + *error_report = 0; move16(); + *bfi = 0; move32(); + + /* mode detection (stage 1) */ + codeword_length = get_codeword_length(n_codewords, n_symb, 0); + + epmr_position = sub(codeword_length, 1); + + rs16_calculate_two_syndromes(syndromes + SYNDROME_IDX(0, 0), iobuf, sub(codeword_length, 1)); + + IF (s_or(syndromes[0 + SYNDROME_IDX(0, 0)], syndromes[1 + SYNDROME_IDX(0, 0)]) == 0) + { + + /* data validation for fec mode 1 */ + *epmr = cw0_get_epmr(iobuf, epmr_position); + + dw0_bitswap(iobuf + 2, 1, n_symb / 2); + + IF (!crc1(iobuf + 8, sub(n_symb, 8), *epmr, iobuf + 2, 3, 1)) + { + mode = 0; move16(); + *error_report |= ERROR_REPORT_ALL_OK; + Dyn_Mem_Deluxe_Out(); + return add(mode, 1); + } + ELSE + { + /* reverse bit swap */ + dw0_bitswap(iobuf + 2, 1, n_symb / 2); + + *epmr = add(*epmr, 4); move16(); + } + } + + blacklist[0] = 1; move16(); + + /* mode detection (stage 2) */ + + /* calculate syndromes of code words 0 to 5 and modes 1 to 3 */ + cw_offset = 0; move16(); + + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + rs16_calculate_six_syndromes(syndromes + SYNDROME_IDX(1, cw_counter), iobuf + cw_offset, + sub(codeword_length, 1)); + + cw_offset = add(cw_offset, codeword_length); + + FOR (mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter--) + { + FOR (i = 0; i < sub(hamming_distance[mode_counter], 1); i++) + { + syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i] = GF16_ADD( + syndromes[SYNDROME_IDX(1, cw_counter) + i], sig_poly_syndr[mode_counter][i]); move16(); + } + } + } + + /* check for valid code words */ + FOR (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + n_broken_cw = 0; + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + broken_cw = 0; + FOR (i = 0; i < sub(hamming_distance[mode_counter], 1); i++) + { + broken_cw = s_or(broken_cw, syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i]); move16(); + } + IF (broken_cw != 0) + { + n_broken_cw = add(n_broken_cw, 1); + } + } + + IF (n_broken_cw == 0) + { + mode = mode_counter; move16(); + cw_offset = 0; move16(); + + *epmr = cw0_get_epmr(iobuf, epmr_position); + + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + FOR (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); + } + cw_offset = add(cw_offset, codeword_length); + } + } + } + + IF (mode < 0) /* mode hasn't been detected so far -> errors occurred in transmission */ + { + /* calculate error locator polynomials for code words 0 to 5 */ + FOR (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] = rs16_calculate_elp( + elp + ELP_IDX(mode_counter, cw_counter), syndromes + SYNDROME_IDX(mode_counter, cw_counter), + t[mode_counter]); move16(); + IF (sub(deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)], t[mode_counter]) > 0) + { + blacklist[mode_counter] = 1; move16(); + BREAK; + } + } + } + + /* risk analysis for mode candidate selection */ + FOR (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; move16(); + dec_risk_f[mode_counter].exponent = 0; move16(); + + IF (blacklist[mode_counter] == 0) + { + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + dec_risk_f[mode_counter] = simple_float_mul( + dec_risk_f[mode_counter], + risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)]]); move16(); + } + + IF (simple_float_cmp(dec_risk_f[mode_counter], ep_risk_thresh) <= 0) + { + mode_candidates[n_mode_candidates++] = mode_counter; move16(); + } + + IF (simple_float_cmp(dec_risk_f[mode_counter], risk_min_f) < 0) + { + risk_min_f = dec_risk_f[mode_counter]; move16(); + } + } + } + assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3 + + /* sort mode candidates by risk */ + FOR (i = 0; i < n_mode_candidates; i++) + { + idx_min = i; move16(); + val_min_f = dec_risk_f[mode_candidates[i]]; move16(); + + FOR (j = i + 1; j < n_mode_candidates; j++) + { + IF (simple_float_cmp(dec_risk_f[mode_candidates[j]], val_min_f) < 0) + { + val_min_f = dec_risk_f[mode_candidates[j]]; move16(); + idx_min = j; move16(); + } + } + + IF (sub(idx_min, i) > 0) + { + tmp = mode_candidates[i]; move16(); + mode_candidates[i] = mode_candidates[idx_min]; move16(); + mode_candidates[idx_min] = tmp; move16(); + } + } + + /* try out candidate modes */ + FOR (i = 0; i < n_mode_candidates; i++) + { + mode = mode_candidates[i]; move16(); + + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + IF (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) + { + IF (rs16_factorize_elp(err_pos + ERR_POS_IDX(mode, cw_counter), elp + ELP_IDX(mode, cw_counter), + deg_elp[DEG_ELP_IDX(mode, cw_counter)], sub(codeword_length, 1))) + { + /* elp did not split into distinct linear factors or error position was out of range */ + mode = -1; move16(); + BREAK; + } + } + } + IF (mode > 0) + { + /* decodable mode with lowest risk has been found */ + BREAK; + } + } + + IF (mode < 0) + { + /* no decodable mode has been found */ + *error_report = ERROR_REPORT_BEC_MASK; move16(); + *bfi = 1; move32(); + mode = -1; move16(); + + *epmr = fec_estimate_epmr_from_cw0(iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, + n_symb); + + Dyn_Mem_Deluxe_Out(); + return mode; + } + + /* perform error correction */ + cw_offset = 0; move16(); + *error_report = 0; move16(); + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + IF (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) + { + rs16_calculate_errors( + err_symb + ERR_SYMB_IDX(mode, cw_counter), err_pos + ERR_POS_IDX(mode, cw_counter), + syndromes + SYNDROME_IDX(mode, cw_counter), deg_elp[DEG_ELP_IDX(mode, cw_counter)], t[mode]); + + /* correct errors and sum up number of corrected bits */ + FOR (i = 0; i < deg_elp[DEG_ELP_IDX(mode, cw_counter)]; i++) + { + iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset] = + GF16_ADD(iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset], + err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]); + *error_report = add(*error_report, + rs16_bit_count_table[err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]]); move16(); + } + + FOR (i = 0; i < mode; i ++) + { + IF(deg_elp[DEG_ELP_IDX(mode, cw_counter)] > i) + { + mode_broken[i] = 1; + } + } + } + + FOR (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); + } + cw_offset = add(cw_offset, codeword_length); + } + + /* set epmr according to risk value of cw0 */ + epmr_dec_fail_increment = 8; + + IF (add(risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent, 8) <= 0) + { + epmr_dec_fail_increment = sub(epmr_dec_fail_increment, 4); + } + IF (add(risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent, 16) <= 0) + { + epmr_dec_fail_increment = sub(epmr_dec_fail_increment, 4); + } + + *epmr = cw0_get_epmr(iobuf, epmr_position) + epmr_dec_fail_increment; + } + + /* mode has been successfully detected -> now check and try to correct remaining code words*/ + *n_pccw = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); + IF (ccc_flag == 0) + { + n_pccw0 = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); + *n_pccw = n_pccw0; + } + ELSE + { + n_pccw0 = 0; + } + + FOR (cw_counter = 6; cw_counter < n_codewords; cw_counter++) + { + /* usual error correction scheme: syndromes -> elp's, errors, etc. */ + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + array_of_trust[n_codewords - 1 - cw_counter] = 1; move16(); + + syndr_calc[sub(t[mode], 1)](syndromes, iobuf + cw_offset, sub(codeword_length, 1)); + + deg_elp[0] = rs16_calculate_elp(elp, syndromes, t[mode]); move16(); + + FOR (i = 0; i < mode; i ++) + { + IF(deg_elp[0] > i) + { + mode_broken[i] = 1; + } + } + IF (sub(deg_elp[0], t[mode]) > 0) + { + FOR (i = 0; i < 4; i ++) + { + mode_broken[i] = 1; + } + cw_offset = add(cw_offset, codeword_length); + IF (cw_counter < n_codewords - n_pccw0) + { + *error_report = ERROR_REPORT_BEC_MASK; move16(); + mode = -1; move16(); + *bfi = 1; move32(); + + BREAK; + } + ELSE + { + *bfi = 2; move32(); + array_of_trust[n_codewords - 1 - cw_counter] = 0; move16(); + CONTINUE; + } + } + + IF (deg_elp[0]) + { + IF (rs16_factorize_elp(err_pos, elp, deg_elp[0], sub(codeword_length, 1))) + { + cw_offset = add(cw_offset, codeword_length); + FOR (i = 0; i < 4; i ++) + { + mode_broken[i] = 1; + } + IF (add(n_pccw0, sub(cw_counter, n_codewords)) < 0) + { + *error_report = ERROR_REPORT_BEC_MASK; move16(); + mode = -1; move16(); + *bfi = 1; move32(); + + BREAK; + } + ELSE + { + *bfi = 2; move32(); + array_of_trust[n_codewords - 1 - cw_counter] = 0; move16(); + CONTINUE; + } + } + + rs16_calculate_errors(err_symb, err_pos, syndromes, deg_elp[0], t[mode]); + + /* correct errors and sum up number of corrected bits */ + FOR (i = 0; i < deg_elp[0]; i++) + { + iobuf[err_pos[i] + cw_offset] = GF16_ADD(iobuf[err_pos[i] + cw_offset], err_symb[i]); + *error_report = add(*error_report, rs16_bit_count_table[err_symb[i]]); + } + } + cw_offset = add(cw_offset, codeword_length); + if (add(risk_table_f[mode][deg_elp[0]].exponent, 16) > 0) + { + array_of_trust[n_codewords - 1 - cw_counter] = 0; move16(); + } + } + + *error_report &= ERROR_REPORT_BEC_MASK; + FOR (i = 0; i < 4; i ++) + { + IF (!mode_broken[i]) + { + *error_report |= error_report_ep_ok[i]; + } + } + + Dyn_Mem_Deluxe_Out(); + IF (mode >= 0) + { + return add(mode, 1); + } + + return -1; +} + +FEC_STATIC void rs16_calculate_six_syndromes(UWord8 *syndromes, UWord8 *cw, int cw_poly_deg) +{ + Dyn_Mem_Deluxe_In( + int i; + UWord8 buffer[15]; + ); + + assert(cw_poly_deg >= 12); + + FOR (i = 0; i <= cw_poly_deg; i++) + { + buffer[i] = cw[i]; move16(); + } + + syndromes[0] = buffer[0]; move16(); + syndromes[1] = buffer[0]; move16(); + syndromes[2] = buffer[0]; move16(); + syndromes[3] = buffer[0]; move16(); + syndromes[4] = buffer[0]; move16(); + syndromes[5] = buffer[0]; move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[1], 96)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[1], 192)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[2], 112)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[2], 240)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[3], 16)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[3], 128)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[4], 96)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[4], 160)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[5], 112)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[5], 16)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[6], 16)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[6], 192)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[7], 96)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[7], 240)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[8], 112)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[8], 128)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[9], 16)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[9], 160)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[10], 96)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[10], 16)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[11], 112)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[11], 192)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[12], 16)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[12], 240)); move16(); + + IF (sub(cw_poly_deg, 13) >= 0) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[13], 96)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[13], 128)); move16(); + } + + IF (sub(cw_poly_deg, 14) >= 0) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); move16(); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[14], 112)); move16(); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[14], 160)); move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC void rs16_calculate_four_syndromes(UWord8 *syndromes, UWord8 *cw, int cw_poly_deg) +{ + Dyn_Mem_Deluxe_In( + int i; + UWord8 buffer[15]; + ); + + assert(cw_poly_deg >= 12); + + FOR (i = 0; i <= cw_poly_deg; i++) + { + buffer[i] = cw[i]; move16(); + } + + syndromes[0] = buffer[0]; move16(); + syndromes[1] = buffer[0]; move16(); + syndromes[2] = buffer[0]; move16(); + syndromes[3] = buffer[0]; move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); move16(); + + IF (sub(cw_poly_deg, 13) >= 0) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); move16(); + } + + IF (sub(cw_poly_deg, 14) >= 0) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); move16(); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); move16(); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC void rs16_calculate_two_syndromes(UWord8 *syndromes, UWord8 *cw, int cw_poly_deg) +{ + Dyn_Mem_Deluxe_In( + int i; + UWord8 buffer[15]; + ); + + assert(cw_poly_deg >= 12); + + FOR (i = 0; i <= cw_poly_deg; i++) + { + buffer[i] = cw[i]; move16(); + } + + syndromes[0] = buffer[0]; move16(); + syndromes[1] = buffer[0]; move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); move16(); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); move16(); + + IF (sub(cw_poly_deg, 13) >= 0) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); move16(); + } + + IF (sub(cw_poly_deg, 14) >= 0) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); move16(); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +FEC_STATIC Word8 rs16_calculate_elp(UWord8 *elp, UWord8 *syndromes, Word16 t) +/* calculates error locator polynomial vie Petterson's algorithm */ +{ + Dyn_Mem_Deluxe_In( + Word8 ret; + UWord8 det, det_inv, aux, all_s, *s; + UWord8 s22, s33, s44, s13, s14, s15; + UWord8 s23, s24, s25, s34, s35; + UWord8 a, b, c, d, e, f; + ); + + ret = 0; move16(); + all_s = 0; move16(); + s = syndromes; move16(); + elp[0] = 1; move16(); + basop_memset(elp + 1, 0, 3); + + SWITCH (t) + { + case 3: + { + /* check for errors */ + all_s = (UWord8)s_or(s[0], s_or(s[1], s_or(s[2], s_or(s[3], s_or(s[4], s[5]))))); + + IF (all_s == 0) + { + BREAK; + } + + /* assume 3 errors */ + s22 = GF16_MUL(s[1], s[1]); + s33 = GF16_MUL(s[2], s[2]); + s44 = GF16_MUL(s[3], s[3]); + s13 = GF16_MUL(s[0], s[2]); + + det = GF16_ADD(GF16_ADD(GF16_MUL(s13, s[4]), GF16_MUL(s44, s[0])), + GF16_ADD(GF16_MUL(s22, s[4]), GF16_MUL(s33, s[2]))); + + IF (det) + { + det_inv = (UWord8)shl(gf16_inv_table[det], 4); + + s14 = GF16_MUL(s[0], s[3]); + s15 = GF16_MUL(s[0], s[4]); + + s23 = GF16_MUL(s[1], s[2]); + s24 = GF16_MUL(s[1], s[3]); + s25 = GF16_MUL(s[1], s[4]); + + s34 = GF16_MUL(s[2], s[3]); + s35 = GF16_MUL(s[2], s[4]); + + a = GF16_ADD(s35, s44) << 4; + b = GF16_ADD(s15, s33) << 4; + c = GF16_ADD(s13, s22) << 4; + d = GF16_ADD(s34, s25) << 4; + e = GF16_ADD(s23, s14) << 4; + f = GF16_ADD(s24, s33) << 4; + + aux = GF16_ADD(GF16_ADD(GF16_MUL0(a, s[3]), GF16_MUL0(d, s[4])), GF16_MUL0(f, s[5])); + elp[3] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_ADD(GF16_MUL0(d, s[3]), GF16_MUL0(b, s[4])), GF16_MUL0(e, s[5])); + elp[2] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_ADD(GF16_MUL0(f, s[3]), GF16_MUL0(e, s[4])), GF16_MUL0(c, s[5])); + elp[1] = GF16_MUL0(aux, det_inv); + + IF (elp[3] == 0) + { + ret = (Word8) add(t, 1); + } + ELSE + { + ret = 3; move16(); + } + BREAK; + } + + /* assume two errors */ + det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); + + IF (det) + { + det_inv = (UWord8)shl(gf16_inv_table[det], 4); + + aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); + elp[1] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); + elp[2] = GF16_MUL0(aux, det_inv); + + /* check remaining LSF relations */ + aux = (UWord8)s_or(GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[2]), GF16_MUL(elp[1], s[3])), s[4]), + GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[3]), GF16_MUL(elp[1], s[4])), s[5])); + + aux = (UWord8)s_or(aux, elp[2] == 0); + + IF (aux != 0) + { + ret = (Word8) add(t, 1); + } + ELSE + { + ret = 2; move16(); + } + BREAK; + } + + /* assume one error */ + IF (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + + /* check remaining LSF relations */ + aux = (UWord8)s_or(s_or(GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]), GF16_ADD(GF16_MUL(elp[1], s[2]), s[3])), + s_or(GF16_ADD(GF16_MUL(elp[1], s[3]), s[4]), GF16_ADD(GF16_MUL(elp[1], s[4]), s[5]))); + + aux = (UWord8)s_or(aux, elp[1] == 0); + + IF (aux != 0) + { + ret = (Word8) add(t, 1); + } + ELSE + { + ret = 1; move16(); + } + BREAK; + } + + ret = (Word8) add(t, 1); + BREAK; + } + case 2: + { + all_s = (UWord8)s_or(s[0], s_or(s[1], s_or(s[2], s[3]))); + + IF (all_s == 0) + { + BREAK; + } + + /* assume two errors */ + det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); + + IF (det) + { + det_inv = (UWord8)shl(gf16_inv_table[det], 4); + + aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); + elp[1] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); + elp[2] = GF16_MUL0(aux, det_inv); + + IF (elp[2] == 0) + { + ret = (Word8) add(t, 1); + } + ELSE + { + ret = 2; move16(); + } + BREAK; + } + + /* assume one error */ + IF (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + + /* check remaining LSF relation */ + aux = (UWord8)s_or(GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]), GF16_ADD(GF16_MUL(elp[1], s[2]), s[3])); + aux = (UWord8)s_or(aux, elp[1] == 0); + IF (aux != 0) + { + ret = (Word8) add(t, 1); + } + ELSE + { + ret = 1; move16(); + } + BREAK; + } + + ret = (Word8) add(t, 1); + BREAK; + } + case 1: + { + all_s = (UWord8)s_or(s[0], s[1]); + + IF (all_s == 0) + { + BREAK; + } + + IF (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + IF (elp[1] == 0) + { + ret = (Word8) add(t, 1); + } + ELSE + { + ret = 1; move16(); + } + BREAK; + } + + ret = (Word8) add(t, 1); + BREAK; + } + default: assert(0 && "calculating elp of this degree not implemented"); + } + + Dyn_Mem_Deluxe_Out(); + return ret; +} + +FEC_STATIC Word16 rs16_factorize_elp(UWord8 *err_pos, UWord8 *elp, Word16 deg_elp, Word16 max_pos) +{ + Dyn_Mem_Deluxe_In( + UWord8 beta, gamma; + Word16 zeros, err_pos0, err_pos1, err_pos2, ret; + ); + + beta = 0; move16(); + gamma = 0; move16(); + zeros = 0; move16(); + ret = 0; move16(); + + SWITCH (deg_elp) + { + case 0: BREAK; + + case 1: + err_pos0 = gf16_log_g[elp[1]]; move16(); + IF (sub(err_pos0, max_pos) > 0) + { + ret = 1; move16(); + BREAK; + } + + err_pos[0] = (UWord8)err_pos0; move16(); + BREAK; + + case 2: + zeros = rs16_elp_deg2_table[s_or(elp[1], shl(elp[2], 4))]; move16(); + IF (zeros == 0) + { + Dyn_Mem_Deluxe_Out(); + return 1; + } + + err_pos0 = s_and(zeros, 15); + err_pos1 = s_and(shr(zeros, 4), 15); + + IF (sub(err_pos0, max_pos) > 0 || sub(err_pos1, max_pos) > 0) + { + ret = 1; move16(); + BREAK; + } + + err_pos[0] = (UWord8)err_pos0; move16(); + err_pos[1] = (UWord8)err_pos1; move16(); + BREAK; + + case 3: + /* beta = a*a + b, gamma = a*b + c */ + beta = GF16_ADD(GF16_MUL(elp[1], elp[1]), elp[2]); + gamma = GF16_ADD(GF16_MUL(elp[1], elp[2]), elp[3]); + zeros = rs16_elp_deg3_table[beta | gamma << 4]; + + IF (zeros == 0) + /* elp does not split over GF(16) or has multiple zeros */ + { + ret = 1; move16(); + BREAK; + } + + /* remove shift from zeros */ + err_pos0 = GF16_ADD(s_and(zeros, 15), elp[1]); + err_pos1 = GF16_ADD(s_and(shr(zeros, 4), 15), elp[1]); + err_pos2 = GF16_ADD(s_and(shr(zeros, 8), 15), elp[1]); + + IF (err_pos0 == 0 || err_pos1 == 0 || err_pos2 == 0) + { + test(); test(); + Dyn_Mem_Deluxe_Out(); + return 1; + } + + err_pos0 = gf16_log_g[err_pos0]; + err_pos1 = gf16_log_g[err_pos1]; + err_pos2 = gf16_log_g[err_pos2]; + + IF (sub(err_pos0, max_pos) > 0 || sub(err_pos1, max_pos) > 0 || sub(err_pos2, max_pos) > 0) + { + test(); test(); + ret = 1; move16(); + BREAK; + } + + err_pos[0] = (UWord8)err_pos0; move16(); + err_pos[1] = (UWord8)err_pos1; move16(); + err_pos[2] = (UWord8)err_pos2; move16(); + + BREAK; + + default: assert(0 && "invalid degree in rs16_error_locator"); + } + + Dyn_Mem_Deluxe_Out(); + return ret; +} + +FEC_STATIC void rs16_calculate_errors(UWord8 *err_symb, UWord8 *err_pos, UWord8 *syndromes, Word8 deg_elp, Word8 t) +{ + Dyn_Mem_Deluxe_In( + UWord8 det_inv; + UWord8 x0, x1, x2; + UWord8 x0sq, x1sq, x2sq; + UWord8 c0, c1, c2; + UWord8 s0, s1, s2; + UWord8 tmp; + ); + + assert(deg_elp <= t); + UNUSED(t); + + SWITCH (deg_elp) + { + case 0: BREAK; + + case 1: + err_symb[0] = GF16_MUL(gf16_g_pow[15 - err_pos[0]], syndromes[0]); move16(); + + BREAK; + + case 2: + s0 = (UWord8)shl(syndromes[0], 4); + s1 = (UWord8)shl(syndromes[1], 4); + + x0 = gf16_g_pow[err_pos[0]]; move16(); + x1 = gf16_g_pow[err_pos[1]]; move16(); + + x0sq = GF16_MUL(x0, x0); + x1sq = GF16_MUL(x1, x1); + + tmp = GF16_ADD(GF16_MUL(x0sq, x1), GF16_MUL(x1sq, x0)); + det_inv = (UWord8)shl(gf16_inv_table[tmp], 4); + + tmp = GF16_ADD(GF16_MUL0(x1sq, s0), GF16_MUL0(x1, s1)); + err_symb[0] = GF16_MUL0(tmp, det_inv); move16(); + + tmp = GF16_ADD(GF16_MUL0(x0sq, s0), GF16_MUL0(x0, s1)); + err_symb[1] = GF16_MUL0(tmp, det_inv); move16(); + + BREAK; + + case 3: + s0 = (UWord8)shl(syndromes[0], 4); + s1 = (UWord8)shl(syndromes[1], 4); + s2 = (UWord8)shl(syndromes[2], 4); + + x0 = gf16_g_pow[err_pos[0]]; move16(); + x1 = gf16_g_pow[err_pos[1]]; move16(); + x2 = gf16_g_pow[err_pos[2]]; move16(); + + x0sq = GF16_MUL(x0, x0); + x1sq = GF16_MUL(x1, x1); + x2sq = GF16_MUL(x2, x2); + + tmp = GF16_MUL(GF16_ADD(x1, x0), GF16_ADD(x2, x0)); + tmp = GF16_MUL(GF16_ADD(x2, x1), tmp); + det_inv = (UWord8)shl(gf16_inv_table[tmp], 4); + + c0 = GF16_ADD(GF16_MUL(x1, x2sq), GF16_MUL(x2, x1sq)); + c1 = GF16_ADD(x2sq, x1sq); + c2 = GF16_ADD(x2, x1); + + err_symb[0] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); move16(); + + c0 = GF16_ADD(GF16_MUL(x0, x2sq), GF16_MUL(x2, x0sq)); + c1 = GF16_ADD(x2sq, x0sq); + c2 = GF16_ADD(x2, x0); + + err_symb[1] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); move16(); + + c0 = GF16_ADD(GF16_MUL(x0, x1sq), GF16_MUL(x1, x0sq)); + c1 = GF16_ADD(x1sq, x0sq); + c2 = GF16_ADD(x1, x0); + + err_symb[2] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); move16(); + + tmp = GF16_MUL0(err_symb[0], det_inv); + err_symb[0] = GF16_MUL(tmp, gf16_inv_table[x0]); move16(); + + tmp = GF16_MUL0(err_symb[1], det_inv); + err_symb[1] = GF16_MUL(tmp, gf16_inv_table[x1]); move16(); + + tmp = GF16_MUL0(err_symb[2], det_inv); + err_symb[2] = GF16_MUL(tmp, gf16_inv_table[x2]); move16(); + + BREAK; + + default: assert(0 && "method not implemented\n"); BREAK; + } + + Dyn_Mem_Deluxe_Out(); +} + +/* hash functions for data validation */ + +/* hamming distance 4 */ +static const UWord32 crc14_mask[16] = {0, 17989, 35978, 51919, 71956, 89937, 103838, 119771, + 143912, 160877, 179874, 194791, 207676, 224633, 239542, 254451}; + +/* hamming distance 4 */ +static const UWord32 crc22_mask[16] = {0, 4788009, 9576018, 14356859, 19152036, 23933837, 28713718, 33500639, + 33650273, 38304072, 43214899, 47867674, 52775621, 57427436, 62346391, 67001278}; + +FEC_STATIC Word16 crc1(UWord8 *data, Word16 data_size, Word16 epmr, UWord8 *hash, Word16 hash_size, Word16 check) +{ + Dyn_Mem_Deluxe_In( + UWord32 const *mask; + int shift, i, fail; + UWord32 rem; + ); + + fail = 0; move16(); + rem = 0; move16(); + + assert(hash_size > 0); + + SWITCH (hash_size) + { + case 2: + shift = 14; move16(); + mask = crc14_mask; move32(); + BREAK; + case 3: + shift = 22; move16(); + mask = crc22_mask; move32(); + BREAK; + default: + shift = 0; + mask = 0; + assert(0 && "crc hash size not implemented"); + } + + /* data array contains 4-bit words */ + FOR (i = data_size - 1; i >= 0; i--) + { + rem = UL_xor(UL_lshl(rem, 4), data[i]); move32(); + rem = UL_xor(rem, mask[UL_and(UL_lshr(rem, shift), 15)]); move32(); + } + + rem = UL_xor(UL_lshl(rem, 4), UL_lshl(epmr, 2)); + rem = UL_xor(rem, mask[UL_and(UL_lshr(rem, shift), 15)]); move32(); + + FOR (i = 0; i < 2 * hash_size - 1; i++) + { + rem = UL_lshl(rem, 4); + rem = UL_xor(rem, mask[UL_and(UL_lshr(rem, shift), 15)]); move32(); + } + + rem = UL_xor(rem, UL_lshl((UWord32)epmr, shift)); move32(); + + IF (check) + { + /* test hash value */ + FOR (i = 0; i < 2 * hash_size; i++) + { + fail = s_or(fail, UL_xor(hash[i], UL_and(UL_lshr(rem, shl(i, 2)), 15))); move32(); + } + } + ELSE + { + /* write hash value */ + for (i = 0; i < 2 * hash_size; i++) + { + hash[i] = (UWord8)UL_and(UL_lshr(rem, shl(i, 2)), 15); move32(); + } + } + + Dyn_Mem_Deluxe_Out(); + return fail; +} + +/* hamming distance = 4 */ +static const UWord32 crc16_mask[16] = {0, 107243, 190269, 214486, 289937, 380538, 428972, 469319, + 579874, 621513, 671263, 761076, 832947, 857944, 938638, 1044581}; + +FEC_STATIC Word16 crc2(UWord8 *data, Word16 data_size, UWord8 *hash, Word16 hash_size, Word16 check) +{ + Dyn_Mem_Deluxe_In( + UWord32 const *mask; + int shift, i, fail; + UWord32 rem; + ); + + fail = 0; move16(); + rem = 0; move16(); + + assert(hash_size > 0); + + SWITCH (hash_size) + { + case 2: + shift = 16; move16(); + mask = crc16_mask; move32(); + BREAK; + default: + shift = 0; + mask = 0; + assert(0 && "crc hash size not implemented"); + } + + /* data array contains 4-bit words */ + FOR (i = data_size - 1; i >= 0; i--) + { + rem = UL_xor(UL_lshl(rem, 4), data[i]); move32(); + rem = UL_xor(rem, mask[UL_and(UL_lshr(rem, shift), 15)]); move32(); + } + + FOR (i = 0; i < 2 * hash_size; i++) + { + rem = UL_lshl(rem, 4); + rem = UL_xor(rem, mask[UL_and(UL_lshr(rem, shift), 15)]); move32(); + } + + IF (check) + { + /* test hash value */ + FOR (i = 0; i < 2 * hash_size; i++) + { + fail = s_or(fail, UL_xor(hash[i], UL_and(UL_lshr(rem, shl(i, 2)), 15))); move32(); + } + } + ELSE + { + /* write hash value */ + FOR (i = 0; i < 2 * hash_size; i++) + { + hash[i] = (UWord8)UL_and(UL_lshr(rem, shl(i, 2)), 15); move32(); + } + } + + Dyn_Mem_Deluxe_Out(); + return fail; +} + +/* simple float implementation */ + +FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2) +{ + Dyn_Mem_Deluxe_In( + simple_float rop; + Word32 aux; + ); + aux = L_shr(L_mult0(op1.mantissa, op2.mantissa), 14); + rop.exponent = add(op1.exponent, op2.exponent); + IF (L_and(aux, 32768L)) + { + aux = L_shr(aux, 1); + rop.exponent = add(rop.exponent, 1); + } + rop.mantissa = extract_l(aux); + Dyn_Mem_Deluxe_Out(); + return rop; +} + +/* Auxiliary */ + +FEC_STATIC Word16 simple_float_cmp(simple_float op1, simple_float op2) +/* returns 1 if op1 > op2, 0 if op1 = op2, and -1 if op1 < op2 */ +{ + Dyn_Mem_Deluxe_In( + Word16 rval; + Word16 mdiff; + Word16 ediff; + ); + + rval = 0; move16(); + + ediff = sub(op1.exponent, op2.exponent); + mdiff = sub(op1.mantissa, op2.mantissa); + + IF (ediff == 0) + { + if (mdiff > 0) + { + rval = 1; + } + if (mdiff < 0) + { + rval = -1; + } + } + ELSE + { + if (ediff > 0) + { + rval = 1; + } + if (ediff < 0) + { + rval = -1; + } + } + + Dyn_Mem_Deluxe_Out(); + return rval; +} + + diff --git a/lib_lc3plus/apply_global_gain_fx.c b/lib_lc3plus/apply_global_gain_fx.c new file mode 100644 index 000000000..7c5220f10 --- /dev/null +++ b/lib_lc3plus/apply_global_gain_fx.c @@ -0,0 +1,66 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 global_gain_idx, Word16 global_gain_off) +{ + Counter i; +#ifdef ENABLE_HR_MODE + Word32 global_gain; +#else + Word16 global_gain; +#endif + Word16 global_gain_e; + Word32 tmp32; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processApplyGlobalGain_fx", sizeof(struct { + Counter i; + Word16 global_gain, global_gain_e; + Word32 tmp32; + })); +#endif + +#ifdef ENABLE_HR_MODE + /* 1 / (28 * log 2) is 0x797D in Q18, L_shl_pos by 7 results in Q25 tmp32 */ + /* round(2^31 / (28 * log10(2))) = 254778081 */ + //tmp32 = L_shl_pos(Mpy_32_16_lc3plus(254778081, add(global_gain_idx, global_gain_off)), 9); + Word32 mh; + UWord16 ml; + + Mpy_32_16_ss(254778081, add(global_gain_idx, global_gain_off), &mh, &ml); + tmp32 = L_shl_pos(mh, 9) | L_deposit_l((shr((Word16)ml, 7)) & 0x1ff); + move16(); + /* Uses an argument in Q25 */ + global_gain = BASOP_Util_InvLog2_lc3plus(L_or(tmp32, (Word32)0xFE000000)); +#else + tmp32 = L_shl_pos(L_mult0(add(global_gain_idx, global_gain_off), 0x797D), 7); + /* Uses an argument in Q25 */ + global_gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, (Word32)0xFE000000))); +#endif + global_gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); + + FOR (i = 0; i < xLen; i++) + { +#ifdef ENABLE_HR_MODE + x[i] = Mpy_32_32_lc3plus(x[i], global_gain); +#else + x[i] = Mpy_32_16_lc3plus(x[i], global_gain); +#endif + move32(); + } + + *x_e = add(*x_e, global_gain_e); move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c new file mode 100644 index 000000000..8092aa28e --- /dev/null +++ b/lib_lc3plus/ari_codec.c @@ -0,0 +1,2465 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + + +typedef struct +{ + Word16 inv_bin; + Word16 numbytes; + Word16 c_bp; + Word16 c_bp_side; + Word16 bytes; + Word16 b_left; + Word16 b_right; + Word16 enc; + Word16 sim_dec; + Word16 bfi; + Word16 be_bp_left; + Word16 be_bp_right; +} Pc_State_fx; + +typedef struct +{ + UWord32 ac_low_fx; + UWord32 ac_range_fx; + Word16 ac_cache_fx; + Word16 ac_carry_fx; + Word16 ac_carry_count_fx; +} Encoder_State_fx; + +typedef struct +{ + UWord32 ac_low_fx; + UWord32 ac_range_fx; + UWord32 ac_help_fx; + Word16 BER_detect; + Pc_State_fx pc; +} Decoder_State_fx; + +static void ac_dec_init_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_side, Word16 *mask_side, + Decoder_State_fx *st_fx /* i/o: Decoder State */ +); + +static __forceinline void pc_init_fx(Word16 n_pc, Word16 numbytes, Word16 be_bp_left, Word16 be_bp_right, Word16 L_spec, + Word16 enc, Word16 sim_dec, Word16 bfi, Pc_State_fx *pc /* i/o: Pc State */ +); +static __forceinline Word16 check_pc_bytes(Word16 *bp, Word16 *bp_side, Word16 *mask_side, Word16 cur_bin, + Word16 from_left, Pc_State_fx *pc /* i/o: Pc State */ +); + +static void ac_enc_init_fx(Encoder_State_fx *st_fx /* i/o: Encoder state */ +); + +static void ac_enc_shift_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx /* i/o: Encoder state */ +); + +static void write_indice_forward(UWord8 *ptr, Word16 bp, Word16 indice, Word16 numbits); + +static void ac_encode_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx, /* i/o: Encoder state */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol */ + UWord32 sym_freq /* i : Symbol probability */ +); + +static Word16 ac_enc_finish_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx /* i/o: Encoder state */ +); + +static Word16 ac_decode_fx( /* o : Decoded cumulative frequency */ + Decoder_State_fx *st_fx, /* i/o: Decoder State */ + Word16 pki); +static Word16 ac_decode_tns_order( /* o : Decoded cumulative frequency */ + Decoder_State_fx *st_fx, /* i/o: Decoder State */ + Word16 enable_lpc_weighting); +static Word16 ac_decode_tns_coef( /* o : Decoded cumulative frequency */ + Decoder_State_fx *st_fx, /* i/o: Decoder State */ + Word16 pki); +static Word16 ac_dec_update_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_side, Word16 *mask_side, Word16 cur_bin, + Decoder_State_fx *st_fx, /* i/o: Decoder State */ + UWord32 cum_freq, /* i : Cumulative frequency */ + UWord32 sym_freq /* i : Symbol frequency */ +); + +/*************************************************************************/ + +# ifdef ENABLE_HR_MODE + +Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side_in, Word16 mask_side_in, Word16 nbbits, Word32 xq[], + Word16 *tns_order, Word16 tns_numfilters, Word16 *tns_idx, Word16 lastnz, + Word16 *codingdata, UWord8 *resBits, Word16 numResBits, Word16 lsbMode, + Word16 enable_lpc_weighting, Word8 *scratchBuffer) +{ + Word16 resbit, i1, i2; + + Dyn_Mem_Deluxe_In(Encoder_State_fx st; Word16 bp, bp_side, mask_side, extra_bits; + Word32 a1, b1, a1_i, b1_i, a1_msb, b1_msb; Word16 lev1; Word16 nbits_side; Word16 tmp; + Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Counter i, n, k, lev;); + + lsb = (Word16 *)scratchAlign(scratchBuffer, 0); /* size = 2 * lastnz */ + + /* Init */ + a1_i = 0; + move16(); + b1_i = 1; + move16(); + bp = 0; + move16(); + numResBitsEnc = 0; + move16(); + nlsbs = 0; + move16(); + ptr = bytes; + bp_side = bp_side_in; + move16(); + mask_side = mask_side_in; + move16(); + + /*Start Encoding*/ + ac_enc_init_fx(&st); + + /* TNS data */ + FOR (n = 0; n < tns_numfilters; n++) + { + IF (tns_order[n] > 0) + { + ac_encode_fx(ptr, &bp, &st, ac_tns_order_cumfreq[enable_lpc_weighting][tns_order[n] - 1], + ac_tns_order_freq[enable_lpc_weighting][tns_order[n] - 1]); + FOR (k = 0; k < tns_order[n]; k++) + { + ac_encode_fx(ptr, &bp, &st, ac_tns_coef_cumfreq[k][tns_idx[MAXLAG * n + k]], + ac_tns_coef_freq[k][tns_idx[MAXLAG * n + k]]); + } + } + } + + IF (lsbMode == 0) + { + + /*Main Loop through the 2-tuples*/ + FOR (k = 0; k < lastnz; k += 2) + { + IF (codingdata[1] < 0) + { + ac_encode_fx(ptr, &bp, &st, 0, + ari_spec_freq[ari_spec_lookup[codingdata[0]]][0]); + } + ELSE IF (codingdata[1] == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][codingdata[2]]); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[a1_i], 31)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[b1_i], 31)); + } + } + ELSE IF (sub(codingdata[1], 1) == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][VAL_ESC]); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]]); + write_bit_backward(ptr, &bp_side, &mask_side, L_and(xq[a1_i], 1)); + write_bit_backward(ptr, &bp_side, &mask_side, L_and(xq[b1_i], 1)); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[a1_i], 31)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[b1_i], 31)); + } + } + ELSE + { + a1 = L_abs(xq[a1_i]); + b1 = L_abs(xq[b1_i]); + FOR (lev = 0; lev < codingdata[1]; lev++) + { + lev1 = s_min(lev, 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC]); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(L_shr_pos(a1, lev), 1)); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(L_shr_pos(b1, lev), 1)); + } + lev1 = s_min(codingdata[1], 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]]); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[a1_i], 31)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[b1_i], 31)); + } + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /*end of the 2-tuples loop*/ + } + ELSE + { + /*Main Loop through the 2-tuples*/ + FOR (k = 0; k < lastnz; k += 2) + { + IF (codingdata[1] < 0) + { + ac_encode_fx(ptr, &bp, &st, 0, + ari_spec_freq[ari_spec_lookup[codingdata[0]]][0]); + } + ELSE IF (codingdata[1] == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][codingdata[2]]); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[a1_i], 31)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[b1_i], 31)); + } + } + ELSE IF (sub(codingdata[1], 1) == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][VAL_ESC]); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]]); + a1_msb = s_and(codingdata[2], 0x3); + tmp = L_and(xq[a1_i], 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (a1_msb == 0 && tmp > 0) + { + if (xq[a1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[a1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + IF (a1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[a1_i], 31)); + } + b1_msb = shr_pos(codingdata[2], 2); + tmp = L_and(xq[b1_i], 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (b1_msb == 0 && tmp > 0) + { + if (xq[b1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[b1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + IF (b1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[b1_i], 31)); + } + } + ELSE + { + a1 = L_abs(xq[a1_i]); + b1 = L_abs(xq[b1_i]); + a1_msb = L_shr_pos(a1, 1); + tmp = L_and(a1, 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (a1_msb == 0 && tmp > 0) + { + if (xq[a1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[a1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + b1_msb = L_shr_pos(b1, 1); + tmp = s_and(b1, 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (b1_msb == 0 && tmp > 0) + { + if (xq[b1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[b1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[0]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[0]]][VAL_ESC]); + FOR (lev = 1; lev < codingdata[1]; lev++) + { + lev1 = s_min(lev, 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC]); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(L_shr_pos(a1, lev), 1)); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(L_shr_pos(b1, lev), 1)); + } + lev1 = s_min(codingdata[1], 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]]); + IF (a1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[a1_i], 31)); + } + IF (b1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, L_lshr(xq[b1_i], 31)); + } + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /*end of the 2-tuples loop*/ + } + + /* Side bits (in sync with the decoder) */ + nbits_side = sub(nbbits, add(shl_pos(bp_side, 3), sub(norm_s(mask_side), 6))); + + /* Residual bits (in sync with the decoder) */ + extra_bits = sub(norm_ul(st.ac_range_fx), 6); + if (st.ac_cache_fx >= 0) + { + extra_bits = add(extra_bits, 8); + } + if (st.ac_carry_count_fx > 0) + { + extra_bits = add(extra_bits, shl_pos(st.ac_carry_count_fx, 3)); + } + + n = s_max(sub(nbbits, add(shl_pos(bp, 3), add(extra_bits, nbits_side))), 0); + move16(); + + IF (lsbMode == 0) + { + numResBitsEnc = s_min(numResBits, n); + FOR (i = 0; i < numResBitsEnc; i++) + { + resbit = 0; move16(); + i1 = shr(i, RESBITS_PACK_SHIFT); + i2 = s_and(i, RESBITS_PACK_MASK); + if (s_and(resBits[i1], shl(1, i2))) + { + resbit = 1; + } + write_bit_backward(ptr, &bp_side, &mask_side, resbit); + } + } + ELSE + { + nlsbs = s_min(nlsbs, n); + FOR (k = 0; k < nlsbs; k++) + { + write_bit_backward(ptr, &bp_side, &mask_side, lsb[k]); + } + } + + /* End arithmetic coder, overflow management */ + extra_bits = ac_enc_finish_fx(ptr, &bp, &st); + + /* Fill bits (for debugging, the exact number of fill bits cannot be computed in the decoder)*/ + fill_bits = nbbits - (bp * 8 + extra_bits + nbits_side + nlsbs + numResBitsEnc); + + Dyn_Mem_Deluxe_Out(); + + return fill_bits; +} + +# else /* ENABLE_HR_MODE */ + +Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side_in, Word16 mask_side_in, Word16 nbbits, Word16 xq[], + Word16 *tns_order, Word16 tns_numfilters, Word16 *tns_idx, Word16 lastnz, + Word16 *codingdata, UWord8 *resBits, Word16 numResBits, Word16 lsbMode, + Word16 enable_lpc_weighting, Word8 *scratchBuffer) +{ +#ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In(Encoder_State_fx st; Word16 bp, bp_side, mask_side, extra_bits; + Word16 a1, b1, a1_i, b1_i, a1_msb, b1_msb; Word16 lev1; Word16 nbits_side; Word16 tmp; + Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Counter i, n, k, lev; + ); +#else + Dyn_Mem_Deluxe_In(Encoder_State_fx st; Word16 bp, bp_side, mask_side, extra_bits; + Word16 a1, b1, a1_i, b1_i, a1_msb, b1_msb; Word16 lev1; Word16 nbits_side; Word16 tmp; + Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Counter i, n, k, lev; + ); +#endif + + + lsb = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN * 2 bytes */ + + /* Init */ + a1_i = 0; + move16(); + b1_i = 1; + move16(); + bp = 0; + move16(); + numResBitsEnc = 0; + move16(); + nlsbs = 0; + move16(); + ptr = bytes; + bp_side = bp_side_in; + move16(); + mask_side = mask_side_in; + move16(); + + /*Start Encoding*/ + ac_enc_init_fx(&st); + + /* TNS data */ + FOR (n = 0; n < tns_numfilters; n++) + { + IF (tns_order[n] > 0) + { + ac_encode_fx(ptr, &bp, &st, ac_tns_order_cumfreq[enable_lpc_weighting][tns_order[n] - 1], + ac_tns_order_freq[enable_lpc_weighting][tns_order[n] - 1]); + FOR (k = 0; k < tns_order[n]; k++) + { + ac_encode_fx(ptr, &bp, &st, ac_tns_coef_cumfreq[k][tns_idx[MAXLAG * n + k]], + ac_tns_coef_freq[k][tns_idx[MAXLAG * n + k]]); + } + } + } + + IF (lsbMode == 0) + { + + /*Main Loop through the 2-tuples*/ + FOR (k = 0; k < lastnz; k += 2) + { + IF (codingdata[1] < 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][0], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][0]); + } + ELSE IF (codingdata[1] == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][codingdata[2]]); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[a1_i], 15)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[b1_i], 15)); + } + } + ELSE IF (sub(codingdata[1], 1) == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][VAL_ESC]); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]]); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(xq[a1_i], 1)); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(xq[b1_i], 1)); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[a1_i], 15)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[b1_i], 15)); + } + } + ELSE + { + a1 = abs_s(xq[a1_i]); + b1 = abs_s(xq[b1_i]); + FOR (lev = 0; lev < codingdata[1]; lev++) + { + lev1 = s_min(lev, 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC]); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(shr_pos(a1, lev), 1)); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(shr_pos(b1, lev), 1)); + } + lev1 = s_min(codingdata[1], 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]]); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[a1_i], 15)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[b1_i], 15)); + } + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /*end of the 2-tuples loop*/ + } + ELSE + { + /*Main Loop through the 2-tuples*/ + FOR (k = 0; k < lastnz; k += 2) + { + IF (codingdata[1] < 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][0], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][0]); + } + ELSE IF (codingdata[1] == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][codingdata[2]]); + IF (xq[a1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[a1_i], 15)); + } + IF (xq[b1_i] != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[b1_i], 15)); + } + } + ELSE IF (sub(codingdata[1], 1) == 0) + { + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0]]][VAL_ESC]); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[1]]][codingdata[2]]); + a1_msb = s_and(codingdata[2], 0x3); + tmp = s_and(xq[a1_i], 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (a1_msb == 0 && tmp > 0) + { + if (xq[a1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[a1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + IF (a1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[a1_i], 15)); + } + b1_msb = shr_pos(codingdata[2], 2); + tmp = s_and(xq[b1_i], 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (b1_msb == 0 && tmp > 0) + { + if (xq[b1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[b1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + IF (b1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[b1_i], 15)); + } + } + ELSE + { + a1 = abs_s(xq[a1_i]); + b1 = abs_s(xq[b1_i]); + a1_msb = shr_pos(a1, 1); + tmp = s_and(a1, 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (a1_msb == 0 && tmp > 0) + { + if (xq[a1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[a1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + b1_msb = shr_pos(b1, 1); + tmp = s_and(b1, 1); + lsb[nlsbs++] = tmp; + move16(); + test(); + IF (b1_msb == 0 && tmp > 0) + { + if (xq[b1_i] > 0) + { + lsb[nlsbs++] = 0; + move16(); + } + if (xq[b1_i] < 0) + { + lsb[nlsbs++] = 1; + move16(); + } + } + ac_encode_fx(ptr, &bp, &st, ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[0]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[0]]][VAL_ESC]); + FOR (lev = 1; lev < codingdata[1]; lev++) + { + lev1 = s_min(lev, 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][VAL_ESC]); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(shr_pos(a1, lev), 1)); + write_bit_backward(ptr, &bp_side, &mask_side, s_and(shr_pos(b1, lev), 1)); + } + lev1 = s_min(codingdata[1], 3); + ac_encode_fx(ptr, &bp, &st, + ari_spec_cumfreq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]], + ari_spec_freq[ari_spec_lookup[codingdata[0] + Tab_esc_nb[lev1]]][codingdata[2]]); + IF (a1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[a1_i], 15)); + } + IF (b1_msb != 0) + { + write_bit_backward(ptr, &bp_side, &mask_side, lshr(xq[b1_i], 15)); + } + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /*end of the 2-tuples loop*/ + } + + /* Side bits (in sync with the decoder) */ + nbits_side = sub(nbbits, add(shl_pos(bp_side, 3), sub(norm_s(mask_side), 6))); + + /* Residual bits (in sync with the decoder) */ + extra_bits = sub(norm_ul(st.ac_range_fx), 6); + if (st.ac_cache_fx >= 0) + { + extra_bits = add(extra_bits, 8); + } + if (st.ac_carry_count_fx > 0) + { + extra_bits = add(extra_bits, shl_pos(st.ac_carry_count_fx, 3)); + } + + n = s_max(sub(nbbits, add(shl_pos(bp, 3), add(extra_bits, nbits_side))), 0); + move16(); + + IF (lsbMode == 0) + { + numResBitsEnc = s_min(numResBits, n); + FOR (i = 0; i < numResBitsEnc; i++) + { + FOR (i = 0; i < numResBitsEnc; i++) + { + write_bit_backward(ptr, &bp_side, &mask_side, resBits[i]); + } + } + } + ELSE + { + nlsbs = s_min(nlsbs, n); + FOR (k = 0; k < nlsbs; k++) + { + write_bit_backward(ptr, &bp_side, &mask_side, lsb[k]); + } + } + + /* End arithmetic coder, overflow management */ + extra_bits = ac_enc_finish_fx(ptr, &bp, &st); + + /* Fill bits (for debugging, the exact number of fill bits cannot be computed in the decoder)*/ + fill_bits = nbbits - (bp * 8 + extra_bits + nbits_side + nlsbs + numResBitsEnc); + + Dyn_Mem_Deluxe_Out(); + return fill_bits; +} + +#endif /* ENABLE_HR_MODE */ + +void processAriDecoder_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 L_spec, + Word16 fs_idx, Word16 enable_lpc_weighting, Word16 tns_numfilters, Word16 lsbMode, + Word16 lastnz, Word16 *bfi, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, + Word16 frame_dms, + Word16 n_pc, Word16 be_bp_left, Word16 be_bp_right, Word16 mode, Word16 *spec_inv_idx, + Word16 *b_left, + Word16 *resBits, +# ifdef ENABLE_HR_MODE + Word32 *x, +# else + Word16 *x, +# endif + Word16 *nf_seed, UWord8 *resQdata, Word16 *tns_idx, Word16 *zero_frame, Word8 *scratchBuffer +# ifdef ENABLE_HR_MODE + , Word16 hrmode +# endif +) +{ + Decoder_State_fx st; +# ifdef ENABLE_HR_MODE + Word16 resbit, i1, i2; + Word32 a, b; +# else + Word16 a, b; +# endif + Word16 t, a1, b1, a1_i, b1_i, bp; + Word16 esc_nb; + Word16 rateFlag; + Word16 r; + Word16 nt_half; + Word16 c; + Word16 nbits_side, extra_bits, nbits_ari; + UWord8 * ptr; + Word32 tmp32; + Word16 lsb_ind_c; + Word16 * lsb_ind; + Word16 tmp; + Counter n, k, lev; + Counter i; + Word16 max_lev = 14; + +#ifdef DYNMEM_COUNT +struct _dynmem +{ +Decoder_State_fx st; + Pc_State_fx pc; + Word16 resbit, i1, i2; +# ifdef ENABLE_HR_MODE + Word32 a, b; +# else + Word16 a, b; +# endif + Word16 t, a1, b1, a1_i, b1_i, bp; + Word16 esc_nb; + Word16 rateFlag; + Word16 r; + Word16 nt_half; + Word16 c; + Word16 nbits_side, extra_bits, nbits_ari; + UWord8 * ptr; + Word32 tmp32; + Word16 lsb_ind_c; + Word16 * lsb_ind; + Word16 tmp; + Counter i, n, k, lev; + }; + Dyn_Mem_In("processAriDecoder_fx", sizeof(struct _dynmem)); +#endif + +# ifdef ENABLE_HR_MODE + if (hrmode == 1) + { + max_lev = max_lev + 8; + } +# endif + + lsb_ind = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size 2 * MAX_LEN bytes */ + + /* Rate flag */ + rateFlag = 0; + move16(); +# ifdef ENABLE_HR_MODE + if (fs_idx != 5) /* Don't update rateFlag for 96000 Hz */ +# endif + { + if (sub(nbbits, add(160, DEPR_i_mult(fs_idx, 160))) > 0) + { + rateFlag = 2 << NBITS_CONTEXT; + move16(); + } + } + + pc_init_fx(n_pc, shr_pos(nbbits, 3), be_bp_left, be_bp_right, L_spec, mode==1, mode==2, *bfi, &st.pc); + + /* Init */ + nt_half = shr_pos(L_spec, 1); + c = 0; + move16(); + t = 0; + move16(); + a1_i = 0; + move16(); + b1_i = 1; + move16(); + bp = 0; + move16(); + if (mode != 1) + { + bp = add(bp, st.pc.bytes); + move16(); + } + *spec_inv_idx = L_spec; + move16(); + *b_left = -1; + move16(); + lsb_ind_c = 0; + move16(); + +ptr = bytes; + +/* Start Decoding */ +ac_dec_init_fx(ptr, &bp, bp_side, mask_side, &st); + + /* Decode TNS data */ + tmp = MAXLAG; +IF (sub(frame_dms, 25) == 0) +{ +tmp = shr_pos(tmp, 1); +} +IF (sub(frame_dms, 50) == 0) +{ +tmp = shr_pos(tmp, 1); +} + + FOR (n = 0; n < tns_numfilters; n++) + { + IF (tns_order[n] > 0) + { + tns_order[n] = ac_decode_tns_order(&st, enable_lpc_weighting); + move16(); + tns_order[n] = add(tns_order[n], 1); + move16(); + IF (tns_order[n] > tmp) + { + GOTO ber_detect; + } + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, 0, &st, + ac_tns_order_cumfreq[enable_lpc_weighting][tns_order[n] - 1], + ac_tns_order_freq[enable_lpc_weighting][tns_order[n] - 1]) != 0) + { + GOTO ber_detect; + } + FOR (k = 0; k < tns_order[n]; k++) + { + IF (sub(*bp_side, bp) < 0) + { + GOTO ber_detect; + } + tns_idx[MAXLAG * n + k] = ac_decode_tns_coef(&st, k); + move16(); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, 0, &st, + ac_tns_coef_cumfreq[k][tns_idx[MAXLAG * n + k]], + ac_tns_coef_freq[k][tns_idx[MAXLAG * n + k]]) != 0) + { + GOTO ber_detect; + } + } + } + } + IF (st.BER_detect > 0) + { + GOTO ber_detect; + } + +IF (lsbMode == 0) +{ + +/*Main Loop through the 2-tuples*/ +FOR (k = 0; k < lastnz; k += 2) +{ + +/* Get context */ +t = add(c, rateFlag); +if (sub(k, nt_half) > 0) +{ +t = add(t, 1 << NBITS_CONTEXT); +} + + r = ac_decode_fx(&st, ari_spec_lookup[t]); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t]][r], + ari_spec_freq[ari_spec_lookup[t]][r]) != 0) + { + GOTO ber_detect; + } + + IF (r == 0) + { + x[a1_i] = 0; + move16(); + x[b1_i] = 0; + move16(); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (sub(r, VAL_ESC) < 0) + { + a = s_and(r, 0x3); + b = shr_pos(r, 2); + c = add(shl_pos(s_and(c, 0xf), 4), add(add(a, b), 1)); + IF (a > 0) + { +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} + if (read_bit(ptr, bp_side, mask_side) != 0) + { + a = negate(a); + } + } + x[a1_i] = a; + move16(); + IF (b > 0) + { +if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} + if (read_bit(ptr, bp_side, mask_side) != 0) + { + b = negate(b); + } + } + x[b1_i] = b; + move16(); + } + ELSE + { +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ +GOTO ber_detect; +} +a = read_bit(ptr, bp_side, mask_side); +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ +GOTO ber_detect; +} + b = read_bit(ptr, bp_side, mask_side); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[1]]); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, + ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[1]]][r], + ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[1]]][r]) != 0) + { + GOTO ber_detect; + } + IF (sub(r, VAL_ESC) < 0) + { + a1 = s_and(r, 0x3); + b1 = shr_pos(r, 2); + a = add(shl_pos(a1, 1), a); + b = add(shl_pos(b1, 1), b); + IF (a > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { + a = negate(a); + } + } + x[a1_i] = a; + move16(); + IF (b > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { + b = negate(b); + } + } + x[b1_i] = b; + move16(); + c = add(shl_pos(s_and(c, 0xf), 4), add(shl_pos(add(a1, b1), 1), 1)); + } + ELSE + { +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} +a = add(shl_pos(read_bit(ptr, bp_side, mask_side), 1), a); +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} + b = add(shl_pos(read_bit(ptr, bp_side, mask_side), 1), b); + FOR (lev = 2; lev < max_lev; lev++) + { + esc_nb = s_min(lev, 3); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[esc_nb]]); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, + ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r], + ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r]) != 0) + { + GOTO ber_detect; + } + IF (sub(r, VAL_ESC) < 0) + { + BREAK; + } + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + +# ifdef ENABLE_HR_MODE + a = L_add(L_shl(read_bit(ptr, bp_side, mask_side), lev), a); +# else + a = add(shl(read_bit(ptr, bp_side, mask_side), lev), a); +# endif + + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } +# ifdef ENABLE_HR_MODE + b = L_add(L_shl(read_bit(ptr, bp_side, mask_side), lev), b); +# else + b = add(shl(read_bit(ptr, bp_side, mask_side), lev), b); +# endif + } + /* check for bitflip */ + IF (sub(lev, max_lev) == 0) + { + GOTO ber_detect; + } + + b1 = shr_pos(r, 2); + a1 = s_and(r, 0x3); + +# ifdef ENABLE_HR_MODE + a = L_add(L_shl(a1, lev), a); + b = L_add(L_shl(b1, lev), b); +# else + a = add(shl(a1, lev), a); + b = add(shl(b1, lev), b); +# endif + IF (a > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { +# ifdef ENABLE_HR_MODE + a = L_negate(a); +# else + a = negate(a); +# endif + } + } + x[a1_i] = a; + move16(); + IF (b > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { +# ifdef ENABLE_HR_MODE + b = L_negate(b); +# else + b = negate(b); +# endif + } + } + x[b1_i] = b; + move16(); + c = add(shl_pos(s_and(c, 0xf), 4), add(esc_nb, 12)); + } + } + + test(); + test(); + IF ((sub(sub(bp, *bp_side), 3) > 0 && sub(st.pc.c_bp, st.pc.c_bp_side) == 0) || st.BER_detect > 0) +{ +GOTO ber_detect; +} + +a1_i += 2; +b1_i += 2; +} +} +ELSE +{ +/*Main Loop through the 2-tuples*/ +FOR (k = 0; k < lastnz; k += 2) +{ + +/* Get context */ +t = add(c, rateFlag); +if (sub(k, nt_half) > 0) +{ +t = add(t, 1 << NBITS_CONTEXT); +} + + r = ac_decode_fx(&st, ari_spec_lookup[t]); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t]][r], + ari_spec_freq[ari_spec_lookup[t]][r]) != 0) + { + GOTO ber_detect; + } + + IF (r == 0) + { + x[a1_i] = 0; + move16(); + x[b1_i] = 0; + move16(); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (sub(r, VAL_ESC) < 0) + { + a = s_and(r, 0x3); + b = shr_pos(r, 2); + c = add(shl_pos(s_and(c, 0xf), 4), add(add(a, b), 1)); + IF (a > 0) + { +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} + if (read_bit(ptr, bp_side, mask_side) != 0) + { + a = negate(a); + } + } + x[a1_i] = a; + move16(); + IF (b > 0) + { +if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} + if (read_bit(ptr, bp_side, mask_side) != 0) + { + b = negate(b); + } + } + x[b1_i] = b; + move16(); + } + ELSE + { + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[1]]); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, + ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[1]]][r], + ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[1]]][r]) != 0) + { + GOTO ber_detect; + } + IF (sub(r, VAL_ESC) < 0) + { + a1 = s_and(r, 0x3); + b1 = shr_pos(r, 2); + a = shl_pos(a1, 1); + b = shl_pos(b1, 1); + IF (a > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { + a = negate(a); + } + } + x[a1_i] = a; + move16(); + IF (b > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { + b = negate(b); + } + } + x[b1_i] = b; + move16(); + c = add(shl_pos(s_and(c, 0xf), 4), add(shl_pos(add(a1, b1), 1), 1)); + lsb_ind[lsb_ind_c++] = k; + move16(); + } + ELSE + { +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} +a = shl_pos(read_bit(ptr, bp_side, mask_side), 1); +if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) +{ + GOTO ber_detect; +} + b = shl_pos(read_bit(ptr, bp_side, mask_side), 1); + FOR (lev = 2; lev < max_lev; lev++) + { + esc_nb = s_min(lev, 3); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[esc_nb]]); + if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, + ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r], + ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r]) != 0) + { + GOTO ber_detect; + } + IF (sub(r, VAL_ESC) < 0) + { + BREAK; + } + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } +# ifdef ENABLE_HR_MODE + a = L_add(L_shl(read_bit(ptr, bp_side, mask_side), lev), a); +# else + a = add(shl(read_bit(ptr, bp_side, mask_side), lev), a); +# endif + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } +# ifdef ENABLE_HR_MODE + b = L_add(L_shl(read_bit(ptr, bp_side, mask_side), lev), b); +# else + b = add(shl(read_bit(ptr, bp_side, mask_side), lev), b); +# endif + } + /* check for bitflip */ + IF (sub(lev, max_lev) == 0) + { + GOTO ber_detect; + } + + b1 = shr_pos(r, 2); + a1 = s_and(r, 0x3); +# ifdef ENABLE_HR_MODE + a = L_add(L_shl(a1, lev), a); + b = L_add(L_shl(b1, lev), b); +# else + a = add(shl(a1, lev), a); + b = add(shl(b1, lev), b); +# endif + IF (a > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { +# ifdef ENABLE_HR_MODE + a = L_negate(a); +# else + a = negate(a); +# endif + } + } + x[a1_i] = a; + move16(); + IF (b > 0) + { + if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) + { + GOTO ber_detect; + } + if (read_bit(ptr, bp_side, mask_side) != 0) + { +# ifdef ENABLE_HR_MODE + b = L_negate(b); +# else + b = negate(b); +# endif + } + } + x[b1_i] = b; + move16(); + c = add(shl_pos(s_and(c, 0xf), 4), add(esc_nb, 12)); + lsb_ind[lsb_ind_c++] = k; + move16(); + } + } + + test(); + test(); + IF ((sub(sub(bp, *bp_side), 3) > 0 && sub(st.pc.c_bp, st.pc.c_bp_side) == 0) || st.BER_detect > 0) +{ +GOTO ber_detect; +} + +a1_i += 2; +b1_i += 2; +} +} + +IF (L_spec > k) +{ +basop_memset(&x[k], 0, (L_spec - k) * sizeof(*x)); +} + + nbits_side = sub(nbbits, add(shl_pos(*bp_side, 3), sub(norm_s(*mask_side), 6))); + extra_bits = sub(norm_ul(st.ac_range_fx), 6); + nbits_ari = shl_pos(sub(bp, 3), 3); +IF (mode != 1) +{ +IF (st.pc.c_bp == 0) +{ +nbits_ari = shl_pos(sub(sub(bp, st.pc.bytes), 3), 3); +} +ELSE +{ +nbits_ari = shl_pos(add(bp, sub(sub(st.pc.b_left, st.pc.bytes), 3)), 3); +} + + IF (st.pc.c_bp_side != 0) + { + nbits_side = sub(add(sub(nbbits, shl_pos(st.pc.b_left, 3)), shl_pos(sub(st.pc.bytes, *bp_side), 3)), + sub(norm_s(*mask_side), 6)); + } + } + + n = sub(nbbits, add(nbits_ari, add(extra_bits, nbits_side))); + move16(); + +IF (n < 0) +{ +GOTO ber_detect; +} + + IF (lsbMode == 0) + { + *resBits = n; + move16(); + i=0; + +#ifdef ENABLE_HR_MODE + FOR (k = 0; k < L_spec; k++) + { + IF (x[k] != 0) + { + IF (n == 0) + { + BREAK; + } + if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) + { + GOTO ber_detect_res; + } + i1 = shr(i, RESBITS_PACK_SHIFT); + i2 = s_and(i, RESBITS_PACK_MASK); + resbit = read_bit(ptr, bp_side, mask_side); + if (resbit) + { + resQdata[i1] = (UWord8) s_or(resQdata[i1], shl(1, i2)); + } + i = add(i, 1); + move16(); + n = sub(n, 1); + } + } +#else + FOR (k = 0; k < L_spec; k++) + { + IF (x[k] != 0) + { + IF (n == 0) + { + BREAK; + } + + if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) + { + GOTO ber_detect_res; + } + + *resQdata++ = (UWord8) read_bit(ptr, bp_side, mask_side); + move16(); + n = sub(n, 1); + } + } +#endif + +# ifdef ENABLE_HR_MODE + if (hrmode) + { + Word16 idx_len = sub(*resBits, n); /* Number of nonzero bits */ + Word16 idx_len_lim = idx_len * EXT_RES_ITER_MAX; + + Word16 res_bits_hrmode = s_min(idx_len_lim, *resBits) - idx_len; + /* idx_len bits have been read in the previous loop */ + + for (k = 0; k < res_bits_hrmode; k++) + { + if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) + { + GOTO ber_detect_res; + } + i1 = shr(i, RESBITS_PACK_SHIFT); + i2 = s_and(i, RESBITS_PACK_MASK); + resbit = read_bit(ptr, bp_side, mask_side); + if (resbit) + { + resQdata[i1] = (UWord8) s_or(resQdata[i1], shl(1, i2)); + } + i = add(i, 1); + move16(); + n = sub(n, 1); + } + } +# endif + + *resBits = sub(*resBits, n); + } + ELSE + { + *resBits = 0; + FOR (k = 0; k < lsb_ind_c; k++) + { + a = x[lsb_ind[k]]; + move16(); + IF (n == 0) + { + BREAK; + } +if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) +{ +GOTO ber_detect_res; +} + tmp = read_bit(ptr, bp_side, mask_side); + n = sub(n, 1); + IF (tmp > 0) + { +# ifdef ENABLE_HR_MODE + if (a > 0) + { + a = L_add(a, 1); + } + if (a < 0) + { + a = L_sub(a, 1); + } +# else + if (a > 0) + { + a = add(a, 1); + } + if (a < 0) + { + a = sub(a, 1); + } +# endif + IF (a == 0) + { + IF (n == 0) + { + BREAK; + } + a = 1; +if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) +{ + GOTO ber_detect_res; +} +if (read_bit(ptr, bp_side, mask_side) != 0) +{ + a = negate(a); +} +n = sub(n, 1); +} +} + + x[lsb_ind[k]] = a; + move16(); + b = x[lsb_ind[k] + 1]; + move16(); + IF (n == 0) + { + BREAK; + } +if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) +{ +GOTO ber_detect_res; +} + tmp = read_bit(ptr, bp_side, mask_side); + n = sub(n, 1); + IF (tmp > 0) + { +# ifdef ENABLE_HR_MODE + if (b > 0) + { + b = L_add(b, 1); + } + if (b < 0) + { + b = L_sub(b, 1); + } +# else + if (b > 0) + { + b = add(b, 1); + } + if (b < 0) + { + b = sub(b, 1); + } +# endif + IF (b == 0) + { + IF (n == 0) + { + BREAK; + } + b = 1; +if (check_pc_bytes(&bp, bp_side, mask_side, st.pc.inv_bin, 0, &st.pc) != 0) +{ + GOTO ber_detect_res; +} + if (read_bit(ptr, bp_side, mask_side) != 0) + { + b = negate(b); + } + n = sub(n, 1); + } + } + x[lsb_ind[k] + 1] = b; + move16(); + } + } + +/* Noise Filling seed */ + tmp32 = L_deposit_l(0); + FOR (i = 0; i < L_spec; i++) + { +# ifdef ENABLE_HR_MODE + tmp32 = L_mac0(tmp32, L_and(L_abs(x[i]), 32767), i); +# else + tmp32 = L_mac0(tmp32, abs_s(x[i]), i); +# endif + } + *nf_seed = extract_l(tmp32); + move16(); + + /* Detect zero frame */ + test(); + test(); + test(); + test(); + IF (sub(lastnz, 2) == 0 && sub(x[0], 0) == 0 && sub(x[1], 0) == 0 && sub(gg_idx, 0) == 0 && sub(fac_ns_idx, 7) == 0) + { + *zero_frame = 1; + move16(); + } + ELSE + { + *zero_frame = 0; + move16(); + } + +IF (mode == 1) + { + IF (st.pc.bytes > 0) + { + IF (sub(st.pc.b_left, shr_pos(nbbits, 3)) > 0) + { + *b_left = sub(*bp_side, st.pc.bytes); + } + } + } +IF (mode == 2) +{ +IF (st.pc.bytes > 0) +{ +IF (sub(st.pc.b_left, shr_pos(nbbits,3)) > 0) +{ +*b_left = *bp_side; +} +} +} + +IF (sub(*bfi, 2) == 0) +{ +IF (sub(*spec_inv_idx, L_spec) == 0) +{ +*bfi = 0; +} +} +GOTO bail; + +/* goto for bit error handling */ +ber_detect: + *bfi = 1; + move16(); + *b_left = st.pc.b_left; + move16(); + test(); + IF (st.pc.inv_bin > 0 && sub(st.pc.inv_bin, L_spec) <= 0) + { + *spec_inv_idx = st.pc.inv_bin; + move16(); + *bfi = 2; + move16(); + *resBits = 0; + move16(); + *zero_frame = 0; + move16(); + /* Noise Filling seed */ + tmp32 = L_deposit_l(0); + FOR (i = 0; i < *spec_inv_idx; i++) + { + tmp32 = L_mac0(tmp32, abs_s(x[i]), i); + } + *nf_seed = extract_l(tmp32); + move16(); + } +GOTO bail; + +/* goto for bit error handling in residual signal */ +ber_detect_res: + *b_left = st.pc.b_left; + move16(); + *resBits = 0; + move16(); + *bfi = 0; + move16(); + *zero_frame = 0; + move16(); + /* Noise Filling seed */ + tmp32 = L_deposit_l(0); + FOR (i = 0; i < *spec_inv_idx; i++) + { + tmp32 = L_mac0(tmp32, abs_s(x[i]), i); + } + *nf_seed = extract_l(tmp32); + move16(); + GOTO bail; + +/* goto, because of dynmem out */ +bail: +Dyn_Mem_Deluxe_Out(); +} + + +void processAriDecoderScaling_fx( +# ifdef ENABLE_HR_MODE + Word32 *datain, +# else + Word16 *data16, +# endif + Word16 dataLen, Word32 *data32, Word16 *data_e) +{ + Counter i; + +# ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In(Word16 shift; Word32 tmp, x_min, x_max;); +# else + Dyn_Mem_Deluxe_In(Word16 shift; Word16 tmp, x_min, x_max;); +# endif + + +#ifdef ENABLE_HR_MODE + x_max = 0; + move32(); + x_min = 0; + move32(); +#else + x_max = 0; + move16(); + x_min = 0; + move16(); +#endif + + FOR (i = 0; i < dataLen; i++) + { +#ifdef ENABLE_HR_MODE + if (datain[i] > 0) + x_max = L_max(x_max, datain[i]); + if (datain[i] < 0) + x_min = L_min(x_min, datain[i]); +#else + if (data16[i] > 0) + x_max = s_max(x_max, data16[i]); + if (data16[i] < 0) + x_min = s_min(x_min, data16[i]); +#endif + } + +#ifdef ENABLE_HR_MODE + tmp = L_max(x_max, L_negate(x_min)); + shift = norm_l(tmp); + if (tmp == 0) + { + shift = 31; + move32(); + } +#else + tmp = s_max(x_max, negate(x_min)); + shift = norm_s(tmp); + if (tmp == 0) + { + shift = 15; + move16(); + } +#endif + + FOR (i = 0; i < dataLen; i++) + { +#ifdef ENABLE_HR_MODE + data32[i] = L_shl_pos(datain[i], shift); +#else + data32[i] = L_shl_pos(L_deposit_h(data16[i]), shift); +#endif + } + +#ifdef ENABLE_HR_MODE + *data_e = sub(31, shift); + move16(); +#else + *data_e = sub(15, shift); + move16(); +#endif + + Dyn_Mem_Deluxe_Out(); +} + + +/*************************************************************************/ +/*************************************************************************/ +/*************************************************************************/ + +/*************************************************************************/ + +static __forceinline UWord32 UL_addNs24(UWord32 UL_var1, UWord32 UL_var2, UWord16 *wrap) +{ + return UL_lshr(UL_addNs(UL_lshl(UL_var1, 8), UL_lshl(UL_var2, 8), wrap), 8); +} +#ifdef ENABLE_HR_MODE +Word16 find_last_nz_pair(const Word32 x[], Word16 length) +#else +Word16 find_last_nz_pair(const Word16 x[], Word16 length) +#endif +{ + Dyn_Mem_Deluxe_In(Word16 last_nz, lobs[4]; Counter stage, i;); + + lobs[0] = 4; + move16(); + lobs[1] = shr_pos(length, 1); /* length/2 */ + move16(); + lobs[2] = add(lobs[1], shr_pos(length, 2)); + move16(); + lobs[3] = add(lobs[2], shr_pos(length, 3)); + move16(); + + last_nz = 0; + move16(); + i = length; + move16(); + FOR (stage = 3; stage >= 0; --stage) + { + /* unmapped kernel */ + FOR (; i >= lobs[stage]; i -= 2) + { + if (x[i - 2] != 0) + { + last_nz = s_max(last_nz, i); + } + if (x[i - 1] != 0) + { + last_nz = s_max(last_nz, i); + } + } + IF (last_nz > 0) + { + BREAK; + } + } + + Dyn_Mem_Deluxe_Out(); + return s_max(last_nz, 2); +} + + +void write_bit_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 bit) +{ + if (bit > 0) + { + ptr[*bp] = (UWord8)s_or((Word16)ptr[*bp], *mask); + move16(); + } + *mask = lshl_pos(*mask, 1); + move16(); + if (sub(*mask, 0x100) == 0) + { + *mask = 1; + move16(); + } + if (sub(*mask, 1) == 0) + { + *bp = sub(*bp, 1); + move16(); + } +} + + +void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, Word16 numbits) +{ + Dyn_Mem_Deluxe_In(Counter k; Word16 bit;); + + FOR (k = 0; k < numbits; k++) + { + bit = s_and(indice, 1); + write_bit_backward(ptr, bp, mask, bit); + indice = lshr(indice, 1); + } + + Dyn_Mem_Deluxe_Out(); +} + + +static __forceinline void write_indice_forward(UWord8 *ptr, Word16 bp, Word16 indice, Word16 numbits) +{ + Dyn_Mem_Deluxe_In(Counter k; Word16 bit, mask, tmp;); + + tmp = (Word16)ptr[bp]; + move16(); + mask = 0x80; + move16(); + FOR (k = 0; k < numbits; k++) + { + bit = s_and(indice, mask); + tmp = s_or(tmp, mask); + if (bit == 0) + { + tmp = sub(tmp, mask); + } + mask = lshr(mask, 1); + } + ptr[bp] = (UWord8)tmp; + move16(); + + Dyn_Mem_Deluxe_Out(); +} + +static __forceinline void ac_enc_init_fx(Encoder_State_fx *st_fx) /* i/o: Encoder state */ +{ + st_fx->ac_low_fx = L_deposit_l(0); + move32(); + st_fx->ac_range_fx = 0x00ffffff; + move32(); + st_fx->ac_cache_fx = -1; + move16(); + st_fx->ac_carry_fx = 0; + move16(); + st_fx->ac_carry_count_fx = 0; + move16(); +} + +static __forceinline void ac_enc_shift_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx) /* i/o: Encoder state */ +{ + test(); + L_sub(0, 0); /* For comparision in if */ + IF (st_fx->ac_low_fx < (0x00ff0000UL) || sub(st_fx->ac_carry_fx, 1) == 0) + { + IF (st_fx->ac_cache_fx >= 0) + { + ptr[(*bp)++] = (UWord8)add(st_fx->ac_cache_fx, st_fx->ac_carry_fx); + move16(); + } + + WHILE (st_fx->ac_carry_count_fx > 0) + { + ptr[(*bp)++] = (UWord8)s_and(add(st_fx->ac_carry_fx, 0xff), 255); + move16(); + st_fx->ac_carry_count_fx = sub(st_fx->ac_carry_count_fx, 1); + move16(); + } + + st_fx->ac_cache_fx = u_extract_l(UL_lshr_pos(st_fx->ac_low_fx, 16)); + move16(); + st_fx->ac_carry_fx = 0; + move16(); + } + ELSE + { + st_fx->ac_carry_count_fx = add(st_fx->ac_carry_count_fx, 1); + move16(); + } + st_fx->ac_low_fx = UL_and(UL_lshl_pos(st_fx->ac_low_fx, 8), 0x00ffffff); + move32(); +} + +static __forceinline void ac_encode_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx, /* i/o: Encoder state */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol */ + UWord32 sym_freq) /* i : Symbol probability */ +{ + Dyn_Mem_Deluxe_In(UWord32 r, tmp; UWord16 carry;); + + r = UL_lshr_pos(st_fx->ac_range_fx, 10); + tmp = UL_Mpy_32_32(r, cum_freq); + + assert(r < (1U << 24)); + assert(cum_freq < (1U << 24)); + assert(tmp < (1U << 24)); + assert(st_fx->ac_low_fx < (1U << 24)); + st_fx->ac_low_fx = UL_addNs24(st_fx->ac_low_fx, tmp, &carry); + move32(); + + if (carry != 0) + { + st_fx->ac_carry_fx = carry; + move16(); + } + + st_fx->ac_range_fx = UL_Mpy_32_32(r, sym_freq); + move32(); + + assert(cum_freq < (1U << 24)); + assert(st_fx->ac_range_fx < (1U << 24)); + WHILE (st_fx->ac_range_fx < (1U << 16)) + { + L_sub(0, 0); /* Comparison in while */ + st_fx->ac_range_fx = UL_lshl_pos(st_fx->ac_range_fx, 8); + move32(); + + assert(st_fx->ac_range_fx < (1U << 24)); + + ac_enc_shift_fx(ptr, bp, st_fx); + } + + Dyn_Mem_Deluxe_Out(); +} + +static __forceinline Word16 ac_enc_finish_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx) /* i/o: Encoder state */ +{ + Dyn_Mem_Deluxe_In(UWord32 val, mask, high; Word16 bits; UWord16 over1, over2;); + + /*bits = 24 - log2_i(st->ac_range); */ + bits = sub(norm_ul(st_fx->ac_range_fx), 7); + + mask = UL_lshr(0x00ffffff, bits); + + val = UL_addNs24(st_fx->ac_low_fx, mask, &over1); + high = UL_addNs24(st_fx->ac_low_fx, st_fx->ac_range_fx, &over2); + + L_xor(0, 0); /* For bit not */ + UL_and(1U, 1U); /* added counters */ + val = L_and(val, (~mask) & 0x00ffffff); + + L_xor(0, 0); /* For bit not */ + IF ((L_xor(over1, over2)) == 0) + { + L_sub(0, 0); /* For comparision in if */ + IF (UL_addNsD(val, mask) >= high) + { + bits = add(bits, 1); + mask = UL_lshr_pos(mask, 1); + val = UL_and(UL_addNsD(st_fx->ac_low_fx, mask), (~mask) & 0x00ffffff); + L_xor(0, 0); + UL_and(1, 1); /* For bit not , mask */ + } + + if (val < st_fx->ac_low_fx) + { + st_fx->ac_carry_fx = 1; + move16(); + } + } + + st_fx->ac_low_fx = val; + move32(); + + FOR (; bits > 0; bits -= 8) + { + ac_enc_shift_fx(ptr, bp, st_fx); + } + bits = add(bits, 8); + + assert(st_fx->ac_carry_fx == 0); + + IF (st_fx->ac_carry_count_fx > 0) + { + ptr[(*bp)++] = (UWord8)st_fx->ac_cache_fx; + move16(); + + FOR (; st_fx->ac_carry_count_fx > 1; st_fx->ac_carry_count_fx--) + { + ptr[(*bp)++] = 0xff; + move16(); + } + write_indice_forward(ptr, *bp, lshr(0xff, sub(8, bits)), bits); + } + ELSE + { + write_indice_forward(ptr, *bp, st_fx->ac_cache_fx, bits); + } + + Dyn_Mem_Deluxe_Out(); + return bits; +} + + +__forceinline Word16 read_bit(UWord8 *ptr, Word16 *bp, Word16 *mask) +{ + Dyn_Mem_Deluxe_In(Word16 bit;); + + bit = 0; + move16(); + if (s_and((Word16)ptr[*bp], *mask) > 0) + { + bit = 1; + move16(); + } + *mask = lshl_pos(*mask, 1); + move16(); + if (sub(*mask, 0x100) == 0) + { + *mask = 1; + move16(); + } + if (sub(*mask, 1) == 0) + { + *bp = sub(*bp, 1); + move16(); + } + + Dyn_Mem_Deluxe_Out(); + return bit; +} + + +static __forceinline void ac_dec_init_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_side, Word16 *mask_side, + Decoder_State_fx *st_fx) /* i/o: Decoder State */ +{ + Dyn_Mem_Deluxe_In(Counter i;); + + + st_fx->ac_low_fx = L_deposit_l(0); + move32(); + + st_fx->ac_range_fx = 0x00ffffff; + move32(); + FOR (i = 0; i < 3; i++) + { + if (check_pc_bytes(bp, bp_side, mask_side, 0, 1, &st_fx->pc) != 0) + { + Dyn_Mem_Deluxe_Out(); + return; + } + st_fx->ac_low_fx = UL_addNsD(UL_lshl_pos(st_fx->ac_low_fx, 8), UL_deposit_l((Word16)ptr[(*bp)++])); + move32(); + assert(st_fx->ac_low_fx < (1U << 24)); + } + + st_fx->BER_detect = 0; + move16(); + + Dyn_Mem_Deluxe_Out(); +} + +/* o : Decoded cumulative frequency */ +static __forceinline Word16 ac_decode_fx(Decoder_State_fx *st_fx, /* i/o: Decoder State */ + Word16 pki) +{ + Dyn_Mem_Deluxe_In(UWord16 sgn; Word16 val, r;); + + st_fx->ac_help_fx = UL_lshr_pos(st_fx->ac_range_fx, 10); + move32(); + val = 0; + move16(); + + r = add(val, 8); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ari_spec_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 4); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ari_spec_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 2); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ari_spec_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 1); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ari_spec_cumfreq[pki][r]), &sgn); + IF (sgn == 0) + { + val = r; + move16(); + IF (sub(val, 15) == 0) + { + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ari_spec_cumfreq[pki][16]), &sgn); + if (sgn == 0) + { + val = 16; + move16(); + } + UL_subNs(st_fx->ac_low_fx, UL_lshl(st_fx->ac_help_fx, 10), &sgn); + if (sgn == 0) + { + st_fx->BER_detect = 1; + move16(); + } + } + } + + Dyn_Mem_Deluxe_Out(); + return val; +} + +/* o : Decoded cumulative frequency */ +static __forceinline Word16 ac_decode_tns_order(Decoder_State_fx *st_fx, /* i/o: Decoder State */ + Word16 enable_lpc_weighting) +{ + Dyn_Mem_Deluxe_In(UWord16 sgn; Word16 val, r;); + + st_fx->ac_help_fx = UL_lshr_pos(st_fx->ac_range_fx, 10); + move32(); + val = 0; + move16(); + + r = add(val, 4); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_order_cumfreq[enable_lpc_weighting][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 2); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_order_cumfreq[enable_lpc_weighting][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 1); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_order_cumfreq[enable_lpc_weighting][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + UL_subNs(st_fx->ac_low_fx, UL_lshl(st_fx->ac_help_fx, 10), &sgn); + if (sgn == 0) + { + st_fx->BER_detect = 1; + move16(); + } + + Dyn_Mem_Deluxe_Out(); + return val; +} + +/* o : Decoded cumulative frequency */ +static __forceinline Word16 ac_decode_tns_coef(Decoder_State_fx *st_fx, /* i/o: Decoder State */ + Word16 pki) +{ + Dyn_Mem_Deluxe_In(UWord16 sgn; Word16 val, r;); + + st_fx->ac_help_fx = UL_lshr_pos(st_fx->ac_range_fx, 10); + move32(); + val = 0; + move16(); + + r = add(val, 8); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_coef_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 4); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_coef_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 2); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_coef_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + } + + r = add(val, 1); + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_coef_cumfreq[pki][r]), &sgn); + if (sgn == 0) + { + val = r; + move16(); + IF (sub(val, 15) == 0) + { + UL_subNs(st_fx->ac_low_fx, UL_Mpy_32_32(st_fx->ac_help_fx, ac_tns_coef_cumfreq[pki][16]), &sgn); + if (sgn == 0) + { + val = 16; + move16(); + } + UL_subNs(st_fx->ac_low_fx, UL_lshl(st_fx->ac_help_fx, 10), &sgn); + if (sgn == 0) + { + st_fx->BER_detect = 1; + move16(); + } + } + } + + Dyn_Mem_Deluxe_Out(); + return val; +} + +static __forceinline Word16 ac_dec_update_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_side, Word16 *mask_side, + Word16 cur_bin, Decoder_State_fx *st_fx, /* i/o: Decoder State */ + UWord32 cum_freq, /* i : Cumulative frequency */ + UWord32 sym_freq /* i : Symbol frequency */ +) +{ + UWord32 UL_tmp; + + + assert(st_fx->ac_help_fx < (1U << 24)); + assert(cum_freq < (1U << 24)); + + UL_tmp = UL_Mpy_32_32(cum_freq, st_fx->ac_help_fx); + assert(UL_tmp < (1U << 24)); + + st_fx->ac_low_fx = UL_subNsD(st_fx->ac_low_fx, UL_tmp); + move32(); /*0+0*/ + assert(st_fx->ac_low_fx < (1U << 24)); + + st_fx->ac_range_fx = UL_Mpy_32_32(st_fx->ac_help_fx, sym_freq); + move32(); + + assert(st_fx->ac_range_fx < (1U << 24)); + /* updated to 16 from 24 */ + WHILE (st_fx->ac_range_fx < (1U << 16)) + { + L_sub(0, 0); /* For comparision in while*/ + + st_fx->ac_low_fx = + UL_and(st_fx->ac_low_fx, 0x0000ffFF); /* make sure upshift doe not lead to more than 24 bits */ + assert(st_fx->ac_low_fx < 1U << 16); + + if (check_pc_bytes(bp, bp_side, mask_side, cur_bin, 1, &st_fx->pc) != 0) + return 1; + + /*shift in 8 bits */ + st_fx->ac_low_fx = UL_addNsD(UL_lshl_pos(st_fx->ac_low_fx, 8), UL_deposit_l((Word16)ptr[(*bp)++])); + move32(); + + assert(st_fx->ac_low_fx < (1U << 24)); + st_fx->ac_range_fx = UL_lshl_pos(st_fx->ac_range_fx, 8); + move32(); + assert(st_fx->ac_range_fx < (1U << 24)); + } + return 0; +} + +static __forceinline void pc_init_fx(Word16 n_pc, Word16 numbytes, Word16 be_bp_left, Word16 be_bp_right, Word16 L_spec, + Word16 enc, Word16 sim_dec, Word16 bfi, Pc_State_fx *pc /* i/o: Pc State */ +) +{ +pc->inv_bin = add(L_spec, 1); move16(); +pc->numbytes = numbytes; move16(); +pc->c_bp = 0; move16(); +pc->c_bp_side = 0; move16(); +pc->bytes = shr(add(n_pc, 1),1); move16(); +pc->b_left = add(numbytes,1); move16(); +pc->b_right = -1; move16(); +pc->enc = enc; move16(); +pc->sim_dec = sim_dec; move16(); +pc->bfi = bfi; move16(); +pc->be_bp_left = shr(be_bp_left, 3); move16(); +pc->be_bp_right = shr(be_bp_right, 3); move16(); + assert(pc->be_bp_right < pc->bytes || pc->bytes == 0); +} + +static __forceinline Word16 check_pc_bytes(Word16 *bp, Word16 *bp_side, Word16 *mask_side, Word16 cur_bin, + Word16 from_left, Pc_State_fx *pc /* i/o: Pc State */) +{ + Dyn_Mem_Deluxe_In(Word16 bp_local, bp_side_local, offset;); + + IF (pc->bytes > 0) + { + test(); + IF (from_left == 0 && sub(*mask_side, 1) != 0) + { + Dyn_Mem_Deluxe_Out(); + return 0; + } + test(); + IF (pc->c_bp_side > 0 && *bp_side < 0) + { + assert(*mask_side == 1); + assert(pc->b_right != -1); + *bp_side = pc->b_right; + Dyn_Mem_Deluxe_Out(); + return 0; + } + bp_local = *bp; + bp_side_local = *bp_side; + + IF (from_left != 0) + { + if (sub(*mask_side, 1) == 0) + { + bp_side_local = add(bp_side_local, 1); + } + } + ELSE + { + bp_local = sub(bp_local, 1); + } + + IF (pc->b_right < 0) + { + offset = -1; + move16(); + if (pc->enc == 0) + { + offset = add(offset, pc->bytes); + } + + IF (add(bp_side_local, sub(offset, bp_local)) == pc->bytes) + { + pc->b_left = add(bp_local, 1); + pc->b_right = sub(bp_side_local, 1); + IF (pc->enc != 0) + { + assert(pc->b_right - pc->b_left + 1 == pc->bytes); + Dyn_Mem_Deluxe_Out(); + return 1; + } + } + } + + test(); + IF (pc->enc == 0 && pc->b_right >= 0) + { + test(); + IF (from_left != 0 && sub(*bp, pc->b_left) == 0) + { + IF (pc->sim_dec == 1) + { + pc->b_left = *bp; + Dyn_Mem_Deluxe_Out(); + return 1; + } + *bp = 0; move16(); + pc->c_bp = 1; move16(); + } + test(); + IF (from_left == 0 && sub(bp_side_local, pc->b_right) == 0) + { + *bp_side = sub(pc->bytes, 1); + move16(); + pc->c_bp_side = 1; + move16(); + } + IF (sub(pc->bfi, 2) == 0) + { + test(); + test(); + IF ((pc->c_bp != 0 && sub(*bp, pc->be_bp_left) >= 0) || + (pc->c_bp_side != 0 && sub(*bp_side, pc->be_bp_right) <= 0)) + { + pc->inv_bin = cur_bin; + move16(); + Dyn_Mem_Deluxe_Out(); + return 1; + } + ELSE IF ((pc->c_bp != 0 && *bp >= 0) || (pc->c_bp_side != 0 && sub(*bp_side, sub(pc->bytes, 1)) <= 0)) + { + pc->inv_bin = s_min(pc->inv_bin, cur_bin); + Dyn_Mem_Deluxe_Out(); + return 0; + } + } + } + } + + Dyn_Mem_Deluxe_Out(); + return 0; +} + diff --git a/lib_lc3plus/attack_detector_fx.c b/lib_lc3plus/attack_detector_fx.c new file mode 100644 index 000000000..3c62f8494 --- /dev/null +++ b/lib_lc3plus/attack_detector_fx.c @@ -0,0 +1,119 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void attack_detector_fx(LC3PLUS_Enc *enc, EncSetup *setup, Word16 *input, Word16 input_scaling, void *scratch) +{ + Dyn_Mem_Deluxe_In( + int i, j, position; + Word32 tmp, *block_energy; + Word16 h16, l16, new_scaling, rescale, input_delta_scaling; + Word16 scales[3], *input_16k; + Word16 frame_length_16k; + ); + + block_energy = scratchAlign(scratch, 0); + input_16k = scratchAlign(block_energy, 4 * 4 + 4); + frame_length_16k = DEPR_i_mult(enc->attdec_nblocks, 40); + + IF (setup->attack_handling) + { + /* input scaling */ + scales[0] = add(getScaleFactor16(input, enc->frame_length), input_scaling); + scales[1] = add(getScaleFactor16_0(setup->attdec_filter_mem, 2), setup->attdec_scaling); + scales[2] = + shr(add(add(getScaleFactor32_0(&setup->attdec_acc_energy, 1), shl(setup->attdec_scaling, 1)), 1), 1); + new_scaling = s_min(scales[0], s_min(scales[1], scales[2])); + + new_scaling = sub(new_scaling, 2); /* add overhead for resampler*/ + + /* memory re-scaling */ + rescale = sub(new_scaling, setup->attdec_scaling); + + IF (rescale) + { + rescale = s_min(s_max(rescale, -15), 15); + setup->attdec_filter_mem[0] = shl(setup->attdec_filter_mem[0], rescale); move16(); + setup->attdec_filter_mem[1] = shl(setup->attdec_filter_mem[1], rescale); move16(); + setup->attdec_acc_energy = L_shl(setup->attdec_acc_energy, shl(rescale, 1)); move16(); + } + setup->attdec_scaling = new_scaling; move16(); + + SWITCH (enc->fs) + { + case 32000: + input_delta_scaling = sub(1, sub(new_scaling, input_scaling)); + FOR (i = 0; i < frame_length_16k; i++) + { + input_16k[i] = add(shr(input[2 * i + 0], input_delta_scaling), + shr(input[2 * i + 1], input_delta_scaling)); move16(); + } + break; + case 48000: + input_delta_scaling = sub(2, sub(new_scaling, input_scaling)); + FOR (i = 0; i < frame_length_16k; i++) + { + input_16k[i] = add(shr(input[3 * i + 0], input_delta_scaling), + add(shr(input[3 * i + 1], input_delta_scaling), + shr(input[3 * i + 2], input_delta_scaling))); move16(); + } + break; + default: ASSERT(!"sampling rate not supported in function attack_detector_fx!"); break; + } + + input_16k[-2] = setup->attdec_filter_mem[0]; move16(); + input_16k[-1] = setup->attdec_filter_mem[1]; move16(); + setup->attdec_filter_mem[0] = input_16k[frame_length_16k - 2]; move16(); + setup->attdec_filter_mem[1] = input_16k[frame_length_16k - 1]; move16(); + + FOR (i = frame_length_16k - 1; i >= 0; i--) + { + tmp = L_mult(input_16k[i], 12288); + tmp = L_msu(tmp, input_16k[i - 1], 16384); + tmp = L_mac(tmp, input_16k[i - 2], 4096); + + input_16k[i] = extract_h(tmp); move16(); + } + + basop_memset(block_energy, 0, 4 * sizeof(Word32)); + + FOR (j = 0; j < enc->attdec_nblocks; j++) + { + FOR (i = 0; i < 40; i++) + { + block_energy[j] = L_mac(block_energy[j], input_16k[i + j*40], input_16k[i + j*40]); move16(); + } + } + + setup->attdec_detected = setup->attdec_position >= enc->attdec_hangover_thresh; + test(); move16(); + position = -1; move16(); + + FOR (i = 0; i < enc->attdec_nblocks; i++) + { + /* block_energy[i] / 8.5 */ + l16 = extract_l(L_shr(block_energy[i], 1)); + l16 = s_and(l16, 0x7fff); + h16 = extract_h(block_energy[i]); + tmp = L_shr(L_mult0(l16, 30840), 15); + tmp = L_shr(L_mac0(tmp, h16, 30840), 2); + + IF (tmp > setup->attdec_acc_energy) + { + position = i; move16(); + setup->attdec_detected = 1; move16(); + } + setup->attdec_acc_energy = L_max(L_shr(setup->attdec_acc_energy, 2), block_energy[i]); move16(); + } + setup->attdec_position = position; move16(); + } + + Dyn_Mem_Deluxe_Out(); +} diff --git a/lib_lc3plus/basop_mpy_lc3plus.c b/lib_lc3plus/basop_mpy_lc3plus.c new file mode 100644 index 000000000..88a6d336b --- /dev/null +++ b/lib_lc3plus/basop_mpy_lc3plus.c @@ -0,0 +1,99 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" + +#include "functions.h" + +#ifdef ENABLE_HR_MODE +Word32 Mpy_32_32_0(Word32 x, Word32 y) +{ + Word32 z; + + z = L_shr(L_add(Mpy_32_32_lc3plus(x, y),1), 1); + + return (z); +} + +Word32 Mpy_32_16_0(Word32 x, Word16 y) +{ + Word32 z; + + z = L_shr(L_add(Mpy_32_16_lc3plus(x, y),1), 1); + + return (z); +} +#endif + +Word32 Mpy_32_16_lc3plus(Word32 x, Word16 y) +{ + Word32 mh; + UWord16 ml; + + Mpy_32_16_ss(x, y, &mh, &ml); + + return (mh); +} + + +Word32 Mpy_32_32_lc3plus(Word32 x, Word32 y) +{ + Word32 mh; + UWord32 ml; + + Mpy_32_32_ss(x, y, &mh, &ml); + + return (mh); +} + + +void cplxMpy_32_16(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a_Im, const Word16 b_Re, + const Word16 b_Im) +{ + *c_Re = L_sub(Mpy_32_16_lc3plus(a_Re, b_Re), Mpy_32_16_lc3plus(a_Im, b_Im)); move32(); + *c_Im = L_add(Mpy_32_16_lc3plus(a_Re, b_Im), Mpy_32_16_lc3plus(a_Im, b_Re)); move32(); +} + +void cplxMpy_32_32(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a_Im, const Word32 b_Re, + const Word32 b_Im) +{ + *c_Re = L_sub(Mpy_32_32_lc3plus(a_Re, b_Re), Mpy_32_32_lc3plus(a_Im, b_Im)); move32(); + *c_Im = L_add(Mpy_32_32_lc3plus(a_Re, b_Im), Mpy_32_32_lc3plus(a_Im, b_Re)); move32(); +} + +#ifdef ENABLE_HR_MODE +Word32 Mac_32_16_0(Word32 z, Word32 x, Word16 y) +{ + z = L_add(z, Mpy_32_16_0(x, y)); + + return (z); +} + +Word32 Mac_32_32_0(Word32 z, Word32 x, Word32 y) +{ + z = L_add(z, Mpy_32_32_0(x, y)); + + return (z); +} + +Word32 Msu_32_16_0(Word32 z, Word32 x, Word16 y) +{ + z = L_sub(z, Mpy_32_16_0(x, y)); + + return (z); +} + +Word32 Msu_32_32_0(Word32 z, Word32 x, Word32 y) +{ + z = L_sub(z, Mpy_32_32_0(x, y)); + + return (z); +} + +#endif /* #ifdef ENABLE_HR_MODE */ diff --git a/lib_lc3plus/basop_mpy_lc3plus.h b/lib_lc3plus/basop_mpy_lc3plus.h new file mode 100644 index 000000000..7c08755ee --- /dev/null +++ b/lib_lc3plus/basop_mpy_lc3plus.h @@ -0,0 +1,94 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" + +#ifndef __BASOP_MPY_H +#define __BASOP_MPY_H + +#include "functions.h" + +#ifdef ENABLE_HR_MODE +Word32 Mpy_32_16_0(Word32 x, Word16 y); +#endif + +Word32 Mac_32_16_0(Word32 z, Word32 x, Word16 y); +Word32 Mpy_32_32_0(Word32 x, Word32 y); +Word32 Mac_32_32_0(Word32 z, Word32 x, Word32 y); +Word32 Msu_32_16_0(Word32 z, Word32 x, Word16 y); +Word32 Msu_32_32_0(Word32 z, Word32 x, Word32 y); + +/** + * \brief 32*16 Bit fractional Multiplication using 40 bit OPS + * Performs a multiplication of a 32-bit variable x by + * a 16-bit variable y, returning a 32-bit value. + * + * \param[i] x + * \param[i] y + * + * \return x*y + */ +Word32 Mpy_32_16_lc3plus(Word32 x, Word16 y); + +/** + * \brief 32*32 Bit fractional Multiplication using 40 bit OPS + * + * Performs a multiplication of a 32-bit variable x by + * a 32-bit variable y, returning a 32-bit value. + * + * \param[i] x + * \param[i] y + * + * \return x*y + */ +Word32 Mpy_32_32_lc3plus(Word32 x, Word32 y); + +#ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + +# ifdef ENABLE_HR_MODE +# define cplxMpy32_32_32_2(re, im, a, b, c, d) \ + do \ + { \ + re = L_sub(Mpy_32_32_0(a, c), Mpy_32_32_0(b, d)); \ + im = L_add(Mpy_32_32_0(a, d), Mpy_32_32_0(b, c)); \ + } while (0) +# endif +# define cplxMpy32_32_16_2(re, im, a, b, c, d) \ + do \ + { \ + re = L_sub(L_shr_pos(Mpy_32_16_lc3plus(a, c), 1), L_shr_pos(Mpy_32_16_lc3plus(b, d), 1)); \ + im = L_add(L_shr_pos(Mpy_32_16_lc3plus(a, d), 1), L_shr_pos(Mpy_32_16_lc3plus(b, c), 1)); \ + } while (0) + + +#else /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + +# ifdef ENABLE_HR_MODE +# define cplxMpy32_32_32_2(re, im, a, b, c, d) \ + do \ + { \ + re = L_sub(Mpy_32_32_0(a, c), Mpy_32_32_0(b, d)); \ + im = L_add(Mpy_32_32_0(a, d), Mpy_32_32_0(b, c)); \ + } while (0) +# endif +# define cplxMpy32_32_16_2(re, im, a, b, c, d) \ + do \ + { \ + re = L_sub(L_shr_pos(Mpy_32_16_lc3plus(a, c), 1), L_shr_pos(Mpy_32_16_lc3plus(b, d), 1)); \ + im = L_add(L_shr_pos(Mpy_32_16_lc3plus(a, d), 1), L_shr_pos(Mpy_32_16_lc3plus(b, c), 1)); \ + } while (0) + +#endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + +void cplxMpy_32_16(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a_Im, const Word16 b_Re, + const Word16 b_Im); +void cplxMpy_32_32(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a_Im, const Word32 b_Re, + const Word32 b_Im); + +#endif /* __BASOP_SETTINGS_H */ diff --git a/lib_lc3plus/basop_util_lc3plus.c b/lib_lc3plus/basop_util_lc3plus.c new file mode 100644 index 000000000..55a9b9eb1 --- /dev/null +++ b/lib_lc3plus/basop_util_lc3plus.c @@ -0,0 +1,1069 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" +#include "rom_basop_util.h" +#include "basop_util_lc3plus.h" + +extern const Word32 SqrtTable_lc3plus[32]; +extern const Word16 SqrtDiffTable_lc3plus[32]; + +extern const Word32 ISqrtTable_lc3plus[32]; +extern const Word16 ISqrtDiffTable_lc3plus[32]; + +extern const Word32 InvTable_lc3plus[32]; +extern const Word16 InvDiffTable_lc3plus[32]; + +Word32 BASOP_Util_Log2_lc3plus(Word32 x) +{ + Word32 exp; + Word16 exp_e; + Word16 nIn; + Word16 accuSqr; + Word32 accuRes; + + assert(x >= 0); + + if (x == 0) + { + + return ((Word32)MIN_32); + } + + /* normalize input, calculate integer part */ + exp_e = norm_l(x); + x = L_shl(x, exp_e); + exp = L_deposit_l(exp_e); + + /* calculate (1-normalized_input) */ + nIn = extract_h(L_sub(MAX_32, x)); + + /* approximate ln() for fractional part (nIn *c0 + nIn^2*c1 + nIn^3*c2 + ... + nIn^8 *c7) */ + + /* iteration 1, no need for accumulation */ + accuRes = L_mult(nIn, ldCoeff_lc3plus[0]); /* nIn^i * coeff[0] */ + accuSqr = mult(nIn, nIn); /* nIn^2, nIn^3 .... */ + + /* iteration 2 */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[1]); /* nIn^i * coeff[1] */ + accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ + + /* iteration 3 */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[2]); /* nIn^i * coeff[2] */ + accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ + + /* iteration 4 */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[3]); /* nIn^i * coeff[3] */ + accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ + + /* iteration 5 */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[4]); /* nIn^i * coeff[4] */ + accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ + + /* iteration 6 */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[5]); /* nIn^i * coeff[5] */ + accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ + + /* iteration 7, no need to calculate accuSqr any more */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[6]); /* nIn^i * coeff[6] */ + + /* ld(fractional part) = ln(fractional part)/ln(2), 1/ln(2) = (1 + 0.44269504) */ + accuRes = L_mac0(L_shr(accuRes, 1), extract_h(accuRes), 14506); + + accuRes = L_shr(accuRes, LD_DATA_SCALE - 1); /* fractional part/LD_DATA_SCALE */ + exp = L_shl(exp, (31 - LD_DATA_SCALE)); /* integer part/LD_DATA_SCALE */ + accuRes = L_sub(accuRes, exp); /* result = integer part + fractional part */ + + return (accuRes); +} + +Word32 BASOP_Util_InvLog2_lc3plus(Word32 x) +{ +#ifdef ENABLE_HR_MODE + /* Original code was used for negative x and hence the exp was always 0, which is assumed */ + Word16 exp; + return BASOP_Util_InvLog2_pos(x, &exp); +#else + Word16 frac; + Word16 exp; + Word32 retVal; + UWord32 index3; + UWord32 index2; + UWord32 index1; + UWord32 lookup3f; + UWord32 lookup12; + UWord32 lookup; + + if (x < -1040187392l /*-31.0/64.0 Q31*/) + { + + return 0; + } + test(); + if ((L_sub(x, 1040187392l /*31.0/64.0 Q31*/) >= 0) || (x == 0)) + { + + return 0x7FFFFFFF; + } + + frac = extract_l(L_and(x, 0x3FF)); + + index3 = L_and(L_shr_pos(x, 10), 0x1F); + index2 = L_and(L_shr_pos(x, 15), 0x1F); + index1 = L_and(L_shr_pos(x, 20), 0x1F); + + exp = extract_l(L_shr_pos(x, 25)); + if (x > 0) + { + exp = sub(31, exp); + } + if (x < 0) + { + exp = negate(exp); + } + + lookup3f = L_add(exp2x_tab_long_lc3plus[index3], L_shr_pos(Mpy_32_16_lc3plus(0x0016302F, frac), 1)); + lookup12 = Mpy_32_32_lc3plus(exp2_tab_long_lc3plus[index1], exp2w_tab_long_lc3plus[index2]); + lookup = Mpy_32_32_lc3plus(lookup12, lookup3f); + + retVal = L_shr(lookup, sub(exp, 3)); + + return retVal; +#endif +} + +#ifdef ENABLE_HR_MODE +/* New function which works with positive and negative exponents */ +Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp) +{ + Word16 frac; + Word16 ret_exp; + Word32 retVal; + UWord32 index3; + UWord32 index2; + UWord32 index1; + UWord32 lookup3f; + UWord32 lookup12; + UWord32 lookup; + + /* The usage of exp.mantissa format in LC3plus in Word32 is : floatval = mantissa / (2^(31 - exp)) */ + ret_exp = extract_l(L_shr(x, 25)); + + IF (x < -1040187392l /*-31.0/64.0 Q31*/) + { + *exp = 0; + move16(); + return 0; + } + test(); + IF ((L_sub(x, 1040187392l /*31.0/64.0 Q31*/) >= 0)) + { + *exp = 31; + move16(); + return 0x40000000; + } + ELSE IF(x == 0) + { + *exp = -1; + move16(); + return 0x10000000; + } + + frac = extract_l(L_and(x, 0x3FF)); + + index3 = L_and(L_shr(x, 10), 0x1F); + index2 = L_and(L_shr(x, 15), 0x1F); + index1 = L_and(L_shr(x, 20), 0x1F); + + lookup3f = L_add(exp2x_tab_long_lc3plus[index3], L_shr(Mpy_32_16_lc3plus(0x0016302F, frac), 1)); + lookup12 = Mpy_32_32_lc3plus(exp2_tab_long_lc3plus[index1], exp2w_tab_long_lc3plus[index2]); + lookup = Mpy_32_32_lc3plus(lookup12, lookup3f); + + IF (x > 0) + { + /* The returned exponent is the offset from 31, so the float result is + retVal / 2^(31 - *exp) */ + *exp = add(ret_exp, 3); + retVal = lookup; + } + ELSE + { + /* For negative powers provide the result in Q31 and ignore the exponent */ + *exp = 0; + retVal = L_shr(lookup, sub(negate(ret_exp), 3)); + } + + return retVal; +} +#endif + +/* local function for Sqrt16_lc3plus and Sqrt16norm */ +static Word16 Sqrt16_common(Word16 m, Word16 e) +{ + Word16 index, frac; + + assert((m >= 0x4000) || (m == 0)); + + /* get table index (upper 6 bits minus 32) */ + /* index = (m >> 9) - 32; */ + index = mac_r(-32768 - (32 << 16), m, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = s_and(m, 0x1FF); /* Q9 */ + + /* interpolate */ + if (m != 0) + { + m = mac_r(SqrtTable_lc3plus[index], SqrtDiffTable_lc3plus[index], frac); + } + + /* handle odd exponents */ + if (s_and(e, 1) != 0) + m = mult_r(m, 0x5a82); + + return m; +} + +/* local function for ISqrt16 and ISqrt16norm */ +static Word16 ISqrt16_common(Word16 m, Word16 e) +{ + Word16 index, frac; + + assert(m >= 0x4000); + + /* get table index (upper 6 bits minus 32) */ + /* index = (m >> 9) - 32; */ + index = mac_r(-32768 - (32 << 16), m, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = s_and(m, 0x1FF); /* Q9 */ + + /* interpolate */ + m = msu_r(ISqrtTable_lc3plus[index], ISqrtDiffTable_lc3plus[index], frac); + + /* handle even exponents */ + if (s_and(e, 1) == 0) + m = mult_r(m, 0x5a82); + + return m; +} + +Word16 Sqrt16_lc3plus( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + Word16 preShift, e; + + assert(mantissa >= 0); + + /* normalize */ + preShift = norm_s(mantissa); + + e = sub(*exponent, preShift); + mantissa = shl(mantissa, preShift); + + /* calc mantissa */ + mantissa = Sqrt16_common(mantissa, e); + + /* e = (e + 1) >> 1 */ + *exponent = mult_r(e, 1 << 14); move16(); + + return mantissa; +} + +Word16 ISqrt16( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + Word16 preShift, e; + + assert(mantissa > 0); + + /* normalize */ + preShift = norm_s(mantissa); + + e = sub(*exponent, preShift); + mantissa = shl(mantissa, preShift); + + /* calc mantissa */ + mantissa = ISqrt16_common(mantissa, e); + + /* e = (2 - e) >> 1 */ + *exponent = msu_r(1L << 15, e, 1 << 14); move16(); + + return mantissa; +} + +Word16 Inv16_lc3plus( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +) +{ + Word16 index, frac; + Word16 preShift; + Word16 m, e; + + assert(mantissa != 0); + + /* absolute */ + m = abs_s(s_max(mantissa, MIN_16 + 1)); + + /* normalize */ + preShift = norm_s(m); + + e = sub(*exponent, preShift); + m = shl(m, preShift); + + /* get table index (upper 6 bits minus 32) */ + /* index = (m >> 9) - 32; */ + index = mac_r(-32768 - (32 << 16), m, 1 << 6); + + /* get fractional part for interpolation (lower 9 bits) */ + frac = shl(s_and(m, 0x1FF), 1); /* Q10 */ + + /* interpolate */ + m = msu_r(InvTable_lc3plus[index], InvDiffTable_lc3plus[index], frac); + + /* restore sign */ + if (mantissa < 0) + m = negate(m); + + /* e = 1 - e */ + *exponent = sub(1, e); move16(); + + return m; +} + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x +*/ + +Word16 getScaleFactor16( /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */ + const Word16 *x, /* i: array containing 16-bit data */ + const Word16 len_x) /* i: length of the array to scan */ +{ + Counter i; + Word16 i_min, i_max; + Word16 x_min, x_max; + + x_max = 0; move16(); + x_min = 0; move16(); + FOR (i = 0; i < len_x; i++) + { + if (x[i] >= 0) + x_max = s_max(x_max, x[i]); + if (x[i] < 0) + x_min = s_min(x_min, x[i]); + } + + i_max = 0x10; move16(); + i_min = 0x10; move16(); + + if (x_max != 0) + i_max = norm_s(x_max); + + if (x_min != 0) + i_min = norm_s(x_min); + + i = s_and(s_min(i_max, i_min), 0xF); + + return i; +} + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 16 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x +*/ + +Word16 getScaleFactor16_0( /* o: measured headroom in range [0..15], 16 if all x[i] == 0 */ + const Word16 *x, /* i: array containing 16-bit data */ + const Word16 len_x) /* i: length of the array to scan */ +{ + Counter i; + Word16 i_min, i_max; + Word16 x_min, x_max; + + x_max = 0; move16(); + x_min = 0; move16(); + FOR (i = 0; i < len_x; i++) + { + if (x[i] >= 0) + x_max = s_max(x_max, x[i]); + if (x[i] < 0) + x_min = s_min(x_min, x[i]); + } + + i_max = 0x10; move16(); + i_min = 0x10; move16(); + + if (x_max != 0) + i_max = norm_s(x_max); + + if (x_min != 0) + i_min = norm_s(x_min); + + i = s_min(i_max, i_min); + + return i; +} + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word32 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 1073741824 <= x <= 2147483647 for positive x
+ and -2147483648 <= x <= -1073741824 for negative x +*/ + +Word16 getScaleFactor32_lc3plus( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ + const Word32 *x, /* i: array containing 32-bit data */ + const Word16 len_x) /* i: length of the array to scan */ +{ + Counter i; + Word16 i_min, i_max; + Word32 x_min, x_max; + + x_max = L_add(0, 0); + x_min = L_add(0, 0); + FOR (i = 0; i < len_x; i++) + { + if (x[i] >= 0) + x_max = L_max(x_max, x[i]); + if (x[i] < 0) + x_min = L_min(x_min, x[i]); + } + + i_max = 0x20; move16(); + i_min = 0x20; move16(); + + if (x_max != 0) + i_max = norm_l(x_max); + + if (x_min != 0) + i_min = norm_l(x_min); + + i = s_and(s_min(i_max, i_min), 0x1F); + + return i; +} + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word32 input array is returned
+ If the input array contains only '0', a scalefactor 32 is returned
+ Scaling factor is determined wrt a normalized target x: 1073741824 <= x <= 2147483647 for positive x
+ and -2147483648 <= x <= -1073741824 for negative x +*/ + +Word16 getScaleFactor32_0( /* o: measured headroom in range [0..31], 32 if all x[i] == 0 */ + const Word32 *x, /* i: array containing 32-bit data */ + const Word16 len_x) /* i: length of the array to scan */ +{ + Counter i; + Word16 i_min, i_max; + Word32 x_min, x_max; + + x_max = L_add(0, 0); + x_min = L_add(0, 0); + FOR (i = 0; i < len_x; i++) + { + if (x[i] >= 0) + x_max = L_max(x_max, x[i]); + if (x[i] < 0) + x_min = L_min(x_min, x[i]); + } + + i_max = 0x20; move16(); + i_min = 0x20; move16(); + + if (x_max != 0) + i_max = norm_l(x_max); + + if (x_min != 0) + i_min = norm_l(x_min); + + i = s_min(i_max, i_min); + + return i; +} + +Word16 BASOP_Util_Divide3216_Scale_lc3plus( /* o: result of division x/y, not normalized */ + Word32 x, /* i: numerator, signed */ + Word16 y, /* i: denominator, signed */ + Word16 *s) /* o: scaling, 0, if x==0 */ +{ + Word16 z; + Word16 sx; + Word16 sy; + Word16 sign; + + /*assert (x > (Word32)0); + assert (y >= (Word16)0);*/ + + /* check, if numerator equals zero, return zero then */ + IF (x == (Word32)0) + { + *s = 0; move16(); + + return ((Word16)0); + } + + sign = s_xor(extract_h(x), y); /* just to exor the sign bits */ + x = L_abs(L_max(x, MIN_32 + 1)); + y = abs_s(s_max(y, MIN_16 + 1)); + sx = sub(norm_l(x), 1); + x = L_shl(x, sx); + sy = norm_s(y); + y = shl(y, sy); + *s = sub(sy, sx); move16(); + + z = div_s(round_fx(x), y); + + if (sign < 0) /* if sign bits differ, negate the result */ + { + z = negate(z); + } + + return z; +} + +Word16 BASOP_Util_Divide1616_Scale_lc3plus(Word16 x, Word16 y, Word16 *s) +{ + Word16 z; + Word16 sx; + Word16 sy; + Word16 sign; + + /* assert (x >= (Word16)0); */ + assert(y != (Word16)0); + + sign = 0; move16(); + + IF (x < 0) + { + x = negate(x); + sign = s_xor(sign, 1); + } + + IF (y < 0) + { + y = negate(y); + sign = s_xor(sign, 1); + } + + IF (x == (Word16)0) + { + *s = 0; move16(); + + return ((Word16)0); + } + + sx = norm_s(x); + x = shl(x, sx); + x = shr(x, 1); + *s = sub(1, sx); move16(); + + sy = norm_s(y); + y = shl(y, sy); + *s = add(*s, sy); move16(); + + z = div_s(x, y); + + if (sign != 0) + { + z = negate(z); + } + + return z; +} + +Word32 Norm32Norm(const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e) +{ + Word32 L_tmp, L_tmp2, inc; + Word16 s, shift, tmp; + Counter i; + + shift = headroom; move16(); + + L_tmp = L_deposit_l(0); + + FOR (i = 0; i < length; i++) + { + L_tmp2 = L_sub(L_tmp, 0x40000000); + if (L_tmp2 >= 0) + shift = sub(shift, 1); + if (L_tmp2 >= 0) + L_tmp = L_shr(L_tmp, 2); + + tmp = round_fx_sat(L_shl_sat(x[i], shift)); + L_tmp = L_mac0(L_tmp, tmp, tmp); /* exponent = (1-shift*2) , Q(30+shift*2) */ + } + + /* Consider an increase of 0xfffd per sample in case that the pre-shift factor + in the acf is 1 bit higher than the shift factor estimated in this function. + This prevent overflows in the acf. */ + IF (L_tmp != 0) + { + s = norm_s(length); + inc = L_shl(Mpy_32_16_lc3plus(0x0000fffd, shl(length, s)), sub(15, s)); + L_tmp = L_add_sat(L_tmp, inc); + } + + *result_e = sub(1, shl(shift, 1)); move16(); + + return L_tmp; +} + +void Scale_sig(Word16 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +) +{ + Counter i; + Word16 tmp; + IF (exp0 > 0) + { + tmp = s_min(exp0, 15); move16(); + FOR (i = 0; i < lg; i++) + { + x[i] = shl(x[i], tmp); move16(); /* saturation can occur here */ + } + return; + } + IF (exp0 < 0) + { + tmp = shl(-32768, s_max(exp0, -15)); /* we use negative to correctly represent 1.0 */ + FOR (i = 0; i < lg; i++) + { + x[i] = msu_r(0, x[i], tmp); move16(); /* msu instead of mac because factor is negative */ + } + return; + } +} + +void Copy_Scale_sig(const Word16 x[], /* i : signal to scale input Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +) +{ + Counter i; + Word16 tmp; + + IF (exp0 == 0) + { + basop_memmove(y, x, lg * sizeof(Word16)); + + return; + } + IF (exp0 < 0) + { + tmp = shl(-32768, exp0); /* we use negative to correctly represent 1.0 */ + FOR (i = 0; i < lg; i++) + { + y[i] = msu_r(0, x[i], tmp); move16(); + } + return; + } + FOR (i = 0; i < lg; i++) + { + y[i] = shl_sat(x[i], exp0); move16(); /* saturation can occur here */ + } +} + +Word32 BASOP_Util_Add_Mant32Exp_lc3plus /*!< o: normalized result mantissa */ + (Word32 a_m, /*!< i: Mantissa of 1st operand a */ + Word16 a_e, /*!< i: Exponent of 1st operand a */ + Word32 b_m, /*!< i: Mantissa of 2nd operand b */ + Word16 b_e, /*!< i: Exponent of 2nd operand b */ + Word16 *ptr_e) /*!< o: exponent of result */ +{ + Word32 L_tmp; + Word16 shift; + + /* Compare exponents: the difference is limited to +/- 30 + The Word32 mantissa of the operand with lower exponent is shifted right by the exponent difference. + Then, the unshifted mantissa of the operand with the higher exponent is added. The addition result + is normalized and the result represents the mantissa to return. The returned exponent takes into + account all shift operations. + */ + + if (!a_m) + a_e = add(b_e, 0); + + if (!b_m) + b_e = add(a_e, 0); + + shift = sub(a_e, b_e); + shift = s_max(-31, shift); + shift = s_min(31, shift); + if (shift < 0) + { + /* exponent of b is greater than exponent of a, shr a_m */ + a_m = L_shl(a_m, shift); + } + if (shift > 0) + { + /* exponent of a is greater than exponent of b */ + b_m = L_shr(b_m, shift); + } + a_e = add(s_max(a_e, b_e), 1); + L_tmp = L_add(L_shr(a_m, 1), L_shr(b_m, 1)); + shift = norm_l(L_tmp); + if (shift) + L_tmp = L_shl(L_tmp, shift); + if (L_tmp == 0) + a_e = add(0, 0); + if (L_tmp != 0) + a_e = sub(a_e, shift); + *ptr_e = a_e; + + return (L_tmp); +} + +Word16 BASOP_Util_Cmp_Mant32Exp_lc3plus /*!< o: flag: result of comparison */ + /* 0, if a == b */ + /* 1, if a > b */ + /* -1, if a < b */ + (Word32 a_m, /*!< i: Mantissa of 1st operand a */ + Word16 a_e, /*!< i: Exponent of 1st operand a */ + Word32 b_m, /*!< i: Mantissa of 2nd operand b */ + Word16 b_e) /*!< i: Exponent of 2nd operand b */ + +{ + Word32 diff_m; + Word16 diff_e, shift, result; + + /* + This function compares two input parameters, both represented by a 32-bit mantissa and a 16-bit exponent. + If both values are identical, 0 is returned. + If a is greater b, 1 is returned. + If a is less than b, -1 is returned. + */ + + /* Check, if both mantissa and exponents are identical, when normalized: return 0 */ + shift = norm_l(a_m); + if (shift) + a_m = L_shl(a_m, shift); + if (shift) + a_e = sub(a_e, shift); + + shift = norm_l(b_m); + if (shift) + b_m = L_shl(b_m, shift); + if (shift) + b_e = sub(b_e, shift); + + /* align exponent, if any mantissa is zero */ + if (!a_m) + a_e = add(b_e, 0); + if (!b_m) + b_e = add(a_e, 0); + + IF (a_m > 0 && b_m < 0) + { + diff_m = 1; move16(); + } + ELSE IF (a_m<0 && b_m> 0) + { + diff_m = -1; move16(); + } + ELSE + { + diff_m = L_sub(a_m, b_m); + } + + diff_e = sub(a_e, b_e); + + test(); + IF (diff_m == 0 && diff_e == 0) + { + return 0; + } + + /* Check sign, exponent and mantissa to identify, whether a is greater b or not */ + result = sub(0, 1); + + IF (a_m >= 0) + { + /* a is positive */ + if (b_m < 0) + { + result = add(1, 0); + } + + test(); test(); test(); + if ((b_m >= 0) && ((diff_e > 0) || (diff_e == 0 && diff_m > 0))) + { + result = add(1, 0); + } + } + ELSE + { + /* a is negative */ + test(); test(); test(); + if ((b_m < 0) && ((diff_e < 0) || (diff_e == 0 && diff_m > 0))) + { + result = add(1, 0); + } + } + return result; +} + +/*----------------------------------------------------------------------------------* + * Function: Isqrt + * + * Description: + * + * The function computes 1/sqrt(x). + * The mantissa of the input value must be in the range of 1.0 > x >= 0.5. + * The computation of the inverse square root is an approach with a lookup table + * and linear interpolation. + * + * result = x * 2^x_e + * + * Parameter: + * + * x [i] mantissa (Q31) + * x_e [i/o] pointer to exponent (Q0) + * + * Return value: + * + * mantissa (Q31) + * + *----------------------------------------------------------------------------------*/ +Word32 Isqrt(Word32 x, /* mantissa */ + Word16 *x_e /* pointer to exponent */ +) +{ + Word16 s; + Word32 y; + Word32 idx; + Word32 diff; + Word16 fract; + + IF (x <= 0) + { + *x_e = 0; move16(); + return 0x7FFFFFFF; + } + + /* check if exponent is odd */ + s = s_and(*x_e, 0x0001); + + /* get table index (upper 8 bits) */ + idx = L_and(L_shr(x, (31 - 8)), 0x00000007f); + + /* get fractional part for interpolation (lower 23 bits) */ + fract = extract_h(L_shl(L_and(x, 0x007FFFFF), 8)); + + /* interpolate */ + diff = L_sub(isqrt_table[idx + 1], isqrt_table[idx]); + y = L_add(isqrt_table[idx], Mpy_32_16_lc3plus(diff, fract)); + + /* if exponent is odd apply sqrt(0.5) */ + if (s != 0) + { + y = Mpy_32_16_lc3plus(y, 0x5A82 /*0x5A827999*/); + } + + /* if exponent is odd shift 1 bit left */ + if (s != 0) + { + y = L_shl(y, s); + } + + /* change sign, shift right and add 1 to exponent (implicit exponent of isqrt_table) */ + *x_e = mac_r(32768, *x_e, -16384); move16(); + + return y; +} + +Word16 BASOP_Util_Log2_16(Word32 x, Word16 x_e) +{ + Word16 shift, tmp1, tmp2; + Word16 outInt, outFrac, out; + + assert(x >= 0); + + if (x == 0) + { + return (MIN_16); + } + + /* Scale Input */ + shift = norm_l(x); + x = L_shl(x, sub(shift, 10)); + + /* Integer part */ + outInt = shl(sub(sub(x_e, shift), 1), 9); + + /* Fractional part */ + tmp1 = mac_r(x, -33, 16384); + tmp2 = lshr(extract_l(x), 6); + outFrac = mac_r(Log2_16_table1[tmp1], Log2_16_table2[tmp1], tmp2); + + /* Output */ + out = add(outInt, outFrac); + + return out; +} + +Word16 BASOP_Util_InvLog2_16(Word16 x, Word16 *y_e) +{ + Word16 tmp1, tmp2, y; + + tmp1 = shr(s_and(x, 2047), 5); + tmp2 = shl(s_and(x, 31), 4); + y = mac_r(InvLog2_16_table1[tmp1], InvLog2_16_table2[tmp1], tmp2); + *y_e = add(shr_pos(x, 11), 1); + + return y; +} + +#ifdef ENABLE_HR_MODE +#define DFRACT_BITS 32 /* double precision */ + +#define SQRT_BITS 7 +#define SQRT_BITS_MASK 0x7f +#define SQRT_FRACT_BITS_MASK 0x007FFFFF + +#ifndef Word64 +#define Word64 long long +#endif + +static __inline Word32 Mpy_32_32_noshift(Word32 x1, Word32 x2) +{ + Word64 ret = 0; + ret = ((Word64)x1 * (Word64)x2); + return ((Word32)((ret & (Word64)0xffffffff00000000) >> 32)); +} + +static __inline Word32 fixmadddiv2_DD(const Word32 x, const Word32 a, const Word32 b) +{ + return ((((Word64)x << 32) + (Word64)a * b) >> 32); +} + +/** + * \brief calculate 1.0/sqrt(op) + * \param op_m mantissa of input value. + * \param result_e pointer to return the exponent of the result + * \return mantissa of the result + */ +/***************************************************************************** + delivers 1/sqrt(op) normalized to .5...1 and the shift value of the OUTPUT, + i.e. the denormalized result is 1/sqrt(op) = invSqrtNorm(op) * 2^(shift) + uses Newton-iteration for approximation + Q(n+1) = Q(n) + Q(n) * (0.5 - 2 * V * Q(n)^2) + with Q = 0.5* V ^-0.5; 0.5 <= V < 1.0 +*****************************************************************************/ +static __inline Word32 invSqrtNorm2(Word32 op, Word32 *shift) +{ + Word32 val = op; + Word32 reg1, reg2; + + if (val == 0) + { + *shift = 16; + return ((Word32)0x7FFFFFFF); /* maximum positive value */ + } + +/* #define INVSQRTNORM2_NEWTON_ITERATE */ +#define INVSQRTNORM2_LINEAR_INTERPOLATE +#define INVSQRTNORM2_LINEAR_INTERPOLATE_HQ + + /* normalize input, calculate shift value */ + assert(val > 0); + *shift = norm_l(val); /* CountLeadingBits() is not necessary here since test value is always > 0 */ + val <<= *shift; /* normalized input V */ + *shift += 2; /* bias for exponent */ + +#if defined(INVSQRTNORM2_NEWTON_ITERATE) + /* Newton iteration of 1/sqrt(V) */ + reg1 = invSqrtTab[(Word32)(val >> (DFRACT_BITS - 1 - (SQRT_BITS + 1))) & SQRT_BITS_MASK]; + reg2 = FL2FXCONST_DBL(0.0625f); /* 0.5 >> 3 */ + + Word32 regtmp = fPow2Div2(reg1); /* a = Q^2 */ + regtmp = reg2 - fMultDiv2(regtmp, val); /* b = 0.5 - 2 * V * Q^2 */ + reg1 += (fMultDiv2(regtmp, reg1) << 4); /* Q = Q + Q*b */ +#elif defined(INVSQRTNORM2_LINEAR_INTERPOLATE) + Word32 index = (Word32)(val >> (DFRACT_BITS - 1 - (SQRT_BITS + 1))) & SQRT_BITS_MASK; + Word32 Fract = (Word32)(((Word32)val & SQRT_FRACT_BITS_MASK) << (SQRT_BITS + 1)); + Word32 diff = invSqrtTab[index + 1] - invSqrtTab[index]; + reg1 = invSqrtTab[index] + (Word32)(((UWord32)(Mpy_32_32_noshift(diff, Fract)) << 1)); +#if defined(INVSQRTNORM2_LINEAR_INTERPOLATE_HQ) + /* reg1 = t[i] + (t[i+1]-t[i])*fract ... already computed ... + + (1-fract)fract*(t[i+2]-t[i+1])/2 */ + if (Fract != (Word32)0) + { + /* fract = fract * (1 - fract) */ + Fract = Mpy_32_32_noshift(Fract, (Word32)((UWord32)0x80000000 - (Word32)Fract)) << 1; + diff = diff - (invSqrtTab[index + 2] - invSqrtTab[index + 1]); + reg1 = fixmadddiv2_DD(reg1, Fract, diff); + } +#endif /* INVSQRTNORM2_LINEAR_INTERPOLATE_HQ */ +#else +#error "Either define INVSQRTNORM2_NEWTON_ITERATE or INVSQRTNORM2_LINEAR_INTERPOLATE" +#endif + /* calculate the output exponent = input exp/2 */ + if (*shift & 0x00000001) + { /* odd shift values ? */ + /* Note: Do not use rounded value 0x5A82799A to avoid overflow with shift-by-2 */ + reg2 = (Word32)0x5A827999; /* FL2FXCONST_DBL(0.707106781186547524400844362104849f);*/ /* 1/sqrt(2); */ +#ifdef __ADSP21000__ + reg1 = fMult(reg1, reg2) << 1; /* compiler bug work around (CCES 2.4.0), and better precision */ +#else + reg1 = Mpy_32_32_noshift(reg1, reg2) << 2; +#endif + } + + *shift = *shift >> 1; + + return (reg1); +} + +/** + * \brief calculate 1.0/(op_m * 2^op_e) + * \param op_m mantissa of the input value. + * \param op_e pointer into were the exponent of the input value is stored, and the result will be stored into. + * \return mantissa of the result + */ +Word32 invFixp(Word32 op_m, Word16 *op_e) +{ + if ((op_m == (Word32)0x00000000) || (op_m == (Word32)0x00000001)) + { + *op_e = 31 - *op_e; + return ((Word32)0x7FFFFFFF); + } + + Word32 tmp_exp; + Word32 tmp_inv = invSqrtNorm2(op_m, &tmp_exp); + + *op_e = (tmp_exp << 1) - *op_e + 1; + return Mpy_32_32_noshift(tmp_inv, tmp_inv); +} +#endif diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h new file mode 100644 index 000000000..99bc211a9 --- /dev/null +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -0,0 +1,377 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef __BASOP_UTIL_LC3PLUS_H__ +#define __BASOP_UTIL_LC3PLUS_H__ + +#include "defines.h" +#include "functions.h" +#include +#include + +#define _LONG long +#define _SHORT short +#ifdef _WIN32 +#define _INT64 __int64 +#else +#define _INT64 long long +#endif + +#define WORD32_BITS 32 +#define MAXVAL_WORD32 ((signed)0x7FFFFFFF) +#define MINVAL_WORD32 ((signed)0x80000000) +#define WORD32_FIX_SCALE ((_INT64)(1) << (WORD32_BITS - 1)) + +#define WORD16_BITS 16 +#define MAXVAL_WORD16 (((signed)0x7FFFFFFF) >> 16) +#define MINVAL_WORD16 (((signed)0x80000000) >> 16) +#define WORD16_FIX_SCALE ((_INT64)(1) << (WORD16_BITS - 1)) + +/*! + \def Macro converts a Word32 fixed point to Word16 fixed point <1 with saturation +*/ +#define WORD322WORD16(val) \ + ((((((val) >> (WORD32_BITS - WORD16_BITS - 1)) + 1) > (((_LONG)1 << WORD16_BITS) - 1)) && ((_LONG)(val) > 0)) \ + ? (Word16)(_SHORT)(((_LONG)1 << (WORD16_BITS - 1)) - 1) \ + : (Word16)(_SHORT)((((val) >> (WORD32_BITS - WORD16_BITS - 1)) + 1) >> 1)) + + +/* Word16 Packed Type */ +typedef struct +{ + struct + { + Word16 re; + Word16 im; + } v; +} PWord16; + +#ifdef ENABLE_HR_MODE +/* Word32 Packed Type */ +typedef struct +{ + struct + { + Word32 re; + Word32 im; + } v; +} PWord32; +#endif + +#define cast16 move16 + +#define LD_DATA_SCALE (6) +#define LD_DATA_SHIFT_I5 (7) + +/************************************************************************/ +/*! + \brief Calculate the squareroot of a number given by mantissa and exponent + + Mantissa is in 16/32-bit-fractional format with values between 0 and 1.
+ For *norm versions mantissa has to be between 0.5 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ The exponent is addressed via pointers and will be overwritten with the result. +*/ + +Word16 Sqrt16_lc3plus( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +Word16 ISqrt16( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +/*****************************************************************************/ +/*! + \brief Calculate the inverse of a number given by mantissa and exponent + + Mantissa is in 16-bit-fractional format with values between 0 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ The operand is addressed via pointers and will be overwritten with the result. + + The function uses a table lookup and a newton iteration. +*/ +Word16 Inv16_lc3plus( /*!< output mantissa */ + Word16 mantissa, /*!< input mantissa */ + Word16 *exponent /*!< pointer to exponent */ +); + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x +*/ + +Word16 getScaleFactor16( /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */ + const Word16 *x, /* i: array containing 16-bit data */ + const Word16 len_x); /* i: length of the array to scan */ + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 16 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x +*/ + +Word16 getScaleFactor16_0( /* o: measured headroom in range [0..15], 16 if all x[i] == 0 */ + const Word16 *x, /* i: array containing 16-bit data */ + const Word16 len_x); /* i: length of the array to scan */ + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word32 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 1073741824 <= x <= 2147483647 for positive x
+ and -2147483648 <= x <= -1073741824 for negative x +*/ + +Word16 getScaleFactor32_lc3plus( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ + const Word32 *x, /* i: array containing 32-bit data */ + const Word16 len_x); /* i: length of the array to scan */ + +/********************************************************************/ +/*! + \brief Calculates the scalefactor needed to normalize input array + + The scalefactor needed to normalize the Word32 input array is returned
+ If the input array contains only '0', a scalefactor 32 is returned
+ Scaling factor is determined wrt a normalized target x: 1073741824 <= x <= 2147483647 for positive x
+ and -2147483648 <= x <= -1073741824 for negative x +*/ + +Word16 getScaleFactor32_0( /* o: measured headroom in range [0..31], 32 if all x[i] == 0 */ + const Word32 *x, /* i: array containing 32-bit data */ + const Word16 len_x); /* i: length of the array to scan */ + +/****************************************************************************/ +/*! + \brief Does fractional integer division of Word32 arg1 by Word16 arg2 + + + \return fractional Word16 integer z = arg1(32bits)/arg2(16bits) , z not normalized +*/ +Word16 BASOP_Util_Divide3216_Scale_lc3plus(Word32 x, /*!< i : Numerator */ + Word16 y, /*!< i : Denominator*/ + Word16 *s); /*!< o : Additional scalefactor difference*/ + +/****************************************************************************/ +/*! + \brief Does fractional division of Word16 arg1 by Word16 arg2 + + + \return fractional Q15 Word16 z = arg1(Q15)/arg2(Q15) with scaling s +*/ +Word16 BASOP_Util_Divide1616_Scale_lc3plus(Word16 x, /*!< i : Numerator*/ + Word16 y, /*!< i : Denominator*/ + Word16 *s); /*!< o : Additional scalefactor difference*/ + +/************************************************************************/ +/*! + \brief Binary logarithm with 7 iterations + + \param x + + \return log2(x)/64 + */ +/************************************************************************/ +Word32 BASOP_Util_Log2_lc3plus(Word32 x); + +/************************************************************************/ +/*! + \brief Binary power + + Date: 06-JULY-2012 Arthur Tritthart, IIS Fraunhofer Erlangen + + Version with 3 table lookup and 1 linear interpolations + + Algorithm: compute power of 2, argument x is in Q7.25 format + result = 2^(x/64) + We split exponent (x/64) into 5 components: + integer part: represented by b31..b25 (exp) + fractional part 1: represented by b24..b20 (lookup1) + fractional part 2: represented by b19..b15 (lookup2) + fractional part 3: represented by b14..b10 (lookup3) + fractional part 4: represented by b09..b00 (frac) + => result = (lookup1*lookup2*(lookup3+C1*frac)<<3)>>exp + + Due to the fact, that all lookup values contain a factor 0.5 + the result has to be shifted by 3 to the right also. + Table exp2_tab_long_lc3plus contains the log2 for 0 to 1.0 in steps + of 1/32, table exp2w_tab_long_lc3plus the log2 for 0 to 1/32 in steps + of 1/1024, table exp2x_tab_long_lc3plus the log2 for 0 to 1/1024 in + steps of 1/32768. Since the 2-logarithm of very very small + negative value is rather linear, we can use interpolation. + + Limitations: + + For x <= 0, the result is fractional positive + For x > 0, the result is integer in range 1...7FFF.FFFF + For x < -31/64, we have to clear the result + For x = 0, the result is ~1.0 (0x7FFF.FFFF) + For x >= 31/64, the result is 0x7FFF.FFFF + + \param x + + \return pow(2,(x/64)) + */ +/************************************************************************/ +Word32 BASOP_Util_InvLog2_lc3plus(Word32 x); + +#ifdef ENABLE_HR_MODE +/* New function which works with positive x, BASOP_Util_InvLog2_lc3plus does not give + accurate results for x > 0 */ +Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp); +#endif + +/** + * \brief Compute dot product of 1 32 bit vectors with itself + * \param x input vector 1 + * \param headroom amount of headroom bits the input vector + * \param length the length of the input vector + * \param result_e pointer to where the exponent of the result will be stored into + * \return the dot product of x and x. + */ +Word32 Norm32Norm(const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e); + +/*!********************************************************************** + \brief Add two values given by mantissa and exponent. + + Mantissas are in 32-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ +************************************************************************/ +Word32 BASOP_Util_Add_Mant32Exp_lc3plus /*!< o: normalized result mantissa */ + (Word32 a_m, /*!< i: Mantissa of 1st operand a */ + Word16 a_e, /*!< i: Exponent of 1st operand a */ + Word32 b_m, /*!< i: Mantissa of 2nd operand b */ + Word16 b_e, /*!< i: Exponent of 2nd operand b */ + Word16 *ptr_e); /*!< o: exponent of result */ + /*!********************************************************************** + \brief Returns the comparison result of two normalized values given by mantissa and exponent. + return value: -1: a < b, 0: a == b, 1; a > b + + Mantissas are in 32-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ + ************************************************************************/ +Word16 BASOP_Util_Cmp_Mant32Exp_lc3plus /*!< o: flag: result of comparison */ + (Word32 a_m, /*!< i: Mantissa of 1st operand a */ + Word16 a_e, /*!< i: Exponent of 1st operand a */ + Word32 b_m, /*!< i: Mantissa of 2nd operand b */ + Word16 b_e); /*!< i: Exponent of 2nd operand b */ + +/* compare two positive normalized 16 bit mantissa/exponent values */ +/* return value: positive if first value greater, negative if second value greater, zero if equal */ +Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2); + +void Scale_sig(Word16 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); +void Copy_Scale_sig(const Word16 x[], /* i : signal to scale input Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +#ifdef ENABLE_HR_MODE +void Copy_Scale_sig_32(const Word32 x[], /* i : signal to scale input Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); +#endif + +Word32 Isqrt(Word32 x, /* (i) Q31: normalized value (1.0 > x >= 0.5) */ + Word16 *x_e /* (i/o) Q0 : pointer to exponent */ +); + +Word16 BASOP_Util_Log2_16(Word32 x, Word16 x_e); + +Word16 BASOP_Util_InvLog2_16(Word16 x, Word16 *y_e); + +#ifdef ENABLE_HR_MODE +Word32 invFixp(Word32 op_m, Word16 *op_e); +#endif + +#define BASOP_CFFT_MAX_LENGTH 480 +void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word16 *scale, Word32 *x); +void BASOP_rfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); +void BASOP_irfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); + +#if WMOPS +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif + +static __inline void basop_memcpy(void *dst, const void *src, size_t n) +{ +#if WMOPS + multiCounter[currCounter].move16 += (UWord32)n / 2; +#endif + /* check for overlapping memory */ + assert((const char *)src + n <= (char *)dst || (char *)dst + n <= (const char *)src); + memcpy(dst, src, n); +} + +static __inline void basop_memmove(void *dst, const void *src, size_t n) +{ +#if WMOPS + multiCounter[currCounter].move16 += (UWord32)n / 2; +#endif + memmove(dst, src, n); +} + +static __inline void basop_memset(void *dst, int val, size_t n) +{ +#if WMOPS + multiCounter[currCounter].move16 += (UWord32)n / 2; +#endif + memset(dst, val, n); +} + +/* Macros around Dyn_Mem that don't require duplicate declarations. */ +#ifdef DYNMEM_COUNT +/* older visual studio doesn't have __func__ */ +#if defined _MSC_VER && _MSC_VER < 1900 +#define __func__ __FUNCTION__ +#endif +#define Dyn_Mem_Deluxe_In(...) __VA_ARGS__ Dyn_Mem_In(__func__, sizeof(struct {__VA_ARGS__})) +#define Dyn_Mem_Deluxe_Out() Dyn_Mem_Out() +#else +#define Dyn_Mem_Deluxe_In(...) __VA_ARGS__ +#define Dyn_Mem_Deluxe_Out() +#endif + +/* Macros missing from IVAS BASOP, used only in LC3plus */ +#define L_shl_pos(x, y) (L_shl((x), (y))) +#define L_shr_pos(x, y) (L_shr((x), (y))) +#define L_shr_pos_pos(x, y) (L_shr((x), (y))) + +#define L_shr_r_pos(x, shift) (L_shr_r(x, shift)) + +#define shl_pos(x, y) (shl((x), (y))) +#define shr_pos(x, y) (shr((x), (y))) +#define shr_pos_pos(x, y) (shr((x), (y))) + +#define lshl_pos(x, y) (lshl(x, y)) +#define UL_lshr_pos(x, y) (UL_lshr(x, y)) +#define UL_lshl_pos(x, y) (UL_lshl(x, y)) +#endif /* __BASOP_UTIL_LC3PLUS_H__ */ diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c new file mode 100644 index 000000000..c13c4e49e --- /dev/null +++ b/lib_lc3plus/constants.c @@ -0,0 +1,5046 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "basop_util_lc3plus.h" +#include "constants.h" +#include "defines.h" + +#ifdef ENABLE_HR_MODE + +#ifdef CR8_G_ADD_75MS +const Word32 LowDelayShapes_n960_N480_HRA_7_5ms_IP[720] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 87, 348, 823, 1614, 2855, 4711, + 7394, 11166, 16346, 23325, 32567, 44630, 60168, 79951, 104871, + 135960, 174404, 221554, 278944, 348306, 431580, 530938, 648792, 787807, + 950923, 1141360, 1362631, 1618557, 1913273, 2251235, 2637225, 3076358, 3574079, + 4136163, 4768712, 5478142, 6271180, 7154844, 8136428, 9223482, 10423785, 11745317, + 13196231, 14784811, 16519438, 18408546, 20460576, 22683925, 25086898, 27677652, 30464139, + 33454048, 36654744, 40073208, 43715977, 47589078, 51697972, 56047490, 60641775, 65484225, + 70577443, 75923181, 81522294, 87374702, 93479345, 99834159, 106436041, 113280836, 120363317, + 127677184, 135215062, 142968508, 150928157, 159083617, 167423428, 175935264, 184605929, 193421420, + 202366999, 211427267, 220586253, 229827503, 239134176, 248489151, 257875132, 267274759, 276670727, + 286045896, 295383416, 304666842, 313880253, 323008369, 332036665, 340951481, 349740127, 358390986, + 366893607, 375238791, 383418672, 391426786, 399258131, 406909219, 414378115, 421664463, 428769507, + 435696092, 442448656, 449033209, 455457302, 461729975, 467861704, 473864325, 479750954, 485535888, + 491234502, 496863130, 502438943, 507979811, 513504165, 519030849, 524578969, 530167737, 535816319, + 541543674, 547368406, 553308608, 559381722, 565604392, 571992342, 578560249, 585321630, 592288748, + 599472521, 606882448, 614526549, 622411321, 630541701, 638921050, 647551149, 656432204, 665562870, + 674940281, 684560092, 694416534, 704502476, 714809492, 725327938, 736047035, 746954953, 758038900, + 769285219, 780679474, 792206554, 803850758, 815595897, 827425384, 839322323, 851269604, 863249984, + 875246176, 887240926, 899217093, 911157723, 923046119, 934865908, 946601106, 958236175, 969756079, + 981146337, 992393068, 1003483035, 1014403685, 1025143183, 1035690443, 1046035156, 1056167806, 1066079698, + 1075762962, 1085210568, 1094416328, 1103374896, 1112081767, 1120533266, 1128726537, 1136659525, 1144330955, + 1151740310, 1158887799, 1165774327, 1172401460, 1178771388, 1184886881, 1190751250, 1196368299, 1201742283, + 1206877859, 1211780040, 1216454151, 1220905777, 1225140726, 1229164983, 1232984668, 1236606003, 1240035271, + 1243278790, 1246342881, 1249233843, 1251957932, 1254521342, 1256930191, 1259190506, 1261308214, 1263289136, + 1265138979, 1266863333, 1268467669, 1269957337, 1271337562, 1272613448, 1273789972, 1274871989, 1275864224, + 1276771276, 1277597614, 1278347576, 1279025364, 1279635046, 1280180548, 1280665658, 1281094017, 1281469123, + 1281794327, 1282072831, 1282307692, 1282501820, 1282657982, 1282778803, 1282866770, 1282924240, 1282953439, + 1282956475, 1282935340, 1282891922, 1282828007, 1282745290, 1282645385, 1282529830, 1282400095, 1282257591, + 1282103675, 1281939658, 1281766811, 1281586369, 1281399536, 1281207489, 1281011380, 1280812338, 1280611471, + 1280409867, 1280208592, 1280008692, 1279811190, 1279617083, 1279427343, 1279242908, 1279064691, 1278893575, + 1278730391, 1278575934, 1278430953, 1278296152, 1278172183, 1278059646, 1277959085, 1277870984, 1277795766, + 1277733793, 1277685360, 1277650698, 1277629970, 1277623272, 1277630630, 1277652006, 1277687290, 1277736307, + 1277798815, 1277874509, 1277963018, 1278063911, 1278176696, 1278300826, 1278435697, 1278580655, 1278734998, + 1278897977, 1279068803, 1279246650, 1279430656, 1279619930, 1279813555, 1280010596, 1280210097, 1280411091, + 1280612606, 1280813664, 1281013290, 1281210515, 1281404382, 1281593947, 1281778291, 1281956514, 1282127749, + 1282291161, 1282445951, 1282591364, 1282726688, 1282851259, 1282964467, 1283065755, 1283154623, 1283230634, + 1283293412, 1283342644, 1283378085, 1283399556, 1283406948, 1283400219, 1283379398, 1283344582, 1283295937, + 1283233697, 1283158163, 1283069704, 1282968748, 1282855789, 1282731378, 1282596123, 1282450686, 1282295780, + 1282132162, 1281960636, 1281782040, 1281597253, 1281407178, 1281212748, 1281014916, 1280814653, 1280612938, + -1280410760, -1280209108, -1280008970, -1279811325, -1279617137, -1279427356, -1279242908, -1279064691, -1278893575, + -1278730391, -1278575934, -1278430953, -1278296152, -1278172183, -1278059646, -1277959085, -1277870984, -1277795766, + -1277733793, -1277685360, -1277650698, -1277629970, -1277623272, -1277630630, -1277652006, -1277687290, -1277736307, + -1277798815, -1277874509, -1277963018, -1278063911, -1278176696, -1278300826, -1278435697, -1278580655, -1278734998, + -1278897977, -1279068803, -1279246650, -1279430656, -1279619930, -1279813555, -1280010596, -1280210097, -1280411091, + -1280612606, -1280813664, -1281013290, -1281210515, -1281404382, -1281593947, -1281778291, -1281956514, -1282127749, + -1282291161, -1282445951, -1282591364, -1282726688, -1282851259, -1282964467, -1283065755, -1283154623, -1283230634, + -1283293412, -1283342644, -1283378085, -1283399556, -1283406948, -1283400219, -1283379398, -1283344582, -1283295937, + -1283233697, -1283158163, -1283069704, -1282968748, -1282855789, -1282731378, -1282596123, -1282450686, -1282295780, + -1282132162, -1281960636, -1281782040, -1281597240, -1281407124, -1281212613, -1281014638, -1280814136, -1280612044, + -1280409293, -1280206794, -1280005436, -1279806071, -1279609505, -1279416489, -1279227704, -1279043754, -1278865148, + -1278692290, -1278525466, -1278364827, -1278210380, -1278061967, -1277919259, -1277781732, -1277648661, -1277519103, + -1277391882, -1277265579, -1277138516, -1277008749, -1276874050, -1276731906, -1276579498, -1276413701, -1276231074, + -1276027848, -1275799922, -1275542858, -1275251868, -1274921816, -1274547202, -1274122161, -1273640454, -1273095459, + -1272480163, -1271787153, -1271008605, -1270136275, -1269161491, -1268075138, -1266867650, -1265529002, -1264048705, + -1262415795, -1260618834, -1258645914, -1256484654, -1254122219, -1251545330, -1248740288, -1245693001, -1242389021, + -1238813588, -1234951678, -1230788064, -1226307382, -1221494200, -1216333106, -1210808785, -1204906119, -1198610276, + -1191906816, -1184781789, -1177221841, -1169214319, -1160747375, -1151810067, -1142392460, -1132485722, -1122082216, + -1111175584, -1099760832, -1087834398, -1075394224, -1062439811, -1048972272, -1034994376, -1020510578, -1005527053, + -990051705, -974094182, -957665874, -940779904, -923451116, -905696046, -887532891, -868981469, -850063169, + -830800896, -811219007, -791343239, -771200631, -750819438, -730229039, -709459838, -688543157, -667511126, + -646396563, -625232849, -604053802, -582893543, -561786350, -540766526, -519868245, -499125406, -478571481, + -458239366, -438161227, -418368350, -398890991, -379758233, -360997846, -342636148, -324697881, -307206093, + -290182024, -273645013, -257612410, -242099504, -227119464, -212683299, -198799827, -185475666, -172715241, + -160520802, -148892465, -137828265, -127324223, -117374432, -107971150, -99104909, -90764635, -82937772, + -75610419, -68767471, -62392760, -56469205, -50978959, -45903556, -41224052, -36921169, -32975429, + -29367284, -26077235, -23085950, -20374365, -17923784, -15715959, -13733175, -11958308, -10374886, + -8967135, -7720017, -6619257, -5651362, -4803637, -4064184, -3421902, -2866477, -2388368, + -1978789, -1629681, -1333688, -1084125, -874947, -700710, -556540, -438092, -341515, + -263414, -200812, -151118, -112086, -81786, -58572, -41046, -28035, -18564, + -11827, -7166, -4052, -2065, -873, -219, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +const Word32 LowDelayShapes_n960_N960_HRA_7_5ms_IP[1440] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 44, 108, 200, + 327, 496, 716, 997, 1352, 1793, 2334, 2993, 3788, + 4740, 5873, 7210, 8782, 10618, 12754, 15228, 18079, 21354, + 25102, 29375, 34232, 39736, 45954, 52960, 60833, 69657, 79523, + 90531, 102783, 116393, 131479, 148170, 166600, 186913, 209263, 233812, + 260731, 290202, 322417, 357578, 395898, 437601, 482924, 532113, 585429, + 643144, 705541, 772919, 845587, 923872, 1008108, 1098650, 1195861, 1300121, + 1411824, 1531379, 1659208, 1795748, 1941453, 2096787, 2262233, 2438287, 2625458, + 2824273, 3035270, 3259002, 3496037, 3746956, 4012353, 4292837, 4589026, 4901555, + 5231067, 5578220, 5943680, 6328125, 6732242, 7156730, 7602292, 8069643, 8559503, + 9072598, 9609661, 10171429, 10758643, 11372046, 12012385, 12680404, 13376850, 14102468, + 14858000, 15644185, 16461757, 17311444, 18193967, 19110038, 20060361, 21045626, 22066514, + 23123691, 24217808, 25349499, 26519382, 27728053, 28976092, 30264055, 31592472, 32961855, + 34372684, 35825415, 37320475, 38858262, 40439142, 42063449, 43731482, 45443509, 47199758, + 49000423, 50845659, 52735581, 54670266, 56649748, 58674020, 60743031, 62856690, 65014857, + 67217351, 69463943, 71754359, 74088280, 76465337, 78885116, 81347157, 83850949, 86395935, + 88981513, 91607029, 94271785, 96975035, 99715986, 102493800, 105307656, 108156591, 111039641, + 113955799, 116904014, 119883198, 122892222, 125929920, 128995090, 132086493, 135202860, 138342888, + 141505243, 144688567, 147891470, 151112543, 154350350, 157603439, 160870336, 164149553, 167439589, + 170738931, 174046055, 177359434, 180677535, 183998823, 187321766, 190644834, 193966503, 197285258, + 200599596, 203908028, 207209080, 210501300, 213783255, 217053539, 220310770, 223553598, 226780705, + 229990806, 233182654, 236355043, 239506805, 242636819, 245744010, 248827351, 251885864, 254918626, + 257924767, 260903473, 263853991, 266775622, 269667734, 272529755, 275361176, 278161556, 280930518, + 283667753, 286373022, 289046153, 291687043, 294295661, 296872047, 299416309, 301928628, 304409254, + 306858511, 309276789, 311664551, 314022327, 316350717, 318650389, 320922075, 323166575, 325384751, + 327577531, 329745900, 331890905, 334013649, 336115291, 338197045, 340260173, 342305990, 344335852, + 346351165, 348353370, 350343952, 352324427, 354296346, 356261288, 358220860, 360176691, 362130431, + 364083745, 366038312, 367995821, 369957968, 371926451, 373902968, 375889214, 377886876, 379897629, + 381923135, 383965040, 386024966, 388104513, 390205254, 392328729, 394476448, 396649881, 398850460, + 401079575, 403338572, 405628746, 407951345, 410307564, 412698544, 415125367, 417589059, 420090585, + 422630847, 425210685, 427830873, 430492120, 433195067, 435940288, 438728287, 441559502, 444434298, + 447352971, 450315749, 453322788, 456374176, 459469929, 462609996, 465794259, 469022529, 472294553, + 475610011, 478968518, 482369626, 485812825, 489297542, 492823148, 496388953, 499994212, 503638125, + 507319839, 511038449, 514793004, 518582502, 522405897, 526262100, 530149980, 534068367, 538016053, + 541991796, 545994319, 550022317, 554074452, 558149362, 562245659, 566361935, 570496756, 574648675, + 578816224, 582997925, 587192283, 591397795, 595612950, 599836228, 604066106, 608301058, 612539556, + 616780072, 621021084, 625261070, 629498515, 633731914, 637959769, 642180591, 646392905, 650595252, + 654786183, 658964269, 663128098, 667276277, 671407434, 675520217, 679613298, 683685373, 687735163, + 691761414, 695762900, 699738424, 703686816, 707606936, 711497676, 715357958, 719186737, 722983000, + 726745768, 730474096, 734167073, 737823824, 741443507, 745025319, 748568492, 752072293, 755536028, + 758959039, 762340704, 765680440, 768977700, 772231975, 775442794, 778609720, 781732356, 784810341, + 787843351, 790831096, 793773326, 796669823, 799520406, 802324927, 805083276, 807795372, 810461171, + 813080658, 815653853, 818180806, 820661596, 823096332, 825485155, 827828229, 830125749, 832377934, + 834585028, 836747302, 838865047, 840938578, 842968232, 844954366, 846897354, 848797592, 850655491, + 852471478, 854245997, 855979505, 857672472, 859325380, 860938723, 862513004, 864048738, 865546444, + 867006653, 868429898, 869816720, 871167666, 872483283, 873764126, 875010749, 876223709, 877403563, + 878550870, 879666189, 880750077, 881803089, 882825781, 883818705, 884782410, 885717445, 886624352, + 887503671, 888355939, 889181688, 889981445, 890755734, 891505074, 892229977, 892930955, 893608509, + 894263138, 894895337, 895505593, 896094389, 896662203, 897209507, 897736768, 898244447, 898733000, + 899202877, 899654523, 900088379, 900504877, 900904447, 901287510, 901654485, 902005783, 902341811, + 902662967, 902969647, 903262240, 903541129, 903806691, 904059297, 904299312, 904527095, 904742999, + 904947372, 905140554, 905322879, 905494676, 905656265, 905807964, 905950080, 906082916, 906206768, + 906321926, 906428673, 906527284, 906618032, 906701178, 906776980, 906845690, 906907551, 906962802, + 907011675, 907054396, 907091185, 907122257, 907147818, 907168073, 907183217, 907193443, 907198938, + 907199882, 907196451, 907188818, 907177150, 907161608, 907142351, 907119533, 907093305, 907063813, + 907031199, 906995603, 906957162, 906916008, 906872273, 906826083, 906777563, 906726837, 906674025, + 906619245, 906562613, 906504244, 906444251, 906382745, 906319835, 906255629, 906190236, 906123759, + 906056304, 905987975, 905918873, 905849099, 905778755, 905707939, 905636751, 905565287, 905493644, + 905421918, 905350204, 905278596, 905207187, 905136068, 905065331, 904995065, 904925359, 904856301, + 904787977, 904720472, 904653870, 904588254, 904523701, 904460295, 904398114, 904337234, 904277728, + 904219670, 904163129, 904108175, 904054874, 904003290, 903953487, 903905525, 903859462, 903815353, + 903773252, 903733209, 903695274, 903659492, 903625906, 903594557, 903565482, 903538716, 903514291, + 903492237, 903472579, 903455342, 903440546, 903428208, 903418343, 903410963, 903406076, 903403687, + 903403799, 903406411, 903411521, 903419121, 903429201, 903441750, 903456751, 903474186, 903494033, + 903516269, 903540866, 903567793, 903597018, 903628506, 903662217, 903698112, 903736145, 903776272, + 903818442, 903862605, 903908708, 903956694, 904006505, 904058081, 904111359, 904166274, 904222761, + 904280750, 904340172, 904400953, 904463022, 904526303, 904590718, 904656191, 904722641, 904789988, + 904858152, 904927048, 904996594, 905066706, 905137298, 905208286, 905279583, 905351102, 905422757, + 905494462, 905566128, 905637670, 905709001, 905780033, 905850681, 905920859, 905990482, 906059464, + 906127723, 906195175, 906261739, 906327332, 906391876, 906455291, 906517501, 906578429, 906638002, + 906696146, 906752790, 906807866, 906861306, 906913045, 906963019, 907011167, 907057430, 907101752, + 907144078, 907184355, 907222535, 907258571, 907292418, 907324034, 907353381, 907380422, 907405124, + 907427456, 907447391, 907464903, 907479970, 907492575, 907502701, 907510335, 907515468, 907518092, + 907518205, 907515805, 907510896, 907503482, 907493572, 907481179, 907466317, 907449004, 907429261, + 907407111, 907382581, 907355702, 907326506, 907295028, 907261307, 907225384, 907187302, 907147109, + 907104853, 907060585, 907014361, 906966236, 906916270, 906864523, 906811060, 906755944, 906699245, + 906641031, 906581374, 906520347, 906458025, 906394483, 906329801, 906264057, 906197332, 906129707, + 906061266, 905992093, 905922271, 905851888, 905781028, 905709780, 905638230, 905566465, 905494574, + -905422645, -905350765, -905279024, -905207507, -905136304, -905065500, -904995184, -904925439, -904856352, + -904788008, -904720488, -904653877, -904588254, -904523701, -904460295, -904398114, -904337234, -904277728, + -904219670, -904163129, -904108175, -904054874, -904003290, -903953487, -903905525, -903859462, -903815353, + -903773252, -903733209, -903695274, -903659492, -903625906, -903594557, -903565482, -903538716, -903514291, + -903492237, -903472579, -903455342, -903440546, -903428208, -903418343, -903410963, -903406076, -903403687, + -903403799, -903406411, -903411521, -903419121, -903429201, -903441750, -903456751, -903474186, -903494033, + -903516269, -903540866, -903567793, -903597018, -903628506, -903662217, -903698112, -903736145, -903776272, + -903818442, -903862605, -903908708, -903956694, -904006505, -904058081, -904111359, -904166274, -904222761, + -904280750, -904340172, -904400953, -904463022, -904526303, -904590718, -904656191, -904722641, -904789988, + -904858152, -904927048, -904996594, -905066706, -905137298, -905208286, -905279583, -905351102, -905422757, + -905494462, -905566128, -905637670, -905709001, -905780033, -905850681, -905920859, -905990482, -906059464, + -906127723, -906195175, -906261739, -906327332, -906391876, -906455291, -906517501, -906578429, -906638002, + -906696146, -906752790, -906807866, -906861306, -906913045, -906963019, -907011167, -907057430, -907101752, + -907144078, -907184355, -907222535, -907258571, -907292418, -907324034, -907353381, -907380422, -907405124, + -907427456, -907447391, -907464903, -907479970, -907492575, -907502701, -907510335, -907515468, -907518092, + -907518205, -907515805, -907510896, -907503482, -907493572, -907481179, -907466317, -907449004, -907429261, + -907407111, -907382581, -907355702, -907326506, -907295028, -907261307, -907225384, -907187302, -907147109, + -907104853, -907060585, -907014361, -906966236, -906916270, -906864523, -906811060, -906755944, -906699245, + -906641031, -906581374, -906520347, -906458025, -906394483, -906329801, -906264050, -906197315, -906129676, + -906061214, -905992012, -905922152, -905851718, -905780792, -905709459, -905637802, -905565904, -905493847, + -905421715, -905349587, -905277545, -905205668, -905134032, -905062714, -904991788, -904921326, -904851397, + -904782068, -904713403, -904645463, -904578305, -904511983, -904446548, -904382044, -904318513, -904255990, + -904194508, -904134091, -904074760, -904016528, -903959404, -903903387, -903848473, -903794647, -903741889, + -903690170, -903639452, -903589690, -903540829, -903492806, -903445546, -903398968, -903352977, -903307470, + -903262332, -903217440, -903172655, -903127830, -903082805, -903037408, -902991455, -902944749, -902897082, + -902848230, -902797958, -902746017, -902692145, -902636065, -902577487, -902516107, -902451605, -902383649, + -902311891, -902235969, -902155504, -902070104, -901979361, -901882852, -901780138, -901670764, -901554261, + -901430141, -901297903, -901157028, -901006979, -900847206, -900677140, -900496195, -900303767, -900099237, + -899881968, -899651302, -899406566, -899147069, -898872099, -898580929, -898272809, -897946972, -897602633, + -897238985, -896855201, -896450436, -896023825, -895574479, -895101492, -894603937, -894080864, -893531305, + -892954268, -892348742, -891713696, -891048075, -890350805, -889620793, -888856922, -888058059, -887223048, + -886350714, -885439866, -884489291, -883497761, -882464029, -881386834, -880264898, -879096929, -877881622, + -876617661, -875303716, -873938450, -872520516, -871048562, -869521229, -867937155, -866294976, -864593328, + -862830848, -861006177, -859117961, -857164854, -855145521, -853058635, -850902887, -848676980, -846379640, + -844009611, -841565658, -839046575, -836451182, -833778329, -831026896, -828195801, -825283996, -822290474, + -819214267, -816054453, -812810153, -809480538, -806064827, -802562292, -798972258, -795294106, -791527275, + -787671264, -783725629, -779689995, -775564045, -771347531, -767040273, -762642156, -758153138, -753573244, + -748902575, -744141301, -739289667, -734347993, -729316674, -724196178, -718987051, -713689917, -708305473, + -702834496, -697277838, -691636430, -685911277, -680103464, -674214150, -668244572, -662196041, -656069944, + -649867743, -643590972, -637241240, -630820227, -624329685, -617771433, -611147363, -604459432, -597709664, + -590900148, -584033037, -577110543, -570134942, -563108566, -556033804, -548913099, -541748950, -534543903, + -527300554, -520021545, -512709564, -505367338, -497997635, -490603260, -483187052, -475751882, -468300650, + -460836282, -453361728, -445879958, -438393963, -430906743, -423421316, -415940704, -408467938, -401006049, + -393558069, -386127025, -378715938, -371327818, -363965660, -356632445, -349331130, -342064650, -334835913, + -327647796, -320503142, -313404758, -306355410, -299357818, -292414658, -285528555, -278702079, -271937746, + -265238010, -258605264, -252041836, -245549983, -239131895, -232789684, -226525389, -220340970, -214238305, + -208219189, -202285333, -196438360, -190679806, -185011113, -179433635, -173948631, -168557267, -163260612, + -158059640, -152955229, -147948160, -143039115, -138228681, -133517347, -128905505, -124393450, -119981382, + -115669406, -111457534, -107345683, -103333681, -99421264, -95608082, -91893698, -88277589, -84759152, + -81337704, -78012482, -74782650, -71647299, -68605451, -65656059, -62798015, -60030148, -57351228, + -54759972, -52255046, -49835065, -47498599, -45244179, -43070293, -40975397, -38957912, -37016231, + -35148723, -33353731, -31629581, -29974582, -28387030, -26865208, -25407397, -24011868, -22676893, + -21400745, -20181701, -19018041, -17908057, -16850050, -15842335, -14883242, -13971116, -13104325, + -12281255, -11500315, -10759938, -10058585, -9394741, -8766919, -8173665, -7613552, -7085185, + -6587202, -6118273, -5677102, -5262427, -4873021, -4507690, -4165278, -3844660, -3544752, + -3264499, -3002887, -2758933, -2531691, -2320249, -2123731, -1941292, -1772123, -1615446, + -1470519, -1336627, -1213092, -1099261, -994515, -898263, -809943, -729021, -654988, + -587365, -525695, -469547, -418515, -372215, -330284, -292383, -258192, -227410, + -199757, -174969, -152801, -133024, -115424, -99803, -85978, -73777, -63042, + -53629, -45403, -38240, -32028, -26663, -22051, -18104, -14745, -11902, + -9511, -7514, -5860, -4500, -3394, -2503, -1797, -1244, -820, + -502, -271, -109, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#endif /* #ifdef CR8_G_ADD_75MS */ + +RAM_ALIGN const Word32 LowDelayShapes_n960_N480_HRA_2_5ms_IP[240] = { + 214, 1407, 4144, 9592, 19434, 36052, 62711, 103783, 164992, + 253687, 379148, 552904, 789076, 1104722, 1520198, 2059494, 2750561, 3625602, + 4721314, 6079061, 7744972, 9769942, 12209518, 15123669, 18576419, 22635352, 27370973, + 32855950, 39164229, 46370051, 54546874, 63766241, 74096597, 85602085, 98341344, 112366317, + 127721101, 144440829, 162550610, 182064542, 202984778, 225300694, 248988134, 274008783, 300309659, + 327822776, 356464985, 386138051, 416728983, 448110659, 480142780, 512673177, 545539472, 578571104, + 611591694, 644421704, 676881340, 708793602, 739987407, 770300656, 799583149, 827699226, 854530045, + 879975405, 903955057, 926409465, 947300009, 966608644, 984337071, 1000505451, 1015150768, 1028324899, + 1040092491, 1050528715, 1059716983, 1067746699, 1074711082, 1080705143, 1085823820, 1090160324, 1093804700, + 1096842623, 1099354431, 1101414399, 1103090233, 1104442796, 1105526028, 1106387052, 1107066439, 1107598605, + 1108012308, 1108331223, 1108574556, 1108757676, 1108892731, 1108989242, 1109054637, 1109094735, 1109114155, + 1109116652, 1109105394, 1109083163, 1109052498, 1109015788, 1108975323, 1108933307, 1108891843, 1108852902, + 1108818280, 1108789546, 1108767992, 1108754591, 1108749953, 1108754306, 1108767481, 1108788919, 1108817694, + 1108852552, 1108891964, 1108934195, -1108977380, -1109019614, -1109059032, -1109093898, -1109122681, -1109144125, + -1109157302, -1109161650, -1109156995, -1109143556, -1109121925, -1109093037, -1109058122, -1109018637, -1108976187, + -1108932433, -1108888980, -1108847255, -1108808366, -1108772946, -1108740971, -1108711558, -1108682731, -1108651158, + -1108611855, -1108557851, -1108479820, -1108365676, -1108200143, -1107964292, -1107635083, -1107184891, -1106581062, + -1105785503, -1104754330, -1103437601, -1101779148, -1099716548, -1097181229, -1094098763, -1090389339, -1085968441, + -1080747748, -1074636248, -1067541577, -1059371579, -1050036059, -1039448713, -1027529209, -1014205354, -999415302, + -983109740, -965253961, -945829756, -924837032, -902295070, -878243367, -852741971, -825871301, -797731403, + -768440669, -738134051, -706960817, -675081952, -642667284, -609892453, -576935833, -543975515, -511186440, + -478737764, -446790521, -415495622, -384992199, -355406317, -326850029, -299420751, -273200929, -248257970, + -224644391, -202398148, -181543141, -162089834, -144035993, -127367520, -112059369, -98076525, -85375063, + -73903244, -63602666, -54409446, -46255413, -39069306, -32777951, -27307388, -22583946, -18535216, + -15090941, -12183768, -9749883, -7729511, -6067277, -4712439, -3619003, -2745721, -2055997, + -1517713, -1102987, -787888, -552109, -378629, -253358, -164789, -103664, -62644, + -36017, -19417, -9584, -4141, -1406, -214 }; +RAM_ALIGN const Word32 LowDelayShapes_n960_N480_HRA_5ms_IP[420] = { + 153, 1006, 2962, 6854, 13880, 25735, 44738, 73986, 117524, + 180533, 269534, 392603, 559593, 782368, 1075031, 1454143, 1938937, 2551502, + 3316947, 4263524, 5422707, 6829222, 8521011, 10539137, 12927604, 15733109, 19004698, + 22793344, 27151431, 32132152, 37788816, 44174082, 51339114, 59332667, 68200136, 77982547, + 88715548, 100428385, 113142910, 126872625, 141621804, 157384706, 174144915, 191874817, 210535261, + 230075406, 250432778, 271533559, 293293106, 315616716, 338400617, 361533198, 384896437, 408367524, + 431820627, 455128780, 478165843, 500808481, 522938120, 544442827, 565219197, 585174124, 604225689, + 622304754, 639355717, 655337129, 670221993, 683997778, 696666136, 708242355, 718754575, 728242788, + 736757688, 744359378, 751116012, 757102394, 762398585, 767088551, 771258886, 774997644, 778393288, + 781533768, 784505744, 787393944, 790280637, 793245232, 796363956, 799709608, 803351363, 807354601, + 811780739, 816687064, 822126537, 828147569, 834793773, 842103681, 850110443, 858841520, 868318369, + 878556163, 889563529, 901342346, 913887605, 927187338, 941222645, 955967800, 971390453, 987451937, + 1004107649, 1021307531, 1038996616, 1057115651, 1075601769, 1094389201, 1113410024, 1132594917, 1151873921, + 1171177186, 1190435688, 1209581916, 1228550504, 1247278803, 1265707395, 1283780533, 1301446498, 1318657893, + 1335371854, 1351550191, 1367159457, 1382170967, 1396560748, 1410309460, 1423402271, 1435828702, 1447582463, + 1458661263, 1469066617, 1478803649, 1487880888, 1496310057, 1504105864, 1511285781, 1517869810, 1523880240, + 1529341392, 1534279342, 1538721639, 1542697001, 1546235012, 1549365809, 1552119778, 1554527246, 1556618203, + 1558422028, 1559967247, 1561281317, 1562390436, 1563319395, 1564091445, 1564728213, 1565249633, 1565673917, + 1566017543, 1566295272, 1566520181, 1566703721, 1566855785, 1566984788, 1567097770, 1567200488, 1567297538, + 1567392456, 1567487845, 1567585484, 1567686442, 1567791191, 1567899701, 1568011546, 1568125984, 1568242042, + 1568358534, 1568474289, 1568587995, 1568698311, 1568803945, 1568903672, 1568996349, 1569080932, 1569156484, + 1569222192, 1569277370, 1569321465, 1569354064, 1569374893, 1569383815, 1569380829, 1569366065, 1569339781, + 1569302349, 1569254257, 1569196093, 1569128539, 1569052361, 1568968403, 1568877571, 1568780830, 1568679193, + 1568573710, 1568465461, 1568355548, 1568245083, 1568135185, 1568026967, 1567921528, 1567819946, 1567723271, + 1567632511, 1567548628, 1567472527, 1567405047, 1567346952, 1567298919, 1567261537, 1567235287, 1567220544, + 1567217562, 1567226472, 1567247272, 1567279829, 1567323868, 1567378978, 1567444612, 1567520086, 1567604589, + 1567697189, 1567796846, 1567902419, 1568012687, 1568126359, 1568242097, -1568358534, -1568474289, -1568587995, + -1568698311, -1568803945, -1568903672, -1568996349, -1569080932, -1569156484, -1569222192, -1569277370, -1569321465, + -1569354064, -1569374893, -1569383815, -1569380829, -1569366065, -1569339781, -1569302349, -1569254257, -1569196093, + -1569128539, -1569052361, -1568968403, -1568877571, -1568780830, -1568679193, -1568573710, -1568465461, -1568355548, + -1568245083, -1568135185, -1568026967, -1567921528, -1567819946, -1567723271, -1567632511, -1567548628, -1567472527, + -1567405047, -1567346952, -1567298919, -1567261537, -1567235287, -1567220544, -1567217562, -1567226472, -1567247272, + -1567279829, -1567323868, -1567378978, -1567444612, -1567520086, -1567604589, -1567697189, -1567796846, -1567902419, + -1568012687, -1568126359, -1568242097, -1568358479, -1568473914, -1568586854, -1568695591, -1568798286, -1568892916, + -1568977226, -1569048656, -1569104263, -1569140635, -1569153790, -1569139071, -1569091028, -1569003308, -1568868529, + -1568678156, -1568422382, -1568089999, -1567668277, -1567142834, -1566497514, -1565714254, -1564772952, -1563651331, + -1562324794, -1560766278, -1558946098, -1556831792, -1554387964, -1551576132, -1548354584, -1544678268, -1540498696, + -1535763912, -1530418507, -1524403718, -1517657618, -1510115411, -1501709847, -1492371764, -1482030768, -1470616033, + -1458057247, -1444285654, -1429235205, -1412843785, -1395054486, -1375816907, -1355088440, -1332835519, -1309034797, + -1283674224, -1256753995, -1228287351, -1198301206, -1166836586, -1133948872, -1099707826, -1064197417, -1027515419, + -989772809, -951092956, -911610610, -871470715, -830827045, -789840682, -748678366, -707510713, -666510349, + -625849956, -585700281, -546228117, -507594292, -469951710, -433443460, -398201053, -364342807, -331972440, + -301177891, -272030413, -244583969, -218874947, -194922208, -172727465, -152275991, -133537623, -116468025, + -101010189, -87096098, -74648510, -63582812, -53808877, -45232880, -37759037, -31291209, -25734358, + -20995832, -16986455, -13621428, -10821035, -8511162, -6623645, -5096451, -3873717, -2905668, + -2148423, -1563717, -1118555, -784819, -538834, -360926, -234965, -147925, -89451, + -51458, -27754, -13704, -5923, -2011, -306 }; +RAM_ALIGN const Word32 LowDelayShapes_n960_N480_HRA_IP[780] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 105, 687, 2025, 4688, 9502, 17634, + 30689, 50817, 80838, 124375, 186009, 271432, 387623, 543017, 747676, + 1013467, 1354215, 1785853, 2326545, 2996777, 3819424, 4819763, 6025441, 7466392, + 9174686, 11184326, 13530961, 16251545, 19383921, 22966334, 27036891, 31632957, 36790505, + 42543426, 48922816, 55956247, 63667042, 72073568, 81188571, 91018551, 101563225, 112815065, + 124758945, 137371906, 150623045, 164473553, 178876885, 193779093, 209119296, 224830297, 240839344, + 257069006, 273438164, 289863100, 306258645, 322539389, 338620907, 354420979, 369860792, 384866072, + 399368244, 413305531, 426623420, 439275707, 451224957, 462442920, 472910759, 482619111, 491567983, + 499766479, 507232383, 513991603, 520077504, 525530145, 530395443, 534724296, 538571682, 541995756, + 545056975, 547817267, 550339253, 552685542, 554918106, 557097730, 559283544, 561532631, 563899693, + 566436780, 569193061, 572214618, 575544274, 579221418, 583281849, 587757606, 592676805, 598063482, + 603937430, 610314061, 617204279, 624614388, 632546030, 640996174, 649957147, 659416723, 669358259, + 679760895, 690599795, 701846444, 713468981, 725432569, 737699796, 750231092, 762985159, 775919415, + 788990419, 802154306, 815367198, 828585593, 841766740, 854868978, 867852045, 880677358, 893308258, + 905710214, 917851001, 929700832, 941232469, 952421292, 963245346, 973685357, 983724726, 993349512, + 1002548385, 1011312579, 1019635831, 1027514316, 1034946573, 1041933433, 1048477942, 1054585275, 1060262649, + 1065519228, 1070366010, 1074815711, 1078882625, 1082582470, 1085932219, 1088949913, 1091654462, 1094065430, + 1096202822, 1098086863, 1099737781, 1101175600, 1102419947, 1103489872, 1104403690, 1105178850, 1105831817, + 1106377989, 1106831632, 1107205842, 1107512525, 1107762397, 1107965009, 1108128778, 1108261042, 1108368118, + 1108455375, 1108527311, 1108587638, 1108639366, 1108684891, 1108726077, 1108764338, 1108800715, 1108835945, + 1108870522, 1108904754, 1108938811, 1108972723, 1109006542, 1109040205, 1109073607, 1109106645, 1109139216, + 1109171221, 1109202563, 1109233147, 1109262880, 1109291675, 1109319447, 1109346114, 1109371602, 1109395837, + 1109418753, 1109440288, 1109460385, 1109478991, 1109496061, 1109511552, 1109525430, 1109537663, 1109548227, + 1109557101, 1109564272, 1109569731, 1109573473, 1109575498, 1109575814, 1109574431, 1109571363, 1109566630, + 1109560257, 1109552270, 1109542702, 1109531587, 1109518966, 1109504879, 1109489374, 1109472496, 1109454299, + 1109434835, 1109414161, 1109392335, 1109369417, 1109345469, 1109320555, 1109294742, 1109268095, 1109240684, + 1109212578, 1109183848, 1109154564, 1109124800, 1109094627, 1109064121, 1109033354, 1109002402, 1108971338, + 1108940237, 1108909175, 1108878226, 1108847464, 1108816965, 1108786801, 1108757046, 1108727774, 1108699056, + 1108670963, 1108643567, 1108616936, 1108591139, 1108566243, 1108542312, 1108519412, 1108497603, 1108476946, + 1108457499, 1108439319, 1108422458, 1108406967, 1108392895, 1108380286, 1108369184, 1108359626, 1108351647, + 1108345281, 1108340553, 1108337489, 1108336107, 1108336422, 1108338446, 1108342183, 1108347636, 1108354799, + 1108363664, 1108374217, 1108386437, 1108400301, 1108415777, 1108432830, 1108451419, 1108471498, 1108493014, + 1108515912, 1108540129, 1108565598, 1108592247, 1108620001, 1108648779, 1108678497, 1108709066, 1108740395, + 1108772389, 1108804951, 1108837980, 1108871376, 1108905035, 1108938852, 1108972723, 1109006542, 1109040205, + 1109073607, 1109106645, 1109139216, 1109171221, 1109202563, 1109233147, 1109262880, 1109291675, 1109319447, + 1109346114, 1109371602, 1109395837, 1109418753, 1109440288, 1109460385, 1109478991, 1109496061, 1109511552, + 1109525430, 1109537663, 1109548227, 1109557101, 1109564272, 1109569731, 1109573473, 1109575498, 1109575814, + 1109574431, 1109571363, 1109566630, 1109560257, 1109552270, 1109542702, 1109531587, 1109518966, 1109504879, + 1109489374, 1109472496, 1109454299, 1109434835, 1109414161, 1109392335, 1109369417, 1109345469, 1109320555, + 1109294742, 1109268095, 1109240684, 1109212578, 1109183848, 1109154564, 1109124800, 1109094627, 1109064121, + 1109033354, 1109002402, 1108971338, -1108940237, -1108909175, -1108878226, -1108847464, -1108816965, -1108786801, + -1108757046, -1108727774, -1108699056, -1108670963, -1108643567, -1108616936, -1108591139, -1108566243, -1108542312, + -1108519412, -1108497603, -1108476946, -1108457499, -1108439319, -1108422458, -1108406967, -1108392895, -1108380286, + -1108369184, -1108359626, -1108351647, -1108345281, -1108340553, -1108337489, -1108336107, -1108336422, -1108338446, + -1108342183, -1108347636, -1108354799, -1108363664, -1108374217, -1108386437, -1108400301, -1108415777, -1108432830, + -1108451419, -1108471498, -1108493014, -1108515912, -1108540129, -1108565598, -1108592247, -1108620001, -1108648779, + -1108678497, -1108709066, -1108740395, -1108772389, -1108804951, -1108837980, -1108871376, -1108905035, -1108938852, + -1108972723, -1109006542, -1109040205, -1109073607, -1109106645, -1109139216, -1109171221, -1109202563, -1109233147, + -1109262880, -1109291675, -1109319447, -1109346114, -1109371602, -1109395837, -1109418753, -1109440288, -1109460385, + -1109478991, -1109496061, -1109511552, -1109525430, -1109537663, -1109548227, -1109557101, -1109564272, -1109569731, + -1109573473, -1109575498, -1109575814, -1109574431, -1109571363, -1109566630, -1109560257, -1109552270, -1109542702, + -1109531587, -1109518966, -1109504879, -1109489374, -1109472496, -1109454299, -1109434835, -1109414161, -1109392335, + -1109369417, -1109345469, -1109320555, -1109294742, -1109268095, -1109240684, -1109212578, -1109183848, -1109154564, + -1109124800, -1109094627, -1109064121, -1109033354, -1109002402, -1108971338, -1108940237, -1108909175, -1108878226, + -1108847464, -1108816965, -1108786801, -1108757046, -1108727774, -1108699056, -1108670963, -1108643567, -1108616936, + -1108591139, -1108566243, -1108542312, -1108519412, -1108497603, -1108476946, -1108457499, -1108439319, -1108422458, + -1108406967, -1108392895, -1108380286, -1108369184, -1108359626, -1108351647, -1108345281, -1108340553, -1108337489, + -1108336107, -1108336422, -1108338446, -1108342183, -1108347636, -1108354799, -1108363664, -1108374217, -1108386437, + -1108400301, -1108415777, -1108432830, -1108451419, -1108471498, -1108493014, -1108515912, -1108540129, -1108565598, + -1108592247, -1108620001, -1108648779, -1108678497, -1108709066, -1108740395, -1108772389, -1108804951, -1108837980, + -1108871376, -1108905035, -1108938852, -1108972682, -1109006261, -1109039351, -1109071571, -1109102407, -1109131162, + -1109156896, -1109178374, -1109193989, -1109201688, -1109198891, -1109182406, -1109148336, -1109091993, -1109007805, + -1108889225, -1108728643, -1108517302, -1108245211, -1107901063, -1107472158, -1106944320, -1106301824, -1105527310, + -1104601707, -1103504157, -1102211925, -1100700333, -1098942681, -1096910184, -1094571927, -1091894839, -1088843693, + -1085381150, -1081467851, -1077062556, -1072122362, -1066602975, -1060459071, -1053644721, -1046113898, -1037821043, + -1028721699, -1018773190, -1007935330, -996171157, -983447669, -969736537, -955014802, -939265519, -922478340, + -904650040, -885784954, -865895333, -845001612, -823132583, -800325469, -776625909, -752087844, -726773304, + -700752110, -674101477, -646905528, -619254721, -591245188, -562977986, -534558266, -506094363, -477696807, + -449477265, -421547413, -394017760, -366996430, -340587909, -314891801, -290001587, -266003441, -242975106, + -220984887, -200090776, -180339738, -161767200, -144396752, -128240072, -113297104, -99556455, -86996029, + -75583860, -65279122, -56033278, -47791333, -40493145, -34074759, -28469709, -23610284, -19428682, + -15858075, -12833534, -10292814, -8176993, -6430970, -5003818, -3849000, -2924474, -2192679, + -1620441, -1178790, -842729, -590941, -405483, -271445, -176613, -111130, -67168, + -38622, -20823, -10279, -4442, -1508, -229 }; +RAM_ALIGN const Word32 LowDelayShapes_n960_N960_HRA_2_5ms_IP[480] = { + 214, 718, 1564, 2887, 4850, 7655, 11549, 16828, 23847, + 33024, 44855, 59914, 78870, 102494, 131671, 167412, 210862, 263320, + 326247, 401279, 490246, 595184, 718349, 862234, 1029583, 1223409, 1447008, + 1703973, 1998212, 2333963, 2715805, 3148674, 3637878, 4189104, 4808432, 5502344, + 6277732, 7141903, 8102584, 9167924, 10346495, 11647288, 13079711, 14653577, 16379097, + 18266869, 20327854, 22573365, 25015043, 27664828, 30534935, 33637823, 36986159, 40592781, + 44470665, 48632874, 53092523, 57862728, 62956563, 68387004, 74166887, 80308851, 86825288, + 93728290, 101029595, 108740533, 116871978, 125434289, 134437259, 143890065, 153801219, 164178510, + 175028964, 186358792, 198173341, 210477054, 223273422, 236564945, 250353087, 264638241, 279419691, + 294695574, 310462852, 326717278, 343453367, 360664374, 378342268, 396477718, 415060072, 434077349, + 453516232, 473362064, 493598851, 514209273, 535174695, 556475190, 578089564, 599995393, 622169062, + 644585817, 667219821, 690044217, 713031208, 736152130, 759377547, 782677345, 806020840, 829376886, + 852713991, 876000447, 899204452, 922294246, 945238242, 968005170, 990564209, 1012885127, 1034938418, + 1056695435, 1078128516, 1099211112, 1119917901, 1140224902, 1160109567, 1179550884, 1198529445, 1217027528, + 1235029144, 1252520091, 1269487982, 1285922269, 1301814250, 1317157066, 1331945687, 1346176884, 1359849191, + 1372962859, 1385519797, 1397523511, 1408979025, 1419892807, 1430272680, 1440127732, 1449468226, 1458305498, + 1466651859, 1474520500, 1481925383, 1488881148, 1495403011, 1501506666, 1507208191, 1512523957, 1517470536, + 1522064619, 1526322933, 1530262165, 1533898889, 1537249499, 1540330149, 1543156689, 1545744622, 1548109049, + 1550264632, 1552225553, 1554005489, 1555617576, 1557074399, 1558387963, 1559569689, 1560630404, 1561580336, + 1562429115, 1563185777, 1563858772, 1564455973, 1564984695, 1565451702, 1565863235, 1566225027, 1566542325, + 1566819919, 1567062160, 1567272989, 1567455965, 1567614286, 1567750818, 1567868122, 1567968477, 1568053906, + 1568126199, 1568186936, 1568237509, 1568279142, 1568312908, 1568339752, 1568360503, 1568375889, 1568386553, + 1568393062, 1568395921, 1568395582, 1568392450, 1568386895, 1568379252, 1568369831, 1568358921, 1568346793, + 1568333699, 1568319881, 1568305568, 1568290979, 1568276322, 1568261795, 1568247587, 1568233876, 1568220830, + 1568208605, 1568197346, 1568187184, 1568178237, 1568170607, 1568164384, 1568159638, 1568156425, 1568154783, + 1568154732, 1568156276, 1568159400, 1568164071, 1568170240, 1568177841, 1568186791, 1568196993, 1568208336, + 1568220695, 1568233934, 1568247907, 1568262461, 1568277433, 1568292659, -1568307970, -1568323196, -1568338169, + -1568352723, -1568366698, -1568379938, -1568392298, -1568403642, -1568413846, -1568422797, -1568430399, -1568436568, + -1568441238, -1568444360, -1568445899, -1568445842, -1568444189, -1568440959, -1568436189, -1568429930, -1568422249, + -1568413227, -1568402961, -1568391555, -1568379128, -1568365802, -1568351710, -1568336985, -1568321763, -1568306179, + -1568290362, -1568274432, -1568258500, -1568242658, -1568226981, -1568211514, -1568196277, -1568181247, -1568166364, + -1568151514, -1568136526, -1568121163, -1568105112, -1568087973, -1568069251, -1568048342, -1568024520, -1567996924, + -1567964542, -1567926198, -1567880531, -1567825982, -1567760771, -1567682880, -1567590033, -1567479671, -1567348935, + -1567194644, -1567013268, -1566800908, -1566553276, -1566265667, -1565932945, -1565549513, -1565109302, -1564605744, + -1564031762, -1563379748, -1562641555, -1561808482, -1560871269, -1559820088, -1558644542, -1557333666, -1555875931, + -1554259255, -1552471010, -1550498044, -1548326699, -1545942840, -1543331880, -1540478822, -1537368293, -1533984594, + -1530311749, -1526333557, -1522033659, -1517395595, -1512402882, -1507039082, -1501287884, -1495133187, -1488559185, + -1481550459, -1474092069, -1466169648, -1457769502, -1448878707, -1439485206, -1429577913, -1419146803, -1408183016, + -1396678943, -1384628319, -1372026306, -1358869573, -1345156368, -1330886582, -1316061806, -1300685380, -1284762427, + -1268299884, -1251306514, -1233792909, -1215771486, -1197256464, -1178263828, -1158811290, -1138918228, -1118605615, + -1097895946, -1076813140, -1055382446, -1033630329, -1011584359, -989273085, -966725907, -943972946, -921044904, + -897972934, -874788497, -851523227, -828208798, -804876792, -781558570, -758285150, -735087092, -711994385, + -689036342, -666241506, -643637563, -621251256, -599108313, -577233388, -555649994, -534380464, -513445903, + -492866154, -472659775, -452844015, -433434798, -414446719, -395893041, -377785693, -360135279, -342951091, + -326241124, -310012090, -294269448, -279017421, -264259031, -249996126, -236229411, -222958488, -210181887, + -197897110, -186100669, -174788126, -163954142, -153592518, -143696242, -134257536, -125267909, -116718201, + -108598638, -100898882, -93608083, -86714933, -80207718, -74074369, -68302521, -62879558, -57792672, + -53028908, -48575221, -44418518, -40545711, -36943757, -33599707, -30500746, -27634227, -24987716, + -22549018, -20306212, -18247679, -16362124, -14638601, -13066533, -11635723, -10336374, -9159092, + -8094899, -7135237, -6271969, -5497377, -4804166, -4185453, -3634765, -3146030, -2713568, + -2332079, -1996632, -1702653, -1445912, -1222503, -1028839, -861625, -717855, -594786, + -489927, -401025, -326046, -263164, -210741, -167319, -131601, -102441, -78831, + -59886, -44835, -33011, -23837, -16822, -11545, -7652, -4848, -2886, + -1564, -718, -214 }; +RAM_ALIGN const Word32 LowDelayShapes_n960_N960_HRA_5ms_IP[840] = { + 76, 257, 559, 1032, 1734, 2736, 4127, 6013, 8519, + 11795, 16017, 21388, 28146, 36565, 46958, 59681, 75141, 93793, + 116154, 142798, 174368, 211576, 255213, 306147, 365337, 433830, 512771, + 603404, 707083, 825270, 959545, 1111607, 1283278, 1476512, 1693391, 1936135, + 2207099, 2508779, 2843816, 3214988, 3625222, 4077586, 4575292, 5121693, 5720282, + 6374686, 7088668, 7866117, 8711044, 9627575, 10619947, 11692493, 12849640, 14095892, + 15435823, 16874063, 18415286, 20064193, 21825499, 23703917, 25704138, 27830817, 30088554, + 32481870, 35015193, 37692833, 40518962, 43497594, 46632560, 49927486, 53385775, 57010578, + 60804774, 64770951, 68911378, 73227988, 77722354, 82395670, 87248734, 92281923, 97495181, + 102888003, 108459414, 114207966, 120131717, 126228227, 132494547, 138927218, 145522261, 152275182, + 159180971, 166234104, 173428552, 180757788, 188214801, 195792105, 203481764, 211275403, 219164235, + 227139085, 235190416, 243308359, 251482745, 259703138, 267958873, 276239090, 284532776, 292828806, + 301115982, 309383080, 317618887, 325812253, 333952128, 342027608, 350027981, 357942764, 365761752, + 373475051, 381073123, 388546818, 395887478, 403086861, 410137202, 417031278, 423762414, 430324505, + 436712040, 442920115, 448944445, 454781381, 460427907, 465881653, 471140887, 476204517, 481072084, + 485743749, 490220286, 494503064, 498594029, 502495687, 506211078, 509743756, 513097759, 516277584, + 519288161, 522134817, 524823252, 527359505, 529749922, 532001128, 534119994, 536113606, 537989238, + 539754317, 541416403, 542983151, 544462298, 545861626, 547188947, 548452077, 549658817, 550816937, + 551934153, 553018114, 554076391, 555116460, 556145691, 557171340, 558200539, 559240287, 560297445, + 561378728, 562490702, 563639778, 564832206, 566074075, 567371305, 568729649, 570154682, 571651805, + 573226236, 574883010, 576626970, 578462769, 580394858, 582427488, 584564698, 586810313, 589167940, + 591640954, 594232500, 596945481, 599782552, 602746115, 605838312, 609061015, 612415825, 615904060, + 619526756, 623284658, 627178213, 631207574, 635372590, 639672804, 644107457, 648675483, 653375510, + 658205862, 663164563, 668249336, 673457615, 678786542, 684232980, 689793518, 695464480, 701241935, + 707121707, 713099387, 719170342, 725329733, 731572527, 737893509, 744287298, 750748363, 757271038, + 763849540, 770477982, 777150393, 783860731, 790602903, 797370781, 804158216, 810959059, 817767172, + 824576448, 831380824, 838174297, 844950938, 851704905, 858430460, 865121975, 871773953, 878381029, + 884937988, 891439772, 897881487, 904258415, 910566018, 916799945, 922956036, 929030332, 935019072, + 940918701, 946725867, 952437431, 958050459, 963562228, 968970222, 974272134, 979465863, 984549513, + 989521388, 994379992, 999124027, 1003752385, 1008264148, 1012658583, 1016935141, 1021093445, 1025133296, + 1029054661, 1032857672, 1036542620, 1040109952, 1043560268, 1046894310, 1050112965, 1053217256, 1056208338, + 1059087494, 1061856131, 1064515771, 1067068050, 1069514712, 1071857603, 1074098665, 1076239931, 1078283519, + 1080231627, 1082086525, 1083850551, 1085526101, 1087115629, 1088621631, 1090046648, 1091393252, 1092664044, + 1093861644, 1094988685, 1096047808, 1097041655, 1097972860, 1098844046, 1099657818, 1100416756, 1101123410, + 1101780297, 1102389891, 1102954625, 1103476879, 1103958984, 1104403212, 1104811774, 1105186822, 1105530438, + 1105844638, 1106131370, 1106392508, 1106629854, 1106845137, 1107040012, 1107216060, 1107374784, 1107517617, + 1107645915, 1107760961, 1107863967, 1107956073, 1108038347, 1108111792, 1108177340, 1108235860, 1108288159, + 1108334979, 1108377006, 1108414868, 1108449137, 1108480336, 1108508935, 1108535359, 1108559986, 1108583153, + 1108605158, 1108626260, 1108646685, 1108666625, 1108686243, 1108705675, 1108725031, 1108744398, 1108763843, + 1108783413, 1108803139, 1108823037, 1108843110, 1108863348, 1108883733, 1108904238, 1108924827, 1108945461, + 1108966087, 1108986655, 1109007132, 1109027458, 1109047572, 1109067415, 1109086928, 1109106055, 1109124739, + 1109142927, 1109160566, 1109177606, 1109193997, 1109209694, 1109224653, 1109238833, 1109252194, 1109264701, + 1109276321, 1109287024, 1109296781, 1109305569, 1109313366, 1109320154, 1109325918, 1109330645, 1109334328, + 1109336959, 1109338535, 1109339057, 1109338528, 1109336954, 1109334342, 1109330704, 1109326055, 1109320411, + 1109313791, 1109306216, 1109297711, 1109288301, 1109278014, 1109266881, 1109254934, 1109242206, 1109228734, + 1109214554, 1109199706, 1109184228, 1109168164, 1109151555, 1109134445, 1109116879, 1109098903, 1109080563, + 1109061906, 1109042980, 1109023833, 1109004515, 1108985073, 1108965557, 1108946017, 1108926503, 1108907062, + 1108887746, 1108868601, 1108849679, 1108831026, 1108812690, 1108794719, 1108777158, 1108760054, 1108743451, + 1108727393, 1108711923, 1108697081, 1108682908, 1108669442, 1108656721, 1108644781, 1108633654, 1108623374, + 1108613969, 1108605469, 1108597899, 1108591283, 1108585643, 1108580997, 1108577362, 1108574752, 1108573178, + 1108572650, 1108573172, 1108574747, 1108577376, 1108581056, 1108585780, 1108591541, 1108598324, 1108606116, + 1108614899, 1108624650, 1108635346, 1108646959, 1108659460, 1108672814, 1108686987, 1108701939, 1108717629, + 1108734013, 1108751046, 1108768679, 1108786861, 1108805540, 1108824662, 1108844171, 1108864011, 1108884121, + 1108904445, 1108924921, 1108945488, -1108966087, -1108986655, -1109007132, -1109027458, -1109047572, -1109067415, + -1109086928, -1109106055, -1109124739, -1109142927, -1109160566, -1109177606, -1109193997, -1109209694, -1109224653, + -1109238833, -1109252194, -1109264701, -1109276321, -1109287024, -1109296781, -1109305569, -1109313366, -1109320154, + -1109325918, -1109330645, -1109334328, -1109336959, -1109338535, -1109339057, -1109338528, -1109336954, -1109334342, + -1109330704, -1109326055, -1109320411, -1109313791, -1109306216, -1109297711, -1109288301, -1109278014, -1109266881, + -1109254934, -1109242206, -1109228734, -1109214554, -1109199706, -1109184228, -1109168164, -1109151555, -1109134445, + -1109116879, -1109098903, -1109080563, -1109061906, -1109042980, -1109023833, -1109004515, -1108985073, -1108965557, + -1108946017, -1108926503, -1108907062, -1108887746, -1108868601, -1108849679, -1108831026, -1108812690, -1108794719, + -1108777158, -1108760054, -1108743451, -1108727393, -1108711923, -1108697081, -1108682908, -1108669442, -1108656721, + -1108644781, -1108633654, -1108623374, -1108613969, -1108605469, -1108597899, -1108591283, -1108585643, -1108580997, + -1108577362, -1108574752, -1108573178, -1108572650, -1108573172, -1108574747, -1108577376, -1108581056, -1108585780, + -1108591541, -1108598324, -1108606116, -1108614899, -1108624650, -1108635346, -1108646959, -1108659460, -1108672814, + -1108686987, -1108701939, -1108717629, -1108734013, -1108751046, -1108768679, -1108786861, -1108805540, -1108824662, + -1108844171, -1108864011, -1108884121, -1108904445, -1108924921, -1108945488, -1108966059, -1108986562, -1109006925, + -1109027070, -1109046909, -1109066353, -1109085302, -1109103653, -1109121290, -1109138090, -1109153916, -1109168619, + -1109182038, -1109193990, -1109204280, -1109212687, -1109218972, -1109222869, -1109224086, -1109222302, -1109217164, + -1109208286, -1109195243, -1109177572, -1109154771, -1109126288, -1109091528, -1109049845, -1109000541, -1108942861, + -1108875994, -1108799068, -1108711146, -1108611228, -1108498242, -1108371047, -1108228427, -1108069090, -1107891663, + -1107694692, -1107476636, -1107235870, -1106970675, -1106679239, -1106359654, -1106009912, -1105627904, -1105211414, + -1104758117, -1104265576, -1103731240, -1103152437, -1102526375, -1101850136, -1101120673, -1100334807, -1099489225, + -1098580473, -1097604958, -1096558943, -1095438542, -1094239723, -1092958302, -1091589944, -1090130161, -1088574313, + -1086917606, -1085155099, -1083281700, -1081292171, -1079181138, -1076943086, -1074572374, -1072063243, -1069409818, + -1066606126, -1063646105, -1060523618, -1057232468, -1053766415, -1050119192, -1046284528, -1042256165, -1038027882, + -1033593517, -1028946994, -1024082345, -1018993738, -1013675503, -1008122162, -1002328454, -996289366, -990000160, + -983456402, -976653990, -969589182, -962258626, -954659381, -946788949, -938645296, -930226877, -921532657, + -912562133, -903315354, -893792938, -883996084, -873926592, -863586870, -852979945, -842109472, -830979735, + -819595655, -807962787, -796087320, -783976072, -771636483, -759076610, -746305110, -733331233, -720164799, + -706816188, -693296313, -679616605, -665788980, -651825820, -637739943, -623544570, -609253297, -594880059, + -580439096, -565944918, -551412265, -536856066, -522291404, -507733472, -493197528, -478698857, -464252725, + -449874333, -435578778, -421381001, -407295749, -393337528, -379520558, -365858731, -352365567, -339054174, + -325937207, -313026827, -300334664, -287871784, -275648653, -263675105, -251960314, -240512770, -229340251, + -218449809, -207847746, -197539607, -187530166, -177823422, -168422593, -159330123, -150547678, -142076164, + -133915731, -126065794, -118525050, -111291498, -104362470, -97734652, -91404122, -85366377, -79616373, + -74148557, -68956911, -64034986, -59375949, -54972617, -50817502, -46902854, -43220698, -39762875, + -36521086, -33486923, -30651913, -28007548, -25545325, -23256770, -21133479, -19167136, -17349546, + -15672656, -14128580, -12709614, -11408260, -10217235, -9129491, -8138220, -7236869, -6419144, + -5679019, -5010736, -4408811, -3868031, -3383459, -2950426, -2564532, -2221640, -1917871, + -1649598, -1413439, -1206249, -1025112, -867332, -730423, -612103, -510279, -423042, + -348652, -285533, -232260, -187551, -150254, -119343, -93901, -73120, -56285, + -42770, -32029, -23588, -17037, -12025, -8254, -5472, -3467, -2064, + -1119, -513, -153 }; +RAM_ALIGN const Word32 LowDelayShapes_n960_N960_HRA_IP[1560] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 52, 175, 382, + 705, 1185, 1871, 2823, 4114, 5831, 8077, 10972, 14660, + 19303, 25092, 32244, 41009, 51670, 64545, 79996, 98427, 120290, + 146088, 176379, 211778, 252965, 300685, 355753, 419058, 491567, 574329, + 668476, 775231, 895906, 1031911, 1184750, 1356028, 1547453, 1760836, 1998091, + 2261242, 2552417, 2873848, 3227877, 3616948, 4043606, 4510498, 5020366, 5576047, + 6180463, 6836620, 7547602, 8316559, 9146706, 10041310, 11003683, 12037172, 13145144, + 14330983, 15598071, 16949778, 18389446, 19920381, 21545832, 23268982, 25092926, 27020662, + 29055072, 31198906, 33454766, 35825091, 38312140, 40917976, 43644450, 46493186, 49465569, + 52562726, 55785514, 59134509, 62609992, 66211939, 69940008, 73793535, 77771521, 81872629, + 86095178, 90437137, 94896125, 99469410, 104153908, 108946186, 113842469, 118838639, 123930249, + 129112527, 134380390, 139728454, 145151046, 150642225, 156195792, 161805313, 167464136, 173165413, + 178902121, 184667086, 190453005, 196252476, 202058015, 207862090, 213657145, 219435626, 225190009, + 230912827, 236596697, 242234348, 247818648, 253342624, 258799497, 264182697, 269485893, 274703012, + 279828312, 284856314, 289781856, 294600125, 299306665, 303897390, 308368599, 312716983, 316939635, + 321034059, 324998175, 328830319, 332529248, 336094136, 339524575, 342820570, 345982531, 349011267, + 351907976, 354674236, 357311989, 359823531, 362211496, 364478840, 366628822, 368664989, 370591159, + 372411396, 374129997, 375751467, 377280502, 378721970, 380080887, 381362400, 382571769, 383714343, + 384795547, 385820862, 386795806, 387725921, 388616754, 389473844, 390302710, 391108835, 391897652, + 392674541, 393444809, 394213686, 394986316, 395767747, 396562926, 397376691, 398213764, 399078748, + 399976120, 400910228, 401885285, 402905364, 403974398, 405096172, 406274322, 407512329, 408813519, + 410181054, 411617935, 413126993, 414710888, 416372104, 418112946, 419935539, 421841819, 423833534, + 425912241, 428079300, 430335872, 432682921, 435121205, 437651278, 440273491, 442987985, 445794697, + 448693355, 451683483, 454764399, 457935219, 461194860, 464542039, 467975283, 471492928, 475093126, + 478773851, 482532904, 486367920, 490276375, 494255591, 498302751, 502414896, 506588946, 510821698, + 515109841, 519449966, 523838572, 528272075, 532746823, 537259100, 541805139, 546381131, 550983233, + 555607579, 560250290, 564907481, 569575271, 574249791, 578927195, 583603665, 588275420, 592938724, + 597589893, 602225302, 606841390, 611434670, 616001729, 620539240, 625043960, 629512740, 633942527, + 638330370, 642673418, 646968929, 651214270, 655406919, 659544468, 663624624, 667645211, 671604169, + 675499557, 679329551, 683092449, 686786663, 690410727, 693963289, 697443117, 700849092, 704180212, + 707435589, 710614445, 713716116, 716740046, 719685788, 722553001, 725341451, 728051005, 730681634, + 733233409, 735706498, 738101168, 740417780, 742656787, 744818734, 746904257, 748914076, 750848997, + 752709910, 754497783, 756213660, 757858664, 759433984, 760940881, 762380680, 763754766, 765064584, + 766311629, 767497450, 768623637, 769691823, 770703677, 771660899, 772565218, 773418381, 774222155, + 774978320, 775688661, 776354967, 776979026, 777562617, 778107510, 778615459, 779088198, 779527438, + 779934863, 780312126, 780660846, 780982606, 781278948, 781551373, 781801337, 782030250, 782239474, + 782430322, 782604056, 782761888, 782904976, 783034427, 783151295, 783256582, 783351237, 783436158, + 783512191, 783580133, 783640729, 783694677, 783742630, 783785193, 783822926, 783856349, 783885939, + 783912134, 783935335, 783955909, 783974185, 783990464, 784005015, 784018080, 784029874, 784040589, + 784050394, 784059435, 784067843, 784075728, 784083188, 784090303, 784097145, 784103769, 784110225, + 784116552, 784122782, 784128939, 784135042, 784141107, 784147142, 784153152, 784159138, 784165118, + 784171086, 784177037, 784182968, 784188874, 784194749, 784200591, 784206393, 784212151, 784217862, + 784223520, 784229122, 784234663, 784240139, 784245546, 784250879, 784256136, 784261311, 784266402, + 784271403, 784276313, 784281126, 784285841, 784290452, 784294958, 784299354, 784303638, 784307807, + 784311858, 784315788, 784319595, 784323276, 784326828, 784330250, 784333539, 784336693, 784339710, + 784342589, 784345327, 784347923, 784350376, 784352685, 784354847, 784356862, 784358729, 784360447, + 784362016, 784363434, 784364702, 784365818, 784366783, 784367596, 784368257, 784368766, 784369124, + 784369331, 784369387, 784369292, 784369047, 784368653, 784368111, 784367421, 784366584, 784365602, + 784364475, 784363205, 784361793, 784360241, 784358550, 784356721, 784354756, 784352657, 784350426, + 784348065, 784345575, 784342958, 784340217, 784337354, 784334371, 784331270, 784328053, 784324723, + 784321282, 784317734, 784314079, 784310321, 784306463, 784302507, 784298456, 784294312, 784290078, + 784285758, 784281354, 784276869, 784272306, 784267667, 784262957, 784258177, 784253332, 784248423, + 784243454, 784238429, 784233349, 784228220, 784223043, 784217822, 784212560, 784207260, 784201926, + 784196560, 784191167, 784185749, 784180310, 784174852, 784169380, 784163896, 784158404, 784152907, + 784147408, 784141911, 784136419, 784130935, 784125463, 784120006, 784114567, 784109150, 784103757, + 784098392, 784093059, 784087760, 784082499, 784077278, 784072102, 784066974, 784061896, 784056872, + 784051904, 784046997, 784042152, 784037374, 784032665, 784028028, 784023466, 784018982, 784014580, + 784010261, 784006029, 784001887, 783997837, 783993883, 783990026, 783986270, 783982617, 783979069, + 783975630, 783972302, 783969087, 783965987, 783963005, 783960143, 783957404, 783954788, 783952300, + 783949939, 783947709, 783945612, 783943648, 783941820, 783940130, 783938578, 783937167, 783935898, + 783934772, 783933790, 783932954, 783932264, 783931722, 783931328, 783931084, 783930989, 783931045, + 783931251, 783931609, 783932118, 783932779, 783933592, 783934556, 783935672, 783936938, 783938356, + 783939924, 783941641, 783943507, 783945521, 783947682, 783949989, 783952441, 783955036, 783957773, + 783960650, 783963666, 783966818, 783970106, 783973526, 783977077, 783980756, 783984561, 783988490, + 783992539, 783996706, 784000989, 784005383, 784009887, 784014497, 784019210, 784024022, 784028930, + 784033930, 784039019, 784044193, 784049448, 784054780, 784060186, 784065661, 784071201, 784076801, + 784082459, 784088168, 784093926, 784099727, 784105568, 784111443, 784117348, 784123278, 784129229, + 784135197, 784141176, 784147163, 784153152, 784159138, 784165118, 784171086, 784177037, 784182968, + 784188874, 784194749, 784200591, 784206393, 784212151, 784217862, 784223520, 784229122, 784234663, + 784240139, 784245546, 784250879, 784256136, 784261311, 784266402, 784271403, 784276313, 784281126, + 784285841, 784290452, 784294958, 784299354, 784303638, 784307807, 784311858, 784315788, 784319595, + 784323276, 784326828, 784330250, 784333539, 784336693, 784339710, 784342589, 784345327, 784347923, + 784350376, 784352685, 784354847, 784356862, 784358729, 784360447, 784362016, 784363434, 784364702, + 784365818, 784366783, 784367596, 784368257, 784368766, 784369124, 784369331, 784369387, 784369292, + 784369047, 784368653, 784368111, 784367421, 784366584, 784365602, 784364475, 784363205, 784361793, + 784360241, 784358550, 784356721, 784354756, 784352657, 784350426, 784348065, 784345575, 784342958, + 784340217, 784337354, 784334371, 784331270, 784328053, 784324723, 784321282, 784317734, 784314079, + 784310321, 784306463, 784302507, 784298456, 784294312, 784290078, 784285758, 784281354, 784276869, + 784272306, 784267667, 784262957, 784258177, 784253332, 784248423, 784243454, 784238429, 784233349, + 784228220, 784223043, 784217822, 784212560, 784207260, 784201926, 784196560, 784191167, 784185749, + 784180310, 784174852, 784169380, 784163896, 784158404, 784152907, -784147408, -784141911, -784136419, + -784130935, -784125463, -784120006, -784114567, -784109150, -784103757, -784098392, -784093059, -784087760, + -784082499, -784077278, -784072102, -784066974, -784061896, -784056872, -784051904, -784046997, -784042152, + -784037374, -784032665, -784028028, -784023466, -784018982, -784014580, -784010261, -784006029, -784001887, + -783997837, -783993883, -783990026, -783986270, -783982617, -783979069, -783975630, -783972302, -783969087, + -783965987, -783963005, -783960143, -783957404, -783954788, -783952300, -783949939, -783947709, -783945612, + -783943648, -783941820, -783940130, -783938578, -783937167, -783935898, -783934772, -783933790, -783932954, + -783932264, -783931722, -783931328, -783931084, -783930989, -783931045, -783931251, -783931609, -783932118, + -783932779, -783933592, -783934556, -783935672, -783936938, -783938356, -783939924, -783941641, -783943507, + -783945521, -783947682, -783949989, -783952441, -783955036, -783957773, -783960650, -783963666, -783966818, + -783970106, -783973526, -783977077, -783980756, -783984561, -783988490, -783992539, -783996706, -784000989, + -784005383, -784009887, -784014497, -784019210, -784024022, -784028930, -784033930, -784039019, -784044193, + -784049448, -784054780, -784060186, -784065661, -784071201, -784076801, -784082459, -784088168, -784093926, + -784099727, -784105568, -784111443, -784117348, -784123278, -784129229, -784135197, -784141176, -784147163, + -784153152, -784159138, -784165118, -784171086, -784177037, -784182968, -784188874, -784194749, -784200591, + -784206393, -784212151, -784217862, -784223520, -784229122, -784234663, -784240139, -784245546, -784250879, + -784256136, -784261311, -784266402, -784271403, -784276313, -784281126, -784285841, -784290452, -784294958, + -784299354, -784303638, -784307807, -784311858, -784315788, -784319595, -784323276, -784326828, -784330250, + -784333539, -784336693, -784339710, -784342589, -784345327, -784347923, -784350376, -784352685, -784354847, + -784356862, -784358729, -784360447, -784362016, -784363434, -784364702, -784365818, -784366783, -784367596, + -784368257, -784368766, -784369124, -784369331, -784369387, -784369292, -784369047, -784368653, -784368111, + -784367421, -784366584, -784365602, -784364475, -784363205, -784361793, -784360241, -784358550, -784356721, + -784354756, -784352657, -784350426, -784348065, -784345575, -784342958, -784340217, -784337354, -784334371, + -784331270, -784328053, -784324723, -784321282, -784317734, -784314079, -784310321, -784306463, -784302507, + -784298456, -784294312, -784290078, -784285758, -784281354, -784276869, -784272306, -784267667, -784262957, + -784258177, -784253332, -784248423, -784243454, -784238429, -784233349, -784228220, -784223043, -784217822, + -784212560, -784207260, -784201926, -784196560, -784191167, -784185749, -784180310, -784174852, -784169380, + -784163896, -784158404, -784152907, -784147408, -784141911, -784136419, -784130935, -784125463, -784120006, + -784114567, -784109150, -784103757, -784098392, -784093059, -784087760, -784082499, -784077278, -784072102, + -784066974, -784061896, -784056872, -784051904, -784046997, -784042152, -784037374, -784032665, -784028028, + -784023466, -784018982, -784014580, -784010261, -784006029, -784001887, -783997837, -783993883, -783990026, + -783986270, -783982617, -783979069, -783975630, -783972302, -783969087, -783965987, -783963005, -783960143, + -783957404, -783954788, -783952300, -783949939, -783947709, -783945612, -783943648, -783941820, -783940130, + -783938578, -783937167, -783935898, -783934772, -783933790, -783932954, -783932264, -783931722, -783931328, + -783931084, -783930989, -783931045, -783931251, -783931609, -783932118, -783932779, -783933592, -783934556, + -783935672, -783936938, -783938356, -783939924, -783941641, -783943507, -783945521, -783947682, -783949989, + -783952441, -783955036, -783957773, -783960650, -783963666, -783966818, -783970106, -783973526, -783977077, + -783980756, -783984561, -783988490, -783992539, -783996706, -784000989, -784005383, -784009887, -784014497, + -784019210, -784024022, -784028930, -784033930, -784039019, -784044193, -784049448, -784054780, -784060186, + -784065661, -784071201, -784076801, -784082459, -784088168, -784093926, -784099727, -784105568, -784111443, + -784117348, -784123278, -784129229, -784135197, -784141176, -784147163, -784153131, -784159068, -784164963, + -784170795, -784176541, -784182173, -784187657, -784192951, -784198007, -784202769, -784207169, -784211130, + -784214559, -784217353, -784219391, -784220535, -784220630, -784219497, -784216937, -784212727, -784206617, + -784198327, -784187551, -784173947, -784157141, -784136723, -784112243, -784083213, -784049101, -784009333, + -783963287, -783910294, -783849634, -783780538, -783702180, -783613679, -783514100, -783402445, -783277658, + -783138617, -782984141, -782812977, -782623808, -782415247, -782185834, -781934039, -781658253, -781356794, + -781027899, -780669728, -780280356, -779857776, -779399894, -778904531, -778369419, -777792197, -777170416, + -776501532, -775782908, -775011810, -774185411, -773300787, -772354919, -771344691, -770266894, -769118226, + -767895293, -766594614, -765212620, -763745664, -762190019, -760541889, -758797411, -756952664, -755003678, + -752946440, -750776904, -748491005, -746084664, -743553805, -740894366, -738102311, -735173645, -732104432, + -728890802, -725528974, -722015270, -718346128, -714518120, -710527972, -706372573, -702048997, -697554517, + -692886621, -688043026, -683021694, -677820848, -672438982, -666874876, -661127608, -655196568, -649081463, + -642782332, -636299553, -629633851, -622786302, -615758346, -608551783, -601168786, -593611894, -585884022, + -577988458, -569928861, -561709265, -553334069, -544808041, -536136306, -527324347, -518377994, -509303418, + -500107123, -490795932, -481376983, -471857712, -462245842, -452549370, -442776550, -432935882, -423036090, + -413086109, -403095064, -393072251, -383027119, -372969246, -362908319, -352854112, -342816459, -332805234, + -322830326, -312901609, -303028921, -293222034, -283490629, -273844269, -264292369, -254844170, -245508712, + -236294804, -227211000, -218265568, -209466468, -200821323, -192337394, -184021561, -175880295, -167919639, + -160145191, -152562081, -145174961, -137987988, -131004813, -124228572, -117661879, -111306824, -105164969, + -99237348, -93524475, -88026347, -82742454, -77671790, -72812867, -68163733, -63721988, -59484805, + -55448955, -51610827, -47966456, -44511550, -41241516, -38151492, -35236370, -32490831, -29909374, + -27486341, -25215951, -23092326, -21109518, -19261540, -17542387, -15946062, -14466601, -13098096, + -11834709, -10670701, -9600439, -8618419, -7719279, -6897809, -6148962, -5467868, -4849835, + -4290361, -3785136, -3330046, -2921175, -2554807, -2227423, -1935704, -1676526, -1446955, + -1244248, -1065844, -909363, -772594, -653495, -550182, -460924, -384136, -318370, + -262309, -214759, -174641, -140984, -112917, -89663, -70531, -54908, -42257, + -32104, -24037, -17698, -12781, -9020, -6190, -4103, -2600, -1548, + -839, -385, -115 }; +#endif /* ENABLE_HR_MODE */ + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA_2_5ms[2] = { LowDelayShapes_n960_N480_HRA_2_5ms_IP, + LowDelayShapes_n960_N960_HRA_2_5ms_IP }; + +RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA_5ms[2] = { LowDelayShapes_n960_N480_HRA_5ms_IP, + LowDelayShapes_n960_N960_HRA_5ms_IP }; + +RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA[2] = { LowDelayShapes_n960_N480_HRA_IP, + LowDelayShapes_n960_N960_HRA_IP }; + +# ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA_7_5ms[2] = { LowDelayShapes_n960_N480_HRA_7_5ms_IP, + LowDelayShapes_n960_N960_HRA_7_5ms_IP }; +# endif +#endif /* ENABLE_HR_MODE */ + +RAM_ALIGN const Word16 pitch_max[5] = {MAX_PITCH_8K, MAX_PITCH_16K, MAX_PITCH_24K, MAX_PITCH_32K, MAX_PITCH_48K}; +RAM_ALIGN const Word16 plc_preemph_fac[NUM_SAMP_FREQ] = {20316, 23592, 26869, 30146, 30146 +# ifdef ENABLE_HR_MODE + , 30146 +# endif + }; +/* high pass filter Q15 */ +RAM_ALIGN const Word16 TDC_high_16[11] = {(Word16)0x0000, (Word16)0xfd60, (Word16)0xf7ab, (Word16)0xefec, + (Word16)0xe910, (Word16)0x66c2, (Word16)0xe910, (Word16)0xefec, + (Word16)0xf7ab, (Word16)0xfd60, (Word16)0x0000}; + +RAM_ALIGN const Word16 TDC_high_32[11] = {(Word16)0xf962, (Word16)0xf87d, (Word16)0xf581, (Word16)0xf2e5, + (Word16)0xf11a, (Word16)0x7076, (Word16)0xf11a, (Word16)0xf2e5, + (Word16)0xf581, (Word16)0xf87d, (Word16)0xf962}; + +RAM_ALIGN const Word16 TDC_high_16_harm[11] = {(Word16) 174, (Word16) 0, (Word16) -1442, (Word16) 0, + (Word16) 8641, (Word16) 18022, (Word16) 8641, (Word16) 0, + (Word16) -1442, (Word16) 0, (Word16) 174}; + +RAM_ALIGN const Word16 TDC_high_32_harm[11] = {(Word16) -174, (Word16) -121, (Word16) -459, (Word16) 590, + (Word16) 8743, (Word16) 16355, (Word16) 8743, (Word16) 590, + (Word16) -459, (Word16) -121, (Word16) -174}; + + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 LowDelayShapes_n960_N80[130] = { + -15, -43, -94, -171, -277, -414, -580, -771, -981, -1201, -1423, -1638, -1836, + -2008, -2145, -2240, -2286, -2279, -2214, -2085, -1889, -1621, -1274, -842, -318, 305, + 1034, 1876, 2833, 3906, 5091, 6379, 7754, 9198, 10683, 12179, 13652, 15068, 16390, + 17588, 18634, 19509, 20201, 20712, 21051, 21237, 21297, 21263, 21168, 21044, 20918, 20797, + 20701, 20627, 20571, 20529, 20499, 20479, 20468, 20463, 20464, 20469, 20477, 20486, 20495, + 20503, 20509, 20514, 20516, 20518, 20520, 20524, 20530, 20540, 20556, 20576, 20602, 20633, + 20668, 20705, -20743, -20781, -20816, -20847, -20873, -20894, -20910, -20920, -20927, -20930, -20932, + -20934, -20937, -20942, -20948, -20956, -20966, -20975, -20982, -20988, -20989, -20984, -20972, -20952, + -20921, -20879, -20822, -20747, -20652, -20532, -20359, -20121, -19785, -19318, -18689, -17873, -16855, + -15636, -14231, -12670, -10997, -9266, -7542, -5889, -4373, -3051, -1965, -1136, -560, -207}; +#else +#define LowDelayShapes_n960_N80 NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 LowDelayShapes_n960_N160[260] = { + -14, -29, -49, -76, -112, -156, -210, -275, -350, -437, -534, -641, -759, -885, + -1020, -1163, -1311, -1464, -1620, -1777, -1935, -2090, -2242, -2390, -2530, -2661, -2783, -2893, + -2990, -3073, -3140, -3191, -3224, -3238, -3233, -3208, -3162, -3094, -3003, -2889, -2751, -2587, + -2397, -2180, -1935, -1661, -1355, -1018, -648, -244, 197, 674, 1190, 1745, 2340, 2976, + 3652, 4370, 5129, 5928, 6766, 7642, 8553, 9496, 10470, 11469, 12490, 13529, 14579, 15637, + 16696, 17750, 18792, 19817, 20819, 21791, 22727, 23621, 24469, 25264, 26004, 26685, 27304, 27858, + 28348, 28773, 29134, 29433, 29672, 29855, 29986, 30070, 30112, 30117, 30092, 30043, 29976, 29895, + 29807, 29716, 29632, 29536, 29451, 29374, 29307, 29247, 29195, 29149, 29109, 29075, 29045, 29020, + 28999, 28982, 28968, 28957, 28949, 28943, 28940, 28939, 28940, 28942, 28946, 28950, 28956, 28962, + 28968, 28975, 28981, 28987, 28993, 28998, 29002, 29006, 29009, 29012, 29014, 29015, 29017, 29018, + 29019, 29021, 29024, 29027, 29031, 29037, 29044, 29053, 29064, 29077, 29091, 29108, 29126, 29146, + 29168, 29192, 29216, 29242, 29268, 29295, -29322, -29349, -29376, -29401, -29426, -29450, -29472, -29492, + -29511, -29527, -29542, -29555, -29566, -29575, -29583, -29589, -29593, -29596, -29599, -29601, -29602, -29603, + -29605, -29606, -29608, -29611, -29614, -29618, -29623, -29628, -29634, -29640, -29646, -29653, -29660, -29666, + -29671, -29676, -29680, -29682, -29683, -29682, -29678, -29673, -29664, -29653, -29639, -29621, -29600, -29574, + -29544, -29509, -29469, -29423, -29370, -29310, -29243, -29167, -29083, -28988, -28861, -28718, -28551, -28351, + -28114, -27834, -27505, -27121, -26677, -26168, -25591, -24943, -24223, -23431, -22569, -21639, -20644, -19592, + -18487, -17338, -16154, -14944, -13719, -12491, -11270, -10068, -8898, -7771, -6698, -5689, -4753, -3898, + -3130, -2452, -1866, -1371, -964, -640, -392, -198}; +#else +#define LowDelayShapes_n960_N160 NULL +#endif +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 LowDelayShapes_n960_N240[390] = { + -9, -17, -26, -37, -50, -66, -86, -108, -134, -164, -197, -234, -275, -320, + -369, -422, -479, -539, -603, -670, -741, -814, -891, -969, -1050, -1132, -1216, -1301, + -1387, -1473, -1558, -1643, -1728, -1810, -1892, -1971, -2047, -2120, -2190, -2256, -2318, -2376, + -2429, -2477, -2519, -2556, -2586, -2611, -2629, -2640, -2645, -2642, -2632, -2614, -2589, -2556, + -2515, -2466, -2408, -2341, -2266, -2182, -2088, -1985, -1872, -1748, -1615, -1471, -1316, -1150, + -972, -783, -582, -368, -141, 99, 352, 619, 899, 1194, 1503, 1827, 2166, 2519, + 2888, 3271, 3669, 4082, 4510, 4952, 5408, 5878, 6362, 6857, 7365, 7885, 8414, 8954, + 9502, 10058, 10621, 11189, 11761, 12335, 12912, 13488, 14063, 14635, 15203, 15764, 16319, 16864, + 17399, 17922, 18431, 18926, 19405, 19866, 20309, 20732, 21135, 21517, 21876, 22213, 22526, 22817, + 23083, 23326, 23546, 23743, 23916, 24068, 24198, 24308, 24397, 24469, 24522, 24560, 24582, 24592, + 24589, 24575, 24552, 24522, 24485, 24443, 24398, 24349, 24300, 24252, 24209, 24155, 24104, 24058, + 24014, 23974, 23938, 23904, 23873, 23844, 23818, 23794, 23773, 23753, 23735, 23719, 23705, 23692, + 23681, 23670, 23662, 23654, 23647, 23642, 23638, 23634, 23632, 23630, 23629, 23629, 23629, 23630, + 23632, 23634, 23636, 23639, 23642, 23645, 23648, 23652, 23655, 23658, 23662, 23665, 23669, 23672, + 23674, 23677, 23680, 23682, 23684, 23686, 23687, 23688, 23689, 23690, 23691, 23692, 23693, 23693, + 23694, 23695, 23696, 23697, 23699, 23701, 23703, 23706, 23710, 23714, 23718, 23723, 23729, 23736, + 23743, 23751, 23760, 23769, 23779, 23790, 23801, 23813, 23825, 23838, 23851, 23865, 23879, 23894, + 23908, 23923, -23938, -23952, -23967, -23981, -23996, -24010, -24023, -24036, -24049, -24061, -24072, -24083, + -24093, -24102, -24111, -24119, -24127, -24133, -24139, -24145, -24149, -24153, -24157, -24160, -24162, -24164, + -24166, -24167, -24168, -24169, -24170, -24171, -24171, -24172, -24173, -24174, -24175, -24176, -24178, -24179, + -24181, -24184, -24186, -24189, -24192, -24195, -24198, -24202, -24205, -24209, -24213, -24216, -24219, -24223, + -24226, -24228, -24231, -24233, -24234, -24235, -24236, -24236, -24235, -24233, -24230, -24227, -24222, -24217, + -24210, -24202, -24193, -24183, -24171, -24158, -24143, -24127, -24109, -24089, -24067, -24043, -24017, -23988, + -23957, -23923, -23886, -23847, -23804, -23758, -23708, -23655, -23584, -23509, -23427, -23336, -23234, -23119, + -22990, -22846, -22685, -22506, -22307, -22087, -21845, -21580, -21291, -20977, -20638, -20272, -19880, -19462, + -19018, -18549, -18054, -17536, -16995, -16432, -15849, -15248, -14630, -13997, -13353, -12698, -12036, -11369, + -10700, -10032, -9367, -8709, -8059, -7422, -6800, -6196, -5611, -5050, -4513, -4004, -3523, -3073, + -2655, -2269, -1917, -1598, -1312, -1059, -837, -646, -484, -350, -239, -127}; +#else +#define LowDelayShapes_n960_N240 NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 LowDelayShapes_n960_N320[520] = { + -6, -12, -17, -23, -30, -39, -48, -60, -72, -86, -102, -119, -138, -159, + -182, -207, -234, -262, -293, -325, -359, -396, -434, -473, -515, -558, -603, -649, + -697, -746, -797, -848, -900, -954, -1008, -1062, -1118, -1173, -1229, -1285, -1340, -1396, + -1451, -1505, -1559, -1612, -1664, -1715, -1764, -1813, -1859, -1904, -1947, -1988, -2027, -2064, + -2098, -2130, -2159, -2186, -2210, -2230, -2248, -2263, -2275, -2283, -2289, -2290, -2289, -2283, + -2274, -2262, -2245, -2225, -2201, -2173, -2141, -2105, -2065, -2020, -1971, -1918, -1860, -1797, + -1730, -1658, -1582, -1500, -1414, -1322, -1225, -1122, -1014, -901, -782, -657, -526, -389, + -246, -97, 59, 221, 390, 565, 748, 937, 1133, 1336, 1547, 1764, 1989, 2221, + 2460, 2707, 2961, 3222, 3490, 3765, 4048, 4338, 4634, 4937, 5246, 5562, 5884, 6212, + 6546, 6885, 7229, 7578, 7932, 8289, 8650, 9014, 9382, 9751, 10123, 10496, 10870, 11244, + 11619, 11992, 12365, 12736, 13105, 13471, 13833, 14192, 14546, 14895, 15239, 15576, 15907, 16231, + 16547, 16856, 17155, 17446, 17727, 17999, 18261, 18512, 18753, 18983, 19202, 19409, 19605, 19790, + 19963, 20125, 20275, 20414, 20541, 20658, 20764, 20858, 20943, 21017, 21082, 21137, 21184, 21221, + 21251, 21273, 21287, 21295, 21297, 21293, 21285, 21271, 21254, 21233, 21209, 21182, 21154, 21124, + 21092, 21060, 21028, 20999, 20972, 20935, 20902, 20870, 20839, 20811, 20784, 20758, 20734, 20712, + 20691, 20671, 20653, 20635, 20619, 20604, 20590, 20577, 20565, 20554, 20543, 20534, 20525, 20517, + 20509, 20502, 20496, 20491, 20486, 20481, 20477, 20474, 20471, 20469, 20467, 20465, 20464, 20464, + 20463, 20463, 20463, 20464, 20465, 20466, 20467, 20468, 20470, 20472, 20474, 20476, 20478, 20480, + 20482, 20485, 20487, 20489, 20491, 20494, 20496, 20498, 20500, 20502, 20504, 20505, 20507, 20508, + 20510, 20511, 20512, 20513, 20514, 20515, 20516, 20516, 20517, 20517, 20518, 20518, 20519, 20519, + 20519, 20520, 20521, 20521, 20522, 20523, 20524, 20526, 20527, 20529, 20531, 20533, 20536, 20539, + 20542, 20546, 20549, 20554, 20558, 20563, 20568, 20573, 20579, 20586, 20592, 20599, 20606, 20613, + 20621, 20629, 20637, 20646, 20655, 20663, 20672, 20682, 20691, 20700, 20710, 20720, -20729, -20739, + -20748, -20758, -20767, -20776, -20785, -20794, -20803, -20812, -20820, -20828, -20836, -20843, -20851, -20857, + -20864, -20870, -20876, -20882, -20887, -20892, -20896, -20901, -20905, -20908, -20911, -20914, -20917, -20919, + -20921, -20923, -20925, -20926, -20927, -20928, -20929, -20930, -20931, -20931, -20932, -20932, -20933, -20933, + -20934, -20934, -20935, -20935, -20936, -20937, -20938, -20939, -20940, -20941, -20943, -20944, -20946, -20947, + -20949, -20951, -20953, -20955, -20958, -20960, -20962, -20964, -20967, -20969, -20971, -20974, -20976, -20978, + -20980, -20982, -20983, -20985, -20986, -20987, -20988, -20989, -20989, -20989, -20988, -20988, -20986, -20985, + -20983, -20980, -20978, -20974, -20970, -20966, -20961, -20955, -20949, -20942, -20934, -20926, -20917, -20907, + -20896, -20885, -20873, -20859, -20845, -20830, -20814, -20796, -20778, -20758, -20737, -20714, -20690, -20665, + -20638, -20610, -20580, -20548, -20515, -20480, -20433, -20384, -20333, -20279, -20220, -20155, -20085, -20008, + -19924, -19833, -19734, -19627, -19511, -19385, -19249, -19103, -18946, -18778, -18598, -18406, -18202, -17986, + -17757, -17515, -17260, -16993, -16713, -16421, -16116, -15799, -15470, -15129, -14778, -14415, -14043, -13661, + -13271, -12872, -12466, -12053, -11634, -11210, -10782, -10351, -9918, -9484, -9049, -8616, -8184, -7755, + -7330, -6910, -6496, -6090, -5691, -5301, -4922, -4553, -4196, -3852, -3521, -3204, -2902, -2615, + -2343, -2087, -1847, -1624, -1417, -1226, -1051, -892, -748, -619, -504, -404, -316, -241, + -175, -92}; +#else +#define LowDelayShapes_n960_N320 NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 LowDelayShapes_n960_N480[780] = { + -4, -8, -11, -13, -16, -20, -24, -28, -33, -38, -44, -50, -57, -64, + -72, -81, -90, -100, -110, -121, -133, -146, -159, -173, -187, -202, -218, -235, + -252, -270, -289, -308, -328, -349, -370, -392, -415, -438, -462, -486, -511, -537, + -563, -589, -616, -643, -671, -699, -728, -757, -786, -815, -845, -875, -905, -935, + -965, -996, -1026, -1056, -1087, -1117, -1147, -1177, -1207, -1236, -1266, -1295, -1323, -1352, + -1380, -1407, -1434, -1461, -1486, -1512, -1537, -1561, -1584, -1607, -1629, -1650, -1670, -1690, + -1709, -1726, -1743, -1759, -1774, -1788, -1801, -1813, -1824, -1834, -1842, -1850, -1856, -1861, + -1865, -1868, -1870, -1870, -1869, -1867, -1863, -1858, -1852, -1845, -1836, -1826, -1814, -1801, + -1786, -1770, -1753, -1734, -1713, -1691, -1668, -1643, -1616, -1588, -1558, -1527, -1494, -1459, + -1422, -1384, -1344, -1302, -1259, -1213, -1166, -1117, -1066, -1013, -959, -902, -843, -783, + -720, -655, -588, -519, -448, -374, -299, -221, -141, -58, 27, 114, 203, 295, + 389, 486, 585, 687, 791, 898, 1007, 1119, 1234, 1351, 1471, 1593, 1718, 1846, + 1976, 2109, 2244, 2382, 2523, 2667, 2813, 2961, 3113, 3266, 3423, 3582, 3743, 3907, + 4073, 4241, 4412, 4585, 4760, 4938, 5117, 5299, 5483, 5668, 5855, 6045, 6235, 6428, + 6622, 6817, 7013, 7211, 7410, 7610, 7811, 8012, 8215, 8417, 8621, 8824, 9028, 9232, + 9436, 9639, 9843, 10045, 10248, 10449, 10650, 10850, 11048, 11246, 11442, 11636, 11829, 12020, + 12209, 12396, 12581, 12763, 12944, 13121, 13296, 13468, 13638, 13804, 13967, 14127, 14284, 14437, + 14586, 14732, 14875, 15014, 15148, 15280, 15407, 15530, 15649, 15764, 15875, 15981, 16084, 16183, + 16277, 16367, 16453, 16535, 16612, 16686, 16755, 16821, 16882, 16940, 16993, 17043, 17089, 17131, + 17170, 17205, 17237, 17265, 17291, 17313, 17331, 17348, 17361, 17371, 17379, 17385, 17388, 17389, + 17388, 17385, 17380, 17374, 17366, 17356, 17345, 17333, 17320, 17306, 17292, 17276, 17260, 17243, + 17226, 17209, 17191, 17174, 17157, 17142, 17128, 17108, 17089, 17071, 17053, 17036, 17019, 17003, + 16988, 16973, 16959, 16946, 16933, 16920, 16908, 16897, 16886, 16875, 16865, 16856, 16846, 16838, + 16829, 16821, 16814, 16806, 16799, 16793, 16786, 16780, 16775, 16769, 16764, 16759, 16755, 16751, + 16747, 16743, 16739, 16736, 16733, 16730, 16727, 16725, 16722, 16720, 16718, 16717, 16715, 16714, + 16712, 16711, 16711, 16710, 16709, 16709, 16708, 16708, 16708, 16708, 16708, 16708, 16709, 16709, + 16710, 16710, 16711, 16712, 16713, 16714, 16715, 16716, 16717, 16718, 16719, 16720, 16721, 16722, + 16724, 16725, 16726, 16727, 16728, 16730, 16731, 16732, 16733, 16734, 16736, 16737, 16738, 16739, + 16740, 16741, 16742, 16743, 16744, 16744, 16745, 16746, 16747, 16747, 16748, 16748, 16749, 16750, + 16750, 16750, 16751, 16751, 16751, 16752, 16752, 16752, 16753, 16753, 16753, 16753, 16753, 16754, + 16754, 16754, 16755, 16755, 16755, 16756, 16756, 16757, 16757, 16758, 16759, 16759, 16760, 16761, + 16762, 16763, 16765, 16766, 16767, 16769, 16770, 16772, 16774, 16776, 16778, 16780, 16782, 16785, + 16787, 16790, 16793, 16796, 16799, 16802, 16805, 16809, 16812, 16816, 16820, 16824, 16828, 16832, + 16836, 16840, 16845, 16849, 16854, 16858, 16863, 16868, 16873, 16878, 16883, 16888, 16893, 16898, + 16903, 16908, 16914, 16919, -16924, -16929, -16934, -16940, -16945, -16950, -16955, -16960, -16965, -16970, + -16975, -16980, -16984, -16989, -16994, -16998, -17003, -17007, -17011, -17015, -17020, -17023, -17027, -17031, + -17035, -17038, -17041, -17045, -17048, -17051, -17053, -17056, -17059, -17061, -17064, -17066, -17068, -17070, + -17072, -17074, -17075, -17077, -17078, -17080, -17081, -17082, -17083, -17084, -17085, -17086, -17086, -17087, + -17088, -17088, -17089, -17089, -17089, -17090, -17090, -17090, -17091, -17091, -17091, -17091, -17092, -17092, + -17092, -17092, -17093, -17093, -17093, -17094, -17094, -17094, -17095, -17095, -17096, -17097, -17097, -17098, + -17099, -17099, -17100, -17101, -17102, -17103, -17104, -17105, -17106, -17107, -17108, -17109, -17110, -17111, + -17113, -17114, -17115, -17116, -17118, -17119, -17120, -17121, -17123, -17124, -17125, -17126, -17127, -17129, + -17130, -17131, -17132, -17133, -17133, -17134, -17135, -17136, -17136, -17137, -17137, -17137, -17137, -17137, + -17137, -17137, -17137, -17136, -17136, -17135, -17134, -17133, -17132, -17130, -17129, -17127, -17125, -17123, + -17120, -17118, -17115, -17112, -17109, -17105, -17102, -17098, -17094, -17089, -17085, -17080, -17075, -17069, + -17063, -17057, -17051, -17044, -17037, -17030, -17022, -17014, -17005, -16997, -16987, -16978, -16967, -16957, + -16946, -16934, -16922, -16910, -16897, -16883, -16869, -16855, -16840, -16824, -16808, -16791, -16773, -16755, + -16736, -16717, -16690, -16663, -16637, -16609, -16581, -16550, -16518, -16484, -16448, -16409, -16369, -16326, + -16280, -16232, -16181, -16127, -16070, -16010, -15947, -15880, -15810, -15736, -15658, -15577, -15491, -15402, + -15308, -15210, -15108, -15001, -14890, -14775, -14655, -14530, -14401, -14267, -14128, -13985, -13837, -13685, + -13528, -13367, -13201, -13030, -12855, -12676, -12493, -12306, -12114, -11919, -11720, -11517, -11311, -11102, + -10889, -10674, -10455, -10234, -10010, -9784, -9556, -9327, -9095, -8862, -8628, -8393, -8157, -7921, + -7684, -7448, -7211, -6976, -6741, -6507, -6274, -6042, -5813, -5585, -5360, -5137, -4917, -4700, + -4487, -4276, -4070, -3867, -3668, -3474, -3284, -3099, -2919, -2744, -2574, -2410, -2251, -2097, + -1949, -1807, -1671, -1540, -1415, -1297, -1184, -1077, -976, -881, -791, -707, -629, -556, + -489, -427, -369, -317, -269, -226, -188, -151, -114, -59}; +#else +#define LowDelayShapes_n960_N480 NULL +#endif + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 LowDelayShapes_n960_N40_5ms[70] = { + 29, 112, 280, 563, 991, 1590, 2380, 3377, 4587, 6006, 7624, 9416, 11353, 13393, + 15490, 17595, 19657, 21624, 23450, 25092, 26519, 27707, 28645, 29332, 29783, 30021, 30083, 30008, + 29840, 29625, 29408, 29214, 29077, 28993, 28956, 28961, 29000, 29068, 29156, 29256, -29361, -29462, + -29551, -29620, -29661, -29666, -29628, -29542, -29403, -29209, -28923, -28521, -27962, -27210, -26234, -25014, + -23541, -21819, -19874, -17743, -15481, -13149, -10820, -8571, -6479, -4611, -3020, -1753, -842, -284}; +#else +#define LowDelayShapes_n960_N40_5ms NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 LowDelayShapes_n960_N80_5ms[140] = { + 13, 31, 60, 102, 161, 239, 339, 464, 615, 795, 1006, 1251, 1530, 1845, + 2198, 2588, 3015, 3481, 3983, 4520, 5092, 5697, 6331, 6992, 7677, 8382, 9104, 9838, + 10580, 11326, 12071, 12811, 13540, 14255, 14951, 15624, 16270, 16885, 17466, 18010, 18515, 18978, + 19399, 19775, 20106, 20393, 20636, 20836, 20995, 21115, 21199, 21250, 21271, 21266, 21239, 21194, + 21134, 21064, 20987, 20908, 20836, 20757, 20688, 20630, 20581, 20542, 20513, 20491, 20478, 20473, + 20475, 20483, 20497, 20517, 20541, 20568, 20600, 20633, 20669, 20706, -20743, -20780, -20816, -20850, + -20881, -20910, -20934, -20954, -20968, -20977, -20979, -20973, -20960, -20938, -20908, -20868, -20819, -20761, + -20692, -20613, -20508, -20389, -20248, -20080, -19883, -19653, -19387, -19083, -18738, -18351, -17920, -17444, + -16923, -16358, -15749, -15099, -14410, -13687, -12933, -12154, -11353, -10537, -9712, -8884, -8060, -7246, + -6450, -5679, -4938, -4235, -3574, -2959, -2397, -1889, -1441, -1055, -732, -474, -277, -138}; +#else +#define LowDelayShapes_n960_N80_5ms NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 LowDelayShapes_n960_N120_5ms[210] = { + 9, 17, 28, 44, 65, 91, 123, 161, 208, 262, 325, 398, 480, 572, + 676, 791, 918, 1057, 1209, 1374, 1552, 1744, 1950, 2169, 2402, 2648, 2908, 3181, + 3468, 3767, 4078, 4402, 4736, 5081, 5437, 5801, 6174, 6554, 6942, 7335, 7732, 8134, + 8538, 8943, 9349, 9755, 10159, 10560, 10957, 11349, 11735, 12114, 12485, 12846, 13198, 13539, + 13868, 14184, 14487, 14776, 15051, 15311, 15555, 15784, 15997, 16194, 16374, 16538, 16686, 16818, + 16935, 17036, 17123, 17195, 17254, 17299, 17333, 17355, 17366, 17368, 17361, 17347, 17325, 17297, + 17265, 17228, 17189, 17147, 17104, 17061, 17024, 16979, 16938, 16901, 16867, 16837, 16811, 16788, + 16768, 16752, 16739, 16729, 16722, 16718, 16716, 16717, 16720, 16726, 16734, 16743, 16755, 16768, + 16782, 16798, 16815, 16833, 16852, 16871, 16891, 16911, -16931, -16952, -16972, -16991, -17010, -17028, + -17045, -17061, -17076, -17090, -17101, -17111, -17119, -17125, -17128, -17129, -17127, -17123, -17116, -17106, + -17092, -17076, -17056, -17033, -17006, -16976, -16942, -16905, -16864, -16820, -16760, -16698, -16630, -16553, + -16467, -16370, -16263, -16144, -16013, -15868, -15710, -15537, -15349, -15146, -14927, -14693, -14442, -14175, + -13891, -13591, -13276, -12944, -12597, -12236, -11862, -11474, -11074, -10664, -10244, -9816, -9380, -8938, + -8492, -8043, -7592, -7141, -6692, -6247, -5807, -5374, -4949, -4534, -4131, -3741, -3365, -3005, + -2662, -2337, -2030, -1744, -1478, -1234, -1012, -814, -638, -486, -357, -250, -164, -95}; +#else +#define LowDelayShapes_n960_N120_5ms NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 LowDelayShapes_n960_N160_5ms[280] = { + 13, 23, 36, 52, 73, 98, 128, 163, 205, 253, 308, 371, 441, 520, + 608, 705, 812, 929, 1056, 1195, 1344, 1505, 1678, 1863, 2060, 2270, 2493, 2729, + 2978, 3241, 3516, 3805, 4108, 4424, 4753, 5095, 5450, 5818, 6198, 6591, 6995, 7411, + 7839, 8277, 8725, 9184, 9651, 10128, 10612, 11104, 11603, 12108, 12618, 13133, 13653, 14175, + 14700, 15226, 15754, 16281, 16808, 17334, 17857, 18376, 18892, 19403, 19909, 20408, 20901, 21385, + 21861, 22328, 22784, 23231, 23666, 24089, 24500, 24898, 25283, 25654, 26011, 26354, 26681, 26994, + 27291, 27572, 27838, 28089, 28323, 28541, 28744, 28931, 29103, 29259, 29401, 29528, 29640, 29738, + 29823, 29895, 29955, 30002, 30038, 30063, 30078, 30083, 30080, 30068, 30049, 30023, 29991, 29953, + 29911, 29865, 29815, 29763, 29708, 29653, 29597, 29541, 29496, 29437, 29381, 29329, 29280, 29235, + 29194, 29156, 29122, 29091, 29064, 29039, 29018, 29000, 28986, 28974, 28964, 28958, 28954, 28953, + 28954, 28958, 28964, 28972, 28982, 28994, 29007, 29023, 29040, 29058, 29078, 29099, 29121, 29144, + 29168, 29192, 29218, 29243, 29269, 29295, -29322, -29348, -29374, -29400, -29425, -29450, -29474, -29498, + -29520, -29541, -29561, -29580, -29597, -29613, -29627, -29639, -29649, -29657, -29663, -29667, -29668, -29667, + -29663, -29657, -29647, -29635, -29620, -29602, -29580, -29556, -29528, -29496, -29462, -29424, -29382, -29337, + -29288, -29236, -29181, -29122, -29041, -28964, -28880, -28788, -28688, -28579, -28460, -28332, -28193, -28042, + -27879, -27705, -27517, -27315, -27100, -26871, -26627, -26369, -26095, -25806, -25501, -25180, -24844, -24492, + -24123, -23739, -23339, -22924, -22493, -22048, -21588, -21114, -20627, -20128, -19616, -19094, -18561, -18018, + -17467, -16907, -16341, -15769, -15192, -14611, -14028, -13442, -12857, -12272, -11689, -11109, -10533, -9963, + -9400, -8846, -8300, -7765, -7241, -6730, -6232, -5749, -5282, -4830, -4396, -3979, -3581, -3202, + -2843, -2505, -2188, -1893, -1620, -1369, -1141, -936, -753, -593, -454, -336, -237, -155}; +#else +#define LowDelayShapes_n960_N160_5ms NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 LowDelayShapes_n960_N240_5ms[420] = { + 10, 15, 21, 27, 36, 45, 56, 69, 83, 100, 118, 138, 161, 186, + 214, 244, 276, 312, 350, 392, 436, 484, 535, 590, 648, 710, 775, 845, + 918, 995, 1076, 1162, 1252, 1346, 1444, 1547, 1655, 1767, 1883, 2005, 2131, 2261, + 2397, 2537, 2683, 2833, 2988, 3148, 3312, 3482, 3656, 3835, 4019, 4208, 4401, 4599, + 4801, 5008, 5220, 5436, 5656, 5880, 6109, 6342, 6578, 6818, 7063, 7310, 7562, 7816, + 8074, 8335, 8598, 8865, 9134, 9405, 9679, 9955, 10233, 10513, 10794, 11076, 11360, 11645, + 11931, 12217, 12504, 12791, 13078, 13366, 13652, 13939, 14224, 14509, 14792, 15075, 15356, 15635, + 15912, 16187, 16460, 16731, 16999, 17264, 17526, 17785, 18041, 18293, 18542, 18787, 19028, 19264, + 19497, 19725, 19949, 20168, 20382, 20592, 20796, 20996, 21190, 21379, 21563, 21741, 21914, 22082, + 22243, 22399, 22550, 22695, 22834, 22967, 23095, 23216, 23332, 23443, 23548, 23647, 23740, 23828, + 23910, 23987, 24059, 24125, 24186, 24243, 24294, 24340, 24381, 24418, 24450, 24478, 24502, 24522, + 24537, 24549, 24557, 24562, 24563, 24561, 24556, 24549, 24538, 24525, 24510, 24492, 24473, 24451, + 24428, 24404, 24378, 24351, 24323, 24294, 24264, 24234, 24204, 24173, 24143, 24112, 24093, 24059, + 24027, 23997, 23968, 23940, 23914, 23889, 23865, 23842, 23821, 23801, 23783, 23765, 23749, 23734, + 23720, 23708, 23696, 23686, 23677, 23668, 23661, 23655, 23650, 23647, 23644, 23641, 23640, 23640, + 23641, 23642, 23645, 23648, 23652, 23657, 23662, 23668, 23675, 23682, 23691, 23699, 23708, 23718, + 23728, 23739, 23750, 23762, 23774, 23786, 23799, 23812, 23825, 23839, 23853, 23866, 23881, 23895, + 23909, 23923, -23938, -23952, -23966, -23980, -23994, -24008, -24022, -24036, -24049, -24062, -24075, -24088, + -24100, -24112, -24123, -24134, -24144, -24154, -24164, -24173, -24181, -24189, -24195, -24202, -24207, -24212, + -24216, -24219, -24222, -24223, -24224, -24224, -24223, -24221, -24218, -24214, -24208, -24202, -24195, -24187, + -24177, -24167, -24155, -24142, -24128, -24113, -24097, -24079, -24060, -24040, -24019, -23996, -23972, -23947, + -23921, -23893, -23864, -23834, -23802, -23769, -23721, -23681, -23638, -23592, -23543, -23492, -23438, -23380, + -23319, -23255, -23186, -23115, -23039, -22959, -22875, -22786, -22693, -22596, -22494, -22387, -22275, -22157, + -22035, -21908, -21775, -21637, -21494, -21345, -21190, -21030, -20864, -20692, -20515, -20332, -20143, -19948, + -19748, -19541, -19329, -19112, -18888, -18659, -18425, -18185, -17940, -17690, -17434, -17174, -16909, -16639, + -16365, -16087, -15804, -15518, -15228, -14934, -14637, -14337, -14034, -13728, -13420, -13109, -12797, -12483, + -12167, -11851, -11533, -11215, -10896, -10577, -10258, -9940, -9623, -9307, -8992, -8678, -8367, -8058, + -7752, -7448, -7148, -6851, -6557, -6268, -5983, -5702, -5426, -5156, -4890, -4630, -4375, -4126, + -3884, -3647, -3417, -3194, -2977, -2767, -2565, -2369, -2181, -2001, -1829, -1664, -1507, -1358, + -1218, -1085, -961, -846, -738, -639, -547, -464, -388, -320, -259, -206, -159, -124}; +#else +#define LowDelayShapes_n960_N240_5ms NULL +#endif + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 LowDelayShapes_n960_N40_2_5ms[40] = { + 140, 566, 1277, 2319, 3704, 5404, 7357, 9466, 11616, 13686, 15563, 17163, 18436, 19375, + 20007, 20391, 20594, 20685, 20717, 20724, -20724, -20717, -20685, -20594, -20391, -20007, -19375, -18436, + -17163, -15563, -13686, -11616, -9466, -7357, -5404, -3704, -2319, -1277, -566, -140}; +#else +#define LowDelayShapes_n960_N40_2_5ms NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 LowDelayShapes_n960_N80_2_5ms[80] = { + 140, 353, 653, 1049, 1553, 2171, 2909, 3768, 4747, 5842, 7043, 8341, 9721, 11165, + 12655, 14170, 15688, 17188, 18649, 20051, 21376, 22610, 23739, 24756, 25656, 26436, 27099, 27650, + 28097, 28450, 28721, 28922, 29065, 29164, 29228, 29267, 29290, 29301, 29306, 29308, -29308, -29306, + -29301, -29290, -29267, -29228, -29164, -29065, -28922, -28721, -28450, -28097, -27650, -27099, -26436, -25656, + -24756, -23739, -22610, -21376, -20051, -18649, -17188, -15688, -14170, -12655, -11165, -9721, -8341, -7043, + -5842, -4747, -3768, -2909, -2171, -1553, -1049, -653, -353, -140}; +#else +#define LowDelayShapes_n960_N80_2_5ms NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 LowDelayShapes_n960_N120_2_5ms[120] = { + 93, 196, 328, 491, 689, 924, 1199, 1514, 1873, 2274, 2720, 3209, 3742, 4318, + 4934, 5588, 6277, 7000, 7750, 8526, 9321, 10132, 10953, 11780, 12606, 13427, 14237, 15032, + 15807, 16557, 17278, 17967, 18620, 19234, 19809, 20341, 20830, 21276, 21680, 22040, 22360, 22641, + 22884, 23092, 23269, 23416, 23538, 23636, 23714, 23775, 23822, 23857, 23882, 23900, 23913, 23920, + 23925, 23928, 23930, 23930, -23930, -23930, -23928, -23925, -23920, -23913, -23900, -23882, -23857, -23822, + -23775, -23714, -23636, -23538, -23416, -23269, -23092, -22884, -22641, -22360, -22040, -21680, -21276, -20830, + -20341, -19809, -19234, -18620, -17967, -17278, -16557, -15807, -15032, -14237, -13427, -12606, -11780, -10953, + -10132, -9321, -8526, -7750, -7000, -6277, -5588, -4934, -4318, -3742, -3209, -2720, -2274, -1873, + -1514, -1199, -924, -689, -491, -328, -196, -93}; +#else +#define LowDelayShapes_n960_N120_2_5ms NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 LowDelayShapes_n960_N160_2_5ms[160] = { + 70, 134, 210, 301, 407, 530, 671, 830, 1008, 1206, 1425, 1665, 1926, 2208, + 2512, 2837, 3183, 3550, 3937, 4343, 4768, 5211, 5670, 6143, 6631, 7131, 7642, 8161, + 8688, 9219, 9755, 10292, 10828, 11363, 11893, 12417, 12933, 13440, 13936, 14418, 14887, 15339, + 15775, 16193, 16593, 16972, 17332, 17670, 17988, 18285, 18561, 18816, 19050, 19264, 19459, 19635, + 19793, 19934, 20059, 20168, 20264, 20347, 20418, 20478, 20529, 20572, 20606, 20635, 20657, 20675, + 20689, 20700, 20708, 20713, 20718, 20720, 20722, 20723, 20724, 20724, -20724, -20724, -20723, -20722, + -20720, -20718, -20713, -20708, -20700, -20689, -20675, -20657, -20635, -20606, -20572, -20529, -20478, -20418, + -20347, -20264, -20168, -20059, -19934, -19793, -19635, -19459, -19264, -19050, -18816, -18561, -18285, -17988, + -17670, -17332, -16972, -16593, -16193, -15775, -15339, -14887, -14418, -13936, -13440, -12933, -12417, -11893, + -11363, -10828, -10292, -9755, -9219, -8688, -8161, -7642, -7131, -6631, -6143, -5670, -5211, -4768, + -4343, -3937, -3550, -3183, -2837, -2512, -2208, -1926, -1665, -1425, -1206, -1008, -830, -671, + -530, -407, -301, -210, -134, -70}; +#else +#define LowDelayShapes_n960_N160_2_5ms NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 LowDelayShapes_n960_N240_2_5ms[240] = { + 47, 81, 118, 160, 207, 259, 317, 381, 452, 528, 611, 701, 799, 903, + 1015, 1134, 1260, 1395, 1537, 1686, 1844, 2009, 2183, 2363, 2552, 2748, 2951, 3162, + 3380, 3604, 3836, 4073, 4317, 4567, 4822, 5083, 5348, 5618, 5892, 6170, 6451, 6735, + 7022, 7311, 7601, 7892, 8185, 8477, 8769, 9060, 9350, 9639, 9926, 10209, 10491, 10768, + 11042, 11312, 11577, 11837, 12092, 12341, 12585, 12822, 13053, 13277, 13494, 13705, 13908, 14103, + 14291, 14472, 14645, 14810, 14968, 15118, 15261, 15396, 15523, 15643, 15756, 15862, 15961, 16054, + 16140, 16220, 16293, 16361, 16424, 16481, 16533, 16580, 16623, 16662, 16697, 16728, 16755, 16780, + 16802, 16821, 16837, 16851, 16864, 16874, 16883, 16891, 16897, 16902, 16907, 16910, 16913, 16915, + 16917, 16918, 16919, 16920, 16921, 16921, 16921, 16921, -16921, -16921, -16921, -16921, -16920, -16919, + -16918, -16917, -16915, -16913, -16910, -16907, -16902, -16897, -16891, -16883, -16874, -16864, -16851, -16837, + -16821, -16802, -16780, -16755, -16728, -16697, -16662, -16623, -16580, -16533, -16481, -16424, -16361, -16293, + -16220, -16140, -16054, -15961, -15862, -15756, -15643, -15523, -15396, -15261, -15118, -14968, -14810, -14645, + -14472, -14291, -14103, -13908, -13705, -13494, -13277, -13053, -12822, -12585, -12341, -12092, -11837, -11577, + -11312, -11042, -10768, -10491, -10209, -9926, -9639, -9350, -9060, -8769, -8477, -8185, -7892, -7601, + -7311, -7022, -6735, -6451, -6170, -5892, -5618, -5348, -5083, -4822, -4567, -4317, -4073, -3836, + -3604, -3380, -3162, -2951, -2748, -2552, -2363, -2183, -2009, -1844, -1686, -1537, -1395, -1260, + -1134, -1015, -903, -799, -701, -611, -528, -452, -381, -317, -259, -207, -160, -118, + -81, -47}; +#else +#define LowDelayShapes_n960_N240_2_5ms NULL +#endif + + +#ifdef SUBSET_NB +RAM_ALIGN const Word32 lag_win_8k[16] = {0x7fdba30b, 0x7f6eca1a, 0x7eba2e4e, 0x7dbf01e8, 0x7c7eecec, 0x7afc0879, + 0x7938d8eb, 0x773846e0, 0x74fd973a, 0x728c623e, 0x6fe889ee, 0x6d162fc8, + 0x6a19aa0b, 0x66f778a7, 0x63b43a09, 0x60549fe1}; +#else +#define lag_win_8k NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word32 lag_win_16k[16] = {0x7ff6e7cb, 0x7fdba30b, 0x7fae3d5f, 0x7f6eca1a, 0x7f1d643a, 0x7eba2e4e, + 0x7e455264, 0x7dbf01e8, 0x7d277581, 0x7c7eecec, 0x7bc5aecb, 0x7afc0879, + 0x7a224dcf, 0x7938d8eb, 0x784009f7, 0x773846e0}; +#else +#define lag_win_16k NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word32 lag_win_24k[16] = {0x7ffbf529, 0x7fefd569, 0x7fdba30b, 0x7fbf61e2, 0x7f9b1748, 0x7f6eca1a, + 0x7f3a82b8, 0x7efe4b00, 0x7eba2e4e, 0x7e6e3976, 0x7e1a7ac1, 0x7dbf01e8, + 0x7d5be00f, 0x7cf127c2, 0x7c7eecec, 0x7c0544d0}; +#else +#define lag_win_24k NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word32 lag_win_32k[16] = {0x7ffdb9e3, 0x7ff6e7cb, 0x7feb8a70, 0x7fdba30b, 0x7fc7334b, 0x7fae3d5f, + 0x7f90c3ed, 0x7f6eca1a, 0x7f485382, 0x7f1d643a, 0x7eee00d1, 0x7eba2e4e, + 0x7e81f22e, 0x7e455264, 0x7e045558, 0x7dbf01e8}; +#else +#define lag_win_32k NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word32 lag_win_48k[16] = {0x7ffefd47, 0x7ffbf529, 0x7ff6e7cb, 0x7fefd569, 0x7fe6be59, 0x7fdba30b, + 0x7fce8403, 0x7fbf61e2, 0x7fae3d5f, 0x7f9b1748, 0x7f85f087, 0x7f6eca1a, + 0x7f55a51b, 0x7f3a82b8, 0x7f1d643a, 0x7efe4b00}; +#else +#define lag_win_48k NULL +#endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 lag_win_96k[16] = {0x7fffbf52, 0x7ffefd47, 0x7ffdb9e3, 0x7ffbf529, 0x7ff9af1f, 0x7ff6e7cb, + 0x7ff39f35, 0x7fefd569, 0x7feb8a70, 0x7fe6be59, 0x7fe17132, 0x7fdba30b, + 0x7fd553f5, 0x7fce8403, 0x7fc7334b, 0x7fbf61e2}; +# else +# define lag_win_96k NULL +# endif + +RAM_ALIGN const Word32 *const lag_win[NUM_SAMP_FREQ] = {lag_win_8k, lag_win_16k, lag_win_24k, lag_win_32k, lag_win_48k, lag_win_96k}; + +RAM_ALIGN const Word16 sqrt_table_phecu[49] = {/* used by Sqrt_l */ + 16384, 16888, 17378, 17854, 18318, 18770, 19212, 19644, 20066, 20480, + 20886, 21283, 21674, 22058, 22435, 22806, 23170, 23530, 23884, 24232, + 24576, 24915, 25249, 25580, 25905, 26227, 26545, 26859, 27170, 27477, + 27780, 28081, 28378, 28672, 28963, 29251, 29537, 29819, 30099, 30377, + 30652, 30924, 31194, 31462, 31727, 31991, 32252, 32511, 32767}; + +/* First frequency bin in each subband now adjusted to include last bin * + * which was missed with the previous definition * + * 250 750 1250 2250 4250 8250 12250 16250 20250 ( 24250 ) * + * note that bins over 20000 are zeroed and not used */ +/* [- FB ----------------------------) (Currently limited to 20kHz) + * [- SWB -----------------------) + * [- sWB -------------------) + * [- WB ----------------) + * [- NB -----------) + */ + +RAM_ALIGN const Word16 gw_len_inv_shift_fx[MAX_LGW] = {/* Q0 */ + 1 - 1 /*/1/2*/, 1 - 1, 2 - 1 /*1/4*/, + 3 - 1 /*1/8*/, 4 - 1 /*1/16*/, 4 - 1, + 4 - 1, 4 - 1, 4 - 1}; +RAM_ALIGN const Word16 gwlpr_fx[MAX_LGW + 1] = { + 1, + 3 * QUOT_LPR_LTR, + 5 * QUOT_LPR_LTR, + 9 * QUOT_LPR_LTR, + 17 * QUOT_LPR_LTR, + 33 * QUOT_LPR_LTR, + 49 * QUOT_LPR_LTR, + 65 * QUOT_LPR_LTR, + 81 * QUOT_LPR_LTR, + 97 * QUOT_LPR_LTR}; /* frequency group start bins for transient analysis */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING + /* puretone_ana compressed ATH bandborder weights */ +RAM_ALIGN const Word16 scATHFx[MAX_LGW - 2] = { 14924 , 30499 , 31886 , 32767 , 29770 , 25417 , 16384 }; + /* 0.455444335937500 0.930755615234375 0.973083496093750 0.999969482421875 0.908508300781250 0.775665283203125 0.5*/ +#endif + +RAM_ALIGN const Word16 e_tot_headroom[5] = {3, 3, 4, 4, 4}; /* smallest head room to use for each fs */ + + + +RAM_ALIGN const Word16 xfp_wE_MDCT2FFTQ11[5] = {4077, 8283, 12489, 16698, + 25109}; /* Q11 Mantissa of scale to use for each fs */ + +RAM_ALIGN const Word16 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, 20675, 19745, 18856, 18007, 17197, 16423, + 8211, 4106, 2053, 1026, 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, 0}; +RAM_ALIGN const Word16 POW_ATT_TABLE1[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, 23198, 22410, 21650, 20915, 20205, 19519, + 9759, 4880, 2440, 1220, 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, 0}; + +#ifdef PLC2_FADEOUT_IN_MS +#if PLC2_FADEOUT_IN_MS == 0 +#ifndef CR8_A_PLC_FADEOUT_TUNING +/*/ default setting only requieres two tables */ +RAM_ALIGN const Word16 *const POW_ATT_TABLES[1 + 2] = { + NULL, + POW_ATT_TABLE1 /*1 0.3dB steps */, + POW_ATT_TABLE0 /*2 0.4 dB steps*/, +}; +#endif + +#else /* PLC2_FADEOUT_IN_MS == 0 */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING +RAM_ALIGN const Word16 POW_ATT_TABLE_p3x9_14_7[OFF_FRAMES_LIMIT + 1] = { + 32767, + 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, /* 9 times .3dB steps , 14 6 dB steps, 7 muted steps */ + 12007, 6003, 3002, 1501, 750, 375, 188, 94, 47, 23, 12, 6, 3, 1, + 0, 0, 0, 0, 0, 0, 0 }; + +RAM_ALIGN const Word16 POW_ATT_TABLE_p4x9_14_7[OFF_FRAMES_LIMIT + 1] = +{ 32767, + 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, /* 9 times .4dB steps , 14 6 dB steps, 7 muted steps */ + 10825, 5413, 2706, 1353, 677, 338, 169, 85, 42, 21, 11, 5, 3, 1, + 0, 0,0,0,0,0,0 }; +#endif + +RAM_ALIGN const Word16 POW_ATT_TABLE_p3x8_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, 3216, 1608, 804, 402, 201, 101, + 50, 25, 13, 6, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0}; +RAM_ALIGN const Word16 POW_ATT_TABLE_p4x8_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 11869, 5935, 2967, 1484, 742, 371, 185, 93, + 46, 23, 12, 6, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0}; + +RAM_ALIGN const Word16 POW_ATT_TABLE_p3x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 30581, 29543, 14772, 7386, 3693, 1847, 923, 462, 231, 115, 58, 29, 14, 7, + 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +RAM_ALIGN const Word16 POW_ATT_TABLE_p4x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 14270, 7135, 3568, 1784, 892, 446, 223, 111, 56, 28, 14, 7, + 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +RAM_ALIGN const Word16 POW_ATT_TABLE_p3x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 15828, 7914, 3957, 1979, 989, 495, 247, 124, 62, 31, 15, 8, 4, 2, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +RAM_ALIGN const Word16 POW_ATT_TABLE_p4x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 15647, 7823, 3912, 1956, 978, 489, 244, 122, 61, 31, 15, 8, 4, 2, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +RAM_ALIGN const Word16 POW_ATT_TABLE_p3x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +RAM_ALIGN const Word16 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +#ifdef CR8_A_PLC_FADEOUT_TUNING +/* POW_ATT_TABLES now ordered logically based on initial slow muting phase time */ +/* POW_ATT_TABLES[ind] is used after teh initial gain==1.0 no energy muting phase */ +RAM_ALIGN const Word16 *const POW_ATT_TABLES[1 + 24 / 2] = +{ NULL, +/*0.3dB col , 0.4dB col */ +/* 1*/POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6, /* 0 0.3dB, 16 6dB, 14mute */ /* 0.4dB version */ /* old short mute tabs */ +/* 3*/POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* 1 0.3dB, 15 6dB ,14mute */ /* 0.4dB version */ +/* 5*/POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* 3 0.3dB, 15 6dB , 12 mute */ /* 0.4dB version */ +/* 7*/POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* 7 0.3dB, 15 6dB , 8 mute */ /* 0.4dB version */ +/* 9*/POW_ATT_TABLE_p3x9_14_7, POW_ATT_TABLE_p4x9_14_7, /* 9 0.3dB, 14 6dB , 7 mute */ /* 0.4dB version */ /* opt 120 ms */ +/*11*/POW_ATT_TABLE1, POW_ATT_TABLE0, /* 15 0.3dB, 14 6dB , 1 mute */ /* 0.4dB version */ /* 3GPP original/default curves */ +}; + +/* PLC_FADEOUT_TUNING, extended table nominal muting phases from 30 ms to 140 ms */ +RAM_ALIGN const Word16 fade_scheme_tab_fx[24 / 2][3] = { +/* burst_att_thresh indicates when muting POW_ATT_TABLE[att_per_frame_idx] should be used first time it is 1.0 though */ +/* burst_att_thresh ==2 --> gains [ 1.0, 32767/32768.0(first table value used) , first muted, .... ]*/ +/* burst_att_thresh ==5 --> gains [ 1.0, 1.0, 1,0 1,0, 32767/32768.0(first table value used) , first muted,... ]*/ +/* beta_mute_thr ==4 --> start of final attenuation attenuate AvgMix */ + +/* tabled {att_per_frame_idx_p3dB , burst_att_thresh, beta_mute_thr } */ +{ 1, 2, 0 + 2 + 2 }, /* 30 ms, 0.3 dB delta att in slow mutephase nominal_fadeout=0 */ +{ 1, 3, 0 + 3 + 2 }, /* 40 ms, 0.3 dB delta att in slow mutephase */ +{ 3, 3, 1 + 3 + 1 }, /* 50 ms, 0.3 dB delta att in slow mutephase */ +{ 3, 4, 1 + 4 + 1}, /* 60 ms, 0.3 dB delta att in slow mutephase */ +{ 5, 4, 3 + 4 + 1 }, /* 70 ms, 0.3 dB delta att in slow mutephase */ +{ 5, 5, 3 + 5 + 1 }, /* 80 ms, 0.3 dB delta att in slow mutephase */ +{ 7, 5, 7 + 5 }, /* 90 ms, 0.3 dB delta att in slow mutephase */ +{ 7, 5, 7 + 5 + 1}, /* 100 ms, 0.3 dB delta att in slow mutephase */ +{ 9, 5, 9 + 5 }, /* 110 ms, 0.3 dB delta att in slow mutephase */ +{ 9, 5, 9 + 5 + 1}, /* 120 ms, 0.3 dB delta att in slow mutephase nominal_fadeout=1 */ +{ 11, 5, 15 + 5 },/* 130 ms, 0.3 dB delta att in slow mutephase */ +{ 11, 6, 15 + 6 },/* 140 ms, 0.3 dB delta att in slow mutephase nominal 3GPP */ +}; +/*fade_scheme_tab_fx[ind][0] att_per _fram_index , "points" to first column in POW_ATT TABLES */ +/*fade_scheme_tab_fx[ind][1] is burst_att_thresh, the number of non_muted 1.0 gain frames */ +/*fade_scheme_tab_fx[ind][2] is beta_mute_thr, the location of the start of final attenuation */ + +#else +RAM_ALIGN const Word16 *const POW_ATT_TABLES[1 + 10] = { + NULL, + POW_ATT_TABLE1, + POW_ATT_TABLE0, + /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */ + POW_ATT_TABLE_p3x8_6, + POW_ATT_TABLE_p4x8_6, + /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */ + POW_ATT_TABLE_p3x4_6, + POW_ATT_TABLE_p4x4_6, + /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */ + POW_ATT_TABLE_p3x2_6, + POW_ATT_TABLE_p4x2_6, + /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ + POW_ATT_TABLE_p3x1_6, + POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ +}; +#endif + +#endif /* PLC2_FADEOUT_IN_MS == 0 */ + +#else /* PLC2_FADEOUT_IN_MS */ +RAM_ALIGN const Word16 *const POW_ATT_TABLES[1 + 2] = { + NULL, + POW_ATT_TABLE1 /*1 .3dB steps */, + POW_ATT_TABLE0 /*2 .4 dB steps*/, +}; +#endif /* PLC2_FADEOUT_IN_MS */ + +RAM_ALIGN const Word16 sin_quarterQ15_fx[256 + 1] = { + 0, 201, 402, 603, 804, 1005, 1206, 1407, 1608, 1809, 2009, 2210, 2411, 2611, 2811, 3012, + 3212, 3412, 3612, 3812, 4011, 4211, 4410, 4609, 4808, 5007, 5205, 5404, 5602, 5800, 5998, 6195, + 6393, 6590, 6787, 6983, 7180, 7376, 7571, 7767, 7962, 8157, 8351, 8546, 8740, 8933, 9127, 9319, + 9512, 9704, 9896, 10088, 10279, 10469, 10660, 10850, 11039, 11228, 11417, 11605, 11793, 11980, 12167, 12354, + 12540, 12725, 12910, 13095, 13279, 13463, 13646, 13828, 14010, 14192, 14373, 14553, 14733, 14912, 15091, 15269, + 15447, 15624, 15800, 15976, 16151, 16326, 16500, 16673, 16846, 17018, 17190, 17361, 17531, 17700, 17869, 18037, + 18205, 18372, 18538, 18703, 18868, 19032, 19195, 19358, 19520, 19681, 19841, 20001, 20160, 20318, 20475, 20632, + 20788, 20943, 21097, 21251, 21403, 21555, 21706, 21856, 22006, 22154, 22302, 22449, 22595, 22740, 22884, 23028, + 23170, 23312, 23453, 23593, 23732, 23870, 24008, 24144, 24279, 24414, 24548, 24680, 24812, 24943, 25073, 25202, + 25330, 25457, 25583, 25708, 25833, 25956, 26078, 26199, 26320, 26439, 26557, 26674, 26791, 26906, 27020, 27133, + 27246, 27357, 27467, 27576, 27684, 27791, 27897, 28002, 28106, 28209, 28311, 28411, 28511, 28610, 28707, 28803, + 28899, 28993, 29086, 29178, 29269, 29359, 29448, 29535, 29622, 29707, 29792, 29875, 29957, 30038, 30118, 30196, + 30274, 30350, 30425, 30499, 30572, 30644, 30715, 30784, 30853, 30920, 30986, 31050, 31114, 31177, 31238, 31298, + 31357, 31415, 31471, 31527, 31581, 31634, 31686, 31737, 31786, 31834, 31881, 31927, 31972, 32015, 32058, 32099, + 32138, 32177, 32214, 32251, 32286, 32319, 32352, 32383, 32413, 32442, 32470, 32496, 32522, 32546, 32568, 32590, + 32610, 32629, 32647, 32664, 32679, 32693, 32706, 32718, 32729, 32738, 32746, 32753, 32758, 32762, 32766, 32767, + 32767}; + +/* 16 ms tables for PHECU fft windowing and post ifft preTda MDCT windowing (window 11) */ +/* 3+3ms tapering for the hamming parts */ +/* temporary ROM solution */ +/* alternatively use values from a single 48 kHz table */ + +/* 3ms rising tapering part @48 kHZ */ +/* only quarter sine hamming part is actually used by the C-function windowing_fx */ +/* OPT: store only one table at 48 or 96 kHz */ +/* OPT2: for this to work one must switch to 'periodic' instead of used 'symetric' windows, * + * the different windows are just sub-sampled windows of a 96kHz window */ + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 PhECU_whr16ms_NB_Q15[Lprot_hamm_len2_8k] = {/* From matlab */ + 2621, 2750, 3135, 3769, 4641, 5736, + 7036, 8519, 10158, 11926, 13793, 15727, + 17695, 19662, 21596, 23463, 25231, 26871, + 28353, 29653, 30749, 31621, 32254, 32639}; +#else +#define PhECU_whr16ms_NB_Q15 NULL +#endif +#ifdef SUBSET_WB +RAM_ALIGN const Word16 PhECU_whr16ms_WB_Q15[Lprot_hamm_len2_16k] = {/* From matlab */ + 2621, 2654, 2750, 2911, 3135, 3421, 3769, + 4176, 4641, 5162, 5736, 6362, 7036, 7756, + 8519, 9320, 10158, 11028, 11926, 12850, 13793, + 14754, 15727, 16709, 17695, 18681, 19662, 20635, + 21596, 22540, 23463, 24361, 25231, 26069, 26871, + 27633, 28353, 29027, 29653, 30228, 30749, 31214, + 31621, 31968, 32254, 32478, 32639, 32736}; +#else +#define PhECU_whr16ms_WB_Q15 NULL +#endif +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 PhECU_whr16ms_sWB_Q15[Lprot_hamm_len2_24k] = + {/* From matlab */ + 2621, 2636, 2679, 2750, 2850, 2979, 3135, 3319, 3530, 3769, 4034, 4325, 4641, 4982, 5347, + 5736, 6148, 6582, 7036, 7511, 8006, 8519, 9049, 9596, 10158, 10735, 11324, 11926, 12539, 13162, + 13793, 14432, 15077, 15727, 16381, 17037, 17695, 18352, 19008, 19662, 20312, 20957, 21596, 22227, 22850, + 23463, 24065, 24655, 25231, 25794, 26340, 26871, 27384, 27878, 28353, 28808, 29242, 29653, 30042, 30407, + 30749, 31065, 31356, 31621, 31859, 32070, 32254, 32411, 32539, 32639, 32711, 32754}; +#else +#define PhECU_whr16ms_sWB_Q15 NULL +#endif +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 PhECU_whr16ms_SWB_Q15[Lprot_hamm_len2_32k] = + {/* From matlab */ + 2621, 2630, 2654, 2694, 2750, 2823, 2911, 3015, 3135, 3270, 3421, 3588, 3769, 3965, 4176, 4401, + 4641, 4894, 5162, 5442, 5736, 6043, 6362, 6693, 7036, 7391, 7756, 8132, 8519, 8915, 9320, 9735, + 10158, 10589, 11028, 11474, 11926, 12385, 12850, 13319, 13793, 14272, 14754, 15239, 15727, 16217, 16709, 17202, + 17695, 18188, 18681, 19172, 19662, 20150, 20635, 21118, 21596, 22070, 22540, 23004, 23463, 23916, 24361, 24800, + 25231, 25654, 26069, 26475, 26871, 27257, 27633, 27999, 28353, 28696, 29027, 29347, 29653, 29947, 30228, 30495, + 30749, 30988, 31214, 31424, 31621, 31802, 31968, 32119, 32254, 32374, 32478, 32567, 32639, 32695, 32736, 32760}; +#else +#define PhECU_whr16ms_SWB_Q15 NULL +#endif +#ifdef SUBSET_FB +RAM_ALIGN const Word16 PhECU_whr16ms_FB_Q15[Lprot_hamm_len2_48k] = + {/* From matlab */ + 2621, 2625, 2636, 2654, 2679, 2711, 2750, 2797, 2850, 2911, 2979, 3053, 3135, 3224, 3319, 3421, + 3530, 3646, 3769, 3898, 4034, 4176, 4325, 4480, 4641, 4808, 4982, 5162, 5347, 5539, 5736, 5939, + 6148, 6362, 6582, 6806, 7036, 7271, 7511, 7756, 8006, 8260, 8519, 8782, 9049, 9320, 9596, 9875, + 10158, 10445, 10735, 11028, 11324, 11624, 11926, 12232, 12539, 12850, 13162, 13477, 13793, 14112, 14432, 14754, + 15077, 15402, 15727, 16054, 16381, 16709, 17037, 17366, 17695, 18024, 18352, 18681, 19008, 19336, 19662, 19988, + 20312, 20635, 20957, 21277, 21596, 21913, 22227, 22540, 22850, 23158, 23463, 23765, 24065, 24361, 24655, 24945, + 25231, 25514, 25794, 26069, 26340, 26608, 26871, 27129, 27384, 27633, 27878, 28118, 28353, 28583, 28808, 29027, + 29242, 29450, 29653, 29850, 30042, 30228, 30407, 30581, 30749, 30910, 31065, 31214, 31356, 31491, 31621, 31743, + 31859, 31968, 32070, 32166, 32254, 32336, 32411, 32478, 32539, 32593, 32639, 32678, 32711, 32736, 32754, 32764}; +#else +#define PhECU_whr16ms_FB_Q15 NULL +#endif + +/* initial 2ms for preTda is the LD-MDCT analysis window times the centered inverse whr window */ +#ifdef SUBSET_NB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_128_pre_Q14[16] = {-12, -34, -74, -135, -219, -327, -459, -610, + -776, -949, -1125, -1295, -1451, -1587, -1696, -1771}; +#else +#define PhECU_preTdaFx16ms_128_pre_Q14 NULL +#endif +#ifdef SUBSET_WB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_256_pre_Q14[32] = { + -8, -16, -27, -42, -63, -87, -117, -154, -196, -244, -299, -358, -424, -495, -570, -650, + -733, -818, -906, -993, -1082, -1168, -1253, -1336, -1414, -1488, -1556, -1617, -1671, -1718, -1755, -1784}; +#else +#define PhECU_preTdaFx16ms_256_pre_Q14 NULL +#endif +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_384_pre_Q14[48] = { + -6, -12, -18, -25, -34, -45, -59, -74, -92, -112, -135, -160, -188, -219, -253, -289, + -328, -369, -413, -459, -507, -557, -610, -663, -719, -775, -833, -891, -950, -1008, -1067, -1125, + -1183, -1239, -1295, -1349, -1401, -1451, -1499, -1545, -1587, -1627, -1663, -1696, -1725, -1750, -1771, -1788}; +#else +#define PhECU_preTdaFx16ms_384_pre_Q14 NULL +#endif +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_512_pre_Q14[64] = { + -5, -9, -13, -18, -24, -31, -38, -47, -57, -68, -81, -94, -109, -126, -144, -164, + -185, -207, -232, -257, -284, -313, -343, -374, -407, -441, -477, -513, -551, -590, -630, -670, + -712, -754, -797, -840, -884, -927, -972, -1016, -1059, -1104, -1147, -1190, -1232, -1274, -1316, -1356, + -1395, -1433, -1470, -1505, -1539, -1572, -1602, -1632, -1659, -1684, -1707, -1728, -1747, -1763, -1777, -1789}; +#else +#define PhECU_preTdaFx16ms_512_pre_Q14 NULL +#endif +#ifdef SUBSET_FB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_768_pre_Q14[96] = { + -4, -8, -11, -13, -15, -19, -23, -27, -32, -37, -43, -48, -55, -62, -70, -78, + -87, -97, -107, -117, -129, -141, -154, -168, -181, -196, -211, -228, -244, -261, -280, -298, + -318, -338, -358, -380, -402, -424, -447, -471, -495, -520, -545, -570, -596, -623, -650, -677, + -705, -733, -761, -789, -818, -847, -876, -905, -934, -964, -993, -1022, -1052, -1082, -1111, -1140, + -1169, -1197, -1226, -1254, -1281, -1309, -1336, -1362, -1388, -1415, -1439, -1464, -1488, -1511, -1534, -1556, + -1577, -1598, -1617, -1636, -1655, -1671, -1688, -1703, -1718, -1731, -1744, -1755, -1766, -1776, -1784, -1791}; +#else +#define PhECU_preTdaFx16ms_768_pre_Q14 NULL +#endif + +/* ROM OPT compute it runtime based on MDCT win and tabled inverse hamming sections */ +/* 16 ms tables for PHECU fft windowing and post ifft preTda MDCT windowing */ +/* OPT2 can be reduced to 14.25 ms, due to 1.75 ms trailing zeroes */ +#ifdef SUBSET_NB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_NB_Q14[128] = { + -22591, -21465, -18295, -14331, -10544, -7321, -4690, -2561, -811, 662, 1942, 3090, 4148, 5146, 6107, 7043, + 7961, 8868, 9761, 10640, 11502, 12345, 13164, 13959, 14731, 15423, 15970, 16374, 16642, 16789, 16837, 16810, + 16735, 16637, 16537, 16441, 16366, 16307, 16263, 16230, 16206, 16190, 16181, 16177, 16178, 16182, 16188, 16196, + 16203, 16209, 16214, 16218, 16219, 16221, 16222, 16226, 16230, 16238, 16251, 16267, 16287, 16312, 16339, 16369, + 16399, 16429, 16456, 16481, 16502, 16518, 16531, 16539, 16544, 16547, 16548, 16550, 16552, 16556, 16561, 16567, + 16575, 16582, 16588, 16592, 16593, 16589, 16580, 16564, 16540, 16506, 16461, 16402, 16327, 16232, 16095, 15907, + 15641, 15272, 14775, 14130, 13325, 12361, 11251, 10017, 8694, 7354, 6057, 4825, 3684, 2665, 1795, 1095, + 575, 229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#else +#define PhECU_preTdaFx16ms_NB_Q14 NULL +#endif +#ifdef SUBSET_WB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_WB_Q14[256] = { + -22528, -22351, -21532, -20186, -18475, -16565, -14596, -12673, -10858, -9181, -7654, -6277, -5037, -3923, -2914, + -2001, -1169, -405, 303, 961, 1580, 2166, 2725, 3263, 3781, 4285, 4778, 5262, 5739, 6211, + 6677, 7140, 7601, 8059, 8514, 8968, 9419, 9868, 10314, 10756, 11195, 11630, 12060, 12486, 12907, + 13322, 13733, 14137, 14537, 14917, 15263, 15573, 15847, 16085, 16286, 16454, 16587, 16689, 16763, 16810, + 16833, 16836, 16822, 16795, 16757, 16712, 16663, 16612, 16565, 16511, 16464, 16421, 16383, 16350, 16321, + 16295, 16272, 16253, 16237, 16223, 16211, 16201, 16194, 16187, 16183, 16180, 16178, 16177, 16178, 16179, + 16181, 16184, 16187, 16190, 16194, 16198, 16201, 16204, 16208, 16210, 16213, 16215, 16217, 16218, 16219, + 16220, 16221, 16222, 16222, 16223, 16225, 16227, 16229, 16232, 16236, 16241, 16247, 16255, 16262, 16272, + 16282, 16293, 16305, 16319, 16332, 16347, 16361, 16376, 16391, 16407, 16422, 16436, 16450, 16463, 16475, + 16487, 16497, 16506, 16514, 16522, 16528, 16533, 16537, 16541, 16543, 16545, 16546, 16547, 16548, 16549, + 16550, 16550, 16551, 16553, 16555, 16557, 16560, 16563, 16566, 16569, 16573, 16577, 16580, 16584, 16587, + 16589, 16592, 16593, 16593, 16593, 16591, 16588, 16583, 16577, 16569, 16559, 16547, 16532, 16516, 16496, + 16474, 16448, 16418, 16385, 16347, 16305, 16258, 16205, 16134, 16054, 15960, 15849, 15716, 15560, 15376, + 15161, 14913, 14628, 14306, 13944, 13541, 13098, 12616, 12097, 11540, 10952, 10335, 9692, 9030, 8362, + 7699, 7045, 6400, 5769, 5155, 4560, 3990, 3448, 2936, 2460, 2022, 1625, 1272, 963, 700, + 481, 306, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0}; +#else +#define PhECU_preTdaFx16ms_WB_Q14 NULL +#endif +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_sWB_Q14[384] = { + -22499, -22471, -22152, -21551, -20715, -19688, -18527, -17277, -15982, -14679, -13393, -12145, -10954, -9826, + -8760, -7763, -6831, -5958, -5149, -4394, -3688, -3029, -2410, -1831, -1285, -769, -279, 186, + 630, 1055, 1462, 1856, 2236, 2606, 2966, 3317, 3662, 3999, 4330, 4658, 4981, 5301, + 5618, 5933, 6246, 6556, 6866, 7175, 7481, 7788, 8093, 8398, 8702, 9004, 9306, 9606, + 9906, 10205, 10502, 10798, 11092, 11385, 11676, 11965, 12252, 12537, 12820, 13101, 13379, 13655, + 13929, 14200, 14470, 14732, 14977, 15208, 15422, 15622, 15804, 15970, 16121, 16256, 16374, 16478, + 16567, 16643, 16703, 16753, 16789, 16815, 16830, 16837, 16835, 16825, 16810, 16789, 16764, 16735, + 16704, 16671, 16637, 16604, 16575, 16538, 16503, 16471, 16441, 16414, 16389, 16366, 16345, 16325, + 16307, 16291, 16276, 16263, 16250, 16239, 16230, 16221, 16213, 16206, 16200, 16195, 16190, 16187, + 16184, 16181, 16180, 16178, 16178, 16178, 16178, 16178, 16180, 16181, 16182, 16185, 16187, 16189, + 16191, 16193, 16195, 16198, 16200, 16202, 16205, 16207, 16208, 16211, 16213, 16214, 16215, 16217, + 16217, 16218, 16219, 16219, 16220, 16221, 16221, 16221, 16222, 16223, 16224, 16224, 16226, 16227, + 16228, 16230, 16233, 16236, 16239, 16242, 16246, 16251, 16256, 16261, 16267, 16274, 16280, 16288, + 16295, 16304, 16312, 16321, 16330, 16339, 16349, 16359, 16369, 16379, 16389, 16399, 16409, 16419, + 16429, 16439, 16447, 16456, 16465, 16473, 16481, 16489, 16495, 16502, 16508, 16513, 16519, 16523, + 16527, 16531, 16534, 16536, 16539, 16541, 16543, 16544, 16545, 16546, 16547, 16547, 16548, 16549, + 16549, 16549, 16550, 16551, 16551, 16552, 16554, 16554, 16556, 16558, 16559, 16561, 16563, 16565, + 16567, 16570, 16572, 16575, 16578, 16580, 16582, 16584, 16586, 16588, 16590, 16591, 16592, 16593, + 16593, 16593, 16593, 16591, 16589, 16587, 16584, 16580, 16575, 16570, 16564, 16557, 16549, 16540, + 16530, 16519, 16506, 16493, 16478, 16461, 16443, 16423, 16402, 16379, 16354, 16327, 16297, 16266, + 16232, 16195, 16147, 16096, 16039, 15977, 15907, 15828, 15740, 15642, 15531, 15409, 15273, 15122, + 14956, 14775, 14577, 14362, 14130, 13879, 13611, 13325, 13021, 12700, 12361, 12006, 11636, 11250, + 10851, 10440, 10016, 9583, 9142, 8698, 8255, 7815, 7377, 6944, 6515, 6092, 5675, 5266, + 4865, 4475, 4094, 3726, 3370, 3029, 2703, 2393, 2101, 1826, 1571, 1334, 1117, 921, + 744, 588, 451, 335, 235, 128, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0}; +#else +#define PhECU_preTdaFx16ms_sWB_Q14 NULL +#endif +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_SWB_Q14[512] = { + -22482, -22492, -22345, -22020, -21560, -20952, -20236, -19434, -18551, -17624, -16665, -15691, -14716, -13753, + -12810, -11889, -11002, -10152, -9335, -8553, -7813, -7108, -6442, -5806, -5206, -4634, -4091, -3574, + -3084, -2618, -2173, -1748, -1341, -952, -578, -219, 128, 462, 786, 1099, 1405, 1701, + 1989, 2271, 2548, 2818, 3084, 3345, 3601, 3856, 4106, 4354, 4598, 4840, 5082, 5322, + 5559, 5795, 6029, 6263, 6496, 6729, 6961, 7192, 7422, 7652, 7882, 8111, 8339, 8567, + 8795, 9022, 9249, 9475, 9701, 9926, 10151, 10374, 10597, 10819, 11041, 11261, 11481, 11699, + 11917, 12133, 12349, 12563, 12776, 12988, 13198, 13408, 13616, 13823, 14028, 14233, 14437, 14635, + 14826, 15007, 15181, 15344, 15499, 15645, 15782, 15910, 16029, 16139, 16239, 16332, 16415, 16490, + 16557, 16615, 16667, 16710, 16747, 16777, 16800, 16818, 16829, 16835, 16837, 16834, 16827, 16816, + 16803, 16786, 16767, 16746, 16724, 16700, 16675, 16649, 16624, 16601, 16580, 16551, 16524, 16499, + 16475, 16453, 16431, 16411, 16392, 16374, 16358, 16342, 16328, 16313, 16301, 16289, 16278, 16268, + 16258, 16249, 16241, 16234, 16226, 16220, 16214, 16208, 16204, 16200, 16196, 16192, 16188, 16186, + 16184, 16182, 16181, 16179, 16178, 16178, 16177, 16177, 16177, 16178, 16179, 16180, 16181, 16181, + 16183, 16185, 16186, 16188, 16189, 16191, 16192, 16195, 16196, 16198, 16200, 16202, 16204, 16205, + 16207, 16208, 16210, 16211, 16212, 16213, 16215, 16215, 16216, 16217, 16218, 16219, 16219, 16219, + 16220, 16220, 16221, 16221, 16222, 16222, 16222, 16222, 16223, 16223, 16224, 16225, 16226, 16227, + 16228, 16230, 16231, 16233, 16235, 16238, 16240, 16243, 16245, 16249, 16253, 16256, 16260, 16264, + 16269, 16275, 16279, 16285, 16290, 16296, 16302, 16309, 16315, 16322, 16329, 16336, 16343, 16351, + 16358, 16365, 16373, 16381, 16388, 16396, 16403, 16411, 16418, 16425, 16432, 16439, 16446, 16453, + 16460, 16466, 16472, 16478, 16484, 16489, 16494, 16499, 16504, 16509, 16513, 16517, 16520, 16524, + 16527, 16529, 16532, 16534, 16536, 16538, 16540, 16541, 16543, 16543, 16544, 16545, 16546, 16547, + 16547, 16547, 16548, 16548, 16549, 16549, 16550, 16550, 16551, 16551, 16551, 16552, 16553, 16554, + 16555, 16555, 16557, 16558, 16559, 16560, 16562, 16563, 16565, 16566, 16569, 16570, 16572, 16573, + 16576, 16577, 16579, 16581, 16583, 16585, 16586, 16588, 16589, 16590, 16591, 16592, 16592, 16593, + 16593, 16593, 16592, 16592, 16591, 16590, 16589, 16586, 16585, 16581, 16578, 16575, 16571, 16566, + 16562, 16556, 16550, 16543, 16536, 16528, 16520, 16511, 16502, 16490, 16479, 16468, 16455, 16441, + 16426, 16411, 16394, 16376, 16357, 16337, 16316, 16294, 16270, 16245, 16219, 16191, 16154, 16115, + 16075, 16032, 15985, 15934, 15879, 15818, 15751, 15679, 15601, 15517, 15425, 15325, 15218, 15102, + 14978, 14845, 14703, 14551, 14390, 14219, 14038, 13847, 13645, 13434, 13213, 12982, 12741, 12490, + 12230, 11961, 11683, 11396, 11102, 10800, 10492, 10176, 9855, 9529, 9197, 8864, 8532, 8201, + 7872, 7544, 7218, 6894, 6573, 6255, 5940, 5629, 5322, 5020, 4723, 4432, 4147, 3868, + 3596, 3332, 3076, 2828, 2590, 2361, 2141, 1931, 1732, 1543, 1366, 1200, 1044, 901, + 768, 647, 536, 438, 349, 271, 201, 108, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0}; +#else +#define PhECU_preTdaFx16ms_SWB_Q14 NULL +#endif +#ifdef SUBSET_FB +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_FB_Q14[768] = { + -22463, -22493, -22449, -22334, -22148, -21885, -21560, -21179, -20737, -20250, -19726, -19171, -18581, -17972, + -17340, -16701, -16050, -15401, -14757, -14114, -13474, -12848, -12237, -11637, -11048, -10478, -9922, -9386, + -8864, -8357, -7865, -7393, -6936, -6493, -6069, -5654, -5258, -4874, -4503, -4144, -3801, -3465, + -3140, -2829, -2524, -2230, -1944, -1667, -1399, -1136, -884, -636, -395, -158, 72, 296, + 514, 728, 938, 1144, 1346, 1545, 1739, 1931, 2119, 2305, 2489, 2670, 2849, 3025, + 3199, 3373, 3543, 3713, 3879, 4046, 4211, 4376, 4539, 4700, 4862, 5022, 5182, 5341, + 5499, 5657, 5814, 5970, 6126, 6282, 6437, 6592, 6746, 6901, 7056, 7209, 7362, 7517, + 7669, 7823, 7976, 8129, 8281, 8433, 8585, 8738, 8890, 9040, 9193, 9343, 9495, 9645, + 9796, 9946, 10096, 10245, 10395, 10543, 10693, 10841, 10989, 11137, 11284, 11431, 11578, 11723, + 11869, 12014, 12159, 12303, 12446, 12589, 12733, 12874, 13016, 13157, 13298, 13438, 13577, 13716, + 13855, 13992, 14129, 14266, 14403, 14537, 14667, 14795, 14918, 15037, 15152, 15263, 15371, 15474, + 15573, 15669, 15760, 15847, 15931, 16010, 16084, 16156, 16223, 16287, 16346, 16402, 16453, 16502, + 16546, 16587, 16625, 16659, 16690, 16717, 16742, 16763, 16781, 16797, 16810, 16819, 16827, 16833, + 16836, 16837, 16836, 16833, 16828, 16822, 16815, 16805, 16794, 16783, 16770, 16756, 16743, 16727, + 16712, 16695, 16679, 16663, 16645, 16629, 16612, 16598, 16584, 16565, 16546, 16529, 16511, 16495, + 16479, 16463, 16449, 16434, 16420, 16408, 16395, 16383, 16371, 16360, 16350, 16339, 16329, 16321, + 16311, 16303, 16295, 16287, 16280, 16272, 16266, 16260, 16253, 16247, 16242, 16237, 16232, 16227, + 16223, 16219, 16215, 16211, 16207, 16205, 16202, 16199, 16196, 16194, 16191, 16189, 16187, 16186, + 16184, 16183, 16181, 16180, 16180, 16179, 16178, 16178, 16177, 16177, 16177, 16177, 16177, 16177, + 16178, 16178, 16179, 16179, 16180, 16181, 16182, 16183, 16184, 16185, 16186, 16187, 16188, 16189, + 16190, 16191, 16193, 16194, 16195, 16196, 16197, 16199, 16200, 16201, 16202, 16203, 16205, 16206, + 16206, 16207, 16208, 16209, 16210, 16211, 16212, 16212, 16213, 16214, 16215, 16215, 16216, 16216, + 16217, 16218, 16218, 16218, 16219, 16219, 16219, 16220, 16220, 16220, 16221, 16221, 16221, 16221, + 16221, 16222, 16222, 16222, 16223, 16223, 16223, 16224, 16224, 16225, 16225, 16226, 16227, 16227, + 16228, 16229, 16230, 16231, 16233, 16234, 16235, 16237, 16237, 16239, 16241, 16243, 16245, 16247, + 16249, 16252, 16254, 16257, 16260, 16263, 16266, 16268, 16271, 16275, 16278, 16282, 16286, 16290, + 16294, 16298, 16301, 16305, 16310, 16314, 16319, 16323, 16328, 16332, 16337, 16342, 16347, 16352, + 16357, 16361, 16366, 16371, 16377, 16382, 16387, 16391, 16396, 16402, 16407, 16412, 16417, 16421, + 16426, 16431, 16436, 16441, 16445, 16450, 16454, 16458, 16463, 16467, 16471, 16475, 16480, 16482, + 16486, 16490, 16494, 16497, 16500, 16504, 16507, 16510, 16511, 16514, 16517, 16519, 16522, 16524, + 16526, 16528, 16530, 16532, 16533, 16535, 16536, 16538, 16539, 16540, 16541, 16542, 16542, 16543, + 16543, 16544, 16545, 16545, 16546, 16546, 16546, 16547, 16547, 16547, 16548, 16548, 16548, 16548, + 16549, 16549, 16549, 16549, 16550, 16550, 16550, 16551, 16551, 16551, 16552, 16552, 16553, 16554, + 16554, 16555, 16556, 16556, 16557, 16558, 16559, 16560, 16561, 16562, 16563, 16564, 16565, 16566, + 16567, 16568, 16570, 16571, 16572, 16572, 16574, 16575, 16576, 16577, 16579, 16580, 16581, 16582, + 16583, 16585, 16586, 16587, 16588, 16589, 16589, 16590, 16591, 16592, 16592, 16593, 16593, 16593, + 16593, 16593, 16593, 16593, 16593, 16592, 16592, 16591, 16590, 16589, 16588, 16586, 16585, 16583, + 16581, 16579, 16576, 16574, 16572, 16569, 16566, 16562, 16559, 16555, 16551, 16546, 16542, 16538, + 16533, 16527, 16521, 16515, 16510, 16503, 16496, 16489, 16481, 16474, 16465, 16457, 16448, 16439, + 16428, 16419, 16408, 16396, 16385, 16373, 16360, 16347, 16333, 16320, 16305, 16290, 16274, 16258, + 16240, 16223, 16205, 16186, 16160, 16134, 16109, 16082, 16054, 16024, 15993, 15961, 15926, 15888, + 15849, 15808, 15763, 15717, 15667, 15615, 15560, 15502, 15441, 15376, 15308, 15236, 15161, 15082, + 14999, 14913, 14822, 14727, 14628, 14525, 14417, 14306, 14190, 14069, 13944, 13814, 13679, 13541, + 13398, 13250, 13098, 12943, 12782, 12616, 12447, 12273, 12096, 11915, 11729, 11541, 11348, 11151, + 10952, 10749, 10543, 10335, 10123, 9909, 9692, 9473, 9253, 9032, 8810, 8589, 8369, 8149, + 7929, 7711, 7492, 7276, 7059, 6845, 6631, 6418, 6207, 5997, 5789, 5582, 5378, 5175, + 4975, 4777, 4583, 4389, 4200, 4012, 3827, 3646, 3468, 3294, 3123, 2956, 2793, 2634, + 2479, 2328, 2181, 2039, 1902, 1768, 1639, 1517, 1398, 1284, 1176, 1072, 973, 879, + 791, 707, 629, 556, 486, 423, 364, 310, 261, 213, 163, 85, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#else +#define PhECU_preTdaFx16ms_FB_Q14 NULL +#endif + +RAM_ALIGN const Word16 *const PhECU_wins[5][3] = { + /* 3ms hamm(left part) , 16ms(center IWHR(periodic)*MDCT-anaQ14) , 2ms(initial MDCT-ana in Q14) */ + /*8 kHz*/ {PhECU_whr16ms_NB_Q15, PhECU_preTdaFx16ms_NB_Q14, PhECU_preTdaFx16ms_128_pre_Q14}, + /*16 kHz*/ {PhECU_whr16ms_WB_Q15, PhECU_preTdaFx16ms_WB_Q14, PhECU_preTdaFx16ms_256_pre_Q14}, + /*24 kHz*/ {PhECU_whr16ms_sWB_Q15, PhECU_preTdaFx16ms_sWB_Q14, PhECU_preTdaFx16ms_384_pre_Q14}, + /*32 kHz*/ {PhECU_whr16ms_SWB_Q15, PhECU_preTdaFx16ms_SWB_Q14, PhECU_preTdaFx16ms_512_pre_Q14}, + /*48 kHz*/ {PhECU_whr16ms_FB_Q15, PhECU_preTdaFx16ms_FB_Q14, PhECU_preTdaFx16ms_768_pre_Q14}}; + +/* x=(0:(5*8-1))*(2*pi)/32; y=sin(x);y_int=max(-32768,min(32767,round(y*32768))), y_int/32768 */ +/* 1.25 *2*pi table for low complex and low angle resolution rand_phase_fx */ +RAM_ALIGN const Word16 sincos_lowres_tab_sinQ15_fx[40] = { + 0, 6393, 12540, 18205, 23170, 27246, 30274, 32138, 32767, 32138, 30274, 27246, 23170, 18205, + 12540, 6393, 0, -6393, -12540, -18205, -23170, -27246, -30274, -32138, -32768, -32138, -30274, -27246, + -23170, -18205, -12540, -6393, 0, 6393, 12540, 18205, 23170, 27246, 30274, 32138}; + +/* (PHECU_LA_48K == 0) */ + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 w_new_fs_8_LA_0[OLA_LEN_8K] = {0, 411, 1623, 3574, 6169, 9275, 12738, + 16384, 20030, 23493, 26599, 29194, 31145, 32357}; + + +RAM_ALIGN const Word16 w_old_fs_8_LA_0[OLA_LEN_8K] = { + + /* ( 32768-fliplr(w_new_fs_8_LA_0) ) *[whr3ms(0:13)*/ + 2621, 2721, 3001, 3401, 3836, 4205, 4411, 4377, 4063, 3475, 2673, 1766, 901, 253}; +#else +#define w_new_fs_8_LA_0 NULL +#define w_old_fs_8_LA_0 NULL +#endif /* SUBSET_NB */ + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 w_new_fs_16_LA_0[OLA_LEN_16K] = { + 0, 103, 411, 919, 1623, 2511, 3574, 4799, 6169, 7667, 9275, 10973, 12738, 14550, + 16384, 18218, 20030, 21795, 23493, 25101, 26599, 27969, 29194, 30257, 31145, 31849, 32357, 32665}; + +RAM_ALIGN const Word16 w_old_fs_16_LA_0[OLA_LEN_16K] = {2621, 2646, 2719, 2835, 2990, 3175, 3379, 3592, 3801, 3994, + 4158, 4282, 4355, 4369, 4317, 4196, 4005, 3746, 3425, 3050, + 2635, 2192, 1740, 1299, 889, 531, 250, 66}; +#else +#define w_new_fs_16_LA_0 NULL +#define w_old_fs_16_LA_0 NULL +#endif /* SUBSET_WB */ + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 w_new_fs_24_LA_0[OLA_LEN_24K] = { + 0, 46, 183, 411, 728, 1133, 1623, 2195, 2847, 3574, 4374, 5240, 6169, 7155, + 8192, 9275, 10398, 11555, 12738, 13942, 15160, 16384, 17608, 18826, 20030, 21213, 22370, 23493, + 24576, 25613, 26599, 27528, 28394, 29194, 29921, 30573, 31145, 31635, 32040, 32357, 32585, 32722}; + +RAM_ALIGN const Word16 w_old_fs_24_LA_0[OLA_LEN_24K] = { + 2621, 2632, 2665, 2718, 2790, 2881, 2987, 3106, 3235, 3372, 3512, 3653, 3790, 3919, + 4038, 4143, 4229, 4295, 4337, 4353, 4340, 4298, 4225, 4121, 3986, 3821, 3628, 3408, + 3165, 2902, 2622, 2330, 2032, 1732, 1437, 1152, 884, 640, 426, 249, 114, 30}; +#else +#define w_new_fs_24_LA_0 NULL +#define w_old_fs_24_LA_0 NULL +#endif /* SUBSET_SSWB */ + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 w_new_fs_32_LA_0[OLA_LEN_32K] = { + 0, 26, 103, 231, 411, 640, 919, 1247, 1623, 2044, 2511, 3022, 3574, 4167, + 4799, 5467, 6169, 6903, 7667, 8459, 9275, 10114, 10973, 11848, 12738, 13640, 14550, 15465, + 16384, 17303, 18218, 19128, 20030, 20920, 21795, 22654, 23493, 24309, 25101, 25865, 26599, 27301, + 27969, 28601, 29194, 29746, 30257, 30724, 31145, 31521, 31849, 32128, 32357, 32537, 32665, 32742}; + +RAM_ALIGN const Word16 w_old_fs_32_LA_0[OLA_LEN_32K] = { + 2621, 2628, 2646, 2676, 2717, 2770, 2832, 2904, 2985, 3073, 3167, 3266, 3368, 3473, 3578, 3682, 3784, 3882, 3974, + 4059, 4135, 4202, 4257, 4299, 4328, 4342, 4340, 4323, 4288, 4236, 4167, 4081, 3977, 3856, 3719, 3567, 3400, 3220, + 3028, 2826, 2615, 2398, 2176, 1952, 1728, 1506, 1290, 1081, 882, 697, 528, 377, 248, 143, 65, 17}; +#else +#define w_new_fs_32_LA_0 NULL +#define w_old_fs_32_LA_0 NULL +#endif /* SUBSET_SWB */ + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 w_new_fs_48_LA_0[OLA_LEN_48K] = { + 0, 11, 46, 103, 183, 286, 411, 558, 728, 919, 1133, 1367, 1623, 1899, + 2195, 2511, 2847, 3201, 3574, 3965, 4374, 4799, 5240, 5697, 6169, 6655, 7155, 7667, + 8192, 8728, 9275, 9832, 10398, 10973, 11555, 12144, 12738, 13338, 13942, 14550, 15160, 15771, + 16384, 16997, 17608, 18218, 18826, 19430, 20030, 20624, 21213, 21795, 22370, 22936, 23493, 24040, + 24576, 25101, 25613, 26113, 26599, 27071, 27528, 27969, 28394, 28803, 29194, 29567, 29921, 30257, + 30573, 30869, 31145, 31401, 31635, 31849, 32040, 32210, 32357, 32482, 32585, 32665, 32722, 32757}; + +RAM_ALIGN const Word16 w_old_fs_48_LA_0[OLA_LEN_48K] = { + 2621, 2624, 2632, 2646, 2664, 2688, 2717, 2750, 2789, 2831, 2878, 2929, 2983, 3041, 3101, 3164, 3229, + 3296, 3365, 3434, 3504, 3573, 3643, 3711, 3778, 3844, 3907, 3967, 4024, 4078, 4128, 4173, 4213, 4248, + 4278, 4301, 4319, 4330, 4334, 4331, 4321, 4303, 4278, 4246, 4206, 4158, 4102, 4038, 3967, 3889, 3803, + 3710, 3611, 3505, 3392, 3274, 3150, 3021, 2888, 2750, 2609, 2465, 2319, 2171, 2022, 1873, 1724, 1576, + 1430, 1287, 1147, 1011, 880, 755, 637, 527, 424, 331, 248, 175, 114, 65, 29, 7}; +#else +#define w_new_fs_48_LA_0 NULL +#define w_old_fs_48_LA_0 NULL +#endif /* SUBSET_FB */ + +RAM_ALIGN const Word16 *const w_new[5] = {w_new_fs_8_LA_0, w_new_fs_16_LA_0, w_new_fs_24_LA_0, w_new_fs_32_LA_0, + w_new_fs_48_LA_0}; +RAM_ALIGN const Word16 *const w_old[5] = {w_old_fs_8_LA_0, w_old_fs_16_LA_0, w_old_fs_24_LA_0, w_old_fs_32_LA_0, + w_old_fs_48_LA_0}; + +RAM_ALIGN const Word16 COPY_LEN[5] = {COPY_LEN_8K, COPY_LEN_16K, COPY_LEN_24K, COPY_LEN_32K, COPY_LEN_48K}; /* 2ms */ +RAM_ALIGN const Word16 OLA_LEN[5] = {OLA_LEN_8K, OLA_LEN_16K, OLA_LEN_24K, OLA_LEN_32K, OLA_LEN_48K}; /*1.75 ms mix */ + +RAM_ALIGN const Word16 num_FsByResQ0[5] = {LPROT8K, LPROT16K, LPROT24K, LPROT32K, LPROT48K}; +RAM_ALIGN const Word16 *const LprotSzPtr = num_FsByResQ0; +RAM_ALIGN const Word16 InvLprot_Q22[5] = {INV_LPROT8K_Q22, INV_LPROT16K_Q22, INV_LPROT24K_Q22, INV_LPROT32K_Q22, + INV_LPROT48K_Q22}; +RAM_ALIGN const Word16 PhEcuFftScale[5] = {0, 0, 8, 0, 4}; + +RAM_ALIGN const Word16 oneOverFrameQ15Tab[5] = {INV_L_FRAME8K_Q15, INV_L_FRAME16K_Q15, INV_L_FRAME24K_Q15, + INV_L_FRAME32K_Q15, INV_L_FRAME48K_Q15}; + + +RAM_ALIGN const Word16 PhEcu_Xsav_Flt2FxDnShift[5] = {6, 7, 7, 8, 8}; /* TOTAL FFT adjutmenst shift */ +RAM_ALIGN const Word16 PhEcu_Xsav_Flt2FxScaleQ15[5] = {32767, 32767, 21845, 32767, + 21845}; /* fractional fft adjustment 1./ fft_fs_scale */ + +RAM_ALIGN const Word16 PhEcu_frac_thr_rise_lin_Q15[MAX_LGW] = {3277, 3277, 3277, 3277, 3277, + 3277, 3277, 3277, 3277}; /* for now all fixed to 10dB */ +RAM_ALIGN const Word16 PhEcu_frac_thr_decay_lin_Q15[MAX_LGW] = { + 3277, 3277, 3277, 3277, 3277, + 3277, 3277, 3277, 3277}; /* thresh_rise_dB=10; thresh_lin = 1.0/( 10^(thresh_rise_dB/10) ); */ + +RAM_ALIGN const Word16 mdct_grp_bins_fx[MAX_LGW + 2] = {4, 14, 24, 44, 84, 164, 244, 324, 404, 484}; +RAM_ALIGN const Word16 xavg_N_grp_fx[5] = {4, 5, 6, 7, 8}; + + +RAM_ALIGN const Word16 spec_shape_headroom[5] = {3, 4, 4, 4, 4}; +RAM_ALIGN const Word16 rectLengthTab[NUM_SAMP_FREQ] = {80, 160, 240, 320, 480, 960}; /* 10ms */ +RAM_ALIGN const Word16 hamm_len2Tab[5] = {24, 48, 72, 96, 144}; /* 3 ms*/ + +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR +RAM_ALIGN const Word16 PLC_FADEOUT_TYPE_2_SELECTOR = 10; /* can take values from 0 to 10, default is 10 for longer fadeout*/ +#else +# ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH +RAM_ALIGN const Word16 FADE_OUT_TYPE_2_ALPHA_5MS[30] = { /* 0.5^(nbLostFramesInRow + LC3_ROUND(100.0/frame_dms) - 1) * frame_dms/100.0)*/ + 16384,11585,8192,5792,4096,2896,2048,1448,1024,724,512,362,256,181,128,91,64,45,32,23,16,11,8,6,4,3,2,1,1,1}; +RAM_ALIGN const Word16 FADE_OUT_TYPE_2_ALPHA_2_5MS[60] = { /* 0.5^(nbLostFramesInRow + LC3_ROUND(100.0/frame_dms) - 1) * frame_dms/100.0)*/ + 16384,13777,11585,9742,8192,6889,5793,4871,4096,3444,2896,2435,2048,1722,1448,1218,1024,861,724,609,512,431,362,304,256,215,181,152,128,108,91,76,64,54,45,38,32,27,23,19,16,13,11,10,8,7,6,5,4,3,3,2,2,2,1,1,1,1,1,1}; +# endif +#endif + +RAM_ALIGN const Word16 NN_thresh = 0x7800; /* 30*2^10 */ +RAM_ALIGN const Word16 NN_thresh_exp = -10; +/* Tone detector */ +#ifdef CR8_E_TONE_DETECTOR +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 TD_HR_thresh_10ms = 83402; +# ifdef ENABLE_075_DMS_MODE +RAM_ALIGN const Word32 TD_HR_thresh_7_5ms = 743496; +# endif +RAM_ALIGN const Word32 TD_HR_thresh_5ms = 382564; +RAM_ALIGN const Word32 TD_HR_thresh_2_5ms = 301695; +# endif /* ENABLE_HR_MODE */ +#endif /* CR8_E_TONE_DETECTOR */ +RAM_ALIGN const Word32 BW_thresh_quiet[4] = {0x14000000, 0xA000000, 0xA000000, 0xA000000}; /* [20,10,10,10]*2^24 */ +RAM_ALIGN const Word16 BW_thresh_quiet_exp = 31 - 24; +RAM_ALIGN const Word16 BW_thresh_brickwall[4] = { + 1036, 164, 327, 327}; /* (1/(10^(ctrl.BW_thresh_brickwall/10))*2^15) with [15,23,20,20] dB*/ + +RAM_ALIGN const Word16 BW_brickwall_dist[4] = {4, 4, 3, 1}; +RAM_ALIGN const Word16 BW_warp_idx_start_16k[4] = { + 53, 0, 0, 0}; /* indices for warped bands, with an offset of [17,23,23,23] bins for the start_idx */ +RAM_ALIGN const Word16 BW_warp_idx_stop_16k[4] = { + 63, 0, 0, + 0}; /*'-1' since this is not matlab and another '-1' because of the different formatting of acc_coeff_per_band*/ +RAM_ALIGN const Word16 BW_warp_idx_start_24k[4] = {47, 59, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_24k[4] = {56, 63, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_32k[4] = {44, 54, 60, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_32k[4] = {52, 59, 63, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_48k[4] = {41, 51, 57, 61}; +RAM_ALIGN const Word16 BW_warp_idx_stop_48k[4] = {49, 55, 60, 63}; +RAM_ALIGN const Word16 *const BW_warp_idx_start_all[MAX_BW_BANDS_NUMBER - 1] = { + BW_warp_idx_start_16k, BW_warp_idx_start_24k, BW_warp_idx_start_32k, BW_warp_idx_start_48k}; +RAM_ALIGN const Word16 *const BW_warp_idx_stop_all[MAX_BW_BANDS_NUMBER - 1] = { + BW_warp_idx_stop_16k, BW_warp_idx_stop_24k, BW_warp_idx_stop_32k, BW_warp_idx_stop_48k}; + +RAM_ALIGN const Word16 BW_brickwall_dist_5ms[4] = {4, 4, 3, 1}; +RAM_ALIGN const Word16 BW_warp_idx_start_16k_5ms[4] = {39, 0, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_16k_5ms[4] = {49, 0, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_24k_5ms[4] = {35, 47, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_24k_5ms[4] = {44, 51, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_32k_5ms[4] = {34, 44, 50, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_32k_5ms[4] = {42, 49, 53, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_48k_5ms[4] = {32, 42, 48, 52}; +RAM_ALIGN const Word16 BW_warp_idx_stop_48k_5ms[4] = {40, 46, 51, 54}; +RAM_ALIGN const Word16 *const BW_warp_idx_start_all_5ms[MAX_BW_BANDS_NUMBER - 1] = { + BW_warp_idx_start_16k_5ms, BW_warp_idx_start_24k_5ms, BW_warp_idx_start_32k_5ms, BW_warp_idx_start_48k_5ms}; +RAM_ALIGN const Word16 *const BW_warp_idx_stop_all_5ms[MAX_BW_BANDS_NUMBER - 1] = { + BW_warp_idx_stop_16k_5ms, BW_warp_idx_stop_24k_5ms, BW_warp_idx_stop_32k_5ms, BW_warp_idx_stop_48k_5ms}; + +RAM_ALIGN const Word16 BW_brickwall_dist_2_5ms[4] = {4, 4, 3, 1}; +RAM_ALIGN const Word16 BW_warp_idx_start_16k_2_5ms[4] = {24, 0, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_16k_2_5ms[4] = {34, 0, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_24k_2_5ms[4] = {24, 35, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_24k_2_5ms[4] = {32, 39, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_32k_2_5ms[4] = {24, 33, 39, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_32k_2_5ms[4] = {31, 38, 42, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_48k_2_5ms[4] = {22, 31, 37, 41}; +RAM_ALIGN const Word16 BW_warp_idx_stop_48k_2_5ms[4] = {29, 35, 40, 43}; +RAM_ALIGN const Word16 *const BW_warp_idx_start_all_2_5ms[MAX_BW_BANDS_NUMBER - 1] = { + BW_warp_idx_start_16k_2_5ms, BW_warp_idx_start_24k_2_5ms, BW_warp_idx_start_32k_2_5ms, BW_warp_idx_start_48k_2_5ms}; +RAM_ALIGN const Word16 *const BW_warp_idx_stop_all_2_5ms[MAX_BW_BANDS_NUMBER - 1] = { + BW_warp_idx_stop_16k_2_5ms, BW_warp_idx_stop_24k_2_5ms, BW_warp_idx_stop_32k_2_5ms, BW_warp_idx_stop_48k_2_5ms}; + +# ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 BW_brickwall_dist_7_5ms[4] = {4, 4, 3, 2}; +RAM_ALIGN const Word16 BW_warp_idx_start_16k_7_5ms[4] = {51, 0, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_16k_7_5ms[4] = {63, 0, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_24k_7_5ms[4] = {45, 58, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_24k_7_5ms[4] = {55, 63, 0, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_32k_7_5ms[4] = {42, 53, 60, 0}; +RAM_ALIGN const Word16 BW_warp_idx_stop_32k_7_5ms[4] = {51, 58, 63, 0}; +RAM_ALIGN const Word16 BW_warp_idx_start_48k_7_5ms[4] = {40, 51, 57, 61}; +RAM_ALIGN const Word16 BW_warp_idx_stop_48k_7_5ms[4] = {48, 55, 60, 63}; +RAM_ALIGN const Word16 *const BW_warp_idx_start_all_7_5ms[] = { + BW_warp_idx_start_16k_7_5ms, BW_warp_idx_start_24k_7_5ms, BW_warp_idx_start_32k_7_5ms, BW_warp_idx_start_48k_7_5ms}; +RAM_ALIGN const Word16 *const BW_warp_idx_stop_all_7_5ms[] = { + BW_warp_idx_stop_16k_7_5ms, BW_warp_idx_stop_24k_7_5ms, BW_warp_idx_stop_32k_7_5ms, BW_warp_idx_stop_48k_7_5ms}; +# endif + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 BW_cutoff_bin_all[] = {80, 160, 240, 320, 400, 400}; +RAM_ALIGN const Word16 BW_cutoff_bin_all_HR[] = {80, 160, 240, 320, 400, 400}; +RAM_ALIGN const Word16 BW_cutoff_bits_all[] = {0, 1, 2, 2, 3, 0}; +#else /* ENABLE_HR_MODE */ +RAM_ALIGN const Word16 BW_cutoff_bin_all[] = {80, 160, 240, 320, 400}; +RAM_ALIGN const Word16 BW_cutoff_bits_all[] = {0, 1, 2, 2, 3}; +#endif /* ENABLE_HR_MODE */ + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 LowDelayShapes_n960_len[6] = {130, 260, 390, 520, 780, 1560}; +#else +RAM_ALIGN const Word16 LowDelayShapes_n960_len[5] = {130, 260, 390, 520, 780}; +#endif +RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes[NUM_SAMP_FREQ] = {30, + 60, + 90, + 120, + 180 +#ifdef ENABLE_HR_MODE + , 360 +#endif +}; + +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_HR_MODE +const Word16 LowDelayShapes_n960_len_7_5ms[6] = {106, 212, 318, 424, 636, 1272}; +# else +const Word16 LowDelayShapes_n960_len_7_5ms[5] = {106, 212, 318, 424, 636}; +# endif +const Word16 LowDelayShapes_n960_la_zeroes_7_5ms[NUM_SAMP_FREQ] = {14, 28, 42, 56, 84 +# ifdef ENABLE_HR_MODE + , 168 +# endif +}; +# ifdef ENABLE_HR_MODE +# ifdef SUBSET_NB +const Word32 MDCT_WINDOW_FS_8000_frame_ms_75[106] = { + 4627440, 11253200, 21594770, 36220454, 55523513, 79715027, 108949241, 143324500, 182870991, + 227518888, 277136190, 331449220, 390143896, 452770029, 518831181, 587821768, 659169189, 732247130, + 806397033, 880930033, 955136210, 1028289061, 1099721013, 1168761191, 1234831373, 1297335398, 1355817068, + 1409866562, 1459158403, 1503372583, 1542341368, 1575958063, 1604141948, 1626962506, 1644516439, 1657006271, + 1664740913, 1668084651, 1667510566, 1663566793, 1656808751, 1647805301, 1637186879, 1625507591, 1613355502, + 1601336341, 1590266842, 1579708994, 1571001708, 1564080946, 1558867236, 1555257286, 1553127519, 1552339115, + 1552734517, 1554146897, 1556401387, 1559318893, 1562715844, 1566405205, -1570197717, -1573904742, -1577333468, + -1580290211, -1582582625, -1584022156, -1584425628, -1583621336, -1581452727, -1577790475, -1572531065, -1565603566, + -1556974029, -1546637213, -1533223967, -1517247857, -1497930249, -1474813741, -1447477329, -1415559391, -1378853853, + -1337198324, -1290524957, -1238912889, -1182546000, -1121735805, -1056935470, -988679598, -917579357, -844370566, + -769774729, -694577976, -619621377, -545775321, -473935196, -404978161, -339758802, -279035319, -223452287, + -173535871, -129697804, -92268521, -61482210, -37424210, -19913685, -8400842}; +# else +# define MDCT_WINDOW_FS_8000_frame_ms_75 NULL +# endif +# ifdef SUBSET_WB +const Word32 MDCT_WINDOW_FS_16000_frame_ms_75[212] = { + 2448850, 4225281, 6560055, 9518849, 13169928, 17558685, 22724572, 28709046, 35532706, + 43206772, 51759643, 61197652, 71531905, 82773688, 94926633, 107995294, 121978042, 136866522, + 152653815, 169326944, 186873869, 205260070, 224464206, 244469708, 265226672, 286694090, 308842566, + 331620399, 354982140, 378884306, 403282899, 428126460, 453358062, 478925896, 504771155, 530831178, + 557056009, 583378298, 609738583, 636071404, 662314239, 688406753, 714278048, 739869110, 765133864, + 789997902, 814413107, 838333634, 861699657, 884456686, 906561215, 927970820, 948653245, 968562870, + 987675635, 1005965699, 1023398499, 1039938064, 1055570884, 1070287165, 1084066983, 1096897234, 1108786027, + 1119713468, 1129673618, 1138691939, 1146759882, 1153881756, 1160087929, 1165385723, 1169796304, 1173355296, + 1176085471, 1178017803, 1179194996, 1179657892, 1179448026, 1178622117, 1177223060, 1175290297, 1172896803, + 1170081494, 1166887472, 1163391971, 1159633509, 1155652038, 1151518603, 1147273273, 1142969676, 1138666561, + 1134412515, 1130255869, 1126558117, 1122496331, 1118765157, 1115363902, 1112285558, 1109526458, 1107080797, + 1104939816, 1103098430, 1101543766, 1100269289, 1099261964, 1098510648, 1098002762, 1097726182, 1097665183, + 1097807233, 1098135900, 1098637579, 1099295163, 1100094642, 1101018650, 1102052611, 1103178569, 1104381936, + 1105644852, 1106951761, 1108284322, -1109627660, -1110963442, -1112276637, -1113548581, -1114763260, -1115902204, + -1116950143, -1117888308, -1118701309, -1119370903, -1119882282, -1120217558, -1120362527, -1120300271, -1120018073, + -1119500244, -1118735095, -1117710865, -1116417682, -1114844247, -1112986355, -1110833953, -1108385410, -1105635984, + -1102584489, -1099232427, -1095578582, -1091628491, -1086655755, -1081531176, -1075887278, -1069676603, -1062851542, + -1055375495, -1047209387, -1038304906, -1028645771, -1018191542, -1006905821, -994788854, -981815515, -967960849, + -953236015, -937625018, -921120793, -903739802, -885489416, -866385515, -846456825, -825718325, -804213946, + -781984241, -759069751, -735509614, -711369811, -686704607, -661557703, -636008311, -610118476, -583941228, + -557562076, -531035554, -504439473, -477846967, -451338312, -424989596, -398869327, -373061710, -347653667, + -322717851, -298330826, -274560095, -251498346, -229196510, -207718889, -187124805, -167466055, -148790641, + -131139192, -114544857, -99042767, -84660988, -71425324, -59356162, -48470733, -38776535, -30272788, + -22943830, -16759108, -11669404, -7602417, -4461896 }; +# else +# define MDCT_WINDOW_FS_16000_frame_ms_75 NULL +# endif +# ifdef SUBSET_SSWB +const Word32 MDCT_WINDOW_FS_24000_frame_ms_75[318] = { + 3569045, 5343308, 7469087, 10008734, 12994076, 16456850, 20430606, 24935492, 29988837, + 35611849, 41823777, 48643571, 56071893, 64113030, 72783590, 82094564, 92046985, 102645585, + 113894977, 125803748, 138373328, 151602749, 165496877, 180058414, 195279760, 211161232, 227698398, + 244884561, 262716182, 281188032, 300290267, 320009308, 340323456, 361229416, 382724592, 404784463, + 427382077, 450499367, 474123138, 498236134, 522813796, 547827872, 573261791, 599094644, 625301687, + 651864990, 678758112, 705953149, 733423301, 761143017, 789088191, 817226769, 845526155, 873965021, + 902516713, 931147088, 959825021, 988524208, 1017210384, 1045855673, 1074425690, 1102896296, 1131233244, + 1159399102, 1187365932, 1215118091, 1242623432, 1269848445, 1296758792, 1323338775, 1349569176, 1375419011, + 1400856664, 1425860452, 1450405500, 1474469418, 1498033883, 1521084216, 1543600669, 1565562699, 1586950362, + 1607758181, 1627973678, 1647578495, 1666558705, 1684890994, 1702569411, 1719588669, 1735945131, 1751628259, + 1766631537, 1780942408, 1794568179, 1807511369, 1819759624, 1831304037, 1842145330, 1852303571, 1861781063, + 1870563512, 1878654482, 1886073254, 1892829269, 1898924017, 1904366694, 1909168622, 1913346034, 1916917451, + 1919887595, 1922277229, 1924098512, 1925377637, 1926138245, 1926390110, 1926159966, 1925475348, 1924365664, + 1922840889, 1920921471, 1918639476, 1916032510, 1913117957, 1909905898, 1906425851, 1902721668, 1898817211, + 1894724624, 1890460570, 1886061947, 1881561147, 1876974490, 1872321669, 1867634952, 1862942467, 1858269659, + 1853636539, 1849063935, 1844532585, 1840901848, 1836281978, 1831977326, 1827914309, 1824090826, 1820508133, + 1817156298, 1814036518, 1811148878, 1808486122, 1806045111, 1803824889, 1801820200, 1800024837, 1798435525, + 1797047955, 1795856425, 1794854508, 1794036436, 1793397182, 1792930395, 1792629275, 1792486811, 1792496288, + 1792650932, 1792943382, 1793366271, 1793912436, 1794574259, 1795343928, 1796214319, 1797177519, 1798225910, + 1799351580, 1800546365, 1801802795, 1803112835, 1804468826, 1805862173, 1807285016, 1808728934, 1810185719, + -1811649011, -1813108149, -1814556719, -1815986412, -1817388652, -1818755380, -1820077746, -1821347804, -1822557195, + -1823698097, -1824761958, -1825740466, -1826625594, -1827409009, -1828083190, -1828639928, -1829071236, -1829369628, + -1829527454, -1829537126, -1829391729, -1829084485, -1828608410, -1827956837, -1827123677, -1826104316, -1824893520, + -1823485537, -1821875510, -1820060164, -1818037432, -1815802468, -1813351581, -1810685587, -1807803281, -1804699559, + -1801376829, -1797838749, -1794078176, -1790099212, -1785902823, -1781420977, -1775757613, -1770414541, -1764657397, + -1758514553, -1751966917, -1744988832, -1737559493, -1729660865, -1721279216, -1712390301, -1702968220, -1693002531, + -1682487980, -1671402851, -1659722977, -1647435681, -1634547191, -1621051754, -1606928538, -1592163286, -1576765074, + -1560734340, -1544063625, -1526744164, -1508774562, -1490169863, -1470931267, -1451061598, -1430573380, -1409469788, + -1387774154, -1365486503, -1342628496, -1319212449, -1295268938, -1270814307, -1245866917, -1220443956, -1194576202, + -1168294208, -1141628864, -1114589888, -1087212858, -1059529377, -1031588154, -1003401722, -974995147, -946412027, + -917694623, -888859295, -859943075, -830987474, -802029563, -773092402, -744234412, -715477138, -686865195, + -658426713, -630207057, -602244426, -574581369, -547253226, -520293544, -493735699, -467628500, -441995738, + -416889401, -392319671, -368337811, -344954670, -322202233, -300117288, -278711744, -258020476, -238052276, + -218834457, -200381964, -182706579, -165829103, -149762124, -134517743, -120107705, -106542511, -93830987, + -81979923, -70993541, -60872925, -51615362, -43213756, -35655914, -28924065, -22994343, -17836407, + -13413907, -9700456, -6939916 }; +# else +# define MDCT_WINDOW_FS_24000_frame_ms_75 NULL +# endif +# ifdef SUBSET_SWB +const Word32 MDCT_WINDOW_FS_32000_frame_ms_75[424] = { + 2898737, 4022405, 5281441, 6723878, 8372060, 10235970, 12328606, 14657777, 17238266, + 20075996, 23180406, 26552429, 30204258, 34141418, 38374110, 42901881, 47726394, 52848657, + 58275464, 64009892, 70057240, 76417471, 83091786, 90080421, 97386522, 105014921, 112964415, + 121235754, 129827911, 138744722, 147986004, 157551876, 167437738, 177647147, 188174741, 199022831, + 210184946, 221662871, 233452811, 245554560, 257961285, 270671503, 283672733, 296964439, 310542664, + 324409414, 338557330, 352975270, 367652577, 382584217, 397764861, 413190770, 428852496, 444742036, + 460850489, 477166934, 493686689, 510401963, 527305552, 544386461, 561639986, 579055156, 596625027, + 614334635, 632177187, 650141962, 668224093, 686407908, 704684687, 723041108, 741470500, 759961912, + 778506953, 797092489, 815707619, 834339025, 852979862, 871616777, 890238991, 908834402, 927390921, + 945902091, 964354406, 982734524, 1001028580, 1019227984, 1037324578, 1055313224, 1073178103, 1090910419, + 1108493143, 1125919532, 1143183321, 1160279970, 1177195986, 1193922020, 1210443853, 1226757428, 1242848720, + 1258716966, 1274346305, 1289734310, 1304873724, 1319761111, 1334385677, 1348742053, 1362821420, 1376620057, + 1390134975, 1403361262, 1416296924, 1428929625, 1441257929, 1453270092, 1464967234, 1476341997, 1487396355, + 1498127704, 1508535547, 1518610856, 1528355951, 1537762901, 1546836443, 1555575202, 1563981756, 1572051527, + 1579779433, 1587162378, 1594203212, 1600912026, 1607289540, 1613333597, 1619037500, 1624404299, 1629439428, + 1634149881, 1638537653, 1642603536, 1646350593, 1649779860, 1652898979, 1655708955, 1658229426, 1660449352, + 1662377545, 1664024217, 1665388315, 1666481709, 1667311651, 1667891108, 1668216427, 1668300198, 1668150304, + 1667777789, 1667191944, 1666404102, 1665413150, 1664228568, 1662860495, 1661323561, 1659629730, 1657785817, + 1655794977, 1653662566, 1651401295, 1649028654, 1646557403, 1643989827, 1641331208, 1638586818, 1635770553, + 1632894967, 1629971201, 1627004437, 1624002536, 1620971847, 1617927153, 1614878122, 1611835451, 1608805100, + 1605795099, 1602815547, 1599884473, 1596942341, 1594771673, 1591702411, 1588839753, 1586088059, 1583448720, + 1580925703, 1578521775, 1576232766, 1574055288, 1571990953, 1570040827, 1568202332, 1566472498, 1564851004, + 1563337829, 1561931261, 1560628909, 1559429084, 1558330506, 1557331359, 1556429824, 1555624516, 1554913143, + 1554292592, 1553760945, 1553317125, 1552958916, 1552683122, 1552487276, 1552369480, 1552327252, 1552357490, + 1552457675, 1552625785, 1552859126, 1553154340, 1553508826, 1553920495, 1554386414, 1554903212, 1555468295, + 1556079427, 1556733719, 1557427851, 1558158741, 1558924090, 1559721218, 1560546581, 1561397206, 1562271110, + 1563165114, 1564075458, 1564999378, 1565934440, 1566877694, 1567825218, -1568775555, -1569724227, -1570669763, + -1571608214, -1572536583, -1573452385, -1574352788, -1575233942, -1576092574, -1576926600, -1577732933, -1578507896, + -1579248680, -1579952850, -1580617181, -1581238194, -1581812847, -1582338764, -1582813204, -1583232638, -1583593989, + -1583895045, -1584133086, -1584304626, -1584406873, -1584437736, -1584394635, -1584274418, -1584074588, -1583793268, + -1583428030, -1582975737, -1582434279, -1581802744, -1581079400, -1580261338, -1579346529, -1578333908, -1577222011, + -1576009429, -1574695339, -1573278552, -1571757228, -1570130264, -1568398303, -1566561731, -1564618340, -1562566382, + -1560407784, -1558145041, -1555775754, -1553296829, -1550712057, -1548026396, -1545242289, -1542268350, -1538423280, + -1535025262, -1531395445, -1527591708, -1523601949, -1519416343, -1515026680, -1510422354, -1505596841, -1500543057, + -1495258714, -1489733930, -1483960441, -1477928294, -1471632952, -1465071334, -1458241898, -1451136236, -1443746092, + -1436060907, -1428079531, -1419805847, -1411239360, -1402373353, -1393199823, -1383713926, -1373917135, -1363813377, + -1353400513, -1342677100, -1331640941, -1320284636, -1308611825, -1296630892, -1284342674, -1271742396, -1258835954, + -1245628407, -1232122065, -1218316234, -1204224404, -1189846207, -1175175506, -1160242956, -1145031655, -1129564821, + -1113844775, -1097879736, -1081675373, -1065238433, -1048578417, -1031707925, -1014636539, -997375667, -979937295, + -962314566, -944532531, -926597437, -908531127, -890341534, -872033654, -853615925, -835103871, -816513734, + -797862235, -779149108, -760390220, -741599202, -722791848, -703980340, -685176354, -666389658, -647646244, + -628944722, -610316405, -591754523, -573282405, -554915396, -536666275, -518550375, -500581949, -482775076, + -465139339, -447692836, -430439482, -413418994, -396596647, -380036004, -363729221, -347677810, -331912032, + -316431125, -301242631, -286354637, -271795849, -257560706, -243655300, -230096441, -216894979, -204043835, + -191560528, -179450345, -167715723, -156363602, -145400931, -134832648, -124663143, -114896281, -105536276, + -96587551, -88053476, -79936384, -72238586, -64962154, -58107752, -51674659, -45661585, -40066372, + -34884913, -30111469, -25739290, -21759792, -18161914, -14933570, -12062384, -9522842, -7254663, + -5656627 }; +# else +# define MDCT_WINDOW_FS_32000_frame_ms_75 NULL +# endif +# ifdef SUBSET_FB +const Word32 MDCT_WINDOW_FS_48000_frame_ms_75[636] = { + 2204435, 2827689, 3443319, 4131102, 4878935, 5703040, 6599364, 7574899, 8628974, + 9768536, 10991420, 12304931, 13709256, 15207323, 16799052, 18489324, 20275023, 22160933, + 24148496, 26240076, 28435235, 30739604, 33150351, 35668955, 38294878, 41029635, 43871618, + 46825882, 49890883, 53068998, 56360550, 59766888, 63284768, 66918075, 70664961, 74526448, + 78503039, 82597929, 86807681, 91135031, 95578822, 100139618, 104816236, 109611835, 114523552, + 119554039, 124702224, 129967749, 135348514, 140848111, 146462751, 152193324, 158039847, 164002831, + 170078327, 176269443, 182573647, 188991411, 195521914, 202165741, 208918745, 215783357, 222755240, + 229832331, 237013913, 244302241, 251692923, 259188940, 266788795, 274490295, 282289304, 290186132, + 298175224, 306257381, 314430505, 322694044, 331045821, 339487261, 348012274, 356620678, 365310317, + 374079074, 382922254, 391842074, 400834178, 409898068, 419031270, 428232881, 437497913, 446828175, + 456219802, 465670981, 475178925, 484743299, 494357854, 504022976, 513735237, 523492799, 533292796, + 543136028, 553015990, 562931887, 572880536, 582859524, 592864355, 602896501, 612951047, 623027190, + 633121825, 643232873, 653354882, 663488155, 673627234, 683771323, 693918098, 704065470, 714207061, + 724344108, 734471992, 744587758, 754688429, 764774608, 774840295, 784884831, 794903648, 804894011, + 814851825, 824777247, 834664477, 844515260, 854327259, 864098094, 873822193, 883500485, 893125924, + 902697010, 912211002, 921668164, 931065070, 940403253, 949676961, 958885223, 968024298, 977093615, + 986086667, 995005058, 1003845874, 1012604766, 1021282611, 1029879030, 1038386135, 1046806723, 1055138039, + 1063379017, 1071528406, 1079585832, 1087546197, 1095410412, 1103175087, 1110839263, 1118400067, 1125861251, + 1133217689, 1140469587, 1147616705, 1154658548, 1161589135, 1168411456, 1175122212, 1181718798, 1188199640, + 1194567214, 1200817042, 1206950737, 1212967954, 1218868269, 1224650873, 1230316551, 1235861165, 1241285527, + 1246589565, 1251772729, 1256831629, 1261771016, 1266587826, 1271284733, 1275860443, 1280315823, 1284645497, + 1288852346, 1292933744, 1296889962, 1300722079, 1304434734, 1308025653, 1311497310, 1314848195, 1318076916, + 1321181451, 1324164254, 1327024207, 1329764950, 1332387885, 1334893025, 1337281173, 1339554157, 1341707740, + 1343747791, 1345671522, 1347481634, 1349179572, 1350764422, 1352239980, 1353613012, 1354873992, 1356030340, + 1357079368, 1358026526, 1358871638, 1359613742, 1360257791, 1360804083, 1361255397, 1361617096, 1361885808, + 1362062609, 1362151603, 1362153995, 1362072233, 1361909271, 1361666938, 1361347766, 1360955593, 1360489817, + 1359950116, 1359340101, 1358660855, 1357916180, 1357108339, 1356243400, 1355321087, 1354344570, 1353313776, + 1352230258, 1351093731, 1349909242, 1348677915, 1347405592, 1346095404, 1344750475, 1343369336, 1341955495, + 1340508098, 1339029437, 1337520955, 1335988076, 1334432030, 1332857982, 1331266254, 1329659151, 1328036799, + 1326403000, 1324757066, 1323104230, 1321446604, 1319787700, 1318127699, 1316471738, 1314818892, 1313173031, + 1311534229, 1309906742, 1308289975, 1306691587, 1305107061, 1303560954, 1302485706, 1300837265, 1299230148, + 1297667349, 1296147118, 1294669845, 1293233008, 1291838729, 1290486465, 1289178223, 1287911298, 1286686132, + 1285500617, 1284356733, 1283253302, 1282192039, 1281170798, 1280190420, 1279248602, 1278346792, 1277483349, + 1276659918, 1275874601, 1275128550, 1274419448, 1273748350, 1273113203, 1272515449, 1271953180, 1271427649, + 1270936717, 1270481540, 1270059928, 1269672963, 1269318382, 1268997326, 1268707731, 1268450837, 1268224483, + 1268029756, 1267864381, 1267729424, 1267622629, 1267545013, 1267494302, 1267471571, 1267474578, 1267504402, + 1267558747, 1267638603, 1267741668, 1267868942, 1268018115, 1268190239, 1268383008, 1268597404, 1268831071, + 1269084943, 1269356717, 1269647473, 1269954877, 1270279875, 1270620090, 1270976496, 1271346828, 1271732058, + 1272129716, 1272540744, 1272962829, 1273396990, 1273840888, 1274295422, 1274758248, 1275230417, 1275709517, + 1276196415, 1276688706, 1277187379, 1277690114, 1278197794, 1278707969, 1279221647, 1279736503, 1280253498, + -1280770244, -1281287656, -1281803343, -1282318265, -1282830085, -1283339807, -1283844964, -1284346432, -1284841866, + -1285332250, -1285815146, -1286291410, -1286758593, -1287217737, -1287666452, -1288105628, -1288532876, -1288949203, + -1289352245, -1289742931, -1290118731, -1290480607, -1290826232, -1291156571, -1291469183, -1291765004, -1292041634, + -1292300151, -1292538184, -1292756663, -1292953166, -1293128674, -1293280819, -1293410658, -1293515818, -1293597309, + -1293652773, -1293683213, -1293686282, -1293663081, -1293611326, -1293532118, -1293423149, -1293285472, -1293116803, + -1292918254, -1292687534, -1292425784, -1292130842, -1291804017, -1291443255, -1291049775, -1290621337, -1290159111, + -1289660945, -1289128099, -1288558489, -1287953483, -1287311252, -1286633366, -1285917866, -1285165943, -1284375393, + -1283547520, -1282680564, -1281776335, -1280833350, -1279853230, -1278833852, -1277776244, -1276678466, -1275542433, + -1274367185, -1273154903, -1271903726, -1270614321, -1269284275, -1267915816, -1266508671, -1265065178, -1263583140, + -1262063220, -1260504007, -1258908698, -1256628331, -1254761985, -1252853377, -1250881358, -1248844632, -1246741358, + -1244569594, -1242327619, -1240012651, -1237623600, -1235156149, -1232610864, -1229984110, -1227275248, -1224482272, + -1221606271, -1218642652, -1215591412, -1212448650, -1209213243, -1205881571, -1202455146, -1198931234, -1195311772, + -1191594196, -1187777826, -1183858288, -1179836046, -1175706321, -1171469469, -1167124636, -1162674694, -1158117379, + -1153454731, -1148683225, -1143802349, -1138808714, -1133702904, -1128481825, -1123149280, -1117704914, -1112149514, + -1106481061, -1100702139, -1094806903, -1088800296, -1082676113, -1076437274, -1070082677, -1063618676, -1057039488, + -1050351248, -1043548836, -1036634133, -1029608325, -1022475106, -1015230021, -1007878923, -1000415821, -992849913, + -985179219, -977404151, -969525479, -961538535, -953457394, -945280420, -936999272, -928626277, -920160734, + -911603664, -902957625, -894223210, -885402362, -876498250, -867508512, -858440255, -849293347, -840074392, + -830781521, -821419104, -811990901, -802499334, -792938179, -783315469, -773636100, -763901035, -754111866, + -744278025, -734399140, -724475975, -714510329, -704504133, -694460237, -684383382, -674277250, -664145566, + -653994294, -643817229, -633622219, -623410967, -613187040, -602954520, -592717105, -582476532, -572238350, + -562002979, -551770150, -541551921, -531349514, -521160592, -510991643, -500852505, -490735715, -480646079, + -470590740, -460574626, -450595871, -440662753, -430774557, -420941335, -411160195, -401435877, -391774603, + -382174290, -372642476, -363180190, -353786746, -344482765, -335253937, -326094163, -317034690, -308063867, + -299187762, -290405275, -281715156, -273134873, -264653333, -256282164, -248014183, -239853113, -231807709, + -223884020, -216073113, -208387006, -200816625, -193373144, -186056104, -178871459, -171808633, -164881963, + -158086310, -151426496, -144902306, -138514809, -132265008, -126156408, -120188845, -114364736, -108683712, + -103148269, -97758088, -92515604, -87420431, -82474860, -77678410, -73033188, -68538592, -64196501, + -60006167, -55969182, -52084610, -48353698, -44775286, -41350196, -38077002, -34956005, -31985545, + -29165263, -26493253, -23968386, -21588587, -19351751, -17255806, -15297341, -13474667, -11782386, + -10220076, -8778515, -7460996, -6246830, -5152154, -4038973 }; +# else +# define MDCT_WINDOW_FS_48000_frame_ms_75 NULL +# endif + +const Word32 *const LowDelayShapes_n960_7_5ms[5] = { + MDCT_WINDOW_FS_8000_frame_ms_75, MDCT_WINDOW_FS_16000_frame_ms_75, MDCT_WINDOW_FS_24000_frame_ms_75, MDCT_WINDOW_FS_32000_frame_ms_75, MDCT_WINDOW_FS_48000_frame_ms_75 }; +# else + +RAM_ALIGN const Word16 LowDelayShapes_n960_N60_7_5ms[106] = { + 71, 172, 330, 553, 847, 1216, 1662, 2187, 2790, 3472, 4229, 5058, 5953, 6909, + 7917, 8969, 10058, 11173, 12305, 13442, 14574, 15690, 16780, 17834, 18842, 19796, 20688, 21513, + 22265, 22940, 23534, 24047, 24477, 24825, 25093, 25284, 25402, 25453, 25444, 25384, 25281, 25144, + 24981, 24803, 24618, 24434, 24266, 24104, 23972, 23866, 23786, 23731, 23699, 23687, 23693, 23714, + 23749, 23793, 23845, 23901, -23959, -24016, -24068, -24113, -24148, -24170, -24176, -24164, -24131, -24075, + -23995, -23889, -23758, -23600, -23395, -23151, -22857, -22504, -22087, -21600, -21040, -20404, -19692, -18904, + -18044, -17116, -16128, -15086, -14001, -12884, -11746, -10598, -9455, -8328, -7232, -6179, -5184, -4258, + -3410, -2648, -1979, -1408, -938, -571, -304, -128}; + +RAM_ALIGN const Word16 LowDelayShapes_n960_N120_7_5ms[212] = { + 37, 64, 100, 145, 201, 268, 347, 438, 542, 659, 790, 934, 1091, 1263, + 1448, 1648, 1861, 2088, 2329, 2584, 2851, 3132, 3425, 3730, 4047, 4375, 4713, 5060, + 5417, 5781, 6154, 6533, 6918, 7308, 7702, 8100, 8500, 8902, 9304, 9706, 10106, 10504, + 10899, 11290, 11675, 12054, 12427, 12792, 13148, 13496, 13833, 14160, 14475, 14779, 15071, 15350, + 15616, 15868, 16107, 16331, 16542, 16737, 16919, 17085, 17237, 17375, 17498, 17607, 17702, 17782, + 17850, 17904, 17946, 17975, 17993, 18000, 17997, 17984, 17963, 17934, 17897, 17854, 17805, 17752, + 17695, 17634, 17571, 17506, 17440, 17375, 17310, 17246, 17190, 17128, 17071, 17019, 16972, 16930, + 16893, 16860, 16832, 16808, 16789, 16773, 16762, 16754, 16750, 16749, 16751, 16756, 16764, 16774, + 16786, 16800, 16816, 16833, 16852, 16871, 16891, 16911, -16932, -16952, -16972, -16991, -17010, -17027, + -17043, -17058, -17070, -17080, -17088, -17093, -17095, -17094, -17090, -17082, -17071, -17055, -17035, -17011, + -16983, -16950, -16913, -16871, -16824, -16773, -16717, -16657, -16581, -16503, -16417, -16322, -16218, -16104, + -15979, -15843, -15696, -15536, -15364, -15179, -14981, -14770, -14545, -14307, -14055, -13790, -13511, -13220, + -12916, -12599, -12271, -11932, -11582, -11223, -10855, -10478, -10095, -9705, -9310, -8910, -8508, -8103, + -7697, -7291, -6887, -6485, -6086, -5692, -5305, -4924, -4552, -4189, -3838, -3497, -3170, -2855, + -2555, -2270, -2001, -1748, -1511, -1292, -1090, -906, -740, -592, -462, -350, -256, -178, + -116, -68}; + +RAM_ALIGN const Word16 LowDelayShapes_n960_N180_7_5ms[318] = { + 54, 82, 114, 153, 198, 251, 312, 380, 458, 543, 638, 742, 856, 978, + 1111, 1253, 1405, 1566, 1738, 1920, 2111, 2313, 2525, 2747, 2980, 3222, 3474, 3737, + 4009, 4291, 4582, 4883, 5193, 5512, 5840, 6177, 6521, 6874, 7235, 7602, 7978, 8359, + 8747, 9141, 9541, 9947, 10357, 10772, 11191, 11614, 12041, 12470, 12902, 13336, 13771, 14208, + 14646, 15084, 15521, 15958, 16394, 16829, 17261, 17691, 18118, 18541, 18961, 19376, 19787, 20193, + 20593, 20987, 21375, 21757, 22131, 22499, 22858, 23210, 23553, 23889, 24215, 24532, 24841, 25140, + 25430, 25709, 25979, 26239, 26488, 26728, 26957, 27175, 27383, 27580, 27767, 27943, 28109, 28264, + 28409, 28543, 28666, 28779, 28882, 28975, 29058, 29132, 29195, 29250, 29295, 29332, 29359, 29379, + 29391, 29394, 29391, 29380, 29363, 29340, 29311, 29276, 29236, 29192, 29143, 29090, 29033, 28974, + 28911, 28846, 28779, 28710, 28640, 28569, 28498, 28426, 28355, 28284, 28214, 28145, 28090, 28019, + 27954, 27892, 27833, 27779, 27728, 27680, 27636, 27595, 27558, 27524, 27494, 27466, 27442, 27421, + 27403, 27387, 27375, 27365, 27358, 27353, 27351, 27351, 27354, 27358, 27365, 27373, 27383, 27395, + 27408, 27423, 27439, 27456, 27474, 27493, 27513, 27534, 27555, 27577, 27599, 27621, -27644, -27666, + -27688, -27710, -27731, -27752, -27772, -27792, -27810, -27827, -27844, -27859, -27872, -27884, -27894, -27903, + -27909, -27914, -27916, -27917, -27914, -27910, -27902, -27892, -27880, -27864, -27846, -27824, -27800, -27772, + -27741, -27707, -27670, -27629, -27585, -27538, -27487, -27433, -27375, -27315, -27251, -27182, -27096, -27014, + -26927, -26833, -26733, -26626, -26513, -26393, -26265, -26129, -25985, -25833, -25673, -25504, -25325, -25138, + -24941, -24735, -24520, -24294, -24060, -23815, -23561, -23296, -23022, -22738, -22445, -22141, -21829, -21507, + -21176, -20836, -20487, -20130, -19764, -19391, -19010, -18622, -18228, -17827, -17420, -17007, -16590, -16167, + -15741, -15311, -14877, -14441, -14003, -13563, -13122, -12680, -12238, -11796, -11356, -10917, -10481, -10047, + -9616, -9190, -8767, -8350, -7939, -7534, -7135, -6744, -6361, -5986, -5620, -5264, -4916, -4579, + -4253, -3937, -3632, -3339, -3058, -2788, -2530, -2285, -2053, -1833, -1626, -1432, -1251, -1083, + -929, -788, -659, -544, -441, -351, -272, -205, -148, -106}; + +RAM_ALIGN const Word16 LowDelayShapes_n960_N240_7_5ms[424] = { + 44, 61, 81, 103, 128, 156, 188, 224, 263, 306, 354, 405, 461, 521, + 586, 655, 728, 806, 889, 977, 1069, 1166, 1268, 1375, 1486, 1602, 1724, 1850, + 1981, 2117, 2258, 2404, 2555, 2711, 2871, 3037, 3207, 3382, 3562, 3747, 3936, 4130, + 4329, 4531, 4739, 4950, 5166, 5386, 5610, 5838, 6069, 6305, 6544, 6786, 7032, 7281, + 7533, 7788, 8046, 8307, 8570, 8836, 9104, 9374, 9646, 9920, 10196, 10474, 10753, 11033, + 11314, 11596, 11879, 12163, 12447, 12731, 13015, 13300, 13584, 13868, 14151, 14433, 14715, 14995, + 15274, 15552, 15828, 16103, 16375, 16646, 16914, 17180, 17444, 17704, 17963, 18218, 18470, 18719, + 18964, 19206, 19445, 19680, 19911, 20138, 20361, 20580, 20795, 21006, 21212, 21414, 21611, 21804, + 21992, 22175, 22354, 22527, 22696, 22860, 23018, 23172, 23321, 23464, 23603, 23736, 23864, 23988, + 24106, 24218, 24326, 24428, 24525, 24618, 24705, 24786, 24863, 24935, 25002, 25064, 25121, 25174, + 25221, 25264, 25303, 25336, 25366, 25391, 25412, 25428, 25441, 25450, 25455, 25456, 25454, 25448, + 25439, 25427, 25412, 25394, 25373, 25350, 25324, 25296, 25265, 25233, 25198, 25162, 25124, 25085, + 25045, 25003, 24960, 24916, 24871, 24826, 24780, 24734, 24688, 24641, 24595, 24548, 24502, 24457, + 24412, 24367, 24334, 24287, 24244, 24202, 24162, 24123, 24086, 24051, 24018, 23987, 23957, 23929, + 23902, 23878, 23855, 23833, 23813, 23795, 23778, 23763, 23749, 23737, 23726, 23717, 23709, 23702, + 23696, 23692, 23689, 23687, 23687, 23687, 23689, 23691, 23695, 23699, 23705, 23711, 23718, 23726, + 23735, 23744, 23754, 23764, 23776, 23787, 23799, 23812, 23825, 23838, 23852, 23866, 23880, 23894, + 23909, 23923, -23938, -23952, -23967, -23981, -23995, -24009, -24023, -24036, -24049, -24062, -24074, -24086, + -24097, -24108, -24118, -24128, -24137, -24145, -24152, -24158, -24164, -24168, -24172, -24175, -24176, -24177, + -24176, -24174, -24171, -24167, -24161, -24154, -24146, -24136, -24125, -24113, -24099, -24083, -24066, -24048, + -24028, -24006, -23983, -23958, -23932, -23904, -23874, -23843, -23810, -23775, -23739, -23701, -23662, -23621, + -23579, -23533, -23474, -23423, -23367, -23309, -23248, -23184, -23117, -23047, -22974, -22896, -22816, -22732, + -22643, -22551, -22455, -22355, -22251, -22143, -22030, -21913, -21791, -21665, -21534, -21399, -21259, -21114, + -20964, -20810, -20651, -20488, -20319, -20146, -19968, -19785, -19598, -19405, -19208, -19007, -18801, -18590, + -18375, -18156, -17932, -17704, -17472, -17236, -16996, -16752, -16505, -16254, -16000, -15743, -15482, -15219, + -14953, -14684, -14412, -14139, -13863, -13586, -13306, -13025, -12743, -12459, -12174, -11889, -11603, -11316, + -11029, -10742, -10455, -10168, -9882, -9597, -9313, -9029, -8748, -8467, -8189, -7912, -7638, -7367, + -7097, -6831, -6568, -6308, -6052, -5799, -5550, -5305, -5065, -4828, -4597, -4369, -4147, -3930, + -3718, -3511, -3310, -3113, -2923, -2738, -2559, -2386, -2219, -2057, -1902, -1753, -1610, -1474, + -1344, -1220, -1102, -991, -887, -788, -697, -611, -532, -459, -393, -332, -277, -228, + -184, -145, -111, -86}; + +RAM_ALIGN const Word16 LowDelayShapes_n960_N360_7_5ms[636] = { + 34, 43, 53, 63, 74, 87, 101, 116, 132, 149, 168, 188, 209, 232, + 256, 282, 309, 338, 368, 400, 434, 469, 506, 544, 584, 626, 669, 715, + 761, 810, 860, 912, 966, 1021, 1078, 1137, 1198, 1260, 1325, 1391, 1458, 1528, + 1599, 1673, 1747, 1824, 1903, 1983, 2065, 2149, 2235, 2322, 2411, 2502, 2595, 2690, + 2786, 2884, 2983, 3085, 3188, 3293, 3399, 3507, 3617, 3728, 3841, 3955, 4071, 4188, + 4307, 4428, 4550, 4673, 4798, 4924, 5051, 5180, 5310, 5442, 5574, 5708, 5843, 5979, + 6116, 6255, 6394, 6534, 6676, 6818, 6961, 7106, 7251, 7397, 7543, 7691, 7839, 7988, + 8137, 8288, 8438, 8590, 8741, 8894, 9046, 9199, 9353, 9507, 9661, 9815, 9969, 10124, + 10279, 10434, 10588, 10743, 10898, 11053, 11207, 11362, 11516, 11670, 11823, 11976, 12129, 12282, + 12434, 12585, 12736, 12886, 13036, 13185, 13333, 13481, 13628, 13774, 13919, 14064, 14207, 14349, + 14491, 14631, 14771, 14909, 15046, 15183, 15317, 15451, 15584, 15715, 15845, 15973, 16100, 16226, + 16350, 16473, 16595, 16715, 16833, 16950, 17065, 17179, 17292, 17402, 17511, 17619, 17724, 17829, + 17931, 18032, 18130, 18228, 18323, 18417, 18508, 18598, 18687, 18773, 18858, 18941, 19021, 19101, + 19178, 19253, 19327, 19398, 19468, 19536, 19602, 19666, 19729, 19789, 19847, 19904, 19959, 20012, + 20063, 20112, 20160, 20205, 20249, 20291, 20331, 20369, 20405, 20440, 20473, 20504, 20533, 20561, + 20587, 20611, 20634, 20654, 20674, 20691, 20707, 20722, 20735, 20746, 20756, 20764, 20771, 20777, + 20781, 20783, 20785, 20785, 20784, 20781, 20777, 20773, 20767, 20759, 20751, 20742, 20732, 20720, + 20708, 20695, 20681, 20666, 20650, 20633, 20616, 20598, 20579, 20560, 20540, 20519, 20498, 20477, + 20455, 20432, 20409, 20386, 20362, 20338, 20314, 20289, 20264, 20239, 20214, 20189, 20164, 20138, + 20113, 20088, 20063, 20037, 20012, 19988, 19963, 19939, 19914, 19891, 19874, 19849, 19825, 19801, + 19778, 19755, 19733, 19712, 19691, 19671, 19652, 19633, 19615, 19598, 19581, 19565, 19549, 19534, + 19520, 19506, 19493, 19480, 19468, 19457, 19446, 19436, 19426, 19417, 19408, 19400, 19393, 19386, + 19380, 19374, 19368, 19363, 19359, 19355, 19352, 19349, 19346, 19344, 19342, 19341, 19340, 19340, + 19340, 19341, 19341, 19343, 19344, 19346, 19348, 19351, 19354, 19357, 19361, 19365, 19369, 19373, + 19378, 19383, 19388, 19394, 19399, 19405, 19411, 19417, 19424, 19430, 19437, 19444, 19451, 19458, + 19466, 19473, 19481, 19488, 19496, 19504, 19512, 19519, 19527, 19535, -19543, -19551, -19559, -19567, + -19574, -19582, -19590, -19598, -19605, -19613, -19620, -19627, -19634, -19641, -19648, -19655, -19661, -19668, + -19674, -19680, -19686, -19691, -19696, -19701, -19706, -19711, -19715, -19719, -19723, -19726, -19729, -19732, + -19734, -19736, -19737, -19739, -19740, -19740, -19740, -19740, -19739, -19738, -19736, -19734, -19731, -19728, + -19725, -19721, -19716, -19711, -19706, -19700, -19693, -19686, -19679, -19671, -19662, -19653, -19643, -19632, + -19622, -19610, -19598, -19585, -19572, -19558, -19544, -19529, -19513, -19497, -19481, -19463, -19445, -19427, + -19408, -19388, -19368, -19347, -19325, -19303, -19281, -19258, -19234, -19209, -19175, -19146, -19117, -19087, + -19056, -19024, -18991, -18956, -18921, -18885, -18847, -18808, -18768, -18727, -18684, -18640, -18595, -18548, + -18500, -18451, -18400, -18348, -18294, -18239, -18182, -18124, -18064, -18003, -17940, -17875, -17809, -17741, + -17671, -17600, -17528, -17453, -17377, -17299, -17219, -17138, -17055, -16970, -16884, -16795, -16705, -16614, + -16520, -16425, -16328, -16230, -16129, -16027, -15923, -15818, -15711, -15602, -15491, -15379, -15265, -15150, + -15033, -14914, -14794, -14672, -14549, -14424, -14297, -14170, -14041, -13910, -13778, -13645, -13510, -13374, + -13237, -13099, -12959, -12819, -12677, -12534, -12390, -12245, -12099, -11952, -11805, -11656, -11507, -11357, + -11206, -11055, -10903, -10750, -10597, -10443, -10289, -10134, -9979, -9824, -9668, -9512, -9356, -9200, + -9044, -8888, -8732, -8575, -8419, -8263, -8108, -7952, -7797, -7642, -7488, -7334, -7181, -7028, + -6876, -6724, -6573, -6423, -6274, -6125, -5978, -5832, -5686, -5542, -5398, -5256, -5116, -4976, + -4838, -4701, -4565, -4431, -4299, -4168, -4038, -3911, -3784, -3660, -3537, -3416, -3297, -3180, + -3064, -2951, -2839, -2729, -2622, -2516, -2412, -2311, -2211, -2114, -2018, -1925, -1834, -1745, + -1658, -1574, -1492, -1412, -1334, -1258, -1185, -1114, -1046, -980, -916, -854, -795, -738, + -683, -631, -581, -533, -488, -445, -404, -366, -329, -295, -263, -233, -206, -180, + -156, -134, -114, -95, -79, -62}; + +const Word16 *const LowDelayShapes_n960_7_5ms[5] = { + LowDelayShapes_n960_N60_7_5ms, LowDelayShapes_n960_N120_7_5ms, LowDelayShapes_n960_N180_7_5ms, + LowDelayShapes_n960_N240_7_5ms, LowDelayShapes_n960_N360_7_5ms}; +# endif +#endif + +# ifdef ENABLE_HR_MODE +# ifdef SUBSET_NB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_8000_frame_ms_100[130] = { + -961400, -2849747, -6146069, -11183287, -18168658, -27159976, -38041614, -50544991, -64266305, + -78702302, -93275005, -107359966, -120331449, -131585369, -140567185, -146788394, -149841031, -149374845, + -145077849, -136659567, -123818556, -106218681, -83483575, -55188103, -20866242, 19967468, 67769998, + 122921021, 185652202, 255975827, 333632994, 418021593, 508185345, 602779388, 700109939, 798161092, + 894722554, 987480940, 1074157272, 1152645644, 1221190247, 1278509567, 1323911980, 1357388583, 1379593462, + 1391784272, 1395720478, 1393489246, 1387290092, 1379158144, 1370909958, 1362952657, 1356680081, 1351822616, + 1348129706, 1345389974, 1343434137, 1342132875, 1341380238, 1341082389, 1341146030, 1341475565, 1341976666, + 1342558820, 1343143270, 1343665484, 1344082633, 1344377759, 1344564351, 1344687981, 1344819951, 1345048163, + 1345462207, 1346140636, 1347141158, 1348493131, 1350195802, 1352216474, 1354492706, 1356936321, -1359440659, + -1361893201, -1364185723, -1366227332, -1367952395, -1369325253, -1370343007, -1371033982, -1371456025, -1371688758, + -1371823378, -1371949513, -1372139932, -1372441219, -1372867302, -1373401073, -1373998949, -1374594994, -1375108467, + -1375446347, -1375511619, -1375206190, -1374435007, -1373103717, -1371107592, -1368321163, -1364583182, -1359697421, + -1353439826, -1345583929, -1334252006, -1318640435, -1296625734, -1266042179, -1224814360, -1171299094, -1104589425, + -1024691930, -932610693, -830326556, -720679178, -607287900, -494260157, -385949065, -286606097, -199964372, + -128792415, -74461791, -36690922, -13577456 }; +# else +# define MDCT_WINDOW_FS_8000_frame_ms_100 NULL +# endif +# ifdef SUBSET_WB +Word32 MDCT_WINDOW_FS_16000_frame_ms_100[260] = { + -887375, -1872204, -3197066, -4988439, -7310990, -10227337, -13783209, -18021567, -22958367, + -28610377, -34970773, -42018157, -49718535, -58023758, -66873408, -76198163, -85910142, -95927481, + -106148057, -116469926, -126789141, -136988509, -146961365, -156599505, -165784108, -174413613, -182384155, + -189593925, -195957243, -201380750, -205787662, -209112092, -211278626, -212225338, -211904063, -210251417, + -207219014, -202758648, -196811500, -189330359, -180258003, -169532917, -157095614, -142881796, -126812734, + -108824087, -88825077, -66738724, -42479347, -15962398, 12903137, 44189991, 77985216, 114347898, + 153341694, 195002709, 239360583, 286415769, 336147305, 388513668, 443439084, 500814289, 560507827, + 622347139, 686131895, 751624641, 818548945, 886612081, 955480469, 1024792378, 1094174334, 1163233060, + 1231563801, 1298756609, 1364398281, 1428080024, 1489417472, 1548030726, 1603570137, 1655722624, 1704220353, + 1748832761, 1789380048, 1825732185, 1857837021, 1885694068, 1909350182, 1928926255, 1944599555, 1956591988, + 1965173692, 1970654814, 1973392048, 1973753741, 1972126549, 1968905622, 1964477747, 1959200677, 1953414096, + 1947497068, 1941982397, 1935699544, 1930081097, 1925079908, 1920651209, 1916744799, 1913315837, 1910318315, + 1907712617, 1905458724, 1903525160, 1901880657, 1900501434, 1899362031, 1898444320, 1897728470, 1897199074, + 1896837448, 1896629442, 1896556474, 1896603942, 1896753023, 1896988900, 1897292512, 1897649018, 1898040860, + 1898455207, 1898875282, 1899290274, 1899686952, 1900057791, 1900392969, 1900688703, 1900940068, 1901148890, + 1901315261, 1901446916, 1901549632, 1901635772, 1901716579, 1901808596, 1901925470, 1902085313, 1902301944, + 1902593430, 1902971628, 1903450623, 1904038863, 1904746055, 1905575675, 1906532421, 1907613683, 1908818837, + 1910139810, 1911570484, 1913097876, 1914709921, 1916389064, 1918119705, 1919880868, -1921655075, -1923419485, + -1925156475, -1926844779, -1928468408, -1930009301, -1931454857, -1932791495, -1934012556, -1935109403, -1936080977, + -1936924245, -1937643651, -1938242459, -1938730331, -1939115713, -1939412840, -1939633721, -1939796733, -1939915942, + -1940009808, -1940092245, -1940180131, -1940284940, -1940419293, -1940589100, -1940802279, -1941058948, -1941361010, + -1941703474, -1942082515, -1942488131, -1942912654, -1943342567, -1943766803, -1944168168, -1944533482, -1944844704, + -1945086561, -1945239453, -1945288139, -1945213300, -1944999989, -1944629251, -1944086772, -1943353711, -1942414745, + -1941250214, -1939842441, -1938166561, -1936199807, -1933912258, -1931274378, -1928248720, -1924799179, -1920884332, + -1916465285, -1911499377, -1905951172, -1899784891, -1891449639, -1882086102, -1871092605, -1858022426, -1842504117, + -1824150091, -1802570281, -1777395508, -1748280284, -1714926445, -1677106435, -1634654127, -1587483810, -1535592652, + -1479074019, -1418108336, -1352953154, -1283959587, -1211573312, -1136287716, -1058670176, -979383239, -899114678, + -818587615, -738568308, -659827651, -583145988, -509279027, -438949979, -372825231, -311497711, -255465040, + -205107348, -160673323, -122260482, -89825442, -63156242, -41931466, -25668784, -12980788 }; +# else +# define MDCT_WINDOW_FS_16000_frame_ms_100 NULL +# endif +# ifdef SUBSET_SSWB +Word32 MDCT_WINDOW_FS_24000_frame_ms_100[390] = { + -566705, -1110129, -1685050, -2404955, -3290604, -4357398, -5620992, -7096870, -8797110, + -10732247, -12913348, -15346312, -18033576, -20979359, -24186040, -27648819, -31361639, -35319387, + -39511857, -43926672, -48550894, -53369201, -58364329, -63516998, -68804773, -74208337, -79706124, + -85271101, -90877590, -96504202, -102123140, -107704698, -113222623, -118652834, -123968611, -129140789, + -134141816, -138946789, -143532274, -147872644, -151941696, -155718471, -159183810, -162313004, -165085094, + -167485061, -169496638, -171101141, -172281631, -173021519, -173310456, -173136812, -172483214, -171335676, + -169686052, -167521471, -164827705, -161591409, -157800875, -153444385, -148507128, -142973353, -136828628, + -130059834, -122650769, -114582255, -105836248, -96398529, -86248633, -75363800, -63725732, -51315501, + -38111620, -24094261, -9239538, 6471742, 23056447, 40536457, 58931280, 78254053, 98521159, + 119745967, 141936970, 165102364, 189247343, 214372698, 240474371, 267544931, 295575426, 324551903, + 354450456, 385246198, 416908490, 449403326, 482689758, 516718794, 551441284, 586801891, 622731215, + 659163373, 696029684, 733249762, 770740975, 808417324, 846185475, 883956761, 921637043, 959124688, + 996324031, 1033136615, 1069460208, 1105195788, 1140244773, 1174510921, 1207903363, 1240329980, 1271701586, + 1301936917, 1330960546, 1358704531, 1385106661, 1410109035, 1433668094, 1455740664, 1476295686, 1495314659, + 1512790051, 1528721877, 1543118961, 1555993720, 1567377327, 1577311901, 1585840140, 1593017314, 1598905809, + 1603572858, 1607094048, 1609553036, 1611038032, 1611639187, 1611445924, 1610554709, 1609062783, 1607062660, + 1604647205, 1601904616, 1598915994, 1595761439, 1592514651, 1589411075, 1586578699, 1582990467, 1579691165, + 1576632996, 1573802167, 1571187222, 1568776964, 1566559220, 1564523108, 1562656830, 1560950303, 1559392538, + 1557974462, 1556686097, 1555520279, 1554467590, 1553522528, 1552677071, 1551926380, 1551264122, 1550685851, + 1550186120, 1549761554, 1549406743, 1549118648, 1548892484, 1548724782, 1548611579, 1548548556, 1548532064, + 1548557824, 1548622043, 1548720068, 1548848512, 1549002557, 1549178941, 1549372811, 1549581179, 1549799479, + 1550025081, 1550253392, 1550482320, 1550707996, 1550928257, 1551140242, 1551341918, 1551531258, 1551707132, + 1551867783, 1552012940, 1552142171, 1552255441, 1552353722, 1552437360, 1552508729, 1552569181, 1552621341, + 1552667742, 1552711935, 1552756861, 1552806540, 1552864321, 1552934727, 1553021212, 1553127838, 1553258419, + 1553416594, 1553605935, 1553829154, 1554089545, 1554389317, 1554730803, 1555115388, 1555544621, 1556019161, + 1556539764, 1557105744, 1557717296, 1558373006, 1559071819, 1559811599, 1560590143, 1561405090, 1562252936, + 1563130339, 1564033457, 1564958401, 1565900358, 1566855101, 1567817123, -1568783655, -1569746861, -1570703949, + -1571649364, -1572578812, -1573487389, -1574371102, -1575225988, -1576048579, -1576835227, -1577583436, -1578290863, + -1578955234, -1579575367, -1580149723, -1580678399, -1581160607, -1581597028, -1581988259, -1582335808, -1582641029, + -1582906248, -1583133678, -1583326640, -1583487877, -1583621010, -1583729737, -1583817938, -1583889747, -1583948684, + -1583999362, -1584045193, -1584090279, -1584137621, -1584190841, -1584252527, -1584325358, -1584410718, -1584511035, + -1584626668, -1584758614, -1584906848, -1585070936, -1585250612, -1585444090, -1585650227, -1585866958, -1586092212, + -1586323072, -1586557326, -1586791018, -1587022005, -1587245580, -1587459040, -1587657701, -1587838487, -1587996409, + -1588128112, -1588228637, -1588294501, -1588320923, -1588304007, -1588239369, -1588123278, -1587951328, -1587719494, + -1587424275, -1587060842, -1586626176, -1586114863, -1585523601, -1584847006, -1584080761, -1583218674, -1582256132, + -1581185350, -1580001184, -1578694604, -1577258975, -1575684935, -1573964180, -1572086641, -1570043344, -1567823810, + -1565418712, -1562817696, -1560011672, -1556991601, -1553746487, -1550232508, -1545614483, -1540661510, -1535326382, + -1529347469, -1522634820, -1515104434, -1506662411, -1497214433, -1486667044, -1474925134, -1461899585, -1447505979, + -1431661421, -1414293801, -1395342396, -1374757780, -1352499694, -1328538688, -1302862307, -1275470003, -1246373968, + -1215606643, -1183212323, -1149244754, -1113774081, -1076886070, -1038679407, -999271421, -958778521, -917331256, + -875071965, -832168635, -788780400, -745078907, -701235665, -657439320, -613872407, -570722470, -528178104, + -486428392, -445655594, -406038238, -367747699, -330944214, -295781070, -262392452, -230898968, -201404745, + -173990773, -148716671, -125619512, -104711740, -85981071, -69390841, -54880490, -42367028, -31748204, + -22909680, -15677896, -8320202 }; +# else +# define MDCT_WINDOW_FS_24000_frame_ms_100 NULL +# endif +# ifdef SUBSET_SWB +Word32 MDCT_WINDOW_FS_32000_frame_ms_100[520] = { + -410329, -796949, -1136328, -1530183, -1997206, -2544529, -3177199, -3900727, -4721409, + -5644580, -6674901, -7816606, -9073542, -10449649, -11947654, -13568981, -15314575, -17185616, + -19183576, -21308469, -23557934, -25929130, -28420717, -31030313, -33753791, -36586142, -39522623, + -42558881, -45688908, -48905915, -52203334, -55573600, -59008578, -62500911, -66043225, -69627153, + -73242249, -76878656, -80528547, -84184130, -87834359, -91467738, -95074499, -98645962, -102173556, + -105646999, -109055430, -112389025, -115637823, -118792264, -121843979, -124784385, -127604158, -130292837, + -132842231, -135246333, -137497670, -139586545, -141504332, -143245396, -144804682, -146175706, -147351477, + -148325994, -149093197, -149646348, -149980871, -150094482, -149982174, -149636889, -149052616, -148226262, + -147155224, -145834061, -144257234, -142420419, -140318794, -137947501, -135302755, -132379903, -129173499, + -125677248, -121885484, -117793976, -113398013, -108690888, -103666131, -98316590, -92636250, -86619948, + -80260566, -73550172, -66480755, -59045143, -51237113, -43048956, -34473252, -25502546, -16127957, + -6341514, 3862818, 14491541, 25552349, 37053485, 49000846, 61399638, 74255377, 87574137, + 101359692, 115615618, 130345077, 145550314, 161232640, 177393068, 194030243, 211141818, 228724496, + 246775667, 265291298, 284263733, 303683434, 323542122, 343829307, 364532416, 385638632, 407133703, + 428999825, 451218622, 473771892, 496640476, 519799290, 543222449, 566886347, 590766871, 614834881, + 639060282, 663412218, 687860455, 712370477, 736908535, 761442526, 785938885, 810359699, 834668800, + 858831376, 882812136, 906573323, 930077938, 953289749, 976173461, 998692986, 1020814305, 1042504195, + 1063729320, 1084456529, 1104654343, 1124293323, 1143346837, 1161788685, 1179595571, 1196744793, 1213214499, + 1228990130, 1244053625, 1258390343, 1271989157, 1284842646, 1296945646, 1308295983, 1318894029, 1328742964, + 1337845893, 1346207620, 1353840346, 1360760354, 1366981286, 1372519590, 1377396138, 1381633759, 1385255026, + 1388285177, 1390752262, 1392686884, 1394119237, 1395082423, 1395609697, 1395734288, 1395488163, 1394907750, + 1394029226, 1392887172, 1391513953, 1389943438, 1388208885, 1386340921, 1384367440, 1382316364, 1380214130, + 1378106162, 1376182641, 1374415552, 1372026612, 1369811233, 1367710559, 1365724178, 1363849407, 1362082203, + 1360417744, 1358852161, 1357381258, 1356001076, 1354706993, 1353494673, 1352361089, 1351302228, 1350313689, + 1349392506, 1348535330, 1347739116, 1347001032, 1346317031, 1345686404, 1345105561, 1344572298, 1344084536, + 1343640384, 1343238137, 1342875748, 1342550922, 1342263301, 1342010831, 1341791477, 1341604203, 1341447356, + 1341320237, 1341220346, 1341146654, 1341097800, 1341072665, 1341069082, 1341085615, 1341121386, 1341174740, + 1341243587, 1341326852, 1341422956, 1341530950, 1341648658, 1341774344, 1341907686, 1342046793, 1342189996, + 1342336371, 1342484315, 1342633509, 1342781772, 1342928111, 1343072442, 1343213120, 1343349339, 1343480101, + 1343605189, 1343724192, 1343836029, 1343940104, 1344037064, 1344126250, 1344207727, 1344281010, 1344347228, + 1344406398, 1344458631, 1344504740, 1344545486, 1344582197, 1344614878, 1344644716, 1344673602, 1344702406, + 1344732123, 1344764116, 1344799913, 1344841581, 1344889533, 1344945396, 1345011275, 1345087987, 1345177164, + 1345279600, 1345397199, 1345531309, 1345682002, 1345850876, 1346039023, 1346247352, 1346476070, 1346725599, + 1346997017, 1347290788, 1347606421, 1347944342, 1348304546, 1348687326, 1349091759, 1349517389, 1349964590, + 1350432001, 1350919119, 1351424549, 1351948150, 1352488782, 1353044492, 1353614173, 1354196920, 1354791164, + 1355395130, 1356006741, 1356625062, 1357248513, 1357874066, -1358501833, -1359127963, -1359752565, -1360372594, + -1360986451, -1361593178, -1362190669, -1362777107, -1363350886, -1363911059, -1364456475, -1364985125, -1365495818, + -1365988370, -1366461329, -1366914145, -1367345397, -1367755425, -1368143727, -1368509329, -1368852492, -1369173176, + -1369471783, -1369747786, -1370001627, -1370234382, -1370446455, -1370638040, -1370810046, -1370963570, -1371100229, + -1371220085, -1371324505, -1371415420, -1371493639, -1371560818, -1371617789, -1371666695, -1371709196, -1371745710, + -1371778346, -1371808661, -1371838047, -1371867517, -1371897959, -1371931304, -1371968763, -1372010342, -1372057396, + -1372110702, -1372171094, -1372238686, -1372313498, -1372396683, -1372487751, -1372586771, -1372693072, -1372807320, + -1372928910, -1373056739, -1373190393, -1373329652, -1373473500, -1373621114, -1373770813, -1373922515, -1374075203, + -1374226645, -1374376513, -1374523166, -1374665655, -1374802265, -1374931057, -1375051695, -1375162397, -1375260925, + -1375346302, -1375416903, -1375471622, -1375508310, -1375525267, -1375521592, -1375495812, -1375445706, -1375370134, + -1375267707, -1375137383, -1374976617, -1374784711, -1374559999, -1374301455, -1374007032, -1373674676, -1373304076, + -1372892947, -1372439276, -1371941405, -1371397503, -1370805562, -1370163465, -1369467701, -1368717718, -1367909588, + -1367040649, -1366108055, -1365108685, -1364039842, -1362897427, -1361677778, -1360378277, -1358995048, -1357523990, + -1355961737, -1354304757, -1352549921, -1350693234, -1348731568, -1346663222, -1344488796, -1342151873, -1339094859, + -1335868526, -1332575618, -1329015998, -1325134514, -1320899332, -1316281926, -1311249778, -1305767783, -1299801189, + -1293316467, -1286278496, -1278652937, -1270407089, -1261510752, -1251931832, -1241641304, -1230612600, -1218823121, + -1206251778, -1192882032, -1178699247, -1163691417, -1147850058, -1131172617, -1113659053, -1095312137, -1076139342, + -1056154695, -1035374650, -1013817533, -991505119, -968465043, -944729088, -920331658, -895311402, -869713787, + -843580319, -816956722, -789893244, -762442487, -734669461, -706629428, -678385082, -649998064, -621530231, + -593051422, -564628794, -536328929, -508220768, -480373259, -452855166, -425735746, -399081503, -372957401, + -347428629, -322556345, -298398778, -275013415, -252453167, -230765335, -209993816, -190178661, -171354066, + -153547820, -136781064, -121069202, -106422336, -92843298, -80326106, -68858674, -58425411, -49003701, + -40559788, -33054527, -26453090, -20722011, -15806421, -11453718, -6043487 }; +# else +# define MDCT_WINDOW_FS_32000_frame_ms_100 NULL +# endif +# ifdef SUBSET_FB +Word32 MDCT_WINDOW_FS_48000_frame_ms_100[780] = { + -260941, -512326, -694531, -879311, -1080918, -1308853, -1562751, -1845827, -2158684, + -2503004, -2880077, -3290946, -3737685, -4221002, -4742864, -5303548, -5904756, -6546614, + -7230857, -7957740, -8729060, -9544323, -10404756, -11309433, -12259734, -13255019, -14296724, + -15384139, -16518209, -17697344, -18921986, -20190385, -21503384, -22859520, -24259194, -25700342, + -27183029, -28705009, -30266328, -31864635, -33500032, -35169872, -36873876, -38609380, -40375887, + -42170731, -43993030, -45839524, -47709533, -49600244, -51511244, -53439376, -55383757, -57340675, + -59308752, -61284610, -63267293, -65253972, -67243943, -69233263, -71220507, -73201745, -75175694, + -77138930, -79090353, -81026756, -82947219, -84848184, -86728232, -88583507, -90412766, -92212306, + -93980997, -95715499, -97414829, -99075933, -100697747, -102276727, -103811934, -105299541, -106738717, + -108126346, -109462104, -110743333, -111969072, -113135967, -114242829, -115286640, -116267230, -117181898, + -118030913, -118811562, -119523250, -120163192, -120730923, -121223904, -121641755, -121981772, -122243774, + -122425704, -122528356, -122549198, -122488317, -122342868, -122112204, -121794056, -121388712, -120894363, + -120311595, -119637953, -118873094, -118014671, -117062760, -116014831, -114871079, -113629173, -112289425, + -110849719, -109309933, -107667532, -105922420, -104072007, -102115976, -100051888, -97879875, -95597465, + -93204875, -90699195, -88080200, -85345024, -82492843, -79520968, -76429175, -73215366, -69879179, + -66417490, -62829616, -59111848, -55264005, -51283182, -47168943, -42918760, -38531620, -34004372, + -29336594, -24525462, -19570192, -14467231, -9215895, -3812888, 1741410, 7449630, 13312759, + 19333517, 25513103, 31854549, 38357631, 45024786, 51855914, 58853769, 66018789, 73353520, + 80857218, 88531868, 96377212, 104395033, 112584867, 120948431, 129484622, 138194897, 147077806, + 156134120, 165362222, 174762717, 184333381, 194074737, 203984869, 214063752, 224308471, 234717970, + 245288658, 256019674, 266907692, 277950967, 289145264, 300489211, 311977987, 323609345, 335378203, + 347280982, 359312288, 371469093, 383745604, 396138434, 408640853, 421247404, 433950689, 446746484, + 459627611, 472589454, 485624370, 498725842, 511885724, 525097999, 538353697, 551646906, 564968308, + 578310445, 591664155, 605022969, 618377829, 631721846, 645044713, 658338326, 671592921, 684801497, + 697954218, 711043692, 724059806, 736994360, 749837478, 762581648, 775216823, 787735715, 800128161, + 812386829, 824502387, 836468309, 848275065, 859915578, 871380881, 882663894, 893755956, 904651429, + 915341669, 925821650, 936083534, 946122397, 955931903, 965507514, 974842174, 983932079, 992771963, + 1001359538, 1009689065, 1017758097, 1025562027, 1033099052, 1040366302, 1047363095, 1054086968, 1060539102, + 1066717272, 1072622704, 1078255082, 1083616279, 1088705978, 1093526428, 1098077639, 1102363841, 1106387711, + 1110154526, 1113666093, 1116927603, 1119941829, 1122715077, 1125251563, 1127558143, 1129638911, 1131501374, + 1133150240, 1134593560, 1135837167, 1136890075, 1137758087, 1138450616, 1138974310, 1139338430, 1139549551, + 1139617253, 1139547254, 1139350624, 1139033981, 1138607794, 1138078811, 1137457063, 1136748191, 1135963275, + 1135107610, 1134191756, 1133220410, 1132203794, 1131145038, 1130056206, 1128938553, 1127804154, 1126651875, + 1125505224, 1124387956, 1123424960, 1122502936, 1121204059, 1119950632, 1118742198, 1117576653, 1116454214, + 1115372925, 1114332841, 1113331819, 1112370092, 1111445403, 1110557933, 1109705650, 1108888492, 1108104203, + 1107353139, 1106633126, 1105944161, 1105284140, 1104653414, 1104049906, 1103473745, 1102922793, 1102397465, + 1101895930, 1101418393, 1100962642, 1100529407, 1100117107, 1099725702, 1099353203, 1099000764, 1098666499, + 1098350488, 1098051309, 1097769862, 1097504226, 1097255015, 1097020632, 1096801846, 1096597180, 1096407228, + 1096230254, 1096067339, 1095917048, 1095779800, 1095654043, 1095540974, 1095438919, 1095348396, 1095268166, + 1095199173, 1095139611, 1095090409, 1095050175, 1095019519, 1094996963, 1094983471, 1094977391, 1094979525, + 1094988385, 1095004796, 1095027271, 1095056499, 1095090869, 1095131425, 1095176627, 1095227052, 1095281232, + 1095340201, 1095402343, 1095468278, 1095536534, 1095608171, 1095681620, 1095757514, 1095834402, 1095913392, + 1095992947, 1096073625, 1096154019, 1096235421, 1096316155, 1096396797, 1096476293, 1096555751, 1096633346, + 1096710075, 1096784773, 1096858327, 1096929351, 1096998877, 1097065514, 1097130458, 1097192392, 1097252182, + 1097308660, 1097363134, 1097414177, 1097462864, 1097508260, 1097551529, 1097591240, 1097628824, 1097663320, + 1097695680, 1097724878, 1097752577, 1097777519, 1097800889, 1097821938, 1097842083, 1097860192, 1097877707, + 1097893767, 1097909925, 1097925238, 1097941056, 1097956579, 1097973457, 1097990704, 1098009705, 1098029761, + 1098052600, 1098077182, 1098104865, 1098135087, 1098169468, 1098206820, 1098248699, 1098294539, 1098345796, + 1098401373, 1098462829, 1098529452, 1098602617, 1098681182, 1098766743, 1098858507, 1098957729, 1099063375, + 1099176931, 1099297350, 1099425943, 1099561602, 1099705648, 1099857107, 1100017184, 1100184629, 1100360829, + 1100544624, 1100737006, 1100936785, 1101145313, 1101361273, 1101585583, 1101817094, 1102057069, 1102303875, + 1102558446, 1102819734, 1103088684, 1103363640, 1103645734, 1103933619, 1104228082, 1104527573, 1104833025, + 1105142974, 1105458288, 1105777328, 1106100968, 1106427742, 1106758401, 1107091175, 1107426928, 1107764262, + 1108103811, 1108443736, 1108785137, -1109126464, -1109468075, -1109808418, -1110148595, -1110486758, -1110823540, + -1111157536, -1111489609, -1111817975, -1112143382, -1112464352, -1112781755, -1113093934, -1113401755, -1113703734, + -1114000803, -1114291390, -1114576277, -1114854097, -1115125982, -1115390248, -1115647841, -1115897690, -1116140732, + -1116375302, -1116602670, -1116821661, -1117033199, -1117235935, -1117431235, -1117617882, -1117796873, -1117967024, + -1118129738, -1118283734, -1118430232, -1118568236, -1118699084, -1118821642, -1118937239, -1119044805, -1119145850, + -1119239316, -1119326479, -1119406526, -1119481081, -1119548979, -1119611618, -1119668271, -1119720525, -1119767262, + -1119809963, -1119848051, -1119883112, -1119913933, -1119942166, -1119967238, -1119990533, -1120010991, -1120030373, + -1120047967, -1120065185, -1120081021, -1120097158, -1120112780, -1120129265, -1120145650, -1120163521, -1120181998, + -1120202553, -1120224032, -1120247880, -1120273333, -1120301601, -1120331401, -1120364428, -1120399639, -1120438004, + -1120478543, -1120522718, -1120569068, -1120618782, -1120670906, -1120726540, -1120784227, -1120845302, -1120908575, + -1120974930, -1121043024, -1121114079, -1121186673, -1121261863, -1121338234, -1121416691, -1121496045, -1121577316, + -1121658638, -1121741144, -1121823756, -1121907065, -1121989354, -1122071945, -1122153400, -1122234287, -1122313032, + -1122390771, -1122466015, -1122539413, -1122609356, -1122676929, -1122740622, -1122801070, -1122856613, -1122908312, + -1122954661, -1122996249, -1123031496, -1123061471, -1123084522, -1123101354, -1123110442, -1123112631, -1123106394, + -1123092556, -1123069422, -1123037982, -1122996721, -1122946267, -1122885196, -1122814464, -1122732221, -1122639444, + -1122534864, -1122419021, -1122290207, -1122149656, -1121995788, -1121829044, -1121647967, -1121453676, -1121244410, + -1121020792, -1120781333, -1120526836, -1120255693, -1119968555, -1119663488, -1119341437, -1119000986, -1118642248, + -1118263342, -1117865480, -1117446686, -1117006965, -1116544763, -1116060878, -1115553126, -1115021782, -1114465065, + -1113883468, -1113274918, -1112639632, -1111975615, -1111283324, -1110560756, -1109808026, -1109023086, -1108206431, + -1107355953, -1106471748, -1105551963, -1104596956, -1103604680, -1102575570, -1101507722, -1100401422, -1099254985, + -1098068882, -1096841318, -1095572135, -1093824443, -1092028958, -1090297711, -1088504795, -1086622918, -1084627237, + -1082515433, -1080275819, -1077903929, -1075390736, -1072729748, -1069911131, -1066927638, -1063770248, -1060430896, + -1056901504, -1053173546, -1049238310, -1045087876, -1040714437, -1036109920, -1031267875, -1026179775, -1020838674, + -1015237521, -1009370093, -1003230227, -996813209, -990113245, -983126698, -975849235, -968277852, -960408557, + -952239544, -943768000, -934993585, -925915442, -916534205, -906849190, -896862428, -886574831, -875990255, + -865111684, -853943783, -842489873, -830755484, -818745230, -806465779, -793923840, -781127868, -768084617, + -754803973, -741294413, -727567055, -713632929, -699502178, -685184041, -670691428, -656036019, -641230326, + -626286760, -611223511, -596053211, -580789367, -565447177, -550042966, -534590207, -519104101, -503600887, + -488098220, -472611780, -457157918, -441752495, -426412611, -411154642, -395995557, -380951672, -366040108, + -351277307, -336679493, -322262126, -308041137, -294032383, -280251079, -266711613, -253427888, -240414233, + -227684137, -215250748, -203125310, -191319486, -179843288, -168707738, -157921160, -147492810, -137428529, + -127735992, -118418783, -109483185, -100930269, -92764786, -84984919, -77594007, -70587122, -63966522, + -57723857, -51860743, -46364893, -41238076, -36463273, -32043815, -27956560, -24209143, -20769591, + -17655994, -14819879, -12293428, -9917917, -7494462, -3886267 }; +# else +# define MDCT_WINDOW_FS_48000_frame_ms_100 NULL +# endif + +# ifdef PACK_MDCT_WINDOWS +RAM_ALIGN const Word16 * LowDelayShapes_n960[6]; +# else +RAM_ALIGN const Word32 *const LowDelayShapes_n960[6] = { MDCT_WINDOW_FS_8000_frame_ms_100, MDCT_WINDOW_FS_16000_frame_ms_100, + MDCT_WINDOW_FS_24000_frame_ms_100, MDCT_WINDOW_FS_32000_frame_ms_100, + MDCT_WINDOW_FS_48000_frame_ms_100, NULL }; +# endif + +#else +RAM_ALIGN const Word16 *const LowDelayShapes_n960[6] = {LowDelayShapes_n960_N80, LowDelayShapes_n960_N160, + LowDelayShapes_n960_N240, LowDelayShapes_n960_N320, + LowDelayShapes_n960_N480, NULL}; +#endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 LowDelayShapes_n960_len_5ms[6] = {70, 140, 210, 280, 420, 840}; +# else +RAM_ALIGN const Word16 LowDelayShapes_n960_len_5ms[5] = {70, 140, 210, 280, 420}; +# endif + +RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes_5ms[NUM_SAMP_FREQ] = {10, + 20, + 30, + 40, + 60 +# ifdef ENABLE_HR_MODE + , 120 +# endif +}; + +# ifdef ENABLE_HR_MODE +# ifdef SUBSET_NB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_8000_frame_ms_25[40] = { + 9151354, 37109627, 83712740, 151998210, 242715442, 354150912, 482126354, 620379048, + 761296862, 896901837, 1019922302, 1124767307, 1208223590, 1269735636, 1311202326, 1336324669, + 1349655864, 1355605615, 1357680847, 1358157082, -1358157082, -1357680847, -1355605615, -1349655864, + -1336324669, -1311202326, -1269735636, -1208223590, -1124767307, -1019922302, -896901837, -761296862, + -620379048, -482126354, -354150912, -242715442, -151998210, -83712740, -37109627, -9151354}; +# else +# define MDCT_WINDOW_FS_8000_frame_ms_25 NULL +# endif +# ifdef SUBSET_WB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_16000_frame_ms_25[80] = { + 9151337, 23138265, 42763907, 68767772, 101782534, 142300433, 190643613, 246939893, 311105303, + 382834448, 461599452, 546657840, 637069348, 731721202, 829361019, 928636120, 1028137675, 1126447891, + 1222188210, 1314066414, 1400920509, 1481757333, 1555784035, 1622430811, 1681363664, 1732486397, 1775931558, + 1812040689, 1841334847, 1864477074, 1882229157, 1895405578, 1904827946, 1911283293, 1915489337, 1918069115, + 1919536352, 1920291661, 1920628396, 1920745966, -1920745966, -1920628396, -1920291661, -1919536352, -1918069115, + -1915489337, -1911283293, -1904827946, -1895405578, -1882229157, -1864477074, -1841334847, -1812040689, -1775931558, + -1732486397, -1681363664, -1622430811, -1555784035, -1481757333, -1400920509, -1314066414, -1222188210, -1126447891, + -1028137675, -928636120, -829361019, -731721202, -637069348, -546657840, -461599452, -382834448, -311105303, + -246939893, -190643613, -142300433, -101782534, -68767772, -42763907, -23138265, -9151337 }; +# else +# define MDCT_WINDOW_FS_16000_frame_ms_25 NULL +# endif +# ifdef SUBSET_SSWB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_24000_frame_ms_25[120] = { + 6100899, 12864132, 21489409, 32196712, 45171875, 60580072, 78565098, 99246695, 122717635, + 149041013, 178247915, 210335558, 245265970, 282965259, 323323502, 366195270, 411400805, 458727828, + 507933969, 558749783, 610882290, 664019005, 717832373, 771984525, 826132286, 879932323, 933046345, + 985146249, 1035919114, 1085071930, 1132335985, 1177470792, 1220267489, 1260551623, 1298185265, 1333068386, + 1365139469, 1394375330, 1420790145, 1444433697, 1465388876, 1483768499, 1499711524, 1513378754, 1524948163, + 1534609980, 1542561681, 1549003060, 1554131535, 1558137849, 1561202310, 1563491688, 1565156852, 1566331192, + 1567129839, 1567649635, 1567969785, 1568153080, 1568247554, 1568288448, -1568288448, -1568247554, -1568153080, + -1567969785, -1567649635, -1567129839, -1566331192, -1565156852, -1563491688, -1561202310, -1558137849, -1554131535, + -1549003060, -1542561681, -1534609980, -1524948163, -1513378754, -1499711524, -1483768499, -1465388876, -1444433697, + -1420790145, -1394375330, -1365139469, -1333068386, -1298185265, -1260551623, -1220267489, -1177470792, -1132335985, + -1085071930, -1035919114, -985146249, -933046345, -879932323, -826132286, -771984525, -717832373, -664019005, + -610882290, -558749783, -507933969, -458727828, -411400805, -366195270, -323323502, -282965259, -245265970, + -210335558, -178247915, -149041013, -122717635, -99246695, -78565098, -60580072, -45171875, -32196712, + -21489409, -12864132, -6100899 }; +# else +# define MDCT_WINDOW_FS_24000_frame_ms_25 NULL +# endif +# ifdef SUBSET_SWB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_32000_frame_ms_25[160] = { + 4575679, 8767860, 13776210, 19722611, 26689435, 34747238, 43959497, 54383445, 66069923, + 79062931, 93399091, 109107106, 126207257, 144710958, 164620379, 185928150, 208617151, 232660396, + 258021008, 284652300, 312497943, 341492250, 371560541, 402619617, 434578316, 467338167, 500794115, + 534835326, 569346062, 604206611, 639294264, 674484335, 709651210, 744669409, 779414654, 813764938, + 847601565, 880810169, 913281687, 944913281, 975609194, 1005281536, 1033850982, 1061247376, 1087410241, + 1112289173, 1135844126, 1158045581, 1178874586, 1198322683, 1216391705, 1233093455, 1248449271, 1262489470, + 1275252698, 1286785178, 1297139874, 1306375586, 1314555990, 1321748631, 1328023899, 1333453999, 1338111934, + 1342070524, 1345401476, 1348174521, 1350456644, 1352311405, 1353798377, 1354972700, 1355884752, 1356579954, + 1357098688, 1357476324, 1357743362, 1357925654, 1358044707, 1358118045, 1358159612, 1358180205, -1358180205, + -1358159612, -1358118045, -1358044707, -1357925654, -1357743362, -1357476324, -1357098688, -1356579954, -1355884752, + -1354972700, -1353798377, -1352311405, -1350456644, -1348174521, -1345401476, -1342070524, -1338111934, -1333453999, + -1328023899, -1321748631, -1314555990, -1306375586, -1297139874, -1286785178, -1275252698, -1262489470, -1248449271, + -1233093455, -1216391705, -1198322683, -1178874586, -1158045581, -1135844126, -1112289173, -1087410241, -1061247376, + -1033850982, -1005281536, -975609194, -944913281, -913281687, -880810169, -847601565, -813764938, -779414654, + -744669409, -709651210, -674484335, -639294264, -604206611, -569346062, -534835326, -500794115, -467338167, + -434578316, -402619617, -371560541, -341492250, -312497943, -284652300, -258021008, -232660396, -208617151, + -185928150, -164620379, -144710958, -126207257, -109107106, -93399091, -79062931, -66069923, -54383445, + -43959497, -34747238, -26689435, -19722611, -13776210, -8767860, -4575679 }; +# else +# define MDCT_WINDOW_FS_32000_frame_ms_25 NULL +# endif +# ifdef SUBSET_FB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_48000_frame_ms_25[240] = { + 3050456, 5295536, 7753004, 10501942, 13578229, 17006497, 20806969, 24997575, 29594719, + 34613583, 40068237, 45971662, 52335732, 59171174, 66487516, 74293042, 82594732, 91398213, + 100707709, 110526001, 120854381, 131692624, 143038956, 154890033, 167240926, 180085109, 193414462, + 207219271, 221488240, 236208515, 251365705, 266943917, 282925795, 299292569, 316024108, 333098980, + 350494519, 368186897, 386151203, 404361529, 422791056, 441412148, 460196455, 479115006, 498138325, + 517236531, 536379451, 555536738, 574677975, 593772799, 612791011, 631702693, 650478321, 669088878, + 687505964, 705701904, 723649854, 741323899, 758699157, 775751861, 792459455, 808800673, 824755609, + 840305794, 855434253, 870125559, 884365881, 898143024, 911446458, 924267340, 936598527, 948434586, + 959771781, 970608068, 980943072, 990778052, 1000115868, 1008960932, 1017319150, 1025197865, 1032605778, + 1039552878, 1046050356, 1052110513, 1057746665, 1062973048, 1067804709, 1072257401, 1076347473, 1080091765, + 1083507488, 1086612119, 1089423293, 1091958692, 1094235940, 1096272508, 1098085614, 1099692137, 1101108528, + 1102350741, 1103434158, 1104373531, 1105182928, 1105875693, 1106464406, 1106960861, 1107376047, 1107720140, + 1108002502, 1108231688, 1108415463, 1108560820, 1108674010, 1108760573, 1108825377, 1108872657, 1108906059, + 1108928685, 1108943144, 1108951592, -1108951592, -1108943144, -1108928685, -1108906059, -1108872657, -1108825377, + -1108760573, -1108674010, -1108560820, -1108415463, -1108231688, -1108002502, -1107720140, -1107376047, -1106960861, + -1106464406, -1105875693, -1105182928, -1104373531, -1103434158, -1102350741, -1101108528, -1099692137, -1098085614, + -1096272508, -1094235940, -1091958692, -1089423293, -1086612119, -1083507488, -1080091765, -1076347473, -1072257401, + -1067804709, -1062973048, -1057746665, -1052110513, -1046050356, -1039552878, -1032605778, -1025197865, -1017319150, + -1008960932, -1000115868, -990778052, -980943072, -970608068, -959771781, -948434586, -936598527, -924267340, + -911446458, -898143024, -884365881, -870125559, -855434253, -840305794, -824755609, -808800673, -792459455, + -775751861, -758699157, -741323899, -723649854, -705701904, -687505964, -669088878, -650478321, -631702693, + -612791011, -593772799, -574677975, -555536738, -536379451, -517236531, -498138325, -479115006, -460196455, + -441412148, -422791056, -404361529, -386151203, -368186897, -350494519, -333098980, -316024108, -299292569, + -282925795, -266943917, -251365705, -236208515, -221488240, -207219271, -193414462, -180085109, -167240926, + -154890033, -143038956, -131692624, -120854381, -110526001, -100707709, -91398213, -82594732, -74293042, + -66487516, -59171174, -52335732, -45971662, -40068237, -34613583, -29594719, -24997575, -20806969, + -17006497, -13578229, -10501942, -7753004, -5295536, -3050456 }; +# else +# define MDCT_WINDOW_FS_48000_frame_ms_25 NULL +# endif +#endif + +# ifdef ENABLE_HR_MODE +# ifdef SUBSET_NB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_8000_frame_ms_50[70] = { + 1912909, 7335521, 18325724, 36910622, 64974178, 104198418, 155981280, 221305462, 300589079, + 393635120, 499623692, 617106989, 744004208, 877694270, 1015162828, 1153137249, 1288239038, 1417150998, + 1536791945, 1644447880, 1737962977, 1815833349, 1877263804, 1922306058, 1951829636, 1967471711, 1971505676, + 1966594148, 1955602246, 1941502114, 1927310881, 1914588900, 1905592841, 1900063224, 1897652925, 1897963170, + 1900562354, 1904988644, 1910750498, 1917333371, -1924208315, -1930837552, -1936677590, -1941187989, -1943846368, + -1944164165, -1941697923, -1936063536, -1926966575, -1914246866, -1895468226, -1869147188, -1832534703, -1783214725, + -1719263259, -1639330989, -1542778136, -1429960741, -1302431717, -1162827131, -1014564422, -861762630, -709123640, + -561741289, -424627691, -302165309, -197940066, -114914393, -55161222, -18600494 }; +# else +# define MDCT_WINDOW_FS_8000_frame_ms_50 NULL +# endif +# ifdef SUBSET_WB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_16000_frame_ms_50[140] = { + 834388, 2023133, 3917156, 6701705, 10565521, 15685856, 22235650, 30384241, 40286022, + 52095516, 65948322, 81967398, 100265346, 120927126, 144016301, 169574495, 197607091, 228098907, + 261006859, 296253144, 333742048, 373344049, 414902600, 458235462, 503129294, 549353006, 596652543, + 644762423, 693401311, 742277119, 791098023, 839557429, 887360048, 934211532, 979820668, 1023922652, + 1066251747, 1106569674, 1144656239, 1180316465, 1213396318, 1243758349, 1271300584, 1295946391, 1317664404, + 1336461856, 1352374790, 1365487180, 1375907723, 1383780765, 1389286272, 1392625157, 1394020824, 1393712039, + 1391944281, 1388970703, 1385052050, 1380450904, 1375432870, 1370255673, 1365493257, 1360311818, 1355815371, + 1351987330, 1348809662, 1346259072, 1344307938, 1342925268, 1342077528, 1341729312, 1341843769, 1342382749, + 1343306801, 1344575110, 1346145481, 1347974400, 1350017219, 1352228384, 1354561632, 1356970112, -1359406807, + -1361823903, -1364173707, -1366408059, -1368478813, -1370338075, -1371938535, -1373233878, -1374179166, -1374731135, + -1374848407, -1374491689, -1373624022, -1372211199, -1370222452, -1367631371, -1364416934, -1360564607, -1356067324, + -1350921653, -1344029735, -1336226439, -1326949476, -1315967441, -1303050661, -1287981322, -1270565808, -1250633190, + -1228037147, -1202659404, -1174406746, -1143219019, -1109079369, -1072015866, -1032110341, -989504343, -944386484, + -896992664, -847599093, -796504062, -744037160, -690570612, -636495945, -582226621, -528203723, -474881089, + -422717084, -372160937, -323635430, -277529378, -234193138, -193941056, -157058932, -123809989, -94431397, + -69117849, -47990622, -31057417, -18172622, -9019056 }; +# else +# define MDCT_WINDOW_FS_16000_frame_ms_50 NULL +# endif +# ifdef SUBSET_SSWB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_24000_frame_ms_50[210] = { + 564151, 1104419, 1865494, 2894039, 4235165, 5932159, 8033172, 10580362, 13613959, + 17177173, 21310358, 26053470, 31441110, 37512859, 44302113, 51841191, 60158985, 69285016, + 79244161, 90055834, 101740044, 114307277, 127770768, 142131061, 157390145, 173545185, 190584386, + 208498576, 227265343, 246867205, 267275117, 288457873, 310382420, 333006130, 356286886, 380173162, + 404613227, 429551030, 454926373, 480676280, 506737023, 533041379, 559520739, 586104532, 612719819, + 639298867, 665764101, 692044954, 718069120, 743765156, 769064062, 793893410, 818192510, 841895640, + 864939671, 887267243, 908824605, 929558785, 949422426, 968375342, 986383128, 1003413393, 1019433821, + 1034427350, 1048371873, 1061257817, 1073079562, 1083838763, 1093544388, 1102204732, 1109843920, 1116483171, + 1122153769, 1126889366, 1130731703, 1133726105, 1135920322, 1137368676, 1138125139, 1138249333, 1137797435, + 1136832092, 1135413661, 1133604477, 1131468200, 1129067483, 1126468580, 1123733695, 1120926768, 1118121453, + 1115661504, 1112733456, 1110039679, 1107592275, 1105388417, 1103424195, 1101694785, 1100194540, 1098917076, + 1097855409, 1097002014, 1096348961, 1095887953, 1095610427, 1095507566, 1095570351, 1095789547, 1096155725, + 1096659227, 1097290187, 1098038501, 1098893850, 1099845706, 1100883348, 1101995893, 1103172315, 1104401472, + 1105672121, 1106972938, 1108292669, -1109619302, -1110942189, -1112249205, -1113528884, -1114769580, -1115959638, + -1117087420, -1118141328, -1119109856, -1119981619, -1120745408, -1121390225, -1121905319, -1122280224, -1122504764, + -1122569097, -1122463704, -1122179448, -1121707579, -1121039818, -1120168401, -1119086203, -1117786804, -1116264645, + -1114515111, -1112534671, -1110320979, -1107872954, -1105190944, -1102290376, -1098369607, -1094349090, -1089850335, + -1084803470, -1079152632, -1072839707, -1065811535, -1058014404, -1049399648, -1039922082, -1029539502, -1018216878, + -1005918442, -992617105, -978287110, -962909114, -946468188, -928955851, -910372331, -890723372, -870025772, + -848301812, -825588219, -801924529, -777362543, -751959302, -725776798, -698887464, -671358557, -643273732, + -614708529, -585759042, -556515015, -527075925, -497538887, -468010517, -438598442, -409412725, -380564000, + -352163661, -324321484, -297140687, -270721761, -245158912, -220540161, -196946958, -174455223, -153136078, + -133056674, -114280750, -96868231, -80874056, -66345855, -53320577, -41820223, -31847346, -23380692, + -16371397, -10739000, -6256916 }; +# else +# define MDCT_WINDOW_FS_24000_frame_ms_50 NULL +# endif +# ifdef SUBSET_SWB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_32000_frame_ms_50[280] = { + 882763, 1521118, 2358563, 3425984, 4762639, 6395771, 8362131, 10689006, 13418692, + 16576000, 20193865, 24299300, 28928500, 34104984, 39865074, 46229302, 53228467, 60887056, + 69236180, 78292965, 88087142, 98634050, 109959733, 122081209, 135019424, 148782425, 163392710, + 178855011, 195181305, 212377526, 230451659, 249395809, 269219382, 289915225, 311477904, 333897457, + 357170677, 381274098, 406199848, 431929301, 458441926, 485710203, 513718369, 542430861, 571822196, + 601857045, 632504350, 663719412, 695470641, 727711424, 760403450, 793496784, 826949741, 860710772, + 894737379, 928972875, 963373530, 997882662, 1032450522, 1067021806, 1101552211, 1135977909, 1170251366, + 1204317771, 1238127288, 1271622131, 1304759595, 1337479850, 1369736833, 1401482421, 1432674669, 1463259078, + 1493196881, 1522440628, 1550955893, 1578698536, 1605635690, 1631726882, 1656947594, 1681264014, 1704659250, + 1727103999, 1748576205, 1769054798, 1788533700, 1806990078, 1824418644, 1840812466, 1856170505, 1870488908, + 1883781944, 1896047096, 1907297858, 1917548829, 1926819646, 1935123035, 1942490021, 1948939055, 1954502859, + 1959211322, 1963101243, 1966202102, 1968559589, 1970206964, 1971189283, 1971546464, 1971324022, 1970559672, + 1969305529, 1967600289, 1965492731, 1963026251, 1960251018, 1957207403, 1953949375, 1950518787, 1946965804, + 1943332468, 1939669743, 1936018211, 1933074896, 1929170790, 1925511708, 1922091318, 1918913458, 1915970631, + 1913265545, 1910789617, 1908544525, 1906520767, 1904719178, 1903129502, 1901751868, 1900575443, 1899599816, + 1898813735, 1898216400, 1897796234, 1897552155, 1897472330, 1897555435, 1897789418, 1898172732, 1898693091, + 1899348726, 1900127098, 1901026195, 1902033230, 1903145941, 1904351313, 1905646871, 1907019391, 1908466229, + 1909973977, 1911539869, 1913150363, 1914802598, 1916482920, 1918188394, 1919905292, -1921630629, -1923350609, + -1925062194, -1926751519, -1928415501, -1930040212, -1931622556, -1933148598, -1934615259, -1936008644, -1937325739, + -1938552759, -1939686835, -1940714349, -1941632651, -1942428351, -1943099088, -1943631764, -1944024336, -1944264050, + -1944349204, -1944267410, -1944017355, -1943587051, -1942975631, -1942171601, -1941174620, -1939973809, -1938569504, + -1936951577, -1935121231, -1933069293, -1930798023, -1928299406, -1925576914, -1922623868, -1919445128, -1916035514, + -1912401346, -1908538993, -1903226832, -1898165387, -1892651677, -1886636702, -1880083188, -1872945708, -1865186866, + -1856760038, -1847633035, -1837760249, -1827110036, -1815644193, -1803335041, -1790145270, -1776055593, -1761033530, + -1745059396, -1728108424, -1710167501, -1691212572, -1671237793, -1650226116, -1628174600, -1605075941, -1580936677, + -1555754529, -1529546654, -1502320930, -1474101256, -1444909741, -1414780308, -1383738492, -1351831573, -1319095487, + -1285577912, -1251324682, -1216394344, -1180827594, -1144691880, -1108040592, -1070930654, -1033434550, -995621142, + -957552560, -919309430, -880954958, -842572374, -804234470, -766025822, -728021485, -690307576, -652960034, + -616065598, -579699451, -543943367, -508866771, -474546527, -441046910, -408438534, -376778154, -346129113, + -316541929, -288074358, -260771792, -234687576, -209863469, -186348825, -164181088, -143404068, -124048067, + -106147028, -89718620, -74780184, -61329654, -49360094, -38842904, -29739589, -21991349, -15513048, + -10180154 }; +# else +# define MDCT_WINDOW_FS_32000_frame_ms_50 NULL +# endif +# ifdef SUBSET_FB +RAM_ALIGN const Word32 MDCT_WINDOW_FS_48000_frame_ms_50[420] = { + 641452, 963468, 1344309, 1798864, 2336113, 2963727, 3690212, 4523143, 5470567, + 6539876, 7738462, 9075874, 10560639, 12200013, 14000287, 15968479, 18112467, 20440430, + 22959153, 25675517, 28597257, 31731569, 35084700, 38662325, 42471171, 46518292, 50811124, + 55354756, 60154720, 65216952, 70547205, 76150562, 82031461, 88195322, 94647798, 101393537, + 108435354, 115776449, 123420676, 131372779, 139634617, 148207504, 157093536, 166295700, 175815910, + 185653595, 195807761, 206278987, 217068929, 228177014, 239600679, 251337195, 263385931, 275745715, + 288413583, 301384760, 314655039, 328222340, 342083665, 356233498, 370664518, 385372123, 400351243, + 415596618, 431100575, 446855251, 462853492, 479088256, 495551477, 512233512, 529124734, 546216403, + 563499351, 580963667, 598598648, 616393743, 634338212, 652420945, 670630244, 688955012, 707384418, + 725906000, 744507517, 763176760, 781901922, 800670867, 819470287, 838286395, 857107788, 875922821, + 894718707, 913481313, 932196408, 950852353, 969437415, 987938553, 1006342043, 1024635125, 1042806406, + 1060844237, 1078734559, 1096464849, 1114023247, 1131399453, 1148583332, 1165562052, 1182324038, 1198858240, + 1215154081, 1231201466, 1246990634, 1262512157, 1277756598, 1292714571, 1307377034, 1321735176, 1335781943, + 1349510011, 1362912058, 1375982854, 1388718627, 1401109382, 1413152613, 1424839949, 1436168435, 1447135603, + 1457737882, 1467971469, 1477831821, 1487317959, 1496429995, 1505166563, 1513525606, 1521507797, 1529115290, + 1536350460, 1543213224, 1549704472, 1555827692, 1561587898, 1566989343, 1572034920, 1576728782, 1581076815, + 1585086027, 1588761389, 1592109107, 1595136511, 1597852394, 1600264963, 1602381209, 1604209606, 1605759882, + 1607041997, 1608065019, 1608838122, 1609371538, 1609676596, 1609763199, 1609640908, 1609320042, 1608811796, + 1608127979, 1607278811, 1606274326, 1605125864, 1603845218, 1602443629, 1600931810, 1599320348, 1597621250, + 1595846595, 1594007402, 1592114826, 1590179414, 1588213076, 1586227163, 1584231653, 1582234964, 1580207977, + 1578973545, 1576735799, 1574650444, 1572657612, 1570752789, 1568935343, 1567204832, 1565560739, 1564002460, + 1562529304, 1561140497, 1559835185, 1558612434, 1557471243, 1556410547, 1555429220, 1554526076, 1553699872, + 1552949321, 1552273100, 1551669839, 1551138129, 1550676530, 1550283581, 1549957792, 1549697644, 1549501594, + 1549368091, 1549295559, 1549282400, 1549326998, 1549427723, 1549582929, 1549790946, 1550050083, 1550358639, + 1550714889, 1551117086, 1551563464, 1552052237, 1552581604, 1553149738, 1553754795, 1554394911, 1555068212, + 1555772800, 1556506765, 1557268182, 1558055112, 1558865609, 1559697712, 1560549450, 1561418844, 1562303905, + 1563202640, 1564113045, 1565033113, 1565960825, 1566894119, 1567830370, -1568770400, -1569707772, -1570643299, + -1571574337, -1572498793, -1573414613, -1574319739, -1575212113, -1576089676, -1576950365, -1577792121, -1578612885, + -1579410602, -1580183223, -1580928704, -1581645010, -1582330113, -1582982003, -1583598681, -1584178165, -1584718489, + -1585217707, -1585673898, -1586085163, -1586449622, -1586765423, -1587030743, -1587243787, -1587402781, -1587505982, + -1587551679, -1587538195, -1587463877, -1587327103, -1587126293, -1586859906, -1586526431, -1586124397, -1585652387, + -1585109032, -1584493010, -1583803053, -1583037961, -1582196603, -1581277917, -1580280911, -1579204680, -1578048412, + -1576811384, -1575492968, -1574092640, -1572609980, -1571044684, -1569396562, -1567665543, -1565851670, -1563955090, + -1561975794, -1559909960, -1557699231, -1554579493, -1551951859, -1549122074, -1546121016, -1542941389, -1539572601, + -1536005010, -1532229275, -1528234689, -1524011122, -1519548313, -1514837211, -1509868869, -1504633300, -1499121016, + -1493323395, -1487232726, -1480841309, -1474140699, -1467123022, -1459782240, -1452112311, -1444106817, -1435759114, + -1427063276, -1418015155, -1408610288, -1398843935, -1388711462, -1378209682, -1367336091, -1356088102, -1344462791, + -1332458664, -1320075617, -1307313612, -1294173092, -1280654545, -1266760135, -1252493498, -1237857298, -1222855659, + -1207493934, -1191778366, -1175716859, -1159315327, -1142581197, -1125524357, -1108155092, -1090483582, -1072519662, + -1054273467, -1035757912, -1016986859, -997971439, -978723129, -959255645, -939584189, -919723670, -899686034, + -879484158, -859140109, -838667380, -818082710, -797402257, -776643501, -755824703, -734962210, -714073915, + -693179322, -672297393, -651446511, -630646657, -609917124, -589277150, -568746490, -548345449, -528092326, + -508008241, -488111645, -468421183, -448956496, -429734434, -410773661, -392090517, -373702005, -355624406, + -337873208, -320463322, -303409145, -286724555, -270422942, -254517317, -239020241, -223943842, -209300003, + -195100311, -181356034, -168078124, -155277193, -142963461, -131146681, -119836028, -109039985, -98766166, + -89021184, -79810417, -71137840, -63005796, -55414797, -48363340, -41847826, -35862016, -30397367, + -25442735, -20983937, -17003804, -13482292, -10414308, -8112352 }; +# else +# define MDCT_WINDOW_FS_48000_frame_ms_50 NULL +# endif +#endif + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 *const LowDelayShapes_n960_5ms[6] = { + MDCT_WINDOW_FS_8000_frame_ms_50, MDCT_WINDOW_FS_16000_frame_ms_50, MDCT_WINDOW_FS_24000_frame_ms_50, MDCT_WINDOW_FS_32000_frame_ms_50, MDCT_WINDOW_FS_48000_frame_ms_50, NULL }; +#else +RAM_ALIGN const Word16 *const LowDelayShapes_n960_5ms[6] = {LowDelayShapes_n960_N40_5ms, LowDelayShapes_n960_N80_5ms, + LowDelayShapes_n960_N120_5ms, LowDelayShapes_n960_N160_5ms, + LowDelayShapes_n960_N240_5ms, NULL}; +#endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 LowDelayShapes_n960_len_2_5ms[6] = {40, 80, 120, 160, 240, 480}; +# else +RAM_ALIGN const Word16 LowDelayShapes_n960_len_2_5ms[5] = {40, 80, 120, 160, 240}; +# endif + +RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes_2_5ms[NUM_SAMP_FREQ] = {0, + 0, + 0, + 0, + 0 +}; + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 *const LowDelayShapes_n960_2_5ms[6] = { + MDCT_WINDOW_FS_8000_frame_ms_25, MDCT_WINDOW_FS_16000_frame_ms_25, MDCT_WINDOW_FS_24000_frame_ms_25, MDCT_WINDOW_FS_32000_frame_ms_25, MDCT_WINDOW_FS_48000_frame_ms_25, NULL }; +#else +RAM_ALIGN const Word16 *const LowDelayShapes_n960_2_5ms[6] = { + LowDelayShapes_n960_N40_2_5ms, LowDelayShapes_n960_N80_2_5ms, LowDelayShapes_n960_N120_2_5ms, + LowDelayShapes_n960_N160_2_5ms, LowDelayShapes_n960_N240_2_5ms, NULL}; +#endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k_HR[6] = {12, 74, 137, 200, 266, 333}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k_HR[6] = {74, 137, 200, 266, 333, 400}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_96k_HR[6] = {12, 74, 137, 200, 266, 333}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_96k_HR[6] = {74, 137, 200, 266, 333, 400}; +RAM_ALIGN const Word16 *const tns_subdiv_startfreq_HR[2] = {tns_subdiv_startfreq_48k_HR, tns_subdiv_startfreq_96k_HR}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_HR[2] = {tns_subdiv_stopfreq_48k_HR, tns_subdiv_stopfreq_96k_HR}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k_5ms_HR[4] = {6, 53, 100, 150}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k_5ms_HR[4] = {53, 100, 150, 200}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_96k_5ms_HR[4] = {6, 53, 100, 150}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_96k_5ms_HR[4] = {53, 100, 150, 200}; + +RAM_ALIGN const Word16 *const tns_subdiv_startfreq_5ms_HR[2] = {tns_subdiv_startfreq_48k_5ms_HR, + tns_subdiv_startfreq_96k_5ms_HR}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_5ms_HR[2] = {tns_subdiv_stopfreq_48k_5ms_HR, + tns_subdiv_stopfreq_96k_5ms_HR}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k_2_5ms_HR[2] = {3, 51}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k_2_5ms_HR[2] = {51, 100}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_96k_2_5ms_HR[2] = {3, 51}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_96k_2_5ms_HR[2] = {51, 100}; + +RAM_ALIGN const Word16 *const tns_subdiv_startfreq_2_5ms_HR[2] = {tns_subdiv_startfreq_48k_2_5ms_HR, + tns_subdiv_startfreq_96k_2_5ms_HR}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_2_5ms_HR[2] = {tns_subdiv_stopfreq_48k_2_5ms_HR, + tns_subdiv_stopfreq_96k_2_5ms_HR}; +# endif + + +RAM_ALIGN const Word16 tns_subdiv_startfreq_8k[6] = {12, 34, 57, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_8k[6] = {34, 57, 80, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_16k[6] = {12, 61, 110, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_16k[6] = {61, 110, 160, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_24k[6] = {12, 88, 164, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_24k[6] = {88, 164, 240, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_32k[6] = {12, 61, 110, 160, 213, 266}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_32k[6] = {61, 110, 160, 213, 266, 320}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k[6] = {12, 74, 137, 200, 266, 333}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k[6] = {74, 137, 200, 266, 333, 400}; +RAM_ALIGN const Word16 *const tns_subdiv_startfreq[MAX_BW_BANDS_NUMBER] = { + tns_subdiv_startfreq_8k, tns_subdiv_startfreq_16k, tns_subdiv_startfreq_24k, tns_subdiv_startfreq_32k, + tns_subdiv_startfreq_48k}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq[MAX_BW_BANDS_NUMBER] = { + tns_subdiv_stopfreq_8k, tns_subdiv_stopfreq_16k, tns_subdiv_stopfreq_24k, tns_subdiv_stopfreq_32k, + tns_subdiv_stopfreq_48k}; + + +RAM_ALIGN const Word16 tns_subdiv_startfreq_8k_5ms[4] = {6, 23, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_8k_5ms[4] = {23, 40, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_16k_5ms[4] = {6, 43, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_16k_5ms[4] = {43, 80, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_24k_5ms[4] = {6, 63, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_24k_5ms[4] = {63, 120, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_32k_5ms[4] = {6, 43, 80, 120}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_32k_5ms[4] = {43, 80, 120, 160}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k_5ms[4] = {6, 53, 100, 150}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k_5ms[4] = {53, 100, 150, 200}; +RAM_ALIGN const Word16 *const tns_subdiv_startfreq_5ms[MAX_BW_BANDS_NUMBER] = { + tns_subdiv_startfreq_8k_5ms, tns_subdiv_startfreq_16k_5ms, tns_subdiv_startfreq_24k_5ms, + tns_subdiv_startfreq_32k_5ms, tns_subdiv_startfreq_48k_5ms}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_5ms[MAX_BW_BANDS_NUMBER] = { + tns_subdiv_stopfreq_8k_5ms, tns_subdiv_stopfreq_16k_5ms, tns_subdiv_stopfreq_24k_5ms, tns_subdiv_stopfreq_32k_5ms, + tns_subdiv_stopfreq_48k_5ms}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_8k_2_5ms[2] = {3, 11}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_8k_2_5ms[2] = {11, 20}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_16k_2_5ms[2] = {3, 21}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_16k_2_5ms[2] = {21, 40}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_24k_2_5ms[2] = {3, 31}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_24k_2_5ms[2] = {31, 60}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_32k_2_5ms[2] = {3, 41}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_32k_2_5ms[2] = {41, 80}; +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k_2_5ms[2] = {3, 51}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k_2_5ms[2] = {51, 100}; + +RAM_ALIGN const Word16 *const tns_subdiv_startfreq_2_5ms[MAX_BW_BANDS_NUMBER] = { + tns_subdiv_startfreq_8k_2_5ms, tns_subdiv_startfreq_16k_2_5ms, tns_subdiv_startfreq_24k_2_5ms, + tns_subdiv_startfreq_32k_2_5ms, tns_subdiv_startfreq_48k_2_5ms}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_2_5ms[MAX_BW_BANDS_NUMBER] = { + tns_subdiv_stopfreq_8k_2_5ms, tns_subdiv_stopfreq_16k_2_5ms, tns_subdiv_stopfreq_24k_2_5ms, + tns_subdiv_stopfreq_32k_2_5ms, tns_subdiv_stopfreq_48k_2_5ms}; + +#ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 tns_subdiv_startfreq_8k_7_5ms[6] = {9, 26, 43, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_8k_7_5ms[6] = {26, 43, 60, 0, 0, 0}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_16k_7_5ms[6] = {9, 46, 83, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_16k_7_5ms[6] = {46, 83, 120, 0, 0, 0}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_24k_7_5ms[6] = {9, 66, 123, 0, 0, 0}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_24k_7_5ms[6] = {66, 123, 180, 0, 0, 0}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_32k_7_5ms[6] = {9, 46, 82, 120, 159, 200}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_32k_7_5ms[6] = {46, 82, 120, 159, 200, 240}; + +RAM_ALIGN const Word16 tns_subdiv_startfreq_48k_7_5ms[6] = {9, 56, 103, 150, 200, 250}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_48k_7_5ms[6] = {56, 103, 150, 200, 250, 300}; + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 tns_subdiv_startfreq_96k_7_5ms[6] = {9, 56, 103, 150, 200, 250}; +RAM_ALIGN const Word16 tns_subdiv_stopfreq_96k_7_5ms[6] = {56, 103, 150, 200, 250, 300}; +# endif + +RAM_ALIGN const Word16 *const tns_subdiv_startfreq_7_5ms[] = { + tns_subdiv_startfreq_8k_7_5ms, tns_subdiv_startfreq_16k_7_5ms, tns_subdiv_startfreq_24k_7_5ms, + tns_subdiv_startfreq_32k_7_5ms, tns_subdiv_startfreq_48k_7_5ms +# ifdef ENABLE_HR_MODE + , tns_subdiv_startfreq_96k_7_5ms +# endif +}; +RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_7_5ms[] = { + tns_subdiv_stopfreq_8k_7_5ms, tns_subdiv_stopfreq_16k_7_5ms, tns_subdiv_stopfreq_24k_7_5ms, + tns_subdiv_stopfreq_32k_7_5ms, tns_subdiv_stopfreq_48k_7_5ms +# ifdef ENABLE_HR_MODE + , tns_subdiv_stopfreq_96k_7_5ms +# endif +}; +# endif + +RAM_ALIGN const Word16 Tab_esc_nb[4] = {0 << (NBITS_CONTEXT + NBITS_RATEQ), 1 << (NBITS_CONTEXT + NBITS_RATEQ), + 2 << (NBITS_CONTEXT + NBITS_RATEQ), 3 << (NBITS_CONTEXT + NBITS_RATEQ)}; +RAM_ALIGN const Word8 ari_spec_lookup[4096] = { + 0x01, 0x27, 0x07, 0x19, 0x16, 0x16, 0x1C, 0x16, 0x16, 0x16, 0x16, 0x1C, 0x1C, 0x1C, 0x22, 0x1F, 0x1F, 0x28, 0x2B, + 0x2E, 0x31, 0x34, 0x0E, 0x11, 0x24, 0x24, 0x24, 0x26, 0x00, 0x39, 0x26, 0x16, 0x00, 0x08, 0x09, 0x0B, 0x2F, 0x0E, + 0x0E, 0x11, 0x24, 0x24, 0x24, 0x26, 0x3B, 0x3B, 0x26, 0x16, 0x16, 0x1A, 0x2E, 0x1D, 0x1E, 0x20, 0x21, 0x23, 0x24, + 0x24, 0x24, 0x26, 0x00, 0x3B, 0x17, 0x16, 0x2E, 0x2E, 0x2D, 0x2F, 0x30, 0x32, 0x32, 0x12, 0x36, 0x36, 0x36, 0x26, + 0x3B, 0x3B, 0x3B, 0x16, 0x00, 0x3E, 0x3F, 0x03, 0x21, 0x02, 0x02, 0x3D, 0x14, 0x14, 0x14, 0x15, 0x3B, 0x3B, 0x27, + 0x1C, 0x1C, 0x3F, 0x3F, 0x03, 0x21, 0x02, 0x02, 0x3D, 0x26, 0x26, 0x26, 0x15, 0x3B, 0x3B, 0x27, 0x1C, 0x1C, 0x06, + 0x06, 0x06, 0x02, 0x12, 0x3D, 0x14, 0x15, 0x15, 0x15, 0x3B, 0x27, 0x27, 0x07, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33, 0x35, 0x36, 0x14, 0x26, + 0x26, 0x39, 0x27, 0x27, 0x27, 0x07, 0x18, 0x22, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x38, 0x26, 0x39, 0x39, 0x3B, 0x07, 0x07, 0x07, 0x2A, + 0x2A, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x04, 0x04, 0x05, 0x15, 0x15, 0x3B, 0x07, 0x07, 0x07, 0x07, 0x19, 0x19, 0x19, 0x22, 0x04, 0x04, 0x04, 0x04, + 0x05, 0x17, 0x17, 0x27, 0x07, 0x07, 0x07, 0x2A, 0x19, 0x19, 0x16, 0x1F, 0x1F, 0x27, 0x27, 0x27, 0x27, 0x07, 0x07, + 0x2A, 0x00, 0x19, 0x16, 0x16, 0x16, 0x1C, 0x22, 0x1F, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x28, 0x08, 0x09, 0x31, 0x31, 0x34, 0x11, 0x11, 0x11, 0x04, 0x00, + 0x14, 0x11, 0x3C, 0x28, 0x28, 0x08, 0x2B, 0x1B, 0x31, 0x31, 0x0E, 0x11, 0x11, 0x11, 0x24, 0x2A, 0x2A, 0x11, 0x39, + 0x39, 0x28, 0x08, 0x1A, 0x1B, 0x31, 0x0C, 0x0E, 0x11, 0x11, 0x11, 0x24, 0x00, 0x26, 0x24, 0x01, 0x08, 0x08, 0x2B, + 0x09, 0x0B, 0x31, 0x0C, 0x0E, 0x0E, 0x21, 0x32, 0x32, 0x32, 0x3D, 0x24, 0x27, 0x08, 0x08, 0x2B, 0x2E, 0x31, 0x34, + 0x1E, 0x0E, 0x0E, 0x21, 0x32, 0x32, 0x32, 0x32, 0x12, 0x19, 0x08, 0x08, 0x2B, 0x2E, 0x31, 0x34, 0x1E, 0x0E, 0x0E, + 0x12, 0x05, 0x05, 0x05, 0x3D, 0x12, 0x17, 0x2B, 0x2B, 0x2B, 0x09, 0x31, 0x34, 0x03, 0x0E, 0x0E, 0x32, 0x32, 0x32, + 0x32, 0x3D, 0x11, 0x18, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, + 0x2B, 0x2B, 0x2B, 0x2B, 0x09, 0x0B, 0x34, 0x34, 0x0E, 0x0E, 0x11, 0x3D, 0x3D, 0x3D, 0x36, 0x11, 0x27, 0x2D, 0x2D, + 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2C, 0x1B, 0x1D, + 0x34, 0x30, 0x34, 0x34, 0x11, 0x11, 0x11, 0x11, 0x02, 0x11, 0x07, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, + 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x09, 0x1B, 0x1B, 0x0C, 0x34, 0x0E, 0x0E, 0x3A, 0x29, + 0x29, 0x29, 0x06, 0x11, 0x25, 0x09, 0x09, 0x09, 0x1B, 0x0B, 0x31, 0x0C, 0x34, 0x0E, 0x0E, 0x0E, 0x32, 0x00, 0x35, + 0x11, 0x1C, 0x34, 0x34, 0x31, 0x34, 0x0C, 0x34, 0x1E, 0x0E, 0x0E, 0x11, 0x02, 0x02, 0x02, 0x26, 0x26, 0x22, 0x1F, + 0x22, 0x22, 0x1F, 0x1F, 0x1F, 0x1F, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x1F, 0x13, 0x2C, 0x2C, 0x3E, 0x1E, + 0x20, 0x3A, 0x23, 0x24, 0x24, 0x26, 0x00, 0x3B, 0x07, 0x07, 0x27, 0x22, 0x22, 0x2D, 0x2F, 0x30, 0x21, 0x23, 0x23, + 0x24, 0x26, 0x26, 0x26, 0x3B, 0x07, 0x07, 0x27, 0x22, 0x22, 0x3E, 0x1E, 0x0F, 0x32, 0x35, 0x35, 0x36, 0x15, 0x15, + 0x15, 0x3B, 0x07, 0x07, 0x07, 0x22, 0x1E, 0x1E, 0x30, 0x21, 0x3A, 0x12, 0x12, 0x38, 0x17, 0x17, 0x17, 0x3B, 0x07, + 0x07, 0x18, 0x22, 0x22, 0x06, 0x06, 0x3A, 0x35, 0x36, 0x36, 0x15, 0x3B, 0x3B, 0x3B, 0x27, 0x07, 0x07, 0x2A, 0x22, + 0x06, 0x06, 0x21, 0x3A, 0x35, 0x36, 0x3D, 0x15, 0x3B, 0x3B, 0x3B, 0x27, 0x07, 0x07, 0x2A, 0x22, 0x22, 0x33, 0x33, + 0x35, 0x36, 0x38, 0x38, 0x39, 0x27, 0x27, 0x27, 0x07, 0x2A, 0x2A, 0x19, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x04, 0x04, 0x04, 0x05, 0x17, 0x17, 0x27, 0x07, + 0x07, 0x07, 0x2A, 0x19, 0x19, 0x16, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x05, 0x05, 0x05, 0x05, 0x39, 0x39, 0x27, 0x18, 0x18, 0x18, 0x2A, 0x16, 0x16, 0x1C, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x29, + 0x29, 0x29, 0x29, 0x27, 0x27, 0x07, 0x2A, 0x2A, 0x2A, 0x19, 0x1C, 0x1C, 0x1C, 0x1F, 0x1F, 0x29, 0x29, 0x29, 0x29, + 0x27, 0x27, 0x18, 0x19, 0x19, 0x19, 0x16, 0x1C, 0x1C, 0x22, 0x1F, 0x1F, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x1C, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1F, 0x13, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x0B, 0x2F, 0x20, 0x32, 0x12, 0x12, 0x14, 0x15, 0x15, 0x15, 0x27, + 0x3B, 0x22, 0x1A, 0x1A, 0x1B, 0x1D, 0x1E, 0x21, 0x32, 0x12, 0x12, 0x14, 0x39, 0x39, 0x39, 0x3B, 0x3B, 0x22, 0x1B, + 0x1B, 0x0B, 0x0C, 0x30, 0x32, 0x3A, 0x3D, 0x3D, 0x38, 0x39, 0x39, 0x39, 0x3B, 0x27, 0x22, 0x2D, 0x2D, 0x0C, 0x1E, + 0x20, 0x02, 0x02, 0x3D, 0x26, 0x26, 0x26, 0x39, 0x00, 0x3B, 0x27, 0x22, 0x3F, 0x3F, 0x03, 0x20, 0x3A, 0x12, 0x12, + 0x14, 0x15, 0x15, 0x15, 0x3B, 0x27, 0x27, 0x07, 0x1F, 0x1F, 0x03, 0x03, 0x21, 0x3A, 0x12, 0x12, 0x14, 0x15, 0x15, + 0x15, 0x3B, 0x07, 0x07, 0x07, 0x1F, 0x06, 0x06, 0x33, 0x33, 0x35, 0x36, 0x36, 0x26, 0x39, 0x39, 0x39, 0x27, 0x07, + 0x07, 0x2A, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x33, 0x35, 0x35, 0x36, 0x38, 0x38, 0x39, 0x3B, 0x3B, 0x3B, 0x07, 0x18, 0x18, 0x19, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x04, 0x04, 0x04, 0x36, 0x15, + 0x15, 0x39, 0x27, 0x27, 0x27, 0x07, 0x2A, 0x2A, 0x16, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x05, 0x05, 0x05, 0x05, 0x17, 0x17, 0x3B, 0x07, 0x07, 0x07, 0x2A, + 0x16, 0x16, 0x1C, 0x1F, 0x1F, 0x04, 0x04, 0x04, 0x05, 0x17, 0x17, 0x27, 0x18, 0x18, 0x18, 0x19, 0x1C, 0x1C, 0x22, + 0x1F, 0x1F, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x1C, 0x22, 0x22, 0x22, 0x1F, 0x1F, 0x1F, 0x1F, 0x13, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, + 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, + 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3C, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x10, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, + 0x3C, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x25, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x13, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x13, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, + 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x3C, 0x3C, 0x3C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +RAM_ALIGN const UWord16 ari_spec_cumfreq[64][17] = { + {0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834}, + {0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341}, + {0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764}, + {0, 160, 290, 336, 354, 475, 598, 653, 677, 722, 777, 808, 823, 842, 866, 881, 890}, + {0, 71, 144, 177, 195, 266, 342, 385, 411, 445, 489, 519, 539, 559, 586, 607, 622}, + {0, 48, 108, 140, 159, 217, 285, 327, 354, 385, 427, 457, 478, 497, 524, 545, 561}, + {0, 138, 247, 290, 308, 419, 531, 584, 609, 655, 710, 742, 759, 780, 807, 825, 836}, + {0, 16, 40, 62, 79, 103, 139, 170, 195, 215, 245, 270, 290, 305, 327, 346, 362}, + {0, 579, 729, 741, 743, 897, 970, 980, 982, 996, 1007, 1010, 1011, 1014, 1017, 1018, 1019}, + {0, 398, 582, 607, 612, 788, 902, 925, 931, 956, 979, 987, 990, 996, 1002, 1005, 1007}, + {0, 13, 34, 52, 63, 83, 112, 134, 149, 163, 183, 199, 211, 221, 235, 247, 257}, + {0, 281, 464, 501, 510, 681, 820, 857, 867, 902, 938, 953, 959, 968, 978, 984, 987}, + {0, 198, 362, 408, 421, 575, 722, 773, 789, 832, 881, 905, 915, 928, 944, 954, 959}, + {0, 1, 2, 95, 139, 140, 141, 213, 251, 337, 407, 450, 475, 515, 551, 576, 592}, + {0, 133, 274, 338, 366, 483, 605, 664, 691, 730, 778, 807, 822, 837, 857, 870, 878}, + {0, 128, 253, 302, 320, 443, 577, 636, 659, 708, 767, 799, 814, 833, 857, 872, 881}, + {0, 1, 2, 25, 42, 43, 44, 67, 85, 105, 126, 144, 159, 174, 191, 205, 217}, + {0, 70, 166, 229, 267, 356, 468, 533, 569, 606, 653, 685, 705, 722, 745, 762, 774}, + {0, 55, 130, 175, 200, 268, 358, 416, 449, 488, 542, 581, 606, 628, 659, 683, 699}, + {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, + {0, 34, 85, 123, 147, 196, 265, 317, 352, 386, 433, 470, 497, 518, 549, 574, 593}, + {0, 30, 73, 105, 127, 170, 229, 274, 305, 335, 377, 411, 436, 455, 483, 506, 524}, + {0, 9, 24, 38, 51, 65, 87, 108, 126, 139, 159, 177, 193, 204, 221, 236, 250}, + {0, 30, 74, 105, 125, 166, 224, 266, 294, 322, 361, 391, 413, 431, 457, 478, 494}, + {0, 15, 38, 58, 73, 95, 128, 156, 178, 196, 222, 245, 263, 276, 296, 314, 329}, + {0, 11, 28, 44, 57, 74, 100, 123, 142, 157, 179, 199, 216, 228, 246, 262, 276}, + {0, 448, 619, 639, 643, 821, 926, 944, 948, 971, 991, 998, 1000, 1005, 1010, 1012, 1013}, + {0, 332, 520, 549, 555, 741, 874, 903, 910, 940, 970, 981, 985, 991, 998, 1002, 1004}, + {0, 8, 21, 34, 45, 58, 78, 96, 112, 124, 141, 157, 170, 180, 194, 207, 219}, + {0, 239, 415, 457, 468, 631, 776, 820, 833, 872, 914, 933, 940, 951, 964, 971, 975}, + {0, 165, 310, 359, 375, 513, 652, 707, 727, 774, 828, 856, 868, 884, 904, 916, 923}, + {0, 3, 8, 13, 18, 23, 30, 37, 44, 48, 55, 62, 68, 72, 78, 84, 90}, + {0, 115, 237, 289, 311, 422, 547, 608, 635, 680, 737, 771, 788, 807, 832, 849, 859}, + {0, 107, 221, 272, 293, 399, 521, 582, 610, 656, 714, 749, 767, 787, 813, 831, 842}, + {0, 6, 16, 26, 35, 45, 60, 75, 89, 98, 112, 125, 137, 145, 157, 168, 178}, + {0, 72, 160, 210, 236, 320, 422, 482, 514, 555, 608, 644, 665, 685, 712, 732, 745}, + {0, 45, 108, 153, 183, 244, 327, 385, 421, 455, 502, 536, 559, 578, 605, 626, 641}, + {0, 1, 2, 9, 16, 17, 18, 26, 34, 40, 48, 55, 62, 68, 75, 82, 88}, + {0, 29, 73, 108, 132, 174, 236, 284, 318, 348, 391, 426, 452, 471, 500, 524, 543}, + {0, 20, 51, 76, 93, 123, 166, 200, 225, 247, 279, 305, 326, 342, 365, 385, 401}, + {0, 742, 845, 850, 851, 959, 997, 1001, 1002, 1009, 1014, 1016, 1017, 1019, 1020, 1021, 1022}, + {0, 42, 94, 121, 137, 186, 244, 280, 303, 330, 366, 392, 410, 427, 451, 470, 484}, + {0, 13, 33, 51, 66, 85, 114, 140, 161, 178, 203, 225, 243, 256, 275, 292, 307}, + {0, 501, 670, 689, 693, 848, 936, 952, 956, 975, 991, 997, 999, 1004, 1008, 1010, 1011}, + {0, 445, 581, 603, 609, 767, 865, 888, 895, 926, 954, 964, 968, 977, 986, 991, 993}, + {0, 285, 442, 479, 489, 650, 779, 818, 830, 870, 912, 930, 937, 949, 963, 971, 975}, + {0, 349, 528, 561, 569, 731, 852, 883, 892, 923, 953, 965, 970, 978, 987, 992, 994}, + {0, 199, 355, 402, 417, 563, 700, 750, 767, 811, 860, 884, 894, 909, 926, 936, 942}, + {0, 141, 275, 325, 343, 471, 606, 664, 686, 734, 791, 822, 836, 854, 877, 891, 899}, + {0, 243, 437, 493, 510, 649, 775, 820, 836, 869, 905, 923, 931, 941, 953, 960, 964}, + {0, 91, 197, 248, 271, 370, 487, 550, 580, 625, 684, 721, 741, 761, 788, 807, 819}, + {0, 107, 201, 242, 262, 354, 451, 503, 531, 573, 626, 660, 680, 701, 730, 751, 765}, + {0, 168, 339, 407, 432, 553, 676, 731, 755, 789, 830, 854, 866, 879, 895, 906, 912}, + {0, 67, 147, 191, 214, 290, 384, 441, 472, 513, 567, 604, 627, 648, 678, 700, 715}, + {0, 46, 109, 148, 171, 229, 307, 359, 391, 427, 476, 513, 537, 558, 588, 612, 629}, + {0, 848, 918, 920, 921, 996, 1012, 1013, 1014, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023}, + {0, 36, 88, 123, 145, 193, 260, 308, 340, 372, 417, 452, 476, 496, 525, 548, 565}, + {0, 24, 61, 90, 110, 145, 196, 237, 266, 292, 330, 361, 385, 403, 430, 453, 471}, + {0, 85, 182, 230, 253, 344, 454, 515, 545, 590, 648, 685, 706, 727, 756, 776, 789}, + {0, 22, 55, 82, 102, 135, 183, 222, 252, 278, 315, 345, 368, 385, 410, 431, 448}, + {0, 1, 2, 56, 89, 90, 91, 140, 172, 221, 268, 303, 328, 358, 388, 412, 430}, + {0, 45, 109, 152, 177, 239, 320, 376, 411, 448, 499, 537, 563, 585, 616, 640, 658}, + {0, 247, 395, 433, 445, 599, 729, 771, 785, 829, 875, 896, 905, 920, 937, 946, 951}, + {0, 231, 367, 408, 423, 557, 676, 723, 742, 786, 835, 860, 872, 889, 909, 921, 928}}; + +RAM_ALIGN const UWord16 ari_spec_freq[64][17] = { + {1, 1, 175, 48, 1, 1, 109, 36, 171, 109, 47, 20, 49, 36, 20, 10, 190}, + {18, 26, 17, 10, 27, 37, 24, 16, 22, 32, 22, 14, 17, 26, 20, 13, 683}, + {71, 92, 49, 25, 81, 102, 61, 33, 42, 57, 39, 23, 22, 30, 22, 15, 260}, + {160, 130, 46, 18, 121, 123, 55, 24, 45, 55, 31, 15, 19, 24, 15, 9, 134}, + {71, 73, 33, 18, 71, 76, 43, 26, 34, 44, 30, 20, 20, 27, 21, 15, 402}, + {48, 60, 32, 19, 58, 68, 42, 27, 31, 42, 30, 21, 19, 27, 21, 16, 463}, + {138, 109, 43, 18, 111, 112, 53, 25, 46, 55, 32, 17, 21, 27, 18, 11, 188}, + {16, 24, 22, 17, 24, 36, 31, 25, 20, 30, 25, 20, 15, 22, 19, 16, 662}, + {579, 150, 12, 2, 154, 73, 10, 2, 14, 11, 3, 1, 3, 3, 1, 1, 5}, + {398, 184, 25, 5, 176, 114, 23, 6, 25, 23, 8, 3, 6, 6, 3, 2, 17}, + {13, 21, 18, 11, 20, 29, 22, 15, 14, 20, 16, 12, 10, 14, 12, 10, 767}, + {281, 183, 37, 9, 171, 139, 37, 10, 35, 36, 15, 6, 9, 10, 6, 3, 37}, + {198, 164, 46, 13, 154, 147, 51, 16, 43, 49, 24, 10, 13, 16, 10, 5, 65}, + {1, 1, 93, 44, 1, 1, 72, 38, 86, 70, 43, 25, 40, 36, 25, 16, 432}, + {133, 141, 64, 28, 117, 122, 59, 27, 39, 48, 29, 15, 15, 20, 13, 8, 146}, + {128, 125, 49, 18, 123, 134, 59, 23, 49, 59, 32, 15, 19, 24, 15, 9, 143}, + {1, 1, 23, 17, 1, 1, 23, 18, 20, 21, 18, 15, 15, 17, 14, 12, 807}, + {70, 96, 63, 38, 89, 112, 65, 36, 37, 47, 32, 20, 17, 23, 17, 12, 250}, + {55, 75, 45, 25, 68, 90, 58, 33, 39, 54, 39, 25, 22, 31, 24, 16, 325}, + {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 993}, + {34, 51, 38, 24, 49, 69, 52, 35, 34, 47, 37, 27, 21, 31, 25, 19, 431}, + {30, 43, 32, 22, 43, 59, 45, 31, 30, 42, 34, 25, 19, 28, 23, 18, 500}, + {9, 15, 14, 13, 14, 22, 21, 18, 13, 20, 18, 16, 11, 17, 15, 14, 774}, + {30, 44, 31, 20, 41, 58, 42, 28, 28, 39, 30, 22, 18, 26, 21, 16, 530}, + {15, 23, 20, 15, 22, 33, 28, 22, 18, 26, 23, 18, 13, 20, 18, 15, 695}, + {11, 17, 16, 13, 17, 26, 23, 19, 15, 22, 20, 17, 12, 18, 16, 14, 748}, + {448, 171, 20, 4, 178, 105, 18, 4, 23, 20, 7, 2, 5, 5, 2, 1, 11}, + {332, 188, 29, 6, 186, 133, 29, 7, 30, 30, 11, 4, 6, 7, 4, 2, 20}, + {8, 13, 13, 11, 13, 20, 18, 16, 12, 17, 16, 13, 10, 14, 13, 12, 805}, + {239, 176, 42, 11, 163, 145, 44, 13, 39, 42, 19, 7, 11, 13, 7, 4, 49}, + {165, 145, 49, 16, 138, 139, 55, 20, 47, 54, 28, 12, 16, 20, 12, 7, 101}, + {3, 5, 5, 5, 5, 7, 7, 7, 4, 7, 7, 6, 4, 6, 6, 6, 934}, + {115, 122, 52, 22, 111, 125, 61, 27, 45, 57, 34, 17, 19, 25, 17, 10, 165}, + {107, 114, 51, 21, 106, 122, 61, 28, 46, 58, 35, 18, 20, 26, 18, 11, 182}, + {6, 10, 10, 9, 10, 15, 15, 14, 9, 14, 13, 12, 8, 12, 11, 10, 846}, + {72, 88, 50, 26, 84, 102, 60, 32, 41, 53, 36, 21, 20, 27, 20, 13, 279}, + {45, 63, 45, 30, 61, 83, 58, 36, 34, 47, 34, 23, 19, 27, 21, 15, 383}, + {1, 1, 7, 7, 1, 1, 8, 8, 6, 8, 7, 7, 6, 7, 7, 6, 936}, + {29, 44, 35, 24, 42, 62, 48, 34, 30, 43, 35, 26, 19, 29, 24, 19, 481}, + {20, 31, 25, 17, 30, 43, 34, 25, 22, 32, 26, 21, 16, 23, 20, 16, 623}, + {742, 103, 5, 1, 108, 38, 4, 1, 7, 5, 2, 1, 2, 1, 1, 1, 2}, + {42, 52, 27, 16, 49, 58, 36, 23, 27, 36, 26, 18, 17, 24, 19, 14, 540}, + {13, 20, 18, 15, 19, 29, 26, 21, 17, 25, 22, 18, 13, 19, 17, 15, 717}, + {501, 169, 19, 4, 155, 88, 16, 4, 19, 16, 6, 2, 5, 4, 2, 1, 13}, + {445, 136, 22, 6, 158, 98, 23, 7, 31, 28, 10, 4, 9, 9, 5, 2, 31}, + {285, 157, 37, 10, 161, 129, 39, 12, 40, 42, 18, 7, 12, 14, 8, 4, 49}, + {349, 179, 33, 8, 162, 121, 31, 9, 31, 30, 12, 5, 8, 9, 5, 2, 30}, + {199, 156, 47, 15, 146, 137, 50, 17, 44, 49, 24, 10, 15, 17, 10, 6, 82}, + {141, 134, 50, 18, 128, 135, 58, 22, 48, 57, 31, 14, 18, 23, 14, 8, 125}, + {243, 194, 56, 17, 139, 126, 45, 16, 33, 36, 18, 8, 10, 12, 7, 4, 60}, + {91, 106, 51, 23, 99, 117, 63, 30, 45, 59, 37, 20, 20, 27, 19, 12, 205}, + {107, 94, 41, 20, 92, 97, 52, 28, 42, 53, 34, 20, 21, 29, 21, 14, 259}, + {168, 171, 68, 25, 121, 123, 55, 24, 34, 41, 24, 12, 13, 16, 11, 6, 112}, + {67, 80, 44, 23, 76, 94, 57, 31, 41, 54, 37, 23, 21, 30, 22, 15, 309}, + {46, 63, 39, 23, 58, 78, 52, 32, 36, 49, 37, 24, 21, 30, 24, 17, 395}, + {848, 70, 2, 1, 75, 16, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1}, + {36, 52, 35, 22, 48, 67, 48, 32, 32, 45, 35, 24, 20, 29, 23, 17, 459}, + {24, 37, 29, 20, 35, 51, 41, 29, 26, 38, 31, 24, 18, 27, 23, 18, 553}, + {85, 97, 48, 23, 91, 110, 61, 30, 45, 58, 37, 21, 21, 29, 20, 13, 235}, + {22, 33, 27, 20, 33, 48, 39, 30, 26, 37, 30, 23, 17, 25, 21, 17, 576}, + {1, 1, 54, 33, 1, 1, 49, 32, 49, 47, 35, 25, 30, 30, 24, 18, 594}, + {45, 64, 43, 25, 62, 81, 56, 35, 37, 51, 38, 26, 22, 31, 24, 18, 366}, + {247, 148, 38, 12, 154, 130, 42, 14, 44, 46, 21, 9, 15, 17, 9, 5, 73}, + {231, 136, 41, 15, 134, 119, 47, 19, 44, 49, 25, 12, 17, 20, 12, 7, 96}}; + +RAM_ALIGN const UWord16 ari_spec_bits[64][17] = { + {20480, 20480, 5220, 9042, 20480, 20480, 6619, 9892, 5289, 6619, 9105, 11629, 8982, 9892, 11629, 13677, 4977}, + {11940, 10854, 12109, 13677, 10742, 9812, 11090, 12288, 11348, 10240, 11348, 12683, 12109, 10854, 11629, 12902, + 1197}, + {7886, 7120, 8982, 10970, 7496, 6815, 8334, 10150, 9437, 8535, 9656, 11216, 11348, 10431, 11348, 12479, 4051}, + {5485, 6099, 9168, 11940, 6311, 6262, 8640, 11090, 9233, 8640, 10334, 12479, 11781, 11090, 12479, 13988, 6009}, + {7886, 7804, 10150, 11940, 7886, 7685, 9368, 10854, 10061, 9300, 10431, 11629, 11629, 10742, 11485, 12479, 2763}, + {9042, 8383, 10240, 11781, 8483, 8013, 9437, 10742, 10334, 9437, 10431, 11485, 11781, 10742, 11485, 12288, 2346}, + {5922, 6619, 9368, 11940, 6566, 6539, 8750, 10970, 9168, 8640, 10240, 12109, 11485, 10742, 11940, 13396, 5009}, + {12288, 11090, 11348, 12109, 11090, 9892, 10334, 10970, 11629, 10431, 10970, 11629, 12479, 11348, 11781, 12288, + 1289}, + {1685, 5676, 13138, 18432, 5598, 7804, 13677, 18432, 12683, 13396, 17234, 20480, 17234, 17234, 20480, 20480, 15725}, + {2793, 5072, 10970, 15725, 5204, 6487, 11216, 15186, 10970, 11216, 14336, 17234, 15186, 15186, 17234, 18432, 12109}, + {12902, 11485, 11940, 13396, 11629, 10531, 11348, 12479, 12683, 11629, 12288, 13138, 13677, 12683, 13138, 13677, + 854}, + {3821, 5088, 9812, 13988, 5289, 5901, 9812, 13677, 9976, 9892, 12479, 15186, 13988, 13677, 15186, 17234, 9812}, + {4856, 5412, 9168, 12902, 5598, 5736, 8863, 12288, 9368, 8982, 11090, 13677, 12902, 12288, 13677, 15725, 8147}, + {20480, 20480, 7088, 9300, 20480, 20480, 7844, 9733, 7320, 7928, 9368, 10970, 9581, 9892, 10970, 12288, 2550}, + {6031, 5859, 8192, 10635, 6410, 6286, 8433, 10742, 9656, 9042, 10531, 12479, 12479, 11629, 12902, 14336, 5756}, + {6144, 6215, 8982, 11940, 6262, 6009, 8433, 11216, 8982, 8433, 10240, 12479, 11781, 11090, 12479, 13988, 5817}, + {20480, 20480, 11216, 12109, 20480, 20480, 11216, 11940, 11629, 11485, 11940, 12479, 12479, 12109, 12683, 13138, + 704}, + {7928, 6994, 8239, 9733, 7218, 6539, 8147, 9892, 9812, 9105, 10240, 11629, 12109, 11216, 12109, 13138, 4167}, + {8640, 7724, 9233, 10970, 8013, 7185, 8483, 10150, 9656, 8694, 9656, 10970, 11348, 10334, 11090, 12288, 3391}, + {20480, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, + 91}, + {10061, 8863, 9733, 11090, 8982, 7970, 8806, 9976, 10061, 9105, 9812, 10742, 11485, 10334, 10970, 11781, 2557}, + {10431, 9368, 10240, 11348, 9368, 8433, 9233, 10334, 10431, 9437, 10061, 10970, 11781, 10635, 11216, 11940, 2119}, + {13988, 12479, 12683, 12902, 12683, 11348, 11485, 11940, 12902, 11629, 11940, 12288, 13396, 12109, 12479, 12683, + 828}, + {10431, 9300, 10334, 11629, 9508, 8483, 9437, 10635, 10635, 9656, 10431, 11348, 11940, 10854, 11485, 12288, 1946}, + {12479, 11216, 11629, 12479, 11348, 10150, 10635, 11348, 11940, 10854, 11216, 11940, 12902, 11629, 11940, 12479, + 1146}, + {13396, 12109, 12288, 12902, 12109, 10854, 11216, 11781, 12479, 11348, 11629, 12109, 13138, 11940, 12288, 12683, + 928}, + {2443, 5289, 11629, 16384, 5170, 6730, 11940, 16384, 11216, 11629, 14731, 18432, 15725, 15725, 18432, 20480, 13396}, + {3328, 5009, 10531, 15186, 5040, 6031, 10531, 14731, 10431, 10431, 13396, 16384, 15186, 14731, 16384, 18432, 11629}, + {14336, 12902, 12902, 13396, 12902, 11629, 11940, 12288, 13138, 12109, 12288, 12902, 13677, 12683, 12902, 13138, + 711}, + {4300, 5204, 9437, 13396, 5430, 5776, 9300, 12902, 9656, 9437, 11781, 14731, 13396, 12902, 14731, 16384, 8982}, + {5394, 5776, 8982, 12288, 5922, 5901, 8640, 11629, 9105, 8694, 10635, 13138, 12288, 11629, 13138, 14731, 6844}, + {17234, 15725, 15725, 15725, 15725, 14731, 14731, 14731, 16384, 14731, 14731, 15186, 16384, 15186, 15186, 15186, + 272}, + {6461, 6286, 8806, 11348, 6566, 6215, 8334, 10742, 9233, 8535, 10061, 12109, 11781, 10970, 12109, 13677, 5394}, + {6674, 6487, 8863, 11485, 6702, 6286, 8334, 10635, 9168, 8483, 9976, 11940, 11629, 10854, 11940, 13396, 5105}, + {15186, 13677, 13677, 13988, 13677, 12479, 12479, 12683, 13988, 12683, 12902, 13138, 14336, 13138, 13396, 13677, + 565}, + {7844, 7252, 8922, 10854, 7389, 6815, 8383, 10240, 9508, 8750, 9892, 11485, 11629, 10742, 11629, 12902, 3842}, + {9233, 8239, 9233, 10431, 8334, 7424, 8483, 9892, 10061, 9105, 10061, 11216, 11781, 10742, 11485, 12479, 2906}, + {20480, 20480, 14731, 14731, 20480, 20480, 14336, 14336, 15186, 14336, 14731, 14731, 15186, 14731, 14731, 15186, + 266}, + {10531, 9300, 9976, 11090, 9437, 8286, 9042, 10061, 10431, 9368, 9976, 10854, 11781, 10531, 11090, 11781, 2233}, + {11629, 10334, 10970, 12109, 10431, 9368, 10061, 10970, 11348, 10240, 10854, 11485, 12288, 11216, 11629, 12288, + 1469}, + {952, 6787, 15725, 20480, 6646, 9733, 16384, 20480, 14731, 15725, 18432, 20480, 18432, 20480, 20480, 20480, 18432}, + {9437, 8806, 10742, 12288, 8982, 8483, 9892, 11216, 10742, 9892, 10854, 11940, 12109, 11090, 11781, 12683, 1891}, + {12902, 11629, 11940, 12479, 11781, 10531, 10854, 11485, 12109, 10970, 11348, 11940, 12902, 11781, 12109, 12479, + 1054}, + {2113, 5323, 11781, 16384, 5579, 7252, 12288, 16384, 11781, 12288, 15186, 18432, 15725, 16384, 18432, 20480, 12902}, + {2463, 5965, 11348, 15186, 5522, 6934, 11216, 14731, 10334, 10635, 13677, 16384, 13988, 13988, 15725, 18432, 10334}, + {3779, 5541, 9812, 13677, 5467, 6122, 9656, 13138, 9581, 9437, 11940, 14731, 13138, 12683, 14336, 16384, 8982}, + {3181, 5154, 10150, 14336, 5448, 6311, 10334, 13988, 10334, 10431, 13138, 15725, 14336, 13988, 15725, 18432, 10431}, + {4841, 5560, 9105, 12479, 5756, 5944, 8922, 12109, 9300, 8982, 11090, 13677, 12479, 12109, 13677, 15186, 7460}, + {5859, 6009, 8922, 11940, 6144, 5987, 8483, 11348, 9042, 8535, 10334, 12683, 11940, 11216, 12683, 14336, 6215}, + {4250, 4916, 8587, 12109, 5901, 6191, 9233, 12288, 10150, 9892, 11940, 14336, 13677, 13138, 14731, 16384, 8383}, + {7153, 6702, 8863, 11216, 6904, 6410, 8239, 10431, 9233, 8433, 9812, 11629, 11629, 10742, 11781, 13138, 4753}, + {6674, 7057, 9508, 11629, 7120, 6964, 8806, 10635, 9437, 8750, 10061, 11629, 11485, 10531, 11485, 12683, 4062}, + {5341, 5289, 8013, 10970, 6311, 6262, 8640, 11090, 10061, 9508, 11090, 13138, 12902, 12288, 13396, 15186, 6539}, + {8057, 7533, 9300, 11216, 7685, 7057, 8535, 10334, 9508, 8694, 9812, 11216, 11485, 10431, 11348, 12479, 3541}, + {9168, 8239, 9656, 11216, 8483, 7608, 8806, 10240, 9892, 8982, 9812, 11090, 11485, 10431, 11090, 12109, 2815}, + {558, 7928, 18432, 20480, 7724, 12288, 20480, 20480, 18432, 20480, 20480, 20480, 20480, 20480, 20480, 20480, 20480}, + {9892, 8806, 9976, 11348, 9042, 8057, 9042, 10240, 10240, 9233, 9976, 11090, 11629, 10531, 11216, 12109, 2371}, + {11090, 9812, 10531, 11629, 9976, 8863, 9508, 10531, 10854, 9733, 10334, 11090, 11940, 10742, 11216, 11940, 1821}, + {7354, 6964, 9042, 11216, 7153, 6592, 8334, 10431, 9233, 8483, 9812, 11485, 11485, 10531, 11629, 12902, 4349}, + {11348, 10150, 10742, 11629, 10150, 9042, 9656, 10431, 10854, 9812, 10431, 11216, 12109, 10970, 11485, 12109, 1700}, + {20480, 20480, 8694, 10150, 20480, 20480, 8982, 10240, 8982, 9105, 9976, 10970, 10431, 10431, 11090, 11940, 1610}, + {9233, 8192, 9368, 10970, 8286, 7496, 8587, 9976, 9812, 8863, 9733, 10854, 11348, 10334, 11090, 11940, 3040}, + {4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804}, + {4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994}}; + +RAM_ALIGN const Word32 tnsAcfWindow_lc3plus[MAXLAG] = {0x7FBF61E2, 0x7EFE4B00, 0x7DBF01E8, 0x7C0544D0, + 0x79D636E9, 0x773846E0, 0x74330F61, 0x70CF3251}; +RAM_ALIGN const Word16 tnsQuantPts[TNS_COEF_RES] = {-32628, -31517, -29333, -26149, -22076, -17250, -11837, -6021, 0, + 6021, 11837, 17250, 22076, 26149, 29333, 31517, 32628}; +RAM_ALIGN const Word16 tnsQuantThr[TNS_COEF_RES - 1] = {-32210, -30555, -27860, -24216, -19747, -14606, -8967, -3023, + 3023, 8967, 14606, 19747, 24216, 27860, 30555, 32210}; + +RAM_ALIGN const Word16 ac_tns_order_bits[2][MAXLAG] = {{17234, 13988, 11216, 8694, 6566, 4977, 3961, 3040}, + {12683, 9437, 6874, 5541, 5121, 5170, 5359, 5056}}; +RAM_ALIGN const Word16 ac_tns_order_freq[2][MAXLAG] = {{3, 9, 23, 54, 111, 190, 268, 366}, + {14, 42, 100, 157, 181, 178, 167, 185}}; +RAM_ALIGN const Word16 ac_tns_order_cumfreq[2][MAXLAG] = {{0, 3, 12, 35, 89, 200, 390, 658}, + {0, 14, 56, 156, 313, 494, 672, 839}}; +RAM_ALIGN const Word16 ac_tns_coef_bits[MAXLAG][TNS_COEF_RES] = { + {20480, 15725, 12479, 10334, 8694, 7320, 6964, 6335, 5504, 5637, 6566, 6758, 8433, 11348, 15186, 20480, 20480}, + {20480, 20480, 20480, 20480, 12902, 9368, 7057, 5901, 5254, 5485, 5598, 6076, 7608, 10742, 15186, 20480, 20480}, + {20480, 20480, 20480, 20480, 13988, 9368, 6702, 4841, 4585, 4682, 5859, 7764, 12109, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 18432, 13396, 8982, 4767, 3779, 3658, 6335, 9656, 13988, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 14731, 9437, 4275, 3249, 3493, 8483, 13988, 17234, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 12902, 4753, 3040, 2953, 9105, 15725, 20480, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 12902, 3821, 3346, 3000, 12109, 20480, 20480, 20480, 20480, 20480, + 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 15725, 3658, 20480, 1201, 10854, 18432, 20480, 20480, 20480, 20480, + 20480}}; +RAM_ALIGN const Word16 ac_tns_coef_freq[MAXLAG][TNS_COEF_RES] = { + {1, 5, 15, 31, 54, 86, 97, 120, 159, 152, 111, 104, 59, 22, 6, 1, 1}, + {1, 1, 1, 1, 13, 43, 94, 139, 173, 160, 154, 131, 78, 27, 6, 1, 1}, + {1, 1, 1, 1, 9, 43, 106, 199, 217, 210, 141, 74, 17, 1, 1, 1, 1}, + {1, 1, 1, 1, 2, 11, 49, 204, 285, 297, 120, 39, 9, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 7, 42, 241, 341, 314, 58, 9, 3, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 13, 205, 366, 377, 47, 5, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 13, 281, 330, 371, 17, 1, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 5, 297, 1, 682, 26, 2, 1, 1, 1, 1, 1}}; +RAM_ALIGN const Word16 ac_tns_coef_cumfreq[MAXLAG][TNS_COEF_RES] = { + {0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023}, + {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023}, + {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023}, + {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023}, + {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023}, + {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023}, + {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023}, + {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023}}; + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_8000[64] = { + 0x4000, 0x435c, 0x46e5, 0x4a9e, 0x4e89, 0x52a9, 0x5700, 0x5b91, 0x6060, 0x656f, 0x6ac2, 0x705d, 0x7643, + 0x7c79, 0x4181, 0x44f1, 0x4890, 0x4c5f, 0x5061, 0x549a, 0x590b, 0x5db7, 0x62a3, 0x67d1, 0x6d44, 0x7301, + 0x790a, 0x7f65, 0x430b, 0x4690, 0x4a44, 0x4e2a, 0x5245, 0x5696, 0x5b22, 0x5feb, 0x64f4, 0x6a41, 0x6fd5, + 0x75b4, 0x7be2, 0x4131, 0x449e, 0x4838, 0x4c02, 0x5000, 0x5433, 0x589f, 0x5d46, 0x622c, 0x6753, 0x6cc0, + 0x7275, 0x7878, 0x7ecb, 0x42b9, 0x463a, 0x49ea, 0x4dcb, 0x51e1, 0x562d, 0x5ab4, 0x5f77, 0x647a}; + +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_e_8000[64] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05}; +#else +#define lpc_warp_pre_emphasis_64_8000 NULL +#define lpc_warp_pre_emphasis_64_e_8000 NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_16000[64] = { + 0x4000, 0x445a, 0x4900, 0x4df7, 0x5344, 0x58ed, 0x5efa, 0x656f, 0x6c55, 0x73b2, 0x7b91, 0x41fc, 0x4678, + 0x4b43, 0x5061, 0x55d9, 0x5baf, 0x61eb, 0x6894, 0x6fb0, 0x7748, 0x7f65, 0x4407, 0x48a8, 0x4d98, 0x52df, + 0x5882, 0x5e87, 0x64f4, 0x6bd1, 0x7326, 0x7afb, 0x41ac, 0x4623, 0x4ae8, 0x5000, 0x5571, 0x5b40, 0x6174, + 0x6815, 0x6f29, 0x76b8, 0x7ecb, 0x43b5, 0x4850, 0x4d3a, 0x527b, 0x5817, 0x5e14, 0x647a, 0x6b4f, 0x729b, + 0x7a66, 0x415c, 0x45ce, 0x4a8d, 0x4f9f, 0x5509, 0x5ad1, 0x60fe, 0x6797, 0x6ea2, 0x7628, 0x7e31}; + +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_e_16000[64] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}; +#else +#define lpc_warp_pre_emphasis_64_16000 NULL +#define lpc_warp_pre_emphasis_64_e_16000 NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_24000[64] = { + 0x4000, 0x455c, 0x4b2a, 0x5176, 0x5848, 0x5fac, 0x67af, 0x705d, 0x79c5, 0x41fc, 0x4782, 0x4d7f, 0x53fc, + 0x5b04, 0x62a3, 0x6ae5, 0x73d9, 0x7d8c, 0x4407, 0x49b9, 0x4fe6, 0x5696, 0x5dd6, 0x65b2, 0x6e35, 0x7770, + 0x40b8, 0x4623, 0x4c02, 0x5260, 0x5945, 0x60bf, 0x68d8, 0x71a0, 0x7b23, 0x42b9, 0x4850, 0x4e5e, 0x54ed, + 0x5c0a, 0x63be, 0x6c18, 0x7525, 0x7ef4, 0x44cb, 0x4a8d, 0x50cb, 0x578f, 0x5ee4, 0x66d6, 0x6f72, 0x78c7, + 0x4172, 0x46ed, 0x4cdd, 0x534c, 0x5a46, 0x61d5, 0x6a06, 0x72e6, 0x7c85, 0x4379, 0x491f, 0x4f3f}; + +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_e_24000[64] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08}; +#else +#define lpc_warp_pre_emphasis_64_24000 NULL +#define lpc_warp_pre_emphasis_64_e_24000 NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_32000[64] = { + 0x4000, 0x4661, 0x4d65, 0x551d, 0x5d99, 0x66ed, 0x7130, 0x7c79, 0x4471, 0x4b43, 0x52c4, 0x5b04, 0x6417, + 0x6e11, 0x790a, 0x428e, 0x4930, 0x507c, 0x5882, 0x6154, 0x6b08, 0x75b4, 0x40b8, 0x472b, 0x4e44, 0x5611, + 0x5ea6, 0x6815, 0x7275, 0x7dde, 0x4535, 0x4c1b, 0x53b2, 0x5c0a, 0x6536, 0x6f4d, 0x7a66, 0x434d, 0x4a02, + 0x5163, 0x5980, 0x626c, 0x6c3c, 0x7706, 0x4172, 0x47f8, 0x4f25, 0x5708, 0x5fb5, 0x6940, 0x73be, 0x7f48, + 0x45fc, 0x4cf6, 0x54a2, 0x5d12, 0x6659, 0x708d, 0x7bc6, 0x440e, 0x4ad7, 0x524d, 0x5a81, 0x6387}; + +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_e_32000[64] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09}; +#else +#define lpc_warp_pre_emphasis_64_32000 NULL +#define lpc_warp_pre_emphasis_64_e_32000 NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_48000[64] = { + 0x4000, 0x476b, 0x4fb1, 0x58ed, 0x633c, 0x6ebc, 0x7b91, 0x44f1, 0x4cee, 0x55d9, 0x5fcb, 0x6ae5, 0x7748, + 0x428e, 0x4a44, 0x52df, 0x5c7a, 0x6731, 0x7326, 0x403f, 0x47b1, 0x5000, 0x5945, 0x639e, 0x6f29, 0x7c0b, + 0x4535, 0x4d3a, 0x562d, 0x602a, 0x6b4f, 0x77be, 0x42cf, 0x4a8d, 0x5331, 0x5cd5, 0x6797, 0x7398, 0x407f, + 0x47f8, 0x504f, 0x599d, 0x6400, 0x6f97, 0x7c85, 0x457a, 0x4d87, 0x5683, 0x6089, 0x6bb9, 0x7834, 0x4311, + 0x4ad7, 0x5383, 0x5d31, 0x67fd, 0x740a, 0x40be, 0x483f, 0x509e, 0x59f6, 0x6463, 0x7005, 0x7d00}; + +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_e_48000[64] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}; +#else +#define lpc_warp_pre_emphasis_64_48000 NULL +#define lpc_warp_pre_emphasis_64_e_48000 NULL +#endif + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_96000[64] = { + 0x4000, 0x4878, 0x520f, 0x5cea, 0x6936, 0x7721, 0x4372, 0x4c5f, 0x567a, 0x61eb, 0x6ee0, 0x7d8c, 0x4714, + 0x507c, 0x5b22, 0x6731, 0x74d8, 0x4227, 0x4ae8, 0x54d1, 0x600a, 0x6cc0, 0x7b23, 0x45b7, 0x4ef1, 0x5963, + 0x6536, 0x729b, 0x40e2, 0x4978, 0x5331, 0x5e33, 0x6aaa, 0x78c7, 0x4461, 0x4d6d, 0x57ac, 0x6346, 0x7068, + 0x7f48, 0x4810, 0x5199, 0x5c64, 0x689e, 0x7676, 0x4311, 0x4bf1, 0x55fd, 0x615e, 0x6e40, 0x7cd7, 0x46ae, + 0x5008, 0x5a9f, 0x669d, 0x7430, 0x41c8, 0x4a7c, 0x5457, 0x5f80, 0x6c23, 0x7a72, 0x4553, 0x4e7f}; + +RAM_ALIGN const Word16 lpc_warp_pre_emphasis_64_e_96000[64] = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0c, 0x0c}; +#else +# define lpc_warp_pre_emphasis_64_96000 NULL +# define lpc_warp_pre_emphasis_64_e_96000 NULL +#endif + +RAM_ALIGN const Word16 *const lpc_pre_emphasis[NUM_SAMP_FREQ] = {lpc_warp_pre_emphasis_64_8000, + lpc_warp_pre_emphasis_64_16000, + lpc_warp_pre_emphasis_64_24000, + lpc_warp_pre_emphasis_64_32000, + lpc_warp_pre_emphasis_64_48000, + lpc_warp_pre_emphasis_64_96000 +}; + +RAM_ALIGN const Word16 *const lpc_pre_emphasis_e[NUM_SAMP_FREQ] = {lpc_warp_pre_emphasis_64_e_8000, + lpc_warp_pre_emphasis_64_e_16000, + lpc_warp_pre_emphasis_64_e_24000, + lpc_warp_pre_emphasis_64_e_32000, + lpc_warp_pre_emphasis_64_e_48000, + lpc_warp_pre_emphasis_64_e_96000 +}; + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_20_8000[20] = {0x4be4, 0x5b79, 0x7a43, 0x53bf, 0x7106, 0x4a1f, 0x5e46, + 0x7477, 0x4613, 0x5260, 0x5ed4, 0x6b21, 0x76f9, 0x4109, + 0x4612, 0x4a79, 0x4e22, 0x50f6, 0x52e2, 0x53dc}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_20_e_8000[20] = { + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_8000[40] = { + 0x4a6c, 0x4e55, 0x5622, 0x61c5, 0x712d, 0x4220, 0x4d71, 0x5a77, 0x691e, 0x794e, 0x4577, 0x4ef1, 0x5906, 0x63a6, + 0x6ec1, 0x7a44, 0x430f, 0x491f, 0x4f46, 0x557c, 0x5bb8, 0x61ee, 0x6815, 0x6e25, 0x7412, 0x79d4, 0x7f61, 0x4259, + 0x44de, 0x473c, 0x4970, 0x4b76, 0x4d4b, 0x4eec, 0x5056, 0x5187, 0x527e, 0x5338, 0x53b5, 0x53f3}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_e_8000[40] = { + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_8000[80] = { + 0x4a0e, 0x4b09, 0x4cfd, 0x4fec, 0x53d2, 0x58af, 0x5e81, 0x6545, 0x6cf9, 0x759a, 0x7f25, 0x44ca, 0x4a73, 0x508a, + 0x570e, 0x5dfa, 0x654e, 0x6d06, 0x751e, 0x7d94, 0x4332, 0x47c6, 0x4c83, 0x5168, 0x5673, 0x5ba2, 0x60f2, 0x6662, + 0x6bf0, 0x7199, 0x775b, 0x7d34, 0x4191, 0x4490, 0x4798, 0x4aa7, 0x4dba, 0x50d3, 0x53ee, 0x570b, 0x5a29, 0x5d46, + 0x6061, 0x637a, 0x668e, 0x699c, 0x6ca4, 0x6fa3, 0x729a, 0x7587, 0x7868, 0x7b3c, 0x7e03, 0x405e, 0x41b2, 0x42fd, + 0x4440, 0x4579, 0x46a9, 0x47cd, 0x48e7, 0x49f6, 0x4af9, 0x4bf0, 0x4cdb, 0x4db8, 0x4e89, 0x4f4c, 0x5001, 0x50a8, + 0x5140, 0x51ca, 0x5246, 0x52b2, 0x530f, 0x535d, 0x539b, 0x53ca, 0x53e9, 0x53f9}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_8000[80] = { + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +#else +#define lpc_lin_pre_emphasis_20_8000 NULL +#define lpc_lin_pre_emphasis_20_e_8000 NULL +#define lpc_lin_pre_emphasis_40_8000 NULL +#define lpc_lin_pre_emphasis_40_e_8000 NULL +#define lpc_lin_pre_emphasis_80_8000 NULL +#define lpc_lin_pre_emphasis_80_e_8000 NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_16000[40] = { + 0x516b, 0x5a81, 0x6c9d, 0x43d2, 0x55b6, 0x6bdd, 0x4313, 0x5233, 0x6336, 0x7602, 0x453d, 0x503e, 0x5bf4, 0x684b, + 0x7530, 0x4148, 0x4829, 0x4f33, 0x5658, 0x5d8f, 0x64cc, 0x6c03, 0x7328, 0x7a32, 0x408a, 0x43e1, 0x471b, 0x4a31, + 0x4d1e, 0x4fde, 0x526d, 0x54c7, 0x56e7, 0x58cb, 0x5a70, 0x5bd2, 0x5cf0, 0x5dc9, 0x5e59, 0x5ea2}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_e_16000[40] = { + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_16000[80] = { + 0x5091, 0x52d7, 0x5762, 0x5e30, 0x673f, 0x728b, 0x4008, 0x47e3, 0x50d6, 0x5adb, 0x65ef, 0x720e, 0x7f33, 0x46ac, + 0x4e3c, 0x5647, 0x5ec9, 0x67bf, 0x7126, 0x7afa, 0x429b, 0x47ec, 0x4d6d, 0x531c, 0x58f7, 0x5efb, 0x6527, 0x6b78, + 0x71eb, 0x787d, 0x7f2d, 0x42fc, 0x466d, 0x49e8, 0x4d6d, 0x50fa, 0x548d, 0x5825, 0x5bc1, 0x5f5e, 0x62fd, 0x669a, + 0x6a36, 0x6dce, 0x7161, 0x74ee, 0x7872, 0x7bee, 0x7f5f, 0x4162, 0x430e, 0x44b3, 0x4650, 0x47e4, 0x496f, 0x4af0, + 0x4c67, 0x4dd2, 0x4f33, 0x5087, 0x51ce, 0x5309, 0x5436, 0x5554, 0x5665, 0x5766, 0x5858, 0x593a, 0x5a0d, 0x5acf, + 0x5b80, 0x5c20, 0x5caf, 0x5d2d, 0x5d99, 0x5df4, 0x5e3c, 0x5e72, 0x5e97, 0x5ea9}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_16000[80] = { + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +#else +#define lpc_lin_pre_emphasis_40_16000 NULL +#define lpc_lin_pre_emphasis_40_e_16000 NULL +#define lpc_lin_pre_emphasis_80_16000 NULL +#define lpc_lin_pre_emphasis_80_e_16000 NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_24000[40] = { + 0x44f2, 0x59a3, 0x4172, 0x603b, 0x447d, 0x5db8, 0x7ba7, 0x4f0d, 0x626d, 0x77d6, 0x4793, 0x541b, 0x6171, 0x6f7f, + 0x7e2f, 0x46b5, 0x4e8b, 0x568f, 0x5eb2, 0x66ea, 0x6f28, 0x775f, 0x7f83, 0x43c3, 0x47ae, 0x4b7d, 0x4f29, 0x52ac, + 0x5602, 0x5924, 0x5c0e, 0x5ebb, 0x6127, 0x634e, 0x652d, 0x66c1, 0x6807, 0x68fd, 0x69a2, 0x69f5}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_e_24000[40] = { + (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_24000[60] = { + 0x4382, 0x4cb6, 0x5f17, 0x7a99, 0x4f94, 0x6656, 0x40c0, 0x5081, 0x6263, 0x7658, 0x4629, 0x5222, + 0x5f0e, 0x6ce3, 0x7b98, 0x4591, 0x4dbc, 0x5647, 0x5f2b, 0x6862, 0x71e7, 0x7bb2, 0x42de, 0x47ff, + 0x4d39, 0x5288, 0x57e8, 0x5d55, 0x62cc, 0x6849, 0x6dc8, 0x7345, 0x78bc, 0x7e29, 0x41c5, 0x446c, + 0x4709, 0x499a, 0x4c1c, 0x4e8f, 0x50f0, 0x533e, 0x5577, 0x579a, 0x59a4, 0x5b96, 0x5d6c, 0x5f27, + 0x60c4, 0x6243, 0x63a3, 0x64e2, 0x6601, 0x66fd, 0x67d6, 0x688c, 0x691e, 0x698c, 0x69d6, 0x69fb}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_e_24000[60] = { + (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_24000[80] = { + 0x4301, 0x482e, 0x5287, 0x6208, 0x76a9, 0x4832, 0x5797, 0x697e, 0x7dde, 0x4a59, 0x56f7, 0x64c5, 0x73bd, 0x41ed, + 0x4a8a, 0x53b2, 0x5d63, 0x6798, 0x724d, 0x7d7e, 0x4493, 0x4aa1, 0x50e5, 0x575e, 0x5e0a, 0x64e4, 0x6beb, 0x731d, + 0x7a75, 0x40f9, 0x44c7, 0x48a5, 0x4c91, 0x5088, 0x548a, 0x5895, 0x5ca7, 0x60bf, 0x64db, 0x68f9, 0x6d18, 0x7136, + 0x7552, 0x796a, 0x7d7c, 0x40c4, 0x42c4, 0x44c0, 0x46b6, 0x48a5, 0x4a8c, 0x4c6b, 0x4e41, 0x500e, 0x51d0, 0x5386, + 0x5531, 0x56cf, 0x5860, 0x59e4, 0x5b59, 0x5cbf, 0x5e16, 0x5f5c, 0x6092, 0x61b7, 0x62cb, 0x63cd, 0x64bc, 0x6599, + 0x6663, 0x671a, 0x67bd, 0x684c, 0x68c7, 0x692e, 0x6980, 0x69be, 0x69e8, 0x69fd}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_24000[80] = { + (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +#else +#define lpc_lin_pre_emphasis_60_24000 NULL +#define lpc_lin_pre_emphasis_60_e_24000 NULL +#define lpc_lin_pre_emphasis_40_24000 NULL +#define lpc_lin_pre_emphasis_40_e_24000 NULL +#define lpc_lin_pre_emphasis_80_24000 NULL +#define lpc_lin_pre_emphasis_80_e_24000 NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_32000[80] = { + 0x6eab, 0x4e92, 0x7d03, 0x614a, 0x47cb, 0x64a9, 0x439a, 0x57af, 0x6e8c, 0x4414, 0x523c, 0x61b9, 0x7284, 0x424c, + 0x4bf6, 0x563d, 0x611c, 0x6c8f, 0x7892, 0x4290, 0x491a, 0x4fe5, 0x56ed, 0x5e31, 0x65ac, 0x6d5d, 0x753f, 0x7d51, + 0x42c7, 0x46fa, 0x4b40, 0x4f96, 0x53fc, 0x5870, 0x5cef, 0x6178, 0x6609, 0x6aa1, 0x6f3d, 0x73dc, 0x787b, 0x7d1a, + 0x40db, 0x4327, 0x4570, 0x47b4, 0x49f4, 0x4c2d, 0x4e60, 0x508b, 0x52ae, 0x54c8, 0x56d7, 0x58dc, 0x5ad4, 0x5cc0, + 0x5e9f, 0x6070, 0x6232, 0x63e5, 0x6587, 0x6719, 0x689a, 0x6a08, 0x6b64, 0x6cad, 0x6de2, 0x6f03, 0x7010, 0x7108, + 0x71ea, 0x72b7, 0x736e, 0x740f, 0x7499, 0x750c, 0x7569, 0x75ae, 0x75dd, 0x75f4}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_32000[80] = { + (Word16)0xfff9, (Word16)0xfffa, (Word16)0xfffa, (Word16)0xfffb, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +#else +#define lpc_lin_pre_emphasis_80_32000 NULL +#define lpc_lin_pre_emphasis_80_e_32000 NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_48000[60] = { + 0x7330, 0x62e5, 0x5ab1, 0x4c35, 0x753a, 0x5425, 0x72a0, 0x4afd, 0x5f0d, 0x7571, 0x470d, 0x547b, + 0x62fa, 0x727f, 0x4180, 0x4a38, 0x5362, 0x5cf7, 0x66f0, 0x7148, 0x7bf5, 0x4379, 0x491b, 0x4edc, + 0x54b9, 0x5aae, 0x60b6, 0x66cd, 0x6cee, 0x7316, 0x7941, 0x7f69, 0x42c5, 0x45d1, 0x48d4, 0x4bcf, + 0x4ebd, 0x519e, 0x546f, 0x572e, 0x59d9, 0x5c6f, 0x5eee, 0x6153, 0x639d, 0x65cb, 0x67dc, 0x69cc, + 0x6b9c, 0x6d4a, 0x6ed4, 0x703b, 0x717c, 0x7296, 0x738a, 0x7457, 0x74fb, 0x7576, 0x75c9, 0x75f2}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_e_48000[60] = { + (Word16)0xfff9, (Word16)0xfffa, (Word16)0xfffb, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_48000[80] = { + 0x6eab, 0x4e92, 0x7d03, 0x614a, 0x47cb, 0x64a9, 0x439a, 0x57af, 0x6e8c, 0x4414, 0x523c, 0x61b9, 0x7284, 0x424c, + 0x4bf6, 0x563d, 0x611c, 0x6c8f, 0x7892, 0x4290, 0x491a, 0x4fe5, 0x56ed, 0x5e31, 0x65ac, 0x6d5d, 0x753f, 0x7d51, + 0x42c7, 0x46fa, 0x4b40, 0x4f96, 0x53fc, 0x5870, 0x5cef, 0x6178, 0x6609, 0x6aa1, 0x6f3d, 0x73dc, 0x787b, 0x7d1a, + 0x40db, 0x4327, 0x4570, 0x47b4, 0x49f4, 0x4c2d, 0x4e60, 0x508b, 0x52ae, 0x54c8, 0x56d7, 0x58dc, 0x5ad4, 0x5cc0, + 0x5e9f, 0x6070, 0x6232, 0x63e5, 0x6587, 0x6719, 0x689a, 0x6a08, 0x6b64, 0x6cad, 0x6de2, 0x6f03, 0x7010, 0x7108, + 0x71ea, 0x72b7, 0x736e, 0x740f, 0x7499, 0x750c, 0x7569, 0x75ae, 0x75dd, 0x75f4}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_48000[80] = { + (Word16)0xfff9, (Word16)0xfffa, (Word16)0xfffa, (Word16)0xfffb, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +#else +#define lpc_lin_pre_emphasis_60_48000 NULL +#define lpc_lin_pre_emphasis_60_e_48000 NULL +#define lpc_lin_pre_emphasis_80_48000 NULL +#define lpc_lin_pre_emphasis_80_e_48000 NULL +#endif + +# if defined(SUBSET_SWB) || defined(SUBSET_FB) +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_0_92[80] = { + 0x6eab, 0x4e92, 0x7d03, 0x614a, 0x47cb, 0x64a9, 0x439a, 0x57af, 0x6e8c, 0x4414, 0x523c, 0x61b9, 0x7284, 0x424c, + 0x4bf6, 0x563d, 0x611c, 0x6c8f, 0x7892, 0x4290, 0x491a, 0x4fe5, 0x56ed, 0x5e31, 0x65ac, 0x6d5d, 0x753f, 0x7d51, + 0x42c7, 0x46fa, 0x4b40, 0x4f96, 0x53fc, 0x5870, 0x5cef, 0x6178, 0x6609, 0x6aa1, 0x6f3d, 0x73dc, 0x787b, 0x7d1a, + 0x40db, 0x4327, 0x4570, 0x47b4, 0x49f4, 0x4c2d, 0x4e60, 0x508b, 0x52ae, 0x54c8, 0x56d7, 0x58dc, 0x5ad4, 0x5cc0, + 0x5e9f, 0x6070, 0x6232, 0x63e5, 0x6587, 0x6719, 0x689a, 0x6a08, 0x6b64, 0x6cad, 0x6de2, 0x6f03, 0x7010, 0x7108, + 0x71ea, 0x72b7, 0x736e, 0x740f, 0x7499, 0x750c, 0x7569, 0x75ae, 0x75dd, 0x75f4}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_0_92[80] = { + (Word16)0xfff9, (Word16)0xfffa, (Word16)0xfffa, (Word16)0xfffb, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; +# else +# define lpc_lin_pre_emphasis_80_0_92 NULL +# define lpc_lin_pre_emphasis_80_e_0_92 NULL +# endif + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis[NUM_SAMP_FREQ] = {lpc_lin_pre_emphasis_80_8000, lpc_lin_pre_emphasis_80_16000, + lpc_lin_pre_emphasis_80_24000, lpc_lin_pre_emphasis_80_32000, + lpc_lin_pre_emphasis_80_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_0_92 +#endif + }; + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_80_e_8000, lpc_lin_pre_emphasis_80_e_16000, lpc_lin_pre_emphasis_80_e_24000, + lpc_lin_pre_emphasis_80_e_32000, lpc_lin_pre_emphasis_80_e_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_e_0_92 +#endif +}; + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_5ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_40_8000, lpc_lin_pre_emphasis_80_16000, lpc_lin_pre_emphasis_40_24000, + lpc_lin_pre_emphasis_80_32000, lpc_lin_pre_emphasis_80_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_0_92 +#endif +}; + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_5ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_40_e_8000, lpc_lin_pre_emphasis_80_e_16000, lpc_lin_pre_emphasis_40_e_24000, + lpc_lin_pre_emphasis_80_e_32000, lpc_lin_pre_emphasis_80_e_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_e_0_92 +#endif +}; + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_2_5ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_20_8000, lpc_lin_pre_emphasis_40_16000, lpc_lin_pre_emphasis_60_24000, + lpc_lin_pre_emphasis_80_32000, lpc_lin_pre_emphasis_60_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_0_92 +#endif +}; + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_2_5ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_20_e_8000, lpc_lin_pre_emphasis_40_e_16000, lpc_lin_pre_emphasis_60_e_24000, + lpc_lin_pre_emphasis_80_e_32000, lpc_lin_pre_emphasis_60_e_48000 +# ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_e_0_92 +#endif +}; + +# ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_0_62[60] = { + 0x4a26, 0x4be4, 0x4f5d, 0x5490, 0x5b79, 0x6414, 0x6e59, 0x7a43, 0x43e4, 0x4b6f, 0x53bf, 0x5ccc, 0x6690, 0x7106, + 0x7c25, 0x43f3, 0x4a1f, 0x5095, 0x574e, 0x5e46, 0x6578, 0x6cdf, 0x7477, 0x7c39, 0x4210, 0x4613, 0x4a24, 0x4e3e, + 0x5260, 0x5686, 0x5aae, 0x5ed4, 0x62f6, 0x6710, 0x6b21, 0x6f24, 0x7318, 0x76f9, 0x7ac4, 0x7e78, 0x4109, 0x42c7, + 0x4475, 0x4612, 0x479d, 0x4915, 0x4a79, 0x4bc8, 0x4d01, 0x4e22, 0x4f2c, 0x501e, 0x50f6, 0x51b4, 0x5259, 0x52e2, + 0x5351, 0x53a4, 0x53dc, 0x53f8}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_e_0_62[60] = { + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_0_72[60] = { + 0x50c9, 0x54d4, 0x5ce6, 0x68f9, 0x7906, 0x4681, 0x526e, 0x6043, 0x6ff6, 0x40be, 0x4a65, 0x54e8, 0x6040, 0x6c65, + 0x794f, 0x437a, 0x4aa6, 0x5226, 0x59f5, 0x620c, 0x6a68, 0x7301, 0x7bd2, 0x426a, 0x4701, 0x4baa, 0x5062, 0x5526, + 0x59f2, 0x5ec4, 0x6397, 0x6869, 0x6d35, 0x71f9, 0x76b1, 0x7b5a, 0x7ff1, 0x4239, 0x446d, 0x4694, 0x48aa, 0x4ab0, + 0x4ca4, 0x4e84, 0x504f, 0x5204, 0x53a1, 0x5526, 0x5691, 0x57e1, 0x5916, 0x5a2e, 0x5b29, 0x5c07, 0x5cc5, 0x5d65, + 0x5de6, 0x5e46, 0x5e87, 0x5ea7}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_e_0_72[60] = { + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_0_82[60] = { + 0x4382, 0x4cb6, 0x5f17, 0x7a99, 0x4f94, 0x6656, 0x40c0, 0x5081, 0x6263, 0x7658, 0x4629, 0x5222, 0x5f0e, 0x6ce3, + 0x7b98, 0x4591, 0x4dbc, 0x5647, 0x5f2b, 0x6862, 0x71e7, 0x7bb2, 0x42de, 0x47ff, 0x4d39, 0x5288, 0x57e8, 0x5d55, + 0x62cc, 0x6849, 0x6dc8, 0x7345, 0x78bc, 0x7e29, 0x41c5, 0x446c, 0x4709, 0x499a, 0x4c1c, 0x4e8f, 0x50f0, 0x533e, + 0x5577, 0x579a, 0x59a4, 0x5b96, 0x5d6c, 0x5f27, 0x60c4, 0x6243, 0x63a3, 0x64e2, 0x6601, 0x66fd, 0x67d6, 0x688c, + 0x691e, 0x698c, 0x69d6, 0x69fb}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_e_0_82[60] = { + (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_0_92[60] = { + 0x7330, 0x62e5, 0x5ab1, 0x4c35, 0x753a, 0x5425, 0x72a0, 0x4afd, 0x5f0d, 0x7571, 0x470d, 0x547b, 0x62fa, 0x727f, + 0x4180, 0x4a38, 0x5362, 0x5cf7, 0x66f0, 0x7148, 0x7bf5, 0x4379, 0x491b, 0x4edc, 0x54b9, 0x5aae, 0x60b6, 0x66cd, + 0x6cee, 0x7316, 0x7941, 0x7f69, 0x42c5, 0x45d1, 0x48d4, 0x4bcf, 0x4ebd, 0x519e, 0x546f, 0x572e, 0x59d9, 0x5c6f, + 0x5eee, 0x6153, 0x639d, 0x65cb, 0x67dc, 0x69cc, 0x6b9c, 0x6d4a, 0x6ed4, 0x703b, 0x717c, 0x7296, 0x738a, 0x7457, + 0x74fb, 0x7576, 0x75c9, 0x75f2}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_e_0_92[60] = { + (Word16)0xfff9, (Word16)0xfffa, (Word16)0xfffb, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002}; + +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_7_5ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_60_0_62, lpc_lin_pre_emphasis_60_0_72, lpc_lin_pre_emphasis_60_0_82, + lpc_lin_pre_emphasis_80_0_92, lpc_lin_pre_emphasis_60_0_92 +# ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_0_92 +# endif + }; +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_7_5ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_60_e_0_62, lpc_lin_pre_emphasis_60_e_0_72, lpc_lin_pre_emphasis_60_e_0_82, + lpc_lin_pre_emphasis_80_e_0_92, lpc_lin_pre_emphasis_60_e_0_92 +# ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_e_0_92 +# endif + }; +# endif +# endif + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_8000[16] = {0x4000, 0x673f, 0x5348, 0x432d, 0x6c5f, 0x576a, + 0x4682, 0x71bf, 0x5bc0, 0x4a02, 0x7764, 0x604d, + 0x4dae, 0x7d50, 0x6514, 0x5188}; + +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_e_8000[16] = { + (Word16)0x0001, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0xffff, (Word16)0xffff, + (Word16)0xffff, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffd, (Word16)0xfffd, + (Word16)0xfffd, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffc}; +#else +#define lpc_warp_dee_emphasis_16_8000 NULL +#define lpc_warp_dee_emphasis_16_e_8000 NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_16000[16] = {0x4000, 0x6119, 0x49a8, 0x6fc0, 0x54c5, 0x404e, + 0x618f, 0x4a02, 0x7048, 0x552c, 0x409c, 0x6206, + 0x4a5c, 0x70d0, 0x5594, 0x40eb}; + +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_e_16000[16] = { + (Word16)0x0001, (Word16)0x0000, (Word16)0x0000, (Word16)0xffff, (Word16)0xffff, (Word16)0xffff, + (Word16)0xfffe, (Word16)0xfffe, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffc, + (Word16)0xfffc, (Word16)0xfffb, (Word16)0xfffb, (Word16)0xfffb}; +#else +#define lpc_warp_dee_emphasis_16_16000 NULL +#define lpc_warp_dee_emphasis_16_e_16000 NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_24000[16] = {0x4000, 0x5b51, 0x4125, 0x5cf3, 0x424f, 0x5e9c, + 0x437f, 0x604d, 0x44b4, 0x6206, 0x45ee, 0x63c7, + 0x472e, 0x658f, 0x4874, 0x6760}; + +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_e_24000[16] = { + (Word16)0x0001, (Word16)0x0000, (Word16)0x0000, (Word16)0xffff, (Word16)0xffff, (Word16)0xfffe, + (Word16)0xfffe, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffb, + (Word16)0xfffb, (Word16)0xfffa, (Word16)0xfffa, (Word16)0xfff9}; +#else +#define lpc_warp_dee_emphasis_16_24000 NULL +#define lpc_warp_dee_emphasis_16_e_24000 NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_32000[16] = {0x4000, 0x55e1, 0x733b, 0x4d50, 0x67bd, 0x4599, + 0x5d64, 0x7d50, 0x5413, 0x70d0, 0x4bb0, 0x658f, + 0x4423, 0x5b6e, 0x7aaf, 0x524f}; + +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_e_32000[16] = { + (Word16)0x0001, (Word16)0x0000, (Word16)0xffff, (Word16)0xffff, (Word16)0xfffe, (Word16)0xfffe, + (Word16)0xfffd, (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffb, (Word16)0xfffb, (Word16)0xfffa, + (Word16)0xfffa, (Word16)0xfff9, (Word16)0xfff8, (Word16)0xfff8}; +#else +#define lpc_warp_dee_emphasis_16_32000 NULL +#define lpc_warp_dee_emphasis_16_e_32000 NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_48000[16] = {0x4000, 0x50c3, 0x65ea, 0x404e, 0x5126, 0x6666, + 0x409c, 0x5188, 0x66e3, 0x40eb, 0x51ec, 0x6760, + 0x413a, 0x524f, 0x67de, 0x4189}; + +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_e_48000[16] = { + (Word16)0x0001, (Word16)0x0000, (Word16)0xffff, (Word16)0xffff, (Word16)0xfffe, (Word16)0xfffd, + (Word16)0xfffd, (Word16)0xfffc, (Word16)0xfffb, (Word16)0xfffb, (Word16)0xfffa, (Word16)0xfff9, + (Word16)0xfff9, (Word16)0xfff8, (Word16)0xfff7, (Word16)0xfff7}; +#else +#define lpc_warp_dee_emphasis_16_48000 NULL +#define lpc_warp_dee_emphasis_16_e_48000 NULL +#endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_96000[16] = {0x4000, 0x4bf4, 0x5a23, 0x6af9, 0x7ef3, 0x4b54, + 0x5966, 0x6a18, 0x7de9, 0x4ab6, 0x58aa, 0x6939, + 0x7ce0, 0x4a19, 0x57f0, 0x685d}; + +RAM_ALIGN const Word16 lpc_warp_dee_emphasis_16_e_96000[16] = { + (Word16)0x0001, (Word16)0x0000, (Word16)0xffff, (Word16)0xfffe, (Word16)0xfffd, (Word16)0xfffd, + (Word16)0xfffc, (Word16)0xfffb, (Word16)0xfffa, (Word16)0xfffa, (Word16)0xfff9, (Word16)0xfff8, + (Word16)0xfff7, (Word16)0xfff7, (Word16)0xfff6, (Word16)0xfff5}; +# else +# define lpc_warp_dee_emphasis_16_96000 NULL +# define lpc_warp_dee_emphasis_16_e_96000 NULL +# endif + +RAM_ALIGN const Word16 *const lpc_warp_dee_emphasis[NUM_SAMP_FREQ] = { + lpc_warp_dee_emphasis_16_8000, lpc_warp_dee_emphasis_16_16000, lpc_warp_dee_emphasis_16_24000, + lpc_warp_dee_emphasis_16_32000, lpc_warp_dee_emphasis_16_48000, lpc_warp_dee_emphasis_16_96000}; +RAM_ALIGN const Word16 *const lpc_warp_dee_emphasis_e[NUM_SAMP_FREQ] = { + lpc_warp_dee_emphasis_16_e_8000, lpc_warp_dee_emphasis_16_e_16000, lpc_warp_dee_emphasis_16_e_24000, + lpc_warp_dee_emphasis_16_e_32000, lpc_warp_dee_emphasis_16_e_48000, lpc_warp_dee_emphasis_16_e_96000}; + +RAM_ALIGN const Word16 bands_nrg_scale[32] = {0, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 bands_offset_48000_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, + 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 72, 77, 83, 89, 95, 101, 108, 116, + 124, 133, 142, 152, 163, 174, 187, 200, 214, 229, 244, 262, 280, 299, 320, 343, 367, 392, 419, 449, 480}; + +RAM_ALIGN const Word16 bands_offset_96000_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 33, 36, 39, 42, 46, 50, 54, 59, 64, 69, 75, 82, 89, 96, 104, 113, 122, 132, 143, 155, 168, 181, + 196, 213, 230, 249, 270, 292, 316, 342, 371, 401, 434, 470, 509, 551, 596, 646, 699, 757, 819, 887, 960}; + +RAM_ALIGN const Word16 *const bands_offset_HR[2] = {bands_offset_48000_HR, bands_offset_96000_HR}; + +RAM_ALIGN const Word16 bands_offset_48000_5ms_HR[56] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 21, 23, 25, 27, 29, 31, 33, 35, 38, 41, 44, 47, 50, 54, 58, 62, 66, 71, + 76, 81, 87, 93, 100, 107, 114, 122, 131, 140, 149, 160, 171, 183, 196, 209, 224, 240}; +RAM_ALIGN const Word16 bands_offset_96000_5ms_HR[59] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, + 23, 25, 27, 29, 31, 34, 37, 40, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 98, 106, + 115, 124, 135, 146, 158, 171, 185, 200, 217, 235, 254, 275, 298, 323, 349, 378, 409, 443, 480}; + +RAM_ALIGN const Word16 *const bands_offset_5ms_HR[2] = {bands_offset_48000_5ms_HR, bands_offset_96000_5ms_HR}; + +RAM_ALIGN const Word16 bands_offset_48000_2_5ms_HR[46] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 25, + 27, 29, 31, 33, 35, 37, 40, 43, 46, 49, 53, 57, 61, 65, 69, 74, 79, 85, 91, 97, 104, 112, 120}; +RAM_ALIGN const Word16 bands_offset_96000_2_5ms_HR[50] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, + 35, 38, 41, 45, 49, 53, 57, 62, 67, 73, 79, 85, 92, 100, 108, 117, 127, 137, 149, 161, 174, 189, 204, 221, 240}; + +RAM_ALIGN const Word16 *const bands_offset_2_5ms_HR[2] = {bands_offset_48000_2_5ms_HR, bands_offset_96000_2_5ms_HR}; + +#ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 bands_offset_48000_7_5ms_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, + 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 73, 78, 83, 89, 95, 101, 108, + 115, 122, 130, 139, 148, 158, 168, 179, 191, 203, 217, 231, 246, 262, 279, 298, 317, 338, 360}; +RAM_ALIGN const Word16 bands_offset_96000_7_5ms_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, + 30, 32, 35, 38, 41, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 97, 105, 114, 123, 132, 143, 155, 167, + 180, 195, 210, 227, 245, 265, 286, 309, 334, 360, 389, 420, 454, 490, 529, 572, 617, 667, 720}; + +RAM_ALIGN const Word16 *const bands_offset_7_5ms_HR[2] = {bands_offset_48000_7_5ms_HR, bands_offset_96000_7_5ms_HR}; +# endif +#endif /* ENABLE_HR_MODE */ + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 bands_offset_8000_lpc_warp[65] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, + 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, + 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, + 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0033, 0x0035, + 0x0037, 0x0039, 0x003b, 0x003d, 0x003f, 0x0041, 0x0043, 0x0045, 0x0047, 0x0049, 0x004b, 0x004d, 0x0050}; +#else +#define bands_offset_8000_lpc_warp NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 bands_offset_16000_lpc_warp[65] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, + 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, + 0x001a, 0x001b, 0x001c, 0x001e, 0x0020, 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002c, 0x002e, 0x0030, + 0x0032, 0x0034, 0x0037, 0x003a, 0x003d, 0x0040, 0x0043, 0x0046, 0x0049, 0x004c, 0x0050, 0x0054, 0x0058, + 0x005c, 0x0060, 0x0065, 0x006a, 0x006f, 0x0074, 0x0079, 0x007f, 0x0085, 0x008b, 0x0092, 0x0099, 0x00a0}; +#else +#define bands_offset_16000_lpc_warp NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 bands_offset_24000_lpc_warp[65] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, + 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0019, 0x001b, + 0x001d, 0x001f, 0x0021, 0x0023, 0x0025, 0x0027, 0x0029, 0x002b, 0x002e, 0x0031, 0x0034, 0x0037, 0x003a, + 0x003d, 0x0040, 0x0044, 0x0048, 0x004c, 0x0050, 0x0055, 0x005a, 0x005f, 0x0064, 0x006a, 0x0070, 0x0076, + 0x007d, 0x0084, 0x008b, 0x0093, 0x009b, 0x00a4, 0x00ad, 0x00b7, 0x00c1, 0x00cc, 0x00d7, 0x00e3, 0x00f0}; +#else +#define bands_offset_24000_lpc_warp NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 bands_offset_32000_lpc_warp[65] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, + 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0016, 0x0018, 0x001a, 0x001c, 0x001e, + 0x0020, 0x0022, 0x0024, 0x0026, 0x0029, 0x002c, 0x002f, 0x0032, 0x0035, 0x0038, 0x003c, 0x0040, 0x0044, + 0x0048, 0x004c, 0x0051, 0x0056, 0x005b, 0x0061, 0x0067, 0x006d, 0x0074, 0x007b, 0x0083, 0x008b, 0x0094, + 0x009d, 0x00a6, 0x00b0, 0x00bb, 0x00c7, 0x00d3, 0x00e0, 0x00ee, 0x00fc, 0x010c, 0x011c, 0x012e, 0x0140}; +#else +#define bands_offset_32000_lpc_warp NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 bands_offset_48000_lpc_warp[65] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, + 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0014, 0x0016, 0x0018, 0x001a, 0x001c, 0x001e, 0x0020, + 0x0022, 0x0024, 0x0027, 0x002a, 0x002d, 0x0030, 0x0033, 0x0037, 0x003b, 0x003f, 0x0043, 0x0047, 0x004c, + 0x0051, 0x0056, 0x005c, 0x0062, 0x0069, 0x0070, 0x0077, 0x007f, 0x0087, 0x0090, 0x009a, 0x00a4, 0x00af, + 0x00ba, 0x00c6, 0x00d3, 0x00e1, 0x00f0, 0x0100, 0x0111, 0x0123, 0x0136, 0x014a, 0x0160, 0x0177, 0x0190}; +#else +#define bands_offset_48000_lpc_warp NULL +#endif + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 bands_offset_8000_lpc_lin[81] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, + 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, + 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, + 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, + 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050}; +#else +#define bands_offset_8000_lpc_lin NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 bands_offset_16000_lpc_lin[81] = { + 0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000a, 0x000c, 0x000e, 0x0010, 0x0012, 0x0014, 0x0016, 0x0018, 0x001a, + 0x001c, 0x001e, 0x0020, 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002c, 0x002e, 0x0030, 0x0032, 0x0034, 0x0036, + 0x0038, 0x003a, 0x003c, 0x003e, 0x0040, 0x0042, 0x0044, 0x0046, 0x0048, 0x004a, 0x004c, 0x004e, 0x0050, 0x0052, + 0x0054, 0x0056, 0x0058, 0x005a, 0x005c, 0x005e, 0x0060, 0x0062, 0x0064, 0x0066, 0x0068, 0x006a, 0x006c, 0x006e, + 0x0070, 0x0072, 0x0074, 0x0076, 0x0078, 0x007a, 0x007c, 0x007e, 0x0080, 0x0082, 0x0084, 0x0086, 0x0088, 0x008a, + 0x008c, 0x008e, 0x0090, 0x0092, 0x0094, 0x0096, 0x0098, 0x009a, 0x009c, 0x009e, 0x00a0}; +#else +#define bands_offset_16000_lpc_lin NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 bands_offset_24000_lpc_lin[81] = { + 0x0000, 0x0003, 0x0006, 0x0009, 0x000c, 0x000f, 0x0012, 0x0015, 0x0018, 0x001b, 0x001e, 0x0021, 0x0024, 0x0027, + 0x002a, 0x002d, 0x0030, 0x0033, 0x0036, 0x0039, 0x003c, 0x003f, 0x0042, 0x0045, 0x0048, 0x004b, 0x004e, 0x0051, + 0x0054, 0x0057, 0x005a, 0x005d, 0x0060, 0x0063, 0x0066, 0x0069, 0x006c, 0x006f, 0x0072, 0x0075, 0x0078, 0x007b, + 0x007e, 0x0081, 0x0084, 0x0087, 0x008a, 0x008d, 0x0090, 0x0093, 0x0096, 0x0099, 0x009c, 0x009f, 0x00a2, 0x00a5, + 0x00a8, 0x00ab, 0x00ae, 0x00b1, 0x00b4, 0x00b7, 0x00ba, 0x00bd, 0x00c0, 0x00c3, 0x00c6, 0x00c9, 0x00cc, 0x00cf, + 0x00d2, 0x00d5, 0x00d8, 0x00db, 0x00de, 0x00e1, 0x00e4, 0x00e7, 0x00ea, 0x00ed, 0x00f0}; +#else +#define bands_offset_24000_lpc_lin NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 bands_offset_32000_lpc_lin[81] = { + 0x0000, 0x0004, 0x0008, 0x000c, 0x0010, 0x0014, 0x0018, 0x001c, 0x0020, 0x0024, 0x0028, 0x002c, 0x0030, 0x0034, + 0x0038, 0x003c, 0x0040, 0x0044, 0x0048, 0x004c, 0x0050, 0x0054, 0x0058, 0x005c, 0x0060, 0x0064, 0x0068, 0x006c, + 0x0070, 0x0074, 0x0078, 0x007c, 0x0080, 0x0084, 0x0088, 0x008c, 0x0090, 0x0094, 0x0098, 0x009c, 0x00a0, 0x00a4, + 0x00a8, 0x00ac, 0x00b0, 0x00b4, 0x00b8, 0x00bc, 0x00c0, 0x00c4, 0x00c8, 0x00cc, 0x00d0, 0x00d4, 0x00d8, 0x00dc, + 0x00e0, 0x00e4, 0x00e8, 0x00ec, 0x00f0, 0x00f4, 0x00f8, 0x00fc, 0x0100, 0x0104, 0x0108, 0x010c, 0x0110, 0x0114, + 0x0118, 0x011c, 0x0120, 0x0124, 0x0128, 0x012c, 0x0130, 0x0134, 0x0138, 0x013c, 0x0140}; +#else +#define bands_offset_32000_lpc_lin NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 bands_offset_48000_lpc_lin[81] = { + 0x0000, 0x0006, 0x000c, 0x0012, 0x0018, 0x001e, 0x0024, 0x002a, 0x0030, 0x0036, 0x003c, 0x0042, 0x0048, 0x004e, + 0x0054, 0x005a, 0x0060, 0x0066, 0x006c, 0x0072, 0x0078, 0x007e, 0x0084, 0x008a, 0x0090, 0x0096, 0x009c, 0x00a2, + 0x00a8, 0x00ae, 0x00b4, 0x00ba, 0x00c0, 0x00c6, 0x00cc, 0x00d2, 0x00d8, 0x00de, 0x00e4, 0x00ea, 0x00f0, 0x00f6, + 0x00fc, 0x0102, 0x0108, 0x010e, 0x0114, 0x011a, 0x0120, 0x0126, 0x012c, 0x0132, 0x0138, 0x013e, 0x0144, 0x014a, + 0x0150, 0x0156, 0x015c, 0x0162, 0x0168, 0x016e, 0x0174, 0x017a, 0x0180, 0x0186, 0x018c, 0x0192, 0x0198, 0x019e, + 0x01a4, 0x01aa, 0x01b0, 0x01b6, 0x01bc, 0x01c2, 0x01c8, 0x01ce, 0x01d4, 0x01da, 0x01e0}; +#else +#define bands_offset_48000_lpc_lin NULL +#endif + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 bands_offset_8000_lpc_warp_5ms[40] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, + 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, + 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0028}; +#else +#define bands_offset_8000_lpc_warp_5ms NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 bands_offset_16000_lpc_warp_5ms[51] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, + 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, + 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x0020, 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002c, 0x002e, + 0x0030, 0x0032, 0x0034, 0x0036, 0x0039, 0x003c, 0x003f, 0x0042, 0x0045, 0x0048, 0x004c, 0x0050}; +#else +#define bands_offset_16000_lpc_warp_5ms NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 bands_offset_24000_lpc_warp_5ms[53] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, + 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x001a, 0x001c, 0x001e, + 0x0020, 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002c, 0x002f, 0x0032, 0x0035, 0x0038, 0x003b, 0x003e, 0x0041, + 0x0045, 0x0049, 0x004d, 0x0051, 0x0056, 0x005b, 0x0060, 0x0065, 0x006b, 0x0071, 0x0078}; +#else +#define bands_offset_24000_lpc_warp_5ms NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 bands_offset_32000_lpc_warp_5ms[55] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, + 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0018, 0x001a, 0x001c, 0x001e, 0x0020, + 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002d, 0x0030, 0x0033, 0x0036, 0x0039, 0x003d, 0x0041, 0x0045, 0x0049, + 0x004e, 0x0053, 0x0058, 0x005d, 0x0063, 0x0069, 0x0070, 0x0077, 0x007e, 0x0086, 0x008e, 0x0097, 0x00a0}; +#else +#define bands_offset_32000_lpc_warp_5ms NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 bands_offset_48000_lpc_warp_5ms[56] = { + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, + 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0017, 0x0019, 0x001b, 0x001d, 0x001f, 0x0021, + 0x0023, 0x0025, 0x0028, 0x002b, 0x002e, 0x0031, 0x0034, 0x0037, 0x003b, 0x003f, 0x0043, 0x0048, 0x004d, 0x0052, + 0x0057, 0x005d, 0x0063, 0x0069, 0x0070, 0x0078, 0x0080, 0x0088, 0x0091, 0x009b, 0x00a5, 0x00b0, 0x00bb, 0x00c8}; +#else +#define bands_offset_48000_lpc_warp_5ms NULL +#endif + + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 bands_offset_8000_lpc_warp_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +#else +#define bands_offset_8000_lpc_warp_2_5ms NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 bands_offset_16000_lpc_warp_2_5ms[36] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, 38, 40}; +#else +#define bands_offset_16000_lpc_warp_2_5ms NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 bands_offset_24000_lpc_warp_2_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 60}; +#else +#define bands_offset_24000_lpc_warp_2_5ms NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 bands_offset_32000_lpc_warp_2_5ms[44] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80}; +#else +#define bands_offset_32000_lpc_warp_2_5ms NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 bands_offset_48000_lpc_warp_2_5ms[45] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, + 25, 27, 29, 31, 33, 35, 37, 40, 43, 46, 49, 52, 56, 60, 64, 68, 72, 77, 82, 87, 93, 100}; +#else +#define bands_offset_48000_lpc_warp_2_5ms NULL +#endif + + + +RAM_ALIGN const Word16 *const bands_offset[6] = {bands_offset_8000_lpc_warp, bands_offset_16000_lpc_warp, + bands_offset_24000_lpc_warp, bands_offset_32000_lpc_warp, + bands_offset_48000_lpc_warp, NULL}; + +#ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 bands_offset_with_one_max_7_5ms[NUM_OFFSETS] = {60, 34, 27, 24, 22 +# ifdef ENABLE_HR_MODE + , 20, 16 +# endif +}; +RAM_ALIGN const Word16 bands_offset_with_two_max_7_5ms[NUM_OFFSETS] = {0, 48, 38, 33, 31 +# ifdef ENABLE_HR_MODE + , 29, 24 +# endif +}; +# endif + +RAM_ALIGN const Word16 bands_offset_with_one_max[NUM_OFFSETS] = {49, 28, 23, 20, 18 +# ifdef ENABLE_HR_MODE + , 17, 12 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_two_max[NUM_OFFSETS] = {63, 40, 33, 29, 27 +# ifdef ENABLE_HR_MODE + , 25, 21 +# endif + }; + +RAM_ALIGN const Word16 *const bands_offset_5ms[6] = {bands_offset_8000_lpc_warp_5ms, bands_offset_16000_lpc_warp_5ms, + bands_offset_24000_lpc_warp_5ms, bands_offset_32000_lpc_warp_5ms, + bands_offset_48000_lpc_warp_5ms, NULL}; +RAM_ALIGN const Word16 bands_offset_with_one_max_5ms[NUM_OFFSETS] = {38, 30, 24, 22, 21 +# ifdef ENABLE_HR_MODE + , 19, 17 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_two_max_5ms[NUM_OFFSETS] = {39, 42, 34, 32, 29 +# ifdef ENABLE_HR_MODE + , 27, 24 +# endif + }; + +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 bands_number_7_5ms [] = {60, 64, 64, 64, 64, 64}; +# else +RAM_ALIGN const Word16 bands_number_7_5ms [] = {60, 64, 64, 64, 64}; +# endif +#endif + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 bands_number_5ms[NUM_SAMP_FREQ] = {39, 50, 52, 54, 55, 58}; +#else +RAM_ALIGN const Word16 bands_number_5ms[NUM_SAMP_FREQ] = {39, 50, 52, 54, 55}; +#endif + +RAM_ALIGN const Word16 *const bands_offset_2_5ms[6] = { + bands_offset_8000_lpc_warp_2_5ms, bands_offset_16000_lpc_warp_2_5ms, bands_offset_24000_lpc_warp_2_5ms, + bands_offset_32000_lpc_warp_2_5ms, bands_offset_48000_lpc_warp_2_5ms, NULL}; + +RAM_ALIGN const Word16 bands_offset_with_one_max_2_5ms[NUM_OFFSETS] = {20, 30, 26, 24, 21 +# ifdef ENABLE_HR_MODE + , 19, 16 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_two_max_2_5ms[NUM_OFFSETS] = {20, 35, 35, 32, 29 +# ifdef ENABLE_HR_MODE + , 28, 24 +# endif + }; + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 bands_number_2_5ms_HR[] = {20, 35, 40, 43, 45, 49}; +RAM_ALIGN const Word16 bands_number_2_5ms [] = {20, 35, 40, 43, 44, 49}; +# else +RAM_ALIGN const Word16 bands_number_2_5ms [] = {20, 35, 40, 43, 44}; +# endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 bands_offset_96000_lpc_lin[81] = +{ + 0x0000, 0x000c, 0x0018, 0x0024, 0x0030, 0x003c, 0x0048, 0x0054, 0x0060, 0x006c, 0x0078, 0x0084, 0x0090, 0x009c, + 0x00a8, 0x00b4, 0x00c0, 0x00cc, 0x00d8, 0x00e4, 0x00f0, 0x00fc, 0x0108, 0x0114, 0x0120, 0x012c, 0x0138, 0x0144, + 0x0150, 0x015c, 0x0168, 0x0174, 0x0180, 0x018c, 0x0198, 0x01a4, 0x01b0, 0x01bc, 0x01c8, 0x01d4, 0x01e0, 0x01ec, + 0x01f8, 0x0204, 0x0210, 0x021c, 0x0228, 0x0234, 0x0240, 0x024c, 0x0258, 0x0264, 0x0270, 0x027c, 0x0288, 0x0294, + 0x02a0, 0x02ac, 0x02b8, 0x02c4, 0x02d0, 0x02dc, 0x02e8, 0x02f4, 0x0300, 0x030c, 0x0318, 0x0324, 0x0330, 0x033c, + 0x0348, 0x0354, 0x0360, 0x036c, 0x0378, 0x0384, 0x0390, 0x039c, 0x03a8, 0x03b4, 0x03c0 +}; + +# ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 bands_offset_96000_lpc_lin_7_5ms[81] = +{ + 0x0000, 0x0009, 0x0012, 0x001b, 0x0024, 0x002d, 0x0036, 0x003f, 0x0048, 0x0051, 0x005a, 0x0063, 0x006c, 0x0075, + 0x007e, 0x0087, 0x0090, 0x0099, 0x00a2, 0x00ab, 0x00b4, 0x00bd, 0x00c6, 0x00cf, 0x00d8, 0x00e1, 0x00ea, 0x00f3, + 0x00fc, 0x0105, 0x010e, 0x0117, 0x0120, 0x0129, 0x0132, 0x013b, 0x0144, 0x014d, 0x0156, 0x015f, 0x0168, 0x0171, + 0x017a, 0x0183, 0x018c, 0x0195, 0x019e, 0x01a7, 0x01b0, 0x01b9, 0x01c2, 0x01cb, 0x01d4, 0x01dd, 0x01e6, 0x01ef, + 0x01f8, 0x0201, 0x020a, 0x0213, 0x021c, 0x0225, 0x022e, 0x0237, 0x0240, 0x0249, 0x0252, 0x025b, 0x0264, 0x026d, + 0x0276, 0x027f, 0x0288, 0x0291, 0x029a, 0x02a3, 0x02ac, 0x02b5, 0x02be, 0x02c7, 0x02d0 +}; +# endif +# endif + + +RAM_ALIGN const Word16 *const bands_offset_lin[NUM_SAMP_FREQ] = {bands_offset_8000_lpc_lin, bands_offset_16000_lpc_lin, + bands_offset_24000_lpc_lin, bands_offset_32000_lpc_lin, + bands_offset_48000_lpc_lin +# ifdef ENABLE_HR_MODE + , bands_offset_96000_lpc_lin +# endif + }; + +# ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 *const bands_offset_lin_7_5ms[NUM_SAMP_FREQ] = {bands_offset_8000_lpc_lin, bands_offset_16000_lpc_lin, + bands_offset_24000_lpc_lin, bands_offset_24000_lpc_lin, + bands_offset_48000_lpc_lin +# ifdef ENABLE_HR_MODE + , bands_offset_96000_lpc_lin_7_5ms +# endif + }; +# endif + +RAM_ALIGN const Word16 *const bands_offset_lin_5ms[NUM_SAMP_FREQ] = {bands_offset_8000_lpc_lin, bands_offset_8000_lpc_lin, + bands_offset_24000_lpc_lin, bands_offset_16000_lpc_lin, + bands_offset_24000_lpc_lin +# ifdef ENABLE_HR_MODE + , bands_offset_48000_lpc_lin +# endif + }; +RAM_ALIGN const Word16 *const bands_offset_lin_2_5ms[NUM_SAMP_FREQ] = {bands_offset_8000_lpc_lin, bands_offset_8000_lpc_lin, + bands_offset_8000_lpc_lin, bands_offset_8000_lpc_lin, + bands_offset_16000_lpc_lin +# ifdef ENABLE_HR_MODE + , bands_offset_24000_lpc_lin +# endif + }; + +RAM_ALIGN const Word16 bands_offset_with_one_max_lin[NUM_SAMP_FREQ] = {80, 0, 0, 0, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_two_max_lin[NUM_SAMP_FREQ] = {0, 80, 0, 0, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; + +# ifdef CR8_G_ADD_75MS +RAM_ALIGN const Word16 bands_offset_with_one_max_lin_7_5ms[NUM_SAMP_FREQ] = {60, 0, 0, 0, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; + +RAM_ALIGN const Word16 bands_offset_with_two_max_lin_7_5ms[NUM_SAMP_FREQ] = {0, 60, 0, 0, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; +#endif + +RAM_ALIGN const Word16 bands_offset_with_one_max_lin_5ms[NUM_SAMP_FREQ] = {40, 80, 0, 0, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_two_max_lin_5ms[NUM_SAMP_FREQ] = {0, 0, 0, 80, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_one_max_lin_2_5ms[NUM_SAMP_FREQ] = {20, 40, 60, 80, 0 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; +RAM_ALIGN const Word16 bands_offset_with_two_max_lin_2_5ms[NUM_SAMP_FREQ] = {0, 0, 0, 0, 60 +# ifdef ENABLE_HR_MODE + , 0 +# endif + }; +#ifdef CR8_G_ADD_75MS +# ifdef SUBSET_NB +RAM_ALIGN const Word16 bands_offset_8000_lpc_warp_7_5ms[61] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}; +# else +# define bands_offset_8000_lpc_warp_7_5ms NULL +# endif + +# ifdef SUBSET_WB +RAM_ALIGN const Word16 bands_offset_16000_lpc_warp_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, + 54, 56, 58, 60, 62, 65, 68, 71, 74, 77, 80, 83, 86, 90, 94, 98, 102, 106, 110, 115, 120}; +# else +# define bands_offset_16000_lpc_warp_7_5ms NULL +# endif + +# ifdef SUBSET_SSWB +RAM_ALIGN const Word16 bands_offset_24000_lpc_warp_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 52, 55, 58, 61, 64, + 67, 70, 74, 78, 82, 86, 90, 95, 100, 105, 110, 115, 121, 127, 134, 141, 148, 155, 163, 171, 180}; +# else +# define bands_offset_24000_lpc_warp_7_5ms NULL +# endif + +# ifdef SUBSET_SWB +RAM_ALIGN const Word16 bands_offset_32000_lpc_warp_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 60, 63, 67, 71, 75, + 79, 84, 89, 94, 99, 105, 111, 117, 124, 131, 138, 146, 154, 163, 172, 182, 192, 203, 215, 227, 240}; +# else +# define bands_offset_32000_lpc_warp_7_5ms NULL +# endif + +# ifdef SUBSET_FB +RAM_ALIGN const Word16 bands_offset_48000_lpc_warp_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80, 85, + 90, 96, 102, 108, 115, 122, 129, 137, 146, 155, 165, 175, 186, 197, 209, 222, 236, 251, 266, 283, 300}; +# else +# define bands_offset_48000_lpc_warp_7_5ms NULL +# endif + +RAM_ALIGN const Word16 *const bands_offset_7_5ms[5] = { + bands_offset_8000_lpc_warp_7_5ms, bands_offset_16000_lpc_warp_7_5ms, bands_offset_24000_lpc_warp_7_5ms, + bands_offset_32000_lpc_warp_7_5ms, bands_offset_48000_lpc_warp_7_5ms}; +# endif /* ifdef CR8_G_ADD_75MS */ + +RAM_ALIGN const Word32 inv_odft_twiddle_80_re[M] = { + 0x7ff9af04, 0x7fe6bcb0, 0x7fc72ae2, 0x7f9afcb9, 0x7f62368f, 0x7f1cde01, 0x7ecaf9e5, 0x7e6c9251, + 0x7e01b096, 0x7d8a5f40, 0x7d06aa16, 0x7c769e18, 0x7bda497d, 0x7b31bbb2, 0x7a7d055b, 0x79bc384d}; + +RAM_ALIGN const Word32 inv_odft_twiddle_80_im[M] = { + 0x02835b5a, 0x05067734, 0x07891418, 0x0a0af299, 0x0c8bd35e, 0x0f0b7727, 0x11899ed3, 0x14060b68, + 0x16807e15, 0x18f8b83c, 0x1b6e7b7a, 0x1de189a6, 0x2051a4dd, 0x22be8f87, 0x25280c5e, 0x278dde6e}; + +RAM_ALIGN const Word32 inv_odft_twiddle_60_re[16] = { + 0x7ff4c56f, 0x7fd317b4, 0x7f9afcb9, 0x7f4c7e54, 0x7ee7aa4c, 0x7e6c9251, 0x7ddb4bfc, 0x7d33f0ca, + 0x7c769e18, 0x7ba3751d, 0x7aba9ae6, 0x79bc384d, 0x78a879f4, 0x777f903c, 0x7641af3d, 0x74ef0ebc}; + +RAM_ALIGN const Word32 inv_odft_twiddle_60_im[16] = { + 0x0359c428, 0x06b2f1d2, 0x0a0af299, 0x0d61304e, 0x10b5150f, 0x14060b68, 0x17537e63, 0x1a9cd9ac, + 0x1de189a6, 0x2120fb83, 0x245a9d65, 0x278dde6e, 0x2aba2ee4, 0x2ddf0040, 0x30fbc54d, 0x340ff242}; + +RAM_ALIGN const Word32 inv_odft_twiddle_40_re[16] = { + 0x7fe6bcb0, 0x7f9afcb9, 0x7f1cde01, 0x7e6c9251, 0x7d8a5f40, 0x7c769e18, 0x7b31bbb2, 0x79bc384d, + 0x7816a759, 0x7641af3d, 0x743e0918, 0x720c8075, 0x6fadf2fc, 0x6d23501b, 0x6a6d98a4, 0x678dde6e}; + +RAM_ALIGN const Word32 inv_odft_twiddle_40_im[16] = { + 0x05067734, 0x0a0af299, 0x0f0b7727, 0x14060b68, 0x18f8b83c, 0x1de189a6, 0x22be8f87, 0x278dde6e, + 0x2c4d9050, 0x30fbc54d, 0x3596a46c, 0x3a1c5c57, 0x3e8b240e, 0x42e13ba4, 0x471cece7, 0x4b3c8c12}; + +RAM_ALIGN const Word32 inv_odft_twiddle_20_re[16] = { + 0x7f9afcb9, 0x7e6c9251, 0x7c769e18, 0x79bc384d, 0x7641af3d, 0x720c8075, 0x6d23501b, 0x678dde6e, + 0x6154fb91, 0x5a82799a, 0x53211d18, 0x4b3c8c12, 0x42e13ba4, 0x3a1c5c57, 0x30fbc54d, 0x278dde6e}; + +RAM_ALIGN const Word32 inv_odft_twiddle_20_im[16] = { + 0x0a0af299, 0x14060b68, 0x1de189a6, 0x278dde6e, 0x30fbc54d, 0x3a1c5c57, 0x42e13ba4, 0x4b3c8c12, + 0x53211d18, 0x5a82799a, 0x6154fb91, 0x678dde6e, 0x6d23501b, 0x720c8075, 0x7641af3d, 0x79bc384d}; + +#ifdef SUBSET_NB +RAM_ALIGN const Word16 resamp_filt_8k[240] = { + 214, 417, -1052, -4529, 26233, -4529, -1052, 417, 214, 0, 212, 277, -1281, -3928, 26037, -4979, + -755, 550, 206, -8, 200, 136, -1439, -3214, 25456, -5243, -401, 668, 187, -18, 180, 0, + -1522, -2427, 24506, -5289, 0, 763, 156, -28, 154, -125, -1534, -1605, 23211, -5090, 432, 831, + 114, -39, 124, -234, -1478, -785, 21609, -4626, 877, 865, 61, -50, 92, -323, -1361, 0, + 19741, -3885, 1317, 861, 0, -61, 60, -391, -1194, 720, 17658, -2863, 1729, 815, -68, -69, + 29, -436, -987, 1351, 15414, -1563, 2093, 727, -140, -76, 0, -457, -752, 1873, 13068, 0, + 2389, 598, -213, -79, -25, -457, -501, 2274, 10677, 1803, 2597, 430, -282, -77, -46, -436, + -247, 2545, 8302, 3815, 2700, 229, -345, -72, -61, -398, 0, 2686, 5997, 5997, 2686, 0, + -398, -61, -72, -345, 229, 2700, 3815, 8302, 2545, -247, -436, -46, -77, -282, 430, 2597, + 1803, 10677, 2274, -501, -457, -25, -79, -213, 598, 2389, 0, 13068, 1873, -752, -457, 0, + -76, -140, 727, 2093, -1563, 15414, 1351, -987, -436, 29, -69, -68, 815, 1729, -2863, 17658, + 720, -1194, -391, 60, -61, 0, 861, 1317, -3885, 19741, 0, -1361, -323, 92, -50, 61, + 865, 877, -4626, 21609, -785, -1478, -234, 124, -39, 114, 831, 432, -5090, 23211, -1605, -1534, + -125, 154, -28, 156, 763, 0, -5289, 24506, -2427, -1522, 0, 180, -18, 187, 668, -401, + -5243, 25456, -3214, -1439, 136, 200, -8, 206, 550, -755, -4979, 26037, -3928, -1281, 277, 212}; +#else +#define resamp_filt_8k NULL +#endif + +#ifdef SUBSET_WB +RAM_ALIGN const Word16 resamp_filt_16k[240] = { + -61, 214, -398, 417, 0, -1052, 2686, -4529, 5997, 26233, 5997, -4529, 2686, -1052, 0, 417, + -398, 214, -61, 0, -72, 212, -345, 277, 229, -1281, 2700, -3928, 3815, 26037, 8302, -4979, + 2545, -755, -247, 550, -436, 206, -46, -8, -77, 200, -282, 136, 430, -1439, 2597, -3214, + 1803, 25456, 10677, -5243, 2274, -401, -501, 668, -457, 187, -25, -18, -79, 180, -213, 0, + 598, -1522, 2389, -2427, 0, 24506, 13068, -5289, 1873, 0, -752, 763, -457, 156, 0, -28, + -76, 154, -140, -125, 727, -1534, 2093, -1605, -1563, 23211, 15414, -5090, 1351, 432, -987, 831, + -436, 114, 29, -39, -69, 124, -68, -234, 815, -1478, 1729, -785, -2863, 21609, 17658, -4626, + 720, 877, -1194, 865, -391, 61, 60, -50, -61, 92, 0, -323, 861, -1361, 1317, 0, + -3885, 19741, 19741, -3885, 0, 1317, -1361, 861, -323, 0, 92, -61, -50, 60, 61, -391, + 865, -1194, 877, 720, -4626, 17658, 21609, -2863, -785, 1729, -1478, 815, -234, -68, 124, -69, + -39, 29, 114, -436, 831, -987, 432, 1351, -5090, 15414, 23211, -1563, -1605, 2093, -1534, 727, + -125, -140, 154, -76, -28, 0, 156, -457, 763, -752, 0, 1873, -5289, 13068, 24506, 0, + -2427, 2389, -1522, 598, 0, -213, 180, -79, -18, -25, 187, -457, 668, -501, -401, 2274, + -5243, 10677, 25456, 1803, -3214, 2597, -1439, 430, 136, -282, 200, -77, -8, -46, 206, -436, + 550, -247, -755, 2545, -4979, 8302, 26037, 3815, -3928, 2700, -1281, 229, 277, -345, 212, -72}; +#else +#define resamp_filt_16k NULL +#endif + +#ifdef SUBSET_SSWB +RAM_ALIGN const Word16 resamp_filt_24k[240] = { + -50, 19, 143, -93, -290, 278, 485, -658, -701, 1396, 901, -3019, -1042, 10276, 17488, 10276, + -1042, -3019, 901, 1396, -701, -658, 485, 278, -290, -93, 143, 19, -50, 0, -46, 0, + 141, -45, -305, 185, 543, -501, -854, 1153, 1249, -2619, -1908, 8712, 17358, 11772, 0, -3319, + 480, 1593, -504, -796, 399, 367, -261, -142, 138, 40, -52, -5, -41, -17, 133, 0, + -304, 91, 574, -334, -959, 878, 1516, -2143, -2590, 7118, 16971, 13161, 1202, -3495, 0, 1731, + -267, -908, 287, 445, -215, -188, 125, 62, -52, -12, -34, -30, 120, 41, -291, 0, + 577, -164, -1015, 585, 1697, -1618, -3084, 5534, 16337, 14406, 2544, -3526, -523, 1800, 0, -985, + 152, 509, -156, -230, 104, 83, -48, -19, -26, -41, 103, 76, -265, -83, 554, 0, + -1023, 288, 1791, -1070, -3393, 3998, 15474, 15474, 3998, -3393, -1070, 1791, 288, -1023, 0, 554, + -83, -265, 76, 103, -41, -26, -19, -48, 83, 104, -230, -156, 509, 152, -985, 0, + 1800, -523, -3526, 2544, 14406, 16337, 5534, -3084, -1618, 1697, 585, -1015, -164, 577, 0, -291, + 41, 120, -30, -34, -12, -52, 62, 125, -188, -215, 445, 287, -908, -267, 1731, 0, + -3495, 1202, 13161, 16971, 7118, -2590, -2143, 1516, 878, -959, -334, 574, 91, -304, 0, 133, + -17, -41, -5, -52, 40, 138, -142, -261, 367, 399, -796, -504, 1593, 480, -3319, 0, + 11772, 17358, 8712, -1908, -2619, 1249, 1153, -854, -501, 543, 185, -305, -45, 141, 0, -46}; +#else +#define resamp_filt_24k NULL +#endif + +#ifdef SUBSET_SWB +RAM_ALIGN const Word16 resamp_filt_32k[240] = { + -30, -31, 46, 107, 0, -199, -162, 209, 430, 0, -681, -526, 658, 1343, 0, -2264, + -1943, 2999, 9871, 13116, 9871, 2999, -1943, -2264, 0, 1343, 658, -526, -681, 0, 430, 209, + -162, -199, 0, 107, 46, -31, -30, 0, -25, -36, 30, 106, 31, -173, -195, 139, + 432, 114, -597, -641, 439, 1350, 360, -1964, -2313, 1908, 8829, 13019, 10804, 4151, -1431, -2489, + -393, 1273, 864, -378, -739, -123, 408, 275, -117, -218, -34, 103, 62, -23, -35, -4, + -20, -39, 14, 100, 57, -141, -218, 68, 416, 215, -494, -719, 216, 1298, 676, -1607, + -2545, 902, 7707, 12728, 11606, 5339, -781, -2621, -803, 1137, 1047, -200, -767, -251, 364, 334, + -62, -228, -70, 94, 77, -13, -38, -9, -14, -39, 0, 90, 78, -106, -229, 0, + 382, 299, -376, -761, 0, 1194, 937, -1214, -2644, 0, 6534, 12253, 12253, 6534, 0, -2644, + -1214, 937, 1194, 0, -761, -376, 299, 382, 0, -229, -106, 78, 90, 0, -39, -14, + -9, -38, -13, 77, 94, -70, -228, -62, 334, 364, -251, -767, -200, 1047, 1137, -803, + -2621, -781, 5339, 11606, 12728, 7707, 902, -2545, -1607, 676, 1298, 216, -719, -494, 215, 416, + 68, -218, -141, 57, 100, 14, -39, -20, -4, -35, -23, 62, 103, -34, -218, -117, + 275, 408, -123, -739, -378, 864, 1273, -393, -2489, -1431, 4151, 10804, 13019, 8829, 1908, -2313, + -1964, 360, 1350, 439, -641, -597, 114, 432, 139, -195, -173, 31, 106, 30, -36, -25}; +#else +#define resamp_filt_32k NULL +#endif + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 resamp_filt_96k[240] = { + -3, -7, -10, -13, -13, -10, -4, 5, 15, 26, 33, 36, 31, 19, 0, -23, -47, -66, -76, + -73, -54, -21, 23, 70, 111, 139, 143, 121, 72, 0, -84, -165, -227, -256, -240, -175, -67, 72, + 219, 349, 433, 448, 379, 225, 0, -268, -536, -755, -874, -848, -648, -260, 301, 1000, 1780, 2569, 3290, + 3869, 4243, 4372, 4243, 3869, 3290, 2569, 1780, 1000, 301, -260, -648, -848, -874, -755, -536, -268, 0, 225, + 379, 448, 433, 349, 219, 72, -67, -175, -240, -256, -227, -165, -84, 0, 72, 121, 143, 139, 111, + 70, 23, -21, -54, -73, -76, -66, -47, -23, 0, 19, 31, 36, 33, 26, 15, 5, -4, -10, + -13, -13, -10, -7, -3, 0, -1, -5, -8, -12, -13, -12, -8, 0, 10, 21, 30, 35, 34, + 26, 10, -11, -35, -58, -73, -76, -65, -39, 0, 46, 92, 127, 144, 136, 100, 38, -41, -125, + -199, -246, -254, -214, -126, 0, 146, 288, 398, 450, 424, 312, 120, -131, -405, -655, -830, -881, -771, + -477, 0, 636, 1384, 2178, 2943, 3601, 4084, 4340, 4340, 4084, 3601, 2943, 2178, 1384, 636, 0, -477, -771, + -881, -830, -655, -405, -131, 120, 312, 424, 450, 398, 288, 146, 0, -126, -214, -254, -246, -199, -125, + -41, 38, 100, 136, 144, 127, 92, 46, 0, -39, -65, -76, -73, -58, -35, -11, 10, 26, 34, + 35, 30, 21, 10, 0, -8, -12, -13, -12, -8, -5, -1}; +#else +# define resamp_filt_96k NULL +#endif + +#ifdef SUBSET_FB +RAM_ALIGN const Word16 resamp_filt_48k[240] = { + -13, -25, -20, 10, 51, 71, 38, -47, -133, -145, -42, 139, 277, 242, 0, -329, + -511, -351, 144, 698, 895, 450, -535, -1510, -1697, -521, 1999, 5138, 7737, 8744, 7737, 5138, + 1999, -521, -1697, -1510, -535, 450, 895, 698, 144, -351, -511, -329, 0, 242, 277, 139, + -42, -145, -133, -47, 38, 71, 51, 10, -20, -25, -13, 0, -9, -23, -24, 0, + 41, 71, 52, -23, -115, -152, -78, 92, 254, 272, 76, -251, -493, -427, 0, 576, + 900, 624, -262, -1309, -1763, -954, 1272, 4356, 7203, 8679, 8169, 5886, 2767, 0, -1542, -1660, + -809, 240, 848, 796, 292, -252, -507, -398, -82, 199, 288, 183, 0, -130, -145, -71, + 20, 69, 60, 20, -15, -26, -17, -3, -6, -20, -26, -8, 31, 67, 62, 0, + -94, -152, -108, 45, 223, 287, 143, -167, -454, -480, -134, 439, 866, 758, 0, -1071, + -1748, -1295, 601, 3559, 6580, 8485, 8485, 6580, 3559, 601, -1295, -1748, -1071, 0, 758, 866, + 439, -134, -480, -454, -167, 143, 287, 223, 45, -108, -152, -94, 0, 62, 67, 31, + -8, -26, -20, -6, -3, -17, -26, -15, 20, 60, 69, 20, -71, -145, -130, 0, + 183, 288, 199, -82, -398, -507, -252, 292, 796, 848, 240, -809, -1660, -1542, 0, 2767, + 5886, 8169, 8679, 7203, 4356, 1272, -954, -1763, -1309, -262, 624, 900, 576, 0, -427, -493, + -251, 76, 272, 254, 92, -78, -152, -115, -23, 52, 71, 41, 0, -24, -23, -9}; +#else +#define resamp_filt_48k NULL +#endif + + +RAM_ALIGN const Word16 *const resamp_filts[NUM_SAMP_FREQ] = {resamp_filt_8k, + resamp_filt_16k, + resamp_filt_24k, + resamp_filt_32k, + resamp_filt_48k, + resamp_filt_96k +}; + +RAM_ALIGN const Word16 resamp_params[NUM_SAMP_FREQ][4] = { +#ifdef SUBSET_NB + {24, 5, 0, 15}, +#else + {0}, +#endif +#ifdef SUBSET_WB + {12, 10, 1, 3}, +#else + {0}, +#endif +#ifdef SUBSET_SSWB + {8, 15, 1, 7}, +#else + {0}, +#endif +#ifdef SUBSET_SWB + {6, 20, 2, 3}, +#else + {0}, +#endif +#ifdef SUBSET_FB + {4, 30, 3, 3}, +#else + {0}, +#endif +#ifdef ENABLE_HR_MODE + {2, 60, 7, 1}, +#endif +}; + +RAM_ALIGN const Word16 highpass50_filt_num[3] = {32204, -32204, 32204}; +RAM_ALIGN const Word16 highpass50_filt_den[2] = {32199, -31650}; + +RAM_ALIGN const Word16 olpa_ac_weighting[98] = { + 32767, 32598, 32429, 32260, 32091, 31922, 31754, 31585, 31416, 31247, 31078, 30909, 30740, 30571, + 30402, 30233, 30065, 29896, 29727, 29558, 29389, 29220, 29051, 28882, 28713, 28544, 28376, 28207, + 28038, 27869, 27700, 27531, 27362, 27193, 27024, 26855, 26687, 26518, 26349, 26180, 26011, 25842, + 25673, 25504, 25335, 25166, 24998, 24829, 24660, 24491, 24322, 24153, 23984, 23815, 23646, 23477, + 23308, 23140, 22971, 22802, 22633, 22464, 22295, 22126, 21957, 21788, 21619, 21451, 21282, 21113, + 20944, 20775, 20606, 20437, 20268, 20099, 19930, 19762, 19593, 19424, 19255, 19086, 18917, 18748, + 18579, 18410, 18241, 18073, 17904, 17735, 17566, 17397, 17228, 17059, 16890, 16721, 16552, 16384}; + +RAM_ALIGN const Word16 ltpf_ac_interp_filt[7][9] = { + {90, 151, -2472, 26787, 10819, -3468, 940, -94, 0}, {-98, 967, -4270, 19769, 19769, -4270, 967, -98, 0}, + {-94, 940, -3468, 10819, 26787, -2472, 151, 90, 0}, {0, 503, -1550, 2739, 29447, 2739, -1550, 503, 0}, + {0, 90, 151, -2472, 26787, 10819, -3468, 940, -94}, {0, -98, 967, -4270, 19769, 19769, -4270, 967, -98}, + {0, -94, 940, -3468, 10819, 26787, -2472, 151, 90}}; + +RAM_ALIGN const Word16 inter_filter[5][4][12] = { + {{6877, 19121, 6877, 0}, {3506, 18025, 11000, 220}, {1300, 15048, 15048, 1300}, {220, 11000, 18025, 3506}}, + {{6877, 19121, 6877, 0}, {3506, 18025, 11000, 220}, {1300, 15048, 15048, 1300}, {220, 11000, 18025, 3506}}, + {{2072, 8216, 12170, 8216, 2072, 0}, + {1134, 6509, 11883, 9787, 3320, 140}, + {503, 4831, 11057, 11057, 4831, 503}, + {140, 3320, 9787, 11883, 6509, 1134}}, + {{950, 3702, 7248, 8926, 7248, 3702, 950, 0}, + {558, 2858, 6427, 8812, 7946, 4606, 1466, 102}, + {281, 2106, 5530, 8479, 8479, 5530, 2106, 281}, + {102, 1466, 4606, 7946, 8812, 6427, 2858, 558}}, + {{355, 1183, 2515, 4068, 5333, 5822, 5333, 4068, 2515, 1183, 355, 0}, + {231, 924, 2145, 3685, 5074, 5791, 5543, 4433, 2900, 1474, 510, 67}, + {136, 700, 1797, 3293, 4771, 5697, 5697, 4771, 3293, 1797, 700, 136}, + {67, 510, 1474, 2900, 4433, 5543, 5791, 5074, 3685, 2145, 924, 231}}}; +RAM_ALIGN const Word16 inter_filter_shift[5] = {1, 1, 2, 3, 5}; +RAM_ALIGN const Word16 inter_filter_len[5] = {4, 4, 6, 8, 12}; + +RAM_ALIGN const Word16 tilt_filter[5][4][11] = { + {{16777, 11692, -525}, {16697, 11692, -444}, {16622, 11692, -369}, {16551, 11692, -298}}, + {{16777, 11692, -525}, {16697, 11692, -444}, {16622, 11692, -369}, {16551, 11692, -298}}, + {{11112, 14323, 2797, -356, -44}, + {10998, 14271, 2906, -304, -38}, + {10890, 14222, 3008, -255, -32}, + {10788, 14175, 3104, -208, -26}}, + {{8307, 12959, 5866, 1049, -283, -71, -9}, + {8199, 12866, 5931, 1133, -242, -61, -8}, + {8098, 12777, 5992, 1212, -203, -51, -6}, + {8002, 12693, 6050, 1287, -166, -42, -5}}, + {{5519, 9817, 7001, 3967, 1589, 259, -201, -88, -31, -8, -1}, + {5433, 9706, 6991, 4014, 1651, 309, -172, -76, -27, -7, -1}, + {5353, 9601, 6981, 4058, 1710, 356, -145, -64, -23, -6, -1}, + {5277, 9501, 6970, 4100, 1767, 402, -118, -52, -19, -5, -1}}}; +RAM_ALIGN const Word16 tilt_filter_len[5] = {2, 2, 4, 6, 10}; + +RAM_ALIGN const Word16 gain_scale_fac[4] = {13108, 11468, 9832, 8192}; + +RAM_ALIGN const UWord16 pitch_scale[NUM_SAMP_FREQ] = {5120, + 10240, + 15360, + 20480, + 30720 +}; + +RAM_ALIGN const Word16 ltpf_overlap_len[NUM_SAMP_FREQ] = {20, 40, 60, 80, 120 +}; + +/* set up of SNS VQ stages 1 ( split VQ) and SNS stage 2(Transformed PVQ) for bit rate 38 bits */ + +/* trained gain set for DCT Q12 */ +RAM_ALIGN const Word16 sns_vq_reg_adj_gains[2] = {8915, 12054}; +RAM_ALIGN const Word16 sns_vq_reg_lf_adj_gains[4] = {6245, 15043, 17861, 21014}; +RAM_ALIGN const Word16 sns_vq_near_adj_gains[4] = {7099, 9132, 11253, 14808}; +RAM_ALIGN const Word16 sns_vq_far_adj_gains[8] = {4336, 5067, 5895, 8149, 10235, 12825, 16868, 19882}; + +RAM_ALIGN const Word16 *const sns_gaintabPtr[4] = {sns_vq_reg_adj_gains, sns_vq_reg_lf_adj_gains, sns_vq_near_adj_gains, + sns_vq_far_adj_gains}; +RAM_ALIGN const Word16 sns_gainSz[4] = {2, 4, 4, 8}; +RAM_ALIGN const Word16 sns_gainMSBbits[4] = {1, 1, 2, 2}; +RAM_ALIGN const Word16 sns_gainLSBbits[4] = {0, 1, 0, 1}; +RAM_ALIGN const Word16 sns_Kval[4][2] = {{10, 1}, {10, 0}, {8, 0}, {6, 0}}; +RAM_ALIGN const UWord32 sns_MPVQ_Sz[4][2] = { + {4780008U >> 1, (2U * 6U)}, {4780008U >> 1, (2U)}, {30316544U >> 1, 0U}, {MPVQ_SZ_OUTL_FAR, 0U}}; + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 st1SCF0_7_base5_32x8_Q27[256] = { + 303712392, 109160791, -71161366, -182086260, -214684177, -193406093, -153520450, -101361734, 395293327, + 323657083, 128910102, -59488852, -164971858, -208829415, -200908713, -149907762, -293414324, -264613117, + -239872071, -257518046, -240785425, -182185002, -94683128, -6417929, 93105259, 128259784, 77206169, + -15381811, -86711449, -127822437, -144156883, -101748810, -174150364, -99370653, -46355110, -42048494, + -54086690, -49931794, -10514807, 13025043, 122762518, 233932163, 256230537, 207243559, 146760322, + 86903234, 4855873, -39875122, -337462040, -388124479, -269040331, -100785739, 59217144, 161317613, + 178164447, 163811504, -123774032, 84892061, 145943568, 81688751, 17605952, -39748467, -27784884, + 18109316, 106075262, 84342590, 52763395, 64425544, 60104730, 28150050, 881397, -11559399, + 194314494, 365609026, 310154713, 125500457, -36875504, -121074819, -126256135, -85053377, 106482242, + 1931812, -76213503, -87880462, -64351897, -23339746, 9128989, 39611134, 365643112, 397214108, + 248240465, 75602822, 18779354, 48270210, 92537937, 85871184, -71246823, -28546860, 773918, + 57025285, 63502293, 115278828, 159868294, 133706314, 226463440, 326973859, 312753384, 238885783, + 193825560, 204004473, 197567682, 131222320, -396188282, -213934330, -14753048, 52158227, 68844655, + 84303846, 110410429, 117560157, 13673880, 79169310, 83087169, 170095890, 324754621, 302223766, + 70670604, -53229612, 360045196, 178157942, 17473172, -45437142, -49421549, -25728189, -20774539, + -31434755, 647866186, 418689256, 187252080, 33594069, -52829955, -86363494, -86244384, -97065351, + 11789953, -76448652, -153687373, -224101311, -247677903, -210007831, -149983961, -71669806, 186699958, + 265947702, 149338424, -29542330, -104014124, -79733903, 18379464, 109822702, 51618245, -21553862, + -72392588, -71042662, 25559558, 343681831, 378354941, 88136873, 259345425, 404035869, 411436250, + 335692175, 259160465, 76793185, -108950139, -157896166, 23498902, -100733469, -139511132, -152441152, + -139852059, -2040916, 277895647, 460298246, -159473505, 49230106, 175768625, 225929624, 167907618, + 126483532, 110897463, 59049457, 340003306, 283568025, 169501437, 102208613, 70077483, 15928969, + -60712963, -93999711, 536723054, 547476463, 378877401, 231669479, 86858248, -44446002, -118654185, + -151259810, 68169532, 213189358, 232061142, 135146824, 50616355, 63937402, 145968142, 145970189, + 425278032, 437353108, 325116396, 240848448, 204249734, 157298757, 65685431, -8359023, 254228196, + 167918047, 79249020, 81652507, 117866118, 150206430, 136711039, 83275912, 127356599, 286205131, + 365535742, 371764419, 341298198, 271181905, 111406869, -3698627, -252365241, -169692913, 41798753, + 246517983, 302841086, 274903406, 294643934, 272005129, 33067993, 128261383, 204073729, 265277850, + 260441270, 299809987, 266873132, 170768802 }; +RAM_ALIGN const Word32 st1SCF8_15_base5_32x8_Q27[256] = { + 31142327, -135412629, -287525918, -318812488, -299361815, -292052248, -307447065, -339955249, -173817241, + -241497912, -253273077, -242922894, -236679593, -246180047, -242237472, -233108740, 18694612, -34653021, + -87349511, -143365648, -217337078, -293618146, -354009441, -399831591, -42481669, -64122205, -73975722, + -65067182, -31995949, -19196424, 9169576, 11852254, 118046962, 40042530, -122861082, -296146014, + -367947407, -384049364, -387676629, -396187390, -39822658, -130862945, -182344850, -132032812, -87638397, + -132873805, -216717640, -323078583, 45765709, 36091119, 7560964, 6698995, -12806126, -102027773, + -312402661, -506209524, -189555374, -199343014, -159187030, -83886299, 20656444, 77361286, 106715523, + 80069550, -30714319, -44791015, -108625274, -219563932, -252982160, -220783722, -188597085, -196852406, + -143812455, -190276467, -207892204, -195013074, -138489838, -92696486, -57558441, -66432436, -79321135, + -9552782, 46401689, 40339066, -150142954, -327610913, -299110559, -254354980, -113874897, -78279377, + 12085282, 113417337, 143039033, 98996714, 34438988, -66030204, 153101016, 129388157, 51198856, + -64806941, -243783312, -376184794, -434040973, -464270818, -50503881, 5713319, 69329858, 33784868, + -29015184, -71682211, -86004854, -116735202, 89255342, 147358670, 185680385, 180291129, 110458350, + 28974493, -54348215, -143647337, -110899539, -90084420, -30668159, 69656431, 183505023, 292625568, + 340370914, 295441538, 189258173, 101259479, -175222029, -251166616, -166441640, -170071209, -273362338, + -388808843, 48504518, -2952679, -77761569, -118034823, -114177011, -104608901, -98271929, -119232119, + 58716127, 40995519, -991583, -66524997, -108266901, -164325304, -228381893, -301307946, 86986552, + 91576640, 33990299, 9876306, 42173453, 31504911, 19407902, -9155262, 150216257, 165712633, + 79077091, -184136602, -318224471, -269482063, -223725572, -258546087, 19038449, -14852543, -37960074, + -885587, 38376778, 6179995, -80879122, -304095400, 67652037, 110995667, 150298671, 158261551, + 144938274, 93621729, -122480229, -480076341, -67253289, -43711762, 3768810, 35172367, 48397679, + 85311972, 128716474, 175483179, 503277534, 204470792, -61433556, -107201177, -51918012, -50452587, + -88293374, -172018761, -154697999, -148714432, -75512923, -29603347, -46955117, -101124035, -132687189, + -172859645, 138012394, 147331497, 103165859, 27659855, -46010607, -101326252, -139849742, -201777098, + 17291535, 92534989, 150789463, 175737342, 181881080, 191007103, 155298567, 54535272, 179896088, + 186558381, 140214471, 85338684, -36874140, -207934631, -327812990, -405951728, 287015358, 570037814, + 388874539, 125188990, -39301937, -108770623, -105880084, -125540975, 75810265, 213654461, 321816127, + 407615675, 357588710, 186971315, 54201685, -88083199, -56701695, 43775062, 186792575, 299502316, + 350549113, 357744389, 322261535, 236116337 }; +#endif + +RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256] = { + 4634, 1666, -1086, -2778, -3276, -2951, -2343, -1547, 6032, 4939, 1967, -908, -2517, -3186, -3066, -2287, + -4477, -4038, -3660, -3929, -3674, -2780, -1445, -98, 1421, 1957, 1178, -235, -1323, -1950, -2200, -1553, + -2657, -1516, -707, -642, -825, -762, -160, 199, 1873, 3570, 3910, 3162, 2239, 1326, 74, -608, + -5149, -5922, -4105, -1538, 904, 2462, 2719, 2500, -1889, 1295, 2227, 1246, 269, -607, -424, 276, + 1619, 1287, 805, 983, 917, 430, 13, -176, 2965, 5579, 4733, 1915, -563, -1847, -1927, -1298, + 1625, 29, -1163, -1341, -982, -356, 139, 604, 5579, 6061, 3788, 1154, 287, 737, 1412, 1310, + -1087, -436, 12, 870, 969, 1759, 2439, 2040, 3456, 4989, 4772, 3645, 2958, 3113, 3015, 2002, + -6045, -3264, -225, 796, 1050, 1286, 1685, 1794, 209, 1208, 1268, 2595, 4955, 4612, 1078, -812, + 5494, 2718, 267, -693, -754, -393, -317, -480, 9886, 6389, 2857, 513, -806, -1318, -1316, -1481, + 180, -1167, -2345, -3420, -3779, -3204, -2289, -1094, 2849, 4058, 2279, -451, -1587, -1217, 280, 1676, + 788, -329, -1105, -1084, 390, 5244, 5773, 1345, 3957, 6165, 6278, 5122, 3954, 1172, -1662, -2409, + 359, -1537, -2129, -2326, -2134, -31, 4240, 7024, -2433, 751, 2682, 3447, 2562, 1930, 1692, 901, + 5188, 4327, 2586, 1560, 1069, 243, -926, -1434, 8190, 8354, 5781, 3535, 1325, -678, -1811, -2308, + 1040, 3253, 3541, 2062, 772, 976, 2227, 2227, 6489, 6673, 4961, 3675, 3117, 2400, 1002, -128, + 3879, 2562, 1209, 1246, 1798, 2292, 2086, 1271, 1943, 4367, 5578, 5673, 5208, 4138, 1700, -56, + -3851, -2589, 638, 3762, 4621, 4195, 4496, 4150, 505, 1957, 3114, 4048, 3974, 4575, 4072, 2606}; + +RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256] = { + 475, -2066, -4387, -4865, -4568, -4456, -4691, -5187, -2652, -3685, -3865, -3707, -3611, -3756, -3696, -3557, + 285, -529, -1333, -2188, -3316, -4480, -5402, -6101, -648, -978, -1129, -993, -488, -293, 140, 181, + 1801, 611, -1875, -4519, -5614, -5860, -5915, -6045, -608, -1997, -2782, -2015, -1337, -2027, -3307, -4930, + 698, 551, 115, 102, -195, -1557, -4767, -7724, -2892, -3042, -2429, -1280, 315, 1180, 1628, 1222, + -469, -683, -1657, -3350, -3860, -3369, -2878, -3004, -2194, -2903, -3172, -2976, -2113, -1414, -878, -1014, + -1210, -146, 708, 616, -2291, -4999, -4564, -3881, -1738, -1194, 184, 1731, 2183, 1511, 525, -1008, + 2336, 1974, 781, -989, -3720, -5740, -6623, -7084, -771, 87, 1058, 516, -443, -1094, -1312, -1781, + 1362, 2249, 2833, 2751, 1685, 442, -829, -2192, -1692, -1375, -468, 1063, 2800, 4465, 5194, 4508, + 2888, 1545, -2674, -3832, -2540, -2595, -4171, -5933, 740, -45, -1187, -1801, -1742, -1596, -1500, -1819, + 896, 626, -15, -1015, -1652, -2507, -3485, -4598, 1327, 1397, 519, 151, 644, 481, 296, -140, + 2292, 2529, 1207, -2810, -4856, -4112, -3414, -3945, 291, -227, -579, -14, 586, 94, -1234, -4640, + 1032, 1694, 2293, 2415, 2212, 1429, -1869, -7325, -1026, -667, 58, 537, 738, 1302, 1964, 2678, + 7679, 3120, -937, -1636, -792, -770, -1347, -2625, -2361, -2269, -1152, -452, -716, -1543, -2025, -2638, + 2106, 2248, 1574, 422, -702, -1546, -2134, -3079, 264, 1412, 2301, 2682, 2775, 2915, 2370, 832, + 2745, 2847, 2140, 1302, -563, -3173, -5002, -6194, 4380, 8698, 5934, 1910, -600, -1660, -1616, -1916, + 1157, 3260, 4911, 6220, 5456, 2853, 827, -1344, -865, 668, 2850, 4570, 5349, 5459, 4917, 3603}; + +/* tables for MPVQ pulse enumeration */ + +/* N=16, K=12 31.74 bits */ +RAM_ALIGN const UWord32 h_memN16K12[12 + 2] = { + 0U, 1U, 31U, 481U, 4991U, 39041U, 246047U, + 1303777U, 5984767U, 24331777U, 89129247U, 298199265U, 921406335U, /*U*/ 1326824512U}; + +/*N=16,K=8,h_memN16K8={0U,1U,31U,481U,4991U,39041U,246047U,1303777U,5984767U, 12165888U,}; */ + +/*N=10, K=20 +UWord32 h_memN10K20[20+2] = +{ + 0U,1U,19U,181U,1159U,5641U,22363U,75517U,224143U,598417U,1462563U, + 3317445U,7059735U,14218905U,27298155U,50250765U,89129247U,152951073U,254831667U,413442773U,654862247U, + 507444884U +}; +*/ +/*N=10, K=22 31.84 bits */ +RAM_ALIGN const UWord32 h_memN10K22[22 + 2] = {0U, + 1U, + 19U, + 181U, + 1159U, + 5641U, + 22363U, + 75517U, + 224143U, + 598417U, + 1462563U, + 3317445U, + 7059735U, + 14218905U, + 27298155U, + 50250765U, + 89129247U, + 152951073U, + 254831667U, + 413442773U, + 654862247U, + 1014889769U, + 1541911931U, + /*U*/ 1150204814U}; +/* N=10,K=10,h_memN10K10={0U,1U,19U,181U,1159U,5641U,22363U,75517U,224143U,598417U,1462563U,1658722U,}; */ + +/* N=6,K=2,*/ +RAM_ALIGN const UWord32 h_memN6K2[2 + 2] = {0U, 1U, 11U, /*U*/ 30U}; +/*N=6,K=1, h_memN6K1={0U,1U, 5U,}; */ + +RAM_ALIGN const UWord32 *const MPVQ_offs_ptr[M + 1] = {NULL /*0*/, NULL, NULL, NULL, NULL, NULL, + h_memN6K2, NULL, NULL, NULL, h_memN10K22, NULL, + NULL, NULL, NULL, NULL, h_memN16K12}; + +/*maxK coefficents for MPVQ de-indexing lookup */ +RAM_ALIGN const Word16 tabledKMAX[M + 1] = { + 0, 0, 0, 0, 0, 0, 2 /*N=6*/, 0, 0, 0, 22 /*N=10*/, 0, 0, 0, 0, 0, 12 /*N=16*/ +}; + +RAM_ALIGN const Word16 isqrt_Q16tab[1 + 64] = {/*table generated using ISqrt16 function + shift to Q16 */ + 32767, 32767, 32767, 32767, 32766, 29308, 26754, 24770, 23169, 21844, + 20723, 19759, 18918, 18176, 17515, 16921, 16383, 15894, 15446, 15034, + 14654, 14300, 13972, 13665, 13377, 13107, 12852, 12612, 12385, 12169, + 11965, 11770, 11584, 11407, 11238, 11077, 10922, 10773, 10631, 10493, + 10361, 10234, 10112, 9993, 9879, 9769, 9662, 9559, 9459, 9362, + 9268, 9176, 9088, 9001, 8918, 8836, 8757, 8680, 8605, 8532, + 8460, 8390, 8323, 8256, 8191}; + +#ifdef ENABLE_HR_MODE +RAM_ALIGN const Word32 isqrt_Q31tab[1 + 64] = {/* 2^31 / sqrt(idx) */ + 2147483647, 2147483647, 1518500249, 1239850262, 1073741824, 960383883, + 876706528, 811672525, 759250124, 715827882, 679093956, 647490682, + 619925131, 595604800, 573939146, 554477893, 536870912, 520841288, + 506166749, 492666537, 480191941, 468619350, 457845052, 447781294, + 438353264, 429496729, 421156193, 413283420, 405836262, 398777702, + 392075078, 385699449, 379625062, 373828919, 368290407, 362990988, + 357913941, 353044136, 348367849, 343872591, 339546978, 335380599, + 331363920, 327488186, 323745341, 320127961, 316629189, 313242684, + 309962565, 306783378, 303700049, 300707858, 297802400, 294979564, + 292235509, 289566636, 286969573, 284441157, 281978417, 279578557, + 277238946, 274957105, 272730696, 270557508, 268435456 }; +#endif + +# ifdef ENABLE_HR_MODE +RAM_ALIGN const Word16 adjust_global_gain_tables[5][NUM_SAMP_FREQ] = {{80, 230, 380, 530, 680, 830}, + {500, 1025, 1550, 2075, 2600, 3125}, + {850, 1700, 2550, 3400, 4250, 5100}, + {189, 164, 155, 151, 148, 146}, + {1310, 3241, 5268, 7326, 9400, 11482}}; +# else +RAM_ALIGN const Word16 adjust_global_gain_tables[5][NUM_SAMP_FREQ] = {{80, 230, 380, 530, 680}, + {500, 1025, 1550, 2075, 2600}, + {850, 1700, 2550, 3400, 4250}, + {189, 164, 155, 151, 148}, + {1310, 3241, 5268, 7326, 9400}}; +# endif + +#if defined(CR8_A_PLC_FADEOUT_TUNING) +const Word16 plc_fadeout_param_maxlen[4] = {800, 400, 266, 200}; +const Word16 plc_fadeout_param_maxbytes[4] = {27, 14, 9, 7}; +#endif diff --git a/lib_lc3plus/constants.h b/lib_lc3plus/constants.h new file mode 100644 index 000000000..8dee7e6eb --- /dev/null +++ b/lib_lc3plus/constants.h @@ -0,0 +1,402 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef CONSTANTS_H +#define CONSTANTS_H + +#include "defines.h" + +#include "basop_util_lc3plus.h" + + +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 BW_cutoff_bin_all_HR[]; + +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA_2_5ms[2]; +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA_5ms[2]; +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA_7_5ms[2]; +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_HRA[2]; +#endif + +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len[6]; +# else +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len[5]; +# endif +extern RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes[NUM_SAMP_FREQ]; +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960[6]; +# else +extern RAM_ALIGN const Word16 *const LowDelayShapes_n960[6]; +# endif + +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_5ms[6]; +# else +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_5ms[5]; +# endif +extern RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes_5ms[NUM_SAMP_FREQ]; +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_5ms[6]; +# else +extern RAM_ALIGN const Word16 *const LowDelayShapes_n960_5ms[6]; +# endif +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_2_5ms[6]; +#else +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_2_5ms[5]; +#endif +extern RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes_2_5ms[NUM_SAMP_FREQ]; +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_2_5ms[6]; +# else +extern RAM_ALIGN const Word16 *const LowDelayShapes_n960_2_5ms[6]; +# endif + +# ifdef CR8_G_ADD_75MS +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_7_5ms[5]; +# else +extern RAM_ALIGN const Word16 *const LowDelayShapes_n960_7_5ms[5]; +# endif + +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_7_5ms[6]; +# else +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_7_5ms[5]; +# endif +extern RAM_ALIGN const Word16 LowDelayShapes_n960_la_zeroes_7_5ms[NUM_SAMP_FREQ]; +# endif + +extern RAM_ALIGN const Word16 NN_thresh; +extern RAM_ALIGN const Word16 NN_thresh_exp; +#ifdef CR8_E_TONE_DETECTOR +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 TD_HR_thresh_10ms; +# ifdef ENABLE_075_DMS_MODE +extern RAM_ALIGN const Word32 TD_HR_thresh_7_5ms; +# endif +extern RAM_ALIGN const Word32 TD_HR_thresh_5ms; +extern RAM_ALIGN const Word32 TD_HR_thresh_2_5ms; +# endif /* ENABLE_HR_MODE */ +#endif /* CR8_E_TONE_DETECTOR */ +extern RAM_ALIGN const Word32 BW_thresh_quiet[4]; +extern RAM_ALIGN const Word16 BW_thresh_quiet_exp; +extern RAM_ALIGN const Word16 BW_thresh_brickwall[4]; + +extern RAM_ALIGN const Word16 BW_cutoff_bin_all[]; +extern RAM_ALIGN const Word16 BW_cutoff_bits_all[]; + +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 bands_number_2_5ms_HR[]; +#endif + +extern RAM_ALIGN const Word16 BW_brickwall_dist[4]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_start_all[MAX_BW_BANDS_NUMBER - 1]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_stop_all[MAX_BW_BANDS_NUMBER - 1]; + +extern RAM_ALIGN const Word16 BW_brickwall_dist_5ms[4]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_start_all_5ms[MAX_BW_BANDS_NUMBER - 1]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_stop_all_5ms[MAX_BW_BANDS_NUMBER - 1]; +extern RAM_ALIGN const Word16 BW_brickwall_dist_2_5ms[4]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_start_all_2_5ms[MAX_BW_BANDS_NUMBER - 1]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_stop_all_2_5ms[MAX_BW_BANDS_NUMBER - 1]; + +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_075_DMS_MODE +extern RAM_ALIGN const Word16 BW_brickwall_dist_7_5ms[4]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_start_all_7_5ms[]; +extern RAM_ALIGN const Word16 *const BW_warp_idx_stop_all_7_5ms[]; +# endif +#endif + +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq[MAX_BW_BANDS_NUMBER]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq[MAX_BW_BANDS_NUMBER]; + +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq_HR[2]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_HR[2]; + +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq_5ms_HR[2]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_5ms_HR[2]; + +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq_2_5ms_HR[2]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_2_5ms_HR[2]; +# endif + +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq_5ms[MAX_BW_BANDS_NUMBER]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_5ms[MAX_BW_BANDS_NUMBER]; + + +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq_2_5ms[MAX_BW_BANDS_NUMBER]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_2_5ms[MAX_BW_BANDS_NUMBER]; + +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_075_DMS_MODE +extern RAM_ALIGN const Word16 *const tns_subdiv_startfreq_7_5ms[]; +extern RAM_ALIGN const Word16 *const tns_subdiv_stopfreq_7_5ms[]; +# endif +#endif + +extern RAM_ALIGN const Word16 Tab_esc_nb[4]; + +extern RAM_ALIGN const Word8 ari_spec_lookup[4096]; +extern RAM_ALIGN const UWord16 ari_spec_cumfreq[64][17]; +extern RAM_ALIGN const UWord16 ari_spec_freq[64][17]; +extern RAM_ALIGN const UWord16 ari_spec_bits[64][17]; + +extern RAM_ALIGN const Word32 tnsAcfWindow_lc3plus[MAXLAG]; +extern RAM_ALIGN const Word16 ac_tns_order_bits[2][MAXLAG]; +extern RAM_ALIGN const Word16 ac_tns_order_freq[2][MAXLAG]; +extern RAM_ALIGN const Word16 ac_tns_order_cumfreq[2][MAXLAG]; +extern RAM_ALIGN const Word16 ac_tns_coef_bits[MAXLAG][TNS_COEF_RES]; +extern RAM_ALIGN const Word16 ac_tns_coef_freq[MAXLAG][TNS_COEF_RES]; +extern RAM_ALIGN const Word16 ac_tns_coef_cumfreq[MAXLAG][TNS_COEF_RES]; +extern RAM_ALIGN const Word16 tnsQuantPts[TNS_COEF_RES]; +extern RAM_ALIGN const Word16 tnsQuantThr[TNS_COEF_RES - 1]; + +extern RAM_ALIGN const Word16 *const lpc_pre_emphasis[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_pre_emphasis_e[NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_2_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_2_5ms[NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 *const lpc_warp_dee_emphasis[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_warp_dee_emphasis_e[NUM_SAMP_FREQ]; + +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_075_DMS_MODE +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_7_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_7_5ms[NUM_SAMP_FREQ]; +# endif +#endif + +extern RAM_ALIGN const Word16 bands_nrg_scale[32]; + +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 *const bands_offset_2_5ms_HR[2]; +extern RAM_ALIGN const Word16 *const bands_offset_5ms_HR[2]; +extern RAM_ALIGN const Word16 *const bands_offset_HR[2]; +# endif + +extern RAM_ALIGN const Word16 *const bands_offset[6]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max[NUM_OFFSETS]; + +extern RAM_ALIGN const Word16 bands_number_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const bands_offset_5ms[6]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_5ms[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_5ms[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 bands_number_2_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const bands_offset_2_5ms[6]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_2_5ms[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_2_5ms[NUM_OFFSETS]; + +#ifdef CR8_G_ADD_75MS +#ifdef ENABLE_075_DMS_MODE +extern RAM_ALIGN const Word16 bands_number_7_5ms[]; +# ifndef GENERATE_BAND_TABLES +extern RAM_ALIGN const Word16 *const bands_offset_7_5ms[5]; +# endif +# ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 bands_number_7_5ms_HR[]; +# ifndef GENERATE_BAND_TABLES +extern RAM_ALIGN const Word16 *const bands_offset_7_5ms_HR[2]; +# endif +# endif +#endif +#endif + +extern RAM_ALIGN const Word16 pitch_max[5]; +extern RAM_ALIGN const Word16 plc_preemph_fac[NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 TDC_high_16[11]; +extern RAM_ALIGN const Word16 TDC_high_32[11]; +extern RAM_ALIGN const Word16 TDC_high_16_harm[11]; +extern RAM_ALIGN const Word16 TDC_high_32_harm[11]; + +extern RAM_ALIGN const Word32 *const lag_win[NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 *const bands_offset_lin[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_lin[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_lin[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const bands_offset_lin_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_lin_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_lin_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 *const bands_offset_lin_2_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_lin_2_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_lin_2_5ms[NUM_SAMP_FREQ]; + +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_075_DMS_MODE +extern RAM_ALIGN const Word16 bands_offset_with_one_max_7_5ms[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_7_5ms[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 *const bands_offset_lin_7_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_lin_7_5ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_lin_7_5ms[NUM_SAMP_FREQ]; +# endif +#endif + +extern RAM_ALIGN const Word32 inv_odft_twiddle_80_re[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_80_im[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_60_re[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_60_im[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_40_re[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_40_im[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_20_re[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_20_im[M]; + +#ifdef SUBSET_WB +extern RAM_ALIGN const Word16 resamp_filt_16k[240]; +#else +extern RAM_ALIGN const Word16 resamp_filt_16k[1]; +#endif +#ifdef SUBSET_SSWB +extern RAM_ALIGN const Word16 resamp_filt_24k[240]; +#else +extern RAM_ALIGN const Word16 resamp_filt_24k[1]; +#endif +#ifdef SUBSET_SWB +extern RAM_ALIGN const Word16 resamp_filt_32k[240]; +#else +extern RAM_ALIGN const Word16 resamp_filt_32k[1]; +#endif +#ifdef SUBSET_FB +extern RAM_ALIGN const Word16 resamp_filt_48k[240]; +#else +extern RAM_ALIGN const Word16 resamp_filt_48k[1]; +#endif + +extern RAM_ALIGN const Word16 resamp_params[NUM_SAMP_FREQ][4]; +extern RAM_ALIGN const Word16 *const resamp_filts[NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 highpass50_filt_num[3]; +extern RAM_ALIGN const Word16 highpass50_filt_den[2]; + +extern RAM_ALIGN const Word16 olpa_ac_weighting[98]; + +extern RAM_ALIGN const Word16 ltpf_ac_interp_filt[7][9]; +extern RAM_ALIGN const Word16 inter_filter[5][4][12]; +extern RAM_ALIGN const Word16 inter_filter_shift[5]; +extern RAM_ALIGN const Word16 inter_filter_len[5]; +extern RAM_ALIGN const Word16 tilt_filter[5][4][11]; +extern RAM_ALIGN const Word16 tilt_filter_len[5]; +extern RAM_ALIGN const Word16 gain_scale_fac[4]; +extern RAM_ALIGN const UWord16 pitch_scale[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 ltpf_overlap_len[NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 sns_vq_reg_adj_scf[2]; +extern RAM_ALIGN const Word16 sns_vq_reg_lf_adj_scf[4]; +extern RAM_ALIGN const Word16 sns_vq_near_adj_scf[4]; +extern RAM_ALIGN const Word16 sns_vq_far_adj_scf[8]; +extern RAM_ALIGN const Word16 *const sns_gaintabPtr[4]; +extern RAM_ALIGN const Word16 sns_gainSz[4]; +extern RAM_ALIGN const Word16 sns_gainMSBbits[4]; +extern RAM_ALIGN const Word16 sns_gainLSBbits[4]; +extern RAM_ALIGN const Word16 sns_Kval[4][2]; +extern RAM_ALIGN const UWord32 sns_MPVQ_Sz[4][2]; + +extern RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256]; +extern RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256]; + +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 st1SCF0_7_base5_32x8_Q27[256]; +extern RAM_ALIGN const Word32 st1SCF8_15_base5_32x8_Q27[256]; +#endif + +/* PVQ deindexing tables */ +extern RAM_ALIGN const UWord32 h_memN16K12[12 + 2]; +extern RAM_ALIGN const UWord32 h_memN10K22[22 + 2]; +extern RAM_ALIGN const UWord32 h_memN6K2[2 + 2]; +extern RAM_ALIGN const Word16 tabledKMAX[16 + 1]; +extern RAM_ALIGN const UWord32 *const MPVQ_offs_ptr[16 + 1]; + +extern RAM_ALIGN const Word16 isqrt_Q16tab[1 + SQRT_EN_MAX_FX]; +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 isqrt_Q31tab[1 + SQRT_EN_MAX_FX]; +#endif + +extern RAM_ALIGN const Word16 adjust_global_gain_tables[5][NUM_SAMP_FREQ]; + +extern RAM_ALIGN const Word16 sqrt_table_phecu[]; +extern RAM_ALIGN const Word16 POW_ATT_TABLE0[]; +extern RAM_ALIGN const Word16 POW_ATT_TABLE1[]; +#ifdef PLC2_FADEOUT_IN_MS +#if PLC2_FADEOUT_IN_MS == 0 +extern RAM_ALIGN const Word16 *const POW_ATT_TABLES[3]; +#else +#ifdef CR8_A_PLC_FADEOUT_TUNING +extern RAM_ALIGN const Word16 fade_scheme_tab_fx[24 / 2][3]; +extern RAM_ALIGN const Word16 *const POW_ATT_TABLES[1+24/2]; +#else +extern RAM_ALIGN const Word16 *const POW_ATT_TABLES[11]; +#endif + +#endif +#else +extern RAM_ALIGN const Word16 *const POW_ATT_TABLES[3]; +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +extern RAM_ALIGN const Word16 scATHFx[7]; +#endif + +extern RAM_ALIGN const Word16 e_tot_headroom[]; +extern RAM_ALIGN const Word16 xfp_wE_MDCT2FFTQ11[]; + +extern RAM_ALIGN const Word16 num_FsByResQ0[5]; +extern RAM_ALIGN const Word16 *const LprotSzPtr; +extern RAM_ALIGN const Word16 InvLprot_Q22[5]; +extern RAM_ALIGN const Word16 PhEcuFftScale[5]; +extern RAM_ALIGN const Word16 oneOverFrameQ15Tab[5]; +extern RAM_ALIGN const Word16 PhEcu_Xsav_Flt2FxDnShift[]; +extern RAM_ALIGN const Word16 PhEcu_Xsav_Flt2FxScaleQ15[]; +extern RAM_ALIGN const Word16 PhEcu_frac_thr_rise_lin_Q15[]; +extern RAM_ALIGN const Word16 PhEcu_frac_thr_decay_lin_Q15[]; + +extern RAM_ALIGN const Word16 mdct_grp_bins_fx[]; +extern RAM_ALIGN const Word16 xavg_N_grp_fx[]; +extern RAM_ALIGN const Word16 spec_shape_headroom[]; +extern RAM_ALIGN const Word16 rectLengthTab[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 hamm_len2Tab[]; + +#ifndef CR10_A_ATTENUATION_CURVE_SELECTOR +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH +extern RAM_ALIGN const Word16 FADE_OUT_TYPE_2_ALPHA_5MS[30]; +extern RAM_ALIGN const Word16 FADE_OUT_TYPE_2_ALPHA_2_5MS[60]; +#endif +#endif +extern RAM_ALIGN const Word16 gw_len_inv_shift_fx[]; +extern RAM_ALIGN const Word16 gwlpr_fx[]; + +extern RAM_ALIGN const Word16 sin_quarterQ15_fx[]; +extern RAM_ALIGN const Word16 sincos_lowres_tab_sinQ15_fx[]; + +extern RAM_ALIGN const Word16 *const PhECU_wins[5][3]; + +extern RAM_ALIGN const Word16 *const w_new[]; +extern RAM_ALIGN const Word16 *const w_old[]; + +/* extern RAM_ALIGN const Word16 WORK_LEN[]; */ +extern RAM_ALIGN const Word16 COPY_LEN[]; +extern RAM_ALIGN const Word16 OLA_LEN[]; + +#if defined(CR8_A_PLC_FADEOUT_TUNING) +extern const Word16 plc_fadeout_param_maxlen[4]; +extern const Word16 plc_fadeout_param_maxbytes[4]; +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR +extern RAM_ALIGN const Word16 PLC_FADEOUT_TYPE_2_SELECTOR; +#endif + +#endif /* CONSTANTS_H */ diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c new file mode 100644 index 000000000..05f7cce49 --- /dev/null +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -0,0 +1,26 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void process_cutoff_bandwidth(Word32 d_fx[], Word16 len, Word16 bw_bin) +{ + Counter i = 0; + if (len > bw_bin){ + /* roll off */ + for (i = -1; i < 3; i++) { + d_fx[bw_bin + i] = L_shr(d_fx[bw_bin + i], add(i, 2)); + } + + for (i = bw_bin + 3; i < len; i++) { + d_fx[i] = 0; move32(); + } + } +} + diff --git a/lib_lc3plus/dct2_fx.c b/lib_lc3plus/dct2_fx.c new file mode 100644 index 000000000..c301c2aeb --- /dev/null +++ b/lib_lc3plus/dct2_fx.c @@ -0,0 +1,473 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void idct16_fx(const Word16 *in, Word16 *out) +{ + Dyn_Mem_Deluxe_In( + Word16 a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; + Word16 b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15; + ); + + a8 = add(mult_r(in[1], 1136), mult_r(in[15], -11529)); /* Sπ/32/√8 -S15π/32/√8 */ + a9 = add(mult_r(in[9], 8956), mult_r(in[7], -7350)); /* S9π/32/√8 -S7π/32/√8 */ + a10 = add(mult_r(in[5], 5461), mult_r(in[11], -10217)); /* S5π/32/√8 -S11π/32/√8 */ + a11 = add(mult_r(in[13], 11086), mult_r(in[3], -3363)); /* S13π/32/√8 -S3π/32/√8 */ + a12 = add(mult_r(in[3], 11086), mult_r(in[13], 3363)); /* C3π/32/√8 C13π/32/√8 */ + a13 = add(mult_r(in[11], 5461), mult_r(in[5], 10217)); /* C11π/32/√8 C5π/32/√8 */ + a14 = add(mult_r(in[7], 8956), mult_r(in[9], 7350)); /* C7π/32/√8 C9π/32/√8 */ + a15 = add(mult_r(in[15], 1136), mult_r(in[1], 11529)); /* C15π/32/√8 Cπ/32/√8 */ + + b4 = add(mult_r(in[2], 2260), mult_r(in[14], -11363)); /* Sπ/16/√8 -S7π/16/√8 */ + b5 = add(mult_r(in[10], 9633), mult_r(in[6], -6436)); /* S5π/16/√8 -S3π/16/√8 */ + b6 = add(mult_r(in[6], 9633), mult_r(in[10], 6436)); /* C3π/16/√8 C5π/16/√8 */ + b7 = add(mult_r(in[14], 2260), mult_r(in[2], 11363)); /* C7π/16/√8 Cπ/16/√8 */ + b8 = add(a9, a8); + b9 = sub(a8, a9); + b10 = sub(a11, a10); + b11 = add(a10, a11); + b12 = add(a13, a12); + b13 = sub(a12, a13); + b14 = sub(a15, a14); + b15 = add(a14, a15); + + a0 = add(mult_r(in[0], 8192), mult_r(in[8], 8192)); /* Cπ/4/√8 Cπ/4/√8 */ + a1 = add(mult_r(in[8], -8192), mult_r(in[0], 8192)); /* -Cπ/4/√8 Cπ/4/√8 */ + a2 = add(mult_r(in[4], 4433), mult_r(in[12], -10703)); /* Sπ/8/√8 -S3π/8/√8 */ + a3 = add(mult_r(in[12], 4433), mult_r(in[4], 10703)); /* C3π/8/√8 Cπ/8/√8 */ + a4 = add(b5, b4); + a5 = sub(b4, b5); + a6 = sub(b7, b6); + a7 = add(b6, b7); + a8 = b8; move16(); + a9 = add(mult_r(b9, -30274), mult_r(b14, 12540)); /* -Cπ/8 C3π/8 */ + a10 = add(mult_r(b10, -12540), mult_r(b13, -30274)); /* -Sπ/8 -S3π/8 */ + a11 = b11; move16(); + a12 = b12; move16(); + a13 = add(mult_r(b13, 12540), mult_r(b10, -30274)); /* C3π/8 -Cπ/8 */ + a14 = add(mult_r(b14, 30274), mult_r(b9, 12540)); /* S3π/8 Sπ/8 */ + a15 = b15; move16(); + + b0 = add(a3, a0); + b1 = add(a2, a1); + b2 = sub(a1, a2); + b3 = sub(a0, a3); + b4 = a4; move16(); + b5 = add(mult_r(a5, -23170), mult_r(a6, 23170)); /* -Cπ/4 Cπ/4 */ + b6 = add(mult_r(a6, 23170), mult_r(a5, 23170)); /* Cπ/4 Cπ/4 */ + b7 = a7; move16(); + b8 = add(a11, a8); + b9 = add(a10, a9); + b10 = sub(a9, a10); + b11 = sub(a8, a11); + b12 = sub(a15, a12); + b13 = sub(a14, a13); + b14 = add(a13, a14); + b15 = add(a12, a15); + + a0 = add(b7, b0); + a1 = add(b6, b1); + a2 = add(b5, b2); + a3 = add(b4, b3); + a4 = sub(b3, b4); + a5 = sub(b2, b5); + a6 = sub(b1, b6); + a7 = sub(b0, b7); + a10 = add(mult_r(b10, -23170), mult_r(b13, 23170)); /* -Cπ/4 Cπ/4 */ + a11 = add(mult_r(b11, -23170), mult_r(b12, 23170)); /* -Cπ/4 Cπ/4 */ + a12 = add(mult_r(b12, 23170), mult_r(b11, 23170)); /* Cπ/4 Cπ/4 */ + a13 = add(mult_r(b13, 23170), mult_r(b10, 23170)); /* Cπ/4 Cπ/4 */ + + out[0] = add(b15, a0); move16(); + out[1] = add(b14, a1); move16(); + out[2] = add(a13, a2); move16(); + out[3] = add(a12, a3); move16(); + out[4] = add(a11, a4); move16(); + out[5] = add(a10, a5); move16(); + out[6] = add(b9, a6); move16(); + out[7] = add(b8, a7); move16(); + out[8] = sub(a7, b8); move16(); + out[9] = sub(a6, b9); move16(); + out[10] = sub(a5, a10); move16(); + out[11] = sub(a4, a11); move16(); + out[12] = sub(a3, a12); move16(); + out[13] = sub(a2, a13); move16(); + out[14] = sub(a1, b14); move16(); + out[15] = sub(a0, b15); move16(); + + Dyn_Mem_Deluxe_Out(); +} + +void dct32_fx(const Word32 *in, Word32 *out) +{ + Dyn_Mem_Deluxe_In(Word32 a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; + Word32 b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15;); + + a0 = L_add(in[15], in[0]); + a1 = L_add(in[14], in[1]); + a2 = L_add(in[13], in[2]); + a3 = L_add(in[12], in[3]); + a4 = L_add(in[11], in[4]); + a5 = L_add(in[10], in[5]); + a6 = L_add(in[9], in[6]); + a7 = L_add(in[8], in[7]); + a10 = L_sub(in[5], in[10]); + a11 = L_sub(in[4], in[11]); + a12 = L_sub(in[3], in[12]); + a13 = L_sub(in[2], in[13]); + + b0 = L_add(a7, a0); + b1 = L_add(a6, a1); + b2 = L_add(a5, a2); + b3 = L_add(a4, a3); + b4 = L_sub(a3, a4); +#ifdef CR9_C_FIX_DCT2_OVERFLOW + b5 = L_sub_sat(a2, a5); +#else + b5 = L_sub(a2, a5); +#endif +#ifdef CR9_C_FIX_DCT2_OVERFLOW + b6 = L_sub_sat(a1, a6); +#else + b6 = L_sub(a1, a6); +#endif + b7 = L_sub(a0, a7); + b8 = L_sub(in[7], in[8]); + b9 = L_sub(in[6], in[9]); + b10 = L_add(Mpy_32_16_lc3plus(a10, -23170), Mpy_32_16_lc3plus(a13, 23170)); /* -Cπ/4 Cπ/4 */ + b11 = L_add(Mpy_32_16_lc3plus(a11, -23170), Mpy_32_16_lc3plus(a12, 23170)); /* -Cπ/4 Cπ/4 */ + b12 = L_add(Mpy_32_16_lc3plus(a12, 23170), Mpy_32_16_lc3plus(a11, 23170)); /* Cπ/4 Cπ/4 */ + b13 = L_add(Mpy_32_16_lc3plus(a13, 23170), Mpy_32_16_lc3plus(a10, 23170)); /* Cπ/4 Cπ/4 */ + b14 = L_sub(in[1], in[14]); + b15 = L_sub(in[0], in[15]); + + a0 = L_add(b3, b0); + a1 = L_add(b2, b1); + a2 = L_sub(b1, b2); + a3 = L_sub_sat(b0, b3); + a4 = b4; + move16(); + a5 = L_add(Mpy_32_16_lc3plus(b5, -23170), Mpy_32_16_lc3plus(b6, 23170)); /* -Cπ/4 Cπ/4 */ + a6 = L_add(Mpy_32_16_lc3plus(b6, 23170), Mpy_32_16_lc3plus(b5, 23170)); /* Cπ/4 Cπ/4 */ + a7 = b7; + move16(); + a8 = L_add(b11, b8); + a9 = L_add(b10, b9); + a10 = L_sub(b9, b10); + a11 = L_sub(b8, b11); + a12 = L_sub(b15, b12); + a13 = L_sub(b14, b13); + a14 = L_add(b13, b14); + a15 = L_add(b12, b15); + + out[0] = L_add(Mpy_32_16_lc3plus(a0, 8192), Mpy_32_16_lc3plus(a1, 8192)); + move16(); /* Cπ/4/√8 Cπ/4/√8 */ + out[8] = L_add(Mpy_32_16_lc3plus(a1, -8192), Mpy_32_16_lc3plus(a0, 8192)); + move16(); /* -Cπ/4/√8 Cπ/4/√8 */ + out[4] = L_add(Mpy_32_16_lc3plus(a2, 4433), Mpy_32_16_lc3plus(a3, 10703)); + move16(); /* Sπ/8/√8 Cπ/8/√8 */ + out[12] = L_add(Mpy_32_16_lc3plus(a3, 4433), Mpy_32_16_lc3plus(a2, -10703)); + move16(); /* C3π/8/√8 -S3π/8/√8 */ + b4 = L_add(a5, a4); + b5 = L_sub(a4, a5); + b6 = L_sub_sat(a7, a6); + b7 = L_add(a6, a7); + b8 = a8; + move16(); + b9 = L_add(Mpy_32_16_lc3plus(a9, -30274), Mpy_32_16_lc3plus(a14, 12540)); /* -Cπ/8 Sπ/8 */ + b10 = L_add(Mpy_32_16_lc3plus(a10, -12540), Mpy_32_16_lc3plus(a13, -30274)); /* -Sπ/8 -Cπ/8 */ + b11 = a11; + move16(); + b12 = a12; + move16(); + b13 = L_add(Mpy_32_16_lc3plus(a13, 12540), Mpy_32_16_lc3plus(a10, -30274)); /* C3π/8 -S3π/8 */ + b14 = L_add(Mpy_32_16_lc3plus(a14, 30274), Mpy_32_16_lc3plus(a9, 12540)); /* S3π/8 C3π/8 */ + b15 = a15; + move16(); + + out[2] = L_add(Mpy_32_16_lc3plus(b4, 2260), Mpy_32_16_lc3plus(b7, 11363)); + move16(); /* Sπ/16/√8 Cπ/16/√8 */ + out[10] = L_add(Mpy_32_16_lc3plus(b5, 9633), Mpy_32_16_lc3plus(b6, 6436)); + move16(); /* S5π/16/√8 C5π/16/√8 */ + out[6] = L_add(Mpy_32_16_lc3plus(b6, 9633), Mpy_32_16_lc3plus(b5, -6436)); + move16(); /* C3π/16/√8 -S3π/16/√8 */ + out[14] = L_add(Mpy_32_16_lc3plus(b7, 2260), Mpy_32_16_lc3plus(b4, -11363)); + move16(); /* C7π/16/√8 -S7π/16/√8 */ + + a8 = L_add_sat(b9, b8); + a9 = L_sub_sat(b8, b9); + a10 = L_sub_sat(b11, b10); + a11 = L_add_sat(b10, b11); + a12 = L_add_sat(b13, b12); + a13 = L_sub_sat(b12, b13); + a14 = L_sub_sat(b15, b14); + a15 = L_add_sat(b14, b15); + + out[1] = L_add(Mpy_32_16_lc3plus(a8, 1136), Mpy_32_16_lc3plus(a15, 11529)); + move16(); /* Sπ/32/√8 Cπ/32/√8 */ + out[9] = L_add(Mpy_32_16_lc3plus(a9, 8956), Mpy_32_16_lc3plus(a14, 7350)); + move16(); /* S9π/32/√8 C9π/32/√8 */ + out[5] = L_add(Mpy_32_16_lc3plus(a10, 5461), Mpy_32_16_lc3plus(a13, 10217)); + move16(); /* S5π/32/√8 C5π/32/√8 */ + out[13] = L_add(Mpy_32_16_lc3plus(a11, 11086), Mpy_32_16_lc3plus(a12, 3363)); + move16(); /* S13π/32/√8 C13π/32/√8 */ + out[3] = L_add(Mpy_32_16_lc3plus(a12, 11086), Mpy_32_16_lc3plus(a11, -3363)); + move16(); /* C3π/32/√8 -S3π/32/√8 */ + out[11] = L_add(Mpy_32_16_lc3plus(a13, 5461), Mpy_32_16_lc3plus(a10, -10217)); + move16(); /* C11π/32/√8 -S11π/32/√8 */ + out[7] = L_add(Mpy_32_16_lc3plus(a14, 8956), Mpy_32_16_lc3plus(a9, -7350)); + move16(); /* C7π/32/√8 -S7π/32/√8 */ + out[15] = L_add(Mpy_32_16_lc3plus(a15, 1136), Mpy_32_16_lc3plus(a8, -11529)); + move16(); /* C15π/32/√8 -S15/32/√8 */ + + Dyn_Mem_Deluxe_Out(); +} + +void idct32_fx(const Word32 *in, Word32 *out) +{ + Dyn_Mem_Deluxe_In(Word32 a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; + Word32 b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15;); + + a8 = L_add(Mpy_32_16_lc3plus(in[1], 1136), Mpy_32_16_lc3plus(in[15], -11529)); /* Sπ/32/√8 -S15π/32/√8 */ + a9 = L_add(Mpy_32_16_lc3plus(in[9], 8956), Mpy_32_16_lc3plus(in[7], -7350)); /* S9π/32/√8 -S7π/32/√8 */ + a10 = L_add(Mpy_32_16_lc3plus(in[5], 5461), Mpy_32_16_lc3plus(in[11], -10217)); /* S5π/32/√8 -S11π/32/√8 */ + a11 = L_add(Mpy_32_16_lc3plus(in[13], 11086), Mpy_32_16_lc3plus(in[3], -3363)); /* S13π/32/√8 -S3π/32/√8 */ + a12 = L_add(Mpy_32_16_lc3plus(in[3], 11086), Mpy_32_16_lc3plus(in[13], 3363)); /* C3π/32/√8 C13π/32/√8 */ + a13 = L_add(Mpy_32_16_lc3plus(in[11], 5461), Mpy_32_16_lc3plus(in[5], 10217)); /* C11π/32/√8 C5π/32/√8 */ + a14 = L_add(Mpy_32_16_lc3plus(in[7], 8956), Mpy_32_16_lc3plus(in[9], 7350)); /* C7π/32/√8 C9π/32/√8 */ + a15 = L_add(Mpy_32_16_lc3plus(in[15], 1136), Mpy_32_16_lc3plus(in[1], 11529)); /* C15π/32/√8 Cπ/32/√8 */ + + b4 = L_add(Mpy_32_16_lc3plus(in[2], 2260), Mpy_32_16_lc3plus(in[14], -11363)); /* Sπ/16/√8 -S7π/16/√8 */ + b5 = L_add(Mpy_32_16_lc3plus(in[10], 9633), Mpy_32_16_lc3plus(in[6], -6436)); /* S5π/16/√8 -S3π/16/√8 */ + b6 = L_add(Mpy_32_16_lc3plus(in[6], 9633), Mpy_32_16_lc3plus(in[10], 6436)); /* C3π/16/√8 C5π/16/√8 */ + b7 = L_add(Mpy_32_16_lc3plus(in[14], 2260), Mpy_32_16_lc3plus(in[2], 11363)); /* C7π/16/√8 Cπ/16/√8 */ + b8 = L_add(a9, a8); + b9 = L_sub(a8, a9); + b10 = L_sub(a11, a10); + b11 = L_add(a10, a11); + b12 = L_add(a13, a12); + b13 = L_sub(a12, a13); + b14 = L_sub(a15, a14); + b15 = L_add(a14, a15); + + a0 = L_add(Mpy_32_16_lc3plus(in[0], 8192), Mpy_32_16_lc3plus(in[8], 8192)); /* Cπ/4/√8 Cπ/4/√8 */ + a1 = L_add(Mpy_32_16_lc3plus(in[8], -8192), Mpy_32_16_lc3plus(in[0], 8192)); /* -Cπ/4/√8 Cπ/4/√8 */ + a2 = L_add(Mpy_32_16_lc3plus(in[4], 4433), Mpy_32_16_lc3plus(in[12], -10703)); /* Sπ/8/√8 -S3π/8/√8 */ + a3 = L_add(Mpy_32_16_lc3plus(in[12], 4433), Mpy_32_16_lc3plus(in[4], 10703)); /* C3π/8/√8 Cπ/8/√8 */ + a4 = L_add(b5, b4); + a5 = L_sub(b4, b5); + a6 = L_sub(b7, b6); + a7 = L_add(b6, b7); + a8 = b8; + move32(); + a9 = L_add(Mpy_32_16_lc3plus(b9, -30274), Mpy_32_16_lc3plus(b14, 12540)); /* -Cπ/8 C3π/8 */ + a10 = L_add(Mpy_32_16_lc3plus(b10, -12540), Mpy_32_16_lc3plus(b13, -30274)); /* -Sπ/8 -S3π/8 */ + a11 = b11; + move32(); + a12 = b12; + move32(); + a13 = L_add(Mpy_32_16_lc3plus(b13, 12540), Mpy_32_16_lc3plus(b10, -30274)); /* C3π/8 -Cπ/8 */ + a14 = L_add(Mpy_32_16_lc3plus(b14, 30274), Mpy_32_16_lc3plus(b9, 12540)); /* S3π/8 Sπ/8 */ + a15 = b15; + move32(); + + b0 = L_add(a3, a0); + b1 = L_add(a2, a1); + b2 = L_sub(a1, a2); + b3 = L_sub(a0, a3); + b4 = a4; + move32(); + b5 = L_add(Mpy_32_16_lc3plus(a5, -23170), Mpy_32_16_lc3plus(a6, 23170)); /* -Cπ/4 Cπ/4 */ + b6 = L_add(Mpy_32_16_lc3plus(a6, 23170), Mpy_32_16_lc3plus(a5, 23170)); /* Cπ/4 Cπ/4 */ + b7 = a7; + move32(); + b8 = L_add(a11, a8); + b9 = L_add(a10, a9); + b10 = L_sub(a9, a10); + b11 = L_sub(a8, a11); + b12 = L_sub(a15, a12); + b13 = L_sub(a14, a13); + b14 = L_add(a13, a14); + b15 = L_add(a12, a15); + + a0 = L_add(b7, b0); + a1 = L_add(b6, b1); + a2 = L_add(b5, b2); + a3 = L_add(b4, b3); + a4 = L_sub(b3, b4); + a5 = L_sub(b2, b5); + a6 = L_sub(b1, b6); + a7 = L_sub(b0, b7); + a10 = L_add(Mpy_32_16_lc3plus(b10, -23170), Mpy_32_16_lc3plus(b13, 23170)); /* -Cπ/4 Cπ/4 */ + a11 = L_add(Mpy_32_16_lc3plus(b11, -23170), Mpy_32_16_lc3plus(b12, 23170)); /* -Cπ/4 Cπ/4 */ + a12 = L_add(Mpy_32_16_lc3plus(b12, 23170), Mpy_32_16_lc3plus(b11, 23170)); /* Cπ/4 Cπ/4 */ + a13 = L_add(Mpy_32_16_lc3plus(b13, 23170), Mpy_32_16_lc3plus(b10, 23170)); /* Cπ/4 Cπ/4 */ + + out[0] = L_add(b15, a0); + move32(); + out[1] = L_add(b14, a1); + move32(); + out[2] = L_add(a13, a2); + move32(); + out[3] = L_add(a12, a3); + move32(); + out[4] = L_add(a11, a4); + move32(); + out[5] = L_add(a10, a5); + move32(); + out[6] = L_add(b9, a6); + move32(); + out[7] = L_add(b8, a7); + move32(); + out[8] = L_sub(a7, b8); + move32(); + out[9] = L_sub(a6, b9); + move32(); + out[10] = L_sub(a5, a10); + move32(); + out[11] = L_sub(a4, a11); + move32(); + out[12] = L_sub(a3, a12); + move32(); + out[13] = L_sub(a2, a13); + move32(); + out[14] = L_sub(a1, b14); + move32(); + out[15] = L_sub(a0, b15); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +void idct32_32_fx(const Word32 *in, Word32 *out) +{ + Dyn_Mem_Deluxe_In(Word32 a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; + Word32 b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15;); + + /*round(sin(pi*(1:16)/32)/sqrt(8)*2^31) = + 74419526 148122351 220398677 290552444 357908031 421816769 481663180 536870912 + 586908283 631293407 669598830 701455651 726557070 744661347 755594128 759250125 + */ + /*ound(cos(pi*(1:16)/32)/sqrt(8)*2^31) = + 755594128 744661347 726557070 701455651 669598830 631293407 586908283 536870912 + 481663180 421816769 357908031 290552444 220398677 148122351 74419526 0 + */ + + a8 = L_add(Mpy_32_32_lc3plus(in[1], 74419526), Mpy_32_32_lc3plus(in[15], -755594128)); /* Sπ/32/√8 -S15π/32/√8 */ + a9 = L_add(Mpy_32_32_lc3plus(in[9], 586908283), Mpy_32_32_lc3plus(in[7], -481663180)); /* S9π/32/√8 -S7π/32/√8 */ + a10 = L_add(Mpy_32_32_lc3plus(in[5], 357908031), Mpy_32_32_lc3plus(in[11], -669598830)); /* S5π/32/√8 -S11π/32/√8 */ + a11 = L_add(Mpy_32_32_lc3plus(in[13], 726557070), Mpy_32_32_lc3plus(in[3], -220398677)); /* S13π/32/√8 -S3π/32/√8 */ + + a12 = L_add(Mpy_32_32_lc3plus(in[3], 726557070), Mpy_32_32_lc3plus(in[13], 220398677)); /* C3π/32/√8 C13π/32/√8 */ + a13 = L_add(Mpy_32_32_lc3plus(in[11], 357908031), Mpy_32_32_lc3plus(in[5], 669598830)); /* C11π/32/√8 C5π/32/√8 */ + a14 = L_add(Mpy_32_32_lc3plus(in[7], 586908283), Mpy_32_32_lc3plus(in[9], 481663180)); /* C7π/32/√8 C9π/32/√8 */ + a15 = L_add(Mpy_32_32_lc3plus(in[15], 74419526), Mpy_32_32_lc3plus(in[1], 755594128)); /* C15π/32/√8 Cπ/32/√8 */ + + b4 = L_add(Mpy_32_32_lc3plus(in[2], 148122351), Mpy_32_32_lc3plus(in[14], -744661347)); /* Sπ/16/√8 -S7π/16/√8 */ + b5 = L_add(Mpy_32_32_lc3plus(in[10], 631293407), Mpy_32_32_lc3plus(in[6], -421816769)); /* S5π/16/√8 -S3π/16/√8 */ + b6 = L_add(Mpy_32_32_lc3plus(in[6], 631293407), Mpy_32_32_lc3plus(in[10], 421816769)); /* C3π/16/√8 C5π/16/√8 */ + b7 = L_add(Mpy_32_32_lc3plus(in[14], 148122351), Mpy_32_32_lc3plus(in[2], 744661347)); /* C7π/16/√8 Cπ/16/√8 */ + b8 = L_add(a9, a8); + b9 = L_sub(a8, a9); + b10 = L_sub(a11, a10); + b11 = L_add(a10, a11); + b12 = L_add(a13, a12); + b13 = L_sub(a12, a13); + b14 = L_sub(a15, a14); + b15 = L_add(a14, a15); + + a0 = L_add(Mpy_32_32_lc3plus(in[0], 536870912), Mpy_32_32_lc3plus(in[8], 536870912)); /* Cπ/4/√8 Cπ/4/√8 */ + a1 = L_add(Mpy_32_32_lc3plus(in[8], -536870912), Mpy_32_32_lc3plus(in[0], 536870912)); /* -Cπ/4/√8 Cπ/4/√8 */ + a2 = L_add(Mpy_32_32_lc3plus(in[4], 290552444), Mpy_32_32_lc3plus(in[12], -701455651)); /* Sπ/8/√8 -S3π/8/√8 */ + a3 = L_add(Mpy_32_32_lc3plus(in[12], 290552444), Mpy_32_32_lc3plus(in[4], 701455651)); /* C3π/8/√8 Cπ/8/√8 */ + a4 = L_add(b5, b4); + a5 = L_sub(b4, b5); + a6 = L_sub(b7, b6); + a7 = L_add(b6, b7); + a8 = b8; + move32(); + a9 = L_add(Mpy_32_32_lc3plus(b9, -1984016189), Mpy_32_32_lc3plus(b14, 821806413)); /* -Cπ/8 C3π/8 */ + a10 = L_add(Mpy_32_32_lc3plus(b10, -821806413), Mpy_32_32_lc3plus(b13, -1984016189)); /* -Sπ/8 -S3π/8 */ + a11 = b11; + move32(); + a12 = b12; + move32(); + a13 = L_add(Mpy_32_32_lc3plus(b13, 821806413), Mpy_32_32_lc3plus(b10, -1984016189)); /* C3π/8 -Cπ/8 */ + a14 = L_add(Mpy_32_32_lc3plus(b14, 1984016189), Mpy_32_32_lc3plus(b9, 821806413)); /* S3π/8 Sπ/8 */ + a15 = b15; + move32(); + + b0 = L_add(a3, a0); + b1 = L_add(a2, a1); + b2 = L_sub(a1, a2); + b3 = L_sub(a0, a3); + b4 = a4; + move32(); + b5 = L_add(Mpy_32_32_lc3plus(a5, -1518500250), Mpy_32_32_lc3plus(a6, 1518500250)); /* -Cπ/4 Cπ/4 */ + b6 = L_add(Mpy_32_32_lc3plus(a6, 1518500250), Mpy_32_32_lc3plus(a5, 1518500250)); /* Cπ/4 Cπ/4 */ + b7 = a7; + move32(); + b8 = L_add(a11, a8); + b9 = L_add(a10, a9); + b10 = L_sub(a9, a10); + b11 = L_sub(a8, a11); + b12 = L_sub(a15, a12); + b13 = L_sub(a14, a13); + b14 = L_add(a13, a14); + b15 = L_add(a12, a15); + + a0 = L_add(b7, b0); + a1 = L_add(b6, b1); + a2 = L_add(b5, b2); + a3 = L_add(b4, b3); + a4 = L_sub(b3, b4); + a5 = L_sub(b2, b5); + a6 = L_sub(b1, b6); + a7 = L_sub(b0, b7); + a10 = L_add(Mpy_32_32_lc3plus(b10, -1518500250), Mpy_32_32_lc3plus(b13, 1518500250)); /* -Cπ/4 Cπ/4 */ + a11 = L_add(Mpy_32_32_lc3plus(b11, -1518500250), Mpy_32_32_lc3plus(b12, 1518500250)); /* -Cπ/4 Cπ/4 */ + a12 = L_add(Mpy_32_32_lc3plus(b12, 1518500250), Mpy_32_32_lc3plus(b11, 1518500250)); /* Cπ/4 Cπ/4 */ + a13 = L_add(Mpy_32_32_lc3plus(b13, 1518500250), Mpy_32_32_lc3plus(b10, 1518500250)); /* Cπ/4 Cπ/4 */ + + out[0] = L_add(b15, a0); + move32(); + out[1] = L_add(b14, a1); + move32(); + out[2] = L_add(a13, a2); + move32(); + out[3] = L_add(a12, a3); + move32(); + out[4] = L_add(a11, a4); + move32(); + out[5] = L_add(a10, a5); + move32(); + out[6] = L_add(b9, a6); + move32(); + out[7] = L_add(b8, a7); + move32(); + out[8] = L_sub(a7, b8); + move32(); + out[9] = L_sub(a6, b9); + move32(); + out[10] = L_sub(a5, a10); + move32(); + out[11] = L_sub(a4, a11); + move32(); + out[12] = L_sub(a3, a12); + move32(); + out[13] = L_sub(a2, a13); + move32(); + out[14] = L_sub(a1, b14); + move32(); + out[15] = L_sub(a0, b15); + move32(); + + Dyn_Mem_Deluxe_Out(); +} diff --git a/lib_lc3plus/dct4_fx.c b/lib_lc3plus/dct4_fx.c new file mode 100644 index 000000000..af98a395d --- /dev/null +++ b/lib_lc3plus/dct4_fx.c @@ -0,0 +1,228 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include "rom_basop_util.h" + + +void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ + Word16 *pDat_e, /* i/o: pointer to data exponent */ + Word16 L, /* i : length of block */ +#ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION +# ifdef ENABLE_HR_MODE + Word16 hrmode, /* indicate high precision usage */ +# endif +#endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + Word32 *workBuffer) /* : size of L */ + +{ + Word16 sin_step; + Word16 idx; + Word16 M_var; + Word16 M2; + + Word32 *pDat_0; + Word32 *pDat_1; + + Word32 accu1; + Word32 accu2; + Word32 accu3; + Word32 accu4; + + Counter i; + +#ifdef ENABLE_HR_MODE + const PWord32 *twiddle; + const PWord32 *sin_twiddle; +#else + const PWord16 *twiddle; + const PWord16 *sin_twiddle; +#endif + +#ifdef ENABLE_DCTIV_RESCALE + Word16 scale; +#endif + +#ifdef DYNMEM_COUNT +#ifdef ENABLE_HR_MODE + Dyn_Mem_In("dct_IV", sizeof(struct { + Word16 sin_step; + Word16 idx; + Counter i; + Word16 M_var; + Word16 M2; + + Word32 *pDat_0; + Word32 *pDat_1; + + Word32 accu1; + Word32 accu2; + Word32 accu3; + Word32 accu4; + + const PWord32 *twiddle; + const PWord32 *sin_twiddle; + })); + +#else + Dyn_Mem_In("dct_IV", sizeof(struct { + Word16 sin_step; + Word16 idx; + Counter i; + Word16 M_var; + Word16 M2; + + Word32 *pDat_0; + Word32 *pDat_1; + + Word32 accu1; + Word32 accu2; + Word32 accu3; + Word32 accu4; + + const PWord16 *twiddle; + const PWord16 *sin_twiddle; + })); +#endif /* ENABLE_HR_MODE */ +#endif /* DYNMEM_COUNT */ + + M_var = shr_pos_pos(L, 1); + M2 = sub(M_var, 1); + + BASOP_getTables(&twiddle, &sin_twiddle, &sin_step, L); + + pDat_0 = &pDat[0]; + pDat_1 = &pDat[L - 2]; + + FOR (i = 0; i < M2; i += 2) + { +#ifdef ENABLE_HR_MODE +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + if (hrmode) { + cplxMpy32_32_32_2(accu1, accu2, pDat_1[1], pDat_0[0], twiddle[i].v.re, twiddle[i].v.im); + cplxMpy32_32_32_2(accu3, accu4, pDat_1[0], pDat_0[1], twiddle[i + 1].v.re, twiddle[i + 1].v.im); + } else { + cplxMpy32_32_16_2(accu1, accu2, pDat_1[1], pDat_0[0], round_fx_sat(twiddle[i].v.re), round_fx_sat(twiddle[i].v.im)); + cplxMpy32_32_16_2(accu3, accu4, pDat_1[0], pDat_0[1], round_fx_sat(twiddle[i + 1].v.re), round_fx_sat(twiddle[i + 1].v.im)); + } +# else /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + cplxMpy32_32_32_2(accu1, accu2, pDat_1[1], pDat_0[0], twiddle[i].v.re, twiddle[i].v.im); + cplxMpy32_32_32_2(accu3, accu4, pDat_1[0], pDat_0[1], twiddle[i + 1].v.re, twiddle[i + 1].v.im); +# endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + +#else + cplxMpy32_32_16_2(accu1, accu2, pDat_1[1], pDat_0[0], twiddle[i].v.re, twiddle[i].v.im); + cplxMpy32_32_16_2(accu3, accu4, pDat_1[0], pDat_0[1], twiddle[i + 1].v.re, twiddle[i + 1].v.im); +#endif + + pDat_0[0] = accu2; move32(); + pDat_0[1] = accu1; move32(); + pDat_1[0] = accu4; move32(); + pDat_1[1] = L_negate(accu3); move32(); + + pDat_0 = pDat_0 + 2; + pDat_1 = pDat_1 - 2; + } + +#ifdef ENABLE_DCTIV_RESCALE +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + if (hrmode) +# endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + { + + scale = s_max(getScaleFactor32_lc3plus(pDat, L), 0); move16(); + + FOR (i = 0; i < L; i++) + { + pDat[i] = L_shl_pos(pDat[i], scale); move32(); + } + + *pDat_e = sub(*pDat_e, scale); move16(); + } +#endif + + BASOP_cfft_lc3plus(&pDat[0], &pDat[1], M_var, 2, pDat_e, workBuffer); + + pDat_0 = &pDat[0]; + pDat_1 = &pDat[L - 2]; + + idx = sin_step; + M2 = sub(shr_pos_pos(add(M_var, 1), 1), 1); + + /* Sin and Cos values are 0.0f and 1.0f */ +#ifdef ENABLE_HR_MODE + cplxMpy32_32_32_2(accu3, accu4, pDat_1[0], pDat_1[1], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#else + cplxMpy32_32_16_2(accu3, accu4, pDat_1[0], pDat_1[1], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#endif + + pDat_1[1] = L_negate(L_shr_pos(pDat_0[1], 1)); move32(); + pDat_0[0] = L_shr_pos(pDat_0[0], 1); move32(); + + FOR (i = 1; i < M2; i++) + { + pDat_0[1] = accu3; move32(); + pDat_1[0] = accu4; move32(); + + pDat_0 = pDat_0 + 2; + pDat_1 = pDat_1 - 2; + +#ifdef ENABLE_HR_MODE + cplxMpy32_32_32_2(accu1, accu2, pDat_0[1], pDat_0[0], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#else + cplxMpy32_32_16_2(accu1, accu2, pDat_0[1], pDat_0[0], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#endif + + idx += sin_step; + +#ifdef ENABLE_HR_MODE + cplxMpy32_32_32_2(accu3, accu4, pDat_1[0], pDat_1[1], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#else + cplxMpy32_32_16_2(accu3, accu4, pDat_1[0], pDat_1[1], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#endif + + pDat_1[1] = L_negate(accu1); move32(); + pDat_0[0] = accu2; move32(); + } + + pDat_0[1] = accu3; move32(); + pDat_1[0] = accu4; move32(); + + pDat_0 = pDat_0 + 2; + pDat_1 = pDat_1 - 2; + +#ifdef ENABLE_HR_MODE + cplxMpy32_32_32_2(accu3, accu4, pDat_0[1], pDat_0[0], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#else + cplxMpy32_32_16_2(accu3, accu4, pDat_0[1], pDat_0[0], sin_twiddle[idx].v.re, sin_twiddle[idx].v.im); +#endif + +/* Last Sin and Cos value pair are the same */ +#ifdef ENABLE_HR_MODE + accu1 = L_shr_pos(Mpy_32_32_lc3plus(pDat_1[0], TWIDDLE), 1); + accu2 = L_shr_pos(Mpy_32_32_lc3plus(pDat_1[1], TWIDDLE), 1); +#else + accu1 = L_shr_pos(Mpy_32_16_lc3plus(pDat_1[0], TWIDDLE), 1); + accu2 = L_shr_pos(Mpy_32_16_lc3plus(pDat_1[1], TWIDDLE), 1); +#endif + + pDat_1[0] = L_add(accu1, accu2); move32(); + pDat_0[1] = L_sub(accu1, accu2); move32(); + + pDat_1[1] = L_negate(accu3); move32(); + pDat_0[0] = accu4; move32(); + + /* twiddeling scale is 2 */ + *pDat_e = add(*pDat_e, 2); move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c new file mode 100644 index 000000000..48512f9fe --- /dev/null +++ b/lib_lc3plus/dec_entropy.c @@ -0,0 +1,387 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static Word16 read_indice(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 numbits); + +static Word16 ac_dec_split_st2VQ_CW( /* local BER flag */ + const Word32 L_cwRx, /* max 25 bits */ + const Word32 L_szA, const Word32 L_szB, Word32 *L_cwA, Word32 *L_cwB, + Word16 *submodeLSB); + +void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, + Word16 L_spec, Word16 fs_idx, Word16 BW_cutoff_bits, Word16 *tns_numfilters, + Word16 *lsbMode, Word16 *lastnz, Word16 *bfi, Word16 *tns_order, Word16 *fac_ns_idx, + Word16 *gg_idx, Word16 *BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, + Word16 frame_dms) +{ + Dyn_Mem_Deluxe_In( + Word16 L, submodeLSB; + Word32 tmp32, tmp32lim; + Word16 gain_e, gain, submodeMSB, BER_detect; + Counter n; + UWord8 *ptr; + ); + + ptr = bytes; + *bp_side = shr_pos(sub(nbbits, 1), 3); + *mask_side = shl(1, sub(8, sub(nbbits, shl_pos(*bp_side, 3)))); + + /* Cutoff-detection */ + IF (BW_cutoff_bits > 0) + { + *BW_cutoff_idx = read_indice(ptr, bp_side, mask_side, BW_cutoff_bits); + /* check for bitflips */ + IF (sub(fs_idx, *BW_cutoff_idx) < 0) + { + *BW_cutoff_idx = fs_idx; + *bfi = 1; move16(); + Dyn_Mem_Deluxe_Out(); + return; + } + } + ELSE + { + *BW_cutoff_idx = fs_idx; + } + + /* Number of TNS filters */ + IF (sub(*BW_cutoff_idx, 3) >= 0 && frame_dms >= 50) + { + *tns_numfilters = 2; move16(); + } + ELSE + { + *tns_numfilters = 1; move16(); + } + + /* Decode number of ntuples */ + L = sub(14, norm_s(negate(L_spec))); + n = read_indice(ptr, bp_side, mask_side, L); + n = add(n, 1); + *lastnz = shl_pos(n, 1); + IF (sub(*lastnz, L_spec) > 0) + { + *bfi = 1; move16(); + Dyn_Mem_Deluxe_Out(); + return; + } + + /* Mode bit */ + *lsbMode = read_bit(ptr, bp_side, mask_side); + + /* Decode global-gain */ + *gg_idx = read_indice(ptr, bp_side, mask_side, 8); move16(); + tmp32 = L_shl_pos(L_mult0(*gg_idx, 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ + gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); /* get exponent */ + gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, 0xFE000000))); + assert(gain >= 0); /* JSv, check if shr_pos(gain,1) is more appropriate) */ + gain = shr_r(gain, 1); + gain_e = add(gain_e, 1); + + /* Decode TNS on/off flag */ + tns_order[1] = 0; move16(); /* fix problem with uninitialized memory */ + FOR (n = 0; n < *tns_numfilters; n++) + { + tns_order[n] = read_bit(ptr, bp_side, mask_side); move16(); + } + + /* LTPF on/off */ +#ifdef ENABLE_HR_MODE + ltpf_idx[0] = read_bit(ptr, bp_side, mask_side); move16(); +#else + ltpf_idx[0] = read_indice(ptr, bp_side, mask_side, 1); move16(); +#endif + + /* Decode SNS VQ parameters - 1st stage (10 bits) */ +#ifdef ENABLE_HR_MODE + L = read_indice(ptr, bp_side, mask_side, 5 + 5); + L_scf_idx[0] = L_deposit_l(s_and(L, 0x1F)); /* stage1 LF 5 bits */ + L_scf_idx[1] = L_deposit_l(shr_pos(L, 5)); /* stage1 HF 5 bits */ +#else + L_scf_idx[0] = L_deposit_l(read_indice(ptr, bp_side, mask_side, 5)); /* stage1 LF 5 bits */ + L_scf_idx[1] = L_deposit_l(read_indice(ptr, bp_side, mask_side, 5)); /* stage1 HF 5 bits */ +#endif + + /* Decode SNS VQ parameters - 2nd stage side-info (3-4 bits) */ + submodeMSB = read_bit(ptr, bp_side, mask_side); /* submodeMSB 1 bit */ + L_scf_idx[2] = L_deposit_l(shl_pos(submodeMSB, 1)); + ASSERT(sns_gainMSBbits[L_scf_idx[2]] > 0); + L_scf_idx[3] = L_deposit_l( + read_indice(ptr, bp_side, mask_side, sns_gainMSBbits[L_scf_idx[2]])); /* gains or gain MSBs 1-2 bits */ + L_scf_idx[4] = read_bit(ptr, bp_side, mask_side); /* shape LS 1 bit */ + + /* Decode SNS VQ parameters - 2nd stage data (24-25 bits) */ + IF (submodeMSB == 0) + { /* shape_j = 0, or 1 */ + /* regular mode A,B indexes integer multiplexed, total 24.x bits MPVQ codeword section A and codeword for + * section B */ + /* regular mode mode shape index total 24.9999 bits MPVQ codeword */ + tmp32 = L_deposit_l(read_indice(ptr, bp_side, mask_side, 13)); + tmp32 = L_or(tmp32, L_shl_pos(read_indice(ptr, bp_side, mask_side, 12), 13)); move16(); /*for ber state */ + BER_detect = + ac_dec_split_st2VQ_CW( /* local BER flag */ + tmp32, /* L_cwRx max 25 bits */ + sns_MPVQ_Sz[0][0], UL_addNsD(sns_MPVQ_Sz[0][1], sns_MPVQ_Sz[1][1]), /* 12+2 = 14 */ + (&L_scf_idx[5]), /* shape A */ + (&L_scf_idx[6]), /* shape B or gain LSB */ + &submodeLSB /* total submode update below */ + ); + IF (submodeLSB != 0) + { /* add gainLSB bit */ + L_scf_idx[3] = L_add(L_shl_pos(L_scf_idx[3], 1), L_scf_idx[6]); + L_scf_idx[6] = -2L; + } + } + ELSE + { /* shape_j = 2 or 3 */ + ASSERT(submodeMSB == 1); + /* outlier mode shape index total 23.8536 + 19.5637 (19.5637 < (log2(2.^24 -2.^23.8537)) bits MPVQ + * codeword */ + tmp32 = L_deposit_l(read_indice(ptr, bp_side, mask_side, 12)); + tmp32 = L_or(tmp32, L_shl_pos(read_indice(ptr, bp_side, mask_side, 12), 12)); + L_scf_idx[5] = tmp32; move32(); /*shape outl_near or outl_far */ + submodeLSB = 0; move16(); + BER_detect = 0; move16(); + tmp32lim = L_add(sns_MPVQ_Sz[2][0], L_shl_pos(sns_MPVQ_Sz[3][0], 1)); + IF (L_sub(tmp32, tmp32lim) >= 0) + { + BER_detect = 1; move16(); + } + ELSE + { + tmp32 = L_sub(tmp32, sns_MPVQ_Sz[2][0]); /* a potential high index is computed */ + IF (tmp32 >= 0) + { + submodeLSB = 1; move16(); + ASSERT(tmp32 >= 0 && tmp32 < (Word32)(2 * sns_MPVQ_Sz[3][0])); + L_scf_idx[3] = L_add(L_shl_pos(L_scf_idx[3], 1), L_and(tmp32, 0x1)); /* add LSB_gain bit to gain MSBs */ + L_scf_idx[5] = L_shr_pos(tmp32, 1); /* MPVQ index with offset and gainLSB removed */ + L_scf_idx[6] = -2L; move32(); + } + ELSE + { + L_scf_idx[6] = -1L; move32(); + } + } + } + L_scf_idx[2] = + L_add(L_scf_idx[2], L_deposit_l(submodeLSB)); /* decoder internal signal shape_j = submode 0..3 to VQ */ + + IF (BER_detect > 0) + { + *bfi = 1; move16(); + Dyn_Mem_Deluxe_Out(); + return; + } + + /* LTPF data */ + IF (ltpf_idx[0] != 0) + { +#ifdef ENABLE_HR_MODE + L = read_indice(ptr, bp_side, mask_side, 1+9); move16(); + ltpf_idx[1] = s_and(L, 1); move16(); + ltpf_idx[2] = shr_pos(L, 1); move16(); +#else + ltpf_idx[1] = read_indice(ptr, bp_side, mask_side, 1); move16(); + ltpf_idx[2] = read_indice(ptr, bp_side, mask_side, 9); move16(); + +#endif + } + ELSE + { + ltpf_idx[1] = 0; move16(); + ltpf_idx[2] = 0; move16(); + } + + /* Decode noise-fac */ + *fac_ns_idx = read_indice(ptr, bp_side, mask_side, 3); move16(); + + Dyn_Mem_Deluxe_Out(); +} + +#ifdef ENABLE_PADDING +int paddingDec_fx(UWord8 *bytes, Word16 nbbits, Word16 L_spec, Word16 BW_cutoff_bits, Word16 ep_enabled, + Word16 *total_padding, Word16 *np_zero) +{ + Word16 lastnz_threshold; + Word16 padding_len_bits, padding_len; + + Word16 bp_side; + Word16 nbbytes = shr(nbbits,3); + + Word16 mask_side; + UWord8 *ptr = bytes; + + Word16 lastnz; + Word16 nbits = sub(14, norm_s(negate(L_spec))); + if (sub(nbbits, nbits) < 0) + { + return 1; + } + *np_zero = 0; + + *total_padding = 0; + + bp_side = shr_pos(sub(nbbits, 1), 3); + mask_side = shl(1, sub(8, sub(nbbits, shl_pos(bp_side, 3)))); + + test(); + IF (sub(bp_side, 19) < 0 || sub(bp_side, LC3PLUS_MAX_BYTES ) >= 0) { + return 1; + } + + ptr = bytes; + + IF (BW_cutoff_bits > 0) + { + read_indice(ptr, &bp_side, &mask_side, BW_cutoff_bits); + move16(); + } + + lastnz = read_indice(ptr, &bp_side, &mask_side, nbits); + move16(); + + lastnz_threshold = sub(shl(1, nbits), 2); + + WHILE (lastnz == lastnz_threshold) + { + padding_len_bits = sub(sub(12, nbits), BW_cutoff_bits); + + /*Read padding length*/ + padding_len = read_indice(ptr, &bp_side, &mask_side, padding_len_bits); + move16(); + + /* Read 4 reserved bits */ + read_indice(ptr, &bp_side, &mask_side, 4); + move16(); + + IF (ep_enabled == 0) + { + /* Discard padding length bytes */ + bp_side = sub(bp_side, padding_len); + *total_padding = add(add(*total_padding, padding_len), 2); move16(); + } + ELSE + { + *total_padding = add(*total_padding, 2); move16(); + *np_zero = add(*np_zero, padding_len); move16(); + } + + /* test if we have less than 20 bytes left; if so frame is broken */ + IF (sub(sub(nbbytes,add(*total_padding,*np_zero)),20) < 0) { + return 1; + } + + /* Read bandwidth bits */ + IF (BW_cutoff_bits > 0) + { + read_indice(ptr, &bp_side, &mask_side, BW_cutoff_bits); + move16(); + } + + lastnz = read_indice(ptr, &bp_side, &mask_side, nbits); + move16(); + } + + IF (ep_enabled != 0) + { + *total_padding = add(*total_padding, *np_zero); move16(); + } + return 0; +} +#endif + +static __forceinline Word16 read_indice(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 numbits) +{ + Dyn_Mem_Deluxe_In( + Word16 indice, bit; + Counter i; + ); + + indice = read_bit(ptr, bp, mask); + + FOR (i = 1; i < numbits; i++) + { + bit = read_bit(ptr, bp, mask); + indice = add(indice, lshl_pos(bit, i)); + } + + Dyn_Mem_Deluxe_Out(); + return indice; +} + +static __forceinline Word16 ac_dec_split_st2VQ_CW( /* local BER flag */ + const Word32 L_cwRx, /* max 25 bits */ + const Word32 L_szA, const Word32 L_szB, Word32 *L_cwA, Word32 *L_cwB, + Word16 *submodeLSB) +{ + /* demultiplex: L_cwRx = L_cwB(21.z bits) * L_szA(3.y bits) + L_cwA(21.x bits)); */ + Word16 start, fin, ind; + Word32 L_tmp, L_max_size; + Counter i; + + L_max_size = (Word32)UL_Mpy_32_32((UWord32)L_szB, (UWord32)L_szA); /* may be tabled */ + + /* section B ind larger than 13 out of the possible 14 = 0..13 */ + IF (L_sub(L_cwRx, L_max_size) >= 0) + { + *L_cwA = L_deposit_l(0); + *L_cwB = L_deposit_l(0); + *submodeLSB = 0; move16(); + return (Word16)1; /* set berFlag and exit */ + } + + /*initial binary split of cw, select top or low half */ + start = 0; move16(); + + ASSERT((L_szB & 0x1L) == 0); /* this middle split only works if L_szB is even */ + if (L_sub(L_cwRx, L_shr_pos(L_max_size, 1)) >= 0) + { + start = L_shr_pos(L_szB, 1); /* top half start index */ + } + + /*linear loop over a low or a high section */ + ind = start; move16(); + L_tmp = L_negate(L_cwRx); /* search from negative side */ + + L_tmp = L_add(L_tmp, (Word32)UL_Mpy_32_32(UL_deposit_l((UWord16)start), (UWord32)L_szA)); + /* start is 0 or 7 */ /*non-fractional mult is (int)start * L_szA */ + + /* a short linear run over ceil(szB/2) = 7 values */ + + fin = add(start, shr_pos(L_szB, 1)); + FOR (i = start; i < fin; i++) + { + ind = add(ind, 1); + L_tmp = L_add(L_tmp, L_szA); + if (L_tmp > 0) + { + ind = sub(ind, 1); /* passed criteria point, keep index */ + } + } + + *L_cwB = L_deposit_l(ind); + *L_cwA = L_sub(L_cwRx, (Word32)UL_Mpy_32_32(UL_deposit_l((UWord16)ind), + (UWord32)L_szA)); /* non-fractional mult; (int)ind * L_szA */ + + ASSERT(*L_cwA >= 0 && *L_cwA < L_szA); + ASSERT(*L_cwB >= 0 && *L_cwB < L_szB); + + *submodeLSB = 0; + *L_cwB = L_sub(*L_cwB, 2); + if (*L_cwB < 0) + { + *submodeLSB = 1; move16(); + } + *L_cwB = L_mac0(*L_cwB, 2, *submodeLSB); /* add back gain ind if needed */ + + return 0; /* no BER */ +} diff --git a/lib_lc3plus/dec_lc3.c b/lib_lc3plus/dec_lc3.c new file mode 100644 index 000000000..40818106e --- /dev/null +++ b/lib_lc3plus/dec_lc3.c @@ -0,0 +1,788 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_sample, UWord8 *bs_in, void *s_out, Word16 bfi, + Word8 *scratchBuffer) +{ + Word16 scale; + Word32 offset; + Word16 fill_bits; + Word16 nf_seed, gg_idx, fac_ns_idx, q_fx_exp = 0; + Word16 bp_side, mask_side; + Word16 tns_numfilters, lsbMode, lastnz, BW_cutoff_idx, BW_cutoff_idx_nf; + Word16 zero_frame = 0; +#ifdef ENABLE_RFRAME + Word16 rframe = 0; +#endif + Word16 ltpf_idx[3]; + Word16 spec_inv_idx = 0; + Counter i; + + /* Buffers */ + Word16 *int_scf_fx_exp, tns_order[TNS_NUMFILTERS_MAX]; + UWord8 *resBitBuf; +#ifdef ENABLE_HR_MODE + Word32 *sqQdec; +#else + Word16 * sqQdec; + Word16 * int_scf_fx; +#endif + Word16 * x_fx, *indexes; + Word16 scf_q[M]; + Word32 * L_scf_idx; + Word32 * q_d_fx; + Word8 * currentScratch; + DecSetup *h_DecSetup = decoder->channel_setup[channel]; +#ifdef ENABLE_HR_MODE + Word32 *x_fx_ip; + Word32 *int_scf_fx_ip; + Word32 scf_q_ip[M]; +#endif + +#ifdef DYNMEM_COUNT + struct _dynmem + { + Counter i; + Word16 scale; + Word32 offset; + Word16 fill_bits; + Word16 nf_seed, gg_idx, fac_ns_idx, q_fx_exp; + Word16 bp_side, mask_side; + Word16 tns_numfilters, lsbMode, lastnz, BW_cutoff_idx, BW_cutoff_idx_nf; + Word16 zero_frame; + Word16 ltpf_idx[3]; +#ifdef ENABLE_RFRAME + Word16 rframe; +#endif + Word16 spec_inv_idx; + + /* Buffers */ + Word16 *int_scf_fx_exp, tns_order[TNS_NUMFILTERS_MAX]; + UWord8 *resBitBuf; +#ifdef ENABLE_HR_MODE + Word32 *sqQdec; +#else + Word16 *sqQdec; +#endif + Word16 *int_scf_fx, *x_fx, *indexes; + Word32 *L_scf_idx; + Word32 *q_d_fx; + Word8 * currentScratch; + Word16 scf_q[M]; +#ifdef ENABLE_HR_MODE + Word32 scf_q_ip[M]; +#endif + }; + Dyn_Mem_In("Dec_LC3_Channel", sizeof(struct _dynmem)); +#endif + +#ifdef DISABLE_PLC + UNUSED(decoder->plcMeth); +#endif + + + /* BUFFER INITIALISATION. Some buffers may overlap since they are not used in the whole decoding process */ + q_d_fx = scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LEN bytes */ +#ifdef ENABLE_HR_MODE + /* allocate memory for residual bits */ + if (decoder->hrmode) + { + resBitBuf = scratchAlign(q_d_fx, sizeof(*q_d_fx) * + decoder->frame_length); + basop_memset(resBitBuf, 0, sizeof(*resBitBuf) * MAX_RESBITS_LEN); + } + else +#endif + { + resBitBuf = scratchAlign(q_d_fx, sizeof(*q_d_fx) * + decoder->frame_length); /* Size = 2 * NPRM_RESQ = 2 * MAX_LEN bytes for + normal case and 2*MAX_RESBITS_LEN for hrmode */ + basop_memset(resBitBuf, 0, sizeof(*resBitBuf) * 2 * decoder->frame_length); + } + +#ifdef ENABLE_HR_MODE + indexes = scratchAlign(resBitBuf, sizeof(*resBitBuf) * MAX_RESBITS_LEN); +#else + indexes = scratchAlign(resBitBuf, sizeof(*resBitBuf) * 2 * decoder->frame_length); +#endif + memset(indexes, 0, sizeof(*indexes) * TNS_NUMFILTERS_MAX * MAXLAG); + + /* indexes Size = 2 * TNS_NUMFILTERS_MAX * MAXLAG = 32 bytes */ + + L_scf_idx = scratchAlign(indexes, sizeof(*indexes) * TNS_NUMFILTERS_MAX * + MAXLAG); /* Size = 4 * SCF_MAX_PARAM = 28 bytes -> aligned to 32 bytes */ + sqQdec = scratchAlign(L_scf_idx, sizeof(*L_scf_idx) * (SCF_MAX_PARAM)); /* Size = 2 * MAX_LEN bytes */ + int_scf_fx_exp = scratchAlign(sqQdec, sizeof(*sqQdec) * decoder->frame_length); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ +#ifndef ENABLE_HR_MODE + int_scf_fx = scratchAlign(int_scf_fx_exp, + sizeof(*int_scf_fx_exp) * MAX_BANDS_NUMBER); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ +#endif +#ifdef ENABLE_HR_MODE + x_fx = + scratchAlign(int_scf_fx_exp, sizeof(*int_scf_fx_exp) * MAX_BANDS_NUMBER); /* Size = 2 * (MAX_LEN + MDCT_MEM_LEN_MAX) = 2 + * MAX_LEN + 1.25 * MAX_LEN = 3.25 * MAX_LEN */ +#else + x_fx = + scratchAlign(q_d_fx, sizeof(*q_d_fx) * decoder->frame_length); /* Size = 2 * (MAX_LEN + MDCT_MEM_LEN_MAX) = 2 + * MAX_LEN + 1.25 * MAX_LEN = 3.25 * MAX_LEN */ +#endif + +#ifdef ENABLE_HR_MODE + x_fx_ip = scratchAlign(x_fx, sizeof(*x_fx) * (decoder->frame_length + decoder->stDec_ola_mem_fx_len)); + int_scf_fx_ip = scratchAlign(x_fx_ip, sizeof(*x_fx_ip) * (decoder->frame_length + decoder->stDec_ola_mem_fx_len)); + + currentScratch = scratchAlign(int_scf_fx_ip, sizeof(*int_scf_fx_ip) * 2 * MAX_BANDS_NUMBER); /* Size = 4 * MAX_LEN */ +#else + currentScratch = scratchAlign(x_fx, sizeof(*x_fx) * 4 * MAX_LEN); /* Size = 4 * MAX_LEN */ +#endif + +#ifdef DISABLE_PLC + memset(q_d_fx, 0, decoder->frame_length * sizeof(*q_d_fx)); +#endif + +#ifdef WMOPS + BASOP_sub_start("Decoder"); +#endif + +#ifdef ENABLE_RFRAME + IF (sub(bfi, 3) == 0) + { + bfi = 2; + move16(); + rframe = 1; + move16(); + } +#endif + + if (bfi != 1) + { +#ifdef WMOPS + BASOP_sub_sub_start("Dec(bfi=0)"); +#endif + } + else + { +#ifdef WMOPS + BASOP_sub_sub_start("Dec(bfi=1)"); +#endif + } + +#ifdef WMOPS + BASOP_sub_start("Entropy dec"); +#endif + IF (sub(bfi, 1) != 0) + { + processDecoderEntropy_fx(bs_in, &bp_side, &mask_side, h_DecSetup->total_bits, decoder->yLen, decoder->fs_idx, + decoder->BW_cutoff_bits, &tns_numfilters, &lsbMode, &lastnz, &bfi, tns_order, + &fac_ns_idx, &gg_idx, &BW_cutoff_idx, ltpf_idx, L_scf_idx, decoder->frame_dms); + BW_cutoff_idx_nf = BW_cutoff_idx; + move16(); + } +#ifdef WMOPS + BASOP_sub_end(); /* Entropy dec */ +#endif + +#ifdef WMOPS + BASOP_sub_start("Ari dec"); +#endif + IF (sub(bfi, 1) != 0) + { + processAriDecoder_fx(bs_in, &bp_side, &mask_side, h_DecSetup->total_bits, decoder->yLen, decoder->fs_idx, + h_DecSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &bfi, tns_order, + fac_ns_idx, gg_idx, decoder->frame_dms, + decoder->n_pc, decoder->be_bp_left, decoder->be_bp_right, 0, &spec_inv_idx, &scale, + &fill_bits, sqQdec, &nf_seed, resBitBuf, indexes, &zero_frame, currentScratch +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif + ); + +#ifdef ENABLE_RFRAME + test();test(); + IF (sub(rframe, 1) == 0 && zero_frame == 0 && sub(bfi, 1) != 0) + { + bfi = 2; + move16(); + Word16 max_bw_stopband = BW_cutoff_bin_all[BW_cutoff_idx]; + SWITCH (decoder->frame_dms) + { +#ifdef ENABLE_025_DMS_MODE + case 25: + max_bw_stopband = shr_pos(max_bw_stopband, 2); + BREAK; +#endif +#ifdef ENABLE_050_DMS_MODE + case 50: + max_bw_stopband = shr_pos(max_bw_stopband, 1); + BREAK; +#endif +#ifdef CR8_G_ADD_75MS + case 75: + max_bw_stopband = add(shr_pos(max_bw_stopband, 2), add(shr_pos(max_bw_stopband, 2), shr_pos(max_bw_stopband, 2))); + BREAK; +#endif + case 100: + BREAK; + } + + spec_inv_idx = s_max(lastnz, max_bw_stopband); + move16(); + } +#endif + + IF (bfi == 0) + { + processAriDecoderScaling_fx(sqQdec, decoder->yLen, q_d_fx, &q_fx_exp); + } + } +#ifdef WMOPS + BASOP_sub_end(); /* Ari dec */ +#endif + +#ifdef WMOPS + BASOP_sub_start("SnsQuantScfDec"); +#endif + IF (sub(bfi, 1) != 0) + { + /* currentScratch Size = 96 bytes */ +#ifdef ENABLE_HR_MODE + processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q_ip, currentScratch); + downshift_w32_arr(scf_q_ip, scf_q, 15, M); /* required for PLC */ +#else + processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q, currentScratch); +#endif + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("PLC::ComputeStabFac"); +#endif + if (h_DecSetup->plcAd) + { + processPLCcomputeStabFac_main(scf_q, h_DecSetup->plcAd->old_scf_q, h_DecSetup->plcAd->old_old_scf_q, bfi, + h_DecSetup->prev_bfi, h_DecSetup->prev_prev_bfi, &h_DecSetup->plcAd->stab_fac); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Partial Concealment"); +#endif + IF (sub(bfi, 1) != 0) + { + scale = 32767; + move16(); + + IF (h_DecSetup->plcAd) + { + scale = h_DecSetup->plcAd->stab_fac; + } + + processPCmain_fx(rframe, &bfi, decoder->yLen, decoder->frame_dms, h_DecSetup->q_old_res_fx, + &h_DecSetup->q_old_res_fx_exp, sqQdec, h_DecSetup->q_old_d_fx, spec_inv_idx, ltpf_idx[0], + scale, q_d_fx, &q_fx_exp, gg_idx, h_DecSetup->quantizedGainOff, &h_DecSetup->prev_gg, + &h_DecSetup->prev_gg_e, &BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, + &h_DecSetup->prev_fac_ns_fx, &h_DecSetup->pc_nbLostFramesInRow); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + + IF (sub(bfi, 1) != 0) + { +#ifdef WMOPS + BASOP_sub_start("Residual dec"); +#endif + processResidualDecoding_fx(q_d_fx, q_fx_exp, decoder->yLen, resBitBuf, fill_bits +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Noisefill"); +#endif + /* currentScratch Size = 2 * MAX_LEN bytes */ + IF (zero_frame == 0) + { + processNoiseFilling_fx(q_d_fx, nf_seed, q_fx_exp, fac_ns_idx, BW_cutoff_idx_nf, decoder->frame_dms, + h_DecSetup->prev_fac_ns_fx, spec_inv_idx, currentScratch +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif + ); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("applyGlobalGain"); +#endif + processApplyGlobalGain_fx(q_d_fx, &q_fx_exp, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Tns_dec"); +#endif + /* currentScratch Size = 48 bytes */ + processTnsDecoder_fx(indexes, q_d_fx, decoder->yLen, tns_order, &q_fx_exp, BW_cutoff_idx, decoder->frame_dms, + currentScratch +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef ENABLE_HR_MODE +#ifdef WMOPS + BASOP_sub_start("SnsInterpScfDec"); +#endif + processSnsInterpolateScf_fx(scf_q_ip, int_scf_fx_ip, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); + +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Mdct shaping_dec"); +#endif + processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); + + processMdctShaping_fx(q_d_fx, int_scf_fx_ip, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); +#ifdef WMOPS + BASOP_sub_end(); +#endif +#else +#ifdef WMOPS + BASOP_sub_start("SnsInterpScfDec"); +#endif + /* currentScratch Size = 128 bytes */ + processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Mdct shaping_dec"); +#endif + processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); + processMdctShaping_fx(q_d_fx, int_scf_fx, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); +#ifdef WMOPS + BASOP_sub_end(); +#endif + /* end int_scf_fx */ +#endif /* ENABLE_HR_MODE */ + } + + /* x_fx_ip will be used to store h_DecSetup->stDec_ola_mem_fx returned by PLCmain_fx*/ + /* This will be upshifted to 32 bit overlap buffer outside of the PLCmain function */ +#ifdef ENABLE_HR_MODE + Word16 *plc_ola_mem = (Word16 *)x_fx_ip; + IF(sub(bfi, 1) == 0) + { + FOR(i = 0; i < decoder->stDec_ola_mem_fx_len; i++) + { + plc_ola_mem[i] = round_fx(h_DecSetup->stDec_ola_mem_fx[i]); + } + } +#endif + +#ifdef WMOPS + BASOP_sub_start("PLC::Main"); +#endif + /* currentScratch Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ + processPLCmain_fx(decoder->plcMeth, &h_DecSetup->concealMethod, &h_DecSetup->nbLostFramesInRow, bfi, + h_DecSetup->prev_bfi, decoder->frame_length, decoder->la_zeroes, decoder->W_fx, x_fx, +#ifdef ENABLE_HR_MODE + plc_ola_mem, +#else + h_DecSetup->stDec_ola_mem_fx, +#endif + &h_DecSetup->stDec_ola_mem_fx_exp, h_DecSetup->q_old_d_fx, + &h_DecSetup->q_old_fx_exp, q_d_fx, &q_fx_exp, decoder->yLen, decoder->fs_idx, + decoder->bands_offset, decoder->bands_number, &h_DecSetup->plc_damping, h_DecSetup->ltpf_mem_pitch_int, + h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ns_cum_alpha, &h_DecSetup->ns_seed, h_DecSetup->plcAd, + decoder->frame_dms, currentScratch, &h_DecSetup->pc_nbLostFramesInRow +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , h_DecSetup->rel_pitch_change +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + , decoder->alpha_type_2_table +#endif + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef ENABLE_HR_MODE + IF(sub(bfi, 1) == 0) + { + FOR(i = 0; i < decoder->stDec_ola_mem_fx_len; i++) + { + h_DecSetup->stDec_ola_mem_fx[i] = L_deposit_h(plc_ola_mem[i]); + } + } +#endif + +#ifdef WMOPS + BASOP_sub_start("PLC/PC::DampingScrambling"); +#endif + if (h_DecSetup->plcAd) + { + processPLCDampingScrambling_main_fx( + bfi, h_DecSetup->concealMethod, h_DecSetup->nbLostFramesInRow, &h_DecSetup->plcAd->cum_fflcAtten, + h_DecSetup->pc_nbLostFramesInRow, &h_DecSetup->ns_seed, &h_DecSetup->pc_seed, + h_DecSetup->ltpf_mem_pitch_int, ltpf_idx[0], q_d_fx, &q_fx_exp, h_DecSetup->q_old_d_fx, + &h_DecSetup->q_old_fx_exp, decoder->yLen, h_DecSetup->plcAd->stab_fac, decoder->frame_dms, + &h_DecSetup->plcAd->cum_fading_slow, &h_DecSetup->plcAd->cum_fading_fast, spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , h_DecSetup->plcAd->plc_fadeout_type +#endif + ); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Imdct"); +#endif + /* currentScratch Size = 4 * MAX_LEN */ + ProcessingIMDCT(q_d_fx, &q_fx_exp, decoder->W_fx, h_DecSetup->stDec_ola_mem_fx, &h_DecSetup->stDec_ola_mem_fx_exp, +#ifdef ENABLE_HR_MODE + x_fx_ip, +#else + x_fx, +#endif + decoder->W_size, decoder->frame_length, decoder->stDec_ola_mem_fx_len, decoder->frame_dms, + h_DecSetup->concealMethod, bfi, h_DecSetup->prev_bfi, h_DecSetup->nbLostFramesInRow, + h_DecSetup->plcAd, + currentScratch +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif + ); + +#ifdef ENABLE_HR_MODE + IF(sub(bfi, 1) != 0 || sub(h_DecSetup->concealMethod, LC3_CON_TEC_NS_STD) == 0 || sub(h_DecSetup->concealMethod, LC3_CON_TEC_NS_ADV) == 0 || sub(h_DecSetup->concealMethod, LC3_CON_TEC_FREQ_MUTING) == 0) + { + round_w32tow16_arr(x_fx_ip, x_fx, decoder->frame_length); + } + ELSE + { + FOR(i = 0; i < decoder->frame_length; i++) + { + x_fx_ip[i] = L_deposit_h(x_fx[i]); + } + } +#endif /* ENABLE_HR_MODE */ + +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("PLC::Update"); +#endif + + processPLCupdate_fx(h_DecSetup->plcAd, x_fx, q_fx_exp, h_DecSetup->concealMethod, decoder->frame_length, + decoder->fs_idx, &h_DecSetup->nbLostFramesInRow, &h_DecSetup->prev_prev_bfi, + &h_DecSetup->prev_bfi, bfi, scf_q, &h_DecSetup->ns_cum_alpha +#ifdef ENABLE_HR_MODE + , decoder->hrmode +#endif + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("LtpfDec"); +#endif + /* currentScratch Size = 0.5 * MAX_LEN + 20 bytes */ + process_ltpf_decoder_fx(&q_fx_exp, decoder->frame_length, decoder->ltpf_mem_x_len, decoder->fs_idx, + decoder->ltpf_mem_y_len, &h_DecSetup->ltpf_mem_e, x_fx, h_DecSetup->ltpf_mem_x, x_fx, + h_DecSetup->ltpf_mem_y, ltpf_idx[0], ltpf_idx[1], ltpf_idx[2], + &h_DecSetup->ltpf_mem_pitch_int, &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, + &h_DecSetup->ltpf_mem_active, h_DecSetup->ltpf_scale_fac_idx, bfi, + h_DecSetup->concealMethod, + h_DecSetup->plc_damping, &h_DecSetup->ltpf_mem_scale_fac_idx, +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms, +#endif + currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef ENABLE_HR_MODE + IF (!(decoder->hrmode)) + { + FOR (i = 0; i < decoder->frame_length; i++) + { + x_fx_ip[i] = L_deposit_h(x_fx[i]); + } + } +#endif + +#ifdef WMOPS + BASOP_sub_start("Output scaling"); +#endif + { + scale = sub(sub(31 + 16, bits_per_sample), q_fx_exp); + offset = L_shr_sat(32768, sub(16, scale)); + IF (bits_per_sample == 16) + { + scale = sub(15, q_fx_exp); + FOR (i = 0; i < decoder->frame_length; i++) + { +#ifdef ENABLE_HR_MODE + ((Word16 *)s_out)[i] = round_fx_sat(L_shr_sat(x_fx_ip[i], scale)); +#else + ((Word16 *)s_out)[i] = round_fx_sat(L_shr_sat(L_deposit_h(x_fx[i]), scale)); +#endif + move16(); + } + } + ELSE + { + FOR (i = 0; i < decoder->frame_length; i++) + { +#ifdef ENABLE_HR_MODE + ((Word32 *)s_out)[i] = L_shr_sat(L_add_sat(x_fx_ip[i], offset), scale); +#else + ((Word32 *)s_out)[i] = L_shr_sat(L_add_sat(L_deposit_h(x_fx[i]), offset), scale); +#endif + move32(); + } + } + } +#ifdef WMOPS + BASOP_sub_end(); /* Output scaling */ +#endif + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_end(); /* Decoder */ +#endif + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + return bfi; +} + +/* num_bytes = 0 -> bad frame */ +LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, void **output, int bits_per_sample, void *scratch, + int bfi_ext) +{ + int ch = 0, bfi = bfi_ext; + LC3PLUS_Error err = LC3PLUS_OK; + int fec_num_bytes; + int lc3_num_bytes; + int lc3_channel_num_bytes; + int channel_bfi, out_bfi; + Word16 channel_epmr; + + if (bfi == 0) + { + bfi = !num_bytes; + } + + if (decoder->ep_enabled) + { + decoder->combined_channel_coding = decoder->channels > 1 && num_bytes <= 160; + + if (decoder->combined_channel_coding) + { + fec_num_bytes = num_bytes; + +#ifdef WMOPS + BASOP_sub_start("fec_dec"); +#endif + + decoder->error_report = + fec_decoder(input, fec_num_bytes, &lc3_num_bytes, &decoder->epmr, decoder->combined_channel_coding, + &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, + &decoder->m_fec, scratch); + +#ifdef WMOPS + BASOP_sub_end(); +#endif + + for (ch = 0; ch < decoder->channels; ch++) + { + lc3_channel_num_bytes = lc3_num_bytes / decoder->channels + (ch < (lc3_num_bytes % decoder->channels)); + + + if (bfi != 1 && lc3_channel_num_bytes != decoder->channel_setup[ch]->last_size) + { + err = update_dec_bitrate(decoder, ch, lc3_channel_num_bytes); + + if (err) + { + bfi = 1; + } + else + { + decoder->channel_setup[ch]->last_size = lc3_channel_num_bytes; + } + } + + bfi = Dec_LC3PLUS_Channel(decoder, ch, bits_per_sample, input, output[ch], bfi, scratch); + input += decoder->channel_setup[ch]->targetBytes; + } + } + else + { + decoder->epmr = 12; + out_bfi = 0; + + for (ch = 0; ch < decoder->channels; ch++) + { + fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); + +#ifdef WMOPS + BASOP_sub_start("fec_dec"); +#endif + + channel_bfi = bfi; + + decoder->error_report = + fec_decoder(input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, decoder->combined_channel_coding, + &decoder->n_pccw, &channel_bfi, &decoder->be_bp_left, &decoder->be_bp_right, + &decoder->n_pc, &decoder->m_fec, scratch); + +#ifdef WMOPS + BASOP_sub_end(); +#endif + + decoder->epmr = MIN(decoder->epmr, channel_epmr); + + +#ifdef ENABLE_PADDING + if (channel_bfi != 1) + { + Word16 padding_len, np_zero; + + if (paddingDec_fx(input, shl(lc3_num_bytes, 3), decoder->yLen, decoder->BW_cutoff_bits, + decoder->ep_enabled, &padding_len, &np_zero)) + { + channel_bfi = 1; + } + + input = input + np_zero; + decoder->n_pc = s_max(decoder->n_pc - (2 * np_zero), 0); + + if (channel_bfi == 2) + { + if (decoder->be_bp_right < (8 * np_zero)) + { + channel_bfi = 0; + decoder->be_bp_left = -1; + decoder->be_bp_right = -1; + } + else + { + decoder->be_bp_right = decoder->be_bp_right - (8 * np_zero); + decoder->be_bp_left = s_max(decoder->be_bp_left - (8 * np_zero), 0); + } + } + + lc3_num_bytes = lc3_num_bytes - padding_len; + } +#endif + + if (channel_bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) + { + err = update_dec_bitrate(decoder, ch, lc3_num_bytes); + if (err) + { + channel_bfi = 1; + } + else + { + decoder->channel_setup[ch]->last_size = lc3_num_bytes; + } + } + + channel_bfi = Dec_LC3PLUS_Channel(decoder, ch, bits_per_sample, input, output[ch], channel_bfi, scratch); + + out_bfi |= channel_bfi; + input += fec_num_bytes; + } + + bfi = out_bfi & 1; + } + } + else + { + for (ch = 0; ch < decoder->channels; ch++) + { + lc3_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); + +#ifdef ENABLE_PADDING + if (bfi != 1) + { + Word16 padding_len, np_zero; + + if (paddingDec_fx(input, shl(lc3_num_bytes, 3), decoder->yLen, decoder->BW_cutoff_bits, + decoder->ep_enabled, &padding_len, &np_zero)) + { + bfi = 1; + } + + lc3_num_bytes = lc3_num_bytes - padding_len; + if (lc3_num_bytes < 20 || lc3_num_bytes > LC3PLUS_MAX_BYTES) + { + bfi = 1; /* mark frame as broken if frame sizeif below the minimum of 20 bytes */ + } + } +#endif + + if (bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) + { + err = update_dec_bitrate(decoder, ch, lc3_num_bytes); + if (err) + { + bfi = 1; + } + else + { + decoder->channel_setup[ch]->last_size = lc3_num_bytes; + } + } + + bfi = Dec_LC3PLUS_Channel(decoder, ch, bits_per_sample, input, output[ch], bfi, scratch); + input += decoder->channel_setup[ch]->targetBytes; + } + } + + return bfi == 1 ? LC3PLUS_DECODE_ERROR : LC3PLUS_OK; +} diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h new file mode 100644 index 000000000..c9909ddf2 --- /dev/null +++ b/lib_lc3plus/defines.h @@ -0,0 +1,734 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef DEFINES_H +#define DEFINES_H + +#ifndef DISABLE_HR_MODE +# define ENABLE_HR_MODE +#endif + +#ifdef ENABLE_HR_MODE +# define MAX_BW_HR 960 +#endif + +#ifdef ENABLE_HR_MODE +# define extractW16(a) extract_h(a) +#else +# define extractW16(a) (a) +#endif + +#define MAX_BR 320000 /* 400 * 800 */ + +/* FUNCTION MACROS */ +/* NB, divisions in some of these MACROs, use mainly for initial setup, do not use in loops */ +#define CEILING(x, y) (((x) + (y)-1) / (y)) + +#define FRAME2FS_IDX(x) (x / 100) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4 */ +#ifdef ENABLE_HR_MODE +# define FS2FS_IDX(x) ((x) == 96000 ? 5 : (x) / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4, 96000 -> 5 */ +#else +# define FS2FS_IDX(x) (x / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 */ +#endif + +#define UNUSED(x) (void)(x) /* silence unused parameter warning */ +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define STATIC_ASSERTS(cond, s) typedef char assert_##s[(cond) ? 1 : -1] +#define STATIC_ASSERTI(cond, i) STATIC_ASSERTS(cond, i) +#define STATIC_ASSERT(cond) STATIC_ASSERTI(cond, __LINE__) +#define TRACE(x) PRINTF("%s:%i %s = %i\n", __FILE__, __LINE__, #x, (int)(x)) + +/* For dynamic memory calculations */ +#define CODEC_FS(fs) ((fs) == 44100 ? 48000 : (fs)) + +#define DYN_MAX_LEN(fs) (CODEC_FS(fs) / 100) +#define DYN_MAX_LEN_EXT(fs) MAX(CODEC_FS(fs) / 100, 160) /* extension to length 160 for NB(fs=8000) */ +#define DYN_MAX_LPROT(fs) ((512 * (CODEC_FS(fs) / 100)) / 320) + +#define DYN_MAX_PLOCS(fs) (DYN_MAX_LPROT(fs) / 4 + 1) +#define DYN_MAX_MDCT_LEN(fs) (DYN_MAX_LEN(fs) - (180 * DYN_MAX_LEN(fs) / 480)) + +#define MAX_PITCH_FS(fs) (CEILING((MAX_PITCH_12K8 * CODEC_FS(fs)), (12800))) + +/* get the maximum buffer size assuming 10 ms framing */ +/* MAX_PITCH was previously always the highest fs in the current SUBSET , i.e. typically 48 kHz */ +/* now fs(from incoming wav file) adaptive MAX_PITCH_FS(fs) is used instead */ +#define DYN_MAX_LEN_PCM_PLC_CLASSIFIER(fs) \ + (MAX_PITCH_FS(fs) + DYN_MAX_LEN(fs)) /* CLASSIFIER PCM memory requirement */ +#define DYN_MAX_LEN_PCM_PLC_TDCAPPLYFILTER(fs) \ + ((M + 1) + MAX_PITCH_FS(fs) + (DYN_MAX_LEN(fs) / 2)) /* TDC filtering PCM memory requirement */ + +#ifdef ENABLE_HR_MODE +# define DYN_MAX_LEN_PCM_PLC(fs) (MAX_PITCH_FS(fs) + DYN_MAX_LEN(fs)) +#else +# define DYN_MAX_LEN_PCM_PLC(fs) MAX(DYN_MAX_LEN_PCM_PLC_CLASSIFIER(fs), DYN_MAX_LEN_PCM_PLC_TDCAPPLYFILTER(fs)) +#endif + +#define FRAME_MS_BLOCK 25 + +/* OPTIONS */ +#define ENABLE_2_5MS_MODE +#define ENABLE_5MS_MODE +#define ENABLE_075_DMS_MODE +#define ENABLE_10_MS_MODE +#define ENABLE_ADVANCED_PLC +#define ENABLE_ADVANCED_PLC_DEFAULT +#define ENABLE_BW_CONTROLLER +#define ENABLE_ERROR_PROTECTION +#define ENABLE_RFRAME +#define ENABLE_PC +#define ENABLE_PLC +#define ENABLE_PADDING +/* flags */ +#define ENABLE_BANDWIDTH_FLAG +#define ENABLE_RBANDWIDTH_FLAG +#define ENABLE_EP_MODE_FLAG +#define ENABLE_FRAME_MS_FLAG + +#define CR8_A_PLC_FADEOUT_TUNING /* Adapt PLC fadeout to avoid gaps in signal */ +#define CR8_E_TONE_DETECTOR /* Tone detector for hrmode to deactivate TNS - improves SNR and THD+N */ +#define CR8_F_ADAPT_MDCT_DCT_PRECISION +#define CR8_G_ADD_75MS + + +#define CR9_B_FIX_MDCT_OVERFLOW /* Fix overflow */ +#define CR9_C_FIX_DCT2_OVERFLOW /* Fix overflow */ + +#define CR9_F_PITCH_WIN_LEN_FIX /* Increase window length for pitch calculation */ +#define CR9_G_IMPROVE_TDC /* summarize G,H,J,L,N */ +#ifdef CR9_G_IMPROVE_TDC +# define CR9_G_PLC_NS_TDC_FIX /* Always use TDC if pitch > 0 */ +# define CR9_H_REMOVE_SWITCH_TO_PLC_NS +# define CR9_J_SLOW_TDC_FADEOUT +# define CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +# ifdef ENABLE_HR_MODE +# define CR10_A_ATTENUATION_CURVE_SELECTOR +# ifdef CR10_A_ATTENUATION_CURVE_SELECTOR +# define CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH +# endif +# endif +#endif /* CR9_G_IMPROVE_TDC */ +#define CR9_I_INC_TDC_FADEOUT_LEN +#define CR9_K_REDUCE_NORM_CORR_TH +#define CR9_M_FIX_DIV_ZERO + +#ifndef NO_POST_REL_CHANGES +/* Post-release non-bitexact changes */ + +#define CR11_A_FIX_IN_PLC_LONGTERM_STATISTIC + +#endif /* NO_POST_REL_CHANGES Post-release changes */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING +# ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +# ifdef CR9_K_REDUCE_NORM_CORR_TH +# define THRESH_100_DMS_TDC_CNT 9 +# define THRESH_100_DMS_NS_CNT 7 +# define THRESH_100_DMS_TDC_NS_CNT 73 +# define THRESH_075_DMS_TDC_CNT 7 +# define THRESH_075_DMS_NS_CNT 7 +# define THRESH_075_DMS_TDC_NS_CNT 87 +# define THRESH_050_DMS_TDC_CNT 22 +# define THRESH_050_DMS_NS_CNT 15 +# define THRESH_050_DMS_TDC_NS_CNT 141 +# define THRESH_025_DMS_TDC_CNT 20 +# define THRESH_025_DMS_NS_CNT 21 +# define THRESH_025_DMS_TDC_NS_CNT 278 +# else +# define THRESH_100_DMS_TDC_CNT 3 +# define THRESH_100_DMS_NS_CNT 35 +# define THRESH_100_DMS_TDC_NS_CNT 114 +# define THRESH_075_DMS_TDC_CNT 6 +# define THRESH_075_DMS_NS_CNT 37 +# define THRESH_075_DMS_TDC_NS_CNT 130 +# define THRESH_050_DMS_TDC_CNT 12 +# define THRESH_050_DMS_NS_CNT 55 +# define THRESH_050_DMS_TDC_NS_CNT 227 +# define THRESH_025_DMS_TDC_CNT 10 +# define THRESH_025_DMS_NS_CNT 138 +# define THRESH_025_DMS_TDC_NS_CNT 431 +# endif +# else +# define FAC1_FADEOUT 6710886 /* 0.2 * 2^25 */ +# define SHIFT1_FADEOUT 25-15 /* 25 - 16 */ +# define FAC2_FADEOUT 50331648 /* 1.5 * 2^25 */ +# define SHIFT2_FADEOUT 25-15 /* 25 - 16 */ +# define FAC3_FADEOUT 58720256 /* 1.75 * 2^25 */ +# define SHIFT3_FADEOUT 25-15 /* 25 - 16 */ +# endif +# define PLC_LONGTERM_ANALYSIS_MS 200 /* Nominal analysis window 2000 ms */ +# define PLC_LONGTERM_ANALYSIS_STARTUP_FILL (Word16)(0.5*32768.0) /* 16384/32768 == 0.5 required buffer fill amount, set to 0.0 to not require any fill at all */ +#endif /* CR8_A_PLC_FADEOUT_TUNING */ + +#define REL_PITCH_THRESH 11796 + +# define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ +# ifdef SUBSET_NB +# define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ +# endif +# ifdef SUBSET_WB +# define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ +# endif +# ifdef SUBSET_SSWB +# define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ +# endif + +/* G192 bitstream writing/reading */ +#define G192_GOOD_FRAME 0x6B21 +#define G192_BAD_FRAME 0x6B20 +#define G192_REDUNDANCY_FRAME 0x6B22 +#define G192_ZERO 0x007F +#define G192_ONE 0x0081 +#define READ_G192FER /* allow C executable to also read G192 formatted FER files */ + +#ifdef DEBUG +#ifdef READ_G192FER +# define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ +#endif +#endif + + +// #define DYNMEM_COUNT +#define STAMEM_COUNT + + +/* +do not change __forceinline for mex compilation using gcc6.3.0 or larger + gcc630 supported by MATLAB 2018b, via Mingw "app" + */ +#ifdef __GNUC__ +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#else +# define GCC_VERSION 0 +#endif + +/* Define __forceinline as empty if ARM not activated to avoid any errors */ +#undef __forceinline +/* The above undef is needed to compile using make_mex.m without the following warning in Matlab for windows */ +#define __forceinline + +/* SUBSETS */ +#if !(defined(SUBSET_NB) || defined(SUBSET_WB) || defined(SUBSET_SSWB) || defined(SUBSET_SWB) || defined(SUBSET_FB) || defined(SUBSET_UB)) +# define SUBSET_NB +# define SUBSET_WB +# define SUBSET_SSWB +# define SUBSET_SWB +# define SUBSET_FB +# ifdef ENABLE_HR_MODE +# define SUBSET_UB +# endif +#endif + +# define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ +# define MIN_BR_025DMS 64000 /* 20 * 800 * 100/ 25 */ +# define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ +# define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ +# ifdef SUBSET_NB +# define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ +# endif +# ifdef SUBSET_WB +# define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ +# endif +# ifdef SUBSET_SSWB +# define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ +# endif + +#ifdef CR8_G_ADD_75MS +# define MIN_BR_075DMS_48KHZ_HR ((int)124800/ 800/2)* 800 +# define MIN_BR_075DMS_96KHZ_HR ((int)149600/ 800/2)* 800 +# define MIN_BR_075DMS 21334 /* ceil( 20 * 800 * 100/ 75) */ +# define MAX_BR_075DMS 426667 /* ceil(400 * 800 * 100/ 75) */ +# define MAX_BR_075DMS_NB 152534 /* ceil(143 * 800 * 100/ 75) */ +# define MAX_BR_075DMS_WB 295467 /* ceil(277 * 800 * 100/ 75) */ +# define MAX_BR_075DMS_SSWB 419200 /* ceil(393 * 800 * 100/ 75) */ + +# define NOISEFILLWIDTH_7_5MS 2 +# define NOISEFILLSTART_7_5MS 18 +#endif + +#define PACK_RESBITS + +/* FRAME/BUFFER */ +#ifdef SUBSET_UB +# define MAX_LEN 960 /* = 10ms at 96kHz */ +#elif defined SUBSET_FB +# define MAX_LEN 480 /* = 10ms at 48kHz */ +#elif defined(SUBSET_SWB) +# define MAX_LEN 320 /* = 10ms at 32kHz */ +#elif defined(SUBSET_SSWB) +# define MAX_LEN 240 /* = 10ms at 24kHz */ +#elif defined(SUBSET_WB) +# define MAX_LEN 160 /* = 10ms at 16kHz */ +#elif defined(SUBSET_NB) +# define MAX_LEN 80 /* = 10ms at 8kHz */ +#endif + +#ifdef ENABLE_HR_MODE +# define ENABLE_FFT_RESCALE +# define ENABLE_FFT_30X16 +# define ENABLE_DCTIV_RESCALE + +# define EXT_RES_ITER_MAX 20 +# define MAX_RESBITS 5000 +# define HR_MODE_SCRATCH_SIZE 60 +#else /* ENABLE_HR_MODE */ +# define MAX_RESBITS MAX_LEN +#endif /* ENABLE_HR_MODE */ + +/* BW Cutoff-Detection */ +#define MAX_BW_BANDS_NUMBER 5 + +#ifdef ENABLE_HR_MODE +# define RESBITS_PACK_SHIFT 3 +# define RESBITS_PACK_N (1<<(RESBITS_PACK_SHIFT)) +# define RESBITS_PACK_MASK (RESBITS_PACK_N - 1) +# define MAX_RESBITS_LEN ((MAX_RESBITS + RESBITS_PACK_MASK) >> RESBITS_PACK_SHIFT) +# define MAX_RESBITS_LEN_32BIT_ALIGN (((MAX_RESBITS_LEN + 3)/4)*4) +#else /* ENABLE_HR_MODE */ +# define MAX_RESBITS_LEN (MAX_RESBITS) +# define MAX_RESBITS_LEN_32BIT_ALIGN (((MAX_RESBITS_LEN + 3)/4)*4) +#endif /* ENABLE_HR_MODE */ + +#define MAX_CHANNELS 2 +#define MIN_NBYTES 20 /* 100dms: 16 kbps at !=44.1kHz, 14.7kbps at 44.1kHz + 50dms: 32 kbps at !=44.1kHz, 29.4kbps at 44.1kHz + 25dms: 64 kbps at !=44.1kHz, 58.8kbps at 44.1kHz */ +#define MAX_NBYTES_025 100 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_050 200 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_075 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_100 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#ifdef ENABLE_HR_MODE +# define MIN_BR_25MS_48KHZ_HR ((int)172800/3200/2)*3200 +# define MIN_BR_25MS_96KHZ_HR ((int)198400/3200/2)*3200 +# define MIN_BR_50MS_48KHZ_HR ((int)148800/1600/2)*1600 +# define MIN_BR_50MS_96KHZ_HR ((int)174400/1600/2)*1600 +# define MIN_BR_100MS_48KHZ_HR ((int)124800/800/2)*800 +# define MIN_BR_100MS_96KHZ_HR ((int)149600/800/2)*800 +# define MAX_NBYTES_RED_HR 625 /* From table 5.2 */ +# define BYTESBUFSIZE (MAX_NBYTES_RED_HR * LC3PLUS_MAX_CHANNELS) +#else +# define BYTESBUFSIZE (MAX_NBYTES_100 * LC3PLUS_MAX_CHANNELS) +#endif +#define MAX_BW_BIN 400 +#define FEC_SLOT_BYTES_MIN 40 +# define FEC_SLOT_BYTES_MAX 400 +#if MAX_BW_BIN > MAX_LEN +# define MAX_BW MAX_LEN +#else +# define MAX_BW MAX_BW_BIN +#endif + +#define NUM_OFFSETS 7 +#define NUM_SAMP_FREQ 6 + +/* SCF */ +#define M 16 /* LPC_ORDER */ +#define MAX_BANDS_NUMBER 64 +#define MAX_BANDS_NUMBER_PLC 80 +#define PVQ_MAX_VEC_SIZE M +#define KMAX_FX 10 /* N=10 */ +#define K_OUTL_FAR 6 +#define MPVQ_SZ_OUTL_FAR (1549824U >> 1) +#define TOTBITS_SHAPE OUTL_FAR(1.0 + 19.5637) +#define SQRT_EN_MAX_FX 64 /* table size, for fast inv_sqrt */ +#define N_SETA 10 +#define N_SETB (PVQ_MAX_VEC_SIZE - N_SETA) + +#define SNS_DAMPING 27853 /* 0.85 in Q15 */ +#ifdef ENABLE_HR_MODE +# define SNS_DAMPING_HRMODE 19661 /* 0.6 in Q15 */ +# define SNS_DAMPING_HRMODE_UB_10MS 6881 /* 0.21 in Q15 */ +# define SNS_DAMPING_HRMODE_UB_7_5MS 5898 /* 0.18 in Q15 */ +# define SNS_DAMPING_HRMODE_UB_5MS 4915 /* 0.15 in Q15 */ +# define SNS_DAMPING_HRMODE_UB_2_5MS 4915 /* 0.15 in Q15 */ +#endif + +/* PVQ VQ setup */ +#define VQMODES26 \ + ((0 << 4) + (1 << 3) + (1 << 2) + (1 << 1) + \ + (1 << 0)) /* select all shapes, including extended lf, and new far \ + shape for MODE26, add extreme far mode not enabled */ +#define SCF_STAGE1_MAX_BITS (5 + 5) /* typically only (5+5) used */ +#define SCF_STAGE1_NBCDKENTRIES 32 +#define SCF_STAGE2_MAX_GAIN_BITS 2 +#define SCF_STAGE2_NB_MODE_BITS 1 +#define SCF_STAGE2_MAX_NB_SHAPES 3 +#define SCF_MAX_PARAM 7 /* (L+H) + submode_MSB +gain+(Ia_leads+Ia_mpvq)+(Ib_joint_mpvq), submode-LSB */ +#define SCF_MAX_PARAM_ST2 (SCF_MAX_PARAM - 2) +#define N_SCF_SHAPES_ST2 4 +#define N_SCF_SHAPE_SETUPS 1 + +/* ARITHMETIC ENCODER */ +#define NBITS_CONTEXT 8 +#define NBITS_RATEQ 2 +#define A_THRES_SHIFT 2 +#define A_THRES (1 << A_THRES_SHIFT) +#define VAL_ESC 16 +#define SYM_BITS_Q 11 + +/* RESIDUAL CODING */ +#define NPRM_RESQ MAX_LEN + +/* NOISE FILLING */ +#define NOISEFILLWIDTH 3 +#define NOISEFILLSTART 24 +#define NOISEFILLWIDTH_5MS 1 +#define NOISEFILLSTART_5MS 12 +#define NOISEFILLWIDTH_2_5MS 1 +#define NOISEFILLSTART_2_5MS 6 + +/* MDCT */ +#ifdef ENABLE_HR_MODE +# define TWIDDLE ((Word32)0x5a82799a) +#else +# define TWIDDLE WORD322WORD16(0x5a82799a) +#endif +#define MDCT_MEM_LEN_MAX (MAX_LEN - ((180 * MAX_LEN) / 480)) + +/* TNS */ +#define TNS_NUMFILTERS_MAX 2 +#define TNS_COEF_RES 17 +#define INDEX_SHIFT 8 +#define NSUBDIV 3 +#define MAXLAG 8 + +/* OLPA/LTPF */ +#define LEN_12K8 128 +#define LEN_6K4 64 +#define MIN_PITCH_6K4 17 +#define MAX_PITCH_6K4 114 +#define RANGE_PITCH_6K4 98 +#define MIN_PITCH_12K8 32 +#define MAX_PITCH_12K8 228 +#define RES2_PITCH_12K8 157 +#define RES4_PITCH_12K8 127 +#define LTPF_MEMIN_LEN (MAX_PITCH_12K8 + 4) +#define M_LTPF 24 +#define LTPF_MEM_X_LEN (MAX_LEN + MAX_LEN / 40 - 2) +#define LTPF_MEM_Y_LEN (MAX_LEN + CEILING(MAX_PITCH_12K8 * MAX_LEN, 128) + (MAX_LEN / 80)) + +/* PLC */ +#ifdef CR9_I_INC_TDC_FADEOUT_LEN +# define PLC_FADEOUT_TYPE_1_IN_MS 200 +#endif +#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ + +# ifdef CR8_A_PLC_FADEOUT_TUNING + /* table settings */ +# define PLC2_FADEOUT_IN_MS_MIN 30 /* table min */ +# define PLC2_FADEOUT_IN_MS_MAX 140 /* table max */ +# define PLC2_FADEOUT_RES 10 /* 10 ms steps used in fade tables */ + +/* current settings */ +# define PLC2_FADEOUT_LONG_IN_MS 120 +# define PLC2_FADEOUT_IN_MS 30 /* 0 uses original constants for PLC2 + -1 uses TDC::PLC_FADEOUT_IN_MS as basis for a PLC2 macro-re-calculation + 30..140 will use a separate settings for PLC2 fadeout + 30: P800 short fade optimization + 120: Mushra optimized fade */ +#else +# define PLC2_FADEOUT_IN_MS 30 /* 0 uses original fixed values for PLC2 + -1 uses PLC_FADEOUT_IN_MS as basis for a PLC2 macro-re-calculation + 30..100 uses separate setting for PLC2 */ +#endif + + + +#define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ +#define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ +#define PLC34_ATTEN_FAC_100_FX 0x4000 /* attenuation factor for NS and TDC @ 10 ms (0.5000)*/ +#define PLC34_ATTEN_FAC_050_FX 0x5A83 /* attenuation factor for NS and TDC @ 5.0 ms (0.7071)*/ +#define PLC34_ATTEN_FAC_025_FX 0x6BA3 /* attenuation factor for NS and TDC @ 2.5 ms (0.8409)*/ +#ifdef CR8_G_ADD_75MS +#define PLC34_ATTEN_FAC_075_FX 0x4C1C /* attenuation factor for NS and TDC @ 7.5 ms (0.5946) */ +#endif +#define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ + +#define MAX_PITCH_8K (CEILING((MAX_PITCH_12K8 * 8000), (12800))) /*NB was a risky MACRO at 0.5 border !!, */ +#define MAX_PITCH_16K ((MAX_PITCH_12K8 * 16000) / (12800)) /* exact integer */ +#define MAX_PITCH_24K \ + (CEILING((MAX_PITCH_12K8 * 24000), (12800))) /* was a risky MACRO truncation at 0.5 border !! , */ +#define MAX_PITCH_32K ((MAX_PITCH_12K8 * 32000) / (12800)) /* exact integer */ +#define MAX_PITCH_48K ((MAX_PITCH_12K8 * 48000) / (12800)) /* exact integer */ + +#ifdef ENABLE_HR_MODE +# define MAX_PITCH_96K ((MAX_PITCH_12K8 * 96000) / (12800)) /* exact integer */ +#endif + +#ifdef ENABLE_HR_MODE +# define MAX_PITCH MAX_PITCH_96K +#elif defined(SUBSET_FB) +# define MAX_PITCH MAX_PITCH_48K +#elif defined(SUBSET_SWB) +# define MAX_PITCH MAX_PITCH_32K +#elif defined(SUBSET_SSWB) +# define MAX_PITCH MAX_PITCH_24K +#elif defined(SUBSET_WB) +# define MAX_PITCH MAX_PITCH_16K +#elif defined(SUBSET_NB) +# define MAX_PITCH MAX_PITCH_8K +#endif + + +/* macri MAX_LEN_PCM_PLC is used for WC memory size checking + DYN_MAX_LEN_PCM_PLC(fs) is used by static memory buffers + */ +#define MAX_LEN_PCM_PLC (MAX_PITCH + MAX_LEN) + +#define TDC_L_FIR_HP 11 +#define TDC_L_FIR_LP 11 + +#define BASE_LPROT 512 /* BASE Lprot set to 512 for 32 kHz sampling */ + +#define LPROT48K (BASE_LPROT * 48 / 32) /* Fs based Lprot */ +#define LPROT40K (BASE_LPROT * 40 / 32) /* For Fs == 48000 only use 0 - 20000 Hz in 8 bands */ +#define LPROT32K BASE_LPROT +#define LPROT24K (BASE_LPROT * 24 / 32) +#define LPROT16K (BASE_LPROT * 16 / 32) +#define LPROT8K (BASE_LPROT * 8 / 32) + +/* #define PHECU_XFP_LA 1 */ /* Original soluiton xfp generated with 1ms look ahead into MDCT memory + ctrl.PhECU.LA = 0.001 * ctrl.fs; */ +/* #define PHECU_XFP_LA 4 */ /* Option with some lookahead 1/4 ms look ahead into MDCT memory + ctrl.PhECU.LA = 0.001 * ctrl.fs / 4; */ +#define PHECU_XFP_LA \ + 0 /* Option without lookahead 0 ms look ahead into MDCT memory \ + ctrl.PhECU.LA = 0; */ + +#if (PHECU_XFP_LA == 0) + +# define PHECU_LA_48K 0 /* 0 ms */ +# define PHECU_LA_32K 0 /* 0 ms */ +# define PHECU_LA_24K 0 /* 0 ms */ +# define PHECU_LA_16K 0 /* 0 ms */ +# define PHECU_LA_8K 0 /* 0 ms */ + +# define MAX_PHECU_LA (0) + +#else +# if (PHECU_XFP_LA == 4) + +# define PHECU_LA_48K (48 / 4) /* 0.25 ms */ +# define PHECU_LA_32K (32 / 4) /* 0.25 ms */ +# define PHECU_LA_24K (24 / 4) /* 0.25 ms */ +# define PHECU_LA_16K (16 / 4) /* 0.25 ms */ +# define PHECU_LA_8K (8 / 4) /* 0.25 ms */ + +# define MAX_PHECU_LA (MAX_LEN / 10 / 4) + +# else + +# define PHECU_LA_48K 48 /* 1 ms */ +# define PHECU_LA_32K 32 /* 1 ms */ +# define PHECU_LA_24K 24 /* 1 ms */ +# define PHECU_LA_16K 16 /* 1 ms */ +# define PHECU_LA_8K 8 /* 1 ms */ + +# define MAX_PHECU_LA (MAX_LEN / 10) + +# endif +#endif + + +/* (PHECU_LA_48K == 0) */ + +#define COPY_LEN_8K 16 +#define COPY_LEN_16K 32 +#define COPY_LEN_24K 48 +#define COPY_LEN_32K 64 +#define COPY_LEN_48K 96 + +#define OLA_LEN_8K 14 +#define OLA_LEN_16K 28 +#define OLA_LEN_24K 42 +#define OLA_LEN_32K 56 +#define OLA_LEN_48K 84 + +#define LPROT48K_RED LPROT40K /* limit peak searched part of spectrum for FB */ +#define LPROT32K_RED LPROT32K /* limit peak searched part of spectrum for SWB */ +#define LPROT24K_RED LPROT24K /* limit peak searched part of spectrum for HQ */ +#define LPROT16K_RED LPROT16K /* limit peak searched part of spectrum for SQ */ +#define LPROT8K_RED LPROT8K /* limit peak searched part of spectrum for NB */ + +#define INV_LPROT48K_Q22 5461 /* round(2^22/LPROT48K) , 1/6 */ +#define INV_LPROT32K_Q22 8192 /* round(2^22/LPROT32K) , 1/4 */ +#define INV_LPROT24K_Q22 10923 /* round(2^22/LPROT24K) , 1/3 */ +#define INV_LPROT16K_Q22 16384 /* round(2^22/LPROT16K) , 1/2 */ +#define INV_LPROT8K_Q22 32767 /* round(2^22/LPROT8K) , 1/1 */ + +#define LGW48K 8 /* 8 bands defined , but may the same frequency groups as for SWB(32k) */ +#define LGW32K 7 +#define LGW24K 6 +#define LGW16K 5 +#define LGW8K 4 + +#define MAX_LGW 9 /* LGW48K + 1 !! */ + +#define UNINIT_OR_UNSAFE_OOLD_SENTINEL -32768 +#define LTOT_INIT_FLAG -32768 +#define LTOT_MIN_MAN 1 /* lowest possible energy value */ +#define LTOT_MIN_EXP -61 /* L_tot= LTOT_MIN_MAN*2^(LTOT_MIN_EXP-31) */ +#define GRP_SHAPE_INIT 0 /* Q15 */ + +#define TRANA_TIME 4 /* Transient analysis length in ms */ +#define LTRANA48K (48000 * TRANA_TIME / 1000) +#define LTRANA32K (32000 * TRANA_TIME / 1000) +#define LTRANA24K (24000 * TRANA_TIME / 1000) +#define LTRANA16K (16000 * TRANA_TIME / 1000) +#define LTRANA8K (8000 * TRANA_TIME / 1000) + +#define MAX_PLOCS ((MAX_LPROT / 4) + 1) /* maximum number of spectral peaks to be searched */ +#define QUOT_LPR_LTR 4 + +#define BETA_MUTE_FAC_INI 16384 /* Q15, initial noise attenuation factor */ + +#define OFF_FRAMES_LIMIT 30 /* Hard limit to a maximum of 300ms of burst decay frames */ + +#define Lprot_hamm_len2_48k (3 * 48) +#define Lprot_hamm_len2_32k (3 * 32) +#define Lprot_hamm_len2_24k (3 * 24) +#define Lprot_hamm_len2_16k (3 * 16) +#define Lprot_hamm_len2_8k (3 * 8) + +#define FRAME_TIME 10 /* Frame length in ms */ + +#define L_FRAME48K (48000 * FRAME_TIME / 1000) +#define L_FRAME32K (32000 * FRAME_TIME / 1000) +#define L_FRAME24K (24000 * FRAME_TIME / 1000) +#define L_FRAME16K (16000 * FRAME_TIME / 1000) +#define L_FRAME8K (8000 * FRAME_TIME / 1000) + +#ifdef DISABLE_PLC +# define MAX_LTRANA 0 +# define MAX_LPROT LPROT48K +# define MAX_L_FRAME L_FRAME48K +# define MAX_LPROT_RED LPROT48K_RED +#else + +# ifdef SUBSET_UB +# define MAX_LPROT LPROT48K /* Max length of protype frame for buffer allocation */ +# define MAX_LPROT_RED LPROT48K_RED /* stack alloc peak searched part */ +# define MAX_LTRANA LTRANA48K +# define MAX_L_FRAME L_FRAME48K +# elif defined(SUBSET_FB) +# define MAX_LPROT LPROT48K /* Max length of protype frame for buffer allocation */ +# define MAX_LPROT_RED LPROT48K_RED /* stack alloc peak searched part */ +# define MAX_LTRANA LTRANA48K +# define MAX_L_FRAME L_FRAME48K +# elif defined(SUBSET_SWB) +# define MAX_LPROT LPROT32K +# define MAX_LPROT_RED LPROT32K_RED /* stack alloc peak searched part */ +# define MAX_LTRANA LTRANA32K +# define MAX_L_FRAME L_FRAME32K +# elif defined(SUBSET_SSWB) +# define MAX_LPROT LPROT24K +# define MAX_LPROT_RED LPROT24K_RED /* stack alloc peak searched part */ +# define MAX_LTRANA LTRANA24K +# define MAX_L_FRAME L_FRAME24K +# elif defined(SUBSET_WB) +# define MAX_LPROT LPROT16K +# define MAX_LPROT_RED LPROT16K_RED /* stack alloc peak searched part */ +# define MAX_LTRANA LTRANA16K +# define MAX_L_FRAME L_FRAME16K +# elif defined(SUBSET_NB) +# define MAX_LPROT LPROT8K +# define MAX_LPROT_RED LPROT8K_RED /* stack alloc peak searched part */ +# define MAX_LTRANA LTRANA8K +# define MAX_L_FRAME L_FRAME8K +# endif + +#endif /* #ifdef DISABLE_PLC */ + +#define INV_L_FRAME48K_Q15 32768 / L_FRAME48K +#define INV_L_FRAME32K_Q15 32768 / L_FRAME32K +#define INV_L_FRAME24K_Q15 32768 / L_FRAME24K +#define INV_L_FRAME16K_Q15 32768 / L_FRAME16K +#define INV_L_FRAME8K_Q15 32768 / L_FRAME8K + +#define MDCT_MEM_LEN_48 (L_FRAME48K - ((180 * L_FRAME48K) / 480)) + +#define R1_48 690 +#define R2_48 420 +#define R1_16 230 +#define R2_16 140 +#define R1_25 368 +#define R2_25 224 + +#define MAX_LEN_PCM_PLC_TOT (MAX_LEN_PCM_PLC) /* TDC_pcm_buff */ +#define MAX_WIN_PRE_TDA (0) /* not in RAM any longer , now stored in ROM only as PhECU_wins[fs_idx][1] */ + +#define MAX_PLCMETH 1 + +/* Scratch buffer defines */ +#define scratchBuffer_ACTIVE +#ifdef ENABLE_HR_MODE +# define SCRATCH_BUF_LEN_ENC (4 * MAX_LEN + 32 + 32 + 4 * MAX_LEN + 3 * MAX_LEN + MAX_RESBITS_LEN_32BIT_ALIGN) +# define SCRATCH_BUF_LEN_ENC_CURRENT_SCRATCH (4 * MAX_LEN + 8 * 60 + MAX_LEN) +#else +# define SCRATCH_BUF_LEN_ENC (4 * MAX_LEN + 32 + 32 + 2 * MAX_LEN + 3 * MAX_LEN + MAX_RESBITS_LEN_32BIT_ALIGN) +# define SCRATCH_BUF_LEN_ENC_CURRENT_SCRATCH (4 * MAX_LEN) +#endif + +#define SCRATCH_BUF_LEN_ENC_TOT (SCRATCH_BUF_LEN_ENC + SCRATCH_BUF_LEN_ENC_CURRENT_SCRATCH) + +#ifdef ENABLE_HR_MODE +# define SCRATCH_BUF_LEN_DEC (4 * MAX_LEN + MAX_RESBITS_LEN_32BIT_ALIGN + 32 + 32 + 4 * MAX_LEN + 32 + 128 + 128) +#else +# define SCRATCH_BUF_LEN_DEC (4 * MAX_LEN + 2 * MAX_LEN + 32 + 32 + 2 * MAX_LEN + 32 + 128 + 128) +#endif +#define SCRATCH_BUF_LEN_DEC_CURRENT_SCRATCH (2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME) +#ifdef ENABLE_HR_MODE +# define SCRATCH_BUF_LEN_DEC_TOT (SCRATCH_BUF_LEN_DEC + (4 * HR_MODE_SCRATCH_SIZE) + SCRATCH_BUF_LEN_DEC_CURRENT_SCRATCH) +#else +# define SCRATCH_BUF_LEN_DEC_TOT (SCRATCH_BUF_LEN_DEC + SCRATCH_BUF_LEN_DEC_CURRENT_SCRATCH) +#endif + +#define ADVACED_PLC_SIZE \ + (sizeof(AplcSetup) + (4 + 2) * MAX_PLOCS + 2 * MAX_LEN_PCM_PLC_TOT + 0 * MAX_LPROT + 2 * MDCT_MEM_LEN_MAX + \ + 2 * MAX_WIN_PRE_TDA) +/* ERI : Correct this sum after ROM/RAM , joint RAM optimizations */ + + +#define ENC_MAX_SIZE (sizeof(LC3PLUS_Enc) + MAX_CHANNELS * (sizeof(EncSetup) + 6 * MDCT_MEM_LEN_MAX)) +#define DEC_MAX_SIZE \ + (sizeof(LC3PLUS_Dec) + MAX_CHANNELS * (sizeof(DecSetup) + ADVACED_PLC_SIZE + 2 * LTPF_MEM_X_LEN + 2 * LTPF_MEM_Y_LEN + \ + 2 * MDCT_MEM_LEN_MAX + 2 * MAX_BW)) + +#if (defined(_M_ARM) || defined(__CC_ARM) || defined(__TMS470__) || defined(__arm__) || defined(__aarch64__)) && \ + (defined(__TARGET_FEATURE_NEON) || defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__ARM_AARCH64_NEON__)) +# define ALIGNMENT_DEFAULT 16 +#elif defined(__bfin__) +# define ALIGNMENT_DEFAULT 4 +#else +# define ALIGNMENT_DEFAULT 8 +#endif + +/* RAM_ALIGN keyword causes memory alignment of global variables. */ +#if defined(__GNUC__) +# define RAM_ALIGN __attribute__((aligned(ALIGNMENT_DEFAULT))) +#elif defined(__CC_ARM) +# define RAM_ALIGN __align(ALIGNMENT_DEFAULT) +#elif defined(__ANALOG_EXTENSIONS__) +# define RAM_ALIGN +# pragma pack(ALIGNMENT_DEFAULT) +#elif defined(_MSC_VER) +# define RAM_ALIGN __declspec(align(ALIGNMENT_DEFAULT)) +#else +# define RAM_ALIGN +#endif + +#define scratchAlign(ptr, offset) (void *)(((uintptr_t)(ptr) + (offset) + 0x3) & ~0x3) +#define ALIGN_BUFFER_STRUCT + + +/* some configurations leave empty translation units. */ +extern int fix_empty_translation_unit_warning; + +#endif diff --git a/lib_lc3plus/detect_cutoff_warped_fx.c b/lib_lc3plus/detect_cutoff_warped_fx.c new file mode 100644 index 000000000..b6ef25472 --- /dev/null +++ b/lib_lc3plus/detect_cutoff_warped_fx.c @@ -0,0 +1,124 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include "rom_basop_util.h" + +void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 frame_dms) +{ + + Dyn_Mem_Deluxe_In( + Counter iBand; + Word32 d2_fx_sum; + Word32 d2_fx_mean; + Word32 delta_energy; + Word16 d2_fx_sum_exp; + Word16 d2_fx_mean_exp; + Word16 nrg_below_thresh; + Word16 counter; + Word16 brickwall; + Word16 stop; + Word16 brickwall_dist; + const Word16 *warp_idx_start, *warp_idx_stop, *bw_brickwall_dist; + ); + + SWITCH (frame_dms) + { + case 25: + warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; move16(); + warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; move16(); + bw_brickwall_dist = BW_brickwall_dist_2_5ms; + BREAK; + case 50: + warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; move16(); + warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; move16(); + bw_brickwall_dist = BW_brickwall_dist_5ms; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; move16(); + warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; move16(); + bw_brickwall_dist = BW_brickwall_dist_7_5ms; + BREAK; +#endif + default: /* 100 */ + warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; move16(); + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; move16(); + bw_brickwall_dist = BW_brickwall_dist; + BREAK; + } + + counter = fs_idx; + DO + { + + /* counter is 0...num_idxs-1 */ + counter = sub(counter, 1); + + /* always code the lowest band (NB), skip check against threshold if counter == -1 */ + IF (counter < 0) + { + BREAK; + } + + d2_fx_mean = 0; move32(); + d2_fx_mean_exp = 0; move16(); + + iBand = warp_idx_start[counter]; move16(); + d2_fx_sum = d2_fx[iBand]; move32(); + d2_fx_sum_exp = d2_fx_exp; move16(); + + iBand++; + FOR (; iBand <= warp_idx_stop[counter]; iBand++) + { + d2_fx_sum = BASOP_Util_Add_Mant32Exp_lc3plus(d2_fx[iBand], d2_fx_exp, d2_fx_sum, d2_fx_sum_exp, &d2_fx_sum_exp); + } + /* Energy-sum */ + d2_fx_mean = Mpy_32_16_lc3plus(d2_fx_sum, InvIntTable[add(sub(warp_idx_stop[counter], warp_idx_start[counter]), 1)]); + d2_fx_mean_exp = d2_fx_sum_exp; move16(); + + /* check if above threshold */ + nrg_below_thresh = BASOP_Util_Cmp_Mant32Exp_lc3plus(BW_thresh_quiet[counter], BW_thresh_quiet_exp, d2_fx_mean, + d2_fx_mean_exp); /* true if firstNumber > secondNumber */ + } + WHILE (nrg_below_thresh > 0) + ; + + *bw_idx = add(1, counter); move16(); + + /* addtional check for brickwall characteristic */ + IF (sub(fs_idx, *bw_idx) > 0) + { + brickwall = 0; move16(); + stop = add(warp_idx_start[counter + 1], 1); + brickwall_dist = bw_brickwall_dist[counter + 1]; + + FOR (iBand = stop; iBand >= sub(stop, brickwall_dist); iBand--) + { + /* Band(x) > Band(x-3)*Thr */ + delta_energy = + L_sub(Mpy_32_16_lc3plus(d2_fx[iBand - brickwall_dist], BW_thresh_brickwall[counter + 1]), d2_fx[iBand]); + if (delta_energy > 0) + { + brickwall = 1; move16(); + } + IF (brickwall) + { + BREAK; + } + } + if (brickwall == 0) + { + *bw_idx = fs_idx; + } + } + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/dynmem.c b/lib_lc3plus/dynmem.c new file mode 100644 index 000000000..65e157d0a --- /dev/null +++ b/lib_lc3plus/dynmem.c @@ -0,0 +1,288 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* + Tool for dynamic memory estimation + Anisse Taleb, November 2003 + +*/ + +/* turn off stdlib function warnings in visual studio */ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include +#include +#include +#include +#include + +#include "dynmem.h" + +#define MAX_FUNC_NAME_LENGTH 128 + + + +struct C_Path{ + char func_name[MAX_FUNC_NAME_LENGTH]; + long mem_usage; + long mem_usage_acc; + struct C_Path *next; + struct C_Path *parent; +}; + + +typedef struct C_Path C_Path; + +static C_Path *Max_Mem_path; /* Snap shot of the maximum memory usage path */ +static C_Path *Head_path; +static C_Path *Curr_path; /* Current code path */ + + +static long Max_mem_usage; + +static C_Path *Static_mem_head; +static C_Path *Static_mem_curr; + +/* + * initialisation. Must be called at start, sets up all the + * structures and resets counters. + * + * Called externally. + */ + +static void path_free(C_Path * path) +{ + C_Path *path_end,*tmp; + path_end = path; + + if(path == NULL) return; + /* find last node */ + while(path_end->next != NULL) path_end = path_end->next; + + /* walk back */ + while(path_end != NULL) { + tmp = path_end; + path_end = path_end->parent; + free(tmp); + } + +} +static void path_save(void) +{ + C_Path * node; + C_Path * node_save; + C_Path * previous; + /* free the old path */ + path_free(Max_Mem_path); + Max_Mem_path = NULL; + /* */ + + Max_Mem_path = (C_Path *) malloc(sizeof(C_Path)); + + node = Head_path; + node_save = Max_Mem_path; + previous = NULL; + while(node != NULL){ + + strcpy(node_save->func_name,node->func_name); + node_save->mem_usage = node->mem_usage; + node_save->mem_usage_acc = node->mem_usage_acc; + + node_save->parent = previous; + node_save->next = NULL; + + if(node->next != NULL) { + node_save->next = (C_Path *) malloc(sizeof(C_Path)); + } + node = node->next; + previous = node_save; + node_save = node_save->next; + } while(node != NULL); + +} + +void P_Dyn_Mem_Init(void) +{ + + /* initialize the path */ + Head_path = (C_Path *) malloc(sizeof(C_Path)); + strcpy(Head_path->func_name,"---Top---"); + Head_path->mem_usage = 0; + Head_path->mem_usage_acc = 0; /*memory usage accumulator */ + Head_path->parent = NULL; + Head_path->next = NULL; + + Curr_path = Head_path; + /* Initilaize the memory consumptions */ + Max_mem_usage = 0; + Max_Mem_path = NULL; +} + +void P_Dyn_Mem_In(const char *func_name, + long mem_usage) +{ +#ifdef DEBUG_DYNMEM + printf( "Entering: %s\n", func_name ); +#endif + + /* Enter a new function, push on the stack */ + if(Curr_path->next != NULL) { + fprintf(stderr,"\n Something went wrong !!"); + exit(0); + + } + Curr_path->next = (C_Path*) malloc (sizeof(C_Path)); + + if(Curr_path->next == NULL) { + fprintf(stderr,"\n Can't allocate memory"); + exit(0); + } + + Curr_path->next->parent = Curr_path; + Curr_path = Curr_path->next; + Curr_path->next = NULL; + /* save function name */ + strcpy(Curr_path->func_name,func_name); + /* save memory usage */ + Curr_path->mem_usage = mem_usage; + /* update memory usage accumulator */ + Curr_path->mem_usage_acc = Curr_path->parent->mem_usage_acc + mem_usage; +} + +/* Add memory size to current function */ +void P_Dyn_Mem_Add(long mem_usage) +{ +#ifdef DEBUG_DYNMEM + printf( "Staying in: %s\n", Curr_path->func_name); +#endif + + /* Staying in the current function, nothing to push */ + + /* save memory usage */ + Curr_path->mem_usage = Curr_path->mem_usage + mem_usage; + /* update memory usage accumulator */ + Curr_path->mem_usage_acc = Curr_path->mem_usage_acc + mem_usage; +} + + +/* before any return */ + +void P_Dyn_Mem_Out(void) +{ + C_Path *tmp; + if(Curr_path->mem_usage_acc > Max_mem_usage) { + /* set new memory usage record */ + Max_mem_usage = Curr_path->mem_usage_acc; + /* save snap shot */ + path_save(); + } + +#ifdef DEBUG_DYNMEM + printf( "Exiting: %s\n", Curr_path->func_name ); +#endif + + /* delete last node */ + tmp = Curr_path; + + Curr_path = Curr_path->parent; + Curr_path->next = NULL; + free(tmp); +} + + +/* Write data and exit */ + +void P_Dyn_Mem_Exit(void) +{ + /*FILE *f_mem_statistics;*/ + C_Path *node; + /*f_mem_statistics = fopen("mem_stat.txt","wt"); + fprintf(f_mem_statistics,"\n Maximum dynamic memory usage = %ld b, %ld kW \n Critical Memory Usage Path", Max_mem_usage, Max_mem_usage/(1000*2));*/ + /* fprintf(stderr,"\n Maximum dynamic memory usage = %ld kWords (%ld bytes)\n Critical Memory Usage Path", Max_mem_usage/(1000*2),Max_mem_usage); */ + fprintf(stderr,"\n Maximum dynamic memory usage = %.2f kWords (%ld bytes)\n Critical Memory Usage Path", (ceil((float)Max_mem_usage/20.f)/100.f), Max_mem_usage); + + node = Max_Mem_path; + while (node != NULL) { + /*fprintf(f_mem_statistics,"\n %-30s %10ld bytes (+ %10ld bytes)",node->func_name, node->mem_usage_acc, node->mem_usage);*/ + fprintf(stderr,"\n %-30s %10ld bytes (+ %10ld bytes)",node->func_name, node->mem_usage_acc, node->mem_usage); + node=node->next; + } + + /*fclose(f_mem_statistics);*/ + fprintf(stderr,"\n"); + +#ifdef CTEST_MEASUREMENTS + printf("%.3f\n", "dynMem [kWords]", "numeric/float", Max_mem_usage/(1000.0*2)); +#endif + + path_free(Max_Mem_path); + path_free(Head_path); +} + +void P_Dyn_Mem_Exit_noprint(void) +{ + path_free(Max_Mem_path); + path_free(Head_path); +} +void P_Sta_Mem_Init(void) +{ + /* initialize the head object */ + Static_mem_head = (C_Path *) malloc(sizeof(C_Path)); + strcpy(Static_mem_head->func_name,"---Top---"); + Static_mem_head->mem_usage = 0; + Static_mem_head->mem_usage_acc = 0; + Static_mem_head->parent = NULL; + Static_mem_head->next = NULL; + Static_mem_curr = Static_mem_head; +} + +void P_Sta_Mem_Add(const char *func_name, + long mem_usage) +{ + /* Enter a new function, push on the stack */ + Static_mem_curr->next = (C_Path*) malloc (sizeof(C_Path)); + Static_mem_curr->next->parent = Static_mem_curr; + Static_mem_curr = Static_mem_curr->next; + Static_mem_curr->next = NULL; + /* save function name */ + strcpy(Static_mem_curr->func_name,func_name); + /* save memory usage */ + Static_mem_curr->mem_usage = mem_usage; + /* update memory usage accumulator */ + Static_mem_curr->mem_usage_acc = Static_mem_curr->parent->mem_usage_acc + mem_usage; +} + +void P_Sta_Mem_Exit(void) +{ + C_Path *node; + /* fprintf(stderr,"\n Static memory usage = %ld kWords (%ld bytes)\n Detailed Memory Usage", Static_mem_curr->mem_usage_acc/(1000*2),Static_mem_curr->mem_usage_acc); */ + fprintf(stderr,"\n Static memory usage = %.2f kWords (%ld bytes)\n Detailed Memory Usage", (ceil((float)Static_mem_curr->mem_usage_acc/20.f)/100.f),Static_mem_curr->mem_usage_acc); + + node = Static_mem_head->next; + while (node != NULL) { + fprintf(stderr,"\n %-30s %10ld bytes (+ %10ld bytes)",node->func_name, node->mem_usage_acc, node->mem_usage); + node=node->next; + } + + fprintf(stderr,"\n"); + +#ifdef CTEST_MEASUREMENTS + printf("%.3f\n", "statMem [kWords]", "numeric/float", Static_mem_curr->mem_usage_acc/(1000.0*2)); +#endif + + path_free(Static_mem_head); +} + +void P_Sta_Mem_Exit_noprint(void) +{ + path_free(Static_mem_head); +} diff --git a/lib_lc3plus/dynmem.h b/lib_lc3plus/dynmem.h new file mode 100644 index 000000000..e81169a33 --- /dev/null +++ b/lib_lc3plus/dynmem.h @@ -0,0 +1,80 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef DYNMEM_H +#define DYNMEM_H + +#ifdef _MSC_VER +/* This disables warnings about anonymous temporary struct declarations */ +#pragma warning(disable:4115) +#pragma warning(disable:4116) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +void P_Dyn_Mem_Init(void); +void P_Dyn_Mem_In(const char *func_name, + long mem_usage); +void P_Dyn_Mem_Add(long mem_usage); +void P_Dyn_Mem_Out(void); +void P_Dyn_Mem_Exit(void); +void P_Dyn_Mem_Exit_noprint(void); + +void P_Sta_Mem_Init(void); +void P_Sta_Mem_Add(const char *func_name, + long mem_usage); +void P_Sta_Mem_Exit(void); +void P_Sta_Mem_Exit_noprint(void); + +#ifdef DONT_COUNT_MEM + +#define Dyn_Mem_Init() +#define Dyn_Mem_Exit() +#define Dyn_Mem_Exit_noprint() +#define Dyn_Mem_In(a,b) +#define Dyn_Mem_Add(b) +#define Dyn_Mem_Out() + +#define DYN_MEM_IN Dyn_Mem_In +#define DYN_MEM_ADD Dyn_Mem_Add +#define DYN_MEM_OUT Dyn_Mem_Out + +#define Sta_Mem_Init() +#define Sta_Mem_Exit() +#define Sta_Mem_Exit_noprint() +#define Sta_Mem_Add(a,b) + +#else /* DONT_COUNT_MEM */ + +#define Dyn_Mem_Init P_Dyn_Mem_Init +#define Dyn_Mem_Exit P_Dyn_Mem_Exit +#define Dyn_Mem_Exit_noprint P_Dyn_Mem_Exit_noprint +#define Dyn_Mem_In P_Dyn_Mem_In +#define Dyn_Mem_Add P_Dyn_Mem_Add +#define Dyn_Mem_Out P_Dyn_Mem_Out + +#define DYN_MEM_IN P_Dyn_Mem_In +#define DYN_MEM_ADD P_Dyn_Mem_Add +#define DYN_MEM_OUT P_Dyn_Mem_Out + +#define Sta_Mem_Init P_Sta_Mem_Init +#define Sta_Mem_Exit P_Sta_Mem_Exit +#define Sta_Mem_Exit_noprint P_Sta_Mem_Exit_noprint +#define Sta_Mem_Add P_Sta_Mem_Add + +#endif /* DONT_COUNT_MEM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib_lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c new file mode 100644 index 000000000..35dd8d950 --- /dev/null +++ b/lib_lc3plus/enc_entropy.c @@ -0,0 +1,173 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static Word32 ac_enc_mux_st2VQ_cws( /* o: max 25 bits total codeword */ + const Word32 L_szA, /* i: max 22 bits */ + const Word32 L_szB, /* i: max 4 bits */ + const Word32 L_cwA, const Word32 L_cwB); + +void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 targetBytes, + Word16 L_spec, Word16 BW_cutoff_bits, Word16 tns_numfilters, + Word16 lsbMode, Word16 lastnz, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, + Word16 BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, Word16 bfi_ext, Word16 fs_idx) +{ + Word16 tmp; + Word32 L_tmp; + Word16 submode_LSB, submode_MSB, gain_MSBs; + Word32 L_gain_LSB; + Counter n; + UWord8 *ptr; + + Word16 lastnzTrigger[5] = {63, 127, 127, 255, 255}; + +#ifdef DYNMEM_COUNT + struct _dynmem + { + Word16 tmp; + Word32 L_tmp; + Word16 submode_LSB, submode_MSB, gain_MSBs; + Word32 L_gain_LSB; + Counter n; + UWord8 *ptr; + Word16 lastnzTrigger[5]; + }; + Dyn_Mem_In("processEncoderEntropy", sizeof(struct _dynmem)); +#endif + + /* Init */ + *bp_side = shr_pos(sub(nbbits, 1), 3); + *mask_side = shl(1, sub(8, sub(nbbits, shl_pos(*bp_side, 3)))); + ptr = bytes; + + basop_memset(bytes, 0, targetBytes * sizeof(*bytes)); + + /* Cutoff-detection */ + IF (BW_cutoff_bits > 0) + { + write_indice_backward(ptr, bp_side, mask_side, BW_cutoff_idx, BW_cutoff_bits); + } + + /* Encode last non-zero tuple */ + tmp = sub(14, norm_s(negate(L_spec))); + + IF (sub(bfi_ext, 1) == 0) + { + write_indice_backward(ptr, bp_side, mask_side, lastnzTrigger[fs_idx], tmp); + } + ELSE + { + write_indice_backward(ptr, bp_side, mask_side, sub(shr_pos(lastnz, 1), 1), tmp); + } + + /* Mode bit */ + write_bit_backward(ptr, bp_side, mask_side, lsbMode); + + /* Encode global-gain */ + write_indice_backward(ptr, bp_side, mask_side, gg_idx, 8); + + /* TNS on/off flag */ + FOR (n = 0; n < tns_numfilters; n++) + { + write_bit_backward(ptr, bp_side, mask_side, s_min(tns_order[n], 1)); + } + + /* LTPF on/off*/ + write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[0], 1); + + /* Encode SCF VQ parameters - 1st stage (10 bits) */ + write_indice_backward(ptr, bp_side, mask_side, extract_l(L_scf_idx[0]), 5); /* stage1 LF 5 bits */ + write_indice_backward(ptr, bp_side, mask_side, extract_l(L_scf_idx[1]), 5); /* stage1 HF 5 bits */ + + /* Encode SCF VQ parameters - 2nd stage side-info (3-4 bits) */ + submode_MSB = shr_pos(extract_l(L_scf_idx[2]), 1); /* explicit tx */ + write_bit_backward(ptr, bp_side, mask_side, submode_MSB); /* submode MSB 1 explicit bit */ + submode_LSB = s_and(extract_l(L_scf_idx[2]), 0x1); /* for joint coding with shapeCw */ + gain_MSBs = extract_l(L_scf_idx[3]); /* all gain bits */ + L_gain_LSB = L_and(L_scf_idx[3], 0x1L); + gain_MSBs = shr(gain_MSBs, sns_gainLSBbits[L_scf_idx[2]]); + + ASSERT(gain_MSBs >= 0 && gain_MSBs < (1 << sns_gainMSBbits[L_scf_idx[2]])); /* ASSERT max 2 MSB(s) in gain bits */ + + write_indice_backward(ptr, bp_side, mask_side, gain_MSBs, + sns_gainMSBbits[L_scf_idx[2]]); /* adjgain or MSBs of adjGains 1-2 bits */ + write_bit_backward(ptr, bp_side, mask_side, extract_l(L_scf_idx[4])); /* shape LS 1 bit */ + + /* Encode SCF VQ parameters - 2nd stage data (24-25 bits) */ + IF (submode_MSB == 0) + { /* regular,regular_lf*/ + ASSERT(submode_MSB == 0); + + L_tmp = L_add(L_gain_LSB, 0); /* gain-LSB 0,1 for regular_lf, offset is 0 */ + if (submode_LSB == 0) + { + L_tmp = L_add(L_scf_idx[6], + sns_MPVQ_Sz[1][1]); /* shape B pos offset is 2 , upshifted two positions , 0..11 -> 2..13 */ + } + /* regular mode A,B indexes multiplexed, total 24.x bits MPVQ codeword section A + codeword for section B */ + L_tmp = ac_enc_mux_st2VQ_cws(sns_MPVQ_Sz[0][0], /* max 21.3 bits*/ + UL_addNsD(sns_MPVQ_Sz[0][1], sns_MPVQ_Sz[1][1]), /* max log2(14) bits */ + L_scf_idx[5] /* shapeA */, L_tmp /* shapeB joint with adjGainLSB */); + /* regular mode mode shape index total 1+23.9999 bits MPVQ codeword */ + ASSERT(L_tmp < (1L << 25)); + write_indice_backward(ptr, bp_side, mask_side, extract_l(L_tmp), 13); /* multiplex 13 bits */ + write_indice_backward(ptr, bp_side, mask_side, extract_l(L_shr_pos(L_tmp, 13)), 12); /* multiplex 12 bits */ + } + ELSE + { /* outlier near, outlier far */ + ASSERT(submode_MSB == 1); + L_tmp = L_scf_idx[5]; move32(); /* outlier near section assumed */ + if (submode_LSB != 0) + { /* outl_far */ + L_tmp = L_add(L_shl_pos(L_tmp, 1), L_gain_LSB); /* add lsb bit of Gain */ + L_tmp = L_add(L_tmp, sns_MPVQ_Sz[2][0]); /* outlier far section offset added */ + } + + ASSERT(L_tmp < (1L << 24)); + /* outlier mode shape index total 23.8536 ( + ~.14 ) bits as MPVQ codeword */ + write_indice_backward(ptr, bp_side, mask_side, extract_l(L_tmp), 12); /* multiplex 12 bits LSB*/ + write_indice_backward(ptr, bp_side, mask_side, extract_l(L_shr(L_tmp, 12)), 12); /* multiplex 12 bits MSBs */ + } + + /* LTPF data */ + IF (ltpf_idx[0] != 0) + { + write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[1], 1); + write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[2], 9); + } + + /* Encoder noise-fac */ + write_indice_backward(ptr, bp_side, mask_side, fac_ns_idx, 3); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +static __forceinline Word32 +ac_enc_mux_st2VQ_cws( /* o: max 25 bits total codeword */ + const Word32 L_szA, /* i: max 22 bits */ + const Word32 L_szB, /* i: max 4 bits 0..13 */ + const Word32 L_cwA, + const Word32 L_cwB) /* [0..13} corresponding to gains{0,1}, shapeB{0..11} or */ +{ + + Word32 L_cwTx; + /* L_cw_tx = L_cwB(21.z bits) * L_szA(3.y bits) + L_cwA(21.x bits)); */ + L_cwTx = (Word32)UL_Mpy_32_32( + (UWord32)L_cwB, (UWord32)L_szA); /* non-fractional 16x32 -> 32 may possibly also be used if available */ + L_cwTx = L_add(L_cwTx, L_cwA); + + ASSERT((L_szA * L_szB) <= 1 << 25); /* multiplexing only allowed up to 25 bits (+ leading sign) */ + ASSERT(L_cwTx >= 0 && L_cwTx <= 0x01ffFFff); /* max 25 bits allowed */ + UNUSED(L_szB); + + return L_cwTx; +} diff --git a/lib_lc3plus/enc_lc3.c b/lib_lc3plus/enc_lc3.c new file mode 100644 index 000000000..30ff9971b --- /dev/null +++ b/lib_lc3plus/enc_lc3.c @@ -0,0 +1,680 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include // ToDo: probably to be removed + +static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_sample, Word32 *s_in, UWord8 *bytes, + Word8 *scratchBuffer, int bfi_ext) +{ +#ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In(Word16 d_fx_exp; + Word16 gain_e, gain, quantizedGain, quantizedGainMin; + Word16 ener_fx_exp; + Word16 pitch, normcorr; + Word16 ltpf_bits; + Word16 tns_numfilters; + Word16 lsbMode, lastnz, BW_cutoff_idx; + Word16 gainChange, fac_ns_idx; + Word16 nBits, numResBits; + Word16 bp_side, mask_side; + Word16 s_12k8_len; + Word16 b_left; + Word32 * L_scf_idx; + Word32 * d_fx, *ener_fx; + Word16 * s_12k8, *int_scf_fx_exp, tns_order[TNS_NUMFILTERS_MAX], *indexes; + Word32 * q_d_fx24; + Word16 * scf; + Word16 * codingdata; + Word32 * scf_q, *int_scf_fx; + Word32 * s_in_scaled; + Word16 * s_in_scaled_lp; + UWord8 * resBits; + Word16 ltpf_idx[3]; + EncSetup * h_EncSetup; + Word8 * currentScratch; + Word16 hrmode; + ); +#else + Dyn_Mem_Deluxe_In(Word16 d_fx_exp; Word16 gain_e, gain, quantizedGain, quantizedGainMin; Word16 ener_fx_exp; + Word16 pitch, normcorr; Word16 ltpf_bits; Word16 tns_numfilters; + Word16 lsbMode, lastnz, BW_cutoff_idx; Word16 gainChange, fac_ns_idx; Word16 nBits, numResBits; + Word16 bp_side, mask_side; Word16 s_12k8_len; Word16 b_left; + + Word32 * L_scf_idx; Word32 * d_fx, *ener_fx; + Word16 * s_12k8, *int_scf_fx_exp, *q_d_fx16, *int_scf_fx, tns_order[TNS_NUMFILTERS_MAX], *indexes; + Word16 * scf, *scf_q; Word16 * codingdata; Word16 * s_in_scaled; UWord8 * resBits; + Word8 * currentScratch; Word16 ltpf_idx[3]; EncSetup * h_EncSetup;); +#endif /* ENABLE_HR_MODE */ + + h_EncSetup = encoder->channel_setup[channel]; + +#ifdef ENABLE_HR_MODE +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + hrmode = encoder->hrmode; +# endif +#endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + +#ifdef WMOPS + BASOP_sub_start("Encoder"); +#endif + + /* BUFFER INITIALISATION. Some buffers may overlap since they are not used in the whole encoding process */ + d_fx = scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LEN bytes */ + L_scf_idx = scratchAlign( + d_fx, sizeof(*d_fx) * s_max(80, encoder->frame_length)); /* Size = 4 * SCF_MAX_PARAM -> aligned to 32 bytes */ + indexes = scratchAlign(L_scf_idx, + sizeof(*L_scf_idx) * SCF_MAX_PARAM); /* Size = 2 * TNS_NUMFILTERS_MAX * MAXLAG = 32 bytes */ + +#ifdef ENABLE_HR_MODE + q_d_fx24 = scratchAlign(indexes, sizeof(*indexes) * (TNS_NUMFILTERS_MAX * MAXLAG)); +#else + q_d_fx16 = scratchAlign(indexes, sizeof(*indexes) * (TNS_NUMFILTERS_MAX * MAXLAG)); /* Size = 2 * MAX_LEN bytes */ +#endif /* ENABLE_HR_MODE */ + +#ifdef ENABLE_HR_MODE + codingdata = + scratchAlign(q_d_fx24, sizeof(*q_d_fx24) * s_max(80, encoder->frame_length)); /* Size = 3 * MAX_LEN bytes */ +#else + codingdata = + scratchAlign(q_d_fx16, sizeof(*q_d_fx16) * s_max(80, encoder->frame_length)); /* Size = 3 * MAX_LEN bytes */ +#endif + +#ifdef ENABLE_HR_MODE + ener_fx = scratchAlign(q_d_fx24, 0); /* Size = 4 * MAX_BANDS_NUMBER = 256 bytes */ + s_in_scaled = scratchAlign(q_d_fx24, 0); /* Size = 2 * MAX_LEN bytes */ +#else + ener_fx = scratchAlign(q_d_fx16, 0); /* Size = 4 * MAX_BANDS_NUMBER = 256 bytes */ + s_in_scaled = scratchAlign(q_d_fx16, 0); /* Size = 2 * MAX_LEN bytes */ +#endif + +#ifdef ENABLE_HR_MODE + s_in_scaled_lp = (Word16 *)s_in_scaled; +#endif + +#ifdef ENABLE_HR_MODE + /* allocate memory for residual bits */ + if (encoder->hrmode) + { + resBits = scratchAlign(codingdata, sizeof(*codingdata) * (3 * s_max(80, encoder->frame_length) / 2)); + } + else +#endif /* #ifdef ENABLE_HR_MODE */ + { + resBits = scratchAlign(codingdata, + sizeof(*codingdata) * (3 * s_max(80, encoder->frame_length) / 2)); /* Size = MAX_LEN bytes */ + } + + { +#ifdef ENABLE_HR_MODE + currentScratch = + scratchAlign(resBits, sizeof(*resBits) * MAX_RESBITS_LEN); /* Size = 4 * MAX_LEN */ +#else + currentScratch = + scratchAlign(resBits, sizeof(*resBits) * s_max(80, encoder->frame_length)); /* Size = 4 * MAX_LEN */ +#endif /* #ifdef ENABLE_HR_MODE */ + } + + s_12k8 = scratchAlign( + s_in_scaled, + sizeof(*s_in_scaled) * + s_max(80, encoder->frame_length)); /* Size = 2 * (LEN_12K8 + 1) = 258 bytes -> aligned to 288 bytes */ + scf_q = scratchAlign(ener_fx, sizeof(*ener_fx) * MAX_BANDS_NUMBER); /* Size = 2 * M */ + scf = scratchAlign(scf_q, sizeof(*scf_q) * M); /* Size = 2 * M */ + int_scf_fx = scratchAlign(scf, sizeof(*scf) * M); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ + int_scf_fx_exp = + scratchAlign(int_scf_fx, sizeof(*int_scf_fx) * MAX_BANDS_NUMBER); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ + + /* Scale 24-bit input data */ + IF (sub(bits_per_sample, 24) == 0) + { +#ifdef WMOPS + BASOP_sub_start("Scale_signal24"); +#endif + scale_signal24_fx(s_in, s_in_scaled, &h_EncSetup->x_exp, h_EncSetup->stEnc_mdct_mem, + encoder->stEnc_mdct_mem_len, h_EncSetup->r12k8_mem_in, encoder->r12k8_mem_in_len, + h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, encoder->r12k8_mem_out_len, + h_EncSetup->mdct_mem32, encoder->frame_length, h_EncSetup->resamp_mem32, + h_EncSetup->olpa_mem_s12k8, &h_EncSetup->resamp_exp); +#ifdef WMOPS + BASOP_sub_end(); +#endif + } + ELSE + { +#ifdef ENABLE_HR_MODE + Word16 *ip_buf = (Word16*)s_in; + Word32 i; + FOR(i = 0; i < encoder->frame_length; i++) + { + s_in_scaled[i] = L_deposit_h(ip_buf[i]); + } + h_EncSetup->x_exp = 15; move16(); +#else + memcpy(s_in_scaled, s_in, encoder->frame_length * sizeof(*s_in_scaled)); +#endif + } + +#ifdef WMOPS + BASOP_sub_start("Mdct"); +#endif + + /* currentScratch Size = 4 * MAX_LEN */ + processMdct_fx(s_in_scaled, h_EncSetup->x_exp, encoder->frame_length, +#ifdef ENABLE_HR_MODE +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + hrmode, +# endif +#endif + encoder->W_fx, encoder->W_size, + h_EncSetup->stEnc_mdct_mem, encoder->stEnc_mdct_mem_len, d_fx, &d_fx_exp, currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + + /* begin s_12k8 */ +#ifdef WMOPS + BASOP_sub_start("Resamp12k8"); +#endif + /* currentScratch Size = 2.25 * MAX_LEN bytes */ +#ifdef ENABLE_HR_MODE + downshift_w32_arr(s_in_scaled, s_in_scaled_lp, 16, encoder->frame_length); /* s_in_scaled is no longer required */ + + process_resamp12k8_fx(s_in_scaled_lp, encoder->frame_length, h_EncSetup->r12k8_mem_in, encoder->r12k8_mem_in_len, + h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, encoder->r12k8_mem_out_len, s_12k8, + &s_12k8_len, encoder->fs_idx, encoder->frame_dms, currentScratch + , bits_per_sample + ); +#else + process_resamp12k8_fx(s_in_scaled, encoder->frame_length, h_EncSetup->r12k8_mem_in, encoder->r12k8_mem_in_len, + h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, encoder->r12k8_mem_out_len, s_12k8, + &s_12k8_len, encoder->fs_idx, encoder->frame_dms, currentScratch + , bits_per_sample + ); +#endif /* ENABLE_HR_MODE */ +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Olpa"); +#endif + /* currentScratch Size = 392 bytes */ + process_olpa_fx(&h_EncSetup->olpa_mem_s6k4_exp, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, &pitch, + s_12k8, s_12k8_len, &normcorr, &h_EncSetup->olpa_mem_pitch, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + &h_EncSetup->pitch_flag, +#endif + h_EncSetup->resamp_exp, encoder->frame_dms, currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("LtpfEnc"); +#endif + /* currentScratch Size = 512 bytes */ + process_ltpf_coder_fx(<pf_bits, pitch, h_EncSetup->ltpf_enable, &h_EncSetup->ltpf_mem_in_exp, + h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, ltpf_idx, s_12k8, s_12k8_len, + &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_mem_normcorr, normcorr, + &h_EncSetup->ltpf_mem_ltpf_on, &h_EncSetup->ltpf_mem_pitch, h_EncSetup->resamp_exp, + encoder->frame_dms, currentScratch +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,encoder->hrmode +#endif +); +#ifdef WMOPS + BASOP_sub_end(); +#endif + + /* end s_12k8 */ +#ifdef WMOPS + BASOP_sub_start("AttackDetector"); +#endif + /* currentScratch Size = ??? bytes */ +#ifdef ENABLE_HR_MODE + attack_detector_fx(encoder, h_EncSetup, s_in_scaled_lp, sub(h_EncSetup->x_exp, 15), currentScratch); +#else + attack_detector_fx(encoder, h_EncSetup, s_in_scaled, sub(h_EncSetup->x_exp, 15), currentScratch); +#endif +#ifdef WMOPS + BASOP_sub_end(); +#endif + + /* begin ener_fx */ +#ifdef WMOPS + BASOP_sub_start("PerBandEnergy"); +#endif + /* currentScratch Size = 160 bytes */ + processPerBandEnergy_fx(ener_fx, &ener_fx_exp, d_fx, d_fx_exp, encoder->bands_offset, encoder->fs_idx, + encoder->bands_number, 0, encoder->frame_dms, currentScratch +#ifdef ENABLE_HR_MODE + , encoder->hrmode +#endif + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Near Nyquist Detector"); +#endif + /* Near Nyquist Detector */ + processNearNyquistdetector_fx(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, + encoder->bands_number, ener_fx, ener_fx_exp +#ifdef CR8_E_TONE_DETECTOR +#ifdef ENABLE_HR_MODE + , encoder->frame_dms, encoder->hrmode ); +#else + ); +#endif +#else + ); +#endif + /* Disable LTPF if nyquist detector triggers */ + IF (encoder->near_nyquist_flag != 0 || sub(h_EncSetup->lfe, 1) == 0) + { + h_EncSetup->ltpf_mem_ltpf_on = 0; move16(); + ltpf_idx[1] = 0; move16(); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif +#ifdef WMOPS + BASOP_sub_start("BW Cutoff-Detection"); +#endif + IF (h_EncSetup->lfe == 0) + { +#ifdef ENABLE_HR_MODE + /* No BW Cutoff for 8 kHz and 96 kHz */ + IF (encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0) + { +#else /* ENABLE_HR_MODE */ + IF (encoder->fs_idx > 0 && encoder->bw_ctrl_active == 0) + { +#endif /* ENABLE_HR_MODE */ + processDetectCutoffWarped_fx(&BW_cutoff_idx, ener_fx, ener_fx_exp, encoder->fs_idx, encoder->frame_dms); + } + ELSE + { + BW_cutoff_idx = encoder->fs_idx; + move16(); + } + } + ELSE + { + BW_cutoff_idx = 0; + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("SnsCompScf"); +#endif + + + /* currentScratch Size = 512 bytes */ + processSnsComputeScf_fx(ener_fx, ener_fx_exp, encoder->fs_idx, encoder->bands_number, scf, + h_EncSetup->attdec_detected, encoder->attdec_damping, currentScratch, encoder->sns_damping + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("SnsQuantScfEnc"); +#endif + /* currentScratch Size = 500 bytes */ + + processSnsQuantizeScfEncoder_fx(scf, L_scf_idx, scf_q, currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("SnsInterpScfEnc"); +#endif + /* currentScratch Size = 128 bytes */ + processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 1, encoder->bands_number, currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Mdct shaping_enc"); +#endif + processMdctShaping_fx(d_fx, int_scf_fx, int_scf_fx_exp, encoder->bands_offset, encoder->bands_number); + +#ifdef WMOPS + BASOP_sub_end(); +#endif + /* end int_scf_fx_exp */ +#ifdef WMOPS + BASOP_sub_start("BandwidthControl_enc"); +#endif + if (encoder->bandwidth < L_shr_pos(encoder->fs, 1)) + { + process_cutoff_bandwidth(d_fx, encoder->yLen, encoder->bw_ctrl_cutoff_bin); + BW_cutoff_idx = s_min(BW_cutoff_idx, encoder->bw_index); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif +#ifdef WMOPS + BASOP_sub_start("Tns_enc"); +#endif + /* currentScratch Size = 2 * MAX_LEN + 220 */ + + IF (h_EncSetup->lfe == 0) + { + processTnsCoder_fx(&(h_EncSetup->tns_bits), indexes, d_fx, BW_cutoff_idx, tns_order, &tns_numfilters, + h_EncSetup->enable_lpc_weighting, encoder->nSubdivisions, encoder->frame_dms, + encoder->frame_length, currentScratch +#ifdef ENABLE_HR_MODE + , encoder->hrmode +#endif + , encoder->near_nyquist_flag + ); + } + ELSE + { + tns_numfilters = 1; + move16(); + tns_order[0] = 0; + move16(); + h_EncSetup->tns_bits = tns_numfilters; + move16(); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Est. Global Gain"); +#endif + /* currentScratch Size = 4 * MAX_LEN bytes */ + h_EncSetup->targetBitsQuant = sub(h_EncSetup->targetBitsInit, add(h_EncSetup->tns_bits, ltpf_bits)); + + test(); + IF (h_EncSetup->targetBitsQuant < 0 && sub(ltpf_bits, 1) > 0) + { + /* Disable LTPF */ + h_EncSetup->ltpf_mem_ltpf_on = 0; move16(); + ltpf_idx[1] = 0; move16(); + ltpf_bits = 1; move16(); + h_EncSetup->targetBitsQuant = sub(h_EncSetup->targetBitsInit, add(h_EncSetup->tns_bits, ltpf_bits)); + } + +#ifdef ENABLE_HR_MODE + Word32 gain32; +#endif + + processEstimateGlobalGain_fx(d_fx, d_fx_exp, encoder->yLen, h_EncSetup->targetBitsQuant, +#ifdef ENABLE_HR_MODE + &gain32, +#else + &gain, +#endif + &gain_e, + &quantizedGain, &quantizedGainMin, h_EncSetup->quantizedGainOff, + &h_EncSetup->targetBitsOff, &h_EncSetup->mem_targetBits, h_EncSetup->mem_specBits, + currentScratch +#ifdef ENABLE_HR_MODE + , encoder->hrmode, h_EncSetup->regBits, encoder->frame_dms +#endif + ); +#ifdef WMOPS + BASOP_sub_end(); +#endif + /* begin q_d_fx16 */ + +#ifdef WMOPS + BASOP_sub_start("Quant. 1"); +#endif +#ifdef ENABLE_HR_MODE + processQuantizeSpec_fx(d_fx, d_fx_exp, gain32, gain_e, q_d_fx24, encoder->yLen, h_EncSetup->targetBitsQuant, + h_EncSetup->targetBitsAri, &h_EncSetup->mem_specBits, &nBits, encoder->fs_idx, &lastnz, + codingdata, &lsbMode, -1, encoder->hrmode); + +#else + processQuantizeSpec_fx(d_fx, d_fx_exp, gain, gain_e, q_d_fx16, encoder->yLen, h_EncSetup->targetBitsQuant, + h_EncSetup->targetBitsAri, &h_EncSetup->mem_specBits, &nBits, encoder->fs_idx, &lastnz, + codingdata, &lsbMode, -1); +#endif /* ENABLE_HR_MODE */ +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Adj. Global Gain"); +#endif +#ifdef ENABLE_HR_MODE + //gain32 = L_shl_pos((Word32)gain, 16); + processAdjustGlobalGain_fx(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain32, &gain_e, + h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx + , encoder->hrmode, encoder->frame_dms + ); + gain = round_fx(gain32); +#else + processAdjustGlobalGain_fx(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, &gain_e, + h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx); +#endif /* ENABLE_HR_MODE */ +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Quant. 2"); +#endif + IF (sub(gainChange, 1) == 0) + { +#ifdef ENABLE_HR_MODE + processQuantizeSpec_fx(d_fx, d_fx_exp, gain32, gain_e, q_d_fx24, encoder->yLen, h_EncSetup->targetBitsQuant, + h_EncSetup->targetBitsAri, NULL, &nBits, encoder->fs_idx, &lastnz, codingdata, &lsbMode, + 0, encoder->hrmode); +#else + processQuantizeSpec_fx(d_fx, d_fx_exp, gain, gain_e, q_d_fx16, encoder->yLen, h_EncSetup->targetBitsQuant, + h_EncSetup->targetBitsAri, NULL, &nBits, encoder->fs_idx, &lastnz, codingdata, &lsbMode, + 0); +#endif /* ENABLE_HR_MODE */ + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Res. Cod."); +#endif + IF (lsbMode == 0) + { + processResidualCoding_fx(d_fx_exp, d_fx, +#ifdef ENABLE_HR_MODE + q_d_fx24, +#else + q_d_fx16, +#endif +#ifdef ENABLE_HR_MODE + gain32, +#else + gain, +#endif + gain_e, encoder->yLen, h_EncSetup->targetBitsQuant, nBits, resBits, &numResBits +#ifdef ENABLE_HR_MODE + , encoder->hrmode +#endif + ); + } + ELSE + { + numResBits = 0; + move16(); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Noise fac"); +#endif + /* currentScratch Size = 2 * MAX_LEN bytes */ + IF (h_EncSetup->lfe == 0) + { + processNoiseFactor_fx(&fac_ns_idx, d_fx_exp, d_fx, +#ifdef ENABLE_HR_MODE + q_d_fx24, +#else + q_d_fx16, +#endif + gain, gain_e, BW_cutoff_idx, encoder->frame_dms, h_EncSetup->targetBytes, currentScratch +#ifdef ENABLE_HR_MODE + , encoder->hrmode +#endif + ); + } + ELSE + { + fac_ns_idx = 7; + move16(); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Entropy cod"); +#endif + processEncoderEntropy(bytes, &bp_side, &mask_side, h_EncSetup->targetBitsAri, h_EncSetup->targetBytes, + encoder->yLen, encoder->BW_cutoff_bits, tns_numfilters, lsbMode, lastnz, tns_order, + fac_ns_idx, quantizedGain, BW_cutoff_idx, ltpf_idx, L_scf_idx, bfi_ext, encoder->fs_idx); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Ari cod"); +#endif + processAriEncoder_fx(bytes, bp_side, mask_side, h_EncSetup->targetBitsAri, +#ifdef ENABLE_HR_MODE + q_d_fx24, +#else + q_d_fx16, +#endif + tns_order, tns_numfilters, indexes, lastnz, codingdata, resBits, numResBits, lsbMode, + h_EncSetup->enable_lpc_weighting, currentScratch); +#ifdef WMOPS + BASOP_sub_end(); +#endif + +#ifdef WMOPS + BASOP_sub_start("Reorder Bitstream Enc"); +#endif + test(); + IF (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) + { +#ifdef WMOPS + BASOP_sub_start("Reorder Ari dec"); +#endif + +#ifdef ENABLE_HR_MODE + Word32 *xbuf = (Word32 *) scratchAlign(scratchBuffer, 0); + + processAriDecoder_fx(bytes, &bp_side, &mask_side, h_EncSetup->total_bits, encoder->yLen, encoder->fs_idx, + h_EncSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &gain, tns_order, + fac_ns_idx, quantizedGain, encoder->frame_dms, h_EncSetup->n_pc, 0, + shr_pos(h_EncSetup->total_bits, 3), 1, &gain, &b_left, &gain, + xbuf, + &gain, resBits, indexes, &gain, + currentScratch + , encoder->hrmode + ); +#else + + processAriDecoder_fx(bytes, &bp_side, &mask_side, h_EncSetup->total_bits, encoder->yLen, encoder->fs_idx, + h_EncSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &gain, tns_order, + fac_ns_idx, quantizedGain, encoder->frame_dms, h_EncSetup->n_pc, 0, + shr_pos(h_EncSetup->total_bits, 3), 1, &gain, &b_left, &gain, + codingdata, + &gain, resBits, indexes, &gain, + currentScratch + ); +#endif + +#ifdef WMOPS + BASOP_sub_end(); /* Ari dec */ +#endif + processReorderBitstream_fx(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, currentScratch); + } +#ifdef WMOPS + BASOP_sub_end(); +#endif + + /* end q_d_fx16 */ +#ifdef WMOPS + BASOP_sub_end(); +#endif + + Dyn_Mem_Deluxe_Out(); +} + +int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 *output, void *scratch, Word16 bfi_ext) +{ + int ch = 0, output_size = 0; + int input_size = 0; + int totalBytes = (Word32)encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); + int output_size2; + + UWord8 *lc3buf = output; + + for (ch = 0; ch < encoder->channels; ch++) + { + Enc_LC3PLUS_Channel(encoder, ch, bits_per_sample, input[ch], lc3buf, scratch, bfi_ext); + if (encoder->epmode && encoder->combined_channel_coding == 0) + { + output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); +#ifdef WMOPS + BASOP_sub_start("fec_enc"); +#endif + + fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, + encoder->channel_setup[ch]->n_pccw, scratch); + +#ifdef WMOPS + BASOP_sub_end(); +#endif + + lc3buf += output_size2; + output_size += output_size2; + } + else + { + lc3buf += encoder->channel_setup[ch]->targetBytes; + output_size += encoder->channel_setup[ch]->targetBytes; + } + } + + if (encoder->epmode > 0 && encoder->combined_channel_coding) + { + input_size = output_size; + output_size = (Word32)encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); +#ifdef WMOPS + BASOP_sub_start("fec_enc"); +#endif + + fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw, + scratch); + +#ifdef WMOPS + BASOP_sub_end(); +#endif + } + + return output_size; +} + diff --git a/lib_lc3plus/estimate_global_gain_fx.c b/lib_lc3plus/estimate_global_gain_fx.c new file mode 100644 index 000000000..c6d1766b4 --- /dev/null +++ b/lib_lc3plus/estimate_global_gain_fx.c @@ -0,0 +1,506 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbitsSQ, +#ifdef ENABLE_HR_MODE + Word32 *gain, +#else + Word16 *gain, +#endif + Word16 *gain_e, + Word16 *quantizedGain, Word16 *quantizedGainMin, Word16 quantizedGainOff, + Word32 *targetBitsOff, Word16 *old_targetBits, Word16 old_specBits, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode, Word16 regBits, Word16 frame_dms +#endif +) +{ + + Word16 lg_4, tmp16, iszero, s; + Word32 ener, tmp32, x_max; + Word32 target, fac, offset; + Word32 *en; + Counter iter, i; + Word32 diff, diff2; +#ifdef ENABLE_HR_MODE + Word16 *en_exp = NULL; + Word32 M0, M1; +#endif + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processEstimateGlobalGain_fx", sizeof(struct { + Word16 lg_4, s, tmp16, iszero; + Word32 ener, tmp32, x_max; + Word32 target, fac, offset; + Word32 *en; + Counter i, iter; + Word32 diff, diff2; + })); +#endif + + en = (Word32 *)scratchAlign(scratchBuffer, + 0); /* Size = MAX_LEN bytes */ + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + M0 = 1; + M1 = 1; /* Regularization factor; needs´to be 1e-5, but 1e-5 is 0 in Q15 */ + en_exp = (Word16 *) scratchAlign(en, sizeof(*en) * MAX_LEN); + } +#endif + IF (*old_targetBits < 0) + { + *targetBitsOff = 0; + move16(); + } + ELSE + { + tmp32 = L_add(*targetBitsOff, L_deposit_h(sub(*old_targetBits, old_specBits))); + tmp32 = L_min((40 << 16), L_max(-(40 << 16), tmp32)); + *targetBitsOff = L_add(Mpy_32_16_lc3plus(*targetBitsOff, 26214), Mpy_32_16_lc3plus(tmp32, 6554)); + move16(); + } + + *old_targetBits = nbitsSQ; + move16(); + nbitsSQ = add(nbitsSQ, round_fx(*targetBitsOff)); + + lg_4 = shr_pos(lg, 2); + x_max = 0; + move32(); + +/* energy of quadruples with 9dB offset */ +#ifdef ENABLE_HR_MODE + IF (hrmode) + { + FOR (i = 0; i < lg_4; i++) + { + Word32 absval; + Word16 idx; + /* normalization */ + s = 31; + move16(); + + /* M1 requires a 32x16 mult with Q0 i, resulting in Q15. Keeping both M0 and M1 in same Q */ + /* Use Q15 for M0 and M1 calculation */ + idx = shl(i, 2); + + tmp32 = L_abs(x[0]); + absval = L_shr(tmp32, 16); + M0 = L_add(M0, absval); /* M0 += fabs(x[idx])*/ + M1 = L_add(M1, L_mult(absval, idx)); /* M1 += i*fabs(x[idx])*/ + idx = add(idx, 1); + + absval = L_abs(x[1]); + tmp32 = L_max(tmp32, absval); + absval = L_shr(tmp32, 16); + M0 = L_add(M0, absval); /* M0 += fabs(x[idx])*/ + M1 = L_add(M1, L_mult(absval, idx)); /* M1 += idx*fabs(x[idx])*/ + idx = add(idx, 1); + + absval = L_abs(x[2]); + tmp32 = L_max(tmp32, absval); + absval = L_shr(tmp32, 16); + M0 = L_add(M0, absval); /* M0 += fabs(x[idx])*/ + M1 = L_add(M1, L_mult(absval, idx)); /* M1 += idx*fabs(x[idx])*/ + idx = add(idx, 1); + + absval = L_abs(x[3]); + tmp32 = L_max(tmp32, absval); + absval = L_shr(tmp32, 16); + M0 = L_add(M0, absval); /* M0 += fabs(x[idx])*/ + M1 = L_add(M1, L_mult(absval, idx)); /* M1 += idx*fabs(x[idx])*/ + + x_max = L_max(x_max, tmp32); + + if (tmp32 != 0) + s = norm_l(tmp32); + + s = sub(s, 2); /* 2 bits headroom */ + + /* calc quadruple energy */ + ener = L_deposit_l(1); + + tmp16 = round_fx(L_shl(x[0], s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[1], s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[2], s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[3], s)); + ener = L_mac(ener, tmp16, tmp16); + + s = shl_pos(sub(x_e, s), 1); + if (ener == 1 && s < 0) + s = 0; + IF (regBits > 0) + { + en[i] = ener; + en_exp[i] = s; + move32(); + } + ELSE + { + /* log */ + tmp32 = L_add(BASOP_Util_Log2_lc3plus(ener), L_shl_pos(L_deposit_l(s), 25)); /* log2, 6Q25 */ + tmp32 = L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 7), + 0x4E666); /* -> (28/20)*(7+10*tmp32/log2(10)), 16Q15 */ + en[i] = tmp32; + move32(); + } + + x += 4; + } + } + ELSE +#endif + { + FOR (i = 0; i < lg_4; i++) + { + /* normalization */ + s = 31; + move16(); + + tmp32 = L_abs(x[0]); + tmp32 = L_max(tmp32, L_abs(x[1])); + tmp32 = L_max(tmp32, L_abs(x[2])); + tmp32 = L_max(tmp32, L_abs(x[3])); + x_max = L_max(x_max, tmp32); + + if (tmp32 != 0) + s = norm_l(tmp32); + + s = sub(s, 2); /* 2 bits headroom */ + + /* calc quadruple energy */ + ener = L_deposit_l(1); + + tmp16 = round_fx(L_shl(x[0], s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[1], s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[2], s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[3], s)); + ener = L_mac(ener, tmp16, tmp16); + + s = shl_pos(sub(x_e, s), 1); + if (ener == 1 && s < 0) + s = 0; + + /* log */ + tmp32 = L_add_sat(BASOP_Util_Log2_lc3plus(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2, 6Q25 */ + tmp32 = + L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 6), 0x9CCCD); /* -> (28/20)*(7+10*tmp32/log2(10)), 15Q16 */ + en[i] = tmp32; + move32(); + x += 4; + } + } + + IF (x_max == 0) + { + *quantizedGainMin = quantizedGainOff; + move16(); + *quantizedGain = 0; + move16(); + *old_targetBits = -1; + move16(); + } + ELSE + { + Word32 sub_val = 0xFCDD38F; + /*28 * log10(32767 - 0.375) * (1 - 1e-7) in Q21 */ + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + /* + Original float code : + rB_offset = 8 * (1 - MIN(M1/M0, 2*frame_ms)/(2*frame_ms) + */ + Word16 ratio; + Word16 ratio_exp = 0; + Word32 regterm = MAX_32; /* 1 in Q31 */ + Word32 rB_offset, reg_val; + Word32 ratio_prod; + Word16 n_reg_val; + + if (M0 <= 0x7fff) + { + Word16 inv_M0 = Inv16_lc3plus(M0, &ratio_exp); /* Inverse in Q(15 - ratio_exp) */ + ratio = L_shr(Mpy_32_16_lc3plus(M1, inv_M0), 15 - ratio_exp); /* Integer ratio */ + } + else + { + Word16 M0_h = L_shr(M0, 15); + Word32 M1_h = L_shr(M1, 15); + + Word16 inv_M0 = Inv16_lc3plus(M0_h, &ratio_exp); /* Inverse in Q(15 - ratio_exp) */ + ratio = extract_l(L_shr(Mpy_32_16_lc3plus(M1_h, inv_M0), 15 - ratio_exp)); /* Integer ratio */ + } + + /* + regterm = MIN (M1 / M0, 2 *frame_ms) / (2 * frame_ms) + regterm = MIN (M1 * (10 / 2) / M0, frame_dms) / frame_dms + regterm = MIN ( ratio * 5, frame_dms) / frame_dms + */ + + ratio_prod = L_mult(ratio, 5); + + if (ratio_prod < frame_dms) + { + Word16 mult_factor = 0; + + SWITCH (frame_dms) /* 1 / frame_dms in Q15 */ + { + case 25: mult_factor = 1311; break; + case 50: mult_factor = 655; break; +#ifdef CR8_G_ADD_75MS + case 75: mult_factor = 437; break; +#endif + case 100: mult_factor = 328; break; + } + + /* ratio_prod < frame_dms. Hence Word16 can be used */ + + regterm = L_shl(L_mult(extract_l(ratio_prod), mult_factor), 15); /* result in Q31 */ + } + + rB_offset = L_sub(MAX_32, regterm); + /* Calculation in Q28 to prevent overflow. Subtraction result in Q31, downshift by 3 results in Q28. + Multiplication by 8 is implemented as upshift by 3. + */ + + /* + FLOAT code : reg_val = x_max * LC3_POW(2,-regBits - rB_offset); + */ + Word16 reg_val_e = x_e; + + IF(rB_offset > 0) + { + Word32 reg_exp = L_negate(L_add(L_shl(regBits, 25), L_shr(rB_offset, 3))); + reg_val = Mpy_32_32_lc3plus(x_max, BASOP_Util_InvLog2_lc3plus(reg_exp)); /* Product is in Q31 */ + /* reg_val is in Q(31-x_e) */ + } + ELSE + { + reg_val = x_max; + reg_val_e = sub(x_e, regBits); + } + + sub_val = 0x183BA045; + move16(); + /*28 * log10(32768*256 - 2) in Q21 */ + + /* + Adding LC3_POW(2, -31) to reg_val.2^-31 * 2^(31-x_e) = 2^-x_e. + If x_e is positive, this is below precision requirements to be used. + */ + + if (reg_val_e < 0) + { + reg_val = L_add_sat(reg_val, L_shl_sat(1, negate(reg_val_e))); + } + n_reg_val = norm_l(reg_val); + + FOR (i = 0; i < lg_4; i++) + { + ener = en[i]; + move16(); + s = en_exp[i]; + move16(); + + Word16 shift_val = sub(reg_val_e, s); + + IF (sub(n_reg_val, shift_val) > 0) + { + IF(shift_val > -32) + { + ener = L_add(ener, L_shl(reg_val, shift_val)); /* Match q formats */ + } + } + ELSE + { + IF (sub(shift_val, 32) >= 0 ) + { + ener = reg_val; + } + ELSE + { + ener = L_add_sat(reg_val, L_shr(ener, shift_val)); + } + s = reg_val_e; + } + + tmp32 = L_add(BASOP_Util_Log2_lc3plus(ener), L_shl_pos(L_deposit_l(s), 25)); /* log2, 6Q25 */ + tmp32 = L_add(L_shr_pos(Mpy_32_32_lc3plus(tmp32, 0x436E439A), 7), 0x4E666); /* -> (28/20)*(7+10*tmp32/log2(10)), 15Q16 */ + en[i] = tmp32; + move32(); + } + } +#endif + x_max = BASOP_Util_Log2_lc3plus(x_max); + /* Minimum gain */ + x_max = L_add(x_max, L_shl_pos(L_deposit_l(x_e), 25)); /* log2(x_max) in 6Q25 */ + x_max = L_sub( + Mpy_32_32_lc3plus(x_max, 0x436E439A), + sub_val); /* 28*log10(x_max/(32768-0.375)) = log2(x_max)*(28/log2(10))-28*log10(32768-0.375) in 10Q21 */ + /* 28/log1(10) is in Q27 + Mpy_32_32_lc3plus : Q25(x_max) + Q27 + Q1(Mpy_32_32_ss) - Q32 = Q21 */ + *quantizedGainMin = extract_l(L_shr_pos(L_add(x_max, (1 << 21) + (1 << 11)), 21)); + move16(); + ASSERT(*quantizedGainMin <= 255 + quantizedGainOff); + *quantizedGainMin = s_max(quantizedGainOff, s_min(add(255, quantizedGainOff), *quantizedGainMin)); + + offset = L_deposit_h(add(255, quantizedGainOff)); /* -> 127 */ + +#ifdef ENABLE_HR_MODE + IF(hrmode) + { + offset = L_shr_pos(offset, 2); + /* SQ scale: 4 bits / 6 dB per quadruple */ + target = L_mult(0x3EB8, nbitsSQ); /* -> (28/20) * (1.4) * nbitsSQ */ + + fac = L_add(0x400000, 0); /* -> 256 */ + /* find offset (0 to 127) */ + FOR (iter = 0; iter < 8; iter++) + { + fac = L_shr_pos(fac, 1); + offset = L_sub(offset, fac); + + ener = L_deposit_l(0); + iszero = 1; + move16(); + + FOR (i = lg_4 - 1; i >= 0; i--) + { + tmp32 = L_sub(L_shr_pos(en[i], 1), offset); + diff = L_sub(tmp32, 0x27333); /* 0x4E666 -> (28/20)*(7) in Q15 */ + if (diff < 0) + { + if (iszero == 0) + { + ener = L_add(ener, 0xF1EC); /* 0x1E3D7 -> (28/20)*(2.7) in Q15 */ + } + } + else + { + ener = L_add(ener, tmp32); + iszero = 0; + move16(); + + diff2 = L_sub(tmp32, 0x118000); /* 0x230000 -> (28/20)*(50) */ + if (diff2 >= 0) + { + ener = L_add(ener, diff2); + } + } + } + + /* if ener is above target -> increase offset */ + test(); + if (L_sub(ener, target) > 0 && iszero == 0) + { + offset = L_add(offset, fac); + } + } + tmp16 = extract_h(L_shl(offset, 2)); + } + ELSE +#endif + { + /* SQ scale: 4 bits / 6 dB per quadruple */ + target = L_shl_pos(L_mult(0x7D71, nbitsSQ), 1); /* -> (28/20) * (1.4) * nbitsSQ */ + fac = L_add(0x1000000, 0); /* -> 256 */ + + /* find offset (0 to 127) */ + FOR (iter = 0; iter < 8; iter++) + { + fac = L_shr_pos(fac, 1); + offset = L_sub(offset, fac); + + ener = L_deposit_l(0); + iszero = 1; + move16(); + FOR (i = lg_4 - 1; i >= 0; i--) + { + tmp32 = L_sub(en[i], offset); + diff = L_sub(tmp32, 0x9CCCD); /* 0x9CCCD -> (28/20)*(7) in Q16 */ + if (diff < 0) + { + if (iszero == 0) + { + ener = L_add_sat(ener, 0x3C7AE); /* 0x3C7AE -> (28/20)*(2.7) in Q16 */ + } + } + else + { + ener = L_add_sat(ener, tmp32); + iszero = 0; + move16(); + + diff2 = L_sub(tmp32, 0x460000); /* 0x460000 -> (28/20)*(50) in Q16 */ + if (diff2 >= 0) + { + ener = L_add_sat(ener, diff2); + } + } + + } + + /* if ener is above target -> increase offset */ + test(); + if (L_sub(ener, target) > 0 && iszero == 0) + { + offset = L_add(offset, fac); + } + } + tmp16 = extract_h(offset); + + } + + if (sub(tmp16, *quantizedGainMin) < 0) + { + *old_targetBits = -1; + move16(); + } + *quantizedGain = sub(s_max(*quantizedGainMin, tmp16), quantizedGainOff); + move16(); + } + +#ifdef ENABLE_HR_MODE + tmp32 = + Mpy_32_16_lc3plus(0x797CD707, L_shl_pos(add(*quantizedGain, quantizedGainOff), 6)); +#else + tmp32 = + L_shl_pos(L_mult0(add(*quantizedGain, quantizedGainOff), 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ +#endif + *gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); /* get exponent */ +#ifdef ENABLE_HR_MODE + *gain = BASOP_Util_InvLog2_lc3plus(L_or(tmp32, (Word32)0xFE000000)); +#else + *gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32,(Word32) 0xFE000000))); +#endif + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/fft_lc3plus.c b/lib_lc3plus/fft_lc3plus.c new file mode 100644 index 000000000..a86286d04 --- /dev/null +++ b/lib_lc3plus/fft_lc3plus.c @@ -0,0 +1,4537 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include "rom_basop_util.h" + +#ifdef ENABLE_FFT_RESCALE +#ifndef FFT_RESCALE_HR +#define FFT_RESCALE_HR 3 +#endif +#endif + +#define SCALEFACTORN2 3 +#define SCALEFACTOR4 3 +#define SCALEFACTOR5 4 +#define SCALEFACTOR8 4 +#define SCALEFACTOR15 5 +#define SCALEFACTOR30_1 5 +#define SCALEFACTOR30_2 1 +#define SCALEFACTOR32_1 5 +#define SCALEFACTOR32_2 1 + +#ifdef ENABLE_HR_MODE +#define Mpy_32_xx Mpy_32_32_lc3plus +#else +#define Mpy_32_xx Mpy_32_16_lc3plus +#endif + +#ifdef CR8_G_ADD_75MS +#define SCALEFACTOR6 4 +#define C61_32 (0x6ed9eba1) +#endif + +#define SCALEFACTOR10 5 +#define SCALEFACTOR16 5 +#define SCALEFACTOR20 5 +#define SCALEFACTOR30 6 +#define SCALEFACTOR32 6 +#define SCALEFACTOR40 7 +#define SCALEFACTOR48 8 +#define SCALEFACTOR60 7 +#define SCALEFACTOR64 7 +#define SCALEFACTOR80 8 +#define SCALEFACTOR90 9 +#define SCALEFACTOR96 9 +#define SCALEFACTOR120 8 +#define SCALEFACTOR128 8 +#define SCALEFACTOR160 8 +#define SCALEFACTOR180 10 +#define SCALEFACTOR192 10 +#define SCALEFACTOR240 9 +#define SCALEFACTOR256 9 +#define SCALEFACTOR384 11 + +#ifdef ENABLE_HR_MODE +#ifdef CR8_G_ADD_75MS +#define SCALEFACTOR360 11 +#endif +#ifndef ENABLE_FFT_30X16 +#define SCALEFACTOR480 10 +#else +#define SCALEFACTOR480 11 +#endif +#endif + +#ifdef ENABLE_HR_MODE +#undef L_shr_pos +#define L_shr_pos(x, y) (L_shr(L_add(L_shr((x), ((y)-1)),1),1)) +#endif + +#ifdef ENABLE_HR_MODE +#define FFTC(x) ((Word32)x) +#else +#define FFTC(x) WORD322WORD16((Word32)x) +#endif + +#define C31 (FFTC(0x91261468)) /* FL2WORD32( -0.86602540) -sqrt(3)/2 */ + +#define C51 (FFTC(0x79bc3854)) /* FL2WORD32( 0.95105652) */ +#define C52 (FFTC(0x9d839db0)) /* FL2WORD32(-1.53884180/2) */ +#define C53 (FFTC(0xd18053ce)) /* FL2WORD32(-0.36327126) */ +#define C54 (FFTC(0x478dde64)) /* FL2WORD32( 0.55901699) */ +#define C55 (FFTC(0xb0000001)) /* FL2WORD32(-1.25/2) */ + +#define C81 (FFTC(0x5a82799a)) /* FL2WORD32( 7.071067811865475e-1) */ +#define C82 (FFTC(0xa57d8666)) /* FL2WORD32(-7.071067811865475e-1) */ + +#define C161 (FFTC(0x5a82799a)) /* FL2WORD32( 7.071067811865475e-1) INV_SQRT2 */ +#define C162 (FFTC(0xa57d8666)) /* FL2WORD32(-7.071067811865475e-1) -INV_SQRT2 */ + +#define C163 (FFTC(0x7641af3d)) /* FL2WORD32( 9.238795325112867e-1) COS_PI_DIV8 */ +#define C164 (FFTC(0x89be50c3)) /* FL2WORD32(-9.238795325112867e-1) -COS_PI_DIV8 */ + +#define C165 (FFTC(0x30fbc54d)) /* FL2WORD32( 3.826834323650898e-1) COS_3PI_DIV8 */ +#define C166 (FFTC(0xcf043ab3)) /* FL2WORD32(-3.826834323650898e-1) -COS_3PI_DIV8 */ + +#define C51_32 (0x79bc3854) /* FL2WORD32( 0.95105652) */ +#define C52_32 (0x9d839db0) /* FL2WORD32(-1.53884180/2) */ +#define C53_32 (0xd18053ce) /* FL2WORD32(-0.36327126) */ +#define C54_32 (0x478dde64) /* FL2WORD32( 0.55901699) */ +#define C55_32 (0xb0000001) /* FL2WORD32(-1.25/2) */ + + +#define C81_32 (0x5a82799a) /* FL2WORD32( 7.071067811865475e-1) */ +#define C82_32 (0xa57d8666) /* FL2WORD32(-7.071067811865475e-1) */ + +#if defined(ENABLE_HR_MODE) + +# define cplxMpy4_16_0(re, im, a, b, c, d) \ + do \ + { \ + re = L_sub(Mpy_32_xx(a, c), Mpy_32_xx(b, d)); \ + move32(); \ + im = L_add(Mpy_32_xx(a, d), Mpy_32_xx(b, c)); \ + move32(); \ + } while (0) + +# define cplxMpy4_16_1(re, im, a, b) \ + do \ + { \ + re = a; \ + move32(); \ + im = b; \ + move32(); \ + } while (0) + +# endif + +#define Mpy3_0(s12, s13, s14, s15, t0, t1, t2, t3) \ + do \ + { \ + s12 = Mpy_32_32_lc3plus(L_add(t0, t2), C81_32); \ + s14 = Mpy_32_32_lc3plus(L_sub(t0, t2), C81_32); \ + s13 = Mpy_32_32_lc3plus(L_sub(t3, t1), C81_32); \ + s15 = Mpy_32_32_lc3plus(L_add(t1, t3), C82_32); \ + } while (0) + +#define cplxMpy3_0(a, b, c, d) \ + do \ + { \ + as = L_shr_pos(a, 1); \ + bs = L_shr_pos(b, 1); \ + a = L_sub(Mpy_32_32_lc3plus(as, c), Mpy_32_32_lc3plus(bs, d)); \ + b = L_add(Mpy_32_32_lc3plus(as, d), Mpy_32_32_lc3plus(bs, c)); \ + } while (0) + +#ifdef ENABLE_HR_MODE +#define cplxMpy4_4_0(re, im, a, b, c, d) \ + re = L_shr_pos(L_sub(Mpy_32_xx(a, c), Mpy_32_xx(b, d)), SCALEFACTOR60 - SCALEFACTOR15); \ + im = L_shr_pos(L_add(Mpy_32_xx(a, d), Mpy_32_xx(b, c)), SCALEFACTOR60 - SCALEFACTOR15); + +# define cplxMpy4_4_1(re, im, a, b) \ + re = L_shr_pos(a, SCALEFACTOR60 - SCALEFACTOR15); \ + im = L_shr_pos(b, SCALEFACTOR60 - SCALEFACTOR15); +#else +#define cplxMpy4_4_0(re, im, a, b, c, d) \ + re = L_shr(L_sub(Mpy_32_xx(a, c), Mpy_32_xx(b, d)), SCALEFACTOR60 - SCALEFACTOR15); \ + im = L_shr(L_add(Mpy_32_xx(a, d), Mpy_32_xx(b, c)), SCALEFACTOR60 - SCALEFACTOR15); + +#define cplxMpy4_4_1(re, im, a, b) \ + re = L_shr(a, SCALEFACTOR60 - SCALEFACTOR15); \ + im = L_shr(b, SCALEFACTOR60 - SCALEFACTOR15); +#endif + +#define cplxMpy4_8_0(re, im, a, b, c, d) \ + do \ + { \ + re = L_shr_pos(L_sub(Mpy_32_xx(a, c), Mpy_32_xx(b, d)), 1); \ + im = L_shr_pos(L_add(Mpy_32_xx(a, d), Mpy_32_xx(b, c)), 1); \ + } while (0) + + +#define cplxMpy4_8_1(re, im, a, b) \ + do \ + { \ + re = L_shr_pos(a, 1); \ + im = L_shr_pos(b, 1); \ + } while (0) + + +#define cplxMpy4_8_2(re, im, a, b, c, d) \ + do \ + { \ + re = L_shr_pos(L_add(Mpy_32_32_lc3plus(a, c), Mpy_32_32_lc3plus(b, d)), 1); \ + im = L_shr_pos(L_sub(Mpy_32_32_lc3plus(b, c), Mpy_32_32_lc3plus(a, d)), 1); \ + } while (0) + + +#define cplxMpy4_12_0(re, im, a, b, c, d) \ + do \ + { \ + re = L_sub(Mpy_32_xx(a, c), Mpy_32_xx(b, d)); \ + move32(); \ + im = L_add(Mpy_32_xx(a, d), Mpy_32_xx(b, c)); \ + move32(); \ + } while (0) + +#define cplxMpy4_12_1(re, im, a, b) \ + do \ + { \ + re = a; \ + move32(); \ + im = b; \ + move32(); \ + } while (0) + + +static void fft4(Word32 *x) +{ + Dyn_Mem_Deluxe_In(Word32 x0, x1, x2, x3, x4, x5, x6, x7; Word32 t0, t1, t2, t3, t4, t5, t6, t7;); + + x0 = L_shr_pos(x[0], SCALEFACTOR4); + x1 = L_shr_pos(x[1], SCALEFACTOR4); + x2 = L_shr_pos(x[2], SCALEFACTOR4); + x3 = L_shr_pos(x[3], SCALEFACTOR4); + x4 = L_shr_pos(x[4], SCALEFACTOR4); + x5 = L_shr_pos(x[5], SCALEFACTOR4); + x6 = L_shr_pos(x[6], SCALEFACTOR4); + x7 = L_shr_pos(x[7], SCALEFACTOR4); + + /* Pre-additions */ + t0 = L_add(x0, x4); + t2 = L_sub(x0, x4); + t1 = L_add(x1, x5); + t3 = L_sub(x1, x5); + t4 = L_add(x2, x6); + t7 = L_sub(x2, x6); + t5 = L_add(x7, x3); + t6 = L_sub(x7, x3); + + /* Post-additions */ + x[0] = L_add(t0, t4); + x[1] = L_add(t1, t5); + x[2] = L_sub(t2, t6); + x[3] = L_sub(t3, t7); + x[4] = L_sub(t0, t4); + x[5] = L_sub(t1, t5); + x[6] = L_add(t2, t6); + x[7] = L_add(t3, t7); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 5-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR5 bits. + * + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + + +static void fft5(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 x0, x1, x2, x3, x4; Word32 r1, r2, r3, r4; Word32 s1, s2, s3, s4; Word32 t;); + + /* real part */ + x0 = L_shr_pos(re[s * 0], SCALEFACTOR5); + x1 = L_shr_pos(re[s * 1], SCALEFACTOR5); + x2 = L_shr_pos(re[s * 2], SCALEFACTOR5); + x3 = L_shr_pos(re[s * 3], SCALEFACTOR5); + x4 = L_shr_pos(re[s * 4], SCALEFACTOR5); + + r1 = L_add(x1, x4); + r4 = L_sub(x1, x4); + r3 = L_add(x2, x3); + r2 = L_sub(x2, x3); + t = Mpy_32_32_lc3plus(L_sub(r1, r3), C54_32); + r1 = L_add(r1, r3); + re[0] = L_add(x0, r1); + move32(); + /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of + the values as fracts */ + r1 = L_add(re[0], (L_shl_pos(Mpy_32_32_lc3plus(r1, C55_32), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_32_lc3plus(L_add(r4, r2), C51_32); + /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of + the values as fracts */ + r4 = L_add(t, L_shl_pos(Mpy_32_32_lc3plus(r4, C52_32), 1)); + r2 = L_add(t, Mpy_32_32_lc3plus(r2, C53_32)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 0], SCALEFACTOR5); + x1 = L_shr_pos(im[s * 1], SCALEFACTOR5); + x2 = L_shr_pos(im[s * 2], SCALEFACTOR5); + x3 = L_shr_pos(im[s * 3], SCALEFACTOR5); + x4 = L_shr_pos(im[s * 4], SCALEFACTOR5); + + s1 = L_add(x1, x4); + s4 = L_sub(x1, x4); + s3 = L_add(x2, x3); + s2 = L_sub(x2, x3); + t = Mpy_32_32_lc3plus(L_sub(s1, s3), C54_32); + s1 = L_add(s1, s3); + im[0] = L_add(x0, s1); + move32(); + /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of + the values as fracts */ + s1 = L_add(im[0], L_shl_pos(Mpy_32_32_lc3plus(s1, C55_32), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_32_lc3plus(L_add(s4, s2), C51_32); + /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of + the values as fracts */ + s4 = L_add(t, L_shl_pos(Mpy_32_32_lc3plus(s4, C52_32), 1)); + s2 = L_add(t, Mpy_32_32_lc3plus(s2, C53_32)); + + /* combination */ + re[s * 1] = L_add(r1, s2); + move32(); + re[s * 4] = L_sub(r1, s2); + move32(); + re[s * 2] = L_sub(r3, s4); + move32(); + re[s * 3] = L_add(r3, s4); + move32(); + + im[s * 1] = L_sub(s1, r2); + move32(); + im[s * 4] = L_add(s1, r2); + move32(); + im[s * 2] = L_add(s3, r4); + move32(); + im[s * 3] = L_sub(s3, r4); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 6-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR6 bits. + * + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] st stride real and imag input / output + * + * \return void + */ + +#ifdef CR8_G_ADD_75MS +static void fft6(Word32 *re, Word32 *im, Word16 st) +{ + Dyn_Mem_Deluxe_In(Word32 x0, x1, x2, x3, x4, x5; Word32 r1o, r2o, i1e, i2e, i1o, i2o; Word32 t, s;); + + /* process real parts */ + + x0 = L_shr_pos(re[0 * st], SCALEFACTOR6); + x1 = L_shr_pos(re[1 * st], SCALEFACTOR6); + x2 = L_shr_pos(re[2 * st], SCALEFACTOR6); + x3 = L_shr_pos(re[3 * st], SCALEFACTOR6); + x4 = L_shr_pos(re[4 * st], SCALEFACTOR6); + x5 = L_shr_pos(re[5 * st], SCALEFACTOR6); + + t = L_add(x0, L_add(x2, x4)); + s = L_add(x1, L_add(x3, x5)); + re[0 * st] = L_add(t, s); + move32(); + re[3 * st] = L_sub(t, s); + move32(); + t = L_sub(x0, L_shr_pos(L_add(x2, x4), 1)); + + re[1 * st] = t; + move32(); + re[2 * st] = t; + move32(); + re[4 * st] = t; + move32(); + re[5 * st] = t; + move32(); + + s = Mpy_32_32_lc3plus(L_sub(x4, x2), C61_32); + + i1e = s; + i2e = -s; + + t = L_sub(x1, L_shr_pos(L_add(x3, x5), 1)); + s = Mpy_32_32_lc3plus(L_sub(x5, x3), C61_32); + + r1o = r2o = t; + i1o = s; + i2o = -s; + + x0 = L_shr_pos(im[0 * st], SCALEFACTOR6); + x1 = L_shr_pos(im[1 * st], SCALEFACTOR6); + x2 = L_shr_pos(im[2 * st], SCALEFACTOR6); + x3 = L_shr_pos(im[3 * st], SCALEFACTOR6); + x4 = L_shr_pos(im[4 * st], SCALEFACTOR6); + x5 = L_shr_pos(im[5 * st], SCALEFACTOR6); + + t = L_add(x0, L_add(x2, x4)); + s = L_add(x1, L_add(x3, x5)); + + im[0 * st] = L_add(t, s); + move32(); + im[3 * st] = L_sub(t, s); + move32(); + + t = Mpy_32_32_lc3plus(L_sub(x2, x4), C61_32); + s = L_sub(x0, L_shr_pos(L_add(x2, x4), 1)); + + re[1 * st] = L_add(re[1 * st], t); + move32(); + re[2 * st] = L_sub(re[2 * st], t); + move32(); + re[4 * st] = L_add(re[4 * st], t); + move32(); + re[5 * st] = L_sub(re[5 * st], t); + move32(); + + i1e = L_add(i1e, s); + i2e = L_add(i2e, s); + + t = Mpy_32_32_lc3plus(L_sub(x3, x5), C61_32); + s = L_sub(x1, L_shr_pos(L_add(x5, x3), 1)); + + r1o = L_add(r1o, t); + r2o = L_sub(r2o, t); + + i1o = L_add(i1o, s); + i2o = L_add(i2o, s); + + t = L_add(L_shr_pos(r1o, 1), Mpy_32_32_lc3plus(i1o, C61_32)); + s = L_sub(L_shr_pos(i1o, 1), Mpy_32_32_lc3plus(r1o, C61_32)); + + re[1 * st] = L_add(re[1 * st], t); + move32(); + im[1 * st] = L_add(i1e, s); + move32(); + + re[4 * st] = L_sub(re[4 * st], t); + move32(); + im[4 * st] = L_sub(i1e, s); + move32(); + + t = L_sub(Mpy_32_32_lc3plus(i2o, C61_32), L_shr_pos(r2o, 1)); + s = L_negate(L_add(Mpy_32_32_lc3plus(r2o, C61_32), L_shr_pos(i2o, 1))); + + re[2 * st] = L_add(re[2 * st], t); + move32(); + im[2 * st] = L_add(i2e, s); + move32(); + + re[5 * st] = L_sub(re[5 * st], t); + move32(); + im[5 * st] = L_sub(i2e, s); + move32(); + + Dyn_Mem_Deluxe_Out(); +} +#endif + +/** + * \brief Function performs a complex 8-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR8 bits. + * + * WOPS with 32x16 bit multiplications: 108 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + +static void fft8(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 x00, x01, x02, x03, x04, x05, x06, x07; Word32 x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07; Word32 t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07; Word32 s08, s09, s10, s11, s12, s13, s14, s15;); + + /* Pre-additions */ + + x00 = L_shr_pos(re[s * 0], SCALEFACTOR8); + x01 = L_shr_pos(im[s * 0], SCALEFACTOR8); + x02 = L_shr_pos(re[s * 1], SCALEFACTOR8); + x03 = L_shr_pos(im[s * 1], SCALEFACTOR8); + x04 = L_shr_pos(re[s * 2], SCALEFACTOR8); + x05 = L_shr_pos(im[s * 2], SCALEFACTOR8); + x06 = L_shr_pos(re[s * 3], SCALEFACTOR8); + x07 = L_shr_pos(im[s * 3], SCALEFACTOR8); + x08 = L_shr_pos(re[s * 4], SCALEFACTOR8); + x09 = L_shr_pos(im[s * 4], SCALEFACTOR8); + x10 = L_shr_pos(re[s * 5], SCALEFACTOR8); + x11 = L_shr_pos(im[s * 5], SCALEFACTOR8); + x12 = L_shr_pos(re[s * 6], SCALEFACTOR8); + x13 = L_shr_pos(im[s * 6], SCALEFACTOR8); + x14 = L_shr_pos(re[s * 7], SCALEFACTOR8); + x15 = L_shr_pos(im[s * 7], SCALEFACTOR8); + + t00 = L_add(x00, x08); + t02 = L_sub(x00, x08); + t01 = L_add(x01, x09); + t03 = L_sub(x01, x09); + t04 = L_add(x02, x10); + t06 = L_sub(x02, x10); + t05 = L_add(x03, x11); + t07 = L_sub(x03, x11); + t08 = L_add(x04, x12); + t10 = L_sub(x04, x12); + t09 = L_add(x05, x13); + t11 = L_sub(x05, x13); + t12 = L_add(x06, x14); + t14 = L_sub(x06, x14); + t13 = L_add(x07, x15); + t15 = L_sub(x07, x15); + + /* Pre-additions and core multiplications */ + + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + + t01 = L_add(t06, t14); + t02 = L_sub(t06, t14); + t00 = L_add(t07, t15); + t03 = L_sub(t07, t15); + + s12 = Mpy_32_xx(L_add(t00, t02), C81); + s14 = Mpy_32_xx(L_sub(t00, t02), C81); + s13 = Mpy_32_xx(L_sub(t03, t01), C81); + s15 = Mpy_32_xx(L_add(t01, t03), C82); + + /* Post-additions */ + + re[s * 0] = L_add(s00, s02); + move32(); + re[s * 4] = L_sub(s00, s02); + move32(); + im[s * 0] = L_add(s01, s03); + move32(); + im[s * 4] = L_sub(s01, s03); + move32(); + re[s * 2] = L_sub(s04, s06); + move32(); + re[s * 6] = L_add(s04, s06); + move32(); + im[s * 2] = L_sub(s05, s07); + move32(); + im[s * 6] = L_add(s05, s07); + move32(); + re[s * 3] = L_add(s08, s14); + move32(); + re[s * 7] = L_sub(s08, s14); + move32(); + im[s * 3] = L_add(s09, s15); + move32(); + im[s * 7] = L_sub(s09, s15); + move32(); + re[s * 1] = L_add(s10, s12); + move32(); + re[s * 5] = L_sub(s10, s12); + move32(); + im[s * 1] = L_add(s11, s13); + move32(); + im[s * 5] = L_sub(s11, s13); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 10-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR10 bits. + * + * WOPS with 32x16 bit multiplications: 196 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + + +static void fft10(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 t; Word32 x0, x1, x2, x3, x4; Word32 r1, r2, r3, r4; Word32 s1, s2, s3, s4; + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19;); + + /* 2 fft5 stages */ + + /* real part */ + x0 = L_shr_pos(re[s * 0], SCALEFACTOR10); + x1 = L_shr_pos(re[s * 2], SCALEFACTOR10); + x2 = L_shr_pos(re[s * 4], SCALEFACTOR10); + x3 = L_shr_pos(re[s * 6], SCALEFACTOR10); + x4 = L_shr_pos(re[s * 8], SCALEFACTOR10); + + r1 = L_add(x3, x2); + r4 = L_sub(x3, x2); + r3 = L_add(x1, x4); + r2 = L_sub(x1, x4); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y00 = L_add(x0, r1); + r1 = L_add(y00, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 0], SCALEFACTOR10); + x1 = L_shr_pos(im[s * 2], SCALEFACTOR10); + x2 = L_shr_pos(im[s * 4], SCALEFACTOR10); + x3 = L_shr_pos(im[s * 6], SCALEFACTOR10); + x4 = L_shr_pos(im[s * 8], SCALEFACTOR10); + + s1 = L_add(x3, x2); + s4 = L_sub(x3, x2); + s3 = L_add(x1, x4); + s2 = L_sub(x1, x4); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y01 = L_add(x0, s1); + s1 = L_add(y01, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y04 = L_add(r1, s2); + y16 = L_sub(r1, s2); + y08 = L_sub(r3, s4); + y12 = L_add(r3, s4); + + y05 = L_sub(s1, r2); + y17 = L_add(s1, r2); + y09 = L_add(s3, r4); + y13 = L_sub(s3, r4); + + /* real part */ + x0 = L_shr_pos(re[s * 5], SCALEFACTOR10); + x1 = L_shr_pos(re[s * 1], SCALEFACTOR10); + x2 = L_shr_pos(re[s * 3], SCALEFACTOR10); + x3 = L_shr_pos(re[s * 7], SCALEFACTOR10); + x4 = L_shr_pos(re[s * 9], SCALEFACTOR10); + + r1 = L_add(x1, x4); + r4 = L_sub(x1, x4); + r3 = L_add(x3, x2); + r2 = L_sub(x3, x2); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y02 = L_add(x0, r1); + r1 = L_add(y02, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 5], SCALEFACTOR10); + x1 = L_shr_pos(im[s * 1], SCALEFACTOR10); + x2 = L_shr_pos(im[s * 3], SCALEFACTOR10); + x3 = L_shr_pos(im[s * 7], SCALEFACTOR10); + x4 = L_shr_pos(im[s * 9], SCALEFACTOR10); + + s1 = L_add(x1, x4); + s4 = L_sub(x1, x4); + s3 = L_add(x3, x2); + s2 = L_sub(x3, x2); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y03 = L_add(x0, s1); + s1 = L_add(y03, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y06 = L_add(r1, s2); + y18 = L_sub(r1, s2); + y10 = L_sub(r3, s4); + y14 = L_add(r3, s4); + + y07 = L_sub(s1, r2); + y19 = L_add(s1, r2); + y11 = L_add(s3, r4); + y15 = L_sub(s3, r4); + + /* 5 fft2 stages */ + re[s * 0] = L_add(y00, y02); + move32(); + im[s * 0] = L_add(y01, y03); + move32(); + re[s * 5] = L_sub(y00, y02); + move32(); + im[s * 5] = L_sub(y01, y03); + move32(); + + re[s * 2] = L_add(y04, y06); + move32(); + im[s * 2] = L_add(y05, y07); + move32(); + re[s * 7] = L_sub(y04, y06); + move32(); + im[s * 7] = L_sub(y05, y07); + move32(); + + re[s * 4] = L_add(y08, y10); + move32(); + im[s * 4] = L_add(y09, y11); + move32(); + re[s * 9] = L_sub(y08, y10); + move32(); + im[s * 9] = L_sub(y09, y11); + move32(); + + re[s * 6] = L_add(y12, y14); + move32(); + im[s * 6] = L_add(y13, y15); + move32(); + re[s * 1] = L_sub(y12, y14); + move32(); + im[s * 1] = L_sub(y13, y15); + move32(); + + re[s * 8] = L_add(y16, y18); + move32(); + im[s * 8] = L_add(y17, y19); + move32(); + re[s * 3] = L_sub(y16, y18); + move32(); + im[s * 3] = L_sub(y17, y19); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 15-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR15 bits. + * + * WOPS with 32x16 bit multiplications: 354 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + +static void fft15(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 t; Word32 r1, r2, r3, r4; Word32 s1, s2, s3, s4; + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09; + Word32 x10, x11, x12, x13, x14, x15, x16, x17, x18, x19; + Word32 x20, x21, x22, x23, x24, x25, x26, x27, x28, x29; + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + Word32 y20, y21, y22, y23, y24, y25, y26, y27, y28, y29;); + + x00 = L_shr_pos(re[s * 0], SCALEFACTOR15); + x01 = L_shr_pos(im[s * 0], SCALEFACTOR15); + x02 = L_shr_pos(re[s * 3], SCALEFACTOR15); + x03 = L_shr_pos(im[s * 3], SCALEFACTOR15); + x04 = L_shr_pos(re[s * 6], SCALEFACTOR15); + x05 = L_shr_pos(im[s * 6], SCALEFACTOR15); + x06 = L_shr_pos(re[s * 9], SCALEFACTOR15); + x07 = L_shr_pos(im[s * 9], SCALEFACTOR15); + x08 = L_shr_pos(re[s * 12], SCALEFACTOR15); + x09 = L_shr_pos(im[s * 12], SCALEFACTOR15); + + x10 = L_shr_pos(re[s * 5], SCALEFACTOR15); + x11 = L_shr_pos(im[s * 5], SCALEFACTOR15); + x12 = L_shr_pos(re[s * 8], SCALEFACTOR15); + x13 = L_shr_pos(im[s * 8], SCALEFACTOR15); + x14 = L_shr_pos(re[s * 11], SCALEFACTOR15); + x15 = L_shr_pos(im[s * 11], SCALEFACTOR15); + x16 = L_shr_pos(re[s * 14], SCALEFACTOR15); + x17 = L_shr_pos(im[s * 14], SCALEFACTOR15); + x18 = L_shr_pos(re[s * 2], SCALEFACTOR15); + x19 = L_shr_pos(im[s * 2], SCALEFACTOR15); + + x20 = L_shr_pos(re[s * 10], SCALEFACTOR15); + x21 = L_shr_pos(im[s * 10], SCALEFACTOR15); + x22 = L_shr_pos(re[s * 13], SCALEFACTOR15); + x23 = L_shr_pos(im[s * 13], SCALEFACTOR15); + x24 = L_shr_pos(re[s * 1], SCALEFACTOR15); + x25 = L_shr_pos(im[s * 1], SCALEFACTOR15); + x26 = L_shr_pos(re[s * 4], SCALEFACTOR15); + x27 = L_shr_pos(im[s * 4], SCALEFACTOR15); + x28 = L_shr_pos(re[s * 7], SCALEFACTOR15); + x29 = L_shr_pos(im[s * 7], SCALEFACTOR15); + + /* 1. FFT5 stage */ + + /* real part */ + r1 = L_add(x02, x08); + r4 = L_sub(x02, x08); + r3 = L_add(x04, x06); + r2 = L_sub(x04, x06); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y00 = L_add(x00, r1); + r1 = L_add(y00, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x03, x09); + s4 = L_sub(x03, x09); + s3 = L_add(x05, x07); + s2 = L_sub(x05, x07); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y01 = L_add(x01, s1); + s1 = L_add(y01, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y02 = L_add(r1, s2); + y08 = L_sub(r1, s2); + y04 = L_sub(r3, s4); + y06 = L_add(r3, s4); + + y03 = L_sub(s1, r2); + y09 = L_add(s1, r2); + y05 = L_add(s3, r4); + y07 = L_sub(s3, r4); + + /* 2. FFT5 stage */ + + /* real part */ + r1 = L_add(x12, x18); + r4 = L_sub(x12, x18); + r3 = L_add(x14, x16); + r2 = L_sub(x14, x16); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y10 = L_add(x10, r1); + r1 = L_add(y10, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x13, x19); + s4 = L_sub(x13, x19); + s3 = L_add(x15, x17); + s2 = L_sub(x15, x17); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y11 = L_add(x11, s1); + s1 = L_add(y11, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y12 = L_add(r1, s2); + y18 = L_sub(r1, s2); + y14 = L_sub(r3, s4); + y16 = L_add(r3, s4); + + y13 = L_sub(s1, r2); + y19 = L_add(s1, r2); + y15 = L_add(s3, r4); + y17 = L_sub(s3, r4); + + /* 3. FFT5 stage */ + + /* real part */ + r1 = L_add(x22, x28); + r4 = L_sub(x22, x28); + r3 = L_add(x24, x26); + r2 = L_sub(x24, x26); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y20 = L_add(x20, r1); + r1 = L_add(y20, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x23, x29); + s4 = L_sub(x23, x29); + s3 = L_add(x25, x27); + s2 = L_sub(x25, x27); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y21 = L_add(x21, s1); + s1 = L_add(y21, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y22 = L_add(r1, s2); + y28 = L_sub(r1, s2); + y24 = L_sub(r3, s4); + y26 = L_add(r3, s4); + + y23 = L_sub(s1, r2); + y29 = L_add(s1, r2); + y25 = L_add(s3, r4); + y27 = L_sub(s3, r4); + + /* 1. FFT3 stage */ + + /* real part */ + r1 = L_add(y10, y20); + r2 = Mpy_32_xx(L_sub(y10, y20), C31); + re[s * 0] = L_add(y00, r1); + move32(); + r1 = L_sub(y00, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y11, y21); + s2 = Mpy_32_xx(L_sub(y11, y21), C31); + im[s * 0] = L_add(y01, s1); + move32(); + s1 = L_sub(y01, L_shr_pos(s1, 1)); + + /* combination */ + re[s * 10] = L_sub(r1, s2); + move32(); + re[s * 5] = L_add(r1, s2); + move32(); + im[s * 10] = L_add(s1, r2); + move32(); + im[s * 5] = L_sub(s1, r2); + move32(); + + /* 2. FFT3 stage */ + + /* real part */ + r1 = L_add(y12, y22); + r2 = Mpy_32_xx(L_sub(y12, y22), C31); + re[s * 6] = L_add(y02, r1); + move32(); + r1 = L_sub(y02, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y13, y23); + s2 = Mpy_32_xx(L_sub(y13, y23), C31); + im[s * 6] = L_add(y03, s1); + move32(); + s1 = L_sub(y03, L_shr_pos(s1, 1)); + + /* combination */ + re[s * 1] = L_sub(r1, s2); + move32(); + re[s * 11] = L_add(r1, s2); + move32(); + im[s * 1] = L_add(s1, r2); + move32(); + im[s * 11] = L_sub(s1, r2); + move32(); + + /* 3. FFT3 stage */ + + /* real part */ + r1 = L_add(y14, y24); + r2 = Mpy_32_xx(L_sub(y14, y24), C31); + re[s * 12] = L_add(y04, r1); + move32(); + r1 = L_sub(y04, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y15, y25); + s2 = Mpy_32_xx(L_sub(y15, y25), C31); + im[s * 12] = L_add(y05, s1); + move32(); + s1 = L_sub(y05, L_shr_pos(s1, 1)); + + /* combination */ + re[s * 7] = L_sub(r1, s2); + move32(); + re[s * 2] = L_add(r1, s2); + move32(); + im[s * 7] = L_add(s1, r2); + move32(); + im[s * 2] = L_sub(s1, r2); + move32(); + + /* 4. FFT3 stage */ + + /* real part */ + r1 = L_add(y16, y26); + r2 = Mpy_32_xx(L_sub(y16, y26), C31); + re[s * 3] = L_add(y06, r1); + move32(); + r1 = L_sub(y06, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y17, y27); + s2 = Mpy_32_xx(L_sub(y17, y27), C31); + im[s * 3] = L_add(y07, s1); + move32(); + s1 = L_sub(y07, L_shr_pos(s1, 1)); + + /* combination */ + re[s * 13] = L_sub(r1, s2); + move32(); + re[s * 8] = L_add(r1, s2); + move32(); + im[s * 13] = L_add(s1, r2); + move32(); + im[s * 8] = L_sub(s1, r2); + move32(); + + /* 5. FFT3 stage */ + + /* real part */ + r1 = L_add(y18, y28); + r2 = Mpy_32_xx(L_sub(y18, y28), C31); + re[s * 9] = L_add(y08, r1); + move32(); + r1 = L_sub(y08, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y19, y29); + s2 = Mpy_32_xx(L_sub(y19, y29), C31); + im[s * 9] = L_add(y09, s1); + move32(); + s1 = L_sub(y09, L_shr_pos(s1, 1)); + + /* combination */ + re[s * 4] = L_sub(r1, s2); + move32(); + re[s * 14] = L_add(r1, s2); + move32(); + im[s * 4] = L_add(s1, r2); + move32(); + im[s * 14] = L_sub(s1, r2); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +#ifdef CR8_G_ADD_75MS + +#define STC(x) (x) +const Word32 RotVectorReal12[] = +{ + STC(0x6ed9eba1), STC(0x40000000), + STC(0x40000000), STC(0xc0000000), +#ifndef FFT12_UNROLLED_ENABLE + STC(0x00000000), STC(0x80000000), +#endif +}; + +const Word32 RotVectorImag12[] = +{ + STC(0x40000000), STC(0x6ed9eba1), + STC(0x6ed9eba1), STC(0x6ed9eba1), +#ifndef FFT12_UNROLLED_ENABLE + STC(0x7fffffff), STC(0x00000000), +#endif +}; + +static void fft12(Word32 *pInput) +{ + Dyn_Mem_Deluxe_In(Word32 aDst[24]; Word32 * pSrc, *pDst; Counter i; Word32 r1, r2, s1, s2, pD; Word32 re, im; + Word32 vre, vim;); + + pSrc = pInput; + move16(); + pDst = aDst; + move16(); + + /* First 3*2 samples are shifted right by 2 before output */ + r1 = L_add(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)); + r2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)), C31); + pD = L_shr_pos(pSrc[0], 2); + pDst[0] = L_shr_pos(L_add(pD, r1), 1); + r1 = L_sub(pD, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)); + s2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)), C31); + pD = L_shr_pos(pSrc[1], 2); + pDst[1] = L_shr_pos(L_add(pD, s1), 1); + s1 = L_sub(pD, L_shr_pos(s1, 1)); + + r1 = L_shr_pos(r1, 1); + r2 = L_shr_pos(r2, 1); + s1 = L_shr_pos(s1, 1); + s2 = L_shr_pos(s2, 1); + + /* combination */ + pDst[2] = L_sub(r1, s2); + pDst[3] = L_add(s1, r2); + pDst[4] = L_add(r1, s2); + pDst[5] = L_sub(s1, r2); + pSrc += 2; + pDst += 6; + + const Word32 *pVecRe = RotVectorReal12; + const Word32 *pVecIm = RotVectorImag12; + + + + FOR (i = 0; i < 2; i++) + { + /* sample 0,1 are shifted right by 2 before output */ + /* sample 2,3 4,5 are shifted right by 1 and complex multiplied before output */ + + r1 = L_add(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)); + r2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)), C31); + pD = L_shr_pos(pSrc[0], 2); + pDst[0] = L_shr_pos(L_add(pD, r1), 1); + r1 = L_sub(pD, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)); + s2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)), C31); + pD = L_shr_pos(pSrc[1], 2); + pDst[1] = L_shr_pos(L_add(pD, s1), 1); + s1 = L_sub(pD, L_shr_pos(s1, 1)); + + r1 = L_shr_pos(r1, 1); + r2 = L_shr_pos(r2, 1); + s1 = L_shr_pos(s1, 1); + s2 = L_shr_pos(s2, 1); + + /* combination */ + re = L_sub(r1, s2); + im = L_add(s1, r2); + vre = *pVecRe++; + vim = *pVecIm++; + cplxMpy_32_32(&pDst[3], &pDst[2], im, re, vre, vim); + + re = L_add(r1, s2); + im = L_sub(s1, r2); + + vre = *pVecRe++; + vim = *pVecIm++; + cplxMpy_32_32(&pDst[5], &pDst[4], im, re, vre, vim); + + pDst += 6; + pSrc += 2; + } + /* sample 0,1 are shifted right by 2 before output */ + /* sample 2,3 is shifted right by 1 and complex multiplied with (0.0,+1.0) */ + /* sample 4,5 is shifted right by 1 and complex multiplied with (-1.0,0.0) */ + r1 = L_add(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)); + r2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)), C31); + pD = L_shr_pos(pSrc[0], 2); + pDst[0] = L_shr_pos(L_add(pD, r1), 1); + r1 = L_sub(pD, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)); + s2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)), C31); + pD = L_shr_pos(pSrc[1], 2); + pDst[1] = L_shr_pos(L_add(pD, s1), 1); + s1 = L_sub(pD, L_shr_pos(s1, 1)); + + r1 = L_shr_pos(r1, 1); + r2 = L_shr_pos(r2, 1); + s1 = L_shr_pos(s1, 1); + s2 = L_shr_pos(s2, 1); + + /* combination */ + + pDst[2] = L_add(s1, r2); + move32(); + pDst[3] = L_sub(s2, r1); + move32(); + pDst[4] = L_negate(L_add(r1, s2)); + move32(); + pDst[5] = L_sub(r2, s1); + move32(); + /* Perform 3 times the fft of length 4. The input samples are at the address of aDst and the + output samples are at the address of pInput. The input vector for the fft of length 4 is built + of the interleaved samples in aDst, the output samples are stored consecutively at the address + of pInput. + */ + move16(); + move16(); + pSrc = aDst; + pDst = pInput; + FOR (i = 0; i < 3; i++) + { + /* inline FFT4 merged with incoming resorting loop */ + r1 = L_add(L_shr_pos(pSrc[0], 2), L_shr_pos(pSrc[12], 2)); /* Re A + Re B */ + r2 = L_add(L_shr_pos(pSrc[6], 2), L_shr_pos(pSrc[18], 2)); /* Re C + Re D */ + s1 = L_add(L_shr_pos(pSrc[1], 2), L_shr_pos(pSrc[13], 2)); /* Im A + Im B */ + s2 = L_add(L_shr_pos(pSrc[7], 2), L_shr_pos(pSrc[19], 2)); /* Im C + Im D */ + + pDst[0] = L_add(r1, r2); /* Re A' = Re A + Re B + Re C + Re D */ + pDst[1] = L_add(s1, s2); /* Im A' = Im A + Im B + Im C + Im D */ + + re = L_sub(r1, L_shr_pos(pSrc[12], 1)); /* Re A - Re B */ + im = L_sub(s1, L_shr_pos(pSrc[13], 1)); /* Im A - Im B */ + + pDst[12] = L_sub(r1, r2); /* Re C' = Re A + Re B - Re C - Re D */ + pDst[13] = L_sub(s1, s2); /* Im C' = Im A + Im B - Im C - Im D */ + + r2 = L_sub(r2, L_shr_pos(pSrc[18], 1)); /* Re C - Re D */ + s2 = L_sub(s2, L_shr_pos(pSrc[19], 1)); /* Im C - Im D */ + + pDst[6] = L_add(re, s2); /* Re B' = Re A - Re B + Im C - Im D */ + pDst[18] = L_sub(re, s2); /* Re D' = Re A - Re B - Im C + Im D */ + pDst[7] = L_sub(im, r2); /* Im B' = Im A - Im B - Re C + Re D */ + pDst[19] = L_add(im, r2); /* Im D' = Im A - Im B + Re C - Re D */ + + pSrc += 2; + pDst += 2; + } + + Dyn_Mem_Deluxe_Out(); +} + +#else /* CR8_G_ADD_75MS */ + +static void fft12(Word32 *pInput) +{ + Dyn_Mem_Deluxe_In(Word32 aDst[24]; Word32 * pSrc, *pDst; Counter i; Word32 r1, r2, s1, s2, pD; Word32 re, im; + Word16 vre, vim;); + + pSrc = pInput; + move16(); + pDst = aDst; + move16(); + + /* First 3*2 samples are shifted right by 2 before output */ + r1 = L_add(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)); + r2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)), C31); + pD = L_shr_pos(pSrc[0], 2); + pDst[0] = L_shr_pos(L_add(pD, r1), 1); + r1 = L_sub(pD, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)); + s2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)), C31); + pD = L_shr_pos(pSrc[1], 2); + pDst[1] = L_shr_pos(L_add(pD, s1), 1); + s1 = L_sub(pD, L_shr_pos(s1, 1)); + + r1 = L_shr_pos(r1, 1); + r2 = L_shr_pos(r2, 1); + s1 = L_shr_pos(s1, 1); + s2 = L_shr_pos(s2, 1); + + /* combination */ + pDst[2] = L_sub(r1, s2); + pDst[3] = L_add(s1, r2); + pDst[4] = L_add(r1, s2); + pDst[5] = L_sub(s1, r2); + pSrc += 2; + pDst += 6; + + vre = add(0x6eda, 0); + vim = add(0x4000, 0); + + FOR (i = 0; i < 2; i++) + { + /* sample 0,1 are shifted right by 2 before output */ + /* sample 2,3 4,5 are shifted right by 1 and complex multiplied before output */ + + r1 = L_add(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)); + r2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)), C31); + pD = L_shr_pos(pSrc[0], 2); + pDst[0] = L_shr_pos(L_add(pD, r1), 1); + r1 = L_sub(pD, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)); + s2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)), C31); + pD = L_shr_pos(pSrc[1], 2); + pDst[1] = L_shr_pos(L_add(pD, s1), 1); + s1 = L_sub(pD, L_shr_pos(s1, 1)); + + r1 = L_shr_pos(r1, 1); + r2 = L_shr_pos(r2, 1); + s1 = L_shr_pos(s1, 1); + s2 = L_shr_pos(s2, 1); + + /* combination */ + re = L_sub(r1, s2); + im = L_add(s1, r2); + cplxMpy_32_16(&pDst[3], &pDst[2], im, re, vre, vim); + re = L_add(r1, s2); + im = L_sub(s1, r2); + vre = add(0x4000, 0); + if (i == 1) + vre = negate(vre); /* 0xC000 */ + if (i == 0) + vim = add(0x6eda, 0); + cplxMpy_32_16(&pDst[5], &pDst[4], im, re, vre, vim); + + pDst += 6; + pSrc += 2; + } + /* sample 0,1 are shifted right by 2 before output */ + /* sample 2,3 is shifted right by 1 and complex multiplied with (0.0,+1.0) */ + /* sample 4,5 is shifted right by 1 and complex multiplied with (-1.0,0.0) */ + r1 = L_add(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)); + r2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[8], 2), L_shr_pos(pSrc[16], 2)), C31); + pD = L_shr_pos(pSrc[0], 2); + pDst[0] = L_shr_pos(L_add(pD, r1), 1); + r1 = L_sub(pD, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)); + s2 = Mpy_32_xx(L_sub(L_shr_pos(pSrc[9], 2), L_shr_pos(pSrc[17], 2)), C31); + pD = L_shr_pos(pSrc[1], 2); + pDst[1] = L_shr_pos(L_add(pD, s1), 1); + s1 = L_sub(pD, L_shr_pos(s1, 1)); + + r1 = L_shr_pos(r1, 1); + r2 = L_shr_pos(r2, 1); + s1 = L_shr_pos(s1, 1); + s2 = L_shr_pos(s2, 1); + + /* combination */ + + pDst[2] = L_add(s1, r2); + move32(); + pDst[3] = L_sub(s2, r1); + move32(); + pDst[4] = L_negate(L_add(r1, s2)); + move32(); + pDst[5] = L_sub(r2, s1); + move32(); + /* Perform 3 times the fft of length 4. The input samples are at the address of aDst and the + output samples are at the address of pInput. The input vector for the fft of length 4 is built + of the interleaved samples in aDst, the output samples are stored consecutively at the address + of pInput. + */ + move16(); + move16(); + pSrc = aDst; + pDst = pInput; + FOR (i = 0; i < 3; i++) + { + /* inline FFT4 merged with incoming resorting loop */ + r1 = L_add(L_shr_pos(pSrc[0], 2), L_shr_pos(pSrc[12], 2)); /* Re A + Re B */ + r2 = L_add(L_shr_pos(pSrc[6], 2), L_shr_pos(pSrc[18], 2)); /* Re C + Re D */ + s1 = L_add(L_shr_pos(pSrc[1], 2), L_shr_pos(pSrc[13], 2)); /* Im A + Im B */ + s2 = L_add(L_shr_pos(pSrc[7], 2), L_shr_pos(pSrc[19], 2)); /* Im C + Im D */ + + pDst[0] = L_add(r1, r2); /* Re A' = Re A + Re B + Re C + Re D */ + pDst[1] = L_add(s1, s2); /* Im A' = Im A + Im B + Im C + Im D */ + + re = L_sub(r1, L_shr_pos(pSrc[12], 1)); /* Re A - Re B */ + im = L_sub(s1, L_shr_pos(pSrc[13], 1)); /* Im A - Im B */ + + pDst[12] = L_sub(r1, r2); /* Re C' = Re A + Re B - Re C - Re D */ + pDst[13] = L_sub(s1, s2); /* Im C' = Im A + Im B - Im C - Im D */ + + r2 = L_sub(r2, L_shr_pos(pSrc[18], 1)); /* Re C - Re D */ + s2 = L_sub(s2, L_shr_pos(pSrc[19], 1)); /* Im C - Im D */ + + pDst[6] = L_add(re, s2); /* Re B' = Re A - Re B + Im C - Im D */ + pDst[18] = L_sub(re, s2); /* Re D' = Re A - Re B - Im C + Im D */ + pDst[7] = L_sub(im, r2); /* Im B' = Im A - Im B - Re C + Re D */ + pDst[19] = L_add(im, r2); /* Im D' = Im A - Im B + Re C - Re D */ + + pSrc += 2; + pDst += 2; + } + + Dyn_Mem_Deluxe_Out(); +} + +#endif + +/** + * \brief Function performs a complex 16-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR16 bits. + * + * WOPS with 32x16 bit multiplications (scale on ): 288 cycles + * WOPS with 32x16 bit multiplications (scale off): 256 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + + +static void fft16(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 x0, x1, x2, x3, x4, x5, x6, x7; Word32 t0, t1, t2, t3, t4, t5, t6, t7; + Word32 y00, y01, y02, y03, y04, y05, y06, y07; Word32 y08, y09, y10, y11, y12, y13, y14, y15; + Word32 y16, y17, y18, y19, y20, y21, y22, y23; Word32 y24, y25, y26, y27, y28, y29, y30, y31;); + + x0 = L_shr_pos(re[s * 0], SCALEFACTOR16); + x1 = L_shr_pos(im[s * 0], SCALEFACTOR16); + x2 = L_shr_pos(re[s * 4], SCALEFACTOR16); + x3 = L_shr_pos(im[s * 4], SCALEFACTOR16); + x4 = L_shr_pos(re[s * 8], SCALEFACTOR16); + x5 = L_shr_pos(im[s * 8], SCALEFACTOR16); + x6 = L_shr_pos(re[s * 12], SCALEFACTOR16); + x7 = L_shr_pos(im[s * 12], SCALEFACTOR16); + + /* Pre-additions */ + t0 = L_add(x0, x4); + t2 = L_sub(x0, x4); + t1 = L_add(x1, x5); + t3 = L_sub(x1, x5); + t4 = L_add(x2, x6); + t7 = L_sub(x2, x6); + t5 = L_add(x7, x3); + t6 = L_sub(x7, x3); + + /* Post-additions */ + y00 = L_add(t0, t4); + y01 = L_add(t1, t5); + y02 = L_sub(t2, t6); + y03 = L_sub(t3, t7); + y04 = L_sub(t0, t4); + y05 = L_sub(t1, t5); + y06 = L_add(t2, t6); + y07 = L_add(t3, t7); + + x0 = L_shr_pos(re[s * 1], SCALEFACTOR16); + x1 = L_shr_pos(im[s * 1], SCALEFACTOR16); + x2 = L_shr_pos(re[s * 5], SCALEFACTOR16); + x3 = L_shr_pos(im[s * 5], SCALEFACTOR16); + x4 = L_shr_pos(re[s * 9], SCALEFACTOR16); + x5 = L_shr_pos(im[s * 9], SCALEFACTOR16); + x6 = L_shr_pos(re[s * 13], SCALEFACTOR16); + x7 = L_shr_pos(im[s * 13], SCALEFACTOR16); + + /* Pre-additions */ + t0 = L_add(x0, x4); + t2 = L_sub(x0, x4); + t1 = L_add(x1, x5); + t3 = L_sub(x1, x5); + t4 = L_add(x2, x6); + t7 = L_sub(x2, x6); + t5 = L_add(x7, x3); + t6 = L_sub(x7, x3); + + /* Post-additions */ + y08 = L_add(t0, t4); + y09 = L_add(t1, t5); + y10 = L_sub(t2, t6); + y11 = L_sub(t3, t7); + y12 = L_sub(t0, t4); + y13 = L_sub(t1, t5); + y14 = L_add(t2, t6); + y15 = L_add(t3, t7); + + x0 = L_shr_pos(re[s * 2], SCALEFACTOR16); + x1 = L_shr_pos(im[s * 2], SCALEFACTOR16); + x2 = L_shr_pos(re[s * 6], SCALEFACTOR16); + x3 = L_shr_pos(im[s * 6], SCALEFACTOR16); + x4 = L_shr_pos(re[s * 10], SCALEFACTOR16); + x5 = L_shr_pos(im[s * 10], SCALEFACTOR16); + x6 = L_shr_pos(re[s * 14], SCALEFACTOR16); + x7 = L_shr_pos(im[s * 14], SCALEFACTOR16); + + /* Pre-additions */ + t0 = L_add(x0, x4); + t2 = L_sub(x0, x4); + t1 = L_add(x1, x5); + t3 = L_sub(x1, x5); + t4 = L_add(x2, x6); + t7 = L_sub(x2, x6); + t5 = L_add(x7, x3); + t6 = L_sub(x7, x3); + + /* Post-additions */ + y16 = L_add(t0, t4); + y17 = L_add(t1, t5); + y18 = L_sub(t2, t6); + y19 = L_sub(t3, t7); + y20 = L_sub(t1, t5); + y21 = L_sub(t4, t0); + y22 = L_add(t2, t6); + y23 = L_add(t3, t7); + + x0 = L_shr_pos(re[s * 3], SCALEFACTOR16); + x1 = L_shr_pos(im[s * 3], SCALEFACTOR16); + x2 = L_shr_pos(re[s * 7], SCALEFACTOR16); + x3 = L_shr_pos(im[s * 7], SCALEFACTOR16); + x4 = L_shr_pos(re[s * 11], SCALEFACTOR16); + x5 = L_shr_pos(im[s * 11], SCALEFACTOR16); + x6 = L_shr_pos(re[s * 15], SCALEFACTOR16); + x7 = L_shr_pos(im[s * 15], SCALEFACTOR16); + + /* Pre-additions */ + t0 = L_add(x0, x4); + t2 = L_sub(x0, x4); + t1 = L_add(x1, x5); + t3 = L_sub(x1, x5); + t4 = L_add(x2, x6); + t7 = L_sub(x2, x6); + t5 = L_add(x7, x3); + t6 = L_sub(x7, x3); + + /* Post-additions */ + y24 = L_add(t0, t4); + y25 = L_add(t1, t5); + y26 = L_sub(t2, t6); + y27 = L_sub(t3, t7); + y28 = L_sub(t0, t4); + y29 = L_sub(t1, t5); + y30 = L_add(t2, t6); + y31 = L_add(t3, t7); + + /* rotation */ + + x0 = Mpy_32_xx(y22, C162); + x1 = Mpy_32_xx(y23, C162); + y22 = L_sub(x0, x1); + y23 = L_add(x0, x1); + + x0 = Mpy_32_xx(y28, C162); + x1 = Mpy_32_xx(y29, C162); + y28 = L_sub(x0, x1); + y29 = L_add(x0, x1); + + x0 = Mpy_32_xx(y12, C161); + x1 = Mpy_32_xx(y13, C161); + y12 = L_add(x0, x1); + y13 = L_sub(x1, x0); + + x0 = Mpy_32_xx(y18, C161); + x1 = Mpy_32_xx(y19, C161); + y18 = L_add(x0, x1); + y19 = L_sub(x1, x0); + + x0 = Mpy_32_xx(y10, C163); + x1 = Mpy_32_xx(y11, C166); + x2 = Mpy_32_xx(y10, C166); + x3 = Mpy_32_xx(y11, C163); + y10 = L_sub(x0, x1); + y11 = L_add(x2, x3); + + x0 = Mpy_32_xx(y14, C165); + x1 = Mpy_32_xx(y15, C164); + x2 = Mpy_32_xx(y14, C164); + x3 = Mpy_32_xx(y15, C165); + y14 = L_sub(x0, x1); + y15 = L_add(x2, x3); + + x0 = Mpy_32_xx(y26, C165); + x1 = Mpy_32_xx(y27, C164); + x2 = Mpy_32_xx(y26, C164); + x3 = Mpy_32_xx(y27, C165); + y26 = L_sub(x0, x1); + y27 = L_add(x2, x3); + + x0 = Mpy_32_xx(y30, C164); + x1 = Mpy_32_xx(y31, C165); + x2 = Mpy_32_xx(y30, C165); + x3 = Mpy_32_xx(y31, C164); + y30 = L_sub(x0, x1); + y31 = L_add(x2, x3); + + /* Pre-additions */ + + t0 = L_add(y00, y16); + t2 = L_sub(y00, y16); + t1 = L_add(y01, y17); + t3 = L_sub(y01, y17); + t4 = L_add(y08, y24); + t7 = L_sub(y08, y24); + t5 = L_add(y25, y09); + t6 = L_sub(y25, y09); + + /* Post-additions */ + + re[s * 0] = L_add(t0, t4); + move32(); + im[s * 0] = L_add(t1, t5); + move32(); + re[s * 4] = L_sub(t2, t6); + move32(); + im[s * 4] = L_sub(t3, t7); + move32(); + re[s * 8] = L_sub(t0, t4); + move32(); + im[s * 8] = L_sub(t1, t5); + move32(); + re[s * 12] = L_add(t2, t6); + move32(); + im[s * 12] = L_add(t3, t7); + move32(); + + /* Pre-additions */ + + t0 = L_add(y02, y18); + t2 = L_sub(y02, y18); + t1 = L_add(y03, y19); + t3 = L_sub(y03, y19); + t4 = L_add(y10, y26); + t7 = L_sub(y10, y26); + t5 = L_add(y27, y11); + t6 = L_sub(y27, y11); + + /* Post-additions */ + + re[s * 1] = L_add(t0, t4); + move32(); + im[s * 1] = L_add(t1, t5); + move32(); + re[s * 5] = L_sub(t2, t6); + move32(); + im[s * 5] = L_sub(t3, t7); + move32(); + re[s * 9] = L_sub(t0, t4); + move32(); + im[s * 9] = L_sub(t1, t5); + move32(); + re[s * 13] = L_add(t2, t6); + move32(); + im[s * 13] = L_add(t3, t7); + move32(); + + /* Pre-additions */ + + t0 = L_add(y04, y20); + t2 = L_sub(y04, y20); + t1 = L_add(y05, y21); + t3 = L_sub(y05, y21); + t4 = L_add(y12, y28); + t7 = L_sub(y12, y28); + t5 = L_add(y29, y13); + t6 = L_sub(y29, y13); + + /* Post-additions */ + + re[s * 2] = L_add(t0, t4); + move32(); + im[s * 2] = L_add(t1, t5); + move32(); + re[s * 6] = L_sub(t2, t6); + move32(); + im[s * 6] = L_sub(t3, t7); + move32(); + re[s * 10] = L_sub(t0, t4); + move32(); + im[s * 10] = L_sub(t1, t5); + move32(); + re[s * 14] = L_add(t2, t6); + move32(); + im[s * 14] = L_add(t3, t7); + move32(); + + /* Pre-additions */ + + t0 = L_add(y06, y22); + t2 = L_sub(y06, y22); + t1 = L_add(y07, y23); + t3 = L_sub(y07, y23); + t4 = L_add(y14, y30); + t7 = L_sub(y14, y30); + t5 = L_add(y31, y15); + t6 = L_sub(y31, y15); + + /* Post-additions */ + + re[s * 3] = L_add(t0, t4); + move32(); + im[s * 3] = L_add(t1, t5); + move32(); + re[s * 7] = L_sub(t2, t6); + move32(); + im[s * 7] = L_sub(t3, t7); + move32(); + re[s * 11] = L_sub(t0, t4); + move32(); + im[s * 11] = L_sub(t1, t5); + move32(); + re[s * 15] = L_add(t2, t6); + move32(); + im[s * 15] = L_add(t3, t7); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 20-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR20 bits. + * + * WOPS with 32x16 bit multiplications: 432 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + +static void fft20(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 r1, r2, r3, r4; Word32 s1, s2, s3, s4; Word32 x0, x1, x2, x3, x4; + Word32 t, t0, t1, t2, t3, t4, t5, t6, t7; Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + Word32 y20, y21, y22, y23, y24, y25, y26, y27, y28, y29; + Word32 y30, y31, y32, y33, y34, y35, y36, y37, y38, y39;); + + /* 1. FFT5 stage */ + + /* real part */ + x0 = L_shr_pos(re[s * 0], SCALEFACTOR20); + x1 = L_shr_pos(re[s * 16], SCALEFACTOR20); + x2 = L_shr_pos(re[s * 12], SCALEFACTOR20); + x3 = L_shr_pos(re[s * 8], SCALEFACTOR20); + x4 = L_shr_pos(re[s * 4], SCALEFACTOR20); + + r1 = L_add(x1, x4); + r4 = L_sub(x1, x4); + r3 = L_add(x2, x3); + r2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y00 = L_add(x0, r1); + r1 = L_add(y00, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 0], SCALEFACTOR20); + x1 = L_shr_pos(im[s * 16], SCALEFACTOR20); + x2 = L_shr_pos(im[s * 12], SCALEFACTOR20); + x3 = L_shr_pos(im[s * 8], SCALEFACTOR20); + x4 = L_shr_pos(im[s * 4], SCALEFACTOR20); + + s1 = L_add(x1, x4); + s4 = L_sub(x1, x4); + s3 = L_add(x2, x3); + s2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y01 = L_add(x0, s1); + s1 = L_add(y01, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y08 = L_add(r1, s2); + y32 = L_sub(r1, s2); + y16 = L_sub(r3, s4); + y24 = L_add(r3, s4); + + y09 = L_sub(s1, r2); + y33 = L_add(s1, r2); + y17 = L_add(s3, r4); + y25 = L_sub(s3, r4); + + /* 2. FFT5 stage */ + + /* real part */ + x0 = L_shr_pos(re[s * 5], SCALEFACTOR20); + x1 = L_shr_pos(re[s * 1], SCALEFACTOR20); + x2 = L_shr_pos(re[s * 17], SCALEFACTOR20); + x3 = L_shr_pos(re[s * 13], SCALEFACTOR20); + x4 = L_shr_pos(re[s * 9], SCALEFACTOR20); + + r1 = L_add(x1, x4); + r4 = L_sub(x1, x4); + r3 = L_add(x2, x3); + r2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y02 = L_add(x0, r1); + r1 = L_add(y02, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 5], SCALEFACTOR20); + x1 = L_shr_pos(im[s * 1], SCALEFACTOR20); + x2 = L_shr_pos(im[s * 17], SCALEFACTOR20); + x3 = L_shr_pos(im[s * 13], SCALEFACTOR20); + x4 = L_shr_pos(im[s * 9], SCALEFACTOR20); + + s1 = L_add(x1, x4); + s4 = L_sub(x1, x4); + s3 = L_add(x2, x3); + s2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y03 = L_add(x0, s1); + s1 = L_add(y03, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y10 = L_add(r1, s2); + y34 = L_sub(r1, s2); + y18 = L_sub(r3, s4); + y26 = L_add(r3, s4); + + y11 = L_sub(s1, r2); + y35 = L_add(s1, r2); + y19 = L_add(s3, r4); + y27 = L_sub(s3, r4); + + /* 3. FFT5 stage */ + + /* real part */ + x0 = L_shr_pos(re[s * 10], SCALEFACTOR20); + x1 = L_shr_pos(re[s * 6], SCALEFACTOR20); + x2 = L_shr_pos(re[s * 2], SCALEFACTOR20); + x3 = L_shr_pos(re[s * 18], SCALEFACTOR20); + x4 = L_shr_pos(re[s * 14], SCALEFACTOR20); + + r1 = L_add(x1, x4); + r4 = L_sub(x1, x4); + r3 = L_add(x2, x3); + r2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y04 = L_add(x0, r1); + r1 = L_add(y04, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 10], SCALEFACTOR20); + x1 = L_shr_pos(im[s * 6], SCALEFACTOR20); + x2 = L_shr_pos(im[s * 2], SCALEFACTOR20); + x3 = L_shr_pos(im[s * 18], SCALEFACTOR20); + x4 = L_shr_pos(im[s * 14], SCALEFACTOR20); + + s1 = L_add(x1, x4); + s4 = L_sub(x1, x4); + s3 = L_add(x2, x3); + s2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y05 = L_add(x0, s1); + s1 = L_add(y05, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y12 = L_add(r1, s2); + y36 = L_sub(r1, s2); + y20 = L_sub(r3, s4); + y28 = L_add(r3, s4); + + y13 = L_sub(s1, r2); + y37 = L_add(s1, r2); + y21 = L_add(s3, r4); + y29 = L_sub(s3, r4); + + /* 4. FFT5 stage */ + + /* real part */ + x0 = L_shr_pos(re[s * 15], SCALEFACTOR20); + x1 = L_shr_pos(re[s * 11], SCALEFACTOR20); + x2 = L_shr_pos(re[s * 7], SCALEFACTOR20); + x3 = L_shr_pos(re[s * 3], SCALEFACTOR20); + x4 = L_shr_pos(re[s * 19], SCALEFACTOR20); + + r1 = L_add(x1, x4); + r4 = L_sub(x1, x4); + r3 = L_add(x2, x3); + r2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y06 = L_add(x0, r1); + r1 = L_add(y06, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + x0 = L_shr_pos(im[s * 15], SCALEFACTOR20); + x1 = L_shr_pos(im[s * 11], SCALEFACTOR20); + x2 = L_shr_pos(im[s * 7], SCALEFACTOR20); + x3 = L_shr_pos(im[s * 3], SCALEFACTOR20); + x4 = L_shr_pos(im[s * 19], SCALEFACTOR20); + + s1 = L_add(x1, x4); + s4 = L_sub(x1, x4); + s3 = L_add(x2, x3); + s2 = L_sub(x2, x3); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y07 = L_add(x0, s1); + s1 = L_add(y07, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y14 = L_add(r1, s2); + y38 = L_sub(r1, s2); + y22 = L_sub(r3, s4); + y30 = L_add(r3, s4); + + y15 = L_sub(s1, r2); + y39 = L_add(s1, r2); + y23 = L_add(s3, r4); + y31 = L_sub(s3, r4); + + /* 1. FFT4 stage */ + + /* Pre-additions */ + t0 = L_add(y00, y04); + t2 = L_sub(y00, y04); + t1 = L_add(y01, y05); + t3 = L_sub(y01, y05); + t4 = L_add(y02, y06); + t7 = L_sub(y02, y06); + t5 = L_add(y07, y03); + t6 = L_sub(y07, y03); + + /* Post-additions */ + re[s * 0] = L_add(t0, t4); + move32(); + im[s * 0] = L_add(t1, t5); + move32(); + re[s * 5] = L_sub(t2, t6); + move32(); + im[s * 5] = L_sub(t3, t7); + move32(); + re[s * 10] = L_sub(t0, t4); + move32(); + im[s * 10] = L_sub(t1, t5); + move32(); + re[s * 15] = L_add(t2, t6); + move32(); + im[s * 15] = L_add(t3, t7); + move32(); + + /* 2. FFT4 stage */ + + /* Pre-additions */ + t0 = L_add(y08, y12); + t2 = L_sub(y08, y12); + t1 = L_add(y09, y13); + t3 = L_sub(y09, y13); + t4 = L_add(y10, y14); + t7 = L_sub(y10, y14); + t5 = L_add(y15, y11); + t6 = L_sub(y15, y11); + + /* Post-additions */ + re[s * 4] = L_add(t0, t4); + move32(); + im[s * 4] = L_add(t1, t5); + move32(); + re[s * 9] = L_sub(t2, t6); + move32(); + im[s * 9] = L_sub(t3, t7); + move32(); + re[s * 14] = L_sub(t0, t4); + move32(); + im[s * 14] = L_sub(t1, t5); + move32(); + re[s * 19] = L_add(t2, t6); + move32(); + im[s * 19] = L_add(t3, t7); + move32(); + + /* 3. FFT4 stage */ + + /* Pre-additions */ + t0 = L_add(y16, y20); + t2 = L_sub(y16, y20); + t1 = L_add(y17, y21); + t3 = L_sub(y17, y21); + t4 = L_add(y18, y22); + t7 = L_sub(y18, y22); + t5 = L_add(y23, y19); + t6 = L_sub(y23, y19); + + /* Post-additions */ + re[s * 8] = L_add(t0, t4); + move32(); + im[s * 8] = L_add(t1, t5); + move32(); + re[s * 13] = L_sub(t2, t6); + move32(); + im[s * 13] = L_sub(t3, t7); + move32(); + re[s * 18] = L_sub(t0, t4); + move32(); + im[s * 18] = L_sub(t1, t5); + move32(); + re[s * 3] = L_add(t2, t6); + move32(); + im[s * 3] = L_add(t3, t7); + move32(); + + /* 4. FFT4 stage */ + + /* Pre-additions */ + t0 = L_add(y24, y28); + t2 = L_sub(y24, y28); + t1 = L_add(y25, y29); + t3 = L_sub(y25, y29); + t4 = L_add(y26, y30); + t7 = L_sub(y26, y30); + t5 = L_add(y31, y27); + t6 = L_sub(y31, y27); + + /* Post-additions */ + re[s * 12] = L_add(t0, t4); + move32(); + im[s * 12] = L_add(t1, t5); + move32(); + re[s * 17] = L_sub(t2, t6); + move32(); + im[s * 17] = L_sub(t3, t7); + move32(); + re[s * 2] = L_sub(t0, t4); + move32(); + im[s * 2] = L_sub(t1, t5); + move32(); + re[s * 7] = L_add(t2, t6); + move32(); + im[s * 7] = L_add(t3, t7); + move32(); + + /* 5. FFT4 stage */ + + /* Pre-additions */ + t0 = L_add(y32, y36); + t2 = L_sub(y32, y36); + t1 = L_add(y33, y37); + t3 = L_sub(y33, y37); + t4 = L_add(y34, y38); + t7 = L_sub(y34, y38); + t5 = L_add(y39, y35); + t6 = L_sub(y39, y35); + + /* Post-additions */ + re[s * 16] = L_add(t0, t4); + move32(); + im[s * 16] = L_add(t1, t5); + move32(); + re[s * 1] = L_sub(t2, t6); + move32(); + im[s * 1] = L_sub(t3, t7); + move32(); + re[s * 6] = L_sub(t0, t4); + move32(); + im[s * 6] = L_sub(t1, t5); + move32(); + re[s * 11] = L_add(t2, t6); + move32(); + im[s * 11] = L_add(t3, t7); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 30-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR30 bits. + * + * WOPS with 32x16 bit multiplications: 828 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + +static void fft30(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 t; Word32 r1, r2, r3, r4; Word32 s1, s2, s3, s4; + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09; + Word32 x10, x11, x12, x13, x14, x15, x16, x17, x18, x19; + Word32 x20, x21, x22, x23, x24, x25, x26, x27, x28, x29; + + Word32 y00, y01, y02, y03, y04, y05, y06, y07, y08, y09; + Word32 y10, y11, y12, y13, y14, y15, y16, y17, y18, y19; + Word32 y20, y21, y22, y23, y24, y25, y26, y27, y28, y29; + + Word32 z00, z01, z02, z03, z04, z05, z06, z07, z08, z09; + Word32 z10, z11, z12, z13, z14, z15, z16, z17, z18, z19; + Word32 z20, z21, z22, z23, z24, z25, z26, z27, z28, z29; + Word32 z30, z31, z32, z33, z34, z35, z36, z37, z38, z39; + Word32 z40, z41, z42, z43, z44, z45, z46, z47, z48, z49; + Word32 z50, z51, z52, z53, z54, z55, z56, z57, z58, z59; + + Word32 * rel, *reh, *iml, *imh;); + + rel = &re[s * 0]; + reh = &re[s * 15]; + iml = &im[s * 0]; + imh = &im[s * 15]; + + /* 1. FFT15 stage */ + x00 = L_shr_pos(re[s * 0], SCALEFACTOR30_1); + x01 = L_shr_pos(im[s * 0], SCALEFACTOR30_1); + x02 = L_shr_pos(re[s * 18], SCALEFACTOR30_1); + x03 = L_shr_pos(im[s * 18], SCALEFACTOR30_1); + x04 = L_shr_pos(re[s * 6], SCALEFACTOR30_1); + x05 = L_shr_pos(im[s * 6], SCALEFACTOR30_1); + x06 = L_shr_pos(re[s * 24], SCALEFACTOR30_1); + x07 = L_shr_pos(im[s * 24], SCALEFACTOR30_1); + x08 = L_shr_pos(re[s * 12], SCALEFACTOR30_1); + x09 = L_shr_pos(im[s * 12], SCALEFACTOR30_1); + + x10 = L_shr_pos(re[s * 20], SCALEFACTOR30_1); + x11 = L_shr_pos(im[s * 20], SCALEFACTOR30_1); + x12 = L_shr_pos(re[s * 8], SCALEFACTOR30_1); + x13 = L_shr_pos(im[s * 8], SCALEFACTOR30_1); + x14 = L_shr_pos(re[s * 26], SCALEFACTOR30_1); + x15 = L_shr_pos(im[s * 26], SCALEFACTOR30_1); + x16 = L_shr_pos(re[s * 14], SCALEFACTOR30_1); + x17 = L_shr_pos(im[s * 14], SCALEFACTOR30_1); + x18 = L_shr_pos(re[s * 2], SCALEFACTOR30_1); + x19 = L_shr_pos(im[s * 2], SCALEFACTOR30_1); + + x20 = L_shr_pos(re[s * 10], SCALEFACTOR30_1); + x21 = L_shr_pos(im[s * 10], SCALEFACTOR30_1); + x22 = L_shr_pos(re[s * 28], SCALEFACTOR30_1); + x23 = L_shr_pos(im[s * 28], SCALEFACTOR30_1); + x24 = L_shr_pos(re[s * 16], SCALEFACTOR30_1); + x25 = L_shr_pos(im[s * 16], SCALEFACTOR30_1); + x26 = L_shr_pos(re[s * 4], SCALEFACTOR30_1); + x27 = L_shr_pos(im[s * 4], SCALEFACTOR30_1); + x28 = L_shr_pos(re[s * 22], SCALEFACTOR30_1); + x29 = L_shr_pos(im[s * 22], SCALEFACTOR30_1); + + /* 1. FFT5 stage */ + + /* real part */ + r1 = L_add(x02, x08); + r4 = L_sub(x02, x08); + r3 = L_add(x04, x06); + r2 = L_sub(x04, x06); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y00 = L_add(x00, r1); + r1 = L_add(y00, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x03, x09); + s4 = L_sub(x03, x09); + s3 = L_add(x05, x07); + s2 = L_sub(x05, x07); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y01 = L_add(x01, s1); + s1 = L_add(y01, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y02 = L_add(r1, s2); + y08 = L_sub(r1, s2); + y04 = L_sub(r3, s4); + y06 = L_add(r3, s4); + + y03 = L_sub(s1, r2); + y09 = L_add(s1, r2); + y05 = L_add(s3, r4); + y07 = L_sub(s3, r4); + + /* 2. FFT5 stage */ + + /* real part */ + r1 = L_add(x12, x18); + r4 = L_sub(x12, x18); + r3 = L_add(x14, x16); + r2 = L_sub(x14, x16); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y10 = L_add(x10, r1); + r1 = L_add(y10, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x13, x19); + s4 = L_sub(x13, x19); + s3 = L_add(x15, x17); + s2 = L_sub(x15, x17); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y11 = L_add(x11, s1); + s1 = L_add(y11, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y12 = L_add(r1, s2); + y18 = L_sub(r1, s2); + y14 = L_sub(r3, s4); + y16 = L_add(r3, s4); + + y13 = L_sub(s1, r2); + y19 = L_add(s1, r2); + y15 = L_add(s3, r4); + y17 = L_sub(s3, r4); + + /* 3. FFT5 stage */ + + /* real part */ + r1 = L_add(x22, x28); + r4 = L_sub(x22, x28); + r3 = L_add(x24, x26); + r2 = L_sub(x24, x26); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y20 = L_add(x20, r1); + r1 = L_add(y20, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x23, x29); + s4 = L_sub(x23, x29); + s3 = L_add(x25, x27); + s2 = L_sub(x25, x27); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y21 = L_add(x21, s1); + s1 = L_add(y21, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y22 = L_add(r1, s2); + y28 = L_sub(r1, s2); + y24 = L_sub(r3, s4); + y26 = L_add(r3, s4); + + y23 = L_sub(s1, r2); + y29 = L_add(s1, r2); + y25 = L_add(s3, r4); + y27 = L_sub(s3, r4); + + /* 1. FFT3 stage */ + + /* real part */ + r1 = L_add(y10, y20); + r2 = Mpy_32_xx(L_sub(y10, y20), C31); + z00 = L_add(y00, r1); + r1 = L_sub(y00, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y11, y21); + s2 = Mpy_32_xx(L_sub(y11, y21), C31); + z01 = L_add(y01, s1); + s1 = L_sub(y01, L_shr_pos(s1, 1)); + + /* combination */ + z20 = L_sub(r1, s2); + z10 = L_add(r1, s2); + z21 = L_add(s1, r2); + z11 = L_sub(s1, r2); + + /* 2. FFT3 stage */ + + /* real part */ + r1 = L_add(y12, y22); + r2 = Mpy_32_xx(L_sub(y12, y22), C31); + z12 = L_add(y02, r1); + r1 = L_sub(y02, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y13, y23); + s2 = Mpy_32_xx(L_sub(y13, y23), C31); + z13 = L_add(y03, s1); + s1 = L_sub(y03, L_shr_pos(s1, 1)); + + /* combination */ + z02 = L_sub(r1, s2); + z22 = L_add(r1, s2); + z03 = L_add(s1, r2); + z23 = L_sub(s1, r2); + + /* 3. FFT3 stage */ + + /* real part */ + r1 = L_add(y14, y24); + r2 = Mpy_32_xx(L_sub(y14, y24), C31); + z24 = L_add(y04, r1); + r1 = L_sub(y04, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y15, y25); + s2 = Mpy_32_xx(L_sub(y15, y25), C31); + z25 = L_add(y05, s1); + s1 = L_sub(y05, L_shr_pos(s1, 1)); + + /* combination */ + z14 = L_sub(r1, s2); + z04 = L_add(r1, s2); + z15 = L_add(s1, r2); + z05 = L_sub(s1, r2); + + /* 4. FFT3 stage */ + + /* real part */ + r1 = L_add(y16, y26); + r2 = Mpy_32_xx(L_sub(y16, y26), C31); + z06 = L_add(y06, r1); + r1 = L_sub(y06, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y17, y27); + s2 = Mpy_32_xx(L_sub(y17, y27), C31); + z07 = L_add(y07, s1); + s1 = L_sub(y07, L_shr_pos(s1, 1)); + + /* combination */ + z26 = L_sub(r1, s2); + z16 = L_add(r1, s2); + z27 = L_add(s1, r2); + z17 = L_sub(s1, r2); + + /* 5. FFT3 stage */ + + /* real part */ + r1 = L_add(y18, y28); + r2 = Mpy_32_xx(L_sub(y18, y28), C31); + z18 = L_add(y08, r1); + r1 = L_sub(y08, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y19, y29); + s2 = Mpy_32_xx(L_sub(y19, y29), C31); + z19 = L_add(y09, s1); + s1 = L_sub(y09, L_shr_pos(s1, 1)); + + /* combination */ + z08 = L_sub(r1, s2); + z28 = L_add(r1, s2); + z09 = L_add(s1, r2); + z29 = L_sub(s1, r2); + + /* 2. FFT15 stage */ + x00 = L_shr_pos(re[s * 15], SCALEFACTOR30_1); + x01 = L_shr_pos(im[s * 15], SCALEFACTOR30_1); + x02 = L_shr_pos(re[s * 3], SCALEFACTOR30_1); + x03 = L_shr_pos(im[s * 3], SCALEFACTOR30_1); + x04 = L_shr_pos(re[s * 21], SCALEFACTOR30_1); + x05 = L_shr_pos(im[s * 21], SCALEFACTOR30_1); + x06 = L_shr_pos(re[s * 9], SCALEFACTOR30_1); + x07 = L_shr_pos(im[s * 9], SCALEFACTOR30_1); + x08 = L_shr_pos(re[s * 27], SCALEFACTOR30_1); + x09 = L_shr_pos(im[s * 27], SCALEFACTOR30_1); + + x10 = L_shr_pos(re[s * 5], SCALEFACTOR30_1); + x11 = L_shr_pos(im[s * 5], SCALEFACTOR30_1); + x12 = L_shr_pos(re[s * 23], SCALEFACTOR30_1); + x13 = L_shr_pos(im[s * 23], SCALEFACTOR30_1); + x14 = L_shr_pos(re[s * 11], SCALEFACTOR30_1); + x15 = L_shr_pos(im[s * 11], SCALEFACTOR30_1); + x16 = L_shr_pos(re[s * 29], SCALEFACTOR30_1); + x17 = L_shr_pos(im[s * 29], SCALEFACTOR30_1); + x18 = L_shr_pos(re[s * 17], SCALEFACTOR30_1); + x19 = L_shr_pos(im[s * 17], SCALEFACTOR30_1); + + x20 = L_shr_pos(re[s * 25], SCALEFACTOR30_1); + x21 = L_shr_pos(im[s * 25], SCALEFACTOR30_1); + x22 = L_shr_pos(re[s * 13], SCALEFACTOR30_1); + x23 = L_shr_pos(im[s * 13], SCALEFACTOR30_1); + x24 = L_shr_pos(re[s * 1], SCALEFACTOR30_1); + x25 = L_shr_pos(im[s * 1], SCALEFACTOR30_1); + x26 = L_shr_pos(re[s * 19], SCALEFACTOR30_1); + x27 = L_shr_pos(im[s * 19], SCALEFACTOR30_1); + x28 = L_shr_pos(re[s * 7], SCALEFACTOR30_1); + x29 = L_shr_pos(im[s * 7], SCALEFACTOR30_1); + + /* 1. FFT5 stage */ + + /* real part */ + r1 = L_add(x02, x08); + r4 = L_sub(x02, x08); + r3 = L_add(x04, x06); + r2 = L_sub(x04, x06); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y00 = L_add(x00, r1); + r1 = L_add(y00, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x03, x09); + s4 = L_sub(x03, x09); + s3 = L_add(x05, x07); + s2 = L_sub(x05, x07); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y01 = L_add(x01, s1); + s1 = L_add(y01, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y02 = L_add(r1, s2); + y08 = L_sub(r1, s2); + y04 = L_sub(r3, s4); + y06 = L_add(r3, s4); + + y03 = L_sub(s1, r2); + y09 = L_add(s1, r2); + y05 = L_add(s3, r4); + y07 = L_sub(s3, r4); + + /* 2. FFT5 stage */ + + /* real part */ + r1 = L_add(x12, x18); + r4 = L_sub(x12, x18); + r3 = L_add(x14, x16); + r2 = L_sub(x14, x16); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y10 = L_add(x10, r1); + r1 = L_add(y10, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x13, x19); + s4 = L_sub(x13, x19); + s3 = L_add(x15, x17); + s2 = L_sub(x15, x17); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y11 = L_add(x11, s1); + s1 = L_add(y11, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y12 = L_add(r1, s2); + y18 = L_sub(r1, s2); + y14 = L_sub(r3, s4); + y16 = L_add(r3, s4); + + y13 = L_sub(s1, r2); + y19 = L_add(s1, r2); + y15 = L_add(s3, r4); + y17 = L_sub(s3, r4); + + /* 3. FFT5 stage */ + + /* real part */ + r1 = L_add(x22, x28); + r4 = L_sub(x22, x28); + r3 = L_add(x24, x26); + r2 = L_sub(x24, x26); + t = Mpy_32_xx(L_sub(r1, r3), C54); + r1 = L_add(r1, r3); + y20 = L_add(x20, r1); + r1 = L_add(y20, (L_shl_pos(Mpy_32_xx(r1, C55), 1))); + r3 = L_sub(r1, t); + r1 = L_add(r1, t); + t = Mpy_32_xx((L_add(r4, r2)), C51); + r4 = L_add(t, L_shl_pos(Mpy_32_xx(r4, C52), 1)); + r2 = L_add(t, Mpy_32_xx(r2, C53)); + + /* imaginary part */ + s1 = L_add(x23, x29); + s4 = L_sub(x23, x29); + s3 = L_add(x25, x27); + s2 = L_sub(x25, x27); + t = Mpy_32_xx(L_sub(s1, s3), C54); + s1 = L_add(s1, s3); + y21 = L_add(x21, s1); + s1 = L_add(y21, L_shl_pos(Mpy_32_xx(s1, C55), 1)); + s3 = L_sub(s1, t); + s1 = L_add(s1, t); + t = Mpy_32_xx(L_add(s4, s2), C51); + s4 = L_add(t, L_shl_pos(Mpy_32_xx(s4, C52), 1)); + s2 = L_add(t, Mpy_32_xx(s2, C53)); + + /* combination */ + y22 = L_add(r1, s2); + y28 = L_sub(r1, s2); + y24 = L_sub(r3, s4); + y26 = L_add(r3, s4); + + y23 = L_sub(s1, r2); + y29 = L_add(s1, r2); + y25 = L_add(s3, r4); + y27 = L_sub(s3, r4); + + /* 1. FFT3 stage */ + + /* real part */ + r1 = L_add(y10, y20); + r2 = Mpy_32_xx(L_sub(y10, y20), C31); + z30 = L_add(y00, r1); + r1 = L_sub(y00, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y11, y21); + s2 = Mpy_32_xx(L_sub(y11, y21), C31); + z31 = L_add(y01, s1); + s1 = L_sub(y01, L_shr_pos(s1, 1)); + + /* combination */ + z50 = L_sub(r1, s2); + z40 = L_add(r1, s2); + z51 = L_add(s1, r2); + z41 = L_sub(s1, r2); + + /* 2. FFT3 stage */ + + /* real part */ + r1 = L_add(y12, y22); + r2 = Mpy_32_xx(L_sub(y12, y22), C31); + z42 = L_add(y02, r1); + r1 = L_sub(y02, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y13, y23); + s2 = Mpy_32_xx(L_sub(y13, y23), C31); + z43 = L_add(y03, s1); + s1 = L_sub(y03, L_shr_pos(s1, 1)); + + /* combination */ + z32 = L_sub(r1, s2); + z52 = L_add(r1, s2); + z33 = L_add(s1, r2); + z53 = L_sub(s1, r2); + + /* 3. FFT3 stage */ + + /* real part */ + r1 = L_add(y14, y24); + r2 = Mpy_32_xx(L_sub(y14, y24), C31); + z54 = L_add(y04, r1); + r1 = L_sub(y04, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y15, y25); + s2 = Mpy_32_xx(L_sub(y15, y25), C31); + z55 = L_add(y05, s1); + s1 = L_sub(y05, L_shr_pos(s1, 1)); + + /* combination */ + z44 = L_sub(r1, s2); + z34 = L_add(r1, s2); + z45 = L_add(s1, r2); + z35 = L_sub(s1, r2); + + /* 4. FFT3 stage */ + + /* real part */ + r1 = L_add(y16, y26); + r2 = Mpy_32_xx(L_sub(y16, y26), C31); + z36 = L_add(y06, r1); + r1 = L_sub(y06, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y17, y27); + s2 = Mpy_32_xx(L_sub(y17, y27), C31); + z37 = L_add(y07, s1); + s1 = L_sub(y07, L_shr_pos(s1, 1)); + + /* combination */ + z56 = L_sub(r1, s2); + z46 = L_add(r1, s2); + z57 = L_add(s1, r2); + z47 = L_sub(s1, r2); + + /* 5. FFT3 stage */ + + /* real part */ + r1 = L_add(y18, y28); + r2 = Mpy_32_xx(L_sub(y18, y28), C31); + z48 = L_add(y08, r1); + r1 = L_sub(y08, L_shr_pos(r1, 1)); + + /* imaginary part */ + s1 = L_add(y19, y29); + s2 = Mpy_32_xx(L_sub(y19, y29), C31); + z49 = L_add(y09, s1); + s1 = L_sub(y09, L_shr_pos(s1, 1)); + + /* combination */ + z38 = L_sub(r1, s2); + z58 = L_add(r1, s2); + z39 = L_add(s1, r2); + z59 = L_sub(s1, r2); + + /* 1. FFT2 stage */ + r1 = L_shr_pos(z00, SCALEFACTOR30_2); + r2 = L_shr_pos(z30, SCALEFACTOR30_2); + r3 = L_shr_pos(z01, SCALEFACTOR30_2); + r4 = L_shr_pos(z31, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 2. FFT2 stage */ + r1 = L_shr_pos(z16, SCALEFACTOR30_2); + r2 = L_shr_pos(z46, SCALEFACTOR30_2); + r3 = L_shr_pos(z17, SCALEFACTOR30_2); + r4 = L_shr_pos(z47, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 3. FFT2 stage */ + r1 = L_shr_pos(z02, SCALEFACTOR30_2); + r2 = L_shr_pos(z32, SCALEFACTOR30_2); + r3 = L_shr_pos(z03, SCALEFACTOR30_2); + r4 = L_shr_pos(z33, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 4. FFT2 stage */ + r1 = L_shr_pos(z18, SCALEFACTOR30_2); + r2 = L_shr_pos(z48, SCALEFACTOR30_2); + r3 = L_shr_pos(z19, SCALEFACTOR30_2); + r4 = L_shr_pos(z49, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 5. FFT2 stage */ + r1 = L_shr_pos(z04, SCALEFACTOR30_2); + r2 = L_shr_pos(z34, SCALEFACTOR30_2); + r3 = L_shr_pos(z05, SCALEFACTOR30_2); + r4 = L_shr_pos(z35, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 6. FFT2 stage */ + r1 = L_shr_pos(z20, SCALEFACTOR30_2); + r2 = L_shr_pos(z50, SCALEFACTOR30_2); + r3 = L_shr_pos(z21, SCALEFACTOR30_2); + r4 = L_shr_pos(z51, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 7. FFT2 stage */ + r1 = L_shr_pos(z06, SCALEFACTOR30_2); + r2 = L_shr_pos(z36, SCALEFACTOR30_2); + r3 = L_shr_pos(z07, SCALEFACTOR30_2); + r4 = L_shr_pos(z37, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 8. FFT2 stage */ + r1 = L_shr_pos(z22, SCALEFACTOR30_2); + r2 = L_shr_pos(z52, SCALEFACTOR30_2); + r3 = L_shr_pos(z23, SCALEFACTOR30_2); + r4 = L_shr_pos(z53, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 9. FFT2 stage */ + r1 = L_shr_pos(z08, SCALEFACTOR30_2); + r2 = L_shr_pos(z38, SCALEFACTOR30_2); + r3 = L_shr_pos(z09, SCALEFACTOR30_2); + r4 = L_shr_pos(z39, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 10. FFT2 stage */ + r1 = L_shr_pos(z24, SCALEFACTOR30_2); + r2 = L_shr_pos(z54, SCALEFACTOR30_2); + r3 = L_shr_pos(z25, SCALEFACTOR30_2); + r4 = L_shr_pos(z55, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 11. FFT2 stage */ + r1 = L_shr_pos(z10, SCALEFACTOR30_2); + r2 = L_shr_pos(z40, SCALEFACTOR30_2); + r3 = L_shr_pos(z11, SCALEFACTOR30_2); + r4 = L_shr_pos(z41, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 12. FFT2 stage */ + r1 = L_shr_pos(z26, SCALEFACTOR30_2); + r2 = L_shr_pos(z56, SCALEFACTOR30_2); + r3 = L_shr_pos(z27, SCALEFACTOR30_2); + r4 = L_shr_pos(z57, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 13. FFT2 stage */ + r1 = L_shr_pos(z12, SCALEFACTOR30_2); + r2 = L_shr_pos(z42, SCALEFACTOR30_2); + r3 = L_shr_pos(z13, SCALEFACTOR30_2); + r4 = L_shr_pos(z43, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 14. FFT2 stage */ + r1 = L_shr_pos(z28, SCALEFACTOR30_2); + r2 = L_shr_pos(z58, SCALEFACTOR30_2); + r3 = L_shr_pos(z29, SCALEFACTOR30_2); + r4 = L_shr_pos(z59, SCALEFACTOR30_2); + *reh = L_add(r1, r2); + move32(); + *rel = L_sub(r1, r2); + move32(); + *imh = L_add(r3, r4); + move32(); + *iml = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + /* 15. FFT2 stage */ + r1 = L_shr_pos(z14, SCALEFACTOR30_2); + r2 = L_shr_pos(z44, SCALEFACTOR30_2); + r3 = L_shr_pos(z15, SCALEFACTOR30_2); + r4 = L_shr_pos(z45, SCALEFACTOR30_2); + *rel = L_add(r1, r2); + move32(); + *reh = L_sub(r1, r2); + move32(); + *iml = L_add(r3, r4); + move32(); + *imh = L_sub(r3, r4); + move32(); + rel += s, reh += s, iml += s; + imh += s; + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 32-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR32 bits. + * + * WOPS with 32x16 bit multiplications: 752 cycles + * + * \param [i/o] re real input / output + * \param [i/o] im imag input / output + * \param [i ] s stride real and imag input / output + * + * \return void + */ + + +static void fft32(Word32 *re, Word32 *im, Word16 s) +{ + Dyn_Mem_Deluxe_In(Word32 as, bs; Word32 x00, x01, x02, x03, x04, x05, x06, x07; + Word32 x08, x09, x10, x11, x12, x13, x14, x15; Word32 t00, t01, t02, t03, t04, t05, t06, t07; + Word32 t08, t09, t10, t11, t12, t13, t14, t15; Word32 s00, s01, s02, s03, s04, s05, s06, s07; + Word32 s08, s09, s10, s11, s12, s13, s14, s15; + + Word32 y00, y01, y02, y03, y04, y05, y06, y07; Word32 y08, y09, y10, y11, y12, y13, y14, y15; + Word32 y16, y17, y18, y19, y20, y21, y22, y23; Word32 y24, y25, y26, y27, y28, y29, y30, y31; + Word32 y32, y33, y34, y35, y36, y37, y38, y39; Word32 y40, y41, y42, y43, y44, y45, y46, y47; + Word32 y48, y49, y50, y51, y52, y53, y54, y55; Word32 y56, y57, y58, y59, y60, y61, y62, y63;); + + /* 1. FFT8 stage */ + x00 = L_shr_pos(re[s * 0], SCALEFACTOR32_1); + x01 = L_shr_pos(im[s * 0], SCALEFACTOR32_1); + x02 = L_shr_pos(re[s * 4], SCALEFACTOR32_1); + x03 = L_shr_pos(im[s * 4], SCALEFACTOR32_1); + x04 = L_shr_pos(re[s * 8], SCALEFACTOR32_1); + x05 = L_shr_pos(im[s * 8], SCALEFACTOR32_1); + x06 = L_shr_pos(re[s * 12], SCALEFACTOR32_1); + x07 = L_shr_pos(im[s * 12], SCALEFACTOR32_1); + x08 = L_shr_pos(re[s * 16], SCALEFACTOR32_1); + x09 = L_shr_pos(im[s * 16], SCALEFACTOR32_1); + x10 = L_shr_pos(re[s * 20], SCALEFACTOR32_1); + x11 = L_shr_pos(im[s * 20], SCALEFACTOR32_1); + x12 = L_shr_pos(re[s * 24], SCALEFACTOR32_1); + x13 = L_shr_pos(im[s * 24], SCALEFACTOR32_1); + x14 = L_shr_pos(re[s * 28], SCALEFACTOR32_1); + x15 = L_shr_pos(im[s * 28], SCALEFACTOR32_1); + + t00 = L_add(x00, x08); + t02 = L_sub(x00, x08); + t01 = L_add(x01, x09); + t03 = L_sub(x01, x09); + t04 = L_add(x02, x10); + t06 = L_sub(x02, x10); + t05 = L_add(x03, x11); + t07 = L_sub(x03, x11); + t08 = L_add(x04, x12); + t10 = L_sub(x04, x12); + t09 = L_add(x05, x13); + t11 = L_sub(x05, x13); + t12 = L_add(x06, x14); + t14 = L_sub(x06, x14); + t13 = L_add(x07, x15); + t15 = L_sub(x07, x15); + + /* Pre-additions and core multiplications */ + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + t01 = L_add(t06, t14); + t02 = L_sub(t06, t14); + t00 = L_add(t07, t15); + t03 = L_sub(t07, t15); + + Mpy3_0(s12, s13, s14, s15, t00, t01, t02, t03); + + /* Post-additions */ + y00 = L_add(s00, s02); + y08 = L_sub(s00, s02); + y01 = L_add(s01, s03); + y09 = L_sub(s01, s03); + y04 = L_sub(s04, s06); + y12 = L_add(s04, s06); + y05 = L_sub(s05, s07); + y13 = L_add(s05, s07); + y06 = L_add(s08, s14); + y14 = L_sub(s08, s14); + y07 = L_add(s09, s15); + y15 = L_sub(s09, s15); + y02 = L_add(s10, s12); + y10 = L_sub(s10, s12); + y03 = L_add(s11, s13); + y11 = L_sub(s11, s13); + + /* 2. FFT8 stage */ + x00 = L_shr_pos(re[s * 1], SCALEFACTOR32_1); + x01 = L_shr_pos(im[s * 1], SCALEFACTOR32_1); + x02 = L_shr_pos(re[s * 5], SCALEFACTOR32_1); + x03 = L_shr_pos(im[s * 5], SCALEFACTOR32_1); + x04 = L_shr_pos(re[s * 9], SCALEFACTOR32_1); + x05 = L_shr_pos(im[s * 9], SCALEFACTOR32_1); + x06 = L_shr_pos(re[s * 13], SCALEFACTOR32_1); + x07 = L_shr_pos(im[s * 13], SCALEFACTOR32_1); + x08 = L_shr_pos(re[s * 17], SCALEFACTOR32_1); + x09 = L_shr_pos(im[s * 17], SCALEFACTOR32_1); + x10 = L_shr_pos(re[s * 21], SCALEFACTOR32_1); + x11 = L_shr_pos(im[s * 21], SCALEFACTOR32_1); + x12 = L_shr_pos(re[s * 25], SCALEFACTOR32_1); + x13 = L_shr_pos(im[s * 25], SCALEFACTOR32_1); + x14 = L_shr_pos(re[s * 29], SCALEFACTOR32_1); + x15 = L_shr_pos(im[s * 29], SCALEFACTOR32_1); + + t00 = L_add(x00, x08); + t02 = L_sub(x00, x08); + t01 = L_add(x01, x09); + t03 = L_sub(x01, x09); + t04 = L_add(x02, x10); + t06 = L_sub(x02, x10); + t05 = L_add(x03, x11); + t07 = L_sub(x03, x11); + t08 = L_add(x04, x12); + t10 = L_sub(x04, x12); + t09 = L_add(x05, x13); + t11 = L_sub(x05, x13); + t12 = L_add(x06, x14); + t14 = L_sub(x06, x14); + t13 = L_add(x07, x15); + t15 = L_sub(x07, x15); + + /* Pre-additions and core multiplications */ + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + t01 = L_add(t06, t14); + t02 = L_sub(t06, t14); + t00 = L_add(t07, t15); + t03 = L_sub(t07, t15); + + Mpy3_0(s12, s13, s14, s15, t00, t01, t02, t03); + + /* Post-additions */ + y16 = L_add(s00, s02); + y24 = L_sub(s00, s02); + y17 = L_add(s01, s03); + y25 = L_sub(s01, s03); + y20 = L_sub(s04, s06); + y28 = L_add(s04, s06); + y21 = L_sub(s05, s07); + y29 = L_add(s05, s07); + y22 = L_add(s08, s14); + y30 = L_sub(s08, s14); + y23 = L_add(s09, s15); + y31 = L_sub(s09, s15); + y18 = L_add(s10, s12); + y26 = L_sub(s10, s12); + y19 = L_add(s11, s13); + y27 = L_sub(s11, s13); + + /* 3. FFT8 stage */ + x00 = L_shr_pos(re[s * 2], SCALEFACTOR32_1); + x01 = L_shr_pos(im[s * 2], SCALEFACTOR32_1); + x02 = L_shr_pos(re[s * 6], SCALEFACTOR32_1); + x03 = L_shr_pos(im[s * 6], SCALEFACTOR32_1); + x04 = L_shr_pos(re[s * 10], SCALEFACTOR32_1); + x05 = L_shr_pos(im[s * 10], SCALEFACTOR32_1); + x06 = L_shr_pos(re[s * 14], SCALEFACTOR32_1); + x07 = L_shr_pos(im[s * 14], SCALEFACTOR32_1); + x08 = L_shr_pos(re[s * 18], SCALEFACTOR32_1); + x09 = L_shr_pos(im[s * 18], SCALEFACTOR32_1); + x10 = L_shr_pos(re[s * 22], SCALEFACTOR32_1); + x11 = L_shr_pos(im[s * 22], SCALEFACTOR32_1); + x12 = L_shr_pos(re[s * 26], SCALEFACTOR32_1); + x13 = L_shr_pos(im[s * 26], SCALEFACTOR32_1); + x14 = L_shr_pos(re[s * 30], SCALEFACTOR32_1); + x15 = L_shr_pos(im[s * 30], SCALEFACTOR32_1); + + t00 = L_add(x00, x08); + t02 = L_sub(x00, x08); + t01 = L_add(x01, x09); + t03 = L_sub(x01, x09); + t04 = L_add(x02, x10); + t06 = L_sub(x02, x10); + t05 = L_add(x03, x11); + t07 = L_sub(x03, x11); + t08 = L_add(x04, x12); + t10 = L_sub(x04, x12); + t09 = L_add(x05, x13); + t11 = L_sub(x05, x13); + t12 = L_add(x06, x14); + t14 = L_sub(x06, x14); + t13 = L_add(x07, x15); + t15 = L_sub(x07, x15); + + /* Pre-additions and core multiplications */ + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + t01 = L_add(t06, t14); + t02 = L_sub(t06, t14); + t00 = L_add(t07, t15); + t03 = L_sub(t07, t15); + + Mpy3_0(s12, s13, s14, s15, t00, t01, t02, t03); + + /* Post-additions */ + y32 = L_add(s00, s02); + y40 = L_sub(s00, s02); + y33 = L_add(s01, s03); + y41 = L_sub(s01, s03); + y36 = L_sub(s04, s06); + y44 = L_add(s04, s06); + y37 = L_sub(s05, s07); + y45 = L_add(s05, s07); + y38 = L_add(s08, s14); + y46 = L_sub(s08, s14); + y39 = L_add(s09, s15); + y47 = L_sub(s09, s15); + y34 = L_add(s10, s12); + y42 = L_sub(s10, s12); + y35 = L_add(s11, s13); + y43 = L_sub(s11, s13); + + /* 4. FFT8 stage */ + x00 = L_shr_pos(re[s * 3], SCALEFACTOR32_1); + x01 = L_shr_pos(im[s * 3], SCALEFACTOR32_1); + x02 = L_shr_pos(re[s * 7], SCALEFACTOR32_1); + x03 = L_shr_pos(im[s * 7], SCALEFACTOR32_1); + x04 = L_shr_pos(re[s * 11], SCALEFACTOR32_1); + x05 = L_shr_pos(im[s * 11], SCALEFACTOR32_1); + x06 = L_shr_pos(re[s * 15], SCALEFACTOR32_1); + x07 = L_shr_pos(im[s * 15], SCALEFACTOR32_1); + x08 = L_shr_pos(re[s * 19], SCALEFACTOR32_1); + x09 = L_shr_pos(im[s * 19], SCALEFACTOR32_1); + x10 = L_shr_pos(re[s * 23], SCALEFACTOR32_1); + x11 = L_shr_pos(im[s * 23], SCALEFACTOR32_1); + x12 = L_shr_pos(re[s * 27], SCALEFACTOR32_1); + x13 = L_shr_pos(im[s * 27], SCALEFACTOR32_1); + x14 = L_shr_pos(re[s * 31], SCALEFACTOR32_1); + x15 = L_shr_pos(im[s * 31], SCALEFACTOR32_1); + + t00 = L_add(x00, x08); + t02 = L_sub(x00, x08); + t01 = L_add(x01, x09); + t03 = L_sub(x01, x09); + t04 = L_add(x02, x10); + t06 = L_sub(x02, x10); + t05 = L_add(x03, x11); + t07 = L_sub(x03, x11); + t08 = L_add(x04, x12); + t10 = L_sub(x04, x12); + t09 = L_add(x05, x13); + t11 = L_sub(x05, x13); + t12 = L_add(x06, x14); + t14 = L_sub(x06, x14); + t13 = L_add(x07, x15); + t15 = L_sub(x07, x15); + + /* Pre-additions and core multiplications */ + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + t01 = L_add(t06, t14); + t02 = L_sub(t06, t14); + t00 = L_add(t07, t15); + t03 = L_sub(t07, t15); + + Mpy3_0(s12, s13, s14, s15, t00, t01, t02, t03); + + /* Post-additions */ + y48 = L_add(s00, s02); + y56 = L_sub(s00, s02); + y49 = L_add(s01, s03); + y57 = L_sub(s01, s03); + y52 = L_sub(s04, s06); + y60 = L_add(s04, s06); + y53 = L_sub(s05, s07); + y61 = L_add(s05, s07); + y54 = L_add(s08, s14); + y62 = L_sub(s08, s14); + y55 = L_add(s09, s15); + y63 = L_sub(s09, s15); + y50 = L_add(s10, s12); + y58 = L_sub(s10, s12); + y51 = L_add(s11, s13); + y59 = L_sub(s11, s13); + + /* apply twiddle factors */ + y00 = L_shr_pos(y00, SCALEFACTOR32_2); + y01 = L_shr_pos(y01, SCALEFACTOR32_2); + y02 = L_shr_pos(y02, SCALEFACTOR32_2); + y03 = L_shr_pos(y03, SCALEFACTOR32_2); + y04 = L_shr_pos(y04, SCALEFACTOR32_2); + y05 = L_shr_pos(y05, SCALEFACTOR32_2); + y06 = L_shr_pos(y06, SCALEFACTOR32_2); + y07 = L_shr_pos(y07, SCALEFACTOR32_2); + y08 = L_shr_pos(y08, SCALEFACTOR32_2); + y09 = L_shr_pos(y09, SCALEFACTOR32_2); + y10 = L_shr_pos(y10, SCALEFACTOR32_2); + y11 = L_shr_pos(y11, SCALEFACTOR32_2); + y12 = L_shr_pos(y12, SCALEFACTOR32_2); + y13 = L_shr_pos(y13, SCALEFACTOR32_2); + y14 = L_shr_pos(y14, SCALEFACTOR32_2); + y15 = L_shr_pos(y15, SCALEFACTOR32_2); + y16 = L_shr_pos(y16, SCALEFACTOR32_2); + y17 = L_shr_pos(y17, SCALEFACTOR32_2); + y32 = L_shr_pos(y32, SCALEFACTOR32_2); + y33 = L_shr_pos(y33, SCALEFACTOR32_2); + y48 = L_shr_pos(y48, SCALEFACTOR32_2); + y49 = L_shr_pos(y49, SCALEFACTOR32_2); + y40 = L_shr_pos(y40, SCALEFACTOR32_2); + y41 = L_shr_pos(y41, SCALEFACTOR32_2); + + cplxMpy3_0(y18, y19, RotVector_32_32[2 * 0 + 0], RotVector_32_32[2 * 0 + 1]); + cplxMpy3_0(y20, y21, RotVector_32_32[2 * 1 + 0], RotVector_32_32[2 * 1 + 1]); + cplxMpy3_0(y22, y23, RotVector_32_32[2 * 2 + 0], RotVector_32_32[2 * 2 + 1]); + cplxMpy3_0(y24, y25, RotVector_32_32[2 * 3 + 0], RotVector_32_32[2 * 3 + 1]); + cplxMpy3_0(y26, y27, RotVector_32_32[2 * 4 + 0], RotVector_32_32[2 * 4 + 1]); + cplxMpy3_0(y28, y29, RotVector_32_32[2 * 5 + 0], RotVector_32_32[2 * 5 + 1]); + cplxMpy3_0(y30, y31, RotVector_32_32[2 * 6 + 0], RotVector_32_32[2 * 6 + 1]); + cplxMpy3_0(y34, y35, RotVector_32_32[2 * 7 + 0], RotVector_32_32[2 * 7 + 1]); + cplxMpy3_0(y36, y37, RotVector_32_32[2 * 8 + 0], RotVector_32_32[2 * 8 + 1]); + cplxMpy3_0(y38, y39, RotVector_32_32[2 * 9 + 0], RotVector_32_32[2 * 9 + 1]); + cplxMpy3_0(y42, y43, RotVector_32_32[2 * 10 + 0], RotVector_32_32[2 * 10 + 1]); + cplxMpy3_0(y44, y45, RotVector_32_32[2 * 11 + 0], RotVector_32_32[2 * 11 + 1]); + cplxMpy3_0(y46, y47, RotVector_32_32[2 * 12 + 0], RotVector_32_32[2 * 12 + 1]); + cplxMpy3_0(y50, y51, RotVector_32_32[2 * 13 + 0], RotVector_32_32[2 * 13 + 1]); + cplxMpy3_0(y52, y53, RotVector_32_32[2 * 14 + 0], RotVector_32_32[2 * 14 + 1]); + cplxMpy3_0(y54, y55, RotVector_32_32[2 * 15 + 0], RotVector_32_32[2 * 15 + 1]); + cplxMpy3_0(y56, y57, RotVector_32_32[2 * 16 + 0], RotVector_32_32[2 * 16 + 1]); + cplxMpy3_0(y58, y59, RotVector_32_32[2 * 17 + 0], RotVector_32_32[2 * 17 + 1]); + cplxMpy3_0(y60, y61, RotVector_32_32[2 * 18 + 0], RotVector_32_32[2 * 18 + 1]); + cplxMpy3_0(y62, y63, RotVector_32_32[2 * 19 + 0], RotVector_32_32[2 * 19 + 1]); + + /* 1. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y00, y32); + t02 = L_sub(y00, y32); + t01 = L_add(y01, y33); + t03 = L_sub(y01, y33); + t04 = L_add(y16, y48); + t07 = L_sub(y16, y48); + t05 = L_add(y49, y17); + t06 = L_sub(y49, y17); + + /* Post-additions */ + re[s * 0] = L_add(t00, t04); + move32(); + im[s * 0] = L_add(t01, t05); + move32(); + re[s * 8] = L_sub(t02, t06); + move32(); + im[s * 8] = L_sub(t03, t07); + move32(); + re[s * 16] = L_sub(t00, t04); + move32(); + im[s * 16] = L_sub(t01, t05); + move32(); + re[s * 24] = L_add(t02, t06); + move32(); + im[s * 24] = L_add(t03, t07); + move32(); + + /* 2. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y02, y34); + t02 = L_sub(y02, y34); + t01 = L_add(y03, y35); + t03 = L_sub(y03, y35); + t04 = L_add(y18, y50); + t07 = L_sub(y18, y50); + t05 = L_add(y51, y19); + t06 = L_sub(y51, y19); + + /* Post-additions */ + re[s * 1] = L_add(t00, t04); + move32(); + im[s * 1] = L_add(t01, t05); + move32(); + re[s * 9] = L_sub(t02, t06); + move32(); + im[s * 9] = L_sub(t03, t07); + move32(); + re[s * 17] = L_sub(t00, t04); + move32(); + im[s * 17] = L_sub(t01, t05); + move32(); + re[s * 25] = L_add(t02, t06); + move32(); + im[s * 25] = L_add(t03, t07); + move32(); + + /* 3. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y04, y36); + t02 = L_sub(y04, y36); + t01 = L_add(y05, y37); + t03 = L_sub(y05, y37); + t04 = L_add(y20, y52); + t07 = L_sub(y20, y52); + t05 = L_add(y53, y21); + t06 = L_sub(y53, y21); + + /* Post-additions */ + re[s * 2] = L_add(t00, t04); + move32(); + im[s * 2] = L_add(t01, t05); + move32(); + re[s * 10] = L_sub(t02, t06); + move32(); + im[s * 10] = L_sub(t03, t07); + move32(); + re[s * 18] = L_sub(t00, t04); + move32(); + im[s * 18] = L_sub(t01, t05); + move32(); + re[s * 26] = L_add(t02, t06); + move32(); + im[s * 26] = L_add(t03, t07); + move32(); + + /* 4. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y06, y38); + t02 = L_sub(y06, y38); + t01 = L_add(y07, y39); + t03 = L_sub(y07, y39); + t04 = L_add(y22, y54); + t07 = L_sub(y22, y54); + t05 = L_add(y55, y23); + t06 = L_sub(y55, y23); + + /* Post-additions */ + re[s * 3] = L_add(t00, t04); + move32(); + im[s * 3] = L_add(t01, t05); + move32(); + re[s * 11] = L_sub(t02, t06); + move32(); + im[s * 11] = L_sub(t03, t07); + move32(); + re[s * 19] = L_sub(t00, t04); + move32(); + im[s * 19] = L_sub(t01, t05); + move32(); + re[s * 27] = L_add(t02, t06); + move32(); + im[s * 27] = L_add(t03, t07); + move32(); + + /* 5. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y08, y41); + t02 = L_sub(y08, y41); + t01 = L_sub(y09, y40); + t03 = L_add(y09, y40); + t04 = L_add(y24, y56); + t07 = L_sub(y24, y56); + t05 = L_add(y57, y25); + t06 = L_sub(y57, y25); + + /* Post-additions */ + re[s * 4] = L_add(t00, t04); + move32(); + im[s * 4] = L_add(t01, t05); + move32(); + re[s * 12] = L_sub(t02, t06); + move32(); + im[s * 12] = L_sub(t03, t07); + move32(); + re[s * 20] = L_sub(t00, t04); + move32(); + im[s * 20] = L_sub(t01, t05); + move32(); + re[s * 28] = L_add(t02, t06); + move32(); + im[s * 28] = L_add(t03, t07); + move32(); + + /* 6. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y10, y42); + t02 = L_sub(y10, y42); + t01 = L_add(y11, y43); + t03 = L_sub(y11, y43); + t04 = L_add(y26, y58); + t07 = L_sub(y26, y58); + t05 = L_add(y59, y27); + t06 = L_sub(y59, y27); + + /* Post-additions */ + re[s * 5] = L_add(t00, t04); + move32(); + im[s * 5] = L_add(t01, t05); + move32(); + re[s * 13] = L_sub(t02, t06); + move32(); + im[s * 13] = L_sub(t03, t07); + move32(); + re[s * 21] = L_sub(t00, t04); + move32(); + im[s * 21] = L_sub(t01, t05); + move32(); + re[s * 29] = L_add(t02, t06); + move32(); + im[s * 29] = L_add(t03, t07); + move32(); + + /* 7. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y12, y44); + t02 = L_sub(y12, y44); + t01 = L_add(y13, y45); + t03 = L_sub(y13, y45); + t04 = L_add(y28, y60); + t07 = L_sub(y28, y60); + t05 = L_add(y61, y29); + t06 = L_sub(y61, y29); + + /* Post-additions */ + re[s * 6] = L_add(t00, t04); + move32(); + im[s * 6] = L_add(t01, t05); + move32(); + re[s * 14] = L_sub(t02, t06); + move32(); + im[s * 14] = L_sub(t03, t07); + move32(); + re[s * 22] = L_sub(t00, t04); + move32(); + im[s * 22] = L_sub(t01, t05); + move32(); + re[s * 30] = L_add(t02, t06); + move32(); + im[s * 30] = L_add(t03, t07); + move32(); + + /* 8. FFT4 stage */ + + /* Pre-additions */ + t00 = L_add(y14, y46); + t02 = L_sub(y14, y46); + t01 = L_add(y15, y47); + t03 = L_sub(y15, y47); + t04 = L_add(y30, y62); + t07 = L_sub(y30, y62); + t05 = L_add(y63, y31); + t06 = L_sub(y63, y31); + + /* Post-additions */ + re[s * 7] = L_add(t00, t04); + move32(); + im[s * 7] = L_add(t01, t05); + move32(); + re[s * 15] = L_sub(t02, t06); + move32(); + im[s * 15] = L_sub(t03, t07); + move32(); + re[s * 23] = L_sub(t00, t04); + move32(); + im[s * 23] = L_sub(t01, t05); + move32(); + re[s * 31] = L_add(t02, t06); + move32(); + im[s * 31] = L_add(t03, t07); + move32(); + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Function performs a complex 40-point FFT + * The FFT is performed inplace. The result of the FFT + * is scaled by SCALEFACTOR40 bits. + * + * \param [i/o] re real part + * \param [i/o] im imag part + * \param [i ] sx stride real and imag part + * + * \return void + */ + + + +static void fft40(Word32 *re, Word32 *im, Word16 sx, Word32 *x) +{ + Dyn_Mem_Deluxe_In(const Word32 *W; Word16 dim1, dim2; Counter i, j; + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15;); + + dim1 = 5; + move16(); + dim2 = 8; + move16(); + + W = RotVector_40_32; + + FOR (i = 0; i < dim2; i++) + { + FOR (j = 0; j < dim1; j++) + { + x[2 * i * dim1 + 2 * j] = re[sx * i + sx * j * dim2]; + move32(); + x[2 * i * dim1 + 2 * j + 1] = im[sx * i + sx * j * dim2]; + move32(); + } + } + + FOR (i = 0; i < dim2; i++) + { + fft5(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + + FOR (i = 0; i < dim1; i++) + { + cplxMpy4_8_1(x00, x01, x[2 * i + 2 * 0 * dim1], x[2 * i + 2 * 0 * dim1 + 1]); + + IF (i == 0) + { + cplxMpy4_8_1(x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1]); + cplxMpy4_8_1(x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1]); + cplxMpy4_8_1(x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1]); + cplxMpy4_8_1(x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1]); + cplxMpy4_8_1(x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1]); + cplxMpy4_8_1(x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1]); + cplxMpy4_8_1(x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1]); + } + ELSE + { + cplxMpy4_8_2(x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1], W[2 * (i - 1) + 0 * 2 * 4], + W[2 * (i - 1) + 0 * 2 * 4 + 1]); + cplxMpy4_8_2(x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1], W[2 * (i - 1) + 1 * 2 * 4], + W[2 * (i - 1) + 1 * 2 * 4 + 1]); + cplxMpy4_8_2(x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1], W[2 * (i - 1) + 2 * 2 * 4], + W[2 * (i - 1) + 2 * 2 * 4 + 1]); + cplxMpy4_8_2(x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1], W[2 * (i - 1) + 3 * 2 * 4], + W[2 * (i - 1) + 3 * 2 * 4 + 1]); + cplxMpy4_8_2(x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1], W[2 * (i - 1) + 4 * 2 * 4], + W[2 * (i - 1) + 4 * 2 * 4 + 1]); + cplxMpy4_8_2(x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1], W[2 * (i - 1) + 5 * 2 * 4], + W[2 * (i - 1) + 5 * 2 * 4 + 1]); + cplxMpy4_8_2(x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1], W[2 * (i - 1) + 6 * 2 * 4], + W[2 * (i - 1) + 6 * 2 * 4 + 1]); + } + + t00 = L_shr_pos(L_add(x00, x08), SCALEFACTORN2 - 1); + t02 = L_shr_pos(L_sub(x00, x08), SCALEFACTORN2 - 1); + t01 = L_shr_pos(L_add(x01, x09), SCALEFACTORN2 - 1); + t03 = L_shr_pos(L_sub(x01, x09), SCALEFACTORN2 - 1); + t04 = L_shr_pos(L_add(x02, x10), SCALEFACTORN2 - 1); + t06 = L_sub(x02, x10); + t05 = L_shr_pos(L_add(x03, x11), SCALEFACTORN2 - 1); + t07 = L_sub(x03, x11); + t08 = L_shr_pos(L_add(x04, x12), SCALEFACTORN2 - 1); + t10 = L_shr_pos(L_sub(x04, x12), SCALEFACTORN2 - 1); + t09 = L_shr_pos(L_add(x05, x13), SCALEFACTORN2 - 1); + t11 = L_shr_pos(L_sub(x05, x13), SCALEFACTORN2 - 1); + t12 = L_shr_pos(L_add(x06, x14), SCALEFACTORN2 - 1); + t14 = L_sub(x06, x14); + t13 = L_shr_pos(L_add(x07, x15), SCALEFACTORN2 - 1); + t15 = L_sub(x07, x15); + + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + + t01 = L_shr_pos(L_add(t06, t14), SCALEFACTORN2 - 1); + t02 = L_shr_pos(L_sub(t06, t14), SCALEFACTORN2 - 1); + t00 = L_shr_pos(L_add(t07, t15), SCALEFACTORN2 - 1); + t03 = L_shr_pos(L_sub(t07, t15), SCALEFACTORN2 - 1); + + s12 = Mpy_32_32_lc3plus(L_add(t00, t02), C81_32); + s14 = Mpy_32_32_lc3plus(L_sub(t00, t02), C81_32); + s13 = Mpy_32_32_lc3plus(L_sub(t03, t01), C81_32); + s15 = Mpy_32_32_lc3plus(L_add(t01, t03), C82_32); + + re[sx * i + sx * 0 * dim1] = L_add(s00, s02); + move32(); + im[sx * i + sx * 0 * dim1] = L_add(s01, s03); + move32(); + re[sx * i + sx * 1 * dim1] = L_add(s10, s12); + move32(); + im[sx * i + sx * 1 * dim1] = L_add(s11, s13); + move32(); + re[sx * i + sx * 2 * dim1] = L_sub(s04, s06); + move32(); + im[sx * i + sx * 2 * dim1] = L_sub(s05, s07); + move32(); + re[sx * i + sx * 3 * dim1] = L_add(s08, s14); + move32(); + im[sx * i + sx * 3 * dim1] = L_add(s09, s15); + move32(); + re[sx * i + sx * 4 * dim1] = L_sub(s00, s02); + move32(); + im[sx * i + sx * 4 * dim1] = L_sub(s01, s03); + move32(); + re[sx * i + sx * 5 * dim1] = L_sub(s10, s12); + move32(); + im[sx * i + sx * 5 * dim1] = L_sub(s11, s13); + move32(); + re[sx * i + sx * 6 * dim1] = L_add(s04, s06); + move32(); + im[sx * i + sx * 6 * dim1] = L_add(s05, s07); + move32(); + re[sx * i + sx * 7 * dim1] = L_sub(s08, s14); + move32(); + im[sx * i + sx * 7 * dim1] = L_sub(s09, s15); + move32(); + } + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Combined FFT + * + * \param [i/o] re real part + * \param [i/o] im imag part + * \param [i ] W rotation factor + * \param [i ] dim1 length of fft1 + * \param [i ] dim2 length of fft2 + * \param [i ] sx stride real and imag part + * \param [i ] sc stride phase rotation coefficients + * \param [tmp] x 32-bit workbuffer of length=2*len + * \param [i ] Woff offset for addressing the rotation vector table + * + * \return void + */ + + +static void fftN2(Word32 *re, Word32 *im, +#ifdef ENABLE_HR_MODE + const Word32 *W, +#else + const Word16 *W, +#endif + Word16 dim1, Word16 dim2, Word16 sx, Word16 sc, + Word16 Woff + , Word8 *scratchBuffer +#ifdef ENABLE_FFT_RESCALE + , Word16 *scale +#endif + ) +{ + Dyn_Mem_Deluxe_In(Counter i, j;); + + Word32 *x = scratchAlign(scratchBuffer, 0); + + FOR (i = 0; i < dim2; i++) + { + FOR (j = 0; j < dim1; j++) + { + x[2 * i * dim1 + 2 * j] = re[sx * i + sx * j * dim2]; + move32(); + x[2 * i * dim1 + 2 * j + 1] = im[sx * i + sx * j * dim2]; + move32(); + } + } + + SWITCH (dim1) + { + + case 4: + FOR (i = 0; i < dim2; i++) + { + fft4(&x[i * 2 * dim1]); + } + BREAK; + case 8: + FOR (i = 0; i < dim2; i++) + { + fft8(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + BREAK; + + case 10: + FOR (i = 0; i < dim2; i++) + { + fft10(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + BREAK; + case 15: + FOR (i = 0; i < dim2; i++) + { + fft15(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + + BREAK; + case 16: + FOR (i = 0; i < dim2; i++) + { + fft16(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + BREAK; + case 20: + FOR (i = 0; i < dim2; i++) + { + fft20(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + BREAK; + case 30: + FOR (i = 0; i < dim2; i++) + { + fft30(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + BREAK; + case 32: + FOR (i = 0; i < dim2; i++) + { + fft32(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); + } + BREAK; +#ifdef ENABLE_HR_MODE +#if (defined LC3_FFT15) + case 60: + FOR (i = 0; i < dim2; i++) + { +#ifndef ENABLE_FFT_RESCALE + fftN2(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], RotVector_480, 15, 4, sx, 4, 60, scratch); +#else + fftN2(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], RotVector_480, 15, 4, sx, 4, 60, scratch, NULL); +#endif + } + BREAK; +#endif +#endif + default: ASSERT(0); + } + +#ifdef ENABLE_FFT_RESCALE + IF (scale) + { + *scale = s_max(sub(getScaleFactor32_lc3plus(x, dim1 * dim2 * 2), FFT_RESCALE_HR), 0); move16(); + +#if defined(FUNCTION_scaleValues_32) + scaleValues_32(x, dim1 * dim2, *scale); +#else + FOR (i = 0; i < dim1 * dim2 * 2; i++) + { + x[i] = L_shl_pos(x[i], *scale); move32(); + } + } +#endif +#endif + + SWITCH (dim2) + { + case 4: + { + Word32 x00, x01, x02, x03, x04, x05, x06, x07; + Word32 t00, t01, t02, t03, t04, t05, t06, t07; + + j = add(8, 0); + FOR (i = 0; i < dim1; i++) + { + cplxMpy4_4_1(x00, x01, x[2 * i + 2 * 0 * dim1], x[2 * i + 2 * 0 * dim1 + 1]); + IF (i == 0) + { + cplxMpy4_4_1(x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1]); + cplxMpy4_4_1(x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1]); + cplxMpy4_4_1(x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1]); + } + ELSE + { + cplxMpy4_4_0(x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1], + W[sc * i + j * 1 * dim1 - Woff], W[sc * i + j * 1 * dim1 + 1 - Woff]); + cplxMpy4_4_0(x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1], + W[sc * i + j * 2 * dim1 - Woff], W[sc * i + j * 2 * dim1 + 1 - Woff]); + cplxMpy4_4_0(x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1], + W[sc * i + j * 3 * dim1 - Woff], W[sc * i + j * 3 * dim1 + 1 - Woff]); + } + + t00 = L_add(x00, x04); + t02 = L_sub(x00, x04); + t01 = L_add(x01, x05); + t03 = L_sub(x01, x05); + t04 = L_add(x02, x06); + t07 = L_sub(x02, x06); + t05 = L_add(x07, x03); + t06 = L_sub(x07, x03); + + re[sx * i + sx * 0 * dim1] = L_add(t00, t04); + move32(); + im[sx * i + sx * 0 * dim1] = L_add(t01, t05); + move32(); + re[sx * i + sx * 1 * dim1] = L_sub(t02, t06); + move32(); + im[sx * i + sx * 1 * dim1] = L_sub(t03, t07); + move32(); + re[sx * i + sx * 2 * dim1] = L_sub(t00, t04); + move32(); + im[sx * i + sx * 2 * dim1] = L_sub(t01, t05); + move32(); + re[sx * i + sx * 3 * dim1] = L_add(t02, t06); + move32(); + im[sx * i + sx * 3 * dim1] = L_add(t03, t07); + move32(); + } + + BREAK; + } + +#ifdef CR8_G_ADD_75MS + case 6: + { + Word32 y[2 * 10]; + FOR (j = 0; j < dim2; j++) + { + cplxMpy4_12_1(y[2 * j], y[2 * j + 1], x[2 * 0 + 2 * j * dim1], x[2 * 0 + 2 * j * dim1 + 1]); + } + fft6(&y[0], &y[1], 2); + FOR (j = 0; j < dim2; j++) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + move32(); + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + move32(); + } + + FOR (i = 1; i < dim1; i++) + { + cplxMpy4_12_1(y[2 * (0 + 0)], y[2 * (0 + 0) + 1], x[2 * i + 2 * (0 + 0) * dim1], + x[2 * i + 2 * (0 + 0) * dim1 + 1]); + cplxMpy4_12_0(y[2 * (0 + 1)], y[2 * (0 + 1) + 1], x[2 * i + 2 * (0 + 1) * dim1], + x[2 * i + 2 * (0 + 1) * dim1 + 1], W[sc * i + sc * (0 + 1) * dim1 - Woff], + W[sc * i + sc * (0 + 1) * dim1 + 1 - Woff]); + FOR (j = 2; j < dim2; j = j + 2) + { + cplxMpy4_12_0(y[2 * (j + 0)], y[2 * (j + 0) + 1], x[2 * i + 2 * (j + 0) * dim1], + x[2 * i + 2 * (j + 0) * dim1 + 1], W[sc * i + sc * (j + 0) * dim1 - Woff], + W[sc * i + sc * (j + 0) * dim1 + 1 - Woff]); + cplxMpy4_12_0(y[2 * (j + 1)], y[2 * (j + 1) + 1], x[2 * i + 2 * (j + 1) * dim1], + x[2 * i + 2 * (j + 1) * dim1 + 1], W[sc * i + sc * (j + 1) * dim1 - Woff], + W[sc * i + sc * (j + 1) * dim1 + 1 - Woff]); + } + fft6(&y[0], &y[1], 2); + FOR (j = 0; j < dim2; j++) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + move32(); + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + move32(); + } + } + BREAK; + } +#endif + + case 8: + { + Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15; + Word32 t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15; + Word32 s00, s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15; + + FOR (i = 0; i < dim1; i++) + { + cplxMpy4_8_1(x00, x01, x[2 * i + 2 * 0 * dim1], x[2 * i + 2 * 0 * dim1 + 1]); + IF (i == 0) + { + cplxMpy4_8_1(x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1]); + cplxMpy4_8_1(x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1]); + cplxMpy4_8_1(x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1]); + cplxMpy4_8_1(x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1]); + cplxMpy4_8_1(x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1]); + cplxMpy4_8_1(x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1]); + cplxMpy4_8_1(x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1]); + } + ELSE + { + cplxMpy4_8_0(x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1], + W[sc * i + sc * 1 * dim1 - Woff], W[sc * i + sc * 1 * dim1 + 1 - Woff]); + cplxMpy4_8_0(x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1], + W[sc * i + sc * 2 * dim1 - Woff], W[sc * i + sc * 2 * dim1 + 1 - Woff]); + cplxMpy4_8_0(x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1], + W[sc * i + sc * 3 * dim1 - Woff], W[sc * i + sc * 3 * dim1 + 1 - Woff]); + cplxMpy4_8_0(x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1], + W[sc * i + sc * 4 * dim1 - Woff], W[sc * i + sc * 4 * dim1 + 1 - Woff]); + cplxMpy4_8_0(x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1], + W[sc * i + sc * 5 * dim1 - Woff], W[sc * i + sc * 5 * dim1 + 1 - Woff]); + cplxMpy4_8_0(x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1], + W[sc * i + sc * 6 * dim1 - Woff], W[sc * i + sc * 6 * dim1 + 1 - Woff]); + cplxMpy4_8_0(x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1], + W[sc * i + sc * 7 * dim1 - Woff], W[sc * i + sc * 7 * dim1 + 1 - Woff]); + } + + t00 = L_shr_pos(L_add(x00, x08), SCALEFACTORN2 - 1); + t02 = L_shr_pos(L_sub(x00, x08), SCALEFACTORN2 - 1); + t01 = L_shr_pos(L_add(x01, x09), SCALEFACTORN2 - 1); + t03 = L_shr_pos(L_sub(x01, x09), SCALEFACTORN2 - 1); + t04 = L_shr_pos(L_add(x02, x10), SCALEFACTORN2 - 1); + t06 = L_sub(x02, x10); + t05 = L_shr_pos(L_add(x03, x11), SCALEFACTORN2 - 1); + t07 = L_sub(x03, x11); + t08 = L_shr_pos(L_add(x04, x12), SCALEFACTORN2 - 1); + t10 = L_shr_pos(L_sub(x04, x12), SCALEFACTORN2 - 1); + t09 = L_shr_pos(L_add(x05, x13), SCALEFACTORN2 - 1); + t11 = L_shr_pos(L_sub(x05, x13), SCALEFACTORN2 - 1); + t12 = L_shr_pos(L_add(x06, x14), SCALEFACTORN2 - 1); + t14 = L_sub(x06, x14); + t13 = L_shr_pos(L_add(x07, x15), SCALEFACTORN2 - 1); + t15 = L_sub(x07, x15); + + s00 = L_add(t00, t08); + s04 = L_sub(t00, t08); + s01 = L_add(t01, t09); + s05 = L_sub(t01, t09); + s08 = L_sub(t02, t11); + s10 = L_add(t02, t11); + s09 = L_add(t03, t10); + s11 = L_sub(t03, t10); + s02 = L_add(t04, t12); + s07 = L_sub(t04, t12); + s03 = L_add(t05, t13); + s06 = L_sub(t13, t05); + + t01 = L_shr_pos(L_add(t06, t14), SCALEFACTORN2 - 1); + t02 = L_shr_pos(L_sub(t06, t14), SCALEFACTORN2 - 1); + t00 = L_shr_pos(L_add(t07, t15), SCALEFACTORN2 - 1); + t03 = L_shr_pos(L_sub(t07, t15), SCALEFACTORN2 - 1); + + s12 = Mpy_32_xx(L_add(t00, t02), C81); + s14 = Mpy_32_xx(L_sub(t00, t02), C81); + s13 = Mpy_32_xx(L_sub(t03, t01), C81); + s15 = Mpy_32_xx(L_add(t01, t03), C82); + + re[sx * i + sx * 0 * dim1] = L_add(s00, s02); + move32(); + im[sx * i + sx * 0 * dim1] = L_add(s01, s03); + move32(); + re[sx * i + sx * 1 * dim1] = L_add(s10, s12); + move32(); + im[sx * i + sx * 1 * dim1] = L_add(s11, s13); + move32(); + re[sx * i + sx * 2 * dim1] = L_sub(s04, s06); + move32(); + im[sx * i + sx * 2 * dim1] = L_sub(s05, s07); + move32(); + re[sx * i + sx * 3 * dim1] = L_add(s08, s14); + move32(); + im[sx * i + sx * 3 * dim1] = L_add(s09, s15); + move32(); + re[sx * i + sx * 4 * dim1] = L_sub(s00, s02); + move32(); + im[sx * i + sx * 4 * dim1] = L_sub(s01, s03); + move32(); + re[sx * i + sx * 5 * dim1] = L_sub(s10, s12); + move32(); + im[sx * i + sx * 5 * dim1] = L_sub(s11, s13); + move32(); + re[sx * i + sx * 6 * dim1] = L_add(s04, s06); + move32(); + im[sx * i + sx * 6 * dim1] = L_add(s05, s07); + move32(); + re[sx * i + sx * 7 * dim1] = L_sub(s08, s14); + move32(); + im[sx * i + sx * 7 * dim1] = L_sub(s09, s15); + move32(); + } + BREAK; + } + + case 12: + { + Word32 y[2 * 20]; + FOR (j = 0; j < dim2; j++) + { + cplxMpy4_12_1(y[2 * j], y[2 * j + 1], x[2 * 0 + 2 * j * dim1], x[2 * 0 + 2 * j * dim1 + 1]); + } + fft12(y); + FOR (j = 0; j < dim2; j++) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + move32(); + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + move32(); + } + + FOR (i = 1; i < dim1; i++) + { + cplxMpy4_12_1(y[2 * (0 + 0)], y[2 * (0 + 0) + 1], x[2 * i + 2 * (0 + 0) * dim1], + x[2 * i + 2 * (0 + 0) * dim1 + 1]); + cplxMpy4_12_0(y[2 * (0 + 1)], y[2 * (0 + 1) + 1], x[2 * i + 2 * (0 + 1) * dim1], + x[2 * i + 2 * (0 + 1) * dim1 + 1], W[sc * i + sc * (0 + 1) * dim1 - Woff], + W[sc * i + sc * (0 + 1) * dim1 + 1 - Woff]); + FOR (j = 2; j < dim2; j = j + 2) + { + cplxMpy4_12_0(y[2 * (j + 0)], y[2 * (j + 0) + 1], x[2 * i + 2 * (j + 0) * dim1], + x[2 * i + 2 * (j + 0) * dim1 + 1], W[sc * i + sc * (j + 0) * dim1 - Woff], + W[sc * i + sc * (j + 0) * dim1 + 1 - Woff]); + cplxMpy4_12_0(y[2 * (j + 1)], y[2 * (j + 1) + 1], x[2 * i + 2 * (j + 1) * dim1], + x[2 * i + 2 * (j + 1) * dim1 + 1], W[sc * i + sc * (j + 1) * dim1 - Woff], + W[sc * i + sc * (j + 1) * dim1 + 1 - Woff]); + } + fft12(y); + FOR (j = 0; j < dim2; j++) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + move32(); + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + move32(); + } + } + BREAK; + } + +#if defined(ENABLE_HR_MODE) + case 16: + { + Word32 y[2 * 20]; + FOR (j = 0; j < dim2; j++) + { + cplxMpy4_16_1(y[2 * j], y[2 * j + 1], x[2 * 0 + 2 * j * dim1], x[2 * 0 + 2 * j * dim1 + 1]); + } + + fft16(&y[0], &y[1], 2); + FOR (j = 0; j < dim2; j++) + { + re[sx * 0 + sx * j * dim1] = y[2 * j]; + move32(); + im[sx * 0 + sx * j * dim1] = y[2 * j + 1]; + move32(); + } + + FOR (i = 1; i < dim1; i++) + { + cplxMpy4_16_1(y[2 * (0 + 0)], y[2 * (0 + 0) + 1], x[2 * i + 2 * (0 + 0) * dim1], + x[2 * i + 2 * (0 + 0) * dim1 + 1]); + cplxMpy4_16_0(y[2 * (0 + 1)], y[2 * (0 + 1) + 1], x[2 * i + 2 * (0 + 1) * dim1], + x[2 * i + 2 * (0 + 1) * dim1 + 1], W[sc * i + sc * (0 + 1) * dim1 - Woff], + W[sc * i + sc * (0 + 1) * dim1 + 1 - Woff]); + FOR (j = 2; j < dim2; j = j + 2) + { + cplxMpy4_16_0(y[2 * (j + 0)], y[2 * (j + 0) + 1], x[2 * i + 2 * (j + 0) * dim1], + x[2 * i + 2 * (j + 0) * dim1 + 1], W[sc * i + sc * (j + 0) * dim1 - Woff], + W[sc * i + sc * (j + 0) * dim1 + 1 - Woff]); + cplxMpy4_16_0(y[2 * (j + 1)], y[2 * (j + 1) + 1], x[2 * i + 2 * (j + 1) * dim1], + x[2 * i + 2 * (j + 1) * dim1 + 1], W[sc * i + sc * (j + 1) * dim1 - Woff], + W[sc * i + sc * (j + 1) * dim1 + 1 - Woff]); + } + fft16(&y[0], &y[1], 2); + FOR (j = 0; j < dim2; j++) + { + re[sx * i + sx * j * dim1] = y[2 * j]; + move32(); + im[sx * i + sx * j * dim1] = y[2 * j + 1]; + move32(); + } + } + BREAK; + } +# endif + default: ASSERT(0); + } + + Dyn_Mem_Deluxe_Out(); +} + +/** + * \brief Complex valued FFT + * + * \param [i/o] re real part + * \param [i/o] im imag part + * \param [i ] sizeOfFft length of fft + * \param [i ] s stride real and imag part + * \param [i ] scale scalefactor + * + * \return void + */ + + + +/* x is the scratch buffer */ +void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 length, Word16 s, Word16 *scale, Word32 *x) +{ +#if (defined ENABLE_FFT_RESCALE) && ((defined LC3_FFT30) || (defined ENABLE_HR_MODE)) + Word16 fftN2scale = 0; +#endif + +#ifdef ENABLE_HR_MODE + Word8 scratch[6128] = {0}; +#else + Word8 scratch[4068] = {0}; +#endif + + SWITCH (length) + { + + case 10: + fft10(re, im, s); + *scale = add(*scale, SCALEFACTOR10); + move16(); + BREAK; + case 16: + fft16(re, im, s); + *scale = add(*scale, SCALEFACTOR16); + move16(); + BREAK; + case 20: + fft20(re, im, s); + *scale = add(*scale, SCALEFACTOR20); + move16(); + BREAK; + case 30: + fft30(re, im, s); + *scale = add(*scale, SCALEFACTOR30); + move16(); + BREAK; + case 32: + fft32(re, im, s); + *scale = add(*scale, SCALEFACTOR32); + move16(); + BREAK; + case 40: + fft40(re, im, s, x); + *scale = add(*scale, SCALEFACTOR40); + move16(); + BREAK; + case 48: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_32_12, 4, 12, s, 16, 64, scratch); +#else + fftN2(re, im, RotVector_32_12, 4, 12, s, 16, 64, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR48); + move16(); + BREAK; + case 60: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_480, 15, 4, s, 4, 60, scratch); +#else + fftN2(re, im, RotVector_480, 15, 4, s, 4, 60, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR60); + move16(); + BREAK; + case 64: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_32_8, 8, 8, s, 8, 64, scratch); +#else + fftN2(re, im, RotVector_32_8, 8, 8, s, 8, 64, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR64); + move16(); + BREAK; + case 80: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_320, 10, 8, s, 4, 40, scratch); +#else + fftN2(re, im, RotVector_320, 10, 8, s, 4, 40, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR80); + move16(); + BREAK; + case 90: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_15_6, 15, 6, s, 2, 30, scratch); +#else + fftN2(re, im, RotVector_15_6, 15, 6, s, 2, 30, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR90); + move16(); + BREAK; + + case 120: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_480, 15, 8, s, 4, 60, scratch); +#else + fftN2(re, im, RotVector_480, 15, 8, s, 4, 60, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR120); + move16(); + BREAK; + case 128: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_32_8, 16, 8, s, 4, 64, scratch); +#else + fftN2(re, im, RotVector_32_8, 16, 8, s, 4, 64, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR128); + move16(); + BREAK; + case 160: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_320, 20, 8, s, 2, 40, scratch); +#else + fftN2(re, im, RotVector_320, 20, 8, s, 2, 40, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR160); + move16(); + BREAK; + case 180: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_360, 15, 12, s, 4, 60, scratch); + *scale = add(*scale, SCALEFACTOR180); +#else + fftN2(re, im, RotVector_360, 15, 12, s, 4, 60, scratch, &fftN2scale); + *scale = add(*scale, SCALEFACTOR180); + *scale = sub(*scale, fftN2scale); move16(); +#endif + + move16(); + BREAK; + case 192: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_32_12, 16, 12, s, 4, 64, scratch); +#else + fftN2(re, im, RotVector_32_12, 16, 12, s, 4, 64, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR192); + move16(); + BREAK; + case 240: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_480, 30, 8, s, 2, 60, scratch); + *scale = add(*scale, SCALEFACTOR240); +#else + fftN2(re, im, RotVector_480, 30, 8, s, 2, 60, scratch, &fftN2scale); + *scale = add(*scale, SCALEFACTOR240); + *scale = sub(*scale, fftN2scale); move16(); +#endif + move16(); + BREAK; + case 256: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_32_8, 32, 8, s, 2, 64, scratch); +#else + fftN2(re, im, RotVector_32_8, 32, 8, s, 2, 64, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR256); + move16(); + BREAK; + case 384: +#ifndef ENABLE_FFT_RESCALE + fftN2(re, im, RotVector_32_12, 32, 12, s, 2, 64, scratch); +#else + fftN2(re, im, RotVector_32_12, 32, 12, s, 2, 64, scratch, NULL); +#endif + *scale = add(*scale, SCALEFACTOR384); + move16(); + BREAK; +#ifdef ENABLE_HR_MODE +#ifdef CR8_G_ADD_75MS + case 360: + fftN2(re, im, RotVector_720, 30, 12, s, 2, 60, scratch, &fftN2scale); + *scale = add(*scale, SCALEFACTOR360); move16(); + *scale = sub(*scale, fftN2scale); move16(); + BREAK; +#endif + case 480: +#ifndef ENABLE_FFT_RESCALE +#ifndef ENABLE_FFT_30X16 + fftN2(re, im, RotVector_960, 60, 8, s, 2, 120, scratch); +#else + fftN2(re, im, RotVector_30_16, 30, 16, s, 2, 60, scratch); +#endif + *scale = add(*scale, SCALEFACTOR480); move16(); +#else +#ifndef ENABLE_FFT_30X16 + fftN2(re, im, RotVector_960, 60, 8, s, 2, 120, scratch, &fftN2scale); +#else + fftN2(re, im, RotVector_30_16, 30, 16, s, 2, 60, scratch, &fftN2scale); +#endif + *scale = add(*scale, SCALEFACTOR480); move16(); + *scale = sub(*scale, fftN2scale); move16(); +#endif + BREAK; +#endif + default: ASSERT(0); + } +} + + +#define RFFT_TWIDDLE1(x, t1, t2, t3, t4, w1, w2, xb0, xb1, xt0, xt1) \ + do \ + { \ + xb0 = L_shr_pos(x[2 * i + 0], 2); \ + xb1 = L_shr_pos(x[2 * i + 1], 2); \ + xt0 = L_shr_pos(x[sizeOfFft - 2 * i + 0], 2); \ + xt1 = L_shr_pos(x[sizeOfFft - 2 * i + 1], 2); \ + t1 = L_sub(xb0, xt0); \ + t2 = L_add(xb1, xt1); \ + t3 = L_sub(Mpy_32_32_lc3plus(t1, w1), Mpy_32_32_lc3plus(t2, w2)); \ + t4 = L_add(Mpy_32_32_lc3plus(t1, w2), Mpy_32_32_lc3plus(t2, w1)); \ + t1 = L_add(xb0, xt0); \ + t2 = L_sub(xb1, xt1); \ + } while (0) + +#define RFFT_TWIDDLE2(x, t1, t2, t3, t4, w1, w2, xb0, xb1, xt0, xt1) \ + do \ + { \ + xb0 = L_shr_pos(x[2 * i + 0], 2); \ + xb1 = L_shr_pos(x[2 * i + 1], 2); \ + xt0 = L_shr_pos(x[sizeOfFft - 2 * i + 0], 2); \ + xt1 = L_shr_pos(x[sizeOfFft - 2 * i + 1], 2); \ + t1 = L_sub(xb0, xt0); \ + t2 = L_add(xb1, xt1); \ + t3 = L_add(Mpy_32_32_lc3plus(t1, w1), Mpy_32_32_lc3plus(t2, w2)); \ + t4 = L_sub(Mpy_32_32_lc3plus(t2, w1), Mpy_32_32_lc3plus(t1, w2)); \ + t1 = L_add(xb0, xt0); \ + t2 = L_sub(xb1, xt1); \ + } while (0) + + + +static const Word32 *rfft_twid(int size) +{ + SWITCH (size) + { + case 32: return RealFFT32_twid; + case 40: return RealFFT40_twid; + case 64: return RealFFT64_twid; + case 80: return RealFFT80_twid; + case 96: return RealFFT96_twid; + case 128: return RealFFT128_twid; + case 192: return RealFFT192_twid; + case 256: return RealFFT256_twid; + case 384: return RealFFT384_twid; + case 512: return RealFFT512_twid; + case 768: return RealFFT768_twid; + default: ASSERT(0); + } + return NULL; +} + + +void BASOP_rfftN(Word32 *x, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer) +{ + Dyn_Mem_Deluxe_In(Counter i; Word16 sizeOfFft2, sizeOfFft4, sizeOfFft8; Word32 t1, t2, t3, t4, xb0, xb1, xt0, xt1; + Word32 * workBuffer; const Word32 *w32;); + + workBuffer = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * sizeOfFft */ + w32 = rfft_twid(sizeOfFft); + + sizeOfFft2 = shr_pos(sizeOfFft, 1); + sizeOfFft4 = shr_pos(sizeOfFft, 2); + sizeOfFft8 = shr_pos(sizeOfFft, 3); + + BASOP_cfft_lc3plus(&x[0], &x[1], sizeOfFft2, 2, scale, workBuffer); + + xb0 = L_shr_pos(x[0], 1); + xb1 = L_shr_pos(x[1], 1); + x[0] = L_add(xb0, xb1); + move32(); + x[1] = L_sub(xb0, xb1); + move32(); + + FOR (i = 1; i < sizeOfFft8; i++) + { + RFFT_TWIDDLE1(x, t1, t2, t3, t4, w32[2 * i + 1], w32[2 * i], xb0, xb1, xt0, xt1); + x[2 * i] = L_sub(t1, t3); + move32(); + x[2 * i + 1] = L_sub(t2, t4); + move32(); + x[sizeOfFft - 2 * i] = L_add(t1, t3); + move32(); + x[sizeOfFft - 2 * i + 1] = L_negate(L_add(t2, t4)); + move32(); + } + + FOR (i = sizeOfFft8; i < sizeOfFft4; i++) + { + RFFT_TWIDDLE1(x, t1, t2, t3, t4, w32[(2 * sizeOfFft4 - 2 * i)], w32[(2 * sizeOfFft4 - 2 * i + 1)], xb0, xb1, + xt0, xt1); + x[2 * i] = L_sub(t1, t3); + move32(); + x[2 * i + 1] = L_sub(t2, t4); + move32(); + x[sizeOfFft - 2 * i] = L_add(t1, t3); + move32(); + x[sizeOfFft - 2 * i + 1] = L_negate(L_add(t2, t4)); + move32(); + } + + x[sizeOfFft - 2 * i] = L_shr_pos(x[2 * i + 0], 1); + move32(); + x[sizeOfFft - 2 * i + 1] = L_negate(L_shr_pos(x[2 * i + 1], 1)); + move32(); + + *scale = add(*scale, 1); + move16(); + + Dyn_Mem_Deluxe_Out(); +} + + + +void BASOP_irfftN(Word32 *x, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer) +{ + Dyn_Mem_Deluxe_In(Word16 sizeOfFft2, sizeOfFft4, sizeOfFft8; Word32 t1, t2, t3, t4, xb0, xb1, xt0, xt1; + Word32 * workBuffer; const Word32 *w32; Counter i;); + + workBuffer = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * BASOP_CFFT_MAX_LENGTH */ + + w32 = rfft_twid(sizeOfFft); + + sizeOfFft2 = shr_pos(sizeOfFft, 1); + sizeOfFft4 = shr_pos(sizeOfFft, 2); + sizeOfFft8 = shr_pos(sizeOfFft, 3); + + xb0 = L_shr_pos(x[0], 2); + xb1 = L_shr_pos(x[1], 2); + x[0] = L_add(xb0, xb1); + move32(); + x[1] = L_sub(xb1, xb0); + move32(); + + FOR (i = 1; i < sizeOfFft8; i++) + { + RFFT_TWIDDLE2(x, t1, t2, t3, t4, w32[2 * i + 1], w32[2 * i], xb0, xb1, xt0, xt1); + x[2 * i] = L_sub(t1, t3); + move32(); + x[2 * i + 1] = L_sub(t4, t2); + move32(); + x[sizeOfFft - 2 * i] = L_add(t1, t3); + move32(); + x[sizeOfFft - 2 * i + 1] = L_add(t2, t4); + move32(); + } + + FOR (i = sizeOfFft8; i < sizeOfFft4; i++) + { + RFFT_TWIDDLE2(x, t1, t2, t3, t4, w32[(2 * sizeOfFft4 - 2 * i)], w32[(2 * sizeOfFft4 - 2 * i + 1)], xb0, xb1, + xt0, xt1); + x[2 * i] = L_sub(t1, t3); + move32(); + x[2 * i + 1] = L_sub(t4, t2); + move32(); + x[sizeOfFft - 2 * i] = L_add(t1, t3); + move32(); + x[sizeOfFft - 2 * i + 1] = L_add(t2, t4); + move32(); + } + + x[sizeOfFft - 2 * i] = L_shr_pos(x[2 * i + 0], 1); + move32(); + x[sizeOfFft - 2 * i + 1] = L_shr_pos(x[2 * i + 1], 1); + move32(); + + BASOP_cfft_lc3plus(&x[0], &x[1], sizeOfFft2, 2, scale, workBuffer); + + /* If you want BASOP_irfft to be inverse to BASOP_rfft then the result needs + * to be normalised by sizeOfFft */ + FOR (i = 0; i < sizeOfFft2; i++) + { + x[2 * i + 1] = L_negate(x[2 * i + 1]); + move32(); + } + + *scale = add(*scale, 2); + move16(); + + Dyn_Mem_Deluxe_Out(); +} + + diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h new file mode 100644 index 000000000..90571c6cd --- /dev/null +++ b/lib_lc3plus/functions.h @@ -0,0 +1,836 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef FUNCTIONS_H +#define FUNCTIONS_H + +#include "defines.h" + +#include "stl.h" +#ifdef DYNMEM_COUNT +#include "dynmem.h" +#endif + +#include "basop_util_lc3plus.h" +#include "basop32.h" +#include "constants.h" +#include "lc3.h" +#include "setup_dec_lc3.h" /* for decoder state handle ptr */ +#include "setup_enc_lc3.h" /* for encoder state handle ptr */ +#include "basop_mpy_lc3plus.h" + +#include +#include +#include +#include +#include + +#define PRINTF printf /* C console debug, */ +#define ASSERT(test) assert(test) + +typedef struct +{ + Word16 lead_sign_ind; /* this MPVQ index is the first part of the total PVQ index */ + UWord32 index, size; /* this MPVQ index is the second part of the total PVQ index */ + Word16 dim, k_val; + Word16 vec[PVQ_MAX_VEC_SIZE]; /* integer vector */ +} PvqEntry_fx; + +typedef enum { + LC3_CON_TEC_NS_STD, /* 0 */ + LC3_CON_TEC_PHASE_ECU, /* 2 */ + LC3_CON_TEC_TDPLC, /* 3 */ + LC3_CON_TEC_NS_ADV, /* 4 */ + LC3_CON_TEC_FREQ_MUTING, /* 5 */ +} LC3_ConcealTechnique; + +void WarnMsg(char *msg); +void ExitMsg(char *msg); +void AssertMsg(int true_flag, char *msg); + +void processTnsDecoder_fx(Word16 rc_idx[], Word32 x[], Word16 xLen, Word16 order[], Word16 *x_e, Word16 BW_stopband_idx, + Word16 frame_dms, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cutoff_idx, Word16 order[], + Word16 *numfilters, Word16 enable_lpc_weighting, Word16 nSubdivisions, Word16 frame_dms, + Word16 max_len, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif + , Word16 near_nyquist_flag +); + +void TnsUpdate_fx(Word16 *tns_numfilters, Word16 *long_startfreq, const Word16 **subdiv_startfreq, + const Word16 **subdiv_stopfreq, Word16 frame_length, Word16 tab_idx); + +void processResidualDecoding_fx(Word32 spectrum[], Word16 spectrum_e, Word16 L_spec, UWord8 prm[], Word16 resQBits +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void processPreemph_fx(Word16 *x, Word16 len, Word16 mem[], Word16 memLen, Word16 out[], Word16 *outLen, Word16 mu); + +void processNoiseFilling_fx(Word32 xq[], Word16 nfseed, Word16 xq_e, Word16 fac_ns_idx, Word16 BW_cutoff_idx, + Word16 frame_dms, Word16 fac_ns_pc, Word16 spec_inv_idx, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], +#ifdef ENABLE_HR_MODE + Word32 xq[], +#else + Word16 xq[], +#endif + Word16 gg, Word16 gg_e, Word16 BW_cutoff_idx, Word16 frame_dms, Word16 target_bytes, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void processMdctShaping_fx(Word32 x[], +#ifdef ENABLE_HR_MODE + Word32 scf[], +#else + Word16 scf[], +#endif + Word16 scf_exp[], const Word16 bands_offset[], Word16 fdns_npts); + +void processScfScaling(Word16 scf_exp[], Word16 fdns_npts, Word16 *x_e); + +void processMdct_fx( +#ifdef ENABLE_HR_MODE + Word32 x[], +#else + Word16 x[], +#endif + Word16 x_exp, Word16 N, +#ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION +# ifdef ENABLE_HR_MODE + Word16 hrmode, /* i: indicate high precision */ +# endif +#endif +#ifdef ENABLE_HR_MODE + const Word32 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ +#else + const Word16 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ +#endif + Word16 wLen, +#ifdef ENABLE_HR_MODE + Word32 mem[], /* i/o: last block of input samples */ +#else + Word16 mem[], /* i/o: last block of input samples */ +#endif + Word16 memLen, + Word32 y[], Word16 *y_e, Word8 *scratchBuffer); + +void processLevinson_fx(Word32 *lpc, Word32 *ac, Word16 N, Word16 *rc, Word32 *pred_err, Word8 *scratchBuffer); + +void lpc2rc(Word32 *lpc, Word16 *rc, Word16 N); + +void ProcessingIMDCT(Word32 y[], Word16 *y_e, +#ifdef ENABLE_HR_MODE + const Word32 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ + Word32 mem[], /* i/o: overlap add memory */ +#else + const Word16 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ + Word16 mem[], /* i/o: overlap add memory */ +#endif + Word16 *mem_e, +#ifdef ENABLE_HR_MODE + Word32 x[], /* o: time signal out */ +#else + Word16 x[], /* o: time signal out */ +#endif + Word16 wLen, + Word16 N, Word16 memLen, Word16 frame_dms, + Word16 concealMethod, Word16 bfi, Word16 prev_bfi, Word16 nbLostFramesInRow, AplcSetup *plcAd, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +#ifdef ENABLE_HR_MODE +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION +void dct_IV(Word32 *pDat, Word16 *pDat_e, Word16 L, Word16 hrmode, Word32 *workBuffer); +# else /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ +void dct_IV(Word32 *pDat, Word16 *pDat_e, Word16 L, Word32 *workBuffer); +# endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ +#else +void dct_IV(Word32 *pDat, Word16 *pDat_e, Word16 L, Word32 *workBuffer); +#endif + +#ifdef ENABLE_HR_MODE +Word16 find_last_nz_pair(const Word32 x[], Word16 length); +#else +Word16 find_last_nz_pair(const Word16 x[], Word16 length); +#endif + +PvqEntry_fx mpvq_index_fx(const Word16 *vec_in, Word16 dim_in, Word16 k_val_local); +void mpvq_deindex_fx(const PvqEntry_fx *entry, UWord32 *h_mem, Word16 *vec_out); + +void pvq_enc_search_fx(const Word16 *x, /* i: target vector to quantize Qin */ + Word16 * rt_far, /* o: outl_far o, raw pulses (non-scaled short) Q0 */ + Word16 * rt_near, /* o: outl_near o, raw pulses (non-scaled short) Q0 */ + Word16 * rtA, /* o: A section raw pulses (non-scaled short) Q0 */ + Word16 * rtB, /* o: B section raw pulses (non-scaled short) Q0 */ + Word32 *L_corr, /* o: 4 un-normalized correlation sums for outl_far, near, outl, A, AB */ + Word32 *L_search_en, /* o: 4 energy sums for out_far, outl_near, A, AB */ + Word16 *pulses_fin, /* i: number of allocated pulses to outl A, AB section */ + Word16 *pulses_proj, /* i: number of proj pulses pulses to outl, A , AB section */ + + const Word16 dim, /* i: Length of vector */ + const Word16 dimA /* i: Length of vector A section */ +); + +PvqEntry_fx get_size_mpvq_calc_offset_fx(Word16 dim_in, Word16 k_val_in, UWord32 *h_mem); + +Word16 pvq_dec_deidx_fx( /* out BER detected 1 , ok==0 */ + Word16 * y, /* o: decoded vector (non-scaled int) */ + const Word16 k_val, /* i: number of allocated pulses */ + const Word16 dim, /* i: Length of vector */ + const Word16 LS_ind, /* i; lS index 1 bit */ + const UWord32 UL_MPVQ_ind /* i; MPVQ index */ +); + +void pvq_dec_en1_norm_fx( /* */ +#ifdef ENABLE_HR_MODE + Word32 * xq, /* o: en1 normalized decoded vector (Q14) */ +#else + Word16 * xq, /* o: en1 normalized decoded vector (Q14) */ +#endif + const Word16 *y, /* i: decoded vector (non-scaled int) */ + const Word16 kval_max, /* i: max possible K in Q0 kO or kA */ + const Word16 dim, /* i: Length of vector */ + const Word16 neg_glob_gain /* i: a Global Gain (negated to fit 1.0 in Q15 as -1.0) */ +); + +#ifdef ENABLE_HR_MODE +#ifdef WIN32 +#define mexPrintf(x, y) printf(x, y) +#endif +#endif + +void pvq_dec_en1_normQ14_fx( /* Have to be used by both encoder and decoder */ +#ifdef ENABLE_HR_MODE + Word32 * xq, /* o: en1 normalized decoded vector (Q14) */ +#else + Word16 * xq, /* o: en1 normalized decoded vector (Q14) */ +#endif + const Word16 *y, /* i: decoded vector (non-scaled int) */ + const Word16 k_val_max, /* i: max possible K in Q0 kO or kA */ + const Word16 dim /* i: Length of vector */ +); + + +#ifdef ENABLE_HR_MODE +void pvq_dec_scale_vec_fx(const Word32 *inQ29, Word16 adjGainQ13, Word32 *outQ); +#else +void pvq_dec_scale_vec_fx(const Word16 *inQ14, Word16 adjGainQ13, Word16 *outQ14); +#endif + +Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side, Word16 mask_side, Word16 nbbits, +#ifdef ENABLE_HR_MODE + Word32 xq[], +#else + Word16 xq[], +#endif + Word16 *tns_order, Word16 tns_numfilters, Word16 *tns_idx, Word16 lastnz, + Word16 *codingdata, UWord8 *resBits, Word16 numResBits, Word16 lsbMode, + Word16 enable_lpc_weighting, Word8 *scratchBuffer); + +void processAriDecoder_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 L_spec, + Word16 fs_idx, Word16 enable_lpc_weighting, Word16 tns_numfilters, Word16 lsbMode, + Word16 lastnz, Word16 *bfi, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, + Word16 frame_dms, + Word16 n_pc, Word16 be_bp_left, Word16 be_bp_right, Word16 mode, Word16 *spec_inv_idx, + Word16 *b_left, + Word16 *resBits, +#ifdef ENABLE_HR_MODE + Word32 *x, +#else + Word16 *x, +#endif + Word16 *nf_seed, UWord8 *resQdata, Word16 *tns_idx, Word16 *zero_frame, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void processAriDecoderScaling_fx( +#ifdef ENABLE_HR_MODE + Word32 *datain, +#else + Word16 *data16, +#endif + Word16 dataLen, Word32 *data32, Word16 *data_e); + +void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 global_gain_idx, Word16 global_gain_off); + +void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Word16 d_fx_exp, + const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, Word16 frame_dms, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_idx, const Word16 near_nyquist_index, + const Word16 bands_number, const Word32 *ener_fx, const Word16 ener_fx_exp +#ifdef CR8_E_TONE_DETECTOR +#ifdef ENABLE_HR_MODE + , Word16 frame_dms , Word16 hrmode); +#else + ); +#endif +#else + ); +#endif +void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 frame_dms); + +void process_resamp12k8_fx(Word16 x[], Word16 x_len, Word16 mem_in[], Word16 mem_in_len, Word32 mem_50[], + Word16 mem_out[], Word16 mem_out_len, Word16 y[], Word16 *y_len, Word16 fs_idx, + Word16 frame_dms, Word8 *scratchBuffer + , Word16 bps + ); + +void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[], Word16 *pitch, Word16 *s12k8, + Word16 len, Word16 *normcorr, Word16 *mem_pitch, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + Word16 *pitch_flag, +#endif + Word16 s12k8_exp, Word16 frame_dms, Word8 *scratchBuffer); + +void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Word16 *old_wsp_exp, Word16 *old_wsp, + Word16 old_wsplen, Word16 *param, Word16 *wsp, Word16 len, Word16 *mem_normcorr, + Word16 *mem_mem_normcorr, Word16 ol_normcorr, Word16 *mem_ltpf_on, Word16 *mem_ltpf_pitch, + Word16 wsp_exp, Word16 frame_dms, Word8 *scratchBuffer +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,Word16 hrmode +#endif +); + +void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word16 fs_idx, Word16 old_y_len, + Word16 *old_e, Word16 *x, Word16 *old_x, Word16 *y, Word16 *old_y, Word16 ltpf, + Word16 ltpf_active, Word16 pitch_index, Word16 *old_pitch_int, Word16 *old_pitch_fr, + Word16 *old_gain, Word16 *mem_ltpf_active, Word16 scale_fac_idx, Word16 bfi, + Word16 concealMethod, + Word16 damping, Word16 *old_scale_fac_idx, +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + Word32 *rel_pitch_change, Word16 hrmode, Word16 frame_dms, +#endif + Word8 *scratchBuffer); + +void attack_detector_fx(LC3PLUS_Enc *enc, EncSetup *setup, Word16 *input, Word16 input_scaling, void *scratch); + +void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 *scf, + Word16 scf_smoothing_enabled, Word16 attdec_damping_factor, Word8 *scratchBuffer, Word16 sns_damping + ); + +void processSnsQuantizeScfEncoder_fx(Word16 scf[], /* i: input scf M */ + Word32 *L_prm_idx, /* o: indeces . negative == unused */ +#ifdef ENABLE_HR_MODE + Word32 *scf_q, /* o: quantized scf M */ +#else + Word16 *scf_q, /* o: quantized scf M */ +#endif + Word8 * scratchBuffer); + +Word16 processSnsQuantizeScfDecoder_fx( /* o: BER flag */ + Word32 *L_prm_idx, /* i: indeces */ +#ifdef ENABLE_HR_MODE + Word32 scf_q[], +#else + Word16 scf_q[], +#endif + Word8 *scratchBuffer); /* o: M */ + +void processSnsInterpolateScf_fx( +#ifdef ENABLE_HR_MODE + Word32 *scf_q, Word32 mdct_scf[], +#else + Word16 *scf_q, Word16 mdct_scf[], +#endif + Word16 mdct_scf_exp[], Word16 inv_scf, + Word16 n_bands, Word8 *scratchBuffer); + +void downshift_w32_arr(Word32 *w32_arr, Word16 *w16_arr, Word16 shft_val, Word32 len); +void round_w32tow16_arr(Word32 *w32_arr, Word16 *w16_arr, Word32 len); + +void processPLCmain_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFramesInRow, Word16 bfi, Word16 prev_bfi, + Word16 frame_length, Word16 la_zeroes, +#ifdef ENABLE_HR_MODE + const Word32 w[], +#else + const Word16 w[], +#endif + Word16 x_fx[], Word16 ola_mem[], + Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], + Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, const Word16 *band_offsets, Word16 bands_number, Word16 *damping, + Word16 old_pitch_int, Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, + AplcSetup *plcAd, Word16 frame_dms, Word8 *scratchBuffer, Word16 *pc_nbLostFramesInRow +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , Word32 rel_pitch_change +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + , Word16 *alpha_type_2_table +#endif + ); + +void processPLCupdate_fx(AplcSetup *plcAd, Word16 x_fx[], Word16 q_fx_exp, Word16 concealMethod, Word16 frame_length, + Word16 fs_idx, Word16 *nbLostFramesInRow, Word16 *prev_prev_bfi, Word16 *prev_bfi, Word16 bfi, + Word16 scf_q[], Word16 *ns_cum_alpha +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif + ); + +void processPLCupdateSpec_fx(Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 yLen); + + +void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], Word16 yLen, + Word16 *PhECU_oold_grp_shape_fx, Word16 *PhECU_old_grp_shape_fx); + +Word32 winEnCalc(const Word16 *, const Word16, const Word16 *, const Word16, const Word16, Word16 *); + +void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concealMethod, Word16 xLen, Word16 fs_idx, + Word16 *nbLostFramesInRow, Word16 *prev_prev_bfi, Word16 *prev_bfi, Word16 bfi, + Word16 scf_q[], Word16 *ns_cum_alpha, AplcSetup *plcAd); + +void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFramesInRow, Word16 bfi, + Word16 ltpf_mem_pitch_int, Word16 frame_length, Word16 frame_dms, Word16 fs_idx, Word16 yLen, + Word16 q_old_d_fx[], const Word16 *band_offsets, Word16 bands_number, AplcSetup *plcAd, Word8 *scratchBuffer +# ifdef ENABLE_HR_MODE + , Word16 hrmode +# endif + ); + +void processPLCapply_fx( +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 *concealMethod, +#else + Word16 concealMethod, +#endif + Word16 nbLostFramesInRow, Word16 bfi, Word16 prev_bfi, + Word16 frame_length, Word16 la_zeroes, +#ifdef ENABLE_HR_MODE + const Word32 w[], +#else + const Word16 w[], +#endif + Word16 x_fx[], Word16 ola_mem[], + Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], + Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, Word16 *damping, Word16 old_pitch_int, + Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, Word16 frame_dms, AplcSetup *plcAd, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , Word32 rel_pitch_change + +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + , Word16 *alpha_type_2_table +#endif + ); + +void processPLCNoiseSubstitution_fx(Word32 spec[], Word16 spec_prev[], Word16 L_spec); +void processPLCDampingScrambling_main_fx(Word16 bfi, Word16 concealMethod, Word16 ns_nbLostFramesInRow, Word16 *cum_fflcAtten, + Word16 pc_nbLostFramesInRow, Word16 *ns_seed, Word16 *pc_seed, Word16 pitch_present_bfi1, + Word16 pitch_present_bfi2, Word32 spec[], Word16 *q_fx_exp, Word16 *q_old_d_fx, + Word16 *q_old_fx_exp, Word16 L_spec, Word16 stabFac, Word16 frame_dms, + Word16 *cum_fading_slow, Word16 *cum_fading_fast, Word16 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , UWord8 plc_fadeout_type +#endif + ); + +void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostFramesInRow, Word16 stabFac, Word16 processDampScramb, + Word16 *cum_fflcAtten, Word16 pitch_present, Word16 frame_dms, Word16 *cum_fading_slow, + Word16 *cum_fading_fast, Word16 *seed, Word16 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , UWord8 plc_fadeout_type +#endif + ); + +void processLagwin_fx(Word32 r[], const Word32 w[], Word16 m); + +void processInverseODFT_fx(Word32 *r_fx, Word16 *r_fx_exp, Word32 *d2_fx, Word16 d2_fx_exp, Word16 n_bands, + Word16 lpc_order, Word8 *scratchBuffer); + +void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 frame_dms, + Word8 *scratchBuffer); + +void processPLCLpcScaling_fx(Word32 tdc_A_32[], Word16 tdc_A_16[], Word16 m); + +void processPLCcomputeStabFac_main(Word16 scf_q[], Word16 old_scf_q[], Word16 old_old_scf_q[], Word16 bfi, + Word16 prev_bfi, Word16 prev_prev_bfi, Word16 *stab_fac); + +void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, + Word16 *xfp_fx, Word16 xfp_exp_fx,Word16 margin_xfp, + Word16 fs_idx, + Word32 *L_oold_xfp_w_E_fx, Word16 *oold_xfp_w_E_exp_fx, + Word32 *L_old_xfp_w_E_fx, Word16 *old_xfp_w_E_exp_fx, + Word16 *oold_Ltot_exp_fx, Word16 *old_Ltot_exp_fx); + +void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 preemphFac_fx, const Word16 *A_fx, + const Word16 lpc_order, const Word16 *pcmbufHist_fx, + const Word16 frame_length, const Word16 frame_dms, const Word16 fs_idx, + const Word16 nbLostFramesInRow, const Word16 overlap, + const Word16 stabFac_fx, Word16 *fract, Word16 *seed_fx, + Word32 *gain_c_fx, Word16 *synth_fx, Word16 *Q_syn, + Word16 *alpha, Word16 max_len_pcm_plc, + Word16 harmonicBuf_fx[MAX_PITCH], Word16 synthHist_fx[M], Word16 *const harmonicBuf_Q, + Word8 *scratchBuffer +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,UWord8 plc_fadeout_type +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + ,Word16 *alpha_type_2_table +#endif +); + +void processTdac_fx(Word16 *ola_mem, Word16 *ola_mem_exp, const Word16 *synth, const Word16 synth_exp, +#ifdef ENABLE_HR_MODE + const Word32 *win, +#else + const Word16 *win, +#endif + const Word16 la_zeroes, const Word16 frame_len, Word8 *scratchBuffer); + +void plc_phEcu_F0_refine_first_fx(Word16 *plocs, const Word16 n_plocs_in, Word32 *L_f0est, + const Word16 stPhECU_f0hzLtpBinQ7, const Word16 stPhECU_f0gainLtpQ15, + const Word16 nSubm); +void plc_phEcu_LF_peak_analysis_fx(Word16 *plocs, Word16 *n_plocs, Word32 *L_f0estQ16, const Word16 *mag, + const Word16 stPhECU_f0hzLtpBinQ7, const Word16 stPhECU_f0gainLtpQ15, + const Word16 nSubm, Word16 maxPlocs, Word8 *scratchBuffer); + +Word16 plc_phEcuSetF0Hz_fx(Word16 fs_idx, Word16 old_pitch_int, Word16 old_pitch_fr); + +void create_sin2_taper_fx(Word16 *, Word16, Word16); + +void plc_phEcu_initWord16(Word16 * vec, /*i/o : vector pointer */ + const Word16 value, /*i : short initialization value */ + const Word16 len); /*i : number of elements */ + +Word16 plc_phEcu_ratio_fx(const Word32, const Word32, Word16 *); + +void plc_phEcu_minval_fx(const Word16 *inp, /* i : vector */ + const Word16 len, /* i : length */ + Word16 * minvalPtr); /* o : min value Ptr */ + +void plc_phEcu_maxval_fx(const Word16 *inp, /* i : vector */ + const Word16 len, /* i : length */ + Word16 * maxvalPtr); /* o : *maxvalPtr */ + +void Scale_sig_sat(Word16 x[], /* i/o: signal to scale, possibly saturated Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0); /* i : exponent: x = round(x << exp) Qx ?exp */ + +void Processing_ITDA_WIN_OLA(Word32 L_x_tda[], Word16 *y_e, +#ifdef ENABLE_HR_MODE + const Word32 w[], +#else + const Word16 w[], +#endif + Word16 mem[], Word16 *mem_e, Word16 x[], + Word16 wLen, Word16 N, Word16 memLen); + +void trans_burst_ana_fx(const Word16 *xfp, /* i : Input signal Qspec */ + Word16 * mag_chg, /* o : Magnitude modification Q15 */ + Word16 *ph_dith, /* o : Phase dither, 2*PI is not included (Q15, i.e., between 0.0 and 1.0) */ + Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients Q15 */ + const Word16 output_frame, /* i : Frame length */ + const Word16 time_offs, /* i : Time offset (integral multiple of output_frame) */ + const Word16 est_stab_content, /* i : 0.0=dynamic ... 1.0=stable (==st->env_stab ) */ + Word16 * alpha, /* o : Magnitude modification factors for fade to average */ + Word16 * beta, /* : Magnitude modification factors for fade to average */ + Word16 * beta_mute, /* i/o : Factor for long-term mute */ + Word16 * Xavg, /* o : Frequency group average gain to fade to */ + Word16 Q_spec, Word32 L_oold_xfp_w_E_fx, Word16 oold_xfp_w_E_exp_fx, Word16 oold_Ltot_exp_fx, + Word16 *oold_grp_shape_fx, Word32 L_old_xfp_w_E_fx, Word16 old_xfp_w_E_exp_fx, + Word16 old_Ltot_exp_fx, Word16 *old_grp_shape_fx, +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 fadeout, + Word32 *L_Xavg, /* full scale average band amplitudes */ +#endif + Word8 *scratchBuffer); + +void spec_ana_fx(Word16 *xfp, Word16 *, Word32 *, Word16 *, Word16 *, const Word16, const Word16, + const Word16 *, const Word16, const Word16, Word16 maxLprot, Word16 maxPlocs, Word8 *scratchBuffer); + +void subst_spec_fx(const Word16 *, const Word32 *, Word16 *, const Word16, Word16 *, const Word16 *, const Word16, + const Word16 *, const Word16, Word16 *, const Word16 *, const Word16 *, const Word16 *, const Word16 +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,const Word16, + Word16*, + const Word32 * +#endif +); + +void rec_frame_fx(Word16 * X, /* i : FFT spectrum */ + Word32 * L_ecu_rec, /* o : Reconstructed frame in tda domain */ + const Word16 output_frame, /* i : Frame length */ + const Word16 Q, const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + + Word16 maxLprot, const Word16 *prevsynth, const Word16 Q_prevsynth, + Word8 * scratchBuffer); + +Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F); + +void hq_phase_ecu_fx(const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ + Word32 *L_ecu_rec, /* o : reconstructed frame in tda domain , also tmp w32_fft buffer */ + Word16 *time_offs, /* i/o: Sample offset for consecutive frame losses*/ + Word16 *X_sav, /* i/o: Stored spectrum of prototype frame */ + Word16 *Q_spec, /* o: Q value of stored spectrum */ + Word16 *num_p, /* i/o: Number of identified peaks */ + Word16 *plocs, /* i/o: Peak locations */ + Word32 *L_plocsi, /* i/o: Interpolated peak locations Q16 */ + const Word16 env_stab, /* i : Envelope stability parameter */ + const Word16 f0hzLtpBinQ7, /* i: LTP bin frequency in normalized Hz Q7 */ + const Word16 norm_corrQ15_fx, /*i : correlation for lag at f0hzLtpBinQ7 */ + const Word16 prev_bfi, /* i : indicating burst frame error */ + Word16 old_is_transient[2], /* i/o : flags indicating noise generation */ + Word16 * mag_chg_1st, /* i/o: per band magnitude modifier for transients */ + Word16 * mag_chg_gr, /* o: per band magnitude modifier incl burst attenuation */ + Word16 * Xavg, /* i/o: Frequency group average gain to fade to */ + Word16 * beta_mute, /* o : Factor for long-term mute */ + const Word16 bwidth_fx, /* i : Encoded bandwidth */ + const Word16 output_frame, /* i : frame length */ + Word16 * seed_out_fxPtr, /* o: seed synch analysis */ + Word16 * X_out, /* o: utput evolved spectrum */ + const Word16 t_adv, /* i : time adjustment including time_offs */ + const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + const Word16 * sp_ana_win, /* i : whr hamming window */ + Word16 q_fx_old_exp, Word16 maxLprot, Word16 maxPlocs, + Word32 L_oold_xfp_w_E_fx, Word16 oold_xfp_w_E_exp_fx, /* exp of time signal */ + Word16 oold_Ltot_exp_fx, /*true exp of energy */ + Word16 *oold_grp_shape_fx, Word32 L_old_xfp_w_E_fx, + Word16 old_xfp_w_E_exp_fx, /* exp of time signal */ + Word16 old_Ltot_exp_fx, /*true exp of energy */ + Word16 *old_grp_shape_fx, + Word16 margin_prev_synth, /* i: margin in prev_synth(16ms for first bfi , 3.75 ms for other bfi + frames ) , from plcAd.PhECU_margin_xfp */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + const Word16 fadeout, /*i: fadeout length indicator */ + Word16 *nonpure_tone_flag_ptr, /* i/o : non-pure single tone indicator state */ +#endif + Word8 *scratchBuffer /* Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ +); + +Word16 +plc_xcorr_lc_fx(/* o: quantized output xcorr in Q15 [ 0 ..32767 ] = [0. 1.0[ */ + Word16 * + pcmbuf_fx, /* NB should be an already dynamically upscaled buffer with about 0...1 bits margin */ + Word16 max_len_pcm_plc, /* Q0 size of pcmbuf_fx */ + Word16 pitch_int, /* Q0 in Fs, lag value to evaluate, corresponding to the current f0 fr pcm_buf */ + Word16 fs_idx); + +void plc_phEcu_peak_locator_fx(const Word16 *, const Word16, Word16 *, Word16 *, const Word16, const Word16, + const Word16, Word16, Word8 *); + +Word16 plc_phEcu_find_ind_fx(const Word16 *, const Word16, const Word16); + + +Word16 initQV(Word16 SR_idx, Word32 BR); + +void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 sqTargetBits, +#ifdef ENABLE_HR_MODE + Word32 *gain, +#else + Word16 *gain, +#endif + Word16 *gain_e, + Word16 *quantizedGain, Word16 *quantizedGainMin, Word16 quantizedGainOff, + Word32 *targetBitsOff, Word16 *old_targetBits, Word16 old_specBits, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode, Word16 regBits, Word16 frame_dms +#endif +); + +void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx_off, +#ifdef ENABLE_HR_MODE + Word32 *gain, +#else + Word16 *gain, +#endif + Word16 *gain_e, + Word16 target, Word16 nBits, Word16 *gainChange, Word16 fs_idx +#ifdef ENABLE_HR_MODE + , Word16 hrmode, Word16 frame_dms +#endif + ); + +void processScalarQuant_fx(Word32 x[], Word16 x_e, Word16 xq[], Word16 L_frame, Word16 gain, Word16 gain_e); + +#ifdef ENABLE_HR_MODE +void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word32 gain, Word16 gain_e, Word32 xq[], Word16 nt, Word16 target, + Word16 totalBits, Word16 *nBits, Word16 *nBits2, Word16 fs_idx, Word16 *lastnz, + Word16 *codingdata, Word16 *lsbMode, Word16 mode, Word16 hrmode); +#else +void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, Word16 xq[], Word16 nt, + Word16 target, + Word16 totalBits, Word16 *nBits, Word16 *nBits2, Word16 fs_idx, Word16 *lastnz, + Word16 *codingdata, Word16 *lsbMode, Word16 mode); + +#endif /* ENABLE_HR_MODE */ + +void processResidualCoding_fx(Word16 x_e, Word32 x[], +#ifdef ENABLE_HR_MODE + Word32 xq[], Word32 gain, +#else + Word16 xq[], Word16 gain, +#endif + Word16 gain_e, Word16 L_spec, Word16 targetBits, Word16 nBits, + UWord8 *resBits, Word16 *numResBits +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +); + +void scale_signal24_fx(Word32 x[], /* i: time input signal */ +#ifdef ENABLE_HR_MODE + Word32 x_scaled[], +#else + Word16 x_scaled[], +#endif + Word16 *x_exp, +#ifdef ENABLE_HR_MODE + Word32 mdct_mem[], +#else + Word16 mdct_mem[], +#endif + Word16 mdct_mem_len, + Word16 resample_mem_in[], Word16 resample_mem_in_len, Word32 resample_mem_in50[], + Word16 resample_mem_out[], Word16 resample_mem_out_len, Word32 mdct_mem32[], Word16 N, + Word32 resamp_mem32[], Word16 mem_s12k8[], Word16 *resamp_scale); + +void processReorderBitstream_fx(UWord8 *bytes, Word16 n_pccw, Word16 n_pc, Word16 b_left, Word8 *scratchBuffer); + +/* al_fec.c */ +Word16 fec_get_n_pccw(Word16 slot_bytes, Word16 fec_mode, Word16 ccc_flag); +Word16 fec_get_data_size(Word16 fec_mode, Word16 ccc_flag, Word16 slot_bytes); +Word16 fec_get_n_pc(Word16 fec_mode, Word16 n_pccw, Word16 slot_bytes); + +void fec_encoder(Word16 mode, Word16 epmr, UWord8 *iobuf, Word16 data_bytes, Word16 slot_bytes, Word16 n_pccw, + void *scratch); + +int fec_decoder(UWord8 *iobuf, Word16 slot_bytes, int *data_bytes, Word16 *epmr, Word16 ccc_flag, Word16 *n_pccw, + int *bfi, Word16 *be_bp_left, Word16 *be_bp_right, Word16 *n_pc, Word16 *m_fec, void *scratch); + +void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, Word16 frame_dms, Word16 q_old_res_fx[], + Word16 *q_old_res_fx_exp, +#ifdef ENABLE_HR_MODE + Word32 q_res_fx[], +#else + Word16 q_res_fx[], +#endif + Word16 q_old_d_fx[], Word16 spec_inv_idx, + Word16 pitch_present, Word16 stab_fac, Word32 q_d_fx[], Word16 *q_fx_exp, + Word16 gg_idx, Word16 gg_idx_off, Word16 *prev_gg, Word16 *prev_gg_e, Word16 *BW_cutoff_idx_nf, + Word16 *prev_BW_cutoff_idx_nf, Word16 fac_ns_idx, Word16 *prev_fac_ns_fx, Word16 *pc_nbLostFramesInRow); +void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d_fx[], Word16 q_old_res_fx[], + Word16 yLen, Word16 spec_inv_idx, Word16 stab_fac, Word16 *bfi); +void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_exp, +#ifdef ENABLE_HR_MODE + Word32 q_res_fx[], +#else + Word16 q_res_fx[], +#endif + Word16 q_old_d_fx[], Word16 spec_inv_idx, Word16 *fac, Word16 *fac_e, Word32 q_d_fx[], + Word16 *q_fx_exp, Word16 gg_idx, Word16 gg_idx_off, Word16 prev_gg, Word16 prev_gg_e, + Word16 *pc_nbLostFramesInRow); +void processPCupdate_fx(Word16 bfi, Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_exp, +#ifdef ENABLE_HR_MODE + Word32 q_res_fx[], +#else + Word16 q_res_fx[], +#endif + Word16 spec_inv_idx, Word16 gg_idx, Word16 gg_idx_off, Word16 *prev_gg, Word16 *prev_gg_e, + Word16 rframe, Word16 *BW_cutoff_idx_nf, Word16 *prev_BW_cutoff_idx_nf, Word16 fac_ns_idx, + Word16 *prev_fac_ns_fx, Word16 fac, Word16 fac_e); +void processPcApplyDamping_fx(Word32 x[], Word16 xLen, Word16 fac, Word16 spec_inv_idx); + +void process_cutoff_bandwidth(Word32 d_fx[], Word16 len, Word16 bw_bin); + +void idct16_fx(const Word16 *in, Word16 *out); + +void dct32_fx(const Word32 *in, Word32 *out); +void idct32_fx(const Word32 *in, Word32 *out); +void idct32_32_fx(const Word32 *in, Word32 *out); + +/* Functions used in arithmetic coder */ + +void write_bit_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 bit); +void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, Word16 numbits); + +void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 targetBytes, + Word16 L_spec, Word16 BW_cutoff_bits, Word16 tns_numfilters, Word16 lsbMode, Word16 lastnz, + Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, Word16 BW_cutoff_idx, Word16 *ltpf_idx, + Word32 *L_scf_idx, Word16 bfi_ext, Word16 fs_idx); + +void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 L_spec, + Word16 fs_idx, Word16 BW_cutoff_bits, Word16 *tns_numfilters, Word16 *lsbMode, + Word16 *lastnz, Word16 *bfi, Word16 *tns_order, Word16 *fac_ns_idx, Word16 *gg_idx, + Word16 *BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, Word16 frame_dms); + +#ifdef ENABLE_PADDING +int paddingDec_fx(UWord8 *bytes, Word16 nbbits, Word16 L_spec, Word16 BW_cutoff_bits, Word16 ep_enabled, + Word16 *total_padding, Word16 *np_zero); +#endif + +Word16 read_bit(UWord8 *ptr, Word16 *bp, Word16 *mask); + +/* setup_enc_lc3.c */ +int alloc_encoder(LC3PLUS_Enc *encoder, int samplerate, int channels); +void set_enc_frame_params(LC3PLUS_Enc *encoder); +LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate); +LC3PLUS_Error FillEncSetup(LC3PLUS_Enc *encoder, int samplerate, int channels +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + , int32_t lfe_channel_array[] + ); + +/* setup_dec_lc3.c */ +int alloc_decoder(LC3PLUS_Dec *decoder, int samplerate, int channels); +void set_dec_frame_params(LC3PLUS_Dec *decoder); +LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes); +LC3PLUS_Error FillDecSetup(LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + ); + +int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 *output, void *scratch, Word16 bfi_ext); +LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int input_bytes, void **output, int bits_per_sample, void *scratch, + int bfi_ext); + +void *balloc(void *base, size_t *base_size, size_t size); + +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR +Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, Word16 frame_dms); +#endif + +#endif diff --git a/lib_lc3plus/imdct_fx.c b/lib_lc3plus/imdct_fx.c new file mode 100644 index 000000000..50ad2b257 --- /dev/null +++ b/lib_lc3plus/imdct_fx.c @@ -0,0 +1,387 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void ProcessingIMDCT( + Word32 y[], /* i: spectra data */ + Word16 * y_e, /* i: spectral data exponent */ +#ifdef ENABLE_HR_MODE + const Word32 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ + Word32 mem[], /* i/o: overlap add memory */ +#else + const Word16 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ + Word16 mem[], /* i/o: overlap add memory */ +#endif + Word16 * mem_e, /* i/o: overlap add exponent */ +#ifdef ENABLE_HR_MODE + Word32 x[], /* o: time signal out */ +#else + Word16 x[], /* o: time signal out */ +#endif + Word16 wLen, /* i: window length */ + Word16 N, /* i: block size */ + Word16 memLen, /* i: overlap add buffer size */ + Word16 frame_dms, /* i: frame size in ms */ + Word16 concealMethod, /* i: concealment method */ + Word16 bfi, /* i: bad frame indicator */ + Word16 prev_bfi, /* i: previous bad frame indicator */ + Word16 nbLostFramesInRow, /* i: number of consecutive lost frames */ + AplcSetup *plcAd, /* i: advanced plc struct */ + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +) +{ + Counter i; + Word16 o, z, m, s; + Word16 y_s, mem_s, max_bw; + Word32 L_tmp; + Word32 *workBuffer; + +#ifdef DYNMEM_COUNT + struct _dynmem + { + Word16 o, z, m, s; + Word16 y_s, mem_s, max_bw; + Word32 L_tmp; + Counter i; + Word32 *workBuffer; + Word16 mem_i_win; + Word16 w_taper_win; + }; + Dyn_Mem_In("ProcessingIMDCT", sizeof(struct _dynmem)); +#endif + + + test(); test(); test(); + IF (sub(bfi, 1) != 0 || sub(concealMethod, LC3_CON_TEC_NS_STD) == 0 || sub(concealMethod, LC3_CON_TEC_NS_ADV) == 0 || sub(concealMethod, LC3_CON_TEC_FREQ_MUTING) == 0) + { + workBuffer = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LEN bytes */ + + /* Init (constant per sample rate) */ + z = 2 * N - wLen; /* number of leading zeros in window */ + m = N >> 1; /* half block size */ + o = m - z; + max_bw = 0; + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + max_bw = N; + } + else +#endif + { + SWITCH (frame_dms) + { + case 25: + max_bw = MAX_BW >> 2; move16(); + BREAK; + case 50: + max_bw = MAX_BW >> 1; move16(); + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + max_bw = (MAX_BW >> 2) * 3; move16(); + BREAK; +#endif + case 100: + max_bw = MAX_BW; move16(); + BREAK; + } + } + + if (N > max_bw) + basop_memset(&y[max_bw], 0, (N - max_bw) * sizeof(*y)); + + /* Start Processing */ + y_s = getScaleFactor32_0(y, N); + IF (sub(y_s, 32) < 0) + { + FOR (i = 0; i < N; i++) + { + y[i] = L_shl(y[i], y_s); + } + *y_e = sub(*y_e, y_s); +#ifdef ENABLE_HR_MODE + dct_IV(y, y_e, N, +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + hrmode, +# endif + workBuffer); +#else + dct_IV(y, y_e, N, workBuffer); +#endif + y_s = getScaleFactor32_lc3plus(y, N); + y_s = sub(y_s, 1); + *y_e = sub(*y_e, y_s + 3); /* mdct window is scaled by pow(2,x) */ + /* N<=20 only happens for 2.5ms frames in NB */ + if (sub(N, 20) <= 0) + { + *y_e = add(*y_e, 2); + } + else if (sub(N, 120) <= 0) + { + *y_e = add(*y_e, 1); + } + } + ELSE + { + *y_e = 0; move16(); + } + +#ifdef ENABLE_HR_MODE + mem_s = getScaleFactor32_0(mem, memLen); +#else + mem_s = getScaleFactor16_0(mem, memLen); +#endif + +#ifdef ENABLE_HR_MODE + IF (sub(mem_s, 32) < 0) +#else + IF (sub(mem_s, 16) < 0) +#endif + { + mem_s = sub(mem_s, 1); + *mem_e = sub(*mem_e, mem_s); + } + ELSE + { + *mem_e = *y_e; move16(); + } + + s = sub(*mem_e, *y_e); + + IF (s > 0) + { + y_s = sub(y_s, s); + *y_e = add(*y_e, s); + } + ELSE + { + mem_s = add(mem_s, s); + *mem_e = sub(*mem_e, s); + } + + mem_s = s_max(mem_s, -31); + y_s = s_max(y_s, -31); + + if (sub(y_s, 32) >= 0) + { + y_s = 0; move16(); + } +#ifdef ENABLE_HR_MODE + if (sub(mem_s, 32) >= 0) + { + mem_s = 0; move16(); + } +#else + if (sub(mem_s, 16) >= 0) + { + mem_s = 0; move16(); + } +#endif + + UNUSED(prev_bfi); + UNUSED(nbLostFramesInRow); + UNUSED(plcAd); + + { /* regular operation */ + FOR (i = 0; i < o; i++) + { +#ifdef ENABLE_HR_MODE + L_tmp = L_sub(L_shl(mem[i], mem_s), Mpy_32_32_lc3plus(L_shl(y[m + i + z], y_s), w[4 * m - 1 - i - z])); + x[i] = L_tmp; + move32(); +#else + L_tmp = L_sub(L_shl(L_deposit_h(mem[i]), mem_s), Mpy_32_16_lc3plus(L_shl(y[m + i + z], y_s), w[4 * m - 1 - i - z])); + x[i] = round_fx(L_tmp); + move16(); +#endif + } + FOR (i = 0; i < m; i++) + { +#ifdef ENABLE_HR_MODE + L_tmp = L_add(L_shl(mem[i + o], mem_s), Mpy_32_32_lc3plus(L_shl(y[2 * m - 1 - i], y_s), w[3 * m - 1 - i])); + x[i + o] = L_tmp; + move32(); +#else + L_tmp = L_add(L_shl(L_deposit_h(mem[i + o]), mem_s), Mpy_32_16_lc3plus(L_shl(y[2 * m - 1 - i], y_s), w[3 * m - 1 - i])); + x[i + o] = round_fx(L_tmp); + move16(); +#endif + } + } + + FOR (i = 0; i < m; i++) + { +#ifdef ENABLE_HR_MODE + L_tmp = L_negate(Mpy_32_32_lc3plus(L_shl(y[i], y_s), w[m - 1 - i])); + x[3 * m - z + i] = L_tmp; + move32(); +#else + L_tmp = L_negate(Mpy_32_16_lc3plus(L_shl(y[i], y_s), w[m - 1 - i])); + x[3 * m - z + i] = round_fx(L_tmp); + move16(); +#endif + } + + FOR (i = 0; i < m; i++) + { +#ifdef ENABLE_HR_MODE + L_tmp = L_negate(Mpy_32_32_lc3plus(L_shl(y[i], y_s), w[m + i])); + x[3 * m - z - 1 - i] = L_tmp; + move32(); +#else + L_tmp = L_negate(Mpy_32_16_lc3plus(L_shl(y[i], y_s), w[m + i])); + x[3 * m - z - 1 - i] = round_fx(L_tmp); + move16(); +#endif + } + +#ifdef ENABLE_HR_MODE + basop_memmove(mem, &x[N], memLen * sizeof(Word32)); +#else + basop_memmove(mem, &x[N], memLen * sizeof(Word16)); +#endif + + *mem_e = *y_e; move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} +/* End Processing */ + +void Processing_ITDA_WIN_OLA( + Word32 L_x_tda[], /* i: X_TDA buffer data = "y" DCT-IV output */ + Word16 * y_e, /* i/o: x_tda input exponent "y_e" , x output exponent */ +#ifdef ENABLE_HR_MODE + const Word32 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ +#else + const Word16 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ +#endif + Word16 mem[], /* i/o: overlap add memory */ + Word16 * mem_e, /* i/o: overlap add exponent */ + Word16 x[], /* o: time signal out */ + Word16 wLen, /* i: window length */ + Word16 N, /* i: block size */ + Word16 memLen /* i: overlap add buffer size */ + ) +{ + /* Declarations */ + Word16 i, o, z, m, s; + Word16 y_s, mem_s; + Word32 L_tmp; + Word32 *L_y; + Word16 fs_idx, tmp_w, w_factor; + Word16 factorITDA[5]= { 25905 , 18318 , 22435 , 25905 , 31727}; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("Processing_ITDA_WIN_OLA", sizeof(struct { + Word16 i, o, z, m, s; + Word16 y_s, mem_s; + Word32 L_tmp; + Word32 *L_y; + })); +#endif + + + /* Init (constants per sample rate) */ + z = 2 * N - wLen; /* number of leading zeros in window */ + m = N >> 1; /* half block size */ + o = m - z; + + + L_y = L_x_tda; /* use same variables naming as in IMDCT for DCT-IV output signal y */ + + y_s = getScaleFactor32_lc3plus(L_y, N); + + y_s = sub(y_s, 1); /* add 1 bit margin , y_s is now initial tda upscaling factor */ + + + *y_e = sub(add(*y_e,1),y_s); /* handle W scale down by 2^(3) , as mdct synthesis window was upscaled by pow(2,x) x=2 for NB otherwise 3 */ + + + + mem_s = getScaleFactor16_0(mem, memLen); + + IF (sub(mem_s, 16) < 0) + { + mem_s = sub(mem_s, 1); /* one bit margin */ + *mem_e = sub(*mem_e, mem_s); /*adjusted mem exponent due to new scale */ + } + ELSE + { + *mem_e = 0; move16(); + } + + s = sub(*mem_e, *y_e); /* */ + + IF (s > 0) + { + y_s = sub(y_s, s); /* new , reduced upshift of TDA in window application loop */ + *y_e = add(*y_e, s); /* resulting new exp y_e for output signal */ + } + ELSE + { + mem_s = add(mem_s, s); /* s negative or zero, new , decreased upshift of OLAmem in loop */ + *mem_e = sub(*mem_e, s); /* resulting new exp mem_e for OLA_mem output signal */ + } + + fs_idx = mult(N,(Word16)(32768.0/99.0)); /* truncation needed , i.e no rounding can be applied here */ + w_factor = factorITDA[fs_idx]; move16(); + y_s = s_max(s_min(y_s, 31), -31); + + FOR (i = 0; i < o; i++) + { + tmp_w = mult_r(extractW16(w[4 * m - 1 - i - z]), w_factor); + L_tmp = L_sub(L_shl_sat(L_deposit_h(mem[i]), mem_s), Mpy_32_16_lc3plus(L_shl(L_y[m + i + z], y_s), tmp_w)); + x[i] = round_fx_sat(L_tmp); + move16(); + } + + FOR (i = 0; i < m; i++) + { + tmp_w = mult_r(extractW16(w[3 * m - 1 - i]), w_factor); + L_tmp = L_add(L_shl_sat(L_deposit_h(mem[i + o]), mem_s), Mpy_32_16_lc3plus(L_shl(L_y[2 * m - 1 - i], y_s), tmp_w)); + x[i + o] = round_fx_sat(L_tmp); + move16(); + } + + FOR (i = 0; i < m; i++) + { + tmp_w = mult_r(extractW16(w[m - 1 - i]), w_factor); + L_tmp = L_negate(Mpy_32_16_lc3plus(L_shl(L_y[i], y_s), tmp_w)); + x[3 * m - z + i] = round_fx(L_tmp); move16(); + } + + FOR (i = 0; i < m; i++) + { + tmp_w = mult_r(extractW16(w[m + i]), w_factor); + L_tmp = L_negate(Mpy_32_16_lc3plus(L_shl(L_y[i], y_s), tmp_w )); + x[3 * m - z - 1 - i] = round_fx(L_tmp); move16(); + } + + FOR (i = 0; i < memLen; i++) + { + mem[i] = x[N + i]; move16(); + } + *mem_e = *y_e; move16(); /* set OLA mem exp to x_Fx exponent*/ + + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c new file mode 100644 index 000000000..120dd0929 --- /dev/null +++ b/lib_lc3plus/lc3.c @@ -0,0 +1,426 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" +#include "lc3.h" +#include "setup_dec_lc3.h" +#include "setup_enc_lc3.h" + +#define RETURN_IF(cond, error) \ + if (cond) \ + return (error) + +#ifdef SUBSET_NB +#pragma message("- SUBSET_NB") +#endif +#ifdef SUBSET_WB +#pragma message("- SUBSET_WB") +#endif +#ifdef SUBSET_SSWB +#pragma message("- SUBSET_SSWB") +#endif +#ifdef SUBSET_SWB +#pragma message("- SUBSET_SWB") +#endif +#ifdef SUBSET_FB +#pragma message("- SUBSET_FB") +#endif +#ifdef SUBSET_UB +#pragma message("- SUBSET_UB") +#endif + +/* ensure api header constants are up to date */ +STATIC_ASSERT(LC3PLUS_MAX_SAMPLES >= MAX_LEN); +STATIC_ASSERT(LC3PLUS_MAX_CHANNELS >= MAX_CHANNELS); +STATIC_ASSERT(LC3PLUS_MAX_BYTES >= BYTESBUFSIZE); +STATIC_ASSERT(LC3PLUS_ENC_MAX_SIZE >= ENC_MAX_SIZE); +STATIC_ASSERT(LC3PLUS_DEC_MAX_SIZE >= DEC_MAX_SIZE); +STATIC_ASSERT(LC3PLUS_ENC_MAX_SCRATCH_SIZE >= SCRATCH_BUF_LEN_ENC_TOT); +STATIC_ASSERT(LC3PLUS_DEC_MAX_SCRATCH_SIZE >= SCRATCH_BUF_LEN_DEC_TOT); +STATIC_ASSERT(PLC_FADEOUT_IN_MS >= 20); + + +/* misc functions ************************************************************/ + +int lc3plus_version(void) +{ + return LC3PLUS_VERSION; +} + +int lc3plus_channels_supported(int channels) +{ + return channels >= 1 && channels <= MAX_CHANNELS; +} + +int lc3plus_samplerate_supported(int samplerate) +{ + switch (samplerate) + { +#ifdef SUBSET_NB + case 8000: return 1; +#endif +#ifdef SUBSET_WB + case 16000: return 1; +#endif +#ifdef SUBSET_SSWB + case 24000: return 1; +#endif +#ifdef SUBSET_SWB + case 32000: return 1; +#endif +#ifdef SUBSET_FB + case 44100: return 1; + case 48000: return 1; +#endif +#ifdef ENABLE_HR_MODE + case 96000: return 1; +#endif + default: return 0; + } +} + +static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) +{ + switch ((int)plc_mode) + { + case LC3PLUS_PLC_ADVANCED: /* fallthru */ + return 1; + default: return 0; + } +} + +static int lc3plus_frame_size_supported(int frame_dms) +{ + switch (frame_dms) + { + case 25: /* fallthru */ + case 50: /* fallthru */ +#ifdef CR8_G_ADD_75MS + case 75: /* fallthru */ +#endif + case 100: + return 1; + default: return 0; + } +} + +static int null_in_list(void **list, int n) +{ + while (--n >= 0) + RETURN_IF(list[n] == NULL, 1); + return 0; +} + +/* return pointer to aligned base + base_size, *base_size += size + 4 bytes align */ +void *balloc(void *base, size_t *base_size, size_t size) +{ + uintptr_t ptr = ((uintptr_t)base + *base_size + 3) & ~3; + assert((uintptr_t)base % 4 == 0); /* base must be 4-byte aligned */ + *base_size = (*base_size + size + 3) & ~3; + return (void *)ptr; +} + +int32_t lc3_enc_supported_lfe(void) +{ + return 1; +} + +/* encoder functions *********************************************************/ + +LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + , int32_t lfe_channel_array[] + ) +{ + int ch = 0; + + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((uintptr_t)encoder % 4 != 0, LC3PLUS_ALIGN_ERROR); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); + RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); +#ifdef ENABLE_HR_MODE + RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); +#endif + + for (ch = 0; ch < channels; ch++) + { + RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED); + } + +#ifdef ENABLE_HR_MODE + return FillEncSetup(encoder, samplerate, channels, hrmode + , lfe_channel_array + ); /* real bitrate check happens here */ +#else + return FillEncSetup(encoder, samplerate, channels + , lfe_channel_array + ); /* real bitrate check happens here */ +#endif +} + +int lc3plus_enc_get_size(int samplerate, int channels) +{ + RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); + RETURN_IF(!lc3plus_channels_supported(channels), 0); + return alloc_encoder(NULL, samplerate, channels); +} + +int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder) +{ + int size = 0; + RETURN_IF(encoder == NULL, 0); + +#ifdef ENABLE_HR_MODE + size = 47 * MAX(encoder->frame_length, 160) + 64; +#else + size = 14 * MAX(encoder->frame_length, 160) + 64; +#endif + assert(size <= LC3PLUS_ENC_MAX_SCRATCH_SIZE); + return size; +} + +int lc3plus_enc_get_input_samples(const LC3PLUS_Enc *encoder) +{ + RETURN_IF(encoder == NULL, 0); + return encoder->frame_length; +} + +int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder) +{ + RETURN_IF(encoder == NULL, 0); + return (Word32)encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); +} + +int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder) +{ + int ch = 0, totalBytes = 0; + RETURN_IF(encoder == NULL, 0); + RETURN_IF(!encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR); + + for (ch = 0; ch < encoder->channels; ch++) + { + totalBytes += encoder->channel_setup[ch]->targetBytes; + } + + int bitrate = (totalBytes * 80000.0 + encoder->frame_dms - 1) / encoder->frame_dms; + + if (encoder->fs_in == 44100) + { + int rem = bitrate % 480; + bitrate = ((bitrate - rem) / 480) * 441 + (rem * 441) / 480; + } + + return bitrate; +} + +LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc *encoder, int bitrate) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(bitrate <= 0, LC3PLUS_BITRATE_ERROR); + return update_enc_bitrate(encoder, bitrate); +} + +int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder) +{ + RETURN_IF(encoder == NULL, 0); + return encoder->frame_length - 2 * encoder->la_zeroes; +} + +LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((unsigned)epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR); + encoder->epmode = epmode; + return encoder->lc3_br_set ? update_enc_bitrate(encoder, encoder->bitrate) : LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((unsigned)epmr > LC3PLUS_EPMR_HIGH, LC3PLUS_EPMR_ERROR); + encoder->epmr = epmr; + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_dms) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_frame_size_supported(frame_dms), LC3PLUS_FRAMEMS_ERROR); + RETURN_IF(encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR); + encoder->frame_dms = frame_dms; + set_enc_frame_params(encoder); + return LC3PLUS_OK; +} + + +LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + Word32 effective_fs = encoder->fs_in; + if (encoder->bandwidth != bandwidth) { + if (encoder->fs_in > 40000) { + effective_fs = 40000; + } + if ((bandwidth * 2) > effective_fs) { + return LC3PLUS_BW_WARNING; + } + else { + encoder->bandwidth = bandwidth; + encoder->bandwidth_preset = bandwidth; + encoder->bw_ctrl_active = 1; + update_enc_bitrate(encoder, encoder->bitrate); + } + } + return LC3PLUS_OK; +} + + +static LC3PLUS_Error lc3plus_enc(LC3PLUS_Enc *encoder, void **input_samples, int bitdepth, void *output_bytes, int *num_bytes, + void *scratch) +{ + RETURN_IF(!encoder || !input_samples || !output_bytes || !num_bytes || !scratch, LC3PLUS_NULL_ERROR); + RETURN_IF(null_in_list(input_samples, encoder->channels), LC3PLUS_NULL_ERROR); + RETURN_IF(bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR); + RETURN_IF(!encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR); + *num_bytes = Enc_LC3PLUS(encoder, input_samples, bitdepth, output_bytes, scratch, *num_bytes == -1); + + assert(*num_bytes == lc3plus_enc_get_num_bytes(encoder)); + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc *encoder, int16_t **input_samples, void *output_bytes, int *num_bytes, void *scratch) +{ + return lc3plus_enc(encoder, (void **)input_samples, 16, output_bytes, num_bytes, scratch); +} + +LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc *encoder, int32_t **input_samples, void *output_bytes, int *num_bytes, void *scratch) +{ + return lc3plus_enc(encoder, (void **)input_samples, 24, output_bytes, num_bytes, scratch); +} + +/* decoder functions *********************************************************/ + +LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode +#ifdef ENABLE_HR_MODE + , int hrmode +#endif +) +{ + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); + RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); + RETURN_IF(!lc3plus_plc_mode_supported(plc_mode), LC3PLUS_PLCMODE_ERROR); +#ifdef ENABLE_HR_MODE + RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); +#endif + + return FillDecSetup(decoder, samplerate, channels, plc_mode +#ifdef ENABLE_HR_MODE + , hrmode +#endif + ); +} + +int lc3plus_dec_get_size(int samplerate, int channels, LC3PLUS_PlcMode plc_mode) +{ + RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); + RETURN_IF(!lc3plus_channels_supported(channels), 0); + RETURN_IF(!lc3plus_plc_mode_supported(plc_mode), 0); + return alloc_decoder(NULL, samplerate, channels); +} + +int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder) +{ + int size = 0; + RETURN_IF(decoder == NULL, 0); + +#ifdef ENABLE_HR_MODE + size = 30 * DYN_MAX_LEN(decoder->fs) + 2866; + size += 4 * MAX_LGW + 8 * DYN_MAX_LPROT(decoder->fs) + 16 * DYN_MAX_LEN(decoder->fs); +#else + size = 12 * DYN_MAX_LEN(decoder->fs) + 752; + size += 2 * MAX_LGW + 8 * DYN_MAX_LPROT(decoder->fs) + 8 * DYN_MAX_LEN(decoder->fs); + size += 3720; +#endif + + assert(size <= LC3PLUS_DEC_MAX_SCRATCH_SIZE); + return size; +} + +LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int ep_enabled) +{ + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + decoder->ep_enabled = ep_enabled != 0; + decoder->epmr = LC3PLUS_EPMR_ZERO; + return LC3PLUS_OK; +} + +int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->error_report == 2047 ? -1 : decoder->error_report & 0x07FF; +} + +int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->error_report >> 11; +} + +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, LC3PLUS_EPMR_ZERO); + return (LC3PLUS_EpModeRequest)decoder->epmr; +} + +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_dms) +{ + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_frame_size_supported(frame_dms), LC3PLUS_FRAMEMS_ERROR); + RETURN_IF(decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR); + + decoder->frame_dms = frame_dms; + set_dec_frame_params(decoder); + return LC3PLUS_OK; +} + + +int lc3plus_dec_get_output_samples(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->frame_length; +} + +int lc3plus_dec_get_delay(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->frame_length - 2 * decoder->la_zeroes; +} + +static LC3PLUS_Error lc3plus_dec(LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, void **output_samples, int bitdepth, + void *scratch, int bfi_ext) +{ + RETURN_IF(!decoder || !input_bytes || !output_samples || !scratch, LC3PLUS_NULL_ERROR); + RETURN_IF(null_in_list(output_samples, decoder->channels), LC3PLUS_NULL_ERROR); + RETURN_IF(bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR); + return Dec_LC3PLUS(decoder, input_bytes, num_bytes, output_samples, bitdepth, scratch, bfi_ext); +} + +LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int16_t **output_samples, void *scratch, int bfi_ext) +{ + return lc3plus_dec(decoder, input_bytes, num_bytes, (void **)output_samples, 16, scratch, bfi_ext); +} + +LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int32_t **output_samples, void *scratch, int bfi_ext) +{ + return lc3plus_dec(decoder, input_bytes, num_bytes, (void **)output_samples, 24, scratch, bfi_ext); +} diff --git a/lib_lc3plus/lc3.h b/lib_lc3plus/lc3.h new file mode 100644 index 000000000..64d8cc590 --- /dev/null +++ b/lib_lc3plus/lc3.h @@ -0,0 +1,520 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +/*! \file lc3.h + * This header provides the API for LC3plus. + * + * This library is targeting devices with extreme memory limitations, so memory management + * must be handeled by the user. This includes allocating memory for the structs and scratch + * memory. The structs are persistent between function calls. The scratch memory is working + * memory that does not persist between function calls. + * + * The amount of memory needed for various configurations can be obtained from the lc3plus_*_get_size + * and lc3plus_*_get_scratch_size functions. If memory usage is not a concern the LC3PLUS_*_MAX_SIZE + * LC3PLUS_*_MAX_SCRATCH_SIZE macros can be used for all configurations. + * + * Depending on the build configuration some functions might not be available. + */ + +#ifndef LC3PLUS_H +#define LC3PLUS_H + +#define ENABLE_HR_MODE + +#ifndef _MSC_VER +#include +#else +typedef __int16 int16_t; +typedef __int32 int32_t; +#endif + +/*! Construct version number from major/minor/micro values. */ +#define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) + +/*! Version number to ensure header and binary are matching. */ +#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 7, 3) + +/*! Maximum number of supported channels. The actual binary might support + * less, use lc3plus_channels_supported() to check. */ +#define LC3PLUS_MAX_CHANNELS 2 + +/*! Maximum number of samples per channel that can be stored in one LC3plus frame. */ +#ifdef ENABLE_HR_MODE +#define LC3PLUS_MAX_SAMPLES 960 +#else +#define LC3PLUS_MAX_SAMPLES 480 +#endif + +/*! Maximum number of bytes of one LC3plus frame. */ +#ifdef ENABLE_HR_MODE +#define LC3PLUS_MAX_BYTES (625 * LC3PLUS_MAX_CHANNELS) +#else +#define LC3PLUS_MAX_BYTES 870 +#endif + +/*! Maximum size needed to store encoder state. */ +#ifdef ENABLE_HR_MODE +#define LC3PLUS_ENC_MAX_SIZE 12628 +#else +#define LC3PLUS_ENC_MAX_SIZE 7226 +#endif + +/*! Maximum size needed to store decoder state. */ +#ifdef ENABLE_HR_MODE +#define LC3PLUS_DEC_MAX_SIZE 42488 +#else +#define LC3PLUS_DEC_MAX_SIZE 28446 +#endif + +/*! Maximum scratch size needed by lc3plus_enc16() or lc3plus_enc24().*/ +#ifdef ENABLE_HR_MODE +# define LC3PLUS_ENC_MAX_SCRATCH_SIZE 45624 +#else +# define LC3PLUS_ENC_MAX_SCRATCH_SIZE 6784 +#endif + +/*! Maximum scratch size needed by lc3plus_dec16() or lc3plus_dec24(). */ +#ifdef ENABLE_HR_MODE +#define LC3PLUS_DEC_MAX_SCRATCH_SIZE 59768 +#else +#define LC3PLUS_DEC_MAX_SCRATCH_SIZE 27474 +#endif +/*! Decoder packet loss concealment mode */ +typedef enum +{ + LC3PLUS_PLC_ADVANCED = 1 /*!< Enhanced concealment method */ +} LC3PLUS_PlcMode; + +/*! Error protection mode. LC3PLUS_EP_ZERO differs to LC3PLUS_EP_OFF in that + * errors can be detected but not corrected. */ +typedef enum +{ + LC3PLUS_EP_OFF = 0, /*!< Error protection is disabled */ + LC3PLUS_EP_ZERO = 1, /*!< Error protection with 0 bit correction */ + LC3PLUS_EP_LOW = 2, /*!< Error protection correcting one symbol per codeword */ + LC3PLUS_EP_MEDIUM = 3, /*!< Error protection correcting two symbols per codeword */ + LC3PLUS_EP_HIGH = 4 /*!< Error protection correcting three symbols per codeword */ +} LC3PLUS_EpMode; + +/*! Error protection mode request. On the encoder sidem, LC3PLUS_EPMR_ZERO to LC3PLUS_EPMR_HIGH + * can be set. The decoder returns mode requests with different confidences. */ +typedef enum +{ + LC3PLUS_EPMR_ZERO = 0, /*!< Request no error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_LOW = 1, /*!< Request low error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_MEDIUM = 2, /*!< Request medium error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_HIGH = 3, /*!< Request high error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_ZERO_MC = 4, /*!< No error correction requested, medium confidence. */ + LC3PLUS_EPMR_LOW_MC = 5, /*!< Low error correction requested, medium confidence. */ + LC3PLUS_EPMR_MEDIUM_MC = 6, /*!< Medium error correction requested, medium confidence. */ + LC3PLUS_EPMR_HIGH_MC = 7, /*!< High error correction requested, medium confidence. */ + LC3PLUS_EPMR_ZERO_NC = 8, /*!< No error correction requested, unvalidated. */ + LC3PLUS_EPMR_LOW_NC = 9, /*!< Low error correction requested, unvalidated. */ + LC3PLUS_EPMR_MEDIUM_NC = 10, /*!< Medium error correction requested, unvalidated. */ + LC3PLUS_EPMR_HIGH_NC = 11 /*!< High error correction requested, unvalidated. */ +} LC3PLUS_EpModeRequest; + +/*! Error codes returned by functions. */ +typedef enum +{ + LC3PLUS_OK = 0, /*!< No error occurred */ + LC3PLUS_ERROR = 1, /*!< Function call failed */ + LC3PLUS_DECODE_ERROR = 2, /*!< Frame failed to decode and was concealed */ + LC3PLUS_NULL_ERROR = 3, /*!< Pointer argument is null */ + LC3PLUS_SAMPLERATE_ERROR = 4, /*!< Invalid samplerate value */ + LC3PLUS_CHANNELS_ERROR = 5, /*!< Invalid channels value */ + LC3PLUS_BITRATE_ERROR = 6, /*!< Invalid bitrate value */ + LC3PLUS_NUMBYTES_ERROR = 7, /*!< Invalid num_bytes value */ + LC3PLUS_EPMODE_ERROR = 8, /*!< Invalid plc_method value */ + LC3PLUS_FRAMEMS_ERROR = 9, /*!< Invalid epmode value */ + LC3PLUS_ALIGN_ERROR = 10, /*!< Invalid frame_ms value */ + LC3PLUS_HRMODE_ERROR = 11, /*!< Unaligned pointer */ + LC3PLUS_BITRATE_UNSET_ERROR = 12, /*!< Invalid epmr value */ + LC3PLUS_BITRATE_SET_ERROR = 13, /*!< Invalid usage of hrmode, sampling rate and frame size */ + LC3PLUS_HRMODE_BW_ERROR = 14, /*!< Function called before bitrate has been set */ + LC3PLUS_PLCMODE_ERROR = 15, /*!< Function called after bitrate has been set */ + LC3PLUS_EPMR_ERROR = 16, /*!< Invalid external bad frame index */ + LC3PLUS_PADDING_ERROR = 17, /*!< Incorrect padding value */ + FRAMESIZE_ERROR = 18, /*!< Incorrect frame size during decoding */ + LC3PLUS_LFE_MODE_NOT_SUPPORTED = 19, /*!< LFE support not available */ + + /* START WARNING */ + LC3PLUS_WARNING = 20, + LC3PLUS_BW_WARNING = 21 /*!< Invalid bandwidth cutoff frequency */ + +} LC3PLUS_Error; + +typedef struct LC3PLUS_Enc LC3PLUS_Enc; /*!< Opaque encoder struct. */ +typedef struct LC3PLUS_Dec LC3PLUS_Dec; /*!< Opaque decoder struct. */ + +/*! \addtogroup Misc + * \{ */ + +/*! Test LFE mode support. + * + * Tests the support of the LFE mode. + * + * \return 1 for true, 0 for false. + */ +int32_t lc3_enc_supported_lfe(void); + +/*! Return library version number. It should match LC3PLUS_VERSION. */ +int lc3plus_version(void); + +/*! Tests if the library supports number of channels. + * + * \param[in] channels Number of channels. + * \return 1 for true, 0 for false. + */ +int lc3plus_channels_supported(int channels); + +/*! Tests if the library supports a sampling rate. + * + * \param[in] samplerate Sampling rate + * \return 1 for true, 0 for false + */ +int lc3plus_samplerate_supported(int samplerate); + +/*! \} + * \addtogroup Encoder + * \{ */ + +/*! + * Initialize LC3plus encoder. + * + * This function is used to fill a user-allocated encoder struct. This is typically + * called once for a samplerate / channel configuration. After init and before encoding + * the first frame you must call lc3plus_enc_set_bitrate(). + * + * \param[out] encoder Pointer to allocated encoder memory. It must have a size provided + * by lc3plus_enc_get_size() for matching samplerate / channels + * configuration or LC3PLUS_ENC_MAX_SIZE. + * \param[in] channels Number of channels. + * \param[in] samplerate Input sampling rate. Allowed sampling rates are: + * 8000, 16000, 24000, 32000, 44100, 48000 + * \param[in] hrmode High resolution mode. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + , int32_t lfe_channel_array[] + ); + +/*! + * Encode LC3plus frame with 16 bit input. + * + * Each call consumes a fixed number of samples. The number of input samples + * can be obtained from lc3plus_enc_get_input_samples(). + * + * \param[in] encoder Encoder handle initialized by lc3plus_enc_init(). + * \param[in] input_samples Input samples. The left channel is stored in input_samples[0], + * the right channel in input_samples[1]. The input is not changed + * by the encoder. + * \param[out] output_bytes Output buffer. It must have a at least lc3plus_enc_get_num_bytes() + * or at most LC3PLUS_MAX_BYTES. + * \param[out] num_bytes Number of bytes written to output_bytes. + * \param scratch A pointer to an allocated work buffer of at least + * lc3plus_enc_get_scratch_size() or at most LC3PLUS_ENC_SCRATCH_SIZE bytes. + * The buffer does not have to persist, so it can be used for other + * purposes in between calls. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc *encoder, int16_t **input_samples, void *output_bytes, int *num_bytes, void *scratch); + +/*! Encode LC3plus frame with 24 bit input. + * + * The input samples are expected to be 24-bit values, sign-extended to 32-bit. + * See lc3plus_enc16() for parameter documentation. + */ +LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc *encoder, int32_t **input_samples, void *output_bytes, int *num_bytes, void *scratch); + +/*! Get the size of the LC3plus encoder struct for a samplerate / channel configuration. + * If memory is not restricted LC3PLUS_ENC_MAX_SIZE can be used for all configurations. + * + * \param[in] samplerate Sampling rate. + * \param[in] channels Number of channels. + * \return Size in bytes or 0 on error. + */ +int lc3plus_enc_get_size(int samplerate, int channels); + +/*! Get the size of the scratch buffer required by lc3plus_enc16() or lc3plus_enc24() for the current + * encoder configuration. If memory is not restricted, LC3PLUS_ENC_MAX_SCRATCH_SIZE can be used for + * all configurations. + * + * \param[in] encoder Encoder handle. + * \return Size in bytes or 0 on error. + */ +int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder); + +/*! Get number of samples per channel expected by lc3plus_enc16() or lc3plus_enc24(). + * + * \param[in] encoder Encoder handle. + * \return Number of samples or 0 on error. + */ +int lc3plus_enc_get_input_samples(const LC3PLUS_Enc *encoder); + +/*! Get real internal bitrate of the encoder. It might differ from the requested bitrate due + * to error protection or 44.1 kHz input. + * + * \param[in] encoder Encoder handle. + * \return Bitrate in bits per second or 0 on error. + */ +int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder); + +/*! Get the maximum number of bytes produced by lc3plus_enc16() or lc3plus_enc24() for the current + * bitrate. It should be equal to the num_bytes output of lc3plus_enc16(). + * + * \param[in] encoder Encoder handle. + * \return Size in bytes or 0 on error. + */ +int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder); + +/*! Set encoder bitrate for all channels. + * This function must be called at least once before encoding the first frame, but + * after other configuration functions such as lc3plus_enc_set_frame_dms(). + * + * Recommended bitrates for input sampling rates with 10 ms framing: + * kHz | kbps + * --------|----- + * 8 | 24 + * 16 | 32 + * 24 | 48 + * 32 | 64 + * 44.1/48 | 80(voice) 128(music) + * + * \param[in] encoder Encoder handle. + * \param[in] bitrate Bitrate in bits per second. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc *encoder, int bitrate); + +/*! Set encoder Low-frequency effect moded. deactivates LTPF, TNS, NF. + * + * \param[in] encoder Encoder handle. + * \param[in] lfe LFE mode flag + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_lfe(LC3PLUS_Enc* encoder, int lfe); + +/*! Get the encoder delay in number of samples. + * + * \param[in] encoder Encoder handle. + * \return Encoder in samples or 0 on error. + */ +int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder); + +/*! Set the frame length for LC3plus encoder in deci milliseconds. + * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. + * This function must be called before lc3plus_enc_set_bitrate(). The decoder must be + * configured with lc3plus_dec_set_frame_dms() with the same value. + * + * \param[in] encoder Encoder handle. + * \param[in] frame_ms Frame length in ms. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_ms); + +/*! Set error protection mode. The default is LC3PLUS_EP_OFF. It is possible to switch between + * different modees during encoding. Dynamic switching is only allowed between LC3PLUS_EP_ZERO, + * LC3PLUS_EP_LOW, LC3_EP_MEDIUM, and LC3PLUS_EP_HIGH. The the decoder must be notified with + * lc3plus_dec_set_ep_enabled() to expect protected data if epmode is other than LC3PLUS_EP_OFF. + * + * \param[in] encoder Encoder handle. + * \param[in] epmode Error protection mode. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode); + +/*! Sets error protection mode request transmitted in each channel encoded frame. + * The channel coder includes an error protection mode request (EPMR) in every frame. + * The EPMR takes value 0, 1, 2, and 3 which request ep modes 1, 2, 3, and 4 from the + * decoding device. The EPMR can be retrieved from the channel decoder via the interface + * routine lc3plus_dec_get_ep_mode_request(). + * + * \param[in] encoder Encoder handle. + * \param[in] epmr Error Protection Mode Request + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr); + +/*! Set encoder bandwidth to a different value. All frequency bins above the cutoff + * frequency are cut off. Allowed frequencies are: 4 kHz, 8 kHz, 12 kHz, 16 kHz and 24 kHz. + * + * \param[in] encoder Encoder handle. + * \param[in] bandwidth Cutoff Frequency in Hz + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth); + +/*! \} + * \addtogroup Decoder + * \{ */ + + +/*! + * Initialize LC3plus decoder. + * + * This function is used to fill a user-allocated decoder struct. This is typically + * called once for a samplerate / channel / plc_mode configuration. + * + * The samplerate and channel arguments must have the same values that were used for encoding. + * LC3plus does not provide a signalling scheme, transporting these values is the responsibility + * of the application. + * + * \param[out] decoder Pointer to decoder memory. It must have as size of least + * lc3plus_dec_get_size() or at most LC3PLUS_DEC_MAX_SIZE. + * \param[in] samplerate Bitstream sampling rate. + * \param[in] channels Bitstream number of channels. + * \param[in] plc_mode Packet loss concealment mode. + * \param[in] hrmode High resolution mode mode. + * + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + ); + +/*! + * Decode compressed LC3plus frame to 16 bit PCM output. + * + * Each call decodes a fixed number of samples. Use lc3plus_dec_get_output_samples() to obtain this + * number. When the input is corrupted and can not be decoded, LC3PLUS_DECODE_ERROR is returned and + * packet loss concealment is applied, so the output is still usable. + * If error protection is enabled and the errors can be corrected the frame is corrected and + * normally decoded. Use lc3plus_dec_get_error_report() to check if errors were corrected. + * + * \param[in] decoder Decoder initialized by lc3plus_dec_init(). + * \param[in] input_bytes Input bytes. If error protection is enabled the input bytes can be + * altered when error correction is applied. This is why this buffer + * must be writable. + * \param[in] num_bytes Number of valid bytes in input_bytes. To signal a lost frame and + * generate concealment output this value must be set to 0. + * \param[out] output_samples Array of pointers to output channel buffers. Each channel buffer + * should provide enough space to hold at most LC3PLUS_MAX_SAMPLES. The + * left channel is stored in output_samples[0], the right channel in + * output_samples[1]. + * \param scratch A pointer to an allocated work buffer of at least + * lc3plus_dec_get_scratch_size() or at most LC3PLUS_DEC_MAX_SCRATCH_SIZE + * bytes. The scratch buffer does not have to persist, so it can be + * used for other purposes in between calls. + * \return Returns LC3PLUS_OK on success or appropriate error code. Note there is + * a special case for LC3PLUS_DECODE_ERROR where the output is still valid. + */ +LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int16_t **output_samples, void *scratch, + int bfi_ext); + +/*! Decode compressed LC3plus frame to 24 bit PCM output. + * + * The output samples are 24-bit values, sign-extended to 32-bit. + * See lc3plus_dec16() for parameter documentation. + */ +LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int32_t **output_samples, void *scratch, + int bfi_ext); + +/*! Get the size of the LC3plus decoder struct for a samplerate / channel / plc_mode configuration. + * If memory is not restricted LC3PLUS_DEC_MAX_SIZE can be used for all configurations. + * + * \param[in] channels Number of channels. + * \param[in] samplerate Sampling rate. + * \param[in] plc_mode Packet loss concealment mode. + * \return Size in bytes or 0 on error. + */ +int lc3plus_dec_get_size(int samplerate, int channels, LC3PLUS_PlcMode plc_mode); + +/*! Get the size of the scratch buffer required by lc3plus_dec16() or lc3plus_dec24() for the current + * decoder configuration. If memory is not restricted LC3PLUS_DEC_MAX_SCRATCH_SIZE can be used for + * all configurations. + * + * \param[in] decoder Decoder handle. + * \return Size in bytes or 0 on error. + */ +int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder); + +/*! Get the number of samples per channel produced by lc3plus_dec16() or lc3plus_dec24(). + * + * \param[in] decoder Decoder handle. + * \return Number of samples or 0 on error. + */ + +int lc3plus_dec_get_output_samples(const LC3PLUS_Dec *decoder); + +/*! Get the decoder delay in number of samples. + * + * \param[in] decoder Decoder handle. + * \return Delay in samples or 0 on error. + */ +int lc3plus_dec_get_delay(const LC3PLUS_Dec *decoder); + +/*! Set the frame length for LC3plus decoder in deci milliseconds. + * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. + * This only works correcly if the encoder was configured with the same vale. + * + * \param[in] decoder Decoder handle. + * \param[in] frame_ms Frame length in ms. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_ms); + +/*! Enable or disable error protection. Default value is 0 (disabled). If error protection is + * enabled, the decoder expects that the frames were encoded with error protection mode + * LC3PLUS_EP_ZERO or higher. + * + * \param[in] decoder Decoder handle. + * \param[in] ep_enabled 1 (or any nonzero) for true, 0 for false. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int ep_enabled); + +/*! Retrieves the error protection mode reqeust from channel decoder. + * + * The return value encodes both the error protection mode request (EPMR) + * and the confidence of the method by which it was retrieved. + * + * The requested error protection mode is (epmr % 4) + 1, where epmr is the + * function's return value. The confidence is specified as follows. + * + * Confidence | Range + * -----------|------------- + * high | 0 <= epmr < 4 + * medium | 4 <= epmr < 8 + * no | 8 <= epmr < 12 + * + * When receiving stereo content of separately channel encoded audio frames the + * return value is the minimum of two values retrieved from the individual channels. + * + * \param[in] decoder Decoder handle. + * \return Error protection mode reqeust. + */ +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder); + +/*! Get the number of corrected bit errors in the last decoded frame. This only works if + * error protection is active. If the number of errors is greater than the current error + * protection mode can correct, -1 is returned. If the last frame had no errors or the + * decoder handle is NULL, 0 is returned, + * + * \param[in] decoder Decoder handle. + * \return Number of corrected bits or -1. See description for details. + */ +int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder); +/*! This function returns an set of flags indicating whether the last frame + * would have been channel decodable in epmode m, m ranging from 1 to 4. Note that + * this information is not available in case the last frame was not channel + * decodable in which case the return value is 0. If the last frame would have + * been decodable in epmode m, m-1th of the return value will be 1. + * Otherwise, if the frame would not have been decodable or if this information + * cannot be retrieved, the m-1th bit of the return value will be 0. + */ +int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder); + +/*! \} */ +#endif /* LC3plus */ diff --git a/lib_lc3plus/levinson_fx.c b/lib_lc3plus/levinson_fx.c new file mode 100644 index 000000000..9003173d0 --- /dev/null +++ b/lib_lc3plus/levinson_fx.c @@ -0,0 +1,160 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processLevinson_fx(Word32 *lpc, Word32 *ac, Word16 N, Word16 *rc, Word32 *pred_err, Word8 *scratchBuffer) +{ + + Word32 *lpc_tmp; + Word32 rc32, err, sum; + Word16 shift, s, inv; + Counter n, m; + + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processLevinson_fx", sizeof(struct { + Word32 *lpc_tmp; + Word32 rc32, err, sum; + Word16 shift, s, inv; + Counter n, m; + Word32 params[2]; + })); +#endif + + lpc_tmp = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * (M_LTPF + 1) = 100 bytes */ + + /* Init Prediction Error */ + err = ac[0]; move32(); + shift = 0; move16(); + + /* LPC Coefficient 0 */ + lpc[0] = 0x8000000; move32(); + + /* Reflection Coefficient 0 */ + IF (ac[0] != 0) + { + inv = div_s(16383, extract_h(ac[0])); + rc32 = L_shl_pos(Mpy_32_32_lc3plus(L_abs(ac[1]), Mpy_32_16_lc3plus(L_sub(MAX_32, Mpy_32_16_lc3plus(ac[0], inv)), inv)), 2); + } + ELSE + { + rc32 = 0; move32(); + } + if (ac[1] > 0) + { + rc32 = L_negate(rc32); + } + if (rc != NULL) + { + rc[0] = round_fx(rc32); move16(); + } + + /* LPC Coefficient 1 */ + lpc[1] = L_shr_pos(rc32, 4); move32(); + + FOR (n = 2; n <= N; n++) + { + /* Update Prediction Error */ + err = Mpy_32_32_lc3plus(err, L_sub(MAX_32, Mpy_32_32_lc3plus(rc32, rc32))); + s = norm_l(err); + err = L_shl_pos(err, s); + shift = add(shift, s); + + /* Reflection Coefficient n-1 */ + sum = Mpy_32_32_lc3plus(ac[1], lpc[n - 1]); + FOR (m = 2; m < n; m++) + { + sum = L_add(sum, Mpy_32_32_lc3plus(ac[m], lpc[n - m])); + } + + sum = L_add(L_shl_pos(sum, 4), ac[n]); + IF (err != 0) + { + inv = div_s(16383, extract_h(err)); + rc32 = L_shl_pos(Mpy_32_32_lc3plus(L_abs(sum), Mpy_32_16_lc3plus(L_sub(MAX_32, Mpy_32_16_lc3plus(err, inv)), inv)), 2); + } + ELSE + { + rc32 = 0; + } + if (sum > 0) + { + rc32 = L_negate(rc32); + } + rc32 = L_shl(rc32, shift); + if (rc != NULL) + { + rc[n - 1] = round_fx(rc32); move16(); + } + +/* Recompute LPC Coefficients up to n-1 */ + FOR (m = 1; m < n; m++) + { + lpc_tmp[m] = L_add(lpc[m], Mpy_32_32_lc3plus(rc32, lpc[n - m])); move32(); + } + + basop_memmove(&lpc[1], &lpc_tmp[1], (n - 1) * sizeof(Word32)); + + /* LPC Coefficient n */ + lpc[n] = L_shr_pos(rc32, 4); move32(); + } + + /* Final Prediction Error */ + IF (pred_err != NULL) + { + err = Mpy_32_32_lc3plus(err, L_sub(MAX_32, Mpy_32_32_lc3plus(rc32, rc32))); + *pred_err = L_shr(err, shift); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + +void lpc2rc(Word32 *lpc, Word16 *rc, Word16 N) +{ + Word32 lpc_tmp[MAXLAG + 1]; + Word32 rc32, tmp0, tmp1; + Word16 inv; + Counter n, m; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("lpc2rc", sizeof(struct { + Word32 lpc_tmp[MAXLAG + 1]; + Word32 rc32, tmp0, tmp1; + Word16 inv; + Counter n, m; + })); +#endif + + FOR (n = N; n >= 2; n--) + { + rc32 = L_shl_pos(lpc[n], 4); + rc[n - 1] = round_fx(rc32); move16(); + + tmp0 = L_sub(MAX_32, L_abs(Mpy_32_32_lc3plus(rc32, rc32))); + FOR (m = 1; m < n; m++) + { + tmp1 = L_sub(lpc[m], Mpy_32_32_lc3plus(lpc[n - m], rc32)); + inv = div_s(16383, extract_h(tmp0)); + lpc_tmp[m] = L_shl_pos(Mpy_32_32_lc3plus(tmp1, Mpy_32_16_lc3plus(L_sub(MAX_32, Mpy_32_16_lc3plus(tmp0, inv)), inv)), 2); move32(); + } + + basop_memmove(&lpc[1], &lpc_tmp[1], (n - 1) * sizeof(Word32)); + } + + rc[0] = round_fx(L_shl_pos(lpc[1], 4)); move32(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/license.h b/lib_lc3plus/license.h new file mode 100644 index 000000000..22f25e9ff --- /dev/null +++ b/lib_lc3plus/license.h @@ -0,0 +1,21 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" + +static const char *const LICENSE = + "*******************************************************************************\n" + "* ETSI TS 103 634 V1.4.5 *\n" + "* Low Complexity Communication Codec Plus (LC3plus) *\n" + "* Fixed Point Software V%i.%i.%iETSI, " __DATE__ " *\n" + "* Copyright licence is solely granted through ETSI Intellectual Property *\n" + "* Rights Policy, 3rd April 2019. No patent licence is granted by implication, *\n" + "* estoppel or otherwise. *\n" + "*******************************************************************************\n" + "\n"; diff --git a/lib_lc3plus/ltpf_coder_fx.c b/lib_lc3plus/ltpf_coder_fx.c new file mode 100644 index 000000000..212788d73 --- /dev/null +++ b/lib_lc3plus/ltpf_coder_fx.c @@ -0,0 +1,323 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +/*************************************************************************/ + + +void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Word16 *mem_in_exp, Word16 mem_in[], + Word16 mem_in_len, Word16 param[], Word16 *xin, Word16 len, Word16 *mem_normcorr, + Word16 *mem_mem_normcorr, Word16 ol_normcorr, Word16 *mem_ltpf_on, Word16 *mem_ltpf_pitch, + Word16 xin_exp, Word16 frame_dms, Word8 *scratchBuffer +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,Word16 hrmode +#endif +) +{ + Word16 pitch_index, scale0, scale1, scale2, *x, x_exp, shift, prod_exp, ltpf_pitch; + Word32 L_tmp, cor_max32, sum0, sum1, sum2, prod, inv; + Word32 *ac32; + Word16 *ac, *currFrame, *predFrame; + Word16 min_pitch, max_pitch, ac_min_pitch, ac_max_pitch, ac_max; + Word16 pitch, pitch_res, min_pitch_fr, pitch_int, pitch_fr, norm_corr, ltpf_active; + Counter n, m, fr; + Word16 tmp, acflen; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("process_ltpf_coder_fx", sizeof(struct { + Word16 pitch_index, scale0, scale1, scale2, *x, x_exp, shift, prod_exp, ltpf_pitch; + Word32 L_tmp, cor_max32, sum0, sum1, sum2, prod, inv; + Word32 *ac32; + Word16 *ac, *currFrame, *predFrame; + Word16 min_pitch, max_pitch, ac_min_pitch, ac_max_pitch, ac_max; + Word16 pitch, pitch_res, min_pitch_fr, pitch_int, pitch_fr, norm_corr, ltpf_active; + Counter n, m, fr; + Word16 tmp, acflen; + })); +#endif + + + + ac32 = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * 17 = 68 bytes; */ + ac = (Word16 *)scratchAlign(ac32, sizeof(*ac32) * 17); /* Size = 2 * 17 = 34 bytes */ + currFrame = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * 128 = 256 bytes */ + predFrame = (Word16 *)scratchAlign(currFrame, sizeof(*currFrame) * LEN_12K8); /* Size = 2 * 128 = 256 bytes */ + /* Buffers 'overlap' since they are not used at the same time */ /* Total size used = 512 bytes */ + + ltpf_active = 0; move16(); + norm_corr = 0; move16(); + + /* Input buffer */ + x = mem_in + mem_in_len; + + basop_memmove(x, xin, (len + 1) * sizeof(Word16)); + + ASSERT(mem_in_len + len + 1 <= LTPF_MEMIN_LEN + LEN_12K8 + 1); + + /* Scaling */ + scale0 = sub(getScaleFactor16_0(mem_in, mem_in_len), 3); + *mem_in_exp = sub(*mem_in_exp, scale0); move16(); + scale1 = sub(getScaleFactor16_0(x, len + 1), 3); + x_exp = sub(xin_exp, scale1); + scale2 = sub(*mem_in_exp, x_exp); + IF (scale2 > 0) + { + Scale_sig(x, len + 1, sub(scale1, scale2)); + Scale_sig(mem_in, mem_in_len, scale0); + x_exp = *mem_in_exp; move16(); + } + ELSE + { + Scale_sig(x, len + 1, scale1); + Scale_sig(mem_in, mem_in_len, add(scale0, scale2)); + *mem_in_exp = x_exp; move16(); + } + +#ifdef CR9_K_REDUCE_NORM_CORR_TH + Word32 normCorrTh = 0; + if (hrmode) { + normCorrTh = 13107; + } else { + normCorrTh = 19660; + } +#endif + +#ifdef CR9_K_REDUCE_NORM_CORR_TH + IF (sub(ol_normcorr, normCorrTh) > 0) +#else + IF (sub(ol_normcorr, 19660) > 0) +#endif + { + /* Autocorrelation Bounds */ + min_pitch = sub(ol_pitch, 4); + max_pitch = add(ol_pitch, 4); + min_pitch = s_max(min_pitch, MIN_PITCH_12K8); + max_pitch = s_min(max_pitch, MAX_PITCH_12K8); + ac_min_pitch = sub(min_pitch, 4); + ac_max_pitch = add(max_pitch, 4); + acflen = len; move16(); + if (sub(frame_dms, 25) == 0) + { + acflen = shl(len, 1); + x = x - len; + } + + /* Compute norm */ + sum1 = L_mac0(1, x[0], x[0]); + sum2 = L_mac0(1, x[-ac_min_pitch], x[-ac_min_pitch]); + FOR (m = 1; m < acflen; m++) + { + sum1 = L_mac0(sum1, x[m], x[m]); + sum2 = L_mac0(sum2, x[m - ac_min_pitch], x[m - ac_min_pitch]); + } + scale1 = norm_l(sum1); + sum1 = L_shl_pos(sum1, scale1); + + /* Compute Autocorrelation */ + FOR (n = ac_min_pitch; n <= ac_max_pitch; n++) + { + sum0 = L_mac0(0L, x[0], x[0 - n]); + FOR (m = 1; m < acflen; m++) + { + sum0 = L_mac0(sum0, x[m], x[m - n]); + } + if (n > ac_min_pitch) + { + sum2 = L_msu0(sum2, x[acflen - 1 - (n - 1)], x[acflen - 1 - (n - 1)]); + sum2 = L_mac0_sat(sum2, x[-n], x[-n]); + } + scale2 = norm_l(sum2); + L_tmp = L_shl_pos(sum2, scale2); + prod = Mpy_32_32_lc3plus(sum1, L_tmp); + shift = norm_l(prod); + prod = L_shl_pos(prod, shift); + prod_exp = sub(62, add(add(scale1, scale2), shift)); + inv = Isqrt(prod, &prod_exp); + scale0 = norm_l(sum0); + sum0 = L_shl_pos(sum0, scale0); + prod = Mpy_32_32_lc3plus(sum0, inv); + prod_exp = add(sub(31, scale0), prod_exp); + test(); + IF (prod == 0 || sub(norm_l(prod), prod_exp) >= 0) + { + ac[n - ac_min_pitch] = s_max(0, round_fx_sat(L_shl_sat(prod, prod_exp))); move16(); + } + ELSE + { + ac[n - ac_min_pitch] = 32767; move16(); + } + } + + /* Find maximum */ + ac_max = ac[min_pitch - ac_min_pitch]; move16(); + pitch = min_pitch; move16(); + FOR (n = min_pitch + 1; n <= max_pitch; n++) + { + tmp = sub_sat(ac[n - ac_min_pitch], ac_max); + if (tmp > 0) + { + pitch = n; move16(); + } + ac_max = s_max(ac_max, ac[n - ac_min_pitch]); + } + pitch_int = pitch; move16(); + pitch_fr = 0; move16(); + pitch_index = add(pitch_int, 283); + + /* If the pitch is low -> estimate a fractional part */ + IF (sub(pitch, RES2_PITCH_12K8) < 0) + { + IF (sub(pitch, RES4_PITCH_12K8) < 0) + { + pitch_res = 1; move16(); + min_pitch_fr = -3; move16(); + } + ELSE + { + pitch_res = 2; move16(); + min_pitch_fr = -2; move16(); + } + if (sub(pitch, min_pitch) == 0) + { + min_pitch_fr = 0; + } + cor_max32 = MIN_32; + FOR (fr = min_pitch_fr; fr < 4; fr += pitch_res) + { + sum0 = L_mult0(ac[pitch_int - ac_min_pitch - 4], ltpf_ac_interp_filt[fr + 3][0]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch - 3], ltpf_ac_interp_filt[fr + 3][1]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch - 2], ltpf_ac_interp_filt[fr + 3][2]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch - 1], ltpf_ac_interp_filt[fr + 3][3]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch + 0], ltpf_ac_interp_filt[fr + 3][4]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch + 1], ltpf_ac_interp_filt[fr + 3][5]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch + 2], ltpf_ac_interp_filt[fr + 3][6]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch + 3], ltpf_ac_interp_filt[fr + 3][7]); + sum0 = L_mac0(sum0, ac[pitch_int - ac_min_pitch + 4], ltpf_ac_interp_filt[fr + 3][8]); + + L_tmp = L_sub_sat(sum0, cor_max32); + if (L_tmp > 0) + { + pitch_fr = fr; move16(); + } + cor_max32 = L_max(cor_max32, sum0); + } + IF (pitch_fr < 0) + { + pitch_int = sub(pitch_int, 1); + pitch_fr = add(pitch_fr, 4); + } + IF (sub(pitch_int, 127) >= 0) + { + pitch_index = add(add(shl_pos(pitch_int, 1), shr_pos(pitch_fr, 1)), 126); + } + ELSE + { + pitch_index = sub(add(shl_pos(pitch_int, 2), pitch_fr), 128); + } + } + ltpf_pitch = add(shl_pos(pitch_int, 2), pitch_fr); + + /* Filter current and predicted frame */ + + FOR (n = 0; n < acflen; n++) + { + sum0 = L_mult(x[n + 1], inter_filter[0][0][0]); + sum0 = L_mac(sum0, x[n], inter_filter[0][0][1]); + currFrame[n] = mac_r(sum0, x[n - 1], inter_filter[0][0][2]); + + sum0 = L_mult(x[n - pitch_int + 1], inter_filter[0][pitch_fr][0]); + sum0 = L_mac(sum0, x[n - pitch_int], inter_filter[0][pitch_fr][1]); + sum0 = L_mac(sum0, x[n - pitch_int - 1], inter_filter[0][pitch_fr][2]); + predFrame[n] = mac_r(sum0, x[n - pitch_int - 2], inter_filter[0][pitch_fr][3]); + } + + /* Normalized Correlation */ + sum0 = L_mult0(currFrame[0], predFrame[0]); + sum1 = L_mac0(1, predFrame[0], predFrame[0]); + sum2 = L_mac0(1, currFrame[0], currFrame[0]); + for (m = 1; m < acflen; m++) + { + sum0 = L_mac0(sum0, currFrame[m], predFrame[m]); + sum1 = L_mac0(sum1, predFrame[m], predFrame[m]); + sum2 = L_mac0(sum2, currFrame[m], currFrame[m]); + } + + scale1 = norm_l(sum1); + scale2 = norm_l(sum2); + sum1 = L_shl_pos(sum1, scale1); + sum2 = L_shl_pos(sum2, scale2); + prod = Mpy_32_32_lc3plus(sum1, sum2); + shift = norm_l(prod); + prod = L_shl_pos(prod, shift); + prod_exp = sub(62, add(add(scale1, scale2), shift)); + inv = Isqrt(prod, &prod_exp); + scale0 = norm_l(sum0); + sum0 = L_shl_pos(sum0, scale0); + prod = Mpy_32_32_lc3plus(sum0, inv); + prod_exp = add(sub(31, scale0), prod_exp); + test(); + IF (prod == 0 || sub(norm_l(prod), prod_exp) >= 0) + { + norm_corr = s_max(0, round_fx_sat(L_shl_sat(prod, prod_exp))); move16(); + } + ELSE + { + norm_corr = 32767; move16(); + } + if (norm_corr < 0) + { + norm_corr = 0; + } + + IF (sub(ltpf_enable, 1) == 0) + { + test(); test(); test(); test(); + /* Decision if lptf active */ + IF ((*mem_ltpf_on == 0 && sub(*mem_normcorr, 30802) > 0 && sub(norm_corr, 30802) > 0 && + (sub(frame_dms, 100) == 0 || sub(*mem_mem_normcorr, 30802) > 0)) || + (sub(*mem_ltpf_on, 1) == 0 && sub(norm_corr, 29491) > 0) || + (sub(*mem_ltpf_on, 1) == 0 && sub(abs_s(sub(ltpf_pitch, *mem_ltpf_pitch)), 8) < 0 && + add(sub(norm_corr, *mem_normcorr), 3277) > 0 && sub(norm_corr, 27525) > 0)) + { + ltpf_active = 1; move16(); + } + } + + param[0] = 1; move16(); + param[1] = ltpf_active; move16(); + param[2] = pitch_index; move16(); + *bits = 11; move16(); + } + ELSE + { + norm_corr = ol_normcorr; move16(); + param[0] = 0; move16(); + param[1] = 0; move16(); + param[2] = 0; move16(); + *bits = 1; move16(); + ltpf_pitch = 0; move16(); + } + +/* Update memory */ + FOR (n = 0; n < mem_in_len; n++) + { + mem_in[n] = mem_in[n + len]; move16(); + } + + *mem_mem_normcorr = *mem_normcorr; move16(); + *mem_normcorr = norm_corr; move16(); + *mem_ltpf_on = ltpf_active; move16(); + *mem_ltpf_pitch = ltpf_pitch; move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/ltpf_decoder_fx.c b/lib_lc3plus/ltpf_decoder_fx.c new file mode 100644 index 000000000..3bc82085e --- /dev/null +++ b/lib_lc3plus/ltpf_decoder_fx.c @@ -0,0 +1,394 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static void ltpf_synth_filter(Word16 *synth_ltp, Word16 *synth, Word16 length, Word16 pitch_int, Word16 pitch_fr, + Word16 gain, Word16 scale_fac_idx, Word16 fs_idx, + Word16 fade /* 0=normal, +1=fade-in, -1=fade-out */); + +/*************************************************************************/ + + +void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word16 fs_idx, Word16 old_y_len, + Word16 *old_e, Word16 *x_in, Word16 *old_x, Word16 *y_out, Word16 *old_y, Word16 ltpf, + Word16 ltpf_active, Word16 pitch_index, Word16 *old_pitch_int, Word16 *old_pitch_fr, + Word16 *old_gain, Word16 *mem_ltpf_active, Word16 scale_fac_idx, Word16 bfi, + Word16 concealMethod, + Word16 damping, Word16 *old_scale_fac_idx, +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + Word32 *rel_pitch_change, Word16 hrmode, Word16 frame_dms, +#endif + Word8 *scratchBuffer) +{ + Counter i; + Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34; + Word16 *x, *y; + Word16 *z; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + Word32 tmp32, pitch_delta; +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_In("process_ltpf_decoder_fx", sizeof(struct { + Counter i; + Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34; + Word16 *x, *y; + Word16 *z; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + Word32 tmp32, pitch_delta; +#endif + })); +#endif + + z = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = MAX_LEN / 4 + 10 */ + + + test(); + IF ((sub(bfi, 1) == 0) && (sub(concealMethod, LC3_CON_TEC_NS_STD) == 0)) + { + ltpf = 0; move16(); + ltpf_active = 0; move16(); + pitch_int = 0; move16(); + pitch_fr = 0; move16(); + gain = 0; move16(); + } + + /* Filter parameters */ + IF (sub(bfi, 1) != 0) + { + IF (ltpf == 0) + { + pitch_int = 0; move16(); + pitch_fr = 0; move16(); + } + ELSE + { + /* Decode pitch */ + IF (sub(pitch_index, 380) < 0) + { + pitch_int = shr_pos(add(pitch_index, 64), 2); + pitch_fr = add(sub(pitch_index, shl_pos(pitch_int, 2)), 128); + } + ELSE IF (sub(pitch_index, 440) < 0) + { + pitch_int = shr_pos(sub(pitch_index, 126), 1); + pitch_fr = sub(sub(shl_pos(pitch_index, 1), shl_pos(pitch_int, 2)), 252); + } + ELSE + { + pitch_int = sub(pitch_index, 283); + pitch_fr = 0; move16(); + } + pitch = add(shl_pos(pitch_int, 2), pitch_fr); +#ifdef ENABLE_HR_MODE + IF (sub(fs_idx, 5) == 0) + { + pitch = round_fx(L_shl_pos(L_mult(shl_pos(pitch, 2), pitch_scale[4]), 1)); + } + ELSE +#endif + { + pitch = mult_r(shl_pos(pitch, 2), pitch_scale[fs_idx]); + } + pitch_int = shr_pos(pitch, 2); + pitch_fr = sub(pitch, shl_pos(pitch_int, 2)); + } + + /* Decode gain */ + if (scale_fac_idx < 0) + { + ltpf_active = 0; + ASSERT(!(*old_scale_fac_idx < 0 && *mem_ltpf_active == 1)); + } + IF (ltpf_active == 0) + { + gain = 0; move16(); + } + ELSE + { + ASSERT(scale_fac_idx >= 0); + gain = gain_scale_fac[scale_fac_idx]; move16(); + } + } + ELSE IF (sub(concealMethod, LC3_CON_TEC_NS_STD) != 0) + { + /* fix to avoid not initialized filtering for concelament + might be necessary in case of bit errors or rate switching */ + if (scale_fac_idx < 0) { + if (*mem_ltpf_active && *old_scale_fac_idx>=0) + { + scale_fac_idx = *old_scale_fac_idx; + } + } + + ltpf_active = *mem_ltpf_active; move16(); + + if ((sub(concealMethod, LC3_CON_TEC_PHASE_ECU) == 0)) + { /* always start fade off to save filtering WMOPS for the remaining 7.5 ms */ + assert(bfi == 1); + ltpf_active = 0; move16(); /*always start fade off , still maintain *mem_ltpf_active */ + } + + pitch_int = *old_pitch_int; + pitch_fr = *old_pitch_fr; + gain = mult_r(*old_gain, damping); + } + + test(); test(); + IF (ltpf_active == 0 && *mem_ltpf_active == 0) + { + /* LTPF inactive */ + + basop_memmove(y_out, x_in, L_frame * sizeof(Word16)); + + /* Update */ + s = sub(*old_e, *x_e); + IF (s > 0) + { + basop_memmove(old_y, &old_y[L_frame], (old_y_len - L_frame) * sizeof(Word16)); + + IF (sub(s, 15) > 0) + { + basop_memset(&old_y[old_y_len - L_frame], 0, (L_frame) * sizeof(Word16)); + + basop_memset(old_x, 0, (old_x_len) * sizeof(Word16)); + } + ELSE + { + FOR (i = 0; i < L_frame; i++) + { + old_y[i + old_y_len - L_frame] = shr(x_in[i], s); move16(); + } + FOR (i = 0; i < old_x_len; i++) + { + old_x[i] = shr(x_in[i + L_frame - old_x_len], s); move16(); + } + } + } + ELSE + { + IF (sub(s, -15) < 0) + { + basop_memset(old_y, 0, (old_y_len - L_frame) * sizeof(Word16)); + } + ELSE + { + FOR (i = 0; i < old_y_len - L_frame; i++) + { + old_y[i] = shl(old_y[i + L_frame], s); move16(); + } + } + + basop_memmove(&old_y[old_y_len - L_frame], x_in, (L_frame) * sizeof(Word16)); + + basop_memmove(old_x, &x_in[L_frame - old_x_len], (old_x_len) * sizeof(Word16)); + + *old_e = *x_e; move16(); + } + +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (bfi == 0 && sub(hrmode,1) == 0 && (sub(frame_dms,50) == 0 || sub(frame_dms,25) == 0)){ + pitch_delta = abs_s(add(sub(*old_pitch_int,pitch_int) , shr_pos(sub(*old_pitch_fr, pitch_fr),2))); //int_old -int_new + (fr_old-fr_new) / 4.0)); + tmp32 = BASOP_Util_Divide3216_Scale_lc3plus(pitch_delta, MAX(add(*old_pitch_int, shr_pos(*old_pitch_fr,2)), 1),&s0);// = pitch_delta *2^15 / MAX(pitch_fl_c_old, 1); + *rel_pitch_change = L_shl_pos(tmp32,s0+16); + } +#endif + + *old_pitch_int = pitch_int; move16(); + *old_pitch_fr = pitch_fr; move16(); + *old_gain = 0; move16(); + *mem_ltpf_active = 0; move16(); + } + ELSE + { + /* Input/Output buffers */ + x = old_x + old_x_len; + y = old_y + old_y_len; + +#ifdef ENABLE_HR_MODE + assert(fs_idx < 5 && "Ltpf not supported for 96kHz!\n"); +#endif + + N4 = ltpf_overlap_len[fs_idx]; move16(); + N34 = sub(L_frame, N4); move16(); + + /* Input */ + basop_memmove(x, x_in, (L_frame) * sizeof(Word16)); + + /* Scaling */ + s0 = sub(s_min(getScaleFactor16_0(old_x, old_x_len), getScaleFactor16_0(old_y, old_y_len)), 1); + *old_e = sub(*old_e, s0); move16(); + s1 = sub(getScaleFactor16(x, L_frame), 1); + *x_e = sub(*x_e, s1); move16(); + s = sub(*old_e, *x_e); + IF (s > 0) + { + Scale_sig(x, L_frame, sub(s1, s)); + Scale_sig(old_x, old_x_len, s0); + Scale_sig(old_y, old_y_len, s0); + *x_e = *old_e; move16(); + } + ELSE + { + Scale_sig(x, L_frame, s1); + Scale_sig(old_x, old_x_len, add(s0, s)); + Scale_sig(old_y, old_y_len, add(s0, s)); + *old_e = *x_e; move16(); + } + + /* Filtering */ + IF (ltpf_active == 0) + { + ltpf_synth_filter(y, x, N4, *old_pitch_int, *old_pitch_fr, *old_gain, *old_scale_fac_idx, fs_idx, + -1); + } + ELSE IF (*mem_ltpf_active == 0) + { + ltpf_synth_filter(y, x, N4, pitch_int, pitch_fr, gain, scale_fac_idx, fs_idx, 1); + } + ELSE IF (sub(pitch_int, *old_pitch_int) == 0 && sub(*old_pitch_fr, pitch_fr) == 0) + { + ltpf_synth_filter(y, x, N4, pitch_int, pitch_fr, gain, scale_fac_idx, fs_idx, 0); + } + ELSE + { + ltpf_synth_filter(y, x, N4, *old_pitch_int, *old_pitch_fr, *old_gain, *old_scale_fac_idx, fs_idx, + -1); + basop_memmove(z, y - tilt_filter_len[fs_idx], (N4 + tilt_filter_len[fs_idx]) * sizeof(Word16)); + ltpf_synth_filter(y, z + tilt_filter_len[fs_idx], N4, pitch_int, pitch_fr, gain, scale_fac_idx, + fs_idx, 1); + } + IF (ltpf_active > 0) + { + ltpf_synth_filter(y + N4, x + N4, N34, pitch_int, pitch_fr, gain, + scale_fac_idx, fs_idx, 0); + } + ELSE + { + basop_memmove(&y[N4], &x[N4], N34 * sizeof(Word16)); + } + + /* Output */ + basop_memmove(y_out, y, (L_frame) * sizeof(Word16)); + + /* Update */ + basop_memmove(old_x, &old_x[L_frame], (old_x_len) * sizeof(Word16)); + + basop_memmove(old_y, &old_y[L_frame], (old_y_len) * sizeof(Word16)); + + *old_pitch_int = pitch_int; move16(); + *old_pitch_fr = pitch_fr; move16(); + *old_gain = gain; move16(); + *mem_ltpf_active = ltpf_active; move16(); + } + + *old_scale_fac_idx = scale_fac_idx; move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + +static void ltpf_synth_filter(Word16 *synth_ltp, Word16 *synth, Word16 length, Word16 pitch_int, Word16 pitch_fr, + Word16 gain, Word16 scale_fac_idx, Word16 fs_idx, + Word16 fade /* 0=normal, +1=fade-in, -1=fade-out */) +{ + Word16 *x0; + Word16 *y0; + Word32 s; + Word16 alpha, step; + Word16 i, k; + Counter j, l; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("ltpf_synth_filter", sizeof(struct { + Word16 *x0; + Word16 *y0; + Word32 s; + Word16 alpha, step; + Word16 i, k; + Counter j, l; + })); +#endif + + ASSERT(scale_fac_idx >= 0); + + step = 0; /* initialize just to avoid compiler warning */ + alpha = 0; /* initialize just to avoid compiler warning */ + x0 = &synth_ltp[-pitch_int + inter_filter_shift[fs_idx]]; + y0 = synth; + + alpha = 0; move16(); + IF (fade != 0) + { + if (fade < 0) + { + alpha = 0x7FFF; move16(); + } + +/* step = 1.f/(float)(length); */ + if (sub(length, 20) == 0) + { + step = 1638 /*1.f/20.f Q15*/; move16(); + } + if (sub(length, 40) == 0) + { + step = 819 /*1.f/40.f Q15*/; move16(); + } + if (sub(length, 60) == 0) + { + step = 546 /*1.f/60.f Q15*/; move16(); + } + if (sub(length, 80) == 0) + { + step = 409 /*1.f/80.f Q15*/; move16(); + } + if (sub(length, 120) == 0) + { + step = 273 /*1.f/120.f Q15*/; move16(); + } + + if (fade < 0) + step = negate(step); + } + + FOR (j = 0; j < length; j++) + { + s = L_mult(x0[0], inter_filter[fs_idx][pitch_fr][0]); + FOR (l = 1; l < inter_filter_len[fs_idx]; l++) + { + s = L_mac(s, x0[-l], inter_filter[fs_idx][pitch_fr][l]); + } + FOR (l = 0; l < tilt_filter_len[fs_idx]; l++) + { + s = L_msu(s, y0[-l], tilt_filter[fs_idx][scale_fac_idx][l]); + } + + i = msu_r(s, y0[-l], tilt_filter[fs_idx][scale_fac_idx][l]); + + k = mult_r(gain, i); + + if (fade != 0) + k = mult_r(k, alpha); + + synth_ltp[j] = add(synth[j], k); move16(); + + if (fade != 0) + alpha = add(alpha, step); + + x0++; + y0++; + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/makefile b/lib_lc3plus/makefile new file mode 100644 index 000000000..d86232d67 --- /dev/null +++ b/lib_lc3plus/makefile @@ -0,0 +1,180 @@ +#****************************************************************************** +# ETSI TS 103 634 V1.4.5 * +# Low Complexity Communication Codec Plus (LC3plus) * +# * +# Copyright licence is solely granted through ETSI Intellectual Property * +# Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +# estoppel or otherwise. * +#*****************************************************************************/ + +# Options +AFL = 0 +GCOV = 0 +NO_POST_REL_CHANGES_TEST = 0 +OPTIM = 0 +SUBSET = ALL +WMOPS = 1 +HR = 1 +CLANG = 0 +SHORT_PLC_FADEOUT = 0 + +# Paths +VPATH = . basic_op +BUILD = build +CC = gcc +LINK = $(CC) + +# Binary Name +NAME_LC3 = LC3plus +# Shared Library Name +LIB_LC3 = libLC3plus.so + +# Default tool settings +RM = rm -f + +ifndef VERBOSE +QUIET_CC = @echo ' ' Compiling $<; +QUIET_LINK= @echo ' ' Linking $@; +QUIET = @ +endif + +# C compiler flags +# Preprocessor(-I/-D) / Compiler / Linker flags +CPPFLAGS += -Ibasic_op -DSUBSET_$(SUBSET) +CFLAGS += -std=c99 -fPIC \ + -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ + -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ + -Werror-implicit-function-declaration + +ifneq "$(DEBUG)" "0" +CFLAGS += -g3 +LDFLAGS += -g3 +endif + +ifeq "$(HR)" "0" +CFLAGS += -DDISABLE_HR_MODE +endif + +ifeq "$(SHORT_PLC_FADEOUT)" "1" +CFLAGS += -DPLC_TUNING_SHORT_FADEOUT +endif + +# memory sanitizer, find use of uninitialized memory +ifeq "$(CLANG)" "1" + CC = clang + CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer + LDFLAGS += -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer + OPTIM = 2 +endif + +# address sanitizer, find buffer overflows +ifeq "$(CLANG)" "2" + CC = clang + CFLAGS += -fsanitize=address -fno-omit-frame-pointer + LDFLAGS += -fsanitize=address -fno-omit-frame-pointer + OPTIM = 2 +endif + +# undefined behavior sanitizer, find bugs like integer overflows +ifeq "$(CLANG)" "3" + CC = clang + CFLAGS += -fsanitize=undefined + LDFLAGS += -fsanitize=undefined + OPTIM = 2 +endif + +LDFLAGS += -lm + +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD)/$*.Td + +ifeq "$(GCOV)" "1" +CFLAGS += -fprofile-arcs -ftest-coverage +LDFLAGS += -fprofile-arcs -ftest-coverage +endif + +OPTIM ?= 0 +CFLAGS += -O$(OPTIM) + +CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR)) + +ifeq "$(NO_POST_REL_CHANGES_TEST)" "1" +CFLAGS += -DNO_POST_REL_CHANGES +endif + +# disable wmops instrumentation +ifeq "$(WMOPS)" "0" + CPPFLAGS += -DWMOPS=0 -DDONT_COUNT_MEM +endif + +# dependency magic +CC_FLAGS = '$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)' +POSTCOMPILE = mv -f $(BUILD)/$*.Td $(BUILD)/$*.d && touch $@ + +############################################################################### + +SRCS := $(notdir $(foreach DIR, $(VPATH), $(wildcard $(DIR)/*.c))) + +EXCL := ccConvert.c +SRCS := $(notdir $(foreach DIR, $(VPATH), $(wildcard $(DIR)/*.c))) +SRCS := $(filter-out $(EXCL), $(SRCS)) + +EXCL_CCC := $(BUILD)/codec_exe.o +OBJS_CCC_UNF := $(addprefix $(BUILD)/, $(SRCS:.c=.o)) +OBJS_CCC := $(filter-out $(EXCL_CCC), $(OBJS_CCC_UNF)) + +OBJS := $(addprefix $(BUILD)/, $(SRCS:.c=.o)) + +LIBSRCS := $(filter-out $(DIR)/ccConvert.c $(DIR)/codec_exe.c, $(SRCS)) +LIBOBJS := $(addprefix $(BUILD)/, $(LIBSRCS:.c=.o)) + +############################################################################### + +.PHONY: all clean help force + +all: $(NAME_LC3) + +help: + @echo 'Targets:' + @echo ' $(NAME_LC3) (default)' + @echo ' $(LIB_LC3)' + @echo ' ccConvert' + @echo 'Syntax: make [OPTION=VALUE ...]' + @echo 'Build options:' + @echo ' NO_POST_REL_CHANGES_TEST $(NO_POST_REL_CHANGES_TEST) [0,1]' + @echo ' OPTIM $(OPTIM) [0-3]' + @echo ' SUBSET $(SUBSET) [NB,WB,SSWB,SWB,FB,UB,ALL]' + @echo ' WMOPS $(WMOPS) [0,1]' + @echo ' SHORT_PLC_FADEOUT $(SHORT_PLC_FADEOUT) [0,1]' + @echo 'Debug options:' + @echo ' AFL $(AFL) [0,1]' + @echo ' CLANG $(CLANG) [0-3]' + @echo ' GCOV $(GCOV) [0,1]' + +$(NAME_LC3): $(OBJS) + @echo 'Linking' $@ + $(QUIET) $(LINK) $(OBJS) -o $@ $(LDFLAGS) + +$(LIB_LC3): $(LIBOBJS) + @echo 'Linking' $@ + $(QUIET) $(LINK) --shared $(OBJS) -o $@ $(LDFLAGS) + +ccConvert: $(BUILD)/ccConvert.o $(OBJS_CCC) + @echo 'Linking' $@ + $(QUIET) $(LINK) $? -o $@ $(LDFLAGS) + +clean: + $(QUIET) rm -rf $(NAME_LC3) $(LIB_LC3) $(BUILD) ccConvert + +$(BUILD)/%.o : %.c $(BUILD)/cc_flags + @echo 'Compiling' $< + $(QUIET) $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< + $(QUIET) $(POSTCOMPILE) + +# force rebuild if compilation flags changed +$(BUILD)/cc_flags: force + $(QUIET) mkdir -p $(BUILD) + $(QUIET) echo $(CC_FLAGS) | cmp -s - $@ || echo $(CC_FLAGS) > $@ + +# force rebuild if include dependency changed +$(BUILD)/%.d: ; +include $(wildcard $(patsubst %, $(BUILD)/%.d, $(basename $(SRCS)))) diff --git a/lib_lc3plus/mdct_fx.c b/lib_lc3plus/mdct_fx.c new file mode 100644 index 000000000..9e9157204 --- /dev/null +++ b/lib_lc3plus/mdct_fx.c @@ -0,0 +1,223 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +/* Union holding buffers to conserve stack memory. */ + +void processMdct_fx( +#ifdef ENABLE_HR_MODE + Word32 x[], /* i: time input signal */ +#else + Word16 x[], /* i: time input signal */ +#endif + Word16 x_exp, Word16 N, /* i: block size N */ +#ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION +# ifdef ENABLE_HR_MODE + Word16 hrmode, /* i: indicate high precision */ +# endif +#endif +#ifdef ENABLE_HR_MODE + const Word32 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ +#else + const Word16 w[], /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ +#endif + Word16 wLen, /* i: window length */ +#ifdef ENABLE_HR_MODE + Word32 mem[], /* i/o: last block of input samples */ +#else + Word16 mem[], /* i/o: last block of input samples */ +#endif + Word16 memLen, /* i: length of last sample block */ + Word32 y[], /* o: spectral data */ + Word16 * y_e, /* o: spectal data exponent */ + Word8 * scratchBuffer) +{ + Counter i; + Word16 z, s, m; +#ifdef ENABLE_HR_MODE + Word32 *buf; +#else + Word16 *buf; +#endif + Word32 *workBuffer; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processMdct_fx", sizeof(struct { + Counter i; + Word16 z, s, m; + Word16 *buf; + Word32 *workBuffer; + })); +#endif + + /* Buffers overlap since they are not used at the same time */ +#ifdef ENABLE_HR_MODE + buf = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN */ +#else + buf = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN */ +#endif + workBuffer = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LEN */ + + /* Init (constant per sample rate) */ + z = (N << 1) - wLen; /* number of leading zeros in window */ + m = N >> 1; /* half block size */ + +#ifdef ENABLE_HR_MODE + basop_memmove(buf, mem, memLen * sizeof(Word32)); + + basop_memmove(&buf[memLen], x, (N - memLen) * sizeof(Word32)); + + basop_memmove(mem, &x[N - memLen], memLen * sizeof(Word32)); +#else + basop_memmove(buf, mem, memLen * sizeof(Word16)); + + basop_memmove(&buf[memLen], x, (N - memLen) * sizeof(Word16)); + + basop_memmove(mem, &x[N - memLen], memLen * sizeof(Word16)); +#endif + +#ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + +# ifdef ENABLE_HR_MODE + if (hrmode) + { + FOR (i = 0; i < m; i++) + { + y[m + i] = Msu_32_32_0(Mpy_32_32_0(w[i], buf[i]), w[2 * m - 1 - i], buf[2 * m - 1 - i]); move32(); + } + + FOR (i = 0; i < z; i++) + { + y[m - 1 - i] = Mpy_32_32_0(w[2 * m + i], x[2 * m - memLen + i]); move32(); + } + + FOR (i = i; i < m; i++) + { + y[m - 1 - i] = Mac_32_32_0(Mpy_32_32_0(w[2 * m + i], x[2 * m - memLen + i]), w[4 * m - 1 - i], x[4 * m - memLen - 1 - i]); move32(); + } + } else { +# ifdef CR9_B_FIX_MDCT_OVERFLOW + FOR (i = 0; i < m; i++) + { + y[m + i] = L_msu0(L_mult0(round_fx_sat(buf[i]), round_fx(w[i])), round_fx_sat(buf[2 * m - 1 - i]), round_fx(w[2 * m - 1 - i])); move32(); + } + + FOR (i = 0; i < z; i++) + { + y[m - 1 - i] = L_mult0(round_fx_sat(x[2 * m - memLen + i]), round_fx(w[2 * m + i])); move32(); + } + + FOR (i = i; i < m; i++) + { + y[m - 1 - i] = L_mac0(L_mult0(round_fx_sat(x[2 * m - memLen + i]), round_fx(w[2 * m + i])), round_fx_sat(x[4 * m - memLen - 1 - i]), + round_fx(w[4 * m - 1 - i])); move32(); + } +# else /* CR9_B_FIX_MDCT_OVERFLOW */ + FOR (i = 0; i < m; i++) + { + y[m + i] = L_msu0(L_mult0(round_fx(buf[i]), round_fx(w[i])), round_fx(buf[2 * m - 1 - i]), round_fx(w[2 * m - 1 - i])); move32(); + } + + FOR (i = 0; i < z; i++) + { + y[m - 1 - i] = L_mult0(round_fx(x[2 * m - memLen + i]), round_fx(w[2 * m + i])); move32(); + } + + FOR (i = i; i < m; i++) + { + y[m - 1 - i] = L_mac0(L_mult0(round_fx(x[2 * m - memLen + i]), round_fx(w[2 * m + i])), round_fx(x[4 * m - memLen - 1 - i]), + round_fx(w[4 * m - 1 - i])); move32(); + } +# endif /* CR9_B_FIX_MDCT_OVERFLOW */ + } +# else + /* regular resolution only */ + FOR (i = 0; i < m; i++) + { + y[m + i] = L_msu0(L_mult0(buf[i], w[i]), buf[2 * m - 1 - i], w[2 * m - 1 - i]); move32(); + } + + FOR (i = 0; i < z; i++) + { + y[m - 1 - i] = L_mult0(x[2 * m - memLen + i], w[2 * m + i]); move32(); + } + + FOR (i = i; i < m; i++) + { + y[m - 1 - i] = L_mac0(L_mult0(x[2 * m - memLen + i], w[2 * m + i]), x[4 * m - memLen - 1 - i], + w[4 * m - 1 - i]); move32(); + } +# endif + +#else /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + + FOR (i = 0; i < m; i++) + { +# ifdef ENABLE_HR_MODE + y[m + i] = Msu_32_32_0(Mpy_32_32_0(w[i], buf[i]), w[2 * m - 1 - i], buf[2 * m - 1 - i]); move32(); +# else + y[m + i] = L_msu0(L_mult0(buf[i], w[i]), buf[2 * m - 1 - i], w[2 * m - 1 - i]); move32(); +# endif + } + + FOR (i = 0; i < z; i++) + { +# ifdef ENABLE_HR_MODE + y[m - 1 - i] = Mpy_32_32_0(w[2 * m + i], x[2 * m - memLen + i]); move32(); +# else + y[m - 1 - i] = L_mult0(x[2 * m - memLen + i], w[2 * m + i]); move32(); +# endif + } + + FOR (i = i; i < m; i++) + { +# ifdef ENABLE_HR_MODE + y[m - 1 - i] = Mac_32_32_0(Mpy_32_32_0(w[2 * m + i], x[2 * m - memLen + i]), w[4 * m - 1 - i], x[4 * m - memLen - 1 - i]); move32(); +# else + y[m - 1 - i] = L_mac0(L_mult0(x[2 * m - memLen + i], w[2 * m + i]), x[4 * m - memLen - 1 - i], + w[4 * m - 1 - i]); move32(); +# endif + } + +#endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ + + s = s_max(0, getScaleFactor32_lc3plus(y, N)); + FOR (i = 0; i < N; i++) + { + y[i] = L_shl(y[i], s); move32(); + } + + *y_e = sub(sub(x_exp, 2), s); + + /* N=20 only for 2.5ms possible */ + /* maybe implement this a pre init of shift */ + if (sub(N, 20) <= 0) + { + *y_e = add(*y_e, 2); + } + else if (sub(N, 120) <= 0) + { + *y_e = add(*y_e, 1); + } +#ifdef ENABLE_HR_MODE + dct_IV(y, y_e, N, +# ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION + hrmode, +# endif + workBuffer); +#else + dct_IV(y, y_e, N, workBuffer); +#endif + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/mdct_shaping_fx.c b/lib_lc3plus/mdct_shaping_fx.c new file mode 100644 index 000000000..3b36265fd --- /dev/null +++ b/lib_lc3plus/mdct_shaping_fx.c @@ -0,0 +1,74 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processMdctShaping_fx(Word32 x[], +#ifdef ENABLE_HR_MODE + Word32 scf[], +#else + Word16 scf[], +#endif + Word16 scf_exp[], const Word16 bands_offset[], Word16 fdns_npts) +{ + Counter i, j; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processMdctShaping_fx", sizeof(struct { Counter i, j; })); +#endif + + j = 0; move16(); + FOR (i = 0; i < fdns_npts; i++) + { + FOR (; j < bands_offset[i + 1]; j++) + { +#ifdef ENABLE_HR_MODE + x[j] = L_shl(Mpy_32_32_lc3plus(x[j], scf[i]), scf_exp[i]); move32(); +#else + x[j] = L_shl(Mpy_32_16_lc3plus(x[j], scf[i]), scf_exp[i]); move32(); +#endif + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + +void processScfScaling(Word16 scf_exp[], Word16 fdns_npts, Word16 *x_e) +{ + Counter i; + Word16 scf_exp_max; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processLpcGainScaling", sizeof(struct { + Counter i; + Word16 scf_exp_max; + })); +#endif + + scf_exp_max = scf_exp[0]; move16(); + + FOR (i = 1; i < fdns_npts; i++) + { + scf_exp_max = s_max(scf_exp_max, scf_exp[i]); + } + + FOR (i = 0; i < fdns_npts; i++) + { + scf_exp[i] = sub(scf_exp[i], scf_exp_max); move16(); + } + + *x_e = add(*x_e, scf_exp_max); move16(); +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/near_nyquist_detector_fx.c b/lib_lc3plus/near_nyquist_detector_fx.c new file mode 100644 index 000000000..8ae29cbb8 --- /dev/null +++ b/lib_lc3plus/near_nyquist_detector_fx.c @@ -0,0 +1,141 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_idx, const Word16 near_nyquist_index, + const Word16 bands_number, const Word32 *ener_fx, const Word16 ener_fx_exp +#ifdef CR8_E_TONE_DETECTOR +#ifdef ENABLE_HR_MODE + ,Word16 frame_dms, Word16 hrmode) +#else + ) +#endif +#else + ) +#endif +{ + *near_nyquist_flag = 0; +#ifdef CR8_E_TONE_DETECTOR +#ifdef ENABLE_HR_MODE + IF (hrmode == 0){ +#endif +#endif + IF (sub(fs_idx, 4) < 0) + { + Dyn_Mem_Deluxe_In( + Word16 i; + Word16 nrg_above_thresh; + Word16 ener_low_exp; + Word16 ener_high_exp; + Word16 comp_energy_exp; + Word32 comp_energy; + Word32 ener_low; + Word32 ener_high; + ); + + ener_low = 0; move32(); + ener_low_exp = 0; move16(); + FOR (i = 0; i < near_nyquist_index; i++) + { + ener_low = BASOP_Util_Add_Mant32Exp_lc3plus(ener_fx[i], ener_fx_exp, ener_low, ener_low_exp, &ener_low_exp); + } + + ener_high = 0; move32(); + ener_high_exp = 0; move16(); + FOR (i = near_nyquist_index; i < bands_number; i++) + { + ener_high = BASOP_Util_Add_Mant32Exp_lc3plus(ener_fx[i], ener_fx_exp, ener_high, ener_high_exp, &ener_high_exp); + } + + comp_energy = Mpy_32_16_lc3plus(ener_low, NN_thresh); /* Mpy_32_16_lc3plus -> 32Q15 */ + comp_energy_exp = add(add(ener_low_exp, NN_thresh_exp),15); + + nrg_above_thresh = BASOP_Util_Cmp_Mant32Exp_lc3plus(ener_high, ener_high_exp, comp_energy, comp_energy_exp); /* 1 if firstNumber > secondNumber */ + + if (sub(nrg_above_thresh, 1) == 0) + { + *near_nyquist_flag = 1; + } + + Dyn_Mem_Deluxe_Out(); + } +#ifdef CR8_E_TONE_DETECTOR +#ifdef ENABLE_HR_MODE + } + ELSE // hrmode == 1 + { + // inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); + Word32 td_thresh; + + SWITCH (frame_dms) + { + case 25: + td_thresh = TD_HR_thresh_2_5ms; + BREAK; + case 50: + td_thresh = TD_HR_thresh_5ms; + BREAK; + #ifdef ENABLE_075_DMS_MODE + case 75: + td_thresh = TD_HR_thresh_7_5ms; + BREAK; + #endif + default: /* 100 */ + td_thresh = TD_HR_thresh_10ms; + BREAK; + } + + Word16 mean_ener_exp = 0; + + Word32 sum_ener = 0; move32(); + Word16 sum_ener_exp = 0; move16(); + FOR (Word16 i = 0; i < bands_number; i++) + { + sum_ener = BASOP_Util_Add_Mant32Exp_lc3plus(ener_fx[i], ener_fx_exp, sum_ener, sum_ener_exp, &sum_ener_exp); + } + + Word16 denom = sub(14,norm_s(bands_number)); + IF (sub(frame_dms, 50) == 0){ + denom = sub(15,norm_s(bands_number)); move16(); + } + + Word32 mean_ener = L_shr(sum_ener, denom); move32(); // = sum_ener / bands_number + mean_ener_exp = sum_ener_exp; move16(); + + Word32 sum_ener_log2 = 0;move32(); + Word16 sum_ener_log2_exp = 0;move16(); + Word32 mean_ener_log2 = 0;move32(); + + FOR (Word16 i = 0; i < bands_number; i++) + { + IF (ener_fx[i] != 0) { + Word32 log2Value = L_add(BASOP_Util_Log2_lc3plus(ener_fx[i]), L_shl_pos(L_deposit_l(ener_fx_exp), 25)); + /* input argument is in Q7.25 , returns pow(2,(x/64) + floatingpoint value log2_fl = log2Value/pow(2,31-6) */ + sum_ener_log2 = BASOP_Util_Add_Mant32Exp_lc3plus(log2Value, 6, sum_ener_log2, sum_ener_log2_exp, &sum_ener_log2_exp); move32(); + } + } + mean_ener_log2 = L_shr(sum_ener_log2, denom); move32(); //mean_ener_log2 = sum_ener_log2 / bands_number + Word16 mean_ener_log2_exp = sum_ener_log2_exp; + Word32 mean_ener_log2_fl = L_shr_pos(mean_ener_log2 ,s_min(31, sub(31,mean_ener_log2_exp))); //mean_ener_log2_fl = mean_ener_log2 / 2^(31-mean_ener_log2_exp) + Word32 inv_flatness = 0; + if (L_sub(norm_l(mean_ener),sub(sub(mean_ener_exp,31),mean_ener_log2_fl)) < 0 ) { + inv_flatness = maxWord32; + } + else { + inv_flatness = L_shl(mean_ener, s_max(-31,sub(sub(mean_ener_exp,31),mean_ener_log2_fl))); + } + IF (L_sub(inv_flatness, td_thresh) > 0) { + *near_nyquist_flag = 1; move16(); + } + } + #endif // ENABLE_HR_MODE +#endif // CR8_E_TONE_DETECTOR +} diff --git a/lib_lc3plus/noise_factor_fx.c b/lib_lc3plus/noise_factor_fx.c new file mode 100644 index 000000000..75ffb5fac --- /dev/null +++ b/lib_lc3plus/noise_factor_fx.c @@ -0,0 +1,252 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + + +void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], +# ifdef ENABLE_HR_MODE + Word32 xq[], +# else + Word16 xq[], +# endif + Word16 gg, Word16 gg_e, Word16 BW_cutoff_idx, Word16 frame_dms, Word16 target_bytes, + Word8 *scratchBuffer +# ifdef ENABLE_HR_MODE + ,Word16 hrmode +# endif +) +{ + Dyn_Mem_Deluxe_In(Counter k; Word16 nzeros, s1, s2, s3, c, idx, fac_unq, *ind; + Word16 noisefillwidth, noisefillstart, N; Word32 Lsum;); + + + + ind = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN bytes */ + + noisefillwidth = 0; + noisefillstart = 0; + c = 0; + move16(); + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + N = BW_cutoff_bin_all_HR[BW_cutoff_idx]; + move16(); + } + else +#endif + { + N = BW_cutoff_bin_all[BW_cutoff_idx]; + move16(); + } + + SWITCH (frame_dms) + { + case 25: + N = shr_pos(N, 2); + noisefillwidth = NOISEFILLWIDTH_2_5MS; + noisefillstart = NOISEFILLSTART_2_5MS; + BREAK; + case 50: + N = shr_pos(N, 1); + noisefillwidth = NOISEFILLWIDTH_5MS; + noisefillstart = NOISEFILLSTART_5MS; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + N = add(shr_pos(N, 2), add(shr_pos(N, 2), shr_pos(N, 2))); + noisefillwidth = NOISEFILLWIDTH_7_5MS; + noisefillstart = NOISEFILLSTART_7_5MS; + BREAK; +# endif + case 100: + noisefillwidth = NOISEFILLWIDTH; + noisefillstart = NOISEFILLSTART; + BREAK; + } + + nzeros = -2 * noisefillwidth - 1; + move16(); + + FOR (k = noisefillstart - noisefillwidth; k < noisefillstart + noisefillwidth; k++) + { + if (xq[k] != 0) + { + nzeros = -2 * noisefillwidth - 1; + move16(); + } + if (xq[k] == 0) + { + nzeros = add(nzeros, 1); + } + } + + FOR (k = noisefillstart; k < N - noisefillwidth; k++) + { + if (xq[k + noisefillwidth] != 0) + { + nzeros = -2 * noisefillwidth - 1; + move16(); + } + if (xq[k + noisefillwidth] == 0) + { + nzeros = add(nzeros, 1); + } + if (nzeros >= 0) + { + ind[c++] = k; + move16(); + } + } + + FOR (k = N - noisefillwidth; k < N; k++) + { + nzeros = add(nzeros, 1); + if (nzeros >= 0) + { + ind[c++] = k; + move16(); + } + } + + IF (c == 0) + { + fac_unq = 0; + move16(); + } + ELSE + { + + IF (target_bytes <= 20 && frame_dms == 100) + { + Word32 ind_sum; + Word16 mean_ind; + + Word16 fac_unq1, fac_unq2; + + /* calculate mean index */ + ind_sum = ind[0]; + move32(); + FOR (k = 1; k < c; k++) + { + ind_sum = L_add(ind_sum, ind[k]); + } + + mean_ind = BASOP_Util_Divide3216_Scale_lc3plus(ind_sum, c, &s2); + mean_ind = shl(mean_ind, s2 + 1); + + assert(0 <= mean_ind && mean_ind <= ind[c - 1]); + + /* calculate noise filling gain for low frequencies */ + s2 = 0; move16(); + if (sub(mean_ind, ind[0]) > 0) + { + /* calculate scale to ensure that Lsum does not overflow */ + s2 = s_max(sub(sub(14, norm_s(c)), getScaleFactor32_lc3plus(&x[ind[0]], sub(mean_ind, ind[0]))), 0); + } + Lsum = L_shr_pos_pos(L_abs(x[ind[0]]), s2); + + FOR (k = 1; k < c && ind[k] <= mean_ind; k++) + { + /* scale before adding to Lsum */ + Lsum = L_add(Lsum, L_shr_pos_pos(L_abs(x[ind[k]]), s2)); + } + fac_unq1 = BASOP_Util_Divide3216_Scale_lc3plus(Lsum, k, &s1); + /* add scale applied during summing */ + s1 = add(s1, s2); + fac_unq1 = BASOP_Util_Divide1616_Scale_lc3plus(fac_unq1, gg, &s2); + s3 = sub(15, add(x_e, add(s1, sub(s2, gg_e)))); + s2 = norm_s(fac_unq1); + test(); + IF (fac_unq1 != 0 && add(s3, s2) < 0) + { + fac_unq1 = MAX_16; + move16(); + } + ELSE + { + s3 = s_min(s_max(s3, -15), 15); + fac_unq1 = shr_r(fac_unq1, s3); + } + + /* calculate noise filling gain for high frequencies */ + Lsum = 0; + move16(); + idx = sub(c, k); + FOR (; k < c; k++) + { + Lsum = L_add(Lsum, L_abs(x[ind[k]])); + } + fac_unq2 = BASOP_Util_Divide3216_Scale_lc3plus(Lsum, idx, &s1); + fac_unq2 = BASOP_Util_Divide1616_Scale_lc3plus(fac_unq2, gg, &s2); + s3 = sub(15, add(x_e, add(s1, sub(s2, gg_e)))); + s2 = norm_s(fac_unq1); + test(); + IF (fac_unq2 != 0 && add(s3, s2) < 0) + { + fac_unq2 = MAX_16; + move16(); + } + ELSE + { + s3 = s_min(s_max(s3, -15), 15); + fac_unq2 = shr_r(fac_unq2, s3); + } + + /* calculate noise filling gain as minimum over high and low frequencies */ + fac_unq = s_min(fac_unq1, fac_unq2); + } + ELSE + { + /* calculate scale to ensure that Lsum does not overflow */ + s2 = s_max(sub(sub(14, norm_s(c)), getScaleFactor32_lc3plus(&x[ind[0]], sub(N,ind[0]))), 0); + Lsum = L_abs(x[ind[0]]); + FOR (k = 1; k < c; k++) + { + /* scale before adding to Lsum */ + Lsum = L_add(Lsum, L_shr_pos_pos(L_abs(x[ind[k]]), s2)); + } + fac_unq = BASOP_Util_Divide3216_Scale_lc3plus(Lsum, c, &s1); + /* add scale applied during summing */ + s1 = add(s1, s2); + fac_unq = BASOP_Util_Divide1616_Scale_lc3plus(fac_unq, gg, &s2); + s3 = sub(15, add(x_e, add(s1, sub(s2, gg_e)))); + s2 = norm_s(fac_unq); + test(); + IF (fac_unq != 0 && add(s3, s2) < 0) + { + fac_unq = MAX_16; + move16(); + } + ELSE + { + fac_unq = shr_r(fac_unq, s_max(s_min(s3, 15), -15)); + } + } + } + + idx = round_fx(L_sub(0x80000, L_mult(fac_unq, 16))); + if (sub(idx, 7) > 0) + { + idx = 7; + move16(); + } + if (idx < 0) + { + idx = 0; + move16(); + } + *fac_ns_idx = idx; + move16(); + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/noise_filling_fx.c b/lib_lc3plus/noise_filling_fx.c new file mode 100644 index 000000000..9da870553 --- /dev/null +++ b/lib_lc3plus/noise_filling_fx.c @@ -0,0 +1,149 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +/*************************************************************************/ + + + +void processNoiseFilling_fx(Word32 xq[], Word16 nfseed, Word16 xq_e, Word16 fac_ns_idx, Word16 BW_cutoff_idx, + Word16 frame_dms, Word16 fac_ns_pc, Word16 spec_inv_idx, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +) +{ + Dyn_Mem_Deluxe_In( + Counter k; + Word16 nzeros, fac_ns, *ind, c; + Word16 noisefillwidth, noisefillstart, N; + Word32 L_tmp, L_tmp_neg, L_tmp_pc, L_tmp_neg_pc; + ); + + ind = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN bytes */ + + c = 0; move16(); + +#ifdef ENABLE_HR_MODE + if (hrmode == 1) + { + N = BW_cutoff_bin_all_HR[BW_cutoff_idx]; + move16(); + } + else +#endif + { + N = BW_cutoff_bin_all[BW_cutoff_idx]; + move16(); + } + + SWITCH (frame_dms) + { + case 25: + N = shr_pos(N, 2); + noisefillwidth = NOISEFILLWIDTH_2_5MS; + noisefillstart = NOISEFILLSTART_2_5MS; + BREAK; + case 50: + N = shr_pos(N, 1); + noisefillwidth = NOISEFILLWIDTH_5MS; + noisefillstart = NOISEFILLSTART_5MS; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + N = add(shr_pos(N, 2), add(shr_pos(N, 2), shr_pos(N, 2))); + noisefillwidth = NOISEFILLWIDTH_7_5MS; + noisefillstart = NOISEFILLSTART_7_5MS; + BREAK; +#endif + default: /* 100 */ + noisefillwidth = NOISEFILLWIDTH; + noisefillstart = NOISEFILLSTART; + BREAK; + } + + nzeros = -2 * noisefillwidth - 1; move16(); + + FOR (k = noisefillstart - noisefillwidth; k < noisefillstart + noisefillwidth; k++) + { + if (xq[k] != 0) + { + nzeros = -2 * noisefillwidth - 1; move16(); + } + if (xq[k] == 0) + { + nzeros = add(nzeros, 1); + } + } + + FOR (k = noisefillstart; k < N - noisefillwidth; k++) + { + if (xq[k + noisefillwidth] != 0) + { + nzeros = -2 * noisefillwidth - 1; move16(); + } + if (xq[k + noisefillwidth] == 0) + { + nzeros = add(nzeros, 1); + } + if (nzeros >= 0) + { + ind[c++] = k; move16(); + } + } + + FOR (k = N - noisefillwidth; k < N; k++) + { + nzeros = add(nzeros, 1); + if (nzeros >= 0) + { + ind[c++] = k; move16(); + } + } + + IF (c > 0) + { + fac_ns = shl_pos(sub(8, fac_ns_idx), 11); + L_tmp = L_shr_sat(L_deposit_l(fac_ns), sub(xq_e, 16)); + L_tmp_neg = L_negate(L_tmp); + L_tmp_pc = L_shr_sat(L_deposit_l(fac_ns_pc), sub(xq_e, 16)); + L_tmp_neg_pc = L_negate(L_tmp_pc); + + FOR (k = 0; k < c; k++) + { + nfseed = extract_l(L_mac0(13849, nfseed, 31821)); + IF (nfseed >= 0) + { + IF (ind[k] < spec_inv_idx) + { + xq[ind[k]] = L_tmp; move32(); + } + ELSE + { + xq[ind[k]] = L_tmp_pc; move32(); + } + } + IF (nfseed < 0) + { + IF (ind[k] < spec_inv_idx) + { + xq[ind[k]] = L_tmp_neg; move32(); + } + ELSE + { + xq[ind[k]] = L_tmp_neg_pc; move32(); + } + } + } + } + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/olpa_fx.c b/lib_lc3plus/olpa_fx.c new file mode 100644 index 000000000..a72d8b61c --- /dev/null +++ b/lib_lc3plus/olpa_fx.c @@ -0,0 +1,289 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +/*************************************************************************/ + + +void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[], Word16 *pitch, Word16 *s12k8, + Word16 len, Word16 *normcorr, Word16 *mem_pitch, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + Word16 *pitch_flag, +#endif + Word16 s12k8_exp, Word16 frame_dms, Word8 *scratchBuffer) +{ + Word32 sum, sum0, sum1, sum2, prod, inv; + Word16 shift, s6k4_exp, prod_exp, min_pitch, max_pitch; + Word16 scale0, scale1, scale2, pitch2, normcorr2, len2, acflen, mem_in_len; + Word32 max32; + Word32 *ac; + Word16 *s6k4; + Counter n; + + Counter m; + Word32 L_tmp, L_tmp2; + + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("process_olpa_fx", sizeof(struct { + Word32 sum, sum0, sum1, sum2, prod, inv; + Word16 shift, s6k4_exp, prod_exp, min_pitch, max_pitch; + Word16 scale0, scale1, scale2, pitch2, normcorr2, len2, acflen, mem_in_len; + Word32 max32; + Word32 *ac; + Word16 *s6k4; + Counter n; + Word32 sums[3]; + Counter m; + Word32 L_tmp, L_tmp2; + })); +#endif + + /* Buffer alignment */ + ac = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * RANGE_PITCH_6K4 = 392 bytes */ + + /* Downsample input signal by a factor of 2 (12.8kHz -> 6.4kHz) */ + mem_in_len = MAX_PITCH_6K4; move16(); + len2 = shr(len, 1); + acflen = len2; move16(); + +#ifdef CR9_F_PITCH_WIN_LEN_FIX + SWITCH(frame_dms) + { + case 50: + mem_in_len = add(mem_in_len, 32); + acflen = add(acflen, 32); + break; + + case 25: + mem_in_len = add(mem_in_len, 48); + acflen = add(acflen, 48); + break; + } +#endif + +#ifndef CR9_F_PITCH_WIN_LEN_FIX + IF (sub(frame_dms, 25) == 0) + { + mem_in_len = add(mem_in_len, 16); + acflen = add(acflen, 16); + } +#endif + + s6k4 = mem_s6k4 + mem_in_len; + sum = L_mac(L_mac(L_mult(mem_s12k8[0], 4053), mem_s12k8[1], 7712), mem_s12k8[2], 9239); + *s6k4++ = round_fx(L_mac_sat(L_mac(sum, s12k8[0], 7712), s12k8[1], 4053)); move16(); + sum = L_mac(L_mac(L_mult(mem_s12k8[2], 4053), s12k8[0], 7712), s12k8[1], 9239); + *s6k4++ = round_fx(L_mac_sat(L_mac(sum, s12k8[2], 7712), s12k8[3], 4053)); move16(); + + FOR (n = 5; n < len; n += 2) + { + sum = L_mac(L_mac(L_mult(s12k8[n - 4], 4053), s12k8[n - 3], 7712), s12k8[n - 2], 9239); + *s6k4++ = round_fx_sat(L_mac_sat(L_mac(sum, s12k8[n - 1], 7712), s12k8[n], 4053)); move16(); + } + + mem_s12k8[0] = s12k8[len - 3]; move16(); + mem_s12k8[1] = s12k8[len - 2]; move16(); + mem_s12k8[2] = s12k8[len - 1]; move16(); + + /* Scale downsampled signal */ + s6k4 = mem_s6k4 + mem_in_len; + scale0 = sub(getScaleFactor16_0(mem_s6k4, mem_in_len), 3); + *mem_s6k4_exp = sub(*mem_s6k4_exp, scale0); move16(); + scale1 = sub(getScaleFactor16_0(s6k4, len2), 3); + s6k4_exp = sub(s12k8_exp, scale1); + scale2 = sub(*mem_s6k4_exp, s6k4_exp); + IF (scale2 > 0) + { + Scale_sig(s6k4, len2, sub(scale1, scale2)); + shift = scale0; move16(); + s6k4_exp = *mem_s6k4_exp; move16(); + } + ELSE + { + Scale_sig(s6k4, len2, scale1); + shift = add(scale0, scale2); + *mem_s6k4_exp = s6k4_exp; move16(); + } +#ifdef CR9_F_PITCH_WIN_LEN_FIX + SWITCH(frame_dms) + { + case 50: + s6k4 = s6k4 - 32; + break; + + case 25: + s6k4 = s6k4 - 48; + break; + } +#endif + +#ifndef CR9_F_PITCH_WIN_LEN_FIX + if (sub(frame_dms, 25) == 0) + { + s6k4 = s6k4 - 16; + } +#endif + Scale_sig(mem_s6k4, mem_in_len, shift); + + /* Compute autocorrelation */ + FOR (n = MIN_PITCH_6K4; n <= MAX_PITCH_6K4; n++) + { + sum = L_mult0(s6k4[0], s6k4[0 - n]); + FOR (m = 1; m < acflen; m++) + { + sum = L_mac0(sum, s6k4[m], s6k4[m - n]); + } + ac[n - MIN_PITCH_6K4] = sum; move32(); + } + + /* Weight autocorrelation and find maximum */ + max32 = Mpy_32_16_lc3plus(ac[0], olpa_ac_weighting[0]); move32(); + *pitch = MIN_PITCH_6K4; move16(); + FOR (n = MIN_PITCH_6K4 + 1; n <= MAX_PITCH_6K4; n++) + { + L_tmp = Mpy_32_16_lc3plus(ac[n - MIN_PITCH_6K4], olpa_ac_weighting[n - MIN_PITCH_6K4]); + L_tmp2 = L_sub_sat(L_tmp, max32); + if (L_tmp2 > 0) + { + *pitch = n; move16(); + } + max32 = L_max(L_tmp, max32); + } + + /* Compute normalized correlation */ + sum0 = L_mult0(s6k4[0], s6k4[0 - *pitch]); + sum1 = L_mac0(1, s6k4[0 - *pitch], s6k4[0 - *pitch]); + sum2 = L_mac0(1, s6k4[0], s6k4[0]); + for (m = 1; m < acflen; m++) + { + sum0 = L_mac0(sum0, s6k4[m], s6k4[m - *pitch]); + sum1 = L_mac0(sum1, s6k4[m - *pitch], s6k4[m - *pitch]); + sum2 = L_mac0(sum2, s6k4[m], s6k4[m]); + } + scale1 = norm_l(sum1); + scale2 = norm_l(sum2); + sum1 = L_shl_pos(sum1, scale1); + sum2 = L_shl_pos(sum2, scale2); + prod = Mpy_32_32_lc3plus(sum1, sum2); + shift = norm_l(prod); + prod = L_shl_pos(prod, shift); + prod_exp = sub(62, add(add(scale1, scale2), shift)); + inv = Isqrt(prod, &prod_exp); + scale0 = norm_l(sum0); + sum0 = L_shl_pos(sum0, scale0); + prod = Mpy_32_32_lc3plus(sum0, inv); + prod_exp = add(sub(31, scale0), prod_exp); + test(); + IF (prod == 0 || sub(norm_l(prod), prod_exp) >= 0) + { + *normcorr = s_max(0, round_fx_sat(L_shl_sat(prod, prod_exp))); move16(); + } + ELSE + { + *normcorr = 32767; move16(); + } + + /* Second try in the neighborhood of the previous pitch */ + min_pitch = s_max(MIN_PITCH_6K4, sub(*mem_pitch, 4)); + max_pitch = s_min(MAX_PITCH_6K4, add(*mem_pitch, 4)); + + max32 = ac[min_pitch - MIN_PITCH_6K4]; move32(); + pitch2 = min_pitch; move16(); + FOR (n = min_pitch + 1; n <= max_pitch; n++) + { + L_tmp = L_sub_sat(ac[n - MIN_PITCH_6K4], max32); + if (L_tmp > 0) + { + pitch2 = n; move16(); + } + max32 = L_max(ac[n - MIN_PITCH_6K4], max32); + } + IF (sub(*pitch, pitch2) != 0) + { + sum0 = L_mult0(s6k4[0], s6k4[0 - pitch2]); + sum1 = L_mac0(1, s6k4[0 - pitch2], s6k4[0 - pitch2]); + sum2 = L_mac0(1, s6k4[0], s6k4[0]); + for (m = 1; m < acflen; m++) + { + sum0 = L_mac0(sum0, s6k4[m], s6k4[m - pitch2]); + sum1 = L_mac0(sum1, s6k4[m - pitch2], s6k4[m - pitch2]); + sum2 = L_mac0(sum2, s6k4[m], s6k4[m]); + } + scale1 = norm_l(sum1); + scale2 = norm_l(sum2); + sum1 = L_shl_pos(sum1, scale1); + sum2 = L_shl_pos(sum2, scale2); + prod = Mpy_32_32_lc3plus(sum1, sum2); + shift = norm_l(prod); + prod = L_shl_pos(prod, shift); + prod_exp = sub(62, add(add(scale1, scale2), shift)); + inv = Isqrt(prod, &prod_exp); + scale0 = norm_l(sum0); + sum0 = L_shl_pos(sum0, scale0); + prod = Mpy_32_32_lc3plus(sum0, inv); + prod_exp = add(sub(31, scale0), prod_exp); + test(); + IF (prod == 0 || sub(norm_l(prod), prod_exp) >= 0) + { + normcorr2 = s_max(0, round_fx_sat(L_shl_sat(prod, prod_exp))); move16(); + } + ELSE + { + normcorr2 = 32767; move16(); + } + IF (sub(normcorr2, mult_r(*normcorr, 27853)) > 0) + { + *pitch = pitch2; move16(); + *normcorr = normcorr2; move16(); + } + } + +#ifdef CR9_F_PITCH_WIN_LEN_FIX + SWITCH(frame_dms) + { + case 50: + if(*pitch_flag == 1) { + *mem_pitch = *pitch; move16(); + *pitch_flag = 0; + } + else { + *pitch_flag += 1; + } + break; + + case 25: + if (*pitch_flag == 3) { + *mem_pitch = *pitch; move16(); + *pitch_flag = 0; + } + else { + *pitch_flag += 1; + } + break; + + default: +#endif + *mem_pitch = *pitch; move16(); +#ifdef CR9_F_PITCH_WIN_LEN_FIX + } +#endif + + /* Update memory */ + basop_memmove(mem_s6k4, &mem_s6k4[len2], mem_in_len * sizeof(Word16)); + + /* Upsample pitch by a factor of 2 (6.4kHz -> 12.8kHz) */ + *pitch = shl_pos(*pitch, 1); move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/pc_apply_fx.c b/lib_lc3plus/pc_apply_fx.c new file mode 100644 index 000000000..42ddfb243 --- /dev/null +++ b/lib_lc3plus/pc_apply_fx.c @@ -0,0 +1,315 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "constants.h" +#include "functions.h" + +#ifdef ENABLE_HR_MODE +static Word16 getScaleFactor32_withNegativeScaling(Word32 *data32, Word16 dataLen); +#else +static Word16 getScaleFactor16_withNegativeScaling(Word16 *data16, Word16 dataLen); +#endif + + +void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_exp, +#ifdef ENABLE_HR_MODE + Word32 q_res_fx[], +#else + Word16 q_res_fx[], +#endif + Word16 q_old_d_fx[], Word16 spec_inv_idx, Word16 *fac, Word16 *fac_e, Word32 q_d_fx[], + Word16 *q_fx_exp, Word16 gg_idx, Word16 gg_idx_off, Word16 prev_gg, Word16 prev_gg_e, + Word16 *pc_nbLostFramesInRow) +{ + Counter i; + Word16 s, s2, s3, c, tmp16, tmp16_2, inv_gain, thr; + Word32 ener_curr, ener_prev, mean_nrg_high, mean_nrg_low; + Word16 global_gain, global_gain_e, gg2, gg2_e, prev_gg2, prev_gg2_e; + Word32 tmp32, ener_curr_gg2, ener_prev_gg2; + Word16 fac_local, fac_local_e; + +#ifdef DYNMEM_COUNT + struct _dynmem + { + Counter i; + Word16 s, s2, s3, c, tmp16, tmp16_2, inv_gain, thr; + Word32 ener_curr, ener_prev, mean_nrg_high, mean_nrg_low; + Word16 global_gain, global_gain_e, gg2, gg2_e, prev_gg2, prev_gg2_e; + Word32 tmp32, ener_curr_gg2, ener_prev_gg2; + Word16 fac_local, fac_local_e; + }; + Dyn_Mem_In("processPCapply_fx", sizeof(struct _dynmem)); +#endif + + assert(spec_inv_idx >= 0); + + *pc_nbLostFramesInRow = add(*pc_nbLostFramesInRow, 1); + + tmp32 = L_shl_pos(L_mult0(add(gg_idx, gg_idx_off), 0x797D), 7); + global_gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); + global_gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, 0xFE000000))); + + /** Calculate rescaling factor **/ + + /* mean_nrg_low = mean(q_d_prev(1:spec_inv_idx-1).^2); + mean_nrg_high = mean(q_d_prev(spec_inv_idx:end).^2); */ + s = getScaleFactor16(q_old_d_fx, yLen); + + mean_nrg_low = 0; + move32(); + FOR (i = 0; i < spec_inv_idx; i++) + { + tmp16 = shl_sat(q_old_d_fx[i], sub(s, 4)); + mean_nrg_low = L_mac0(mean_nrg_low, tmp16, tmp16); /* exp = 2s - 8 */ + } + + mean_nrg_high = 0; + move32(); + FOR (i = spec_inv_idx; i < yLen; i++) + { + tmp16 = shl_sat(q_old_d_fx[i], sub(s, 4)); + mean_nrg_high = L_mac0(mean_nrg_high, tmp16, tmp16); /* exp = 2s - 8 */ + } + + IF (sub(spec_inv_idx, sub(yLen, spec_inv_idx)) < 0) + { + c = div_s(spec_inv_idx, sub(yLen, spec_inv_idx)); + mean_nrg_high = Mpy_32_16_lc3plus(mean_nrg_high, c); /* exp = 2s - 8 */ + } + ELSE + { + c = div_s(sub(yLen, spec_inv_idx), spec_inv_idx); + mean_nrg_low = Mpy_32_16_lc3plus(mean_nrg_low, c); /* exp = 2s - 8 */ + } + + /* ener_prev = sum(q_old_res(1:spec_inv_idx-1).^2); + ener_curr = sum( q_res(1:spec_inv_idx-1).^2); */ + s = getScaleFactor16(q_old_res_fx, spec_inv_idx); + ener_prev = 0; move32(); + FOR (i = 0; i < spec_inv_idx; i++) + { + tmp16 = shl_sat(q_old_res_fx[i], sub(s, 4)); + ener_prev = L_mac0(ener_prev, tmp16, tmp16); /* exp = - (2s - 8 - 2**q_old_res_fx_exp) */ + } + + ener_curr = 0; + move32(); + +#ifdef ENABLE_HR_MODE + s2 = getScaleFactor32_lc3plus(q_res_fx, spec_inv_idx); + FOR (i = 0; i < spec_inv_idx; i++) + { + tmp16 = extract_h(L_shl_sat(q_res_fx[i], sub(s2, 4))); + ener_curr = L_mac0(ener_curr, tmp16, tmp16); /* exp = - (2s2 - 8) */ + } + s2 = s2 - 16; +#else + s2 = getScaleFactor16(q_res_fx, spec_inv_idx); + FOR (i = 0; i < spec_inv_idx; i++) + { + tmp16 = shl_sat(q_res_fx[i], sub(s2, 4)); + ener_curr = L_mac0(ener_curr, tmp16, tmp16); /* exp = - (2s2 - 8) */ + } +#endif + + + s = shl(sub(s, *q_old_res_fx_exp), 1); + s2 = shl(s2, 1); + s3 = s_max(s, s2); + ener_prev = L_shr_sat(ener_prev, sub(s3, s2)); + ener_curr = L_shr_sat(ener_curr, sub(s3, s)); + + /* fac = 1; */ + *fac = 1; + /* if ener_prev > 0 */ + IF ( ener_prev > 0 ) + { + /* fac = sqrt(ener_curr/ener_prev); */ + s = getScaleFactor32_lc3plus(&ener_prev, 1); + s2 = getScaleFactor32_lc3plus(&ener_curr, 1); + s3 = s_min(s, s2); + tmp16 = extract_h(L_shl_sat(ener_curr, s3)); + tmp16_2 = extract_h(L_shl_sat(ener_prev, s3)); + + *fac_e = 0; move16(); + if ( tmp16_2 == 0) { + tmp16_2 = 32767; move16(); + *fac_e = 15; move16(); + } else { + tmp16_2 = Inv16_lc3plus(tmp16_2, fac_e); + } + + *fac = mult(tmp16, tmp16_2); + + IF (sub(*fac, 32767) < 0) + { + *fac = Sqrt16_lc3plus(*fac, fac_e); move16(); + } + } + + /* fac_local = fac; */ + fac_local = *fac; + fac_local_e = *fac_e; + + /* if (mean_nrg_low > mean_nrg_high) && (ener_prev * prev_gg^2 > ener_curr * gg^2) */ + prev_gg2 = mult(prev_gg, prev_gg); + prev_gg2_e = shl(prev_gg_e, 1); + ener_prev_gg2 = Mpy_32_16_lc3plus(ener_prev, prev_gg2); /* exp = prev_gg2_e */ + + gg2 = mult(global_gain, global_gain); + gg2_e = shl(global_gain_e, 1); + ener_curr_gg2 = Mpy_32_16_lc3plus(ener_curr, gg2); /* exp = gg2_e */ + + s3 = s_max(prev_gg2_e, gg2_e); + ener_prev_gg2 = L_shr_sat(ener_prev_gg2, sub(s3, prev_gg2_e)); + ener_curr_gg2 = L_shr_sat(ener_curr_gg2, sub(s3, gg2_e)); + + + test(); + IF ( (L_sub(mean_nrg_low, mean_nrg_high) <= 0) || (L_sub(ener_prev_gg2, ener_curr_gg2) <= 0) ) + { + /* fac = prev_gg/gg; */ + s = global_gain_e; move16(); + inv_gain = Inv16_lc3plus(global_gain, &s); + fac_local = mult(prev_gg, inv_gain); + fac_local_e = add(s, prev_gg_e); + } + + /* write synthesized samples */ + *q_old_res_fx_exp = add(*q_old_res_fx_exp, fac_local_e); + thr = shl_sat(20480, sub(-15, *q_old_res_fx_exp)); + FOR (i = spec_inv_idx; i < yLen; i++) + { + q_res_fx[i] = extract_h(L_mult(q_old_res_fx[i] /* exp = q_old_res_fx_exp' */, fac_local /* exp = fac_e */)); /* exp = q_old_res_fx_exp */ + + IF (sub(abs_s(q_res_fx[i]), thr) < 0) + { + q_res_fx[i] = 0; + move16(); + } + } + +#ifdef ENABLE_HR_MODE + s = getScaleFactor32_withNegativeScaling(&q_res_fx[0], spec_inv_idx) - 16; /* exp = 0 */ + s2 = getScaleFactor32_withNegativeScaling(&q_res_fx[spec_inv_idx], + sub(yLen, spec_inv_idx)) - 16; /* exp = q_old_res_fx_exp */ +#else + s = getScaleFactor16_withNegativeScaling(&q_res_fx[0], spec_inv_idx); /* exp = 0 */ + s2 = getScaleFactor16_withNegativeScaling(&q_res_fx[spec_inv_idx], + sub(yLen, spec_inv_idx)); /* exp = q_old_res_fx_exp */ +#endif + + s3 = add(s, *q_old_res_fx_exp); + IF (sub(s3, s2) > 0) + { + tmp16 = sub(s3, s2); + s = sub(s, tmp16); + s3 = sub(s3, tmp16); + } + *q_fx_exp = sub(15, s); + move16(); + +#ifdef ENABLE_HR_MODE + s = add(s, 16); + s3 = add(s3, 16); +#endif + + s = s_max(s, -31); + s = s_min(s, 31); + s3 = s_max(s3, -31); + s3 = s_min(s3, 31); + + FOR (i = 0; i < spec_inv_idx; i++) + { +#ifdef ENABLE_HR_MODE + q_d_fx[i] = L_shl(q_res_fx[i], s); +#else + q_d_fx[i] = L_shl(L_deposit_h(q_res_fx[i]), s); +#endif + move32(); + } + FOR (; i < yLen; i++) + { +#ifdef ENABLE_HR_MODE + q_d_fx[i] = L_shl(q_res_fx[i], s3); +#else + q_d_fx[i] = L_shl(L_deposit_h(q_res_fx[i]), s3); +#endif + move32(); + } + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +#ifndef ENABLE_HR_MODE +static Word16 getScaleFactor16_withNegativeScaling(Word16 *data16, Word16 dataLen) +{ + Counter i; + Dyn_Mem_Deluxe_In(Word16 tmp, shift; Word16 x_min, x_max;); + + x_max = 0; + move16(); + x_min = 0; + move16(); + + FOR (i = 0; i < dataLen; i++) + { + if (data16[i] > 0) + x_max = s_max(x_max, data16[i]); + if (data16[i] < 0) + x_min = s_min(x_min, data16[i]); + } + + tmp = s_max(x_max, negate(x_min)); + shift = norm_s(tmp); + if (tmp == 0) + { + shift = 15; + move16(); + } + + Dyn_Mem_Deluxe_Out(); + + return shift; +} + +#else +static Word16 getScaleFactor32_withNegativeScaling(Word32 *data32, Word16 dataLen) +{ + Counter i; + Dyn_Mem_Deluxe_In(Word32 tmp, shift; Word32 x_min, x_max;); + + x_max = L_add(0, 0); + x_min = L_add(0, 0); + + FOR (i = 0; i < dataLen; i++) + { + if (data32[i] >= 0) + x_max = L_max(x_max, data32[i]); + if (data32[i] < 0) + x_min = L_min(x_min, data32[i]); + } + + tmp = L_max(x_max, L_negate(x_min)); + shift = norm_l(tmp); + if (tmp == 0) + { + shift = 31; + move16(); + } + + Dyn_Mem_Deluxe_Out(); + + return shift; +} +#endif diff --git a/lib_lc3plus/pc_classify_fx.c b/lib_lc3plus/pc_classify_fx.c new file mode 100644 index 000000000..28898f963 --- /dev/null +++ b/lib_lc3plus/pc_classify_fx.c @@ -0,0 +1,260 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "constants.h" +#include "functions.h" + +#define BLOCK_SIZE 3 +#define THR1 8 +#define FAC 9830 /* 0.3 */ + +void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover); + +void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d_fx[], Word16 q_old_res_fx[], + Word16 yLen, Word16 spec_inv_idx, Word16 stab_fac, Word16 *bfi) +{ + Dyn_Mem_Deluxe_In( + Word16 maxPitchBin, xover; + Counter i; + Word16 s, tmp16, full_nrg16, part_nrg16; + Word32 full_nrg, part_nrg; + ); + + /* Apply classifier only if lower than 2kHz signal */ + IF (sub(DEPR_i_mult(spec_inv_idx, 10), shl_pos(frame_dms, 2)) < 0 ) + { + IF (sub(stab_fac, 16384 /* 0.5 */) < 0) + { + *bfi = 1; + } + ELSE IF (sub(pitch_present, 1) == 0) + { + maxPitchBin = 8; move16(); + IF (sub(frame_dms, 50) == 0) + { + maxPitchBin = 4; move16(); + } + + /* avoid phase discontinuity in low frequencies */ + peakDetector_fx(q_old_d_fx, yLen, &xover); + test(); + IF (sub(spec_inv_idx, xover) < 0 || sub(spec_inv_idx, maxPitchBin) < 0) + { + *bfi = 1; + } + } + ELSE + { + s = getScaleFactor16(q_old_res_fx, yLen); + + part_nrg = 0; move32(); + FOR (i = 0; i < spec_inv_idx; i++) + { + tmp16 = shl_sat(q_old_res_fx[i], sub(s, 4)); + part_nrg = L_mac0(part_nrg, tmp16, tmp16); /* exp = 2s - 8 */ + } + + full_nrg = part_nrg; move32(); + FOR (i = spec_inv_idx; i < yLen; i++) + { + tmp16 = shl_sat(q_old_res_fx[i], sub(s, 4)); + full_nrg = L_mac0(full_nrg, tmp16, tmp16); /* exp = 2s - 8 */ + } + + s = getScaleFactor32_lc3plus(&full_nrg, 1); + full_nrg16 = extract_h(L_shl(full_nrg, s)); + part_nrg16 = extract_h(L_shl(part_nrg, s)); + + tmp16 = mult(full_nrg16, 9830 /* 0.3 */); + + IF (part_nrg16 < tmp16) + { + *bfi = 1; + } + } + } + + Dyn_Mem_Deluxe_Out(); +} + +void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) +{ + Dyn_Mem_Deluxe_In( + Counter i, j; + Word16 tmp16, c, s, s2, mean_block_nrg16; + Word32 maxPeak, tmp32; + Word32 mean_block_nrg, block_cent; + Word16 cur_max, prev_max, next_max; + ); + + *xover = 0; + + s = getScaleFactor16(in_sig, yLen); + + mean_block_nrg = 0; move32(); + FOR (i = 0; i < yLen; i++) + { + tmp16 = shl_sat(in_sig[i], sub(s, 4)); + mean_block_nrg = L_mac0(mean_block_nrg, tmp16, tmp16); /* exp = 2s - 8 */ + } + + s2 = getScaleFactor16(&yLen, 1); + c = shl(yLen, s2); + mean_block_nrg16 = div_l(mean_block_nrg, c); /* exp = 2s - 8 - s2 - 1 */ + mean_block_nrg = L_shl(L_mult0(mean_block_nrg16, BLOCK_SIZE * THR1), add(4, s2)); /* exp = 2s - 5 */ + + maxPeak = 0; move32(); + c = sub(yLen, 2 * BLOCK_SIZE); + + test(); + IF (abs_s(in_sig[0]) >= abs_s(in_sig[1])) + { + block_cent = 0; move32(); + FOR (j = 0; j <= 1; j++) + { + tmp16 = shl_sat(in_sig[j], sub(s, 2)); + block_cent = L_mac0(block_cent, tmp16, tmp16); /* -> exp = 2s - 4 */ + } + block_cent = L_shr(block_cent, 1); /* exp = 2s - 5 */ + + IF (L_sub(block_cent, mean_block_nrg) > 0) + { + cur_max = abs_s(in_sig[0]); + cur_max = MAX(abs_s(in_sig[1]), cur_max); + + next_max = abs_s(in_sig[-1 + BLOCK_SIZE]); + next_max = MAX(abs_s(in_sig[-1 + BLOCK_SIZE + 1]), next_max); + next_max = MAX(abs_s(in_sig[-1 + BLOCK_SIZE + 2]), next_max); + + IF (sub(cur_max, next_max) > 0) + { + maxPeak = block_cent; move32(); + *xover = 1; + } + } + } + + FOR (i = 0; i < BLOCK_SIZE; i++) + { + test(); + IF (abs_s(in_sig[i + 1]) >= abs_s(in_sig[i]) && abs_s(in_sig[i + 1]) >= abs_s(in_sig[i + 2])) + { + block_cent = 0; move32(); + FOR (j = 0; j < BLOCK_SIZE; j++) + { + tmp16 = shl_sat(in_sig[i + j], sub(s, 2)); + block_cent = L_mac0(block_cent, tmp16, tmp16); /* -> exp = 2s - 4 */ + } + block_cent = L_shr(block_cent, 1); /* exp = 2s - 5 */ + + IF (L_sub(block_cent, mean_block_nrg) > 0) + { + cur_max = abs_s(in_sig[i]); + cur_max = MAX(abs_s(in_sig[i + 1]), cur_max); + cur_max = MAX(abs_s(in_sig[i + 2]), cur_max); + + prev_max = 0; move16(); + FOR (j = i - BLOCK_SIZE; j <= i - 1; j++) + { + IF (j > 0) + { + prev_max = MAX(abs_s(in_sig[j]), prev_max); + } + } + + next_max = abs_s(in_sig[i + BLOCK_SIZE]); + next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 1]), next_max); + next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 2]), next_max); + + test(); + IF (sub(cur_max, prev_max) >= 0 && sub(cur_max, next_max) > 0) + { + IF (L_sub(block_cent, maxPeak) >= 0) + { + maxPeak = block_cent; move32(); + *xover = sub(add(i, BLOCK_SIZE), 1); + } + ELSE + { + tmp32 = L_mult(FAC, extract_h(maxPeak)); + + tmp16 = extract_l(L_shr(maxPeak, 1)); + tmp16 = s_and(tmp16, 0x7fff); + tmp16 = mult(FAC, tmp16); + tmp32 = L_add_sat(tmp32, tmp16); + + IF (L_sub(block_cent, tmp32) > 0) + { + *xover = sub(add(i, BLOCK_SIZE), 1); + } + } + } + } + } + } + + FOR (i = BLOCK_SIZE; i <= c; i++) + { + test(); + IF (abs_s(in_sig[i + 1]) >= abs_s(in_sig[i]) && abs_s(in_sig[i + 1]) >= abs_s(in_sig[i + 2])) + { + block_cent = 0; move32(); + FOR (j = 0; j < BLOCK_SIZE; j++) + { + tmp16 = shl_sat(in_sig[i + j], sub(s, 2)); + block_cent = L_mac0(block_cent, tmp16, tmp16); /* -> exp = 2s - 4 */ + } + block_cent = L_shr(block_cent, 1); /* exp = 2s - 5 */ + + IF (L_sub(block_cent, mean_block_nrg) > 0) + { + cur_max = abs_s(in_sig[i]); + cur_max = MAX(abs_s(in_sig[i + 1]), cur_max); + cur_max = MAX(abs_s(in_sig[i + 2]), cur_max); + + prev_max = abs_s(in_sig[i - BLOCK_SIZE]); + prev_max = MAX(abs_s(in_sig[i - BLOCK_SIZE + 1]), prev_max); + prev_max = MAX(abs_s(in_sig[i - BLOCK_SIZE + 2]), prev_max); + + next_max = abs_s(in_sig[i + BLOCK_SIZE]); + next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 1]), next_max); + next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 2]), next_max); + + test(); + IF (sub(cur_max, prev_max) >= 0 && sub(cur_max, next_max) > 0) + { + IF (L_sub(block_cent, maxPeak) >= 0) + { + maxPeak = block_cent; move32(); + *xover = sub(add(i, BLOCK_SIZE), 1); + } + ELSE + { + tmp32 = L_mult(FAC, extract_h(maxPeak)); + + tmp16 = extract_l(L_shr(maxPeak, 1)); + tmp16 = s_and(tmp16, 0x7fff); + tmp16 = mult(FAC, tmp16); + tmp32 = L_add_sat(tmp32, tmp16); + + IF (L_sub(block_cent, tmp32) > 0) + { + *xover = sub(add(i, BLOCK_SIZE), 1); + } + } + } + } + } + } + + Dyn_Mem_Deluxe_Out(); +} + + diff --git a/lib_lc3plus/pc_main_fx.c b/lib_lc3plus/pc_main_fx.c new file mode 100644 index 000000000..708f79d74 --- /dev/null +++ b/lib_lc3plus/pc_main_fx.c @@ -0,0 +1,57 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "constants.h" +#include "functions.h" + +void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, Word16 frame_dms, Word16 q_old_res_fx[], + Word16 *q_old_res_fx_exp, +#ifdef ENABLE_HR_MODE + Word32 q_res_fx[], +#else + Word16 q_res_fx[], +#endif + Word16 q_old_d_fx[], Word16 spec_inv_idx, + Word16 pitch_present, Word16 stab_fac, Word32 q_d_fx[], Word16 *q_fx_exp, + Word16 gg_idx, Word16 gg_idx_off, Word16 *prev_gg, Word16 *prev_gg_e, Word16 *BW_cutoff_idx_nf, + Word16 *prev_BW_cutoff_idx_nf, Word16 fac_ns_idx, Word16 *prev_fac_ns_fx, Word16 *pc_nbLostFramesInRow) +{ + Dyn_Mem_Deluxe_In( + Word16 fac, fac_e; + ); + + fac = 32767; fac_e = 0; + + IF (sub(*bfi, 2) == 0) + { + processPCclassify_fx(pitch_present, frame_dms, q_old_d_fx, q_old_res_fx, yLen, spec_inv_idx, stab_fac, bfi); + } + + IF (sub(*bfi, 2) == 0) + { + processPCapply_fx(yLen, q_old_res_fx, q_old_res_fx_exp, q_res_fx, q_old_d_fx, spec_inv_idx, + &fac, &fac_e, q_d_fx, q_fx_exp, gg_idx, gg_idx_off, *prev_gg, *prev_gg_e, pc_nbLostFramesInRow); + } + + IF (sub(*bfi, 1) != 0) + { + processPCupdate_fx(*bfi, yLen, q_old_res_fx, q_old_res_fx_exp, q_res_fx, spec_inv_idx, gg_idx, gg_idx_off, prev_gg, + prev_gg_e, rframe, BW_cutoff_idx_nf, prev_BW_cutoff_idx_nf, fac_ns_idx, prev_fac_ns_fx, fac, fac_e); + } + + if (*bfi == 0) + { + *pc_nbLostFramesInRow = 0; move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + + diff --git a/lib_lc3plus/pc_update_fx.c b/lib_lc3plus/pc_update_fx.c new file mode 100644 index 000000000..17b719bcd --- /dev/null +++ b/lib_lc3plus/pc_update_fx.c @@ -0,0 +1,148 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "constants.h" +#include "functions.h" + +#ifdef ENABLE_HR_MODE + +void Copy_Scale_sig_32(const Word32 x[], /* i : signal to scale input Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +) +{ + Counter i; + Word16 tmp; + + if (exp0 == 0) + { + for (i = 0; i < lg; i++) + { + y[i] = extract_h(x[i]); + } + + return; + } + + tmp = s_max(exp0, -31); + tmp = s_min(tmp, 31); + + for (i = 0; i < lg; i++) + { + y[i] = extract_h(L_shr_r(x[i], -tmp)); + } +} +#endif + +void processPCupdate_fx(Word16 bfi, Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_exp, +#ifdef ENABLE_HR_MODE + Word32 q_res_fx[], +#else + Word16 q_res_fx[], +#endif + Word16 spec_inv_idx, Word16 gg_idx, Word16 gg_idx_off, + Word16 *prev_gg, Word16 *prev_gg_e, Word16 rframe, Word16 *BW_cutoff_idx_nf, + Word16 *prev_BW_cutoff_idx_nf, Word16 fac_ns_idx, Word16 *prev_fac_ns_fx, Word16 fac, + Word16 fac_e) +{ + Word16 global_gain, global_gain_e, s, s2, s3, tmp16; + Word32 tmp32; + +#ifdef DYNMEM_COUNT + struct _dynmem + { + Word16 global_gain, global_gain_e, s, s2, s3, tmp16; + Word32 tmp32; + }; + Dyn_Mem_In("processPCupdate_fx", sizeof(struct _dynmem)); +#endif + + tmp32 = L_shl_pos(L_mult0(add(gg_idx, gg_idx_off), 0x797D), 7); + global_gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); + global_gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, 0xFE000000))); + + *prev_gg = global_gain; move16(); + *prev_gg_e = global_gain_e; move16(); + +#ifdef ENABLE_HR_MODE + s = getScaleFactor32_lc3plus(q_res_fx, spec_inv_idx); /* exp = 0 */ +#else + s = getScaleFactor16(q_res_fx, spec_inv_idx); /* exp = 0 */ +#endif + + IF (bfi == 0) + { + *q_old_res_fx_exp = negate(s); +#ifdef ENABLE_HR_MODE + Copy_Scale_sig_32(q_res_fx, q_old_res_fx, yLen, s); + *q_old_res_fx_exp = *q_old_res_fx_exp + 16; +#else + Copy_Scale_sig(q_res_fx, q_old_res_fx, yLen, s); +#endif + } + ELSE + { +#ifdef ENABLE_HR_MODE + s2 = getScaleFactor32_lc3plus(&q_res_fx[spec_inv_idx], sub(yLen, spec_inv_idx)); /* exp = q_old_res_fx_exp */ + IF (s2 == 0) + s2 = 16; + s3 = add(s, *q_old_res_fx_exp); + IF (sub(s3, s2) > 0) + { + tmp16 = sub(s3, s2); + s = sub(s, tmp16); + } + s2 = add(s, *q_old_res_fx_exp); + *q_old_res_fx_exp = negate(s) + 16; + + + if (s2 > -32) + { + Copy_Scale_sig_32(&q_res_fx[spec_inv_idx], &q_old_res_fx[spec_inv_idx], sub(yLen, spec_inv_idx), s2); + } +#else + s2 = getScaleFactor16(&q_res_fx[spec_inv_idx], sub(yLen, spec_inv_idx)); /* exp = q_old_res_fx_exp */ + s3 = add(s, *q_old_res_fx_exp); + IF (sub(s3, s2) > 0) + { + tmp16 = sub(s3, s2); + s = sub(s, tmp16); + } + s2 = add(s, *q_old_res_fx_exp); + *q_old_res_fx_exp = negate(s); + + s = s_max(s_min(s, 15), -15); + s2 = s_max(s_min(s2, 15), -15); + Copy_Scale_sig(q_res_fx, q_old_res_fx, spec_inv_idx, s); + Copy_Scale_sig(&q_res_fx[spec_inv_idx], &q_old_res_fx[spec_inv_idx], sub(yLen, spec_inv_idx), s2); +#endif + } + + IF (rframe == 0) + { + *prev_BW_cutoff_idx_nf = *BW_cutoff_idx_nf; + *prev_fac_ns_fx = shl_pos(sub(8, fac_ns_idx), 11); + } + ELSE IF(sub(bfi, 2) == 0 && sub(*BW_cutoff_idx_nf, *prev_BW_cutoff_idx_nf) != 0 + && sub(spec_inv_idx, yLen) < 0) + { + *BW_cutoff_idx_nf = *prev_BW_cutoff_idx_nf; + *prev_fac_ns_fx = shl_sat(mult(*prev_fac_ns_fx, fac), fac_e); + *prev_fac_ns_fx = s_max(*prev_fac_ns_fx, 2048); + *prev_fac_ns_fx = s_min(*prev_fac_ns_fx, 16384); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/per_band_energy_fx.c b/lib_lc3plus/per_band_energy_fx.c new file mode 100644 index 000000000..14e853212 --- /dev/null +++ b/lib_lc3plus/per_band_energy_fx.c @@ -0,0 +1,275 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include "rom_basop_util.h" + +void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Word16 d_fx_exp, + const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, Word16 frame_dms, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +) +{ + Dyn_Mem_Deluxe_In(Counter i, k, band; Word16 s; Word16 s1; Word16 s2; Word32 nrg; Word16 smax; Word16 tmp16; + Word16 nbands; Word16 maxBwBin; Word16 stopBand; Word16 bandsOffsetOne; Word16 bandsOffsetTwo; + Word16 * d2_band_fx_exp;); + + + d2_band_fx_exp = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_BANDS_NUMBER_PLC bytes */ + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + maxBwBin = MAX_BW_HR; + fs_idx = fs_idx + 1; + move16(); + } + else +#endif + { + maxBwBin = MAX_BW; + move16(); + } + + SWITCH (frame_dms) + { + case 25: maxBwBin = maxBwBin >> 2; move16(); + { + bandsOffsetOne = bands_offset_with_one_max_2_5ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_2_5ms[fs_idx]; + move16(); + } + BREAK; + case 50: maxBwBin = maxBwBin >> 1; move16(); + { + bandsOffsetOne = bands_offset_with_one_max_5ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_5ms[fs_idx]; + move16(); + } + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + maxBwBin = (maxBwBin >> 2) * 3; move16(); + bandsOffsetOne = bands_offset_with_one_max_7_5ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_7_5ms[fs_idx]; + move16(); + BREAK; +#endif + default: /* 100 */ + { + bandsOffsetOne = bands_offset_with_one_max[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max[fs_idx]; + move16(); + } + BREAK; + } + + IF (sub(linear, 1) == 0) + { + + #ifdef ENABLE_HR_MODE + if (hrmode) + { + fs_idx = fs_idx - 1; + } + #endif + + SWITCH (frame_dms) + { + case 25: + bandsOffsetOne = bands_offset_with_one_max_lin_2_5ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_lin_2_5ms[fs_idx]; + move16(); + BREAK; + case 50: + bandsOffsetOne = bands_offset_with_one_max_lin_5ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_lin_5ms[fs_idx]; + move16(); + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + bandsOffsetOne = bands_offset_with_one_max_lin_7_5ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_lin_7_5ms[fs_idx]; + move16(); + BREAK; +#endif + case 100: + bandsOffsetOne = bands_offset_with_one_max_lin[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_lin[fs_idx]; + move16(); + BREAK; + } + } + + /* start processing with band offsets == 1 */ + FOR (band = 0; band < bandsOffsetOne; band++) + { + ASSERT((band_offsets[band + 1] - band_offsets[band]) == 1); + ASSERT(band < maxBwBin); + + s2 = 15; + move16(); + s = norm_l(d_fx[band]); + if (d_fx[band] != 0) + s2 = s_min(s2, s); + + tmp16 = extract_h(L_shl_pos(d_fx[band], s2)); + + d2_fx[band] = L_mult0(tmp16, tmp16); + move32(); + d2_band_fx_exp[band] = sub(1, shl_pos(s2, 1)); + move16(); + } + + /* start processing with band offsets == 2 */ + i = bandsOffsetOne; + move16(); + FOR (; band < bandsOffsetTwo; band++) + { + ASSERT((band_offsets[band + 1] - band_offsets[band]) == 2); + IF (sub(add(i, 1), maxBwBin) >= 0) + { + IF (sub(i, maxBwBin) >= 0) + { + d2_fx[band] = 0; + move32(); + d2_band_fx_exp[band] = sub(1, shl_pos(15, 1)); + move16(); + } + ELSE + { + s2 = 15; + move16(); + s = norm_l(d_fx[band]); + if (d_fx[band] != 0) + s2 = s_min(s2, s); + + tmp16 = extract_h(L_shl_pos(d_fx[band], s2)); + + d2_fx[band] = L_mult0(tmp16, tmp16); + move32(); + d2_band_fx_exp[band] = sub(1, shl_pos(s2, 1)); + move16(); + } + } + ELSE + { + ASSERT(i + 1 < maxBwBin); + + s2 = 15; + move16(); + s = norm_l(d_fx[i]); + if (d_fx[i] != 0) + s2 = s_min(s2, s); + s = norm_l(d_fx[i + 1]); + if (d_fx[i + 1] != 0) + s2 = s_min(s2, s); + + tmp16 = extract_h(L_shl_pos(d_fx[i], s2)); + nrg = L_mult0(tmp16, tmp16); + nrg = L_min(nrg, 0x3FFFFFFF); + tmp16 = extract_h(L_shl_pos(d_fx[i + 1], s2)); + + d2_fx[band] = L_shr_pos(L_mac0(nrg, tmp16, tmp16), 1); + move32(); + d2_band_fx_exp[band] = sub(1, shl_pos(s2, 1)); + move16(); + } + i = add(i, 2); + } + + /* proceed with band offsets > 2 */ + FOR (; band < n_bands; band++) + { + /* normalization */ + k = i; + move16(); + s1 = 15; + move16(); + + stopBand = s_min(band_offsets[band + 1], maxBwBin); + FOR (; k < stopBand; k++) + { + s = norm_l(d_fx[k]); + if (d_fx[k] != 0) + s1 = s_min(s1, s); + } + + nbands = sub(band_offsets[band + 1], band_offsets[band]); +#ifdef ENABLE_HR_MODE + if (nbands < 32) + { + nbands = s_min(s_max(0, nbands), 31); + /* specify headroom, it can be reduced by one due to use of L_mac0 */ + s2 = sub(s1, bands_nrg_scale[nbands]); + } + else + { + /* Active only in the 96 kHz case */ + s2 = sub(s1, 5); + } +#else + ASSERT(nbands < 32); + nbands = s_min(s_max(0, nbands), 31); + /* specify headroom, it can be reduced by one due to use of L_mac0 */ + s2 = sub(s1, bands_nrg_scale[nbands]); +#endif + + /* calculate energy per band */ + nrg = 0; + move32(); + + FOR (; i < stopBand; i++) + { + tmp16 = extract_h(L_shl(d_fx[i], s2)); + nrg = L_mac0(nrg, tmp16, tmp16); + } + i = band_offsets[band + 1]; + + /* calculate mean value of energy */ + nrg = Mpy_32_16_lc3plus(nrg, InvIntTable[nbands]); + + /* store normalized energy */ + s = norm_l(nrg); + d2_fx[band] = L_shl_pos(nrg, s); + move32(); + d2_band_fx_exp[band] = sub(1, add(shl_pos(s2, 1), s)); + move16(); + } + + /* Determine maximum exponent and rescale band energies */ + smax = -31; + move16(); + FOR (band = 0; band < n_bands; band++) + { + smax = s_max(smax, d2_band_fx_exp[band]); + } + FOR (band = 0; band < n_bands; band++) + { + d2_fx[band] = L_shr_pos(d2_fx[band], s_min(sub(smax, d2_band_fx_exp[band]), 31)); + move32(); + } + + /* Save exponent for all bands */ + *d2_fx_exp = s_max(add(shl_pos(d_fx_exp, 1), smax), -32); + move16(); + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/plc_apply_fx.c b/lib_lc3plus/plc_apply_fx.c new file mode 100644 index 000000000..9430d155e --- /dev/null +++ b/lib_lc3plus/plc_apply_fx.c @@ -0,0 +1,419 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "constants.h" +#include "functions.h" + +void processPLCapply_fx( +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 *concealMethod, +#else + Word16 concealMethod, +#endif + Word16 nbLostFramesInRow, Word16 bfi, Word16 prev_bfi, + Word16 frame_length, Word16 la_zeroes, +#ifdef ENABLE_HR_MODE + const Word32 w[], +#else + const Word16 w[], +#endif + Word16 x_fx[], Word16 ola_mem[], + Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], + Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, Word16 *damping, Word16 old_pitch_int, + Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, Word16 frame_dms, AplcSetup *plcAd, + Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , Word32 rel_pitch_change +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + , Word16 *alpha_type_2_table +#endif + ) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word32 *d2_fx; + Word32 *q_old_d_fx32; + Word32 *r_fx; + Word32 *tdc_A_32; + Word16 d2_fx_exp; + Word16 r_fx_exp; + Word16 Q_syn; + Word8 * buffer_perBandEnergy, *buffer_preEmphasis, *buffer_InverseODFT, *buffer_Levinson, + *buffer_tdac, *buffer_phecu; + Word16 y_e; /*exponent of L_ecu_rec */ + Word16 tmp_is_trans[2]; /* may be changed to a single variable */ + Word16 env_stab; + + Word16 n_bands, prev_bfi_plc2; + const Word16 *band_offsets; + Word32 * L_ecu_rec; /* local xtda output is MAX_LEN -> input buffer, + as tmp buffer for w32 fft MAX_LPROT */ + ); +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 consecutiveLostThreshold = 0; +#endif + +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + Word16 thresh_tdc_cnt; + Word16 thresh_ns_cnt; + Word16 thresh_tdc_ns_cnt; +#endif + + band_offsets = NULL; + + d2_fx = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_BANDS_NUMBER_PLC */ + q_old_d_fx32 = (Word32 *)scratchAlign(d2_fx, sizeof(*d2_fx) * MAX_BANDS_NUMBER_PLC); /* Size = 4 * MAX_BW */ + r_fx = (Word32 *)scratchAlign(d2_fx, sizeof(*d2_fx) * MAX_BANDS_NUMBER_PLC); /* Size = 4 * (M + 1) */ + tdc_A_32 = (Word32 *)scratchAlign(r_fx, sizeof(*r_fx) * (M + 1)); /* Size = 4 * (M + 1) */ + + L_ecu_rec = (Word32 *)scratchAlign(tdc_A_32, sizeof(*tdc_A_32) * (M + 1)); /* Size = 4 * MAX_LPROT bytes */ + + buffer_perBandEnergy = + (Word8 *)scratchAlign(q_old_d_fx32, sizeof(*q_old_d_fx32) * (MAX_LEN)); /* Size = 2 * MAX_BANDS_NUMBER_PLC */ + buffer_preEmphasis = + (Word8 *)scratchAlign(tdc_A_32, sizeof(*tdc_A_32) * (M + 1)); /* Size = 2 * MAX_BANDS_NUMBER_PLC */ + buffer_InverseODFT = buffer_preEmphasis; /* Size = 640 bytes */ + buffer_Levinson = buffer_preEmphasis; /* Size = 4 * (M + 1) */ + + buffer_tdac = scratchBuffer; /* Size = 2 * MAX_LEN bytes */ + buffer_phecu = scratchBuffer; /* Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ + /* Buffers overlap since they are not used at once */ + + + UNUSED(ns_cum_alpha); + UNUSED(ns_seed); + + /* Apply/Prepare PLC in bfi-case */ + IF (sub(bfi, 1) == 0) + { + +#ifdef CR8_A_PLC_FADEOUT_TUNING + SWITCH(frame_dms) + { + case 25: + consecutiveLostThreshold = 16; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_025_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_025_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_025_DMS_TDC_NS_CNT; +#endif + break; + case 50: consecutiveLostThreshold = 8; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_050_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_050_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_050_DMS_TDC_NS_CNT; +#endif + break; + case 75: consecutiveLostThreshold = 6; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_075_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_075_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_075_DMS_TDC_NS_CNT; +#endif + break; + case 100: consecutiveLostThreshold = 4; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_100_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_100_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_100_DMS_TDC_NS_CNT; +#endif + break; + default: assert(0); + } + + IF (sub(fs_idx, 2) == 0 || sub(fs_idx, 4) >= 0) + { +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + if (sub(plcAd->longterm_counter_plcTdc, thresh_tdc_cnt) < 0){ + plcAd->plc_fadeout_type = 1; + } + else if (sub(plcAd->longterm_counter_plcNsAdv, thresh_ns_cnt) < 0){ + plcAd->plc_fadeout_type = 1; + } + else if (sub(plcAd->longterm_counter_plcTdc + plcAd->longterm_counter_plcNsAdv, thresh_tdc_ns_cnt) < 0){ + plcAd->plc_fadeout_type = 1; + } + else { + plcAd->plc_fadeout_type = 0; + } + +#else + IF (((sub(plcAd->longterm_counter_plcPhaseEcu, L_shr_pos(Mpy_32_16_lc3plus(FAC1_FADEOUT, plcAd->longterm_counter_plcTdc), SHIFT1_FADEOUT)) < 0) || + (sub(plcAd->longterm_counter_plcPhaseEcu, L_shr_pos(Mpy_32_16_lc3plus(FAC1_FADEOUT, plcAd->longterm_counter_plcNsAdv), SHIFT1_FADEOUT)) < 0)) && + (sub(plcAd->longterm_counter_plcTdc, L_shr_pos(Mpy_32_16_lc3plus(FAC2_FADEOUT, plcAd->longterm_counter_plcNsAdv), SHIFT2_FADEOUT)) < 0)) + { + plcAd->plc_fadeout_type = 0; + } + ELSE + { + IF ((sub(plcAd->longterm_counter_plcPhaseEcu, L_shr_pos(Mpy_32_16_lc3plus(FAC3_FADEOUT, plcAd->longterm_counter_plcTdc), SHIFT3_FADEOUT)) > 0) || + (sub(plcAd->longterm_counter_plcPhaseEcu, L_shr_pos(Mpy_32_16_lc3plus(FAC3_FADEOUT, plcAd->longterm_counter_plcNsAdv), SHIFT3_FADEOUT)) > 0)) + { + plcAd->plc_fadeout_type = 1; + } ELSE { + plcAd->plc_fadeout_type = 0; + } + } +#endif + + + env_stab = norm_s(plcAd->longterm_analysis_counter_max); + IF(sub(shl_pos(plcAd->overall_counter, env_stab), mult(shl_pos(plcAd->longterm_analysis_counter_max, env_stab), PLC_LONGTERM_ANALYSIS_STARTUP_FILL)) < 0) + { + plcAd->plc_fadeout_type = 0; + } + +#ifndef CR9_H_REMOVE_SWITCH_TO_PLC_NS + IF (sub(nbLostFramesInRow, consecutiveLostThreshold) >= 0 && sub(plcAd->plc_fadeout_type, 1) == 0) + { + IF (sub(*concealMethod, LC3_CON_TEC_TDPLC) == 0) + { + *concealMethod = LC3_CON_TEC_NS_ADV; + } + } +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + IF (L_sub(rel_pitch_change,REL_PITCH_THRESH) > 0 && sub(hrmode,1) == 0 && (sub(frame_dms,50) == 0 || sub(frame_dms,25) == 0)){ + plcAd->plc_fadeout_type = 2;move16(); + } ELSE +#endif + IF((sub(nbLostFramesInRow, consecutiveLostThreshold) < 0) && (*concealMethod != LC3_CON_TEC_PHASE_ECU)) + { + plcAd->plc_fadeout_type = 0; + } + } ELSE { + plcAd->plc_fadeout_type = 0; /*fs_idx == 0,1,3 */ + } +#endif /* CR8_A_PLC_FADEOUT_TUNING */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING + SWITCH (*concealMethod) +#else + SWITCH (concealMethod) +#endif + { + case LC3_CON_TEC_PHASE_ECU: + ASSERT(frame_dms == 100); + /* call phaseEcu */ + env_stab = 32767; move16(); /* 1.0=stable , 0.0=dynamic Q15*/ + tmp_is_trans[0] = plcAd->PhECU_short_flag_prev; move16(); + tmp_is_trans[1] = plcAd->PhECU_short_flag_prev; move16(); + + ASSERT(prev_bfi == 0 || prev_bfi == 1|| prev_bfi == 2); /*PC prev_bfi has three states */ + prev_bfi_plc2 = prev_bfi; move16(); + if (sub(prev_bfi_plc2, 2) == 0) + { + prev_bfi_plc2 = 0; move16(); + } + + ASSERT(prev_bfi_plc2 == 0 || prev_bfi_plc2 == 1); /*PhEcu does not accept prev_bfi == 2 */ + IF(prev_bfi_plc2 == 0) + { /* convert pitch lag info at current fs to a normalized fractional bin-frequency */ + plcAd->PhECU_f0hzLtpBinQ7 = plc_phEcuSetF0Hz_fx(fs_idx, old_pitch_int, old_pitch_fr); move16(); + + + + /* first bfi frame calc decoded pcm energy 16,16 ms, in 26 ms buffer separated by 10 ms*/ + + { /* compute energy normalization needed for concealment method 2 Xavg and transient analysis */ + + /* left */ + processPLCUpdateXFP_w_E_hist_fx(0, 0, + &(plcAd->x_old_tot_fx[ sub(plcAd->max_len_pcm_plc , add(num_FsByResQ0[fs_idx],rectLengthTab[fs_idx] )) ]), plcAd->q_fx_old_exp,0, + + fs_idx, + &plcAd->PhECU_L_oold_xfp_w_E_fx, &plcAd->PhECU_oold_xfp_w_E_exp_fx, + &plcAd->PhECU_L_old_xfp_w_E_fx, &plcAd->PhECU_old_xfp_w_E_exp_fx, + &plcAd->PhECU_oold_Ltot_exp_fx, &plcAd->PhECU_old_Ltot_exp_fx); + + /* right */ + processPLCUpdateXFP_w_E_hist_fx(0, 0, plcAd->PhECU_xfp_fx, plcAd->PhECU_xfp_exp_fx, + plcAd->PhECU_margin_xfp, fs_idx, + &plcAd->PhECU_L_oold_xfp_w_E_fx, &plcAd->PhECU_oold_xfp_w_E_exp_fx, + &plcAd->PhECU_L_old_xfp_w_E_fx, &plcAd->PhECU_old_xfp_w_E_exp_fx, + &plcAd->PhECU_oold_Ltot_exp_fx, &plcAd->PhECU_old_Ltot_exp_fx); + } + } + + hq_phase_ecu_fx( + plcAd->PhECU_xfp_fx, /* i : only valid first Bfi frame , buffer of previous synt signal length */ + L_ecu_rec, /* o : reconstructed frame in folded tda domain xtda Word32 Q x */ + &plcAd->PhECU_time_offs, /* i/o: Sample offset for consecutive frame losses*/ + plcAd->PhECU_X_sav_fx, /* i(prev_bfi==1)/o(prev_bfi==0): Stored Complex spectrum of prototype frame */ + &plcAd->PhECU_X_savQ_fx, /* i/o: Q value of stored spectrum */ + &plcAd->PhECU_num_plocs, /* i/o: Number of identified peaks */ + plcAd->PhECU_plocs, /* i/o: Peak locations Q0 */ + plcAd->PhECU_f0est, /* i/o: Interpolated peak locations Q16 */ + env_stab, /* i : Envelope stability parameter */ + plcAd->PhECU_f0hzLtpBinQ7, /* i: LTP bin frequency in normalized Hz Q7 */ + plcAd->norm_corrQ15_fx, /* i : correlation for lag at f0hzLtpBinQ7 */ + prev_bfi_plc2, /* i : indicating burst frame error */ + tmp_is_trans, /* i : flags indicating previous transient frames */ + plcAd->PhECU_mag_chg_1st, /* i/o: per band magnitude modifier for transients*/ + NULL, /* o: dbg per band magnitude modifier, incl. burst attenuation */ + plcAd->PhECU_Xavg, /* i/o: Frequency group average gain to fade to */ + &plcAd->PhECU_beta_mute, /* o : Factor for long-term mute */ + fs_idx, /* i : Encoded bandwidth "nb(0),WB,sWB,WB,FB" */ + frame_length, /* i : frame length */ + NULL , /* o : seed synch dbg */ + NULL , /* o : evolved Spectrum dbg */ + plcAd->PhECU_t_adv, /* i : time adjustment excluding time_offs */ + PhECU_wins[fs_idx][2], /* i: 2 ms initial part pre_tda = mdct-ana */ + PhECU_wins[fs_idx][1], /* i: 16 ms pretda combined part IWHR+MDCT-ana */ + PhECU_wins[fs_idx][0], + plcAd->PhECU_xfp_exp_fx, + plcAd->max_lprot, + plcAd->max_plocs, + plcAd->PhECU_L_oold_xfp_w_E_fx,plcAd->PhECU_oold_xfp_w_E_exp_fx, plcAd->PhECU_oold_Ltot_exp_fx, + plcAd->PhECU_oold_grp_shape_fx, + plcAd->PhECU_L_old_xfp_w_E_fx,plcAd->PhECU_old_xfp_w_E_exp_fx, plcAd->PhECU_old_Ltot_exp_fx, + plcAd->PhECU_old_grp_shape_fx, + plcAd->PhECU_margin_xfp, +#ifdef CR8_A_PLC_FADEOUT_TUNING + plcAd->plc_fadeout_type , /* i : fadeout scheme */ + &(plcAd->PhECU_nonpure_tone_flag), /* i/o : non-pure single tone indicator state */ +#endif + buffer_phecu); + + y_e = 18; move16(); /* the fixed exponent (exp) from Lecu_rec from PhaseECU is 18 */ + + Processing_ITDA_WIN_OLA( + L_ecu_rec, /* i: X_TDA buffer data = "y" DCT-IV output */ + &y_e, /* i/o: x_tda exponent "y_e" */ + w, /* i: window coefficients including normalization of sqrt(2/N) and scaled by 2^4 */ + ola_mem, /* i/o: overlap add memory */ + ola_mem_exp, /* i/o: overlap add exponent */ + x_fx, /* o: time signal out */ + LowDelayShapes_n960_len[fs_idx], /* i: window length */ + frame_length, /* i: block size */ + sub(frame_length, LowDelayShapes_n960_la_zeroes[fs_idx]) /* i: overlap add buffer size */ + ); + *q_fx_exp = y_e; move16(); /* assign updated Q */ + BREAK; + + case LC3_CON_TEC_TDPLC: + IF (sub(nbLostFramesInRow, 1) == 0) + { + plcAd->tdc_fract = old_pitch_fr; move16(); + n_bands = s_min(frame_length, MAX_BANDS_NUMBER_PLC); + SWITCH (frame_dms) + { + case 25: + band_offsets = bands_offset_lin_2_5ms[fs_idx]; move16(); + IF (sub(fs_idx, 4) == 0) + { + n_bands = 60; move16(); + } + BREAK; + case 50: + band_offsets = bands_offset_lin_5ms[fs_idx]; move16(); + IF (sub(fs_idx, 2) == 0) + { + n_bands = 40; move16(); + } + BREAK; +# ifdef CR8_G_ADD_75MS + case 75: + band_offsets = bands_offset_lin_7_5ms[fs_idx]; move16(); +# ifdef ENABLE_HR_MODE + IF (sub(fs_idx, 5) != 0) + { +# endif + IF (sub(fs_idx, 3) != 0) + { + n_bands = 60; move16(); + } +# ifdef ENABLE_HR_MODE + } +# endif + BREAK; +# endif + case 100: + band_offsets = bands_offset_lin[fs_idx]; move16(); + BREAK; + } + + FOR (i = 0; i < yLen; i++) + { + q_old_d_fx32[i] = L_deposit_h(q_old_d_fx[i]); + } + + /* LPC Analysis */ + /* calculate per band energy*/ + processPerBandEnergy_fx(d2_fx, &d2_fx_exp, q_old_d_fx32, *q_old_fx_exp, band_offsets, fs_idx, n_bands, + 1, frame_dms, buffer_perBandEnergy +#ifdef ENABLE_HR_MODE + , hrmode +#endif + ); + + /* calculate pre-emphasis */ + processPreEmphasis_fx(d2_fx, &d2_fx_exp, fs_idx, n_bands, frame_dms, buffer_preEmphasis); + + /* inverse ODFT */ + processInverseODFT_fx(r_fx, &r_fx_exp, d2_fx, d2_fx_exp, n_bands, plcAd->tdc_lpc_order, buffer_InverseODFT); + + /* lag windowing */ + processLagwin_fx(r_fx, lag_win[fs_idx], plcAd->tdc_lpc_order); + + /* Levinson Durbin */ + processLevinson_fx(tdc_A_32, r_fx, plcAd->tdc_lpc_order, NULL, NULL, buffer_Levinson); + + /* 32Q27 -> 16Qx */ + processPLCLpcScaling_fx(tdc_A_32, plcAd->tdc_A, add(plcAd->tdc_lpc_order, 1)); + } + + /* call TD-PLC */ + /* Q_syn = plcAd->q_fx_old_exp; */ /* makes q_fx_old_exp + available in processTimeDomainConcealment_Apply_fx() for + debugging */ + processTimeDomainConcealment_Apply_fx( + old_pitch_int, plcAd->tdc_preemph_fac, plcAd->tdc_A, plcAd->tdc_lpc_order, plcAd->x_old_tot_fx, frame_length, frame_dms, + fs_idx, nbLostFramesInRow, sub(frame_length, la_zeroes), plcAd->stab_fac, &plcAd->tdc_fract, + &plcAd->tdc_seed, + &plcAd->tdc_gain_c, x_fx, &Q_syn, damping, + plcAd->max_len_pcm_plc, + plcAd->harmonicBuf_fx, plcAd->synthHist_fx, &plcAd->harmonicBuf_Q, scratchBuffer +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + , plcAd->plc_fadeout_type +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + , alpha_type_2_table +#endif +); + + /* exponent of TD-PLC output */ + Q_syn = add(Q_syn, sub(15, plcAd->q_fx_old_exp)); + *q_fx_exp = sub(15, Q_syn); move16(); + + /* TDAC */ + processTdac_fx(ola_mem, ola_mem_exp, x_fx, *q_fx_exp, w, la_zeroes, frame_length, buffer_tdac); + BREAK; + + case LC3_CON_TEC_NS_ADV: + *q_fx_exp = *q_old_fx_exp; move16(); + + /* call Noise Substitution */ + processPLCNoiseSubstitution_fx(q_d_fx, q_old_d_fx, yLen); + + BREAK; + default: ASSERT(!"Unsupported PLC method!"); + } + } + + Dyn_Mem_Deluxe_Out(); +} + + diff --git a/lib_lc3plus/plc_classify_fx.c b/lib_lc3plus/plc_classify_fx.c new file mode 100644 index 000000000..bbb01826a --- /dev/null +++ b/lib_lc3plus/plc_classify_fx.c @@ -0,0 +1,424 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +#ifdef CR8_A_PLC_FADEOUT_TUNING + +static Word32 change_bit_at_position(Word32 value, Word8 bit_position, UWord8 bit) +{ + Word32 helper_mask = ~L_shl_pos(1, bit_position); + Word32 tmp = L_and(value, helper_mask); + tmp = L_or(tmp, L_shl_pos(bit, bit_position)); + return tmp; +} + +static void update_bit_and_byte_positions(Word16 longterm_analysis_counter_max_bytebuffer, Word8 *byte_position, Word8 *bit_position) +{ +#ifdef CR11_A_FIX_IN_PLC_LONGTERM_STATISTIC + IF (sub(*bit_position, 29) == 0) +#else + IF (sub(*bit_position, 30) == 0) +#endif + { + *bit_position = 0; move16(); + + if (sub(*byte_position, longterm_analysis_counter_max_bytebuffer) < -1) + { + *byte_position = add(*byte_position, 1); + } else { + *byte_position = 0; move16(); + } + } ELSE { + *bit_position = add(*bit_position, 1); + } +} + +static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_analysis_counter_max, Word16 *overall_counter, Word8 *byte_position, Word8 *bit_position) +{ + Word32 current_byte = 0; + +#ifdef WMOPS + BASOP_sub_sub_start("PLC::array_insert_and_shift"); +#endif + + IF( overall_counter != NULL) + { + *overall_counter = s_min(add(*overall_counter, 1), longterm_analysis_counter_max); + } + + current_byte = array[*byte_position]; move16(); + current_byte = change_bit_at_position(current_byte, *bit_position, value); + array[*byte_position] = current_byte; move16(); + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} + +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Word16 *counter_tdc, Word16 *counter_ns, Word16 longterm_analysis_counter_max) +#else +static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Word16 *counter_tdc, Word16 *counter_ns, Word16 *counter_phecu, Word16 overall_counter, Word16 longterm_analysis_counter_max) +#endif +{ + int i, k; + Word32 current_byte_tdc = 0, current_byte_ns = 0; + Word16 counter_loc_tdc = 0, counter_loc_ns = 0, counter_tmp = 0; + +#ifdef WMOPS + BASOP_sub_sub_start("PLC::array_calculate"); +#endif + + for (i = length - 1; i >= 0; i--) + { + current_byte_tdc = array_tdc[i]; + current_byte_ns = array_ns[i]; + + for (k = 0; k < 30; k++) + { + counter_loc_tdc += ((current_byte_tdc >> k) & 1); + counter_loc_ns += ((current_byte_ns >> k) & 1); + counter_tmp++; + + /* Break from both loops if full 2s buffer has been evaluated */ + if (counter_tmp >= longterm_analysis_counter_max) + { + i = -1; + k = 30; + break; + } + } + } + + *counter_tdc = counter_loc_tdc; + *counter_ns = counter_loc_ns; + +#ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + *counter_phecu = sub(sub(overall_counter, counter_loc_tdc), counter_loc_ns); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} +#endif + +static Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, Word16 bands_number, Word16 frame_length, + Word16 fs_idx, Word8 *scratchBuffer +# ifdef ENABLE_HR_MODE + , Word16 hrmode +# endif + ); + +void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFramesInRow, Word16 bfi, + Word16 ltpf_mem_pitch_int, Word16 frame_length, Word16 frame_dms, Word16 fs_idx, Word16 yLen, + Word16 q_old_d_fx[], const Word16 *band_offsets, Word16 bands_number, AplcSetup *plcAd, Word8 *scratchBuffer +# ifdef ENABLE_HR_MODE + , Word16 hrmode +# endif + ) +{ + Dyn_Mem_Deluxe_In( + Word16 scQ15; + Word32 class; + ); + +#ifdef WMOPS + BASOP_sub_sub_start("PLC::processPLCclassify_fx"); +#endif + + UNUSED(yLen); + UNUSED(q_old_d_fx); + + if (plcAd) + { + plcAd->norm_corrQ15_fx = 0; move16(); + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + /* assert(bfi != 2 && "Error bfi flag value, state of fadeout cntr is affected by PartialConcealment here "); */ + /* Save statistics for 24 kHz, 48 kHz and 96 kHz */ + IF((sub(bfi, 1) == 0) || (((bfi >= 0) && (sub(bfi, 2) <= 0)) && ((sub(fs_idx, 2) == 0) || (sub(fs_idx, 4) == 0) || (sub(fs_idx, 5) == 0)))) /* note for PC bfi==2 is possible */ +#else + IF (sub(bfi, 1) == 0) +#endif + { + /* increase counter of lost-frames-in-a-row */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + IF (sub(bfi, 1) == 0) + { + *nbLostFramesInRow = add(*nbLostFramesInRow, 1); + *nbLostFramesInRow = s_min(*nbLostFramesInRow, 0x100); + } +#else + *nbLostFramesInRow = add(*nbLostFramesInRow, 1); + *nbLostFramesInRow = s_min(*nbLostFramesInRow, 0x100); +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING + /*assert((bfi != 2) && "PartialConcealment checked vs bfi==0 can cause issues "); */ + IF ((sub(*nbLostFramesInRow, 1) == 0) || (bfi != 1) ) /* was "|| (bfi==0)" , NB only test bfi vs "1" as bfi can have the states [0(good),1(bad),2(good,partialConcealment) } */ +#else + IF (sub(*nbLostFramesInRow, 1) == 0) +#endif + { + *concealMethod = plcMeth; move16(); + + IF(sub(plcMeth, 1) == 0) + { + IF(ltpf_mem_pitch_int > 0) + { + *concealMethod = LC3_CON_TEC_TDPLC; move16(); /* TD-PLC */ + /* Calculate Features */ + + plcAd->norm_corrQ15_fx = plc_xcorr_lc_fx(plcAd->x_old_tot_fx, plcAd->max_len_pcm_plc, ltpf_mem_pitch_int, fs_idx); + scQ15 = spectral_centroid_fx_lc(plcAd->old_scf_q, band_offsets, bands_number, frame_length, + fs_idx, scratchBuffer +#ifdef ENABLE_HR_MODE + , hrmode +#endif + ); + + /* Classify */ + class = L_mult(plcAd->norm_corrQ15_fx, 7640); + class = L_mac(class, scQ15, -32768); + class = L_add_sat(class, -335020208); + + IF(class <= 0) + { +#ifdef ENABLE_HR_MODE + IF((frame_dms == 100) && (hrmode == 0)) +#else + IF(frame_dms == 100) +#endif + { + *concealMethod = LC3_CON_TEC_PHASE_ECU; move16(); /* Phase ECU selected */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + ELSE + { +#ifndef CR9_G_PLC_NS_TDC_FIX + *concealMethod = LC3_CON_TEC_NS_ADV; move16(); /* Noise Substitution */ +#endif +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + } +#ifdef CR8_A_PLC_FADEOUT_TUNING + ELSE { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 1, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } +#endif + } + ELSE + { + *concealMethod = LC3_CON_TEC_NS_ADV; move16(); /* Noise Substitution */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 1, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING +# ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, plcAd->longterm_analysis_counter_max); +# else + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, &plcAd->longterm_counter_plcPhaseEcu, plcAd->overall_counter, plcAd->longterm_analysis_counter_max); +# endif + update_bit_and_byte_positions(plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + + } + } + + Dyn_Mem_Deluxe_Out(); +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} + + +Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, Word16 bands_number, Word16 frame_length, + Word16 fs_idx, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif + ) +{ + Dyn_Mem_Deluxe_In( + Counter i, j; + Word32 den32, num32, tmp32; + Word16 s, sc, fac, freq, inv, startfreq, stopfreq; + Word16 s2; + Word16 *old_scf_q_mod; + Word16 *old_scf_q_mod_exp; + Word16 *band_offsets_local; + ); +#ifdef WMOPS + BASOP_sub_sub_start("PLC::spectral_centroid_fx_lc"); +#endif + +#ifdef ENABLE_HR_MODE + s2 = 0; +#else + UNUSED(s2); +#endif + + + old_scf_q_mod = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * M */ + old_scf_q_mod_exp = (Word16 *)scratchAlign(old_scf_q_mod, sizeof(*old_scf_q_mod) * M); /* Size = 2 * M */ + band_offsets_local = (Word16 *)scratchAlign(old_scf_q_mod_exp, sizeof(*old_scf_q_mod_exp) * (M)); /* Size = 2 * bands_number */ + + /* Linear Domain */ + FOR (i = 0; i < M; i++) + { + old_scf_q_mod[i] = BASOP_Util_InvLog2_16(old_scf_q[i], &old_scf_q_mod_exp[i]); + } + + /* De-emphasis */ + FOR (i = 0; i < M; i++) + { + old_scf_q_mod[i] = mult(old_scf_q_mod[i], lpc_warp_dee_emphasis[fs_idx][i]); move16(); + old_scf_q_mod_exp[i] = add(old_scf_q_mod_exp[i], lpc_warp_dee_emphasis_e[fs_idx][i]); move16(); + } + + IF (sub(bands_number, 64) == 0) + { + basop_memmove(band_offsets_local, band_offsets, (bands_number + 1) * sizeof(Word16)); + } + IF (sub(bands_number, 32) < 0) + { + band_offsets_local[0] = 0; move16(); + s = sub(32, bands_number); + FOR (i = sub(bands_number, 1); i >= s; i--) + { + band_offsets_local[(i + s) * 2 + 1 + 1] = band_offsets[i + 1]; move16(); + band_offsets_local[(i + s) * 2 + 0 + 1] = band_offsets[i + 1]; move16(); + } + FOR (i = sub(s, 1); i >= 0; i--) + { + band_offsets_local[i * 4 + 3 + 1] = band_offsets[i + 1]; move16(); + band_offsets_local[i * 4 + 2 + 1] = band_offsets[i + 1]; move16(); + band_offsets_local[i * 4 + 1 + 1] = band_offsets[i + 1]; move16(); + band_offsets_local[i * 4 + 0 + 1] = band_offsets[i + 1]; move16(); + } + } + ELSE + IF (sub(bands_number, 64) < 0) + { + band_offsets_local[0] = 0; move16(); + s = sub(64, bands_number); + FOR (i = sub(bands_number, 1); i >= s; i--) + { + band_offsets_local[i + s + 1] = band_offsets[i + 1]; move16(); + } + FOR (i = sub(s, 1); i >= 0; i--) + { + band_offsets_local[i * 2 + 1 + 1] = band_offsets[i + 1]; move16(); + band_offsets_local[i * 2 + 0 + 1] = band_offsets[i + 1]; move16(); + } + } + + den32 = 1; move16(); + num32 = 0; move16(); + inv = div_s(1, frame_length); + + FOR (i = 0; i < M; i++) + { + freq = 0; move16(); + startfreq = add(band_offsets_local[i * 4], 1); + stopfreq = band_offsets_local[i * 4 + 4]; + +# ifdef ENABLE_HR_MODE + IF (hrmode != 0) + { + tmp32 = 0; move32(); + FOR (j = startfreq; j <= stopfreq; j++) + { + tmp32 = L_add(tmp32, j); + } + + s2 = norm_l(tmp32); + freq = extract_h(L_shl(tmp32, s2)); + s2 = sub(add(15, s2), 31); + tmp32 = L_mult(inv, freq); + s = norm_l(tmp32); + } + ELSE +# endif + { + FOR (j = startfreq; j <= stopfreq; j++) + { + freq = add(freq, j); + } + + tmp32 = L_mult(inv, freq); + s = norm_l(tmp32); + } + + tmp32 = L_mult(old_scf_q_mod[i], extract_h(L_shl(tmp32, s))); + +# ifdef ENABLE_HR_MODE + if (hrmode != 0) + { + s = add(s, s2); + } +# endif + + num32 = L_add(num32, L_shl(tmp32, add(add(-15, old_scf_q_mod_exp[i]), sub(15, s)))); + den32 = L_add(den32, L_shl(L_mult(old_scf_q_mod[i], stopfreq - startfreq + 1), old_scf_q_mod_exp[i])); + } + + s = norm_l(den32); + s = sub(16, s); + + sc = div_s(extract_l(L_shr(num32, s)), extract_l(L_shr(den32, s))); + + SWITCH (fs_idx) + { + case 0: + fac = 5461; move16(); + BREAK; + case 1: + fac = 10922; move16(); + BREAK; + case 2: + fac = 16384; move16(); + BREAK; + case 3: + fac = 21845; move16(); + BREAK; + default: /* case 4: */ + fac = 32767; move16(); + BREAK; + } + sc = round_fx(L_mult(sc, fac)); +# ifdef ENABLE_HR_MODE + if (sub(fs_idx, 5) == 0) + { + sc = shl_pos(sc, 1); + } +# endif + + Dyn_Mem_Deluxe_Out(); +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return sc; +} + + diff --git a/lib_lc3plus/plc_damping_scrambling_fx.c b/lib_lc3plus/plc_damping_scrambling_fx.c new file mode 100644 index 000000000..4c5641634 --- /dev/null +++ b/lib_lc3plus/plc_damping_scrambling_fx.c @@ -0,0 +1,430 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processPLCDampingScrambling_main_fx(Word16 bfi, Word16 concealMethod, Word16 ns_nbLostFramesInRow, Word16 *cum_fflcAtten, + Word16 pc_nbLostFramesInRow, Word16 *ns_seed, Word16 *pc_seed, Word16 pitch_present_bfi1, + Word16 pitch_present_bfi2, Word32 spec[], Word16 *q_fx_exp, Word16 *q_old_d_fx, + Word16 *q_old_fx_exp, Word16 L_spec, Word16 stabFac, Word16 frame_dms, + Word16 *cum_fading_slow, Word16 *cum_fading_fast, Word16 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , UWord8 plc_fadeout_type +#endif + ) +{ + Dyn_Mem_Deluxe_In( + Word16 processDampScramb; + ); + + IF ( bfi != 0 ) + { + processDampScramb = 0; move16(); + test(); + IF (sub(concealMethod, LC3_CON_TEC_NS_ADV) == 0 || sub(bfi, 2) == 0) + { + processDampScramb = 1; move16(); + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + IF (sub(ns_nbLostFramesInRow, 1) == 0) + { + *cum_fading_slow = 32767; move16(); + *cum_fading_fast = 32767; move16(); + *cum_fflcAtten = 32767; move16(); + } +#endif + + IF (sub(bfi, 1) == 0) + { + processPLCDampingScrambling_fx(spec, L_spec, ns_nbLostFramesInRow, stabFac, + processDampScramb, cum_fflcAtten, + pitch_present_bfi1, frame_dms, cum_fading_slow, + cum_fading_fast, ns_seed, 0 +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); + } + ELSE /* bfi == 2 */ + { + processPLCDampingScrambling_fx(spec, L_spec, pc_nbLostFramesInRow, stabFac, + processDampScramb, cum_fflcAtten, + pitch_present_bfi2, frame_dms, cum_fading_slow, + cum_fading_fast, pc_seed, spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); + + processPLCupdateSpec_fx(q_old_d_fx, q_old_fx_exp, spec, q_fx_exp, L_spec); + } + } + Dyn_Mem_Deluxe_Out(); +} + +void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostFramesInRow, Word16 stabFac, Word16 processDampScramb, + Word16 *cum_fflcAtten, Word16 pitch_present, Word16 frame_dms, Word16 *cum_fading_slow, + Word16 *cum_fading_fast, Word16 *seed, Word16 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , UWord8 plc_fadeout_type +#endif + ) +{ + Counter i; + Word16 lossDuration_dms, slow, fast, tmp16; + Word16 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, linFuncStartStop; + Word16 randThreshold, ad_threshFac, energThreshold, s, s2, s3, mean_energy16; + Word32 frame_energy, mean_nrg, fac; + Word16 fflcAtten, cum_fading_slow_local, cum_fading_fast_local; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processPLCDampingScrambling_fx", sizeof(struct { + Counter i; + Word16 lossDuration_dms, slow, fast, tmp16; + Word16 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, linFuncStartStop; + Word16 randThreshold, ad_threshFac, energThreshold, s, s2, s3, mean_energy16; + Word32 frame_energy, mean_nrg, fac; + Word16 fflcAtten, cum_fading_slow_local, cum_fading_fast_local; + })); +#endif + + /** preparation */ +#ifndef CR8_A_PLC_FADEOUT_TUNING + /* init cummulative damping factors at first loss */ + IF (sub(nbLostFramesInRow, 1) == 0) + { + *cum_fading_slow = 32767; move16(); + *cum_fading_fast = 32767; move16(); + *cum_fflcAtten = 32767; move16(); + } +#endif + + /* get damping factors */ + tmp16 = mult(6554 /*0.2*/, stabFac); + slow = add(26214 /*0.8*/, tmp16); + fast = add( 9830 /*0.3*/, tmp16); + + + SWITCH (frame_dms) + { + case 25: + IF (sub(slow, 32767) < 0) + { + tmp16 = 0; + slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = shl(slow, tmp16); + } + IF (sub(slow, 32767) < 0) + { + tmp16 = 0; + slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = shl(slow, tmp16); + } + IF (sub(fast, 32767) < 0) + { + tmp16 = 0; + fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = shl(fast, tmp16); + } + IF (sub(fast, 32767) < 0) + { + tmp16 = 0; + fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = shl(fast, tmp16); + } + BREAK; + case 50: + IF (sub(slow, 32767) < 0) + { + tmp16 = 0; + slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = shl(slow, tmp16); + } + IF (sub(fast, 32767) < 0) + { + tmp16 = 0; + fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = shl(fast, tmp16); + } + BREAK; +#ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS + case 75: + IF (sub(slow, 32767) < 0) + { + slow = mult(slow, mult(slow, slow)); + } + IF (sub(slow, 32767) < 0) + { + tmp16 = 0; + slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = shl(slow, tmp16); + } + IF (sub(slow, 32767) < 0) + { + tmp16 = 0; + slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = shl(slow, tmp16); + } + IF (sub(fast, 32767) < 0) + { + fast = mult(fast, mult(fast, fast)); + } + IF (sub(fast, 32767) < 0) + { + tmp16 = 0; + fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = shl(fast, tmp16); + } + IF (sub(fast, 32767) < 0) + { + tmp16 = 0; + fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = shl(fast, tmp16); + } + BREAK; +# endif +#endif + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type == 0) + { +#endif + *cum_fading_slow = mult_r(*cum_fading_slow, slow); + *cum_fading_fast = mult_r(*cum_fading_fast, fast); +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + IF ( sub(processDampScramb, 1) == 0 ) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0) + { + Word16 lost_frame_thr1 = 4; + Word16 lost_frame_thr2 = 8; + + SWITCH (frame_dms) + { + case 25: + lost_frame_thr1 = 16; + lost_frame_thr2 = 32; + BREAK; + case 50: + lost_frame_thr1 = 8; + lost_frame_thr2 = 16; + BREAK; +#ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS + case 75: + lost_frame_thr1 = 6; + lost_frame_thr2 = 11; +# endif +#endif + } + IF (sub(nbLostFramesInRow, lost_frame_thr1) < 0) + { + cum_fading_slow_local = 32767; move16(); + } + ELSE IF (sub(nbLostFramesInRow, lost_frame_thr2) < 0) + { + cum_fading_slow_local = 29491; move16(); + } + ELSE + { + cum_fading_slow_local = 27852; move16(); + } + + *cum_fading_slow = mult_r(*cum_fading_slow, cum_fading_slow_local); move16(); + cum_fading_slow_local = *cum_fading_slow; move16(); + } else { +#endif + /** rapid fading for FFLC */ + fflcAtten = 32767; move16(); + cum_fading_slow_local = *cum_fading_slow; move16(); + cum_fading_fast_local = *cum_fading_fast; move16(); + + IF (spec_inv_idx == 0) + { + lossDuration_dms = DEPR_i_mult(nbLostFramesInRow, frame_dms); + IF (sub(lossDuration_dms, PLC_FADEOUT_IN_MS*10) > 0) + { + *cum_fflcAtten = 0; move16(); + fflcAtten = 0; move16(); + } + ELSE IF (sub(lossDuration_dms, 200) > 0) + { + SWITCH (frame_dms) + { + case 25: fflcAtten = PLC34_ATTEN_FAC_025_FX; BREAK; + case 50: fflcAtten = PLC34_ATTEN_FAC_050_FX; BREAK; +#ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS + case 75: fflcAtten = PLC34_ATTEN_FAC_075_FX; BREAK; +# endif +#endif + case 100: fflcAtten = PLC34_ATTEN_FAC_100_FX; BREAK; + } + } + IF ( sub(fflcAtten, 32767) < 0 ) + { + *cum_fflcAtten = mult_r(*cum_fflcAtten, fflcAtten); + cum_fading_slow_local = mult_r(*cum_fading_slow, *cum_fflcAtten); + cum_fading_fast_local = mult_r(*cum_fading_fast, *cum_fflcAtten); + } + } + + /** prepare fade-out function */ + /* being 1 up to plc_start_inFrames, being 0 starting with + plc_end_inFrames; decreasing linearly in between */ + SWITCH (frame_dms) + { + case 25: + plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 25; move16(); + plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 25; move16(); + BREAK; + case 50: + plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 50; move16(); + plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 50; move16(); + BREAK; +#ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS + case 75: + plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 75; move16(); + plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 75; move16(); + BREAK; +# endif +#endif + default: + plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 100; move16(); + plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 100; move16(); + } + + if (pitch_present == 0) + { + plc_start_inFrames = 1; move16(); + } + plc_duration_inFrames = sub(plc_end_inFrames, plc_start_inFrames); + + IF (sub(nbLostFramesInRow, plc_start_inFrames) <= 0) + { + linFuncStartStop = 32767; move16(); + } + ELSE IF (sub(nbLostFramesInRow, plc_end_inFrames) >= 0) + { + linFuncStartStop = 0; move16(); + } + ELSE + { + /* + x = xLostFramesInRow; + m = -1 / plc_duration_inFrames; + b = -plc_end_inFrames; % shift on x axis + linFuncStartStop = m * (x + b); + */ + linFuncStartStop = div_s(sub(plc_end_inFrames, nbLostFramesInRow), plc_duration_inFrames); + } + + /** sign scrambling */ + randThreshold = mult(-32768, linFuncStartStop); +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + tmp16 = *seed; move16(); + FOR (i = spec_inv_idx; i < L_spec; i++) + { + tmp16 = extract_l(L_mac0(16831, tmp16, 12821)); + + IF (tmp16 < 0) + { + test(); +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0 || pitch_present == 0 || sub(tmp16, randThreshold) < 0 ) +#else + if (pitch_present == 0 || sub(tmp16, randThreshold) < 0) +#endif + { + spec[i] = L_negate(spec[i]); + } + } + + } + *seed = tmp16; move16(); + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type == 0) + { +#endif + /** adaptive damping */ + tmp16 = mult(18022 /* 10 - 1.2 */, linFuncStartStop); + ad_threshFac = add(shr(tmp16, 1), 1228 /* 1.2 >> 1 */); /* exp = 5 */ + + s = getScaleFactor32_lc3plus(&spec[spec_inv_idx], sub(L_spec, spec_inv_idx)); + frame_energy = 0; move32(); + FOR (i = spec_inv_idx; i < L_spec; i++) + { + tmp16 = extract_h(L_shl_sat(spec[i], sub(s, 4))); + frame_energy = L_mac0(frame_energy, tmp16, tmp16); /* exp = -(2*(s-16) - 8) */ + } + mean_energy16 = BASOP_Util_Divide3216_Scale_lc3plus(frame_energy, sub(L_spec, spec_inv_idx), &s2); /* exp = -(2*(s-16) - 8) + 16 - (15-s2) */ + + energThreshold = mult(ad_threshFac, mean_energy16); /* exp = -(2*(s-16) - 8) + 16 - (15-s2) + 5 */ + + s3 = add(sub(29, shl(sub(s, 16), 1)), s2); + IF (sub(energThreshold, 32767) < 0) + { + energThreshold = Sqrt16_lc3plus(energThreshold, &s3); + } + s3 = sub(s3, 15); + + mean_nrg = L_shl_sat(L_deposit_l(energThreshold), s3); /* exp = 0 */ + fac = mult(sub(cum_fading_slow_local, cum_fading_fast_local), energThreshold); + fac = L_shl_sat(L_deposit_l(fac), s3); /* exp = 0 */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + FOR (i = spec_inv_idx; i < L_spec; i++) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if ( ( plc_fadeout_type != 0 ) || (L_sub(L_abs(spec[i]), mean_nrg) < 0) ) +#else + if (L_sub(L_abs(spec[i]), mean_nrg) < 0) +#endif + { + spec[i] = Mpy_32_16_lc3plus(spec[i], cum_fading_slow_local); + } + else + { + if (spec[i] > 0) + { + spec[i] = L_add_sat(Mpy_32_16_lc3plus(spec[i], cum_fading_fast_local), fac); + } + else if (spec[i] == 0) + { + spec[i] = Mpy_32_16_lc3plus(spec[i], cum_fading_fast_local); + } + else + { + spec[i] = L_sub_sat(Mpy_32_16_lc3plus(spec[i], cum_fading_fast_local), fac); + } + } + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/plc_lpc_scaling_fx.c b/lib_lc3plus/plc_lpc_scaling_fx.c new file mode 100644 index 000000000..85ffbf942 --- /dev/null +++ b/lib_lc3plus/plc_lpc_scaling_fx.c @@ -0,0 +1,36 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processPLCLpcScaling_fx(Word32 tdc_A_32[], Word16 tdc_A_16[], Word16 m) +{ + Counter i; + Word16 s; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processPLCLpcScaling_fx", sizeof(struct { + Counter i; + Word16 s; + })); +#endif + + s = getScaleFactor32_lc3plus(tdc_A_32, m); + FOR (i = 0; i < m; i++) + { + tdc_A_16[i] = round_fx_sat(L_shl_sat(tdc_A_32[i], s)); move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/plc_main_fx.c b/lib_lc3plus/plc_main_fx.c new file mode 100644 index 000000000..1948aa23a --- /dev/null +++ b/lib_lc3plus/plc_main_fx.c @@ -0,0 +1,85 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processPLCmain_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFramesInRow, Word16 bfi, Word16 prev_bfi, + Word16 frame_length, Word16 la_zeroes, +#ifdef ENABLE_HR_MODE + const Word32 w[], +#else + const Word16 w[], +#endif + Word16 x_fx[], Word16 ola_mem[], + Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], + Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, const Word16 *band_offsets, Word16 bands_number, Word16 *damping, + Word16 old_pitch_int, Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, + AplcSetup *plcAd, Word16 frame_dms, Word8 *scratchBuffer, Word16 *pc_nbLostFramesInRow +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + ,Word32 rel_pitch_change +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + ,Word16 *alpha_type_2_table +#endif +) +{ + IF(sub(bfi, 1) == 0 && plcAd) + { + /* FFLC increases the PFLC counter */ + *pc_nbLostFramesInRow = add(*pc_nbLostFramesInRow, 1); + } + + processPLCclassify_fx(plcMeth, concealMethod, nbLostFramesInRow, bfi, old_pitch_int, frame_length, frame_dms, + fs_idx, yLen, q_old_d_fx, band_offsets, bands_number, plcAd, scratchBuffer +#ifdef ENABLE_HR_MODE + , hrmode +#endif + ); + + processPLCapply_fx( +#ifdef CR8_A_PLC_FADEOUT_TUNING + concealMethod, +#else + *concealMethod, +#endif + *nbLostFramesInRow, bfi, prev_bfi, frame_length, la_zeroes, w, x_fx, ola_mem, + ola_mem_exp, q_old_d_fx, q_old_fx_exp, q_d_fx, q_fx_exp, yLen, fs_idx, damping, old_pitch_int, + old_pitch_fr, ns_cum_alpha, ns_seed, frame_dms, plcAd, scratchBuffer +#ifdef ENABLE_HR_MODE + , hrmode +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , rel_pitch_change +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + , alpha_type_2_table +#endif + ); + + IF (bfi == 0) + { + processPLCupdateSpec_fx(q_old_d_fx, q_old_fx_exp, q_d_fx, q_fx_exp, yLen); + } + +#ifdef ENABLE_HR_MODE + IF (plcAd != NULL && (sub(plcAd->PhECU_frame_ms , 10) == 0) && (hrmode == 0)) +#else + IF (plcAd != NULL && (sub(plcAd->PhECU_frame_ms , 10) == 0)) +#endif + { + processPLCspec2shape_fx(prev_bfi, bfi, q_old_d_fx, yLen, plcAd->PhECU_oold_grp_shape_fx, plcAd->PhECU_old_grp_shape_fx); + } + +} + + diff --git a/lib_lc3plus/plc_noise_substitution_fx.c b/lib_lc3plus/plc_noise_substitution_fx.c new file mode 100644 index 000000000..ab618ae7e --- /dev/null +++ b/lib_lc3plus/plc_noise_substitution_fx.c @@ -0,0 +1,32 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processPLCNoiseSubstitution_fx(Word32 spec[], Word16 spec_prev[], Word16 L_spec) +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + + FOR (i = 0; i < L_spec; i++) + { + spec[i] = L_deposit_h(spec_prev[i]); + } + + /* High pass to prevent overflows */ + spec[0] = Mpy_32_16_lc3plus(spec[0], 6553 /* 0.2 Q15*/); move32(); + spec[1] = Mpy_32_16_lc3plus(spec[1], 16384 /* 0.5 Q15*/); move32(); + + Dyn_Mem_Deluxe_Out(); +} + + + diff --git a/lib_lc3plus/plc_phecu_f0_refine_first_fx.c b/lib_lc3plus/plc_phecu_f0_refine_first_fx.c new file mode 100644 index 000000000..5c01a0029 --- /dev/null +++ b/lib_lc3plus/plc_phecu_f0_refine_first_fx.c @@ -0,0 +1,100 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void plc_phEcu_F0_refine_first_fx(Word16 * plocs, /* i/o */ + const Word16 n_plocs_in, Word32 *L_f0est, /* i/o Q16 */ + const Word16 stPhECU_f0hzLtpBinQ7, const Word16 stPhECU_f0gainLtpQ15, + const Word16 nSubm) + +{ + Counter subm, i; + Word16 ploc, n_plocs_ana; + Word32 L_tmp = 0, L_diff, L_f0EstQ7, L_sensitivity_Q7; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("plc_phEcu_F0_refine_first_fx", sizeof(struct { + Counter subm, i; + Word16 ploc, n_plocs_ana; + Word32 L_tmp, L_diff, L_f0EstQ7, L_sensitivity_Q7; + })); +#endif + + + + /* single initial peak F0 correction using available LTP information */ + + IF (sub(stPhECU_f0gainLtpQ15, ((Word16)(0.25 * 32768.0))) > 0) + { + ploc = -1; move16(); /* sentinel */ + n_plocs_ana = s_min(n_plocs_in, 4); /* only analyze at first 3 deteteced LF peaks */ + + /* only apply analysis below nsubm*pitmax_freq ~= 1600Hz */ + i = sub(n_plocs_ana, 1); + WHILE (i >= 0 && sub(plocs[i], (Word16)(1600.0 / 62.5)) > 0) + { + i--; + } + n_plocs_ana = add(i, 1); + + IF ((n_plocs_ana > 0)) + { + /* % find/correct first peak in f0est , that is a submultiple of n*f0Ltp*/ + FOR (i = 0; i < n_plocs_ana; i++) + { + + L_sensitivity_Q7 = L_deposit_l(((Word32)1) << (7 - 1)); /* 0.5 in Q7 */ + if (sub(stPhECU_f0gainLtpQ15, ((Word16)(0.75 * 32768.0))) < 0) + { + L_sensitivity_Q7 = L_shr_pos(L_sensitivity_Q7, 1); /* % more picky if correlation is rather low */ + } + + L_f0EstQ7 = L_shr_pos(L_f0est[i], 9); /* Q16 to Q7 */ + + FOR (subm = 1; subm <= nSubm; subm++) + { + /*adjf0 = abs(f0est - subm*stPhECU_f0hzLtpBin*ones(size(f0est))) < sensitivity ; % L1 difference, + vector operation over f0 + ind = find(adjf0==1,1); */ + L_diff = L_msu0(L_f0EstQ7, subm, stPhECU_f0hzLtpBinQ7); + L_diff = L_abs(L_diff); + IF (L_sub(L_diff, L_sensitivity_Q7) < 0) + { + L_tmp = L_shl_pos(L_mult0(subm, stPhECU_f0hzLtpBinQ7), 16 - 7); /* to Q16 */ + ploc = i; move16(); + BREAK; + } + L_sensitivity_Q7 = Mpy_32_16_lc3plus(L_sensitivity_Q7, (Word16)(0.875 * 32768.0 )); /* 2 cycles */ + } /* subm*/ + + IF (ploc >= 0) + { + BREAK; + } + } /* i, n_ploc_ana*/ + } + + if (ploc >= 0) + { + L_f0est[ploc] = L_tmp; move32(); /* in Q16 */ + /*ideally also integer plocs should be updated , e.g. if f0est goes from 1.45(plocs=1) to 1.6(plocs==2) + */ + /* but that is costly and not required as long as corr_phase width is large enough ]*/ + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + +} + + diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c new file mode 100644 index 000000000..ca2a345f4 --- /dev/null +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -0,0 +1,3157 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" +#include "math.h" /*dbg*/ + +/*---------------------------------------------------------------------* + * Local constants + *---------------------------------------------------------------------*/ + +#define DELTA_CORR 5 /* Tuning parameter - defining range for phase correction around peak */ +#define DELTA_CORR_F0_INT 2 /* Tuning parameter - defining range for phase correction around peak */ + +#define MAX_INCREASE_GRPPOW_FX 0 /* max. amplification in case of transients (in dB scale) */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING +# define ONE_SIDED_SINE_WIDTH (4) /* expected pure sine main lobe maximum width (4+1+4) bins *62.5 hz/bin => approx 560 Hz total width */ +# define SIDE_LIM 12539859L /* 10^ (4.5/20.0) = 2^(a); --> x= 0.747433821 -> Lx_Q24 = round((1L<<(24))*0.747433821)) = 12539859 */ +# define LFHF_LIM 16719812L /* 10^ (6.0/20.0) = 2^(b); --> x= 0.996578428 -> Lx_Q24 = round((1L<<(24))*0.996578428)) = 16719812 */ +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +#else + +#if PLC2_FADEOUT_IN_MS == 0 +#define BURST_ATT_THRESH (4) /* speech start attenuate with losses in a row , stable content is +1 */ +#define ATT_PER_FRAME 2 /* ptr to a table , regular voiced attenuation settings table [0.4 dBx16 frames + 6dBx16 frames] 10 ms frame */ +/* #define ATT_PER_FRAME 1 */ /* ptr to a table , regular attenuation settings table [0.3 dBx16 frames + 6dBx16 frames] 10 ms frame */ +#define BETA_MUTE_THR 20 /* time threshold from BFI start to start of beta-noise further energy attenuation, by .5 each frame */ +/* #define OFF_FRAMES_LIMIT 30 in defines.h , table size and complete zero signal after BURST_ATT_THRESH + OFF_FRAMES_LIMIT */ +#endif + +#if PLC2_FADEOUT_IN_MS != 0 /* TD_PLC muting setting */ + /*% burst attenuation scheme is allowed to be indirectly controlled by a setting from TDC-PLC settings ,if negative PLC2_FADEOUT_IN_MS */ + +#if (PLC2_FADEOUT_IN_MS < 0) +#define FADEOUT_IN_MS PLC_FADEOUT_IN_MS /*% use TDC-SETTING as input */ +#else +#define FADEOUT_IN_MS PLC2_FADEOUT_IN_MS /* % use a PLC2 individual settings as basis */ +#endif + + /* %Examples + % FADEOUT_IN_MS ==30 ms --> shortest setting, att per frame idx = 10 for PLC2 + % FADEOUT_IN_MS ==40 ms --> att per frame idx = 8 setting for PLC2 + % FADEOUT_IN_MS ==60 ms --> att per frame idx = 6 setting for PLC2 (3+4) low decay then fast decay + % FADEOUT_IN_MS ==80 ms --> att per frame idx = 4 setting for PLC2 + % FADEOUT_IN_MS ==100 ms --> att per frame idx = 2 longest = near original setting for PLC2 + */ +#define PLC_P800_SPEECH_FADEOUT_IN_FRAMES (FADEOUT_IN_MS/10) +#define PLC2_FADEOUT_IN_FRAMES MIN(OFF_FRAMES_LIMIT,MAX(6, (3*PLC_P800_SPEECH_FADEOUT_IN_FRAMES))) /* help variable */ + +#define BURST_ATT_THRESH_PRE MIN(5,MAX(1,((1*PLC2_FADEOUT_IN_FRAMES)/6))) /* nominal 10-50 ms to start actual muting, will be thresh +1 */ + +#undef ATT_PER_FRAME +#define ATT_PER_FRAME MIN(10, MAX(2, 2*(6-BURST_ATT_THRESH_PRE))) /* we let the BURST_ATT_THRESH_PRE control the initial table selection */ +/* will eventually become ATT_PER_FRAME-1 = */ + /* table ptr 1,2 --> 16 low decay, 16 high decay, "0" */ + /* table ptr 3,4 --> 8 low decay, 24 high decay, "0" */ + /* table ptr 5,6 --> 4 low decay, 28 high decay , "0"*/ + /* table ptr 7,8 --> 2 low decay, 30 high decay, "0"*/ + /* table ptr 9,10 --> 1 low decay, 31 high decay, "0"*/ +#undef BURST_ATT_THRESH +#define BURST_ATT_THRESH MIN(BURST_ATT_THRESH_PRE, 4 ) /* nominal 10-40 ms, of no regular muting , 20-50 ms */ + + /* beta mute starts to become active when the low decay mute has ended */ +#undef BETA_MUTE_THR +#define BETA_MUTE_THR MIN( 4+(OFF_FRAMES_LIMIT/2)+1 , MAX(4, BURST_ATT_THRESH + 1 +(1<<(BURST_ATT_THRESH_PRE-1)))) /* nominal time to start mandatory decrease of Xavg */ + +#if (ATT_PER_FRAME < 2) || (ATT_PER_FRAME > 10) +#pragma message(" ROM table POW_ATT_TABLES needs update to change the ATT_PER FRAME constants supported are (1),2 (3), 4, (5) ,6 dB/frame ") +#endif + +#else +#if ( ATT_PER_FRAME != 2) +#pragma (" ROM table POW_ATT_TABLES needs update to change the ATT_PER FRAME constants supported are (1),2 dB/frame ") +#endif +#endif + + +#endif + + +#define CMPLMNT_PLOC_SENS_FX 2294 /* (1.0 - p_locator_sens) in Q15 */ +#define FEC_HQ_ECU_ROOT2 23170 /*(0x5a83) */ /* sqrt(2) in Q14 */ +#define FEC_TWOTHIRDS_Q15 21845 /* round(2^15*2/3) */ + +static void get_sin_cosQ10opt(Word16 phase, /* Q10 0..1023 i.e. 1024=2*pi */ + Word16 *ptrSin, /* Q15 */ + Word16 *ptrCos); /* Q15 */ + +static Word16 sqrt2ndOrder(const Word16); + +void my_wtda_fx(const Word16 *new_audio, /* i : input audio to be windowed Q0 20 ms , OPT can be output as well */ + const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + Word32 * L_wtda_audio, /* o : tda audio Q16 20 ms */ + const Word16 L, Word8 *scratchBuffer); + +static void windowing_L(const Word16 *, Word32 *, const Word16 *, const Word16, const Word16); +static void windowing_ola(const Word16 *, Word16 *, const Word16 *, const Word16); +static void ola_add(const Word16 *, const Word16 *, Word16 *, const Word16); +static void intlvW32_2_flippedW16(Word32 *L_x, const Word16 numPairs, const Word16 L_prot, Word16 *x); +static void flippedW16_2_intlvW32(Word16 *x, const Word16 numPairs, const Word16 Lprot, Word32 *L_x); +static Word16 imax_fx(const Word16 *, const Word16); + + +Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F); + +static Word16 imax2_jacobsen_mag_fx(const Word16 *y_re, const Word16 *y_im, const Word16 special); +static void fft_spec2_sqrt_approx_fx(const Word16 x[], Word16 xMagSqrt[], const Word16 N); +static Word16 sqrtMagnApprox_fx(const Word16 re, const Word16 im); + +#ifdef CR8_A_PLC_FADEOUT_TUNING +static Word16 plc_phEcu_nonpure_tone_ana_fx(const Word16* plocs, const Word16 n_plocs, const Word16* X, + const Word32 *L_Xavg, /* i : Frequency group amp averages for tonal tilt analysis pref. Max upshifted */ + const Word16 Lprot, const Word16 fs_idx); +#endif + + +static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 sinFactor, Word16 *re_out_ptr, + Word16 *im_out_ptr) +{ +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::rotate_W16_fx"); +#endif + *re_out_ptr = msu_r(L_mult(re_in, cosFactor), im_in, sinFactor); /* 2 ops no move when inlined */ + *im_out_ptr = mac_r(L_mult(re_in, sinFactor), im_in, cosFactor); /* 2 ops no move when inlined */ +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return; +} + +static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFactor, Word16 cosFactor) +{ + Word16 scale_fx; +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::valley_magnitude_adj_fx"); +#endif + + /* y = 0.5*((2*rand(1,10000) + 1*cos(2*pi*x)) - 1 */ /* y will be in -1 to 1 range */ + /* y = 1*((1*rand(1,10000) + 0.5*cos(2*pi*x)) - 1 */ /* y will be in -1 to 1 range */ + + scale_fx /*Q15*/ = mac_r(L_mult(uniFactor, 16384), cosFactor, 16384); + /* make gain distribution more like N(0,1) than uniform */ + + scale_fx /*Q14*/ = round_fx(L_mac((Word32)(16384L << 16), scale_fx, 4096)); + /* create a random gain scaling value with mean 1.0 and max 1.25 and min 0.75 */ + ASSERT(scale_fx <= (16384 + 8192)); + ASSERT(scale_fx >= (-16384 - 8192)); + *re_ptr = mult_r(scale_fx, shl_sat(*re_ptr, 1)); /* no moves , should be inlined */ + *im_ptr = mult_r(scale_fx, shl_sat(*im_ptr, 1)); /* no moves , should be inlined */ + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return; +} + +/*------------------------------------------------------------------* + * rand_phase() + * + * randomized phase in form of sin and cos components + *------------------------------------------------------------------*/ +Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) +{ + /* 4x8+8 lookup scheme requiring ~40 Words of ROM freqRes 90/8 = 11.25 degrees */ + + /* x=(0:(5*8-1))*(2*pi)/32; y=sin(x);y_int=max(-32768,min(32767,round(y*32768))), y_int/32768 */ + + const Word16 *sincos_lowres_tab_cosQ15_fx = sincos_lowres_tab_sinQ15_fx + 8; + /* position at 90 degrees , ptr init */ + Word16 seed2; + Word16 seed2_shift; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("rand_phase_fx", sizeof(struct { + const Word16 *sincos_lowres_tab_cosQ15_fx; /* position at 90 degrees */ + Word16 seed2; /* 16 bit signed */ + Word16 seed2_shift; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::rand_phase_fx"); +#endif + + seed2 = extract_l(L_mac0(13849, seed, 31821)); + seed2_shift = lshr(seed2, 11); + /* logical shift to get uniform random 5 msb bits; 0-31 , 0 degrees to 31*360/32= 348.75 */ + *sin_F = sincos_lowres_tab_sinQ15_fx[seed2_shift]; move16(); /* these moves can often be avoided by returning seed2shift and inlining */ + *cos_F = sincos_lowres_tab_cosQ15_fx[seed2_shift]; move16(); /* these moves can often be avoided by inlining */ +/* total WC 5 ops */ +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return seed2; +} + +/*----------------------------------------------------------------------------- + * trans_burst_ana_fx() + * + * Transient analysis + *----------------------------------------------------------------------------*/ +void trans_burst_ana_fx( + const Word16 *xfp, /* i : Input signal (, only used if time_offset==0) now in up_scaled *Q_spec */ + Word16 * mag_chg, /* o : Magnitude modification vector Q15 */ + Word16 * ph_dith, /* o : Phase dither, 2*PI is not included (Q15, i.e., between 0.0 and 1.0) */ + Word16 * mag_chg_1st, /* i/o: per band magnitude modifier for transients Q15 */ + const Word16 output_frame, /* i : Frame length */ + const Word16 time_offs, /* i : Time offset (integral multiple of output_frame) */ + const Word16 est_stab_content, /* i : 0.0=dynamic ... 1.0=Stable (==st->env_stab ) */ + Word16 * alpha, /* o : Magnitude modification factors for fade to average */ + Word16 * beta, /* : Magnitude modification factors for fade to average */ + Word16 * beta_mute, /* i/o : Factor for long-term mute */ + Word16 * Xavg, /* o : Frequency group average gain to fade to in same Q as X_sav */ + Word16 Q_spec, Word32 L_oold_xfp_w_E_fx, Word16 oold_xfp_w_E_exp_fx, Word16 oold_Ltot_exp_fx, + Word16 *oold_grp_shape_fx, + + Word32 L_old_xfp_w_E_fx, Word16 old_xfp_w_E_exp_fx, Word16 old_Ltot_exp_fx, Word16 *old_grp_shape_fx, +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 fadeout, + Word32 * L_Xavg, /* full scale band amplitudes */ +#endif + Word8 *scratchBuffer /* Size = 4*4 * MAX_LTRANA + (2*4 + 1*2) * MAX_LGW + 8 */ +) +{ + Word16 att_val, attDegreeFrames; + Word32 * L_pGrPowLeft, *L_pGrPowRight; + Word32 * L_gr_pow_left, *L_gr_pow_right; + Word16 Lgw, i, k, burst_len; + Word16 man, expo; + Word16 att_always = 0; /* fixed attenuation per frequency group if set to 1 */ + Word16 oneOverFrame, roundEstMusContent, tmp16; +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 burst_att_thresh; + Word16 att_per_frame; +#else + Word16 burst_att_thresh = BURST_ATT_THRESH; + Word16 att_per_frame = ATT_PER_FRAME; +#endif + Word16 * tr_dec; + Word32 L_acc; + Word16 fs_scale; + Word16 scale_sh; + + Word32 L_oold_tmp, L_old_tmp; + Word16 oold_exp_fx, old_exp_fx; + Word16 margin_oold, margin_old; + Word16 fs_idx; + Word16 exp_diff; + Word16 Xavg_exp_fx, Xavg_mod_exp_fx; + Word16 tr_rise[MAX_LGW]; + Word16 tr_decay[MAX_LGW]; + Word16 man_in, expo_in, tmp; + Word32 L_tmp, L_tmp2; + Word16 thresh_tr_rise_lin_Q15; + Word16 thresh_tr_decay_lin_Q15; +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 beta_mute_thr; + Word16 fade_ms_ind; +#endif + +#ifdef DYNMEM_COUNT +#ifdef CR8_A_PLC_FADEOUT_TUNING + Dyn_Mem_In("trans_burst_ana_fx", sizeof(struct { + + Word16 att_val, attDegreeFrames; + Word32 * pGrPowLeft_L, *pGrPowRight_L; + Word32 * L_gr_pow_left, *L_gr_pow_right; + Word16 Lprot; + Word16 Lgw, i, k, burst_len; + Word16 man, expo; + Word16 att_always; /* fixed attenuation per frequency group if set to 1 */ + Word16 oneOverFrame, roundEstMusContent, tmp16; + + Word16 burst_att_thresh; + Word16 att_per_frame; + + Word16 * tr_dec; + UWord16 lsb; + Word32 L_acc; + Word16 fs_scale; + Word16 scale_sh; + + Word32 L_oold_tmp; + Word32 L_old_tmp; + Word16 fs_idx; + Word16 shift32; + Word16 margin_old; + Word16 margin_oold; + + Word16 Xavg_exp_fx, Xavg_mod_exp_fx; + Word16 tr_rise[MAX_LGW]; + Word16 tr_decay[MAX_LGW]; + + Word16 man_in, expo_in, tmp; + Word32 L_tmp, L_tmp2; + Word16 thresh_tr_rise_lin_Q15; + Word16 thresh_tr_decay_lin_Q15; + + Word16 beta_mute_thr; + Word16 fade_ms_ind; + })); +#else + Dyn_Mem_In("trans_burst_ana_fx", sizeof(struct { + + Word16 att_val, attDegreeFrames; + Word32 * pGrPowLeft_L, *pGrPowRight_L; + Word32 * L_gr_pow_left, *L_gr_pow_right; + Word16 Lprot; + Word16 Lgw, i, k, burst_len; + Word16 man, expo; + Word16 att_always; /* fixed attenuation per frequency group if set to 1 */ + Word16 oneOverFrame, roundEstMusContent, tmp16; + + Word16 burst_att_thresh; + Word16 att_per_frame; + + Word16 * tr_dec; + UWord16 lsb; + Word32 L_acc; + Word16 fs_scale; + Word16 scale_sh; + + Word32 L_oold_tmp; + Word32 L_old_tmp; + Word16 fs_idx; + Word16 shift32; + Word16 margin_old; + Word16 margin_oold; + + Word16 Xavg_exp_fx, Xavg_mod_exp_fx; + Word16 tr_rise[MAX_LGW]; + Word16 tr_decay[MAX_LGW]; + })); +#endif + +#endif + + UNUSED(xfp); + UNUSED(oold_xfp_w_E_exp_fx); + UNUSED(old_xfp_w_E_exp_fx); + + if (time_offs == 0) + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(1st)"); +#endif + } + else + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(N)"); +#endif + } + + fs_idx = mult(output_frame, (Word16)(32768.0 / 99.0)); /* truncation needed , i.e no rounding can be applied here */ + ASSERT(fs_idx == (output_frame / 100)); + + L_gr_pow_left = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LGW */ /* Size = 4 * MAX_LGW */ + + L_gr_pow_right = (Word32 *)scratchAlign(L_gr_pow_left, sizeof(*L_gr_pow_left) * MAX_LGW); /* Size = 4 * MAX_LGW */ + + tr_dec = (Word16 *)scratchAlign(L_gr_pow_right, sizeof(*L_gr_pow_right) * MAX_LGW); /* Size = 2bytes * MAX_LGW */ + + oneOverFrame = oneOverFrameQ15Tab[fs_idx]; + Lgw = s_min(add(fs_idx, LGW8K), LGW48K); /* 4,5,6,7, (7/8) */ + + burst_len = add(mult_r(time_offs, oneOverFrame), 1); + + UNUSED(est_stab_content); + UNUSED(roundEstMusContent); +#ifndef CR8_A_PLC_FADEOUT_TUNING + burst_att_thresh = add(BURST_ATT_THRESH, 1); /* in Q0 , stable setting */ + att_per_frame = sub(ATT_PER_FRAME, 1); /* in Q0 , stable setting */ +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING + move16(); + fade_ms_ind = (PLC2_FADEOUT_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; /* a shorter fading entry in fade_scheme_tab_fx */ + test(); + if (fadeout != 0) + { + fade_ms_ind = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; move16(); + /* a long fading table entry in fade_scheme_tab */ + } + + move16(); move16(); move16(); + att_per_frame = fade_scheme_tab_fx[fade_ms_ind][0]; + burst_att_thresh = fade_scheme_tab_fx[fade_ms_ind][1]; /* number of 1.0 frames before muting phase */ + /* band gain muting can take place earlier due to a band transient */ + beta_mute_thr = fade_scheme_tab_fx[fade_ms_ind][2]; /* faster muting of added noise starts when slow main signal fadeout is over */ +#endif + + + + +#ifdef PLC_FADEOUT_IN_MS +#ifdef CR8_A_PLC_FADEOUT_TUNING + ASSERT(att_per_frame >= 1 && att_per_frame <= 12); /* table based lookup restriction */ +#else + ASSERT(att_per_frame >= 1 && att_per_frame <=10 ); /* table based lookup restriction */ +#endif +#else + ASSERT(att_per_frame == 1 || att_per_frame == 2); /* table based lookup restriction */ +#endif + + *ph_dith = 0; /* peak scrambling, not in use */ + + attDegreeFrames = 0; move16(); + IF(sub(burst_len, burst_att_thresh) > 0) + { + att_always = 1; move16(); + /* increase degree of attenuation */ + + /* N.B. To facilitate the subsequent 10^(-att_degree/20) implementation + * so as to use direct table-lookup, + * the first (burstLen - burst_att_thresh) are NOT multiplied by "att_per_frame". */ + attDegreeFrames = sub(burst_len, burst_att_thresh); /* multiplied by 1.0 , */ + /* Furthermore, in order to minimize the size of the lookup-table required to + * implement 10^(-att_degree/10), hard limit attDegreeFrames to (30% of 100)=30. + * If attDegreeFrames is greater than 30, it means there are more than 30 successive + * bad frames. */ + if (sub(attDegreeFrames, OFF_FRAMES_LIMIT) > 0) + {/* Hard limit the no. of frames, for table lookup */ + attDegreeFrames = OFF_FRAMES_LIMIT; move16(); + } + } + + plc_phEcu_initWord16(alpha, 32767, MAX_LGW); + basop_memset(beta, 0, (MAX_LGW) * sizeof(Word16)); + IF(sub(burst_len, 1) <= 0) + { + *beta_mute = BETA_MUTE_FAC_INI; move16(); + *beta_mute = shr_pos(*beta_mute , 1); /* perceptual decrease */ + } + + IF(sub(burst_len, 1) <= 0) + { + L_pGrPowLeft = &L_gr_pow_left[0]; /* ptr init*/ + L_pGrPowRight = &L_gr_pow_right[0]; /* ptr init*/ + + fs_scale = xfp_wE_MDCT2FFTQ11[fs_idx]; move16(); + scale_sh = 4; /* 15-11 */ move16(); + /* L_*old_xfp_w_E_fx, always upscaled to max from the calculating function */ + + + L_oold_tmp = Mpy_32_16_lc3plus(L_oold_xfp_w_E_fx, fs_scale); + L_old_tmp = Mpy_32_16_lc3plus(L_old_xfp_w_E_fx, fs_scale); + + oold_exp_fx = add(oold_Ltot_exp_fx, scale_sh); + old_exp_fx = add(old_Ltot_exp_fx, scale_sh); + + /*re-normalize L_mantissas and adjust exps */ + margin_oold = norm_l(L_oold_tmp); + L_oold_tmp = L_shl_pos(L_oold_tmp, margin_oold); + oold_exp_fx = sub(oold_exp_fx, margin_oold); + + margin_old = norm_l(L_old_tmp); + L_old_tmp = L_shl_pos(L_old_tmp, margin_old); + old_exp_fx = sub(old_exp_fx, margin_old); + + /* now time to analyze how the actual L_tot exponent scaling should be done */ + /* bring up the lowest exp to the same exp as the higher exp, and scale down the corresponding mantissa */ + exp_diff = sub(old_exp_fx, oold_exp_fx); /* energy increase from oold to old in log2 shifts */ + + /* Overflow2 fix */ + exp_diff = s_max(-31, exp_diff); + exp_diff = s_min(31, exp_diff); + if (exp_diff > 0) + { /* oold_exp < old_exp */ + /* old_exp is limiting, shift down oold mantissa */ + L_oold_tmp = L_shr_pos(L_oold_tmp, exp_diff); + } + if (exp_diff < 0) + { /* oold_exp > old_exp */ + /* oold_exp is limiting, shift down old mantissa */ + L_old_tmp = L_shr_pos(L_old_tmp, negate(exp_diff)); + } + oold_exp_fx = s_max(oold_exp_fx, old_exp_fx); + old_exp_fx = oold_exp_fx; move16(); + + /* safety set lowest energy to 2 , as one bit is shifted away in avg calculation */ + L_oold_tmp = L_max(L_oold_tmp, 2L); + L_old_tmp = L_max(L_old_tmp, 2L); + + FOR(k = 0; k < Lgw; k++) /* NB Lgw may be shorter than all defined bands , e.g at at 48k */ + { + L_gr_pow_left[k] = Mpy_32_16_lc3plus(L_oold_tmp, oold_grp_shape_fx[k]); move32(); + L_gr_pow_right[k] = Mpy_32_16_lc3plus(L_old_tmp, old_grp_shape_fx[k]); move32(); + + /*Xavg[k] = sqrt(0.5f*(gr_pow_left[k]+gr_pow_right[k])/(float)(gw[k+1]-gw[k]));*/ + Xavg_exp_fx = sub(old_exp_fx, 1); /* virtual pre divide X_avg by 2 too keep precision in summation */ + L_acc = L_add(L_shr_pos(L_gr_pow_left[k], 1), L_shr_pos(L_gr_pow_right[k], 1)); + L_acc = L_shr_pos(L_acc, gw_len_inv_shift_fx[k]); /* divide by (bandwidth/2) in bins */ + + { /* new Xavg_fx calculation */ + L_acc = L_max(L_acc, 1L); + tmp = norm_l(L_acc); + Xavg_exp_fx = sub(Xavg_exp_fx, tmp); + L_acc = L_shl_pos(L_acc, tmp); /* now between 0.5 an 1.0*/ + + expo_in = add(Xavg_exp_fx, 0); + man_in = round_fx_sat(L_acc); + + /* now allow both positive and negative expos into sqrt */ + man = sqrt2ndOrder(man_in); + if (s_and(expo_in, 1) != 0) + { + man = mult_r(man, FEC_HQ_ECU_ROOT2); /* odd exp operation */ /* 1/sqrt(2) */ + } + expo = shr_r(expo_in, 1); /* apply even part of exp , square root operation. shr_r needed for positive side exps */ + + + + L_acc = L_deposit_h(man); + Xavg_exp_fx = add(expo, 0); + /*Note: sqrt approximaton may overshoot e.g- sqrt(1.0) may become 1.0001 i.e. saturation is needed when eventually applying expo */ + + + /* Xavg (unscaled flt in L_acc*2^(exp-31)) needs to be saved in the same scale + Q as the stored 16bit + * Xsav_fx, for use in subst_spec() */ + /* move Xavg fft scale to fx domain fx-fft scale*/ + L_acc = Mpy_32_16_lc3plus(L_acc, PhEcu_Xsav_Flt2FxScaleQ15[fs_idx]); /* fs fixed fractional change */ + Xavg_mod_exp_fx = sub(Xavg_exp_fx, PhEcu_Xsav_Flt2FxDnShift[fs_idx]); /* fs fixed exp change*/ + Xavg_mod_exp_fx = add(Xavg_mod_exp_fx, Q_spec); /* signal adaptive exp change*/ + + /* :: move to Q_spec domain of Xsav , Q fixed in first BFI frames */ + + /* extract Q0 value shift so that the mantissa is in the high part with man*2,^(0-15) */ + exp_diff = sub(15, Xavg_mod_exp_fx); + + + exp_diff = s_min(31, exp_diff); /* limit to meaningfull DSP shifts as described by up to 6 bits */ + exp_diff = s_max(-32, exp_diff); + if (exp_diff > 0) + { + L_acc = L_shr_pos(L_acc, exp_diff); /* may underflow */ + } + + if (exp_diff < 0) + { + L_acc = L_shr_sat(L_acc, exp_diff); + } +#ifdef CR8_A_PLC_FADEOUT_TUNING + L_Xavg[k] = L_acc; /* export full 31 bit scale band amplitude */ +#endif + Xavg[k] = round_fx_sat(L_acc); /* extract high part */ + + } /*end of new Xavg_fx calculation */ + /* internal transition detection */ + + { /* pure percentage based transient detection */ + thresh_tr_rise_lin_Q15 = PhEcu_frac_thr_rise_lin_Q15[k]; + thresh_tr_decay_lin_Q15 = PhEcu_frac_thr_decay_lin_Q15[k]; + + /* analyse rise */ + /* one of L_left or L_right should be pre-upshifted to a near max mantissa, (in one band ) */ + L_tmp2 = L_deposit_h(0); + L_tmp = Mpy_32_16_lc3plus(*L_pGrPowRight, thresh_tr_rise_lin_Q15); + if (L_sub(*L_pGrPowLeft, L_tmp) <= 0) + { + L_tmp2 = L_deposit_l(1); + } + + if (*L_pGrPowLeft == 0) /* denominator zero special cases */ + { + /* rise: Right/Left ; " * / 0 " --> tr_rise=1 ; "0/0" --> tr_rise = 0 */ + L_tmp2 = L_min(*L_pGrPowRight, 1L); + } + tr_rise[k] = extract_l(L_tmp2); move16(); + + /* analyse decay */ + L_tmp2 = L_deposit_h(0); + L_tmp = Mpy_32_16_lc3plus(*L_pGrPowLeft, thresh_tr_decay_lin_Q15); + if (L_sub(L_tmp, *L_pGrPowRight) >= 0) + { + L_tmp2 = L_deposit_l(1); + } + if (*L_pGrPowRight == 0) /* right side no energy , special cases */ + { + /* decay: Right/Left ; " 0 / * " --> tr_decay=0 ; "0/0" --> tr_decay = 0 */ + L_tmp2 = L_deposit_h(0); + } + tr_decay[k] = extract_l(L_tmp2); move16(); + + tr_dec[k] = s_max(tr_rise[k], tr_decay[k]); move16(); + + } /* percentage tr_dec */ + /* magnitude modification, calculated for decay only */ + IF(add(tr_dec[k], att_always) != 0) + { + +#if MAX_INCREASE_GRPPOW_FX != 0 +#error trans_burst_ana_fx-- The following implementation is incorrect +#endif + att_val = 32767; move16(); + IF(L_sub(*L_pGrPowRight, 0) > 0) + { + IF(L_sub(*L_pGrPowRight, *L_pGrPowLeft) < 0) /* decay , i.e., (gr_pow_right/gr_pow_left) < 1.0 */ + { + /* Compute sqrt(grp_pow_chg), where grp_pow_chg = gr_pow_right/gr_pow_left. */ + tmp16 = plc_phEcu_ratio_fx(*L_pGrPowRight, *L_pGrPowLeft, &expo); /* output tmp16 in Q14 */ + + expo = sub(expo, (15 - 14)); /* Now, tmp16 is considered in Q15 */ + i = norm_s(tmp16); + man = shl_pos(tmp16, i); /* Mandatory normalization before sqrtNthOrder(). */ + expo = add(expo, i); + man = sqrt2ndOrder(man); + if (s_and(expo, 1) != 0) /* Check even or odd. */ + { + man = mult_r(man, FEC_HQ_ECU_ROOT2); + } + expo = shr_pos(expo, 1); /* Divided by 2-- square root operation. */ + att_val = shr(man, expo); /* Denormalize the mantissa back to Q15. */ + } + /* ELSE + { + do nothing because (gr_pow_right/gr_pow_left) >= 1.0 + } + */ + } + + mag_chg_1st[k] = att_val; move16(); + mag_chg[k] = att_val; move16(); + } + ELSE + { + mag_chg_1st[k] = 32767; move16(); + mag_chg[k] = 32767; move16(); /* Set to ]1.0 in Q15 */ + } + + L_pGrPowLeft++; + L_pGrPowRight++; + } /* FOR band k */ + } + ELSE /* sub(burst_len, 1) <= 0) */ + { + /* BURST path */ + + /* Since attDegreeFrames is discrete (integer) and hard limited to OFF_FRAMES_LIMIT, + * it is easier to implement 10^(-att_degree/20.0) by a simply direct + * table-lookup. Also, att_per_frame is discrete as well and can be + * either ATT_PER_FRAME-1 or ATT_PER_FRAME and nothing else. This + * means only 2 tables of size=(OFF_FRAMES_LIMIT+1) each are required. + * To take square root into account, it is divided by 20 instead of 10. */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (sub(burst_len, beta_mute_thr) > 0) /* beta_mute_thr coincides/close to stronger 6dB muting phase */ + { + *beta_mute = shr_pos_pos(*beta_mute, 1); + } +#endif + + + FOR(k = 0; k < Lgw; k++) /* Lgw may be shorter than all bands at 48k */ + { + /* global burst attenuation */ + #if PLC2_FADEOUT_IN_MS != 0 + #ifdef CR8_A_PLC_FADEOUT_TUNING + /* att_per_frame idx = "1:12") */ +#else + /* att_per_frame idx = "1:10") */ +#endif + att_val = POW_ATT_TABLES[att_per_frame][s_min(OFF_FRAMES_LIMIT, attDegreeFrames)]; move16(); +#else + /* att_per_frame idx = "1:2") */ + att_val = POW_ATT_TABLES[att_per_frame][s_min(OFF_FRAMES_LIMIT, attDegreeFrames)]; move16(); + /* 10^(-attDegreeFrames*(att_per_frame = "1 or 2")/20) */ +#endif + + mag_chg[k] = mult_r(mag_chg_1st[k], att_val); /* Q15 */ + +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (sub(burst_len, BETA_MUTE_THR) > 0) /* BETA_MUTE_THR ~= (5+15) coincides/close to stronger 6dB muting phase */ + { + *beta_mute = shr_pos_pos(*beta_mute, 1); + } +#endif + alpha[k] = mag_chg[k]; move16(); + ASSERT(beta[k] == 0); /* initialization required */ + IF(sub(alpha[k], 32766) < 0) + { + /* beta_pre[k] = sqrt(1.0f - SQR(alpha[k])); */ + /* beta[k] = beta_pre[k]* *beta_mute;*/ + /* (1.0-alpha.^2), in exp 1 due to L_mult0; */ + + L_acc = L_sub((INT32_MAX >> 1) + 1, L_mult0(alpha[k], alpha[k])); + { + + /* use lower complex(WMOPS/ROM) 2nd-order sqrt approximation */ + Word32 L_man, L_acc2 = L_acc; + Word16 tmp, expo_in, expo2, man_in, man; + /* updated code using the 2nd order approximation routine */ + /* form is flt=(L_acc2*2.^(-31 + 1) */ + + tmp = norm_l(L_acc2); /* tmp is always 1 or higher due to Lmac0 downshift */ + man_in = round_fx_sat(L_shl_pos(L_acc2, tmp)); + expo_in = sub(1, tmp); /* 1 due to original 1 bit margin gain in L_mult0 */ + + /* both positive and negative expos into sqrt */ + man = sqrt2ndOrder(man_in); + if (s_and(expo_in, 1) != 0) + { + man = mult_r(man, FEC_HQ_ECU_ROOT2); /* odd exp operation */ /* sqrt(2)/2 */ + } + + expo2 = shr_r(expo_in, 1); /* apply square root operation. shr_r needed for pos and neg exps */ + ASSERT(expo2 <= 1); + + L_man = L_deposit_h(man); + L_man = L_shl_sat(L_man, expo2); /* move to a zero exp , _sat needed for 1.0 input (due to approximation overshoot) */ + + man = round_fx_sat(L_man); /* better perf with round here */ + + + beta[k] = mult_r(*beta_mute, man); move16(); + } + + /* bw Lowpass shape additive component */ + /* tab[LGW48K + 1] = { 1.0, ....1.0, 0.5,0.5, ... 0.1, 0.1 } */ + + IF(sub(k, LGW32K - 1) >= 0) + { + beta[k] = mult_r(beta[k], 3277); /* 0.1 in Q15 */ + } + ELSE IF(sub(k, LGW16K - 1) >= 0) + { + beta[k] = mult_r(beta[k], 16384); /* 0.5 in Q15 */ + } + + /* + % limit Xavg noise contribution further in case of offset/tr_decay + % attenuation was already active + + if (burst_len <= burst_att_thresh) && ( stPhECU_mag_chg_1st(k) < (32766/32768) ) + XavgFadeinFactor = (burst_len-1)/burst_att_thresh; + XavgFadeinFactor = min(1.0, XavgFadeinFactor); + beta(k) = beta(k)*XavgFadeinFactor; + % limit initial Xavg noise contribution until We have reached regular burst attenuation + end + end + */ + IF( sub(mag_chg_1st[k], 32767) <0 ) + { /* offset muting was started before burst muting phase */ + /* Xavg noise gradually increased during a short period */ + Word16 XavgFadeinFactor = 32767; + Word16 ratio2_3_4_5tab[4][5 - 1] = { + {(Word16)(.5 * 32768.0), (Word16)(1.0 * 32767.0), (Word16)(1.0 * 32767.0), (Word16)(1.0 * 32767.0)}, /* 1/2*/ + {(Word16)(.333 * 32768.0), (Word16)(.666 * 32768.0), (Word16)(1.0 * 32767.0), (Word16)(1.0 * 32767.0)}, /* 1/3*/ + {(Word16)(.25 * 32768.0), (Word16)(.5 * 32768.0), (Word16)(.75 * 32768.0), (Word16)(1.0 * 32767.0)}, /* 1/4 */ + {(Word16)(.2 * 32768.0), (Word16)(.4 * 32768.0), (Word16)(.6 * 32768.0), (Word16)(.8 * 32768.0)} /* 1/5 */ + + }; + ASSERT(burst_att_thresh >= 1 && burst_att_thresh <= 5); + ASSERT(burst_len >= 2); + if (sub(burst_len,burst_att_thresh) <= 0) + { + ASSERT(burst_len - 2 < (5-1)); + ASSERT(burst_att_thresh-1-1 < (4)); + XavgFadeinFactor = ratio2_3_4_5tab[burst_att_thresh-1-1][burst_len - 2]; /* second bfi frame burst_len= is 2 */ + } + beta[k] = mult_r(beta[k], XavgFadeinFactor); /* n Q15 */ + } + } /* IF (sub(alpha[k], 32766) < 0) */ + } /* FOR k*/ + + } /* BURST */ + + + + IF(sub(output_frame, L_FRAME48K) == 0) + { /* for 48kHz set/handle scalings of last group/band the same way as previous lower freq band(s) */ + + FOR(k = Lgw; k < MAX_LGW; k++) + { + tr_dec[k] = tr_dec[k - 1]; move16(); /* only available in first bfi frame */ + Xavg[k] = Xavg[k - 1]; move16(); + mag_chg_1st[k] = mag_chg_1st[k - 1]; move16(); + mag_chg[k] = mag_chg[k - 1]; move16(); + alpha[k] = alpha[k - 1]; move16(); + beta[k] = beta[k - 1]; move16(); + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} + +/*----------------------------------------------------------------------------- + * imax_fx() + * + * Get interpolated maximum position + *-----------------------------------------------------------------------------*/ +static Word16 imax_fx( /* o: The location, relative to the middle of the 3 given data point, of the maximum. (Q15) */ + const Word16 *y, /* i: The 3 given data points. */ + const Word16 special /* i: -1 = left edge special case, 0 = normal, +1 = right edge special case */ +) +{ + Word16 posi; + Word16 man, expo, edge; + const Word16 *pY; + Word32 L_y1, L_y2, L_y3, L_numer, L_denom, L_sign, L_acc, L_y3_y1; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("imax_fx", sizeof(struct { + Word16 posi; + Word16 man, expo, edge; + const Word16 *pY; + Word32 L_y1, L_y2, L_y3, L_numer, L_denom, L_sign, L_acc, L_y3_y1; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::imax_fx"); +#endif + + /* Seek the extremum of the parabola P(x) defined by 3 consecutive points + so that P([-1 0 1]) = [y1 y2 y3] */ + pY = y; + L_y1 = L_deposit_l(*pY++), L_y2 = L_deposit_l(*pY++), L_y3 = L_deposit_l(*pY); + + /* The extremum value: + * y2i = -0.125f * SQR(y3_y1) / (y1+y3-2*y2)+y2 + * is not computed. Alternatively, the derivative of the parabola evaluated at y=0, + * dP/dy|y=0, is used to determine whether the extremum is maximum or not. + */ + + /* Compute the extremum location: posi = (y3 - y1)/(4*y2 - 2*y1 - 2*y3). */ + L_y3_y1 = L_sub(L_y3, L_y1); + L_acc = L_shl_pos(L_y2, 1); /* N.B. y2 is multiplied by 2 not 4. */ + L_acc = L_sub(L_acc, L_y1); /* N.B. Y1 is not multiplied by 2. */ + L_denom = L_sub(L_acc, L_y3); /* N.B. Y3 is not multiplied by 2. */ + L_sign = L_xor(L_y3_y1, L_denom); /* Preserve the sign since div_s() only takes positive arguments. */ + L_numer = L_abs(L_y3_y1); + L_denom = L_abs(L_denom); + + test(); + IF(L_numer == 0 || L_denom == 0) + { + posi = 0; move16(); /* flat top , exit with center freq. */ + } + ELSE + { + + IF(L_sub(L_denom, L_shr_pos_pos(L_numer, 1)) > 0) + { + /* Although the output of ratio() is in Q14, adding the missing factor of 2 (See above) + * in the denominator, the output is now considered to be in Q15. */ + man = plc_phEcu_ratio_fx(L_numer, L_denom, &expo); /* The mantissa is considered in Q15 */ + + posi = shr_sat(man, expo); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ + } + ELSE + { + posi = 0x7fff; move16(); + } + + if (L_sign < 0) /* Restore the sign. */ + { + posi = negate(posi); + } + + /* For both edges (left and right), the extremum found above may be minimum. + * It needs to reject the minimum. */ + IF(special != 0) /* Either edge special case. */ + { + edge = 0x7fff; /* 1 in Q15 for the right edge special case */ move16(); + if (special < 0) + { + edge = 0; /* Left edge special case */ move16(); + } + + /* The derivative (slope) of the interpolating parabola = 2*A*y + B, + * where A = (y3 + y1)/2 - y2 + * and B = (y3 - y1)/2. + * Therefore, the slope at y=0 is simply B. Use this slope to determine + * if the parabola is concave upward or downward. + */ + IF(posi > 0) /* The extremum is in between the middle and the right given data points. */ + { + posi = sub(0x7fff, posi); /* maximum case */ + if (L_sub(L_y3, L_y1) <= 0) /* Check the slope at y=0, i.e., at the middle given data point. */ + { + posi = edge; /* minimum case */ move16(); + } + } + ELSE /* The extremum is in between the left and the middle given data points. */ + { + posi = add(0x7fff, posi); /* maximum case */ + if (L_sub(L_y3, L_y1) >= 0) + { + posi = edge; /* minimum case */ move16(); + } + } + } + } +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return posi; + /* Q15. The position either left or right relative to the index of the middle of the 3 given data points. */ +} + + /*----------------------------------------------------------------------------- + * spec_ana_fx() + * + * Spectral analysis + *-----------------------------------------------------------------------------*/ + /* OPT add the FB transient input flags , and skip peakfinder if fullband transient is set */ + void spec_ana_fx(Word16 * xfp, /* i/o : Input 16ms pre-upscaled time signal, output xfp utility buffer */ + Word16 * plocs, /* o : The indicies of the identified peaks Q0 */ + Word32 * L_plocsi, /* o : Interpolated positions of the identified peaks Q16 */ + Word16 * num_plocs, /* o : Number of identified peaks Q0 */ + Word16 * X_sav, /* o : Stored fft spectrum */ + const Word16 output_frame, /* i : Frame length Q0 */ + const Word16 bwidth_fx, /* i : Encoded Fs index Q0 */ + const Word16 *sp_ana_win, /* i : spectral analysis window Q15 */ + const Word16 f0hzLtpBinQ7, /* i : LTP bin frequency in normalized Hz Q7 */ + const Word16 norm_corrQ15_fx, /* i : correlation for lag at f0hzLtpBinQ7 */ + Word16 maxLprot, Word16 maxPlocs, + Word8 *scratchBuffer /* Size = 4 * (MAX_LPROT + MAX_LPROT_RED + 1) + 2 * MAX_PLOCS */ + ) + { + Counter n, k; + Word16 nJacob, Lprot, hamm_len2 = 0, Lprot2, Lprot2p1; + Word32 *L_xfp; + + Word16 *pXfp; + Word16 *pPlocs; + Word16 Xmax, Xmin, sens; + Word16 rectLength, fraction; + Word32 *pPlocsi_L; + Word32 L_acc; + Word16 peak_range_1; + Word16 stop_band_start; + Word16 stop_band_length; + Word16 fft_scale; + Word8 * buffer_fft; + Word16 currPlocs, endPlocs; + Word16 P_in_plocs; + Word16 n_real_interp_tail; + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::spec_ana_fx(1st)"); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_In("spec_ana_fx", sizeof(struct { + Counter n, k; + Word16 nJacob ,Lprot, hamm_len2, Lprot2, Lprot2p1; + Word32 *L_xfp; + Word32 *pXfp_L; + Word16 *y_re_ptr, *y_im_ptr; /* otrs to Xsav as xfp was overwritten */ + Word16 *pXfp, *pXfp1, *pPlocs; + Word16 Xmax, Xmin, sel; + Word16 rectLength, fraction, special; + Word32 *pPlocsi_L; + Word32 L_acc; + Word16 peak_range_1; + Word16 stop_band_start; + Word16 stop_band_length; + Word16 fft_scale; + Word8 * buffer_fft; + Word16 fft_scale_by4; + Word16 currPlocs, endPlocs; + Word16 P_in_plocs; + Word16 n_real_interp_tail; + })); +#endif + /* Initialize for 48k to avoid warnings + Lprot - length of saved prototype samples + hamm_len2 - half Hamming window length + pFftTbl - Table for real input FFT + LprotLog2Minus1 - FFT stages for complex input FFT + */ + + + L_xfp = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LPROT bytes */ + buffer_fft = scratchAlign(L_xfp, sizeof(*L_xfp) * maxLprot); /* Size = 4 * (MAX_LPROT_RED + 1) + 2 * MAX_PLOCS */ + + ASSERT(bwidth_fx >= 0 && bwidth_fx <= 4); /* avoid bwidth_fx variable warning */ + + Lprot = LprotSzPtr[bwidth_fx]; + move16(); + hamm_len2 = DEPR_i_mult(3, mult(output_frame, (Word16)(3277) /* divBy10 + floor */)); /* 3 ms */ + fft_scale = PhEcuFftScale[bwidth_fx]; + move16(); /* 32,16,8 kHz all have fft scale 0, 24 has 8, 48 has 4 */ + Lprot2 = shr_pos(Lprot, 1); + Lprot2p1 = add(Lprot2, 1); /* Magnitude lengths */ + rectLength = sub(Lprot, shl_pos(hamm_len2, 1)); + /* The length of the rectangular portion of the Hamming-Rectangular window. */ + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::WhrAnaWin+fft"); +#endif + + /* Apply hamming-rect window */ + windowing_L(xfp, L_xfp, sp_ana_win, rectLength, hamm_len2); + BASOP_rfftN(L_xfp, Lprot, &fft_scale, buffer_fft); + } +#ifdef WMOPS + BASOP_sub_sub_end(); /* anawin+fft */ +#endif + + /* Convert 32 Bit intlv FFT into phecu 16 bit flipped fft format */ + /* can not yet be an inplace operation */ + + intlvW32_2_flippedW16(L_xfp, sub(Lprot2, 1), Lprot, xfp); + + /* Apply zeroing of non-coded FFT spectrum above 20 kHz */ + IF(sub(output_frame, ((L_FRAME48K) * 40) / 48) >= 0) /* only relevant for 48kHz in LC3plus */ + { + stop_band_start = ((LPROT48K / 2) * 40) / 48; /* initial start position in real part , 320 */ + stop_band_length = ((LPROT48K * 8) / 48) - 1; /* real tail and into Im parts , 128-1 */ + stop_band_start = add(stop_band_start, 1); /* exclude DC ... */ + + basop_memset(xfp + stop_band_start, 0, (stop_band_length) * sizeof(Word16)); + } + + peak_range_1 = s_min(Lprot2p1, MAX_LPROT_RED / 2 + 1); /* limit preliminary only active for 48k to save WMOPS */ + + basop_memmove(X_sav, xfp, (Lprot) * sizeof(Word16)); + + /* Magnitude representation */ + fft_spec2_sqrt_approx_fx(xfp, xfp, Lprot); + /* inplace, i.e. [ Dc, real part of xfp ,Fs/2 ] will be replaced by magnitude(scaled by .5) */ + + /* Find global maximum and minimum. */ + plc_phEcu_maxval_fx(xfp, peak_range_1, &Xmax); + plc_phEcu_minval_fx(xfp, peak_range_1, &Xmin); + sens = mult_r(sub(Xmax, Xmin), CMPLMNT_PLOC_SENS_FX); + + + plc_phEcu_peak_locator_fx(xfp, peak_range_1, plocs, num_plocs, sens, Xmax, Xmin, MAX_LPROT_RED, buffer_fft); + + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::Peaks_refine"); +#endif + + /* Refine peaks */ + pPlocsi_L = L_plocsi; + pPlocs = plocs; + /* n = sub(*num_plocs, 1); */ /* -1 so as to exclude the very last peak. */ + n = *num_plocs; /* number of peaks to process */ + /* Special case-- The very 1st peak if it is at 0 index position (DC) */ + /* With DELTA_CORR_F0_INT == 2 one needs to handle both *pPlocs==0 and *pPlocs==1 */ + logic16(); + IF((n > 0) && (sub(*pPlocs, 0) == 0)) /* Very 1st peak position possible to have a peak at 0/DC index position. */ + { + fraction = imax_fx(xfp, -1); /* -1 signifies special left edge case. */ + L_acc = L_deposit_h(*pPlocs++); /* N.B., (*pPlocs) must be zero here. */ + *pPlocsi_L++ = L_mac(L_acc, fraction, 1); move32(); /* in Q16 */ + n = sub(n, 1); /* This special case is taken care of -- one less peak to go */ + } + logic16(); + IF((n > 0) && (sub(*pPlocs, 1) == 0)) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */ + { + fraction = imax_fx(xfp, 0); /* for parabolic this is not a special case. */ + L_acc = L_deposit_h(*pPlocs++); /* N.B., (*pPlocs) must be 1 here. */ + *pPlocsi_L++ = L_mac(L_acc, fraction, 1); move32(); /* in Q16 */ + n = sub(n, 1); /* This special case is taken care of -- one less peak to go */ + } + + /* All remaining peaks except the very last two possible integer positions */ + currPlocs = *pPlocs++; move16(); + endPlocs = sub(Lprot2p1, DELTA_CORR_F0_INT); /* last *pPlocs position for Jacobsen */ + + /* precompute number of turns based on endpoint integer location and make into a proper FOR loop */ + IF(n > 0) + { + nJacob = n; move16(); + + /* catch all three xxx01 , xxx10 and xxx11 , + and not only xxx01, xxx10 */ + + n_real_interp_tail = 0; move16(); + if (sub(endPlocs, plocs[sub(*num_plocs, 1)]) <= 0) + { + n_real_interp_tail = add(n_real_interp_tail, 1); + } + + logic16(); + if (sub(n,1) > 0 && sub(endPlocs, plocs[sub(*num_plocs, 2)]) <= 0) + { + n_real_interp_tail = add(n_real_interp_tail, 1); + } + + nJacob = sub(nJacob, n_real_interp_tail); + + FOR (k = 0; k < nJacob; k++) + { + fraction = imax2_jacobsen_mag_fx(&(X_sav[currPlocs - 1]), &(X_sav[Lprot - 1 - currPlocs]), 0); /* in Q15 */ /* not endpoint */ + move16(); move16(); /* account for inloop indirect ptrs into Xsav */ + + L_acc = L_deposit_h(currPlocs); + *pPlocsi_L++ = L_mac(L_acc, fraction, 1); move32(); /* in Q16. Append the fractional part to the integral part. */ + currPlocs = *pPlocs++; move16(); + } + n = sub(n, nJacob); + } + + /* At this point there should at most two plocs left to process */ + /* the position before fs/2 and fs/2 both use the same magnitude points */ + + IF(n > 0) + { + /* [ . . . . . . . ] Lprot/2+1 positions */ + /* | | | */ + /* 0 (Lprot/2-2) (Lprot/2) */ + + pXfp = xfp + sub(Lprot2, 2); + IF(sub(currPlocs, sub(Lprot2p1, DELTA_CORR_F0_INT)) == 0) + /* Also 2nd last peak position uses fs/2 which makes jacobsen less suitable. */ + { + fraction = imax_fx(pXfp, 0); /* for parabolic this is not a special case. */ + + L_acc = L_deposit_h(currPlocs); /* N.B., (*pPlocs) must be 1 here. */ + *pPlocsi_L++ = L_mac(L_acc, fraction, 1); move32(); /* in Q16 */ + currPlocs = *pPlocs++; move16(); + n = sub(n, 1); /* This special case is taken care of -- one less peak to go */ + + if (n > 0) + { + /* allow for an additional consecutive final plocs after (Fs/2-1) at Fs/2 */ + currPlocs = *pPlocs++; move16(); + } + } + + /* Here the only remaining point would be a fs/2 plocs */ + /* pXfp = xfp + sub(Lprot2,1); already set just a reminder where it whould point */ + IF(n > 0) /* fs/2 which makes special case . */ + { + fraction = imax_fx(pXfp, 1); /* for parabolic this is a special case. */ + + L_acc = L_deposit_h(currPlocs); /* N.B., (*pPlocs) must be 1 here. */ + *pPlocsi_L++ = L_mac(L_acc, fraction, 1); move32(); /* in Q16 */ + currPlocs = *pPlocs++; move16(); + n = sub(n, 1); /* This special case is taken care of -- one less peak to go */ + } + } + + /* here n should be 0 if all peaks have been processed */ + ASSERT(n == 0); + + /* Check number of plocs within an assumed pitch range */ + P_in_plocs = 0; move16(); + FOR(n = 0; n < *num_plocs; n++) + { + /* count number of peaks in locations 1,2,3,4,5,6 , ~= 60 Hz ... 380 Hz */ + fraction = s_min(1, plocs[n]); /* 0 stays zero , otherwise 1 */ + if (sub(plocs[n], 7) < 0) + { + P_in_plocs = add(P_in_plocs, fraction); + } + } + +#ifdef WMOPS + BASOP_sub_sub_end(); /* peaks refine */ +#endif + + logic16(); + IF(f0hzLtpBinQ7 > 0 && P_in_plocs > 0) + { + Word16 n_plocs_in, n_plocs_out; + + n_plocs_in = *num_plocs; move16(); + + /* NB LF peak analysis may add adjacent peaks in { plocs, L_plocsi}, (output from peakfinder did not have + * adjacent peaks ) */ + plc_phEcu_LF_peak_analysis_fx(plocs /* i/o */, num_plocs /* i/o */, L_plocsi /* i/o */, xfp, f0hzLtpBinQ7, + norm_corrQ15_fx, 2, maxPlocs, buffer_fft); + n_plocs_out = *num_plocs; move16(); + + IF(sub(n_plocs_in, n_plocs_out) == 0) + { + /* adjust first peak coinciding with LTPF0 measures if it indicates so */ + plc_phEcu_F0_refine_first_fx(plocs /* i/o */, *num_plocs, L_plocsi /* i/o */, f0hzLtpBinQ7, norm_corrQ15_fx, + 3); + } + } + /* moved inside spec_ana_fx , to include validated pitch peak P_in_plocs*/ + { + Word16 peak_limits_fx[5] = { 14 /*NB*/, 14 /*WB*/, 14 /*sWB*/, 14 /*SWB*/, + 14 /* FB */ }; /* to be trained for each BW */ + + test(); + test(); + IF((sub(norm_corrQ15_fx, 0) > 0) && /* == 0 indicates a negative correlation, which could be likely stable */ + (sub((Word16)(0.5 * 32768), norm_corrQ15_fx) > 0) && (sub(*num_plocs, peak_limits_fx[bwidth_fx]) > 0)) + { + if (P_in_plocs > 0) + { + *num_plocs = 0; move16(); /*activate noise only path only if normcorr vas valid energywise */ + } + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + /*-------------------------------------------------------------------* + * subst_spec_fx() + * + * Substitution spectrum calculation + *-------------------------------------------------------------------*/ + + void subst_spec_fx( + const Word16 *plocs, /* i : The indices of the identified peaks Q0 */ + const Word32 *L_plocsi, /* i : Interpolated positions of the identified peaks Q16 */ + Word16 * num_plocs, /* i/o : Number of identified peaks Q0 */ + const Word16 time_offs, /* i : Time offset Q0 */ + Word16 * X, /* i/o : FFT spectrum */ + const Word16 *mag_chg, /* i : Magnitude modification Q15 */ + const Word16 ph_dith, /* i : Phase dither, 2*PI is not included. (Q15, i.e., between 0.0 and 1.0) */ + const Word16 *is_trans, /* i : (Transient) noise generation flags (either 0 or not 1 ) */ + const Word16 output_frame, /* i : Frame length Q0 */ + Word16 * seed, /* i/o : Random seed */ + const Word16 *alpha, /* i : Magnitude modification factors for fade to average Q15 */ + const Word16 *beta, /* i : Magnitude modification factors for fade to average Q15 */ + const Word16 *Xavg, /* i : Frequency group averages to fade to Q0 */ + const Word16 t_adv /* i : time adjustement excluding time_offs Q0 */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,const Word16 fadeout, /* need for DC muting */ + Word16 * nonpure_tone_flag_ptr, /* i/o : non-pure single tone indicator state */ + const Word32 * L_Xavg /* i : Frequency group amp averages for tonal tilt analysis Max upshifted */ +#endif + ) + { + Word16 Xph_short; + Word32 L_corr_phase[MAX_PLOCS], L_Xph; + Word32 *pCorrPhase_L; + Word16 cos_F, sin_F, tmp; + Word16 peak_sin_F = 0, peak_cos_F = 0; + Word16 sin_F_fade2avg, cos_F_fade2avg; + Word16 fs_idx; + Word16 Lprot, m, i, e, im_ind, delta_corr_up, delta_corr_dn, delta_tmp; + UWord16 lsb; + Word16 j, re, im, *pReX, *pImX, lastPeak, lprotBy2Minus1, segmentLen; + Word16 pkLocation_1, pkLocation, pkLocation1; + const Word16 *pPlocs; + const Word32 *pPlocsi_L; + Word32 L_acc; + Word16 Lprot_inv; + Word16 k; + Word16 tmp2; + Word16 alpha_local; + Word32 tmp_L; + Word16 mag_chg_local; + const Word16 *gwlpr_fxPlus1; + Word16 one_peak_flag_mask; + Word16 noise_mag_scale_neg; + Word16 up_shift_adj; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("subst_spec_fx", sizeof(struct { + Word16 Xph_short; + Word32 L_corr_phase[MAX_PLOCS], L_Xph; + Word32 *pCorrPhase_L; + Word16 cos_F, sin_F, tmp; + Word16 peak_sin_F, peak_cos_F; + Word16 sin_F_fade2avg, cos_F_fade2avg; + Word16 fs_idx; + Word16 Lprot, m, i, e, im_ind, delta_corr_up, delta_corr_dn, delta_tmp; + UWord16 lsb; + Word16 j, re, im, *pReX, *pImX, lastPeak, lprotBy2Minus1, segmentLen; + Word16 pkLocation_1, pkLocation, pkLocation1; + const Word16 *pPlocs; + const Word32 *pPlocsi_L; + Word32 L_acc; + Word16 Lprot_inv; + Word16 k; + Word16 tmp2; + Word16 alpha_local; + Word16 expo; + Word32 tmp_L; + Word16 mag_chg_local; + const Word16 *gwlpr_fxPlus1; + Word16 one_peak_flag_mask; + Word16 noise_mag_scale_neg; + Word16 up_shift_adj; + })); +#endif + + if (time_offs == 0) + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::subst_spec_fx(1st)"); +#endif + } + else + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::subst_spec_fx(N)"); +#endif + } + + + gwlpr_fxPlus1 = &(gwlpr_fx[1]); /* ptr init */ + fs_idx = mult(output_frame, (Word16)(32768.0 / 99.0)); /* truncation needed , i.e no rounding can be applied here */ + ASSERT(fs_idx == (output_frame / 100)); + Lprot = LprotSzPtr[fs_idx];move16(); + Lprot_inv = InvLprot_Q22[fs_idx]; move16(); + + tmp2 = add(mult_r(time_offs, oneOverFrameQ15Tab[fs_idx]), 1);/* save a local burst_len for securing DC and fs/2 muting */ + + /* Correction/evolution phase of the identified peaks */ + IF(s_or(is_trans[0], is_trans[1]) != 0) + { + *num_plocs = 0; move16(); + } + ELSE + { + + tmp = t_adv; + + tmp = add_sat(tmp, time_offs); + /* NB tmp can be stored in Word16 Q0 as max used value is 684+(OFF FRAMELIMIT==60)*480 = 29484 */ + tmp_L = L_mult0(tmp, Lprot_inv); + + + tmp = norm_l(tmp_L); + up_shift_adj = s_max(0, sub(4, tmp)); /* 48kHz : PLC frame 1..49 -> tmp_L<<4 , frame 50..60 -> tmpL<<3 */ + tmp_L = L_shl_sat(tmp_L, sub(4, up_shift_adj)); + tmp = round_fx_sat( tmp_L); + + + pPlocsi_L = L_plocsi; + pCorrPhase_L = L_corr_phase; + FOR(m = 0; m < *num_plocs; m++) + { + + /* tmp has variable resolution 10 or 9 bits */ + ASSERT( up_shift_adj >= 0); + Mpy_32_16_ss(L_shl_pos(*pPlocsi_L++, up_shift_adj), tmp, &L_acc, &lsb); + L_acc = L_add(L_shl_pos(L_acc, 5), lshr(lsb, 11)); + /* 5 lsb's actually unused though, as 6 bits are shifted out */ + *pCorrPhase_L++ = L_acc; move32();/* in Q16. 2*PI is not included. */ + } + } + + one_peak_flag_mask = (Word16)0xFFFF; move16(); /* all ones mask -> keep */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + test(); logic16(); + IF((*num_plocs > 0) && sub(*num_plocs, 3) < 0) + { + one_peak_flag_mask = 0x0000; move16(); /* all zeroes mask -> zeroes in valleys, single clean tone assumed */ + + /* revert initial pure tone decision in some cases */ + logic16(); logic16(); + IF((sub(*nonpure_tone_flag_ptr, 0) < 0) && + ((sub(fs_idx, 2) == 0)/* SemiSWB 24 kHz */ || (sub(fs_idx, 4) >= 0)) /* FB 48 kHz */ + ) + { + /* in the first lost frame analyze spectra and spectral bands to possibly reverse an initial pure sine assumption */ + *nonpure_tone_flag_ptr = plc_phEcu_nonpure_tone_ana_fx(plocs, *num_plocs, X, L_Xavg, Lprot, fs_idx); + +#ifdef LOCAL_PLC2_TON_ANA_DEACTIVATE + *nonpure_tone_flag_ptr = 0; /* dbg of inactive tone analysis */ +#endif + } + + + if (sub(*nonpure_tone_flag_ptr, 0) > 0) + { + /* actually revert single pure tone detection */ /* 0-> mute all surrounding valley bins in evolution , 0xff -> generate noise in all valleys */ + one_peak_flag_mask = (Word16)0xFFFF; move16(); /* all ones mask -> keep */ + } + } +#else + logic16(); + if ((*num_plocs > 0) && sub(*num_plocs, 3) < 0) + { + one_peak_flag_mask = 0x0000; move16(); /* all zeroes mask -> zero */ + } +#endif + + + noise_mag_scale_neg = 0; move16(); /* no change of valley noise magnitude */ + logic16(); + if ((*num_plocs == 0) || (time_offs != 0)) + { /* only adj_scale noise amplitude when we have no WC path , or in all noise frame */ + noise_mag_scale_neg = -32768; move16(); /* all ones --> scale_noise */ + } + + IF(*num_plocs == 0) + { + X[0] = 0; move16(); /* reset DC if there are no peaks */ + X[shr_pos(Lprot, 1)] = 0; move16(); /* also reset fs/2 if there are no peaks */ + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + /* the binary selection of fadeout scheme */ + tmp = (PLC2_FADEOUT_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; move16(); + if (fadeout != 0) + { + tmp = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; move16(); + } + + IF(sub(tmp2, add(fade_scheme_tab_fx[tmp][1],1) ) > 0) +#else + IF(sub(tmp2, (BURST_ATT_THRESH+1)) > 0) +#endif + { + /* also start DC scaling attenuation */ + X[0] = mult(alpha[0], X[0]); move16(); + /* start fs/by2 attenuation */ + X[shr_pos(Lprot, 1)] = mult(alpha[s_min(add(fs_idx, LGW8K), LGW48K)], X[shr_pos(Lprot, 1)]); move16(); + } + + + lprotBy2Minus1 = sub(shr_pos(Lprot, 1), 1); + + /* for 48k the last (63+1+63) 128/2-1 values above 20 kHz are always zeroes */ + { /* after a last, peak no need to evolve above 20kHz , those coeffs have been/ will be zeroed already */ + /* DC, Xused,ReZeroed, fs/2, ImZeroed, ImUsed */ + /*N: 1, 320 , 63 , 1 , 63 , 320 */ + /*Cind: 0, 1-320, 321-383 , 384 , 385-447, 448 -767 */ + lprotBy2Minus1 = s_min( lprotBy2Minus1, 320); + /*only process up to bin X[320] , 63 coeffs X[321] fwd should already be zeroed */ + } + + i = 1; move16(); /* index in the X[DC, ReX part of X_Sav ,i.e *pReX == X[i] */ + k = 0; move16(); + + pReX = X + i; + im_ind = (Lprot - 1); /* ptr init */ + pImX = X + im_ind; + pPlocs = plocs; + pCorrPhase_L = L_corr_phase; + + + pkLocation_1 = -4; move16(); /* dummy value to avoid Out of Array Read */ + pkLocation = -3; move16(); /* dummy value to avoid Out of Array Read for the *num_plocs==0 case */ + pkLocation1 = -2; move16(); /* dummy value to avoid Out of Array Read */ + + IF (*num_plocs != 0) + { + + pkLocation = *pPlocs; move16(); /* N.B. No post-increment */ + lastPeak = sub(*num_plocs, 1); + if (lastPeak >= 0) + { + pkLocation1 = *pPlocs++; move16(); /* get a next peak */ + } + } + + FOR(m = 0; m < *num_plocs; m++) + { + pkLocation_1 = pkLocation; /* plocs[m - 1] */ move16(); + pkLocation = pkLocation1; /* plocs[m] */move16(); + + /*location dependent update of plocs[m + 1] */ + if ( sub(lastPeak, m) > 0) + { /* only read additional peak when teher is a valid position to read */ + pkLocation1 = *pPlocs++; /* plocs[m + 1] */ move16(); + } + + delta_tmp = shr_pos(sub(sub(pkLocation, pkLocation_1), 1), 1); + if (m == 0) + { + delta_tmp = DELTA_CORR; move16(); /* first peak special case */ + } + delta_corr_dn = s_min(delta_tmp, DELTA_CORR); + + delta_tmp = shr_pos(sub(sub(pkLocation1, pkLocation), 1), 1); + if (sub(m, lastPeak) >= 0) + { + delta_tmp = DELTA_CORR; move16(); + } + delta_corr_up = s_min(delta_tmp, DELTA_CORR); /* last peak special case */ + + + /* Input Xph */ + segmentLen = sub(sub(pkLocation, delta_corr_dn), i); /* may be negative */ + + ASSERT(pReX == &(X[i])); + ASSERT(*pReX == X[i]); /*before first, nth valley*/ + + FOR(j = 0; j < segmentLen; j++) /* valley section , may be skipped for segmentlen < 0 */ + { + + *seed = rand_phase_fx(*seed, &sin_F, &cos_F); + + /* phase scrambling */ + rotate_W16_fx(*pReX, *pImX, cos_F, sin_F, &tmp, &im); /* tmp=real part, should be inlined */ + UNUSED(re); + + /* i.e. add a bit of magnitude scrambling around 1.0 in longer bursts */ + *seed = rand_phase_fx(*seed, &sin_F_fade2avg, &cos_F_fade2avg); + IF(noise_mag_scale_neg != 0) + { + valley_magnitude_adj_fx(&tmp, &im, *seed, cos_F); + /* use two random variables */ /*reuse cosF from regular X scrambling, + reuse *seed from fade2avg + */ + } + + IF( beta[k] != 0 ) + { + alpha_local = alpha[k]; /* no move as alpha_local is only needed for debug */ + /* the fade2avg mixing branch, fade2avg and transient downscaling and evolution rotation */ + tmp2 = mult_r(beta[k], Xavg[k]); + + { + tmp2 = s_and(tmp2, one_peak_flag_mask); + tmp = s_and(tmp, one_peak_flag_mask); + im = s_and(im, one_peak_flag_mask); + } + + *pReX++ = mac_r(L_mult(alpha_local, tmp), tmp2, cos_F_fade2avg); move16(); + *pImX-- = mac_r(L_mult(alpha_local, im), tmp2, sin_F_fade2avg); move16(); + } + ELSE + { /* the no fade2avg mixing branch, only transient downscaling and evolution rotation */ + { + tmp = s_and(tmp, one_peak_flag_mask); + im = s_and(im, one_peak_flag_mask); + } + + + *pReX++ = mult_r(mag_chg[k], tmp); move16(); + *pImX-- = mult_r(mag_chg[k], im); move16(); + } + i = add(i, 1); + ASSERT(pReX == &(X[i])); /* nth Valley */ + ASSERT(*pReX == X[i]); /* nth Valley */ + if (sub(i, gwlpr_fxPlus1[k]) >= 0) + { + k = add(k, 1); + } + } /* segment_len 1st++ etc valley excluding last */ + + /* peak area section */ + + e = s_min(lprotBy2Minus1, add(pkLocation, delta_corr_up)); + segmentLen = sub(e, sub(i, 1)); + + + L_Xph = *pCorrPhase_L; move32(); + /* rounding here, add "0.5" before extracting the 10 bits for table lookup */ + Xph_short = s_and(extract_l(L_shr_pos_pos(L_add(L_Xph, (1L << (16 - 10 - 1))), 16 - 10)), 0x3ff); + /* 10 bits precision after radix point, for a virtual 0-1023 sin/cos table lookup */ + + + get_sin_cosQ10opt(Xph_short, &peak_sin_F, &peak_cos_F); + + + ASSERT(pReX == &(X[i])); /*before peak*/ + FOR(j = 0; j < segmentLen; j++) + { + mag_chg_local = mag_chg[k]; /* mag_chg_local actually only need for debugging , no move16()*/ + + UNUSED(ph_dith); + *seed = extract_l(L_mac0(13849, *seed, 31821)); + rotate_W16_fx(*pReX, *pImX, peak_cos_F, peak_sin_F, &tmp, &im); /* should be inlined */ + UNUSED(re); + + *seed = rand_phase_fx(*seed, &sin_F, &cos_F); + + IF( beta[k] != 0 ) + { /* fade2avg path alpha*X_sav + beta *Xavg */ + alpha_local = mag_chg_local; /* no move alpha_local only needed for dbg */ + tmp2 = mult_r(beta[k], Xavg[k]); + + + *pReX++ = mac_r(L_mult(alpha_local, tmp), tmp2, cos_F); move16(); + *pImX-- = mac_r(L_mult(alpha_local, im), tmp2, sin_F); move16(); + } + ELSE + { + *pReX++ = mult_r(mag_chg_local, tmp); move16(); + *pImX-- = mult_r(mag_chg_local, im); move16(); + } + + i = add(i, 1); + ASSERT(pReX == &(X[i])); + ASSERT(*pReX == X[i]); + if (sub(i, gwlpr_fxPlus1[k]) > 0) + { + k = add(k, 1); + } + } /* segment_length Peak*/ + pCorrPhase_L++; + } + + segmentLen = sub(lprotBy2Minus1, sub(i, 1)); /* tail/valley noise-bins */ + + /* for 48k the last 63+1+63 = values above 20 kHz */ + { /* after last, peak no need to scramble above 20kHz , those coeffs have been/ will be zeroed already */ + /* DC, Xused,ReZeroed, fs/2, ImZeroed, ImUsed */ + /*N: 1, 320 , 63 , 1 , 63 , 320 */ + /*ind: 0, 1-320, 321-383 ,384 , 385-447, 448 -767 */ + /* segmentLen = sub(320, i-1); */ /*only process up to bin X[320] , 63 coeffs X[321] fwd should already be + zeroed */ + /* ASSERT(i-1+ segmentLen == lprotBy2Minus1 ); */ + } + + ASSERT(*pReX == X[i]); /* before a final valley*/ + FOR(j = 0; j < segmentLen; j++) + { + + + *seed = rand_phase_fx(*seed, &sin_F, &cos_F); + rotate_W16_fx(*pReX, *pImX, cos_F, sin_F, &tmp, &im); /* should be inlined , tmp=real part */ + + *seed = rand_phase_fx(*seed, &sin_F_fade2avg, &cos_F_fade2avg); + /* i.e. add a bit of magnitude scrambling around 1.0 in longer bursts */ + IF(noise_mag_scale_neg != 0) + { + valley_magnitude_adj_fx(&tmp, &im, *seed, cos_F); + /*reuse cosF from regular X scrambling, + reuse *seed from fade2avg */ + } + + tmp = s_and(tmp, one_peak_flag_mask); + im = s_and(im, one_peak_flag_mask); + IF(beta[k] != 0) + { /* fade2avg path never in first BFI frame */ + + alpha_local = alpha[k]; /* no move as alpha_local is only needed for debug */ + tmp2 = mult_r(beta[k], Xavg[k]); + { + tmp2 = s_and(tmp2, one_peak_flag_mask); + } + + + *pReX++ = mac_r(L_mult(alpha_local, tmp), tmp2, cos_F_fade2avg); move16(); + *pImX-- = mac_r(L_mult(alpha_local, im), tmp2, sin_F_fade2avg); move16(); + } + ELSE + { + + *pReX++ = mult_r(mag_chg[k], tmp); move16(); + *pImX-- = mult_r(mag_chg[k], im); move16(); + } + i = add(i, 1); + ASSERT(*pReX == X[i]); + if (sub(i, gwlpr_fxPlus1[k]) > 0) + { + k = add(k, 1); + } + } /* segment_len last valley */ + + + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + void my_wtda_fx(const Word16 *new_audio, /* i : input audio to be windowed Q0 20 ms , OPT can be output as well */ + const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + Word32 *L_wtda_audio, /* o : tda audio Q16 20 ms */ + const Word16 L, Word8 *scratchBuffer) /* Size = 8 * MAX_L_FRAME */ + { + Word16 i, L2; /*,L4;*/ + const Word16 *pX; + const Word16 *pW; + Word32 *p1_L, *p2_L, *p3_L, *p4_L; + Word32 *L_w_audio; /*OPt 1 use input buffer , OPT2, may be shortened from 20 ms to 16 ms due to + zeroed parts*/ + Word32 *pY_L, *pa1_L, *pa2_L; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("my_wtda_fx", sizeof(struct { + Word16 i, L2; /*,L4;*/ + const Word16 *pX; + const Word16 *pW; + Word32 *p1_L, *p2_L, *p3_L, *p4_L; + Word32 *L_w_audio; /*OPT 1 use input buffer, OPT2, may be shortened from 20 ms to 16.25+(1.75) ms + due to zeroed parts*/ + Word32 *pY_L, *pa1_L, *pa2_L; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::my_wtda_fx"); +#endif + + L_w_audio = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * 2 * MAX_L_FRAME */ + + /* |111111|222222|333333|444444 */ + /* |p1 p2| p3||p4 */ + + /* Apply analysis window */ + + pX = new_audio; + pY_L = L_w_audio; + + pW = win2ms_init; + FOR(i = 0; i < ((2 * L / 10)); i++) /* Loop over 2ms window MDCT-ana length */ + { + *pY_L++ = L_mult(*pX++, *pW++); move32(); + } + + pW = win16ms_center; + /* 20 ms - 2ms - 3.75 ms = 14.25 ms */ + FOR(i = 0; i < (2 * L - (2 * L / 10) - ((3 * 2 * L) / 16)); + i++) /* Loop over remaining 14.25ms, currently out of a 16 ms stored length */ + { + *pY_L++ = L_mult(*pX++, *pW++); move32(); + } + + + /* tda */ + L2 = shr_pos_pos(L, 1); /* length of tda blocks */ + + p1_L = L_w_audio; /* block 1 fwd */ + p2_L = L_w_audio + L - 1; /* block 2 rev */ + p3_L = L_w_audio + L + L2 - 1; /* block 3 rev */ + p4_L = L_w_audio + L + L2; /* block 4 fwd */ + + pa1_L = L_wtda_audio; /* first part output */ + pa2_L = L_wtda_audio + L2; /* second part output */ + + FOR(i = 0; i < (L / 8); i++) + { + /* first 1.25ms part of tda signal -p3_rev -p4_fwd */ + *pa1_L++ = L_negate(L_add_sat(*p3_L--, *p4_L++)); move32(); + } + FOR(; i < L2; i++) + { + /* first front part 3.75 ms p4_l is zeroes -p3_rev + (-p4_fwd==0) */ + *pa1_L++ = L_negate(*p3_L--); move32(); + } + + FOR(i = 0; i < L2; i++) + { + /* second part of tda signal p1 -p2_rev */ + *pa2_L++ = L_sub_sat(*p1_L++, *p2_L--); move32(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return; + } + + /*-------------------------------------------------------------------------- + * rec_wtda() + * + * Windowing and TDA of reconstructed frame + *--------------------------------------------------------------------------*/ + + + static void + rec_wtda_fx( + Word16 *X, /* i : iFFT(X-evolved) TD-signal o: dbg 16 ms */ + Word32 *L_ecu_rec, /* o : Reconstructed frame in tda domain Qx? */ + const Word16 output_frame, /* i : Frame length */ + const Word16 Lprot, /* i : Prototype frame length */ + const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + const Word16 maxLen, + const Word16 *prevsynth, + const Word16 Q_psMinus1, /*i: Q prev_synth minus 1 , (-1 to match Q of Xsav in first bfi frame ) */ + Word8 *scratchBuffer) /* Size = 12 * MAX_L_FRAME */ + { + Word16 l, Lprot2; + Word16 *rec_buf; + Word16 *xsubst_; /*,*out_ptr;*/ + + Word16 ola_old[COPY_LEN_48K + OLA_LEN_48K]; /* 3.75 ms */ + Word16 work_len; + Word16 copy_len; + Word16 ola_len; + + + Word8 *buffer_wtda; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("rec_wtda_fx", sizeof(struct { + Word16 l, Lprot2; + Word16 *rec_buf; + Word16 *xsubst_; /*,*out_ptr;*/ + Word8 *buffer_wtda; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::rec_wtda_fx"); +#endif + + rec_buf = scratchAlign(scratchBuffer, 0); /* Size = 2 * 2 * MAX_L_FRAME */ + buffer_wtda = (Word8 *)scratchAlign(rec_buf, sizeof(*rec_buf) * (2 * maxLen)); /* Size = 4 * 2 * MAX_L_FRAME */ + + xsubst_ = rec_buf; + Lprot2 = shr_pos_pos(Lprot, 1); + + /* extract reconstructed frame with ld window into rec_buf */ + l = sub(output_frame, Lprot2); + basop_memmove(xsubst_ + l, X, (Lprot) * sizeof(Word16)); /* 16 ms IFFT raw output */ + copy_len = COPY_LEN[FRAME2FS_IDX(output_frame)]; + ola_len = OLA_LEN[FRAME2FS_IDX(output_frame)]; + work_len = add(copy_len, ola_len); + /* Copy and scale copy part 2ms from prevsynth */ + basop_memmove(rec_buf, &prevsynth[Lprot - work_len], (copy_len) * sizeof(Word16)); /* 2ms out of 3.75 ms copied */ + Scale_sig_sat(rec_buf, copy_len, sub(-3, Q_psMinus1)); /* inplace scaling by 2^(-Q_ps-4) */ + + + /* Copy, window and scale 1.75 ms ola part from prevsynth , into a temporary buffer ola_old */ + + + windowing_ola(&prevsynth[Lprot - ola_len], ola_old, w_old[FRAME2FS_IDX(output_frame)], ola_len); /* 1.75 ms */ + + Scale_sig_sat(ola_old, ola_len, sub(-3, Q_psMinus1)); /* inplace scaling by 2^(-Qps-4) */ + + /* Window 1.75 ms length inplace recreated X=IFFT(prototype) signal copied into rec_buf signal */ + windowing_ola(&rec_buf[copy_len], &rec_buf[copy_len], w_new[FRAME2FS_IDX(output_frame)], ola_len); + /* mix add the two windowed components */ + ola_add(&rec_buf[copy_len], ola_old, &rec_buf[copy_len], ola_len); /* OPT: sat check */ + + my_wtda_fx(rec_buf, + win2ms_init, /* i: 2 ms initial part of pre_tda window */ + win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + L_ecu_rec, output_frame, buffer_wtda); /* */ + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + + return; + } + + /*-------------------------------------------------------------------------- + * rec_frame_fx() + * + * Frame reconstruction + *--------------------------------------------------------------------------*/ + void rec_frame_fx(Word16 * x, /* i : FFT spectrum 16 ms, o: ifft() TD debug signal 16ms */ + Word32 * L_ecu_rec, /* o : Reconstructed frame in tda domain 10ms buffer */ + const Word16 output_frame, /* i : Frame length */ + const Word16 Q, /* i : Xsav Q */ + const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + Word16 maxLprot, + const Word16 *prevsynth, + const Word16 Q_prevsynthMinus1, /* i : prevsynthQ-1 or xfp Q */ + Word8 *scratchBuffer /* Size = 4 * MAX_LPROT + 12 * MAX_L_FRAME */ + ) + { + Counter i; + Word16 Lprot; + Word32 *L_x; + Word32 *pX_L; + Word16 *pX; + Word16 fft_scale; + Word8 * buffer_fft; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("rec_frame_fx", sizeof(struct { + Counter i; + Word16 Lprot; + Word32 *L_x; + Word32 *pX_L; + Word16 *pX; + Word16 fft_scale; + Word8 * buffer_fft; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::rec_frame_fx"); +#endif + + L_x = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LPROT */ + buffer_fft = (Word8 *)scratchAlign(L_x, sizeof(*L_x) * maxLprot); /* Size = 4* (2+1) * MAX_L_FRAME */ + + /* Initialize to FB constants */ + Lprot = mult(output_frame, (Word16)(32768.0 / 99.0)); /* truncation needed , i.e no rounding can be applied here */ + ASSERT(Lprot == (output_frame / 100)); + Lprot = LprotSzPtr[Lprot]; move16(); + + + /* Convert stored 16 bit into 32bit for fft */ + flippedW16_2_intlvW32(x, sub(shr_pos_pos(Lprot, 1), 1), Lprot, L_x); + /*scratch x now free for re-use */ + + fft_scale = -1; move16(); + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::IFFT_fx"); +#endif + BASOP_irfftN(L_x, Lprot, &fft_scale, buffer_fft); +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + + pX_L = &L_x[0]; + pX = &x[0]; /* scratch x reused */ + + { + FOR(i = 0; i < Lprot; i++) + { + *pX++ = extract_h(L_shl_sat(*pX_L++, fft_scale)); move16(); + } + } + /* Scratch L_x may be released */ + + + /* Saturation possible when rescaling to Q0 if there are random bit errors in the bit stream + * One may use one guard bit to better handle this - though it should not be needed for normal + * operation. + */ + Scale_sig_sat(x, Lprot, negate(Q)); /* scale by 2^(-Q) */ + + /*scratch x is Lprot word16 */ + /* scatch need for win-TDA XXX */ + /* scrcatch need for TDA XXX */ + + rec_wtda_fx(x, L_ecu_rec, output_frame, Lprot, + win2ms_init, /* i: 2 ms initial part of pre_tda window */ + win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + s_max(output_frame, 160), + prevsynth, + Q_prevsynthMinus1, /* NB: prevsynth Q may change from prev_bfi=0 to prev_bfi==1, due to phase + of signal or PLC2-muting */ + buffer_fft); + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return; + } + + /*-------------------------------------------------------------------------- + * hq_phase_ecu_fx() + * + * Main routine for HQ phase ECU + *--------------------------------------------------------------------------*/ + void hq_phase_ecu_fx( + const Word16 *prevsynth, /* i : buffer of previously synthesized signal currently 16ms */ + Word32 * L_ecu_rec, /* o : reconstructed frame in tda domain , also tmp w32_fft buffer */ + Word16 * time_offs, /* i/o: Sample offset for consecutive frame losses*/ + Word16 * X_sav, /* i/o: Stored spectrum of prototype frame */ + Word16 * Q_spec, /* o: Q value of stored spectrum */ + Word16 * num_p, /* i/o: Number of identified peaks */ + Word16 * plocs, /* i/o: Peak locations */ + Word32 * L_plocsi, /* i/o: Interpolated peak locations Q16 */ + const Word16 env_stab, /* i : Envelope stability parameter */ + const Word16 f0hzLtpBinQ7, /* i: LTP bin frequency in normalized Hz Q7 */ + const Word16 norm_corrQ15_fx, /*i : correlation for lag at f0hzLtpBinQ7 */ + const Word16 prev_bfi, /* i : indicating burst frame error */ + Word16 old_is_transient[2], /* i/o : flags indicating noise generation frames */ + Word16 * mag_chg_1st, /* i/o: per band magnitude modifier for transients*/ + Word16 * mag_chg_gr, /* o: per band magnitude modifier, incl burst attenuation */ + Word16 * Xavg, /* i/o: Frequency group average gain to fade to */ + Word16 * beta_mute, /* o : Factor for long-term mute */ + const Word16 bwidth_fx, /* i : Encoded bandwidth */ + const Word16 output_frame, /* i : frame length */ + Word16 * seed_out_fxPtr, /* o: utput dbg NULL may be used*/ + Word16 * X_out, /* o: utput dbg NUll may be used */ + const Word16 t_adv, /* i : time adjustment including time_offs */ + const Word16 *const win2ms_init, /* i: 2 ms initial part of pre_tda window */ + const Word16 *const win16ms_center, /* i: 16 ms combined part of pre_tda IWHR+MDCT-ana */ + const Word16 *sp_ana_win, /* i : whr 3+10+3 window */ + Word16 q_fx_old_exp, /* i : exp of prev_synth */ + + Word16 maxLprot, /* i : maz spectrum buffer size */ + Word16 maxPlocs, /* i : max nb of peaks */ + Word32 L_oold_xfp_w_E_fx, Word16 oold_xfp_w_E_exp_fx, /* exp of time signale */ + Word16 oold_Ltot_exp_fx, /*true exp of energy */ + Word16 *oold_grp_shape_fx, Word32 L_old_xfp_w_E_fx, Word16 old_xfp_w_E_exp_fx, /* exp of time signale */ + Word16 old_Ltot_exp_fx, /*true exp of energy */ + Word16 *old_grp_shape_fx, + Word16 margin_prevsynth, +#ifdef CR8_A_PLC_FADEOUT_TUNING + const Word16 fadeout, + Word16 *nonpure_tone_flag_ptr, /* i/o : non-pure single tone indicator state */ +#endif + Word8 *scratchBuffer /* Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ + ) + { + Word16 lprot; + Word16 *mag_chg, ph_dith, *X; + Word16 *xfp; + Word16 seed; + Word16 alpha[MAX_LGW], beta[MAX_LGW] ; + Word16 prevsynth_man_upshift; + Word16 Q_prevsynthMinus1; + Word8 *buffer; +# ifdef CR8_A_PLC_FADEOUT_TUNING + Word32 L_Xavg[MAX_LGW]; /* i/o : Frequency group amp averages for tonal tilt analysis Max upshifted */ +# endif +#ifdef DYNMEM_COUNT + Dyn_Mem_In("hq_phase_ecu_fx", sizeof(struct { + Counter i; + Word16 lprot; + Word16 *mag_chg, ph_dith, *X; + Word16 seed; + Word16 alpha[MAX_LGW], beta[MAX_LGW]; + Word16 prevsynth_man_upshift; + Word16 Q_prevsynthMinus1; + Word8 *buffer; + // ToDO Word32 L_Xavg[MAX_LGW]; + })); +#endif + + if (!prev_bfi) + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(1st)"); +#endif + } + else + { +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(N)"); +#endif + } + + mag_chg = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LGW */ + X = (Word16 *)scratchAlign(mag_chg, sizeof(*mag_chg) * MAX_LGW); /* Size = 2 * MAX_LPROT == 1 Word16*MAX_LPROT */ + xfp = (Word16 *)scratchAlign(X, sizeof(*X) * maxLprot); /* Size = 2 * MAX_LPROT == 1 Word16*MAX_LPROT */ + buffer = (Word8 *)scratchAlign(xfp, sizeof(*xfp) * maxLprot); /* Size = 4 * MAX_LPROT + 12 * MAX_L_FRAME */ + + /* buffer size = Word32 * MAX_LPROT (FFT, IFFT) DRAM + + 3*Word32 * MAX_L_FRAME */ + + basop_memset(alpha, 0, MAX_LGW*sizeof(Word16)); + basop_memset(beta, 0, MAX_LGW*sizeof(Word16)); + + lprot = LprotSzPtr[bwidth_fx]; move16(); + + test(); + ASSERT(prev_bfi >= 0 && prev_bfi <= 1); + IF( prev_bfi == 0 ) /* inside PhECU we can check vs 0 */ + { + *time_offs = 0; move16(); +#ifdef CR8_A_PLC_FADEOUT_TUNING + *nonpure_tone_flag_ptr = -1; move16(); /* flag nonpure tone flag for new analysis */ +#endif + /* analysis made outside, up/down scaling here from static RAM to dynamic RAM */ + /* prevsynth_in_flt = prev_synth_man*2.^(-15 + exp_old) */ + /* X_sav_flt = X_man/2.^(Q_spec) */ + + /* 1 bit headroom needed in xfp_tmp_buf for FFT processing into X_sav */ + /* margin_prevsynth = actual margin in incoming 16 ms xpf segment */ + /* q_fx_old_exp was computed on full 21+ ms updatepcm buffer) */ + + ASSERT(margin_prevsynth >= 0 && (margin_prevsynth <= 16)); + + prevsynth_man_upshift = + sub(margin_prevsynth, 1); /* 0 --> -1(==down), 1--> 0 , 2 --> 1(==up), ... */ + ASSERT(prevsynth_man_upshift >= -16 && prevsynth_man_upshift <= 15); /* avoid Overflow in shr, shl */ + *Q_spec = sub(15, sub(q_fx_old_exp, prevsynth_man_upshift)); + /* Q_spec target is to create 1 additional bit of margin in the xfp TD buffer , before converting to + * Xsav + */ + + if (margin_prevsynth == 0) + { + Word16 Qold = 15 - (q_fx_old_exp + 1); + Word16 tmp_man_upshift = margin_prevsynth - 1; /* 1 .. -15 */ + Word16 Qnew = 15 - (q_fx_old_exp - tmp_man_upshift); + assert(Qold == Qnew); + UNUSED(Qold); + UNUSED(Qnew); + } + if (margin_prevsynth == 1) + { + Word16 Qold = 15 - (q_fx_old_exp + 0); + assert(*Q_spec == Qold); + UNUSED(Qold); + } + if (margin_prevsynth == 2) + { + Word16 Qold = 15 - (q_fx_old_exp - 1); + assert(*Q_spec == Qold); + UNUSED(Qold); + } + + Q_prevsynthMinus1 = sub(15, add(q_fx_old_exp, +1)); /* dbg to use non-scaled prevsynth for OLA */ + + /* Q of prev_synth now separated from prev_bfi=0 and prev_bfi==1 */ + +#ifdef USE_TMPXFP_IN_OLA + Q_prevsynthMinus1 = *Q_spec; /* a possibly upscaled Q */ +#endif + + + Copy_Scale_sig( + prevsynth, xfp, lprot, + prevsynth_man_upshift); /* unscaled prevsynth is still used by rec_frame, copy to a temporary + xfp analysis buffer, and scale down to a margin of 1 bit */ + + + trans_burst_ana_fx( + ((void *)NULL), + mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, alpha, beta, beta_mute, Xavg, + (*Q_spec), L_oold_xfp_w_E_fx, oold_xfp_w_E_exp_fx, oold_Ltot_exp_fx, oold_grp_shape_fx, + L_old_xfp_w_E_fx, old_xfp_w_E_exp_fx, old_Ltot_exp_fx, old_grp_shape_fx, +#ifdef CR8_A_PLC_FADEOUT_TUNING + fadeout, + L_Xavg, /* full scale band amplitudes in first bfi frame */ +#endif + buffer); + + spec_ana_fx(&(xfp[0]), plocs, L_plocsi, num_p, X_sav, output_frame, bwidth_fx, + sp_ana_win, f0hzLtpBinQ7, norm_corrQ15_fx, maxLprot, maxPlocs, buffer); + } + ELSE + { + /* analysis made outside, possible up/down scaling here from static RAM to dynamic RAM */ + ASSERT(margin_prevsynth >= 0 && (margin_prevsynth <= 15)); + + /* prev_synth may have been scaled outside by update_pcm() function */ + /* prevsynth_in_flt = prev_synth_man*2.^(-15 + exp_old) */ + /* first bfi frame: X_sav_flt = X_man/2.^(*Q_spec) */ + /* this bfi frame prev_synth(TD) is mixed with ifft signal(TD,from Q_spec) in rec_frame_fx + variable Q_prevsynthMinus1 provided to rec_frame for this TD+TD mixing + */ + + Q_prevsynthMinus1 = sub(15, add(q_fx_old_exp, +1)); /* for now, "old" use of unscaled prevsynth for added OLA */ + +#ifdef USE_TMPXFP_IN_OLA + { /* DBG target here is to instead upshift to a zero margin */ + /* but Q value is maintained to match the save Xsav *Q_spec which is used with an offset of " -1" */ + /* prevsynth_man_upshift = -prevsynth_margin ; */ + Word16 tmp, worklen = add(hamm_len2Tab[bwidth_fx], shr(hamm_len2Tab[bwidth_fx], 2)); + tmp = mult(7680, lprot); /* needs to truncate to integer */ + ASSERT(tmp == worklen); + Copy_Scale_sig(&prevsynth[lprot - worklen], &xfp[lprot - worklen], worklen, + margin_prevsynth); /* only scale up last 3.75 ms */ + Q_prevsynthMinus1 = sub(15, add(q_fx_old_exp, margin_prevsynth)); /*-1 does not make sense */ + } +#endif + + *time_offs = add_sat(*time_offs, output_frame); + + trans_burst_ana_fx( + ((void *)NULL), + mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, alpha, beta, beta_mute, Xavg, + (0), /* *Q_spec input only used in first bfi frames for burst analysis */ + L_oold_xfp_w_E_fx, oold_xfp_w_E_exp_fx, oold_Ltot_exp_fx, oold_grp_shape_fx, L_old_xfp_w_E_fx, + old_xfp_w_E_exp_fx, old_Ltot_exp_fx, old_grp_shape_fx, +#ifdef CR8_A_PLC_FADEOUT_TUNING + fadeout, + NULL, /* full scale band amplitudes , only used in first bfi frame */ +#endif + buffer); + } + /* cpy LPROT Word16 from Static RAM Xsav to working DRAM/scratch buffer X ;*/ + basop_memmove(X, X_sav, (lprot) * sizeof(Word16)); + /* seed for own_rand2 */ + seed = *time_offs; move16(); + + if (mag_chg_gr != NULL) /* o: dbg per band magnitude modifier, incl. burst attenuation */ + { + Counter k; + Word16 lgw_local = s_min(add(bwidth_fx, LGW8K), LGW48K); /* 4,5,6,7, (7/8) */ + for (k = 0; k < lgw_local; k++) + { + mag_chg_gr[k] = mag_chg[k]; /* dbg SNR output */ + } + } + + subst_spec_fx(plocs, L_plocsi, num_p, *time_offs, X, mag_chg, ph_dith, old_is_transient, output_frame, + &seed, alpha, beta, + Xavg, t_adv +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,fadeout, + nonpure_tone_flag_ptr, /* i/o : non-pure single tone indicator state */ + L_Xavg /*i : only used in first bfi frame */ +#endif + ); + + if (seed_out_fxPtr != NULL) + { + *seed_out_fxPtr = seed; /* verify seed synch after subst_spec */ + } + + + if (X_out != NULL) + { + Word16 ii; + for (ii = 0; ii < lprot; ii++) + { + X_out[ii] = X[ii]; /* evolve spectrum, no moves counted as this is a dbg-vector info cpy */ + } + } + + /* reconstructed frame in tda domain */ + /* NB *Q_spec only updated in first bfi frame */ + + /*Scratch Analysis at this point */ + /* X fft input needed as evolved spectrum Lprot* Word16 */ + /* xfp not needed any longer Word16* Lprot */ + /* IFFT operation needs Word32*Lprot in and Word32*Lprot out */ + /* MDCT win operation may be inplace 2x MAX_L_FRAME */ + /* TDA output is 1x MAX_L_FRAME */ + + rec_frame_fx(X, L_ecu_rec, output_frame, *Q_spec, + win2ms_init, win16ms_center, + maxLprot, +#ifdef USE_TMPXFP_IN_OLA + xfp, /* only last 3.75 ms used, in both prevbfi=0 and prevBfi=1 i.e frames, xfp is an + upscaled prev_synth */ +#else + prevsynth, /*only last 3.75 ms used in both prevbfi=0 and prevBfi=1 i.e frames */ +#endif + Q_prevsynthMinus1, + buffer); + + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + + static Word16 sqrt2ndOrder( /* o: in Q15 (2nd order least square approx.) */ + const Word16 x /* i: x must be in between 0.5 and 1.0 (Q15). */ + ) + { + Word32 acc; + Word16 z; +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::sqrt2ndOrder"); +#endif + + ASSERT(x >= 16384); + + acc = 1890205600L; /* 0.880195572812922 in Q31 */ move32(); + z = mac_r(acc, x, -6506); /* -0.198537395405340 in Q15 */ + acc = 682030261L; /* 0.317595089462249 in Q31 */ move32(); + z = mac_r(acc, z, x); /* in Q15 */ + + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return z; + } + + + /* Modified version to produce Word32 input to FFT */ + static void windowing_L( + const Word16 *x, /* i: Input signal */ + Word32 * L_y, /* o: Windowed output */ + const Word16 *win, /* i: Window coefficients */ + const Word16 rectLength, /* i: Offset in between the 1st and 2nd symmetric halves of the Hamming window */ + const Word16 halfLength /* i: Half of the total length of a complete Hamming window. */ + ) + { + Counter i; + Word32 * pY_L; + const Word16 *pX, *pW; + Word16 tmp_RL; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("windowing_L", sizeof(struct { + Counter i; + Word32 * pY_L; + const Word16 *pX, *pW; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::windowing_L"); +#endif + + pX = x; + pW = win; + pY_L = L_y; + + FOR(i = 0; i < halfLength; i++) /* 1st symmetric half of the Hamming window */ + { + *pY_L++ = L_mult(*pX++, *pW++); move32(); + } + /* Periodic filter - one more rect sample before end tapering */ + + tmp_RL = add(rectLength, 1); + + if (rectLength == 0) + { + tmp_RL = 0; move16(); + } + /* If rectLength is zero, it's a pure Hamming window; otherwise Hamming-Rectangular. */ + FOR(i = 0; i < tmp_RL;i++) + { + *pY_L++ = L_deposit_h(*pX++); move32(); + } + tmp_RL = sub(halfLength, 1); + if (rectLength == 0) + { + tmp_RL = halfLength; move16(); + } + FOR(i = 0; i < tmp_RL; i++) /* 2nd symmetric half of the Hamming window. */ + { + *pY_L++ = L_mult(*pX++, *(--pW)); move32(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + /* Modified version to produce Word16 input to FFT */ + static void windowing_ola(const Word16 *x, /* i: Input signal */ + Word16 * y, /* o: Windowed output */ + const Word16 *win, /* i: Window coefficients */ + const Word16 Length /* i: Half of the total length of a complete Hamming window. */ + ) + { + Counter i; + Word16 * pY; + const Word16 *pX, *pW; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("windowing_ola", sizeof(struct { + Counter i; + Word16 * pY; + const Word16 *pX, *pW; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::windowing_ola"); +#endif + + pX = x; + pW = win; + pY = y; + + FOR(i = 0; i < Length; i++) /* 1st symmetric half of the Hamming window */ + { + *pY++ = mult_r(*pX++, *pW++); move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + /* Modified version to produce Word16 input to FFT */ + static void ola_add(const Word16 *x, /* i: Input signal 1 */ + const Word16 *y, /* i: Input signal 2 */ + Word16 * z, /* o: Output signal */ + const Word16 Length /* i: Half of the total length of a complete window. */ + ) + { + Counter i; + Word16 * pZ; + const Word16 *pX, *pY; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("windowing_ola", sizeof(struct { + Counter i; + Word16 * pY; + const Word16 *pX, *pW; + })); +#endif + + + + pX = x; + pY = y; + pZ = z; + + FOR(i = 0; i < Length; i++) /* 1st symmetric half of the Hamming window */ + { + *pZ++ = add_sat(*pX++, *pY++); move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + + } + + /*----------------------------------------------------------------------------- + * magnSqrtApprox_fx() + * + * Approximation of sqrt(Square magnitude) of fft spectrum + * if min_abs <= 0.4142135*max_abs + * abs = 0.99*max_abs + 0.197*min_abs + * else + * abs = 0.84*max_abs + 0.561*min_abs + * end + * + * Note: even to handle the dynamics of sqrt(re^2+im^2) located on + * a scaled unit circle. One need to scale down the results + * with a factor 2, that is Q_out = Q_in - 1 + * sqrt(32768.^2+32768.^2) results in = 23170 Q0-1, + * which corresponds to 46341 in the Q0 domain + *----------------------------------------------------------------------------*/ + Word16 sqrtMagnApprox_fx( /* o : sqrt of magnitude square spectrum Q_in-1*/ + const Word16 re, /* i : Real part Q_in */ + const Word16 im /* i : Imag part Q_in */ + ) + { + /* Constants for Approximation of sqrt(Square magnitude) of fft spectrum + * >> num2str(round(0.4142135]*2.^15)) + * ans = 13573 + * >> num2str(round([0.99 0.197 0.84 0.561]*2.^14)) + * ans = 16220 3228 13763 9191 + */ + +#define C_0p4142135_Q15 13573 + +#define C_0p99_Q14 16220 +#define C_0p197_Q14 3228 +#define C_0p84_Q14 13763 +#define C_0p561_Q14 9191 + Word16 sgn_bit, re_abs, im_abs, max_abs, min_abs, sum; + Word16 jcoeffs[2][2] = { {C_0p99_Q14, C_0p197_Q14}, {C_0p84_Q14, C_0p561_Q14} }; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("sqrtMagnApprox_fx", sizeof(struct { + Word16 sgn_bit, re_abs, im_abs, max_abs, min_abs, sum; + Word16 jcoeffs[2][2]; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::sqrtMagnApprox_fx"); +#endif + + /* Get values and move pointers */ + re_abs = abs_s(re); /* 1 cycle */ + im_abs = abs_s(im); /* 1 cycle */ + + /* Find max and min value */ + min_abs = s_min(re_abs, im_abs); /* 1 cycle */ + max_abs = s_max(re_abs, im_abs); /* 1 cycle */ + + /* Calc approximation depending on relation */ + sgn_bit = lshr(sub(mult(max_abs, C_0p4142135_Q15), min_abs), 15); /* 3 cycles */ + sum = mac_r(L_mult(max_abs, jcoeffs[sgn_bit][0]), min_abs, jcoeffs[sgn_bit][1]); /* 2 cycles */ +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return sum; + } + + /*----------------------------------------------------------------------------- + * fft_spec2_sqrt_approx_fx() + * + * Approximation of sqrt(Square magnitude) of fft spectrum + * if min_abs <= 0.4142135*max_abs + * abs = 0.99 max_abs + 0.197*min_abs + * else + * abs = 0.84 max_abs + 0.561*min_abs + * end + * + * Note: even to handle the dynamics of sqrt(re^2+im^2) located on + * a scaled unit circle. One need to scale down the results + * with a factor 2, that is Q_out = Q_in - 1 + * sqrt( -32768.^2 + -32768.^2 ) results in = 23170 Qin-1, + * which corresponds to 46341 in the Qin domain + *----------------------------------------------------------------------------*/ + + void fft_spec2_sqrt_approx_fx(const Word16 x[], /* i : Input vector: complex spectrum , Qin */ + Word16 xMagSqrt[], /* o : sqrt of magnitude square spectrum Qout=Qin-1*/ + const Word16 N /* i : Input vector x length */ + ) + { + Counter i; + Word16 l; + const Word16 *pRe, *pIm; + Word16 * pMagSqrt; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("fft_spec2_sqrt_approx_fx", sizeof(struct { + Counter i; + Word16 l; + const Word16 *pRe, *pIm; + Word16 * pMagSqrt; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::fft_spec2_sqrt_approx_fx"); +#endif + + /* Magnitude at 0. only real component */ + pMagSqrt = &xMagSqrt[0]; + pRe = &x[0]; + *pMagSqrt++ = mult(abs_s(*pRe++), C_0p99_Q14); move16(); + + /* From 1 to (N/2 - 1). */ + pIm = &x[N - 1]; + + l = sub(shr_pos_pos(N, 1), 1); /* N/2 - 1. */ + l = s_min(l, (LPROT48K_RED / 2 - 1) + DELTA_CORR_F0_INT); + /* at 48 k the top 8 khz are always zero, and further peaks are not + located above LPROT48K_RED 32 kHz */ + FOR(i = 0; i < l; i++) + { + *pMagSqrt++ = sqrtMagnApprox_fx(*pRe++, *pIm--); move16(); + } + + /* The sqrt magnitude square at N/2 - only real component */ + *pMagSqrt = mult(abs_s(*pRe), C_0p99_Q14); move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return; + } + + Word16 + imax2_jacobsen_mag_fx(/* o: The location, relative to the middle of the 3 given data point, of the maximum. + (Q15) */ + const Word16 *y_re, /* i: The 3 given data points. real part order -1 0 1 */ + const Word16 *y_im, /* i: The 3 given data points. imag part order 1 0 -1 (from FFT)*/ + const Word16 + special /* i: -1 = left edge special case, 0 = normal, +1 = right edge special case */ + ) + { + Word16 posi; + Word16 man, expo; + const Word16 *pY; + Word16 y_m1_re, y_0_re, y_p1_re; + Word16 y_m1_im, y_0_im, y_p1_im; + + Word16 D_re, D_im, N_re, N_im; + + Word32 L_sign, L_denom, L_numer; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("imax2_jacobsen_mag_fx", sizeof(struct { + Word16 posi; + Word16 man, expo; + const Word16 *pY; + Word16 y_m1_re, y_0_re, y_p1_re; + Word16 y_m1_im, y_0_im, y_p1_im; + Word16 D_re, D_im, N_re, N_im; + Word32 L_sign, L_denom, L_numer; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::imax2_jacobsen_mag_fx"); +#endif + + /* Jacobsen estimates peak offset relative y_0 using + * X_m1 - X_p1 + * d = REAL ( ------------------- ) * c_jacob + * 2*X_0 - X_m1 -Xp1 + * + * Where c_jacob is a window dependent constant + */ +#define C_JACOB_Q14 18725 /* c_jacob = 1.1429; % assume 0.1875 hammrect window 'periodic' */ + + ASSERT(special == 0); /* always use other imax for edges cases */ + UNUSED(special); + + /* Get the bin parameters into variables */ + pY = y_re; + y_m1_re = *pY++; + y_0_re = *pY++; + y_p1_re = *pY++; + + /* Same for imaginary parts - note reverse order from FFT */ + pY = y_im; + y_p1_im = *pY++; + y_0_im = *pY++; + y_m1_im = *pY++; + + test(); + IF( norm_s(y_0_re) == 0 || norm_s(y_0_im) == 0 ) + { +#define JACOB_MARGIN 2 + /* for very high peaks the Complex denominator values may need to be downshifted 2 steps */ + y_0_re = shr_pos(y_0_re, JACOB_MARGIN); + y_0_im = shr_pos(y_0_im, JACOB_MARGIN); + + y_m1_re = shr_pos(y_m1_re, JACOB_MARGIN); + y_m1_im = shr_pos(y_m1_im, JACOB_MARGIN); + + y_p1_re = shr_pos(y_p1_re, JACOB_MARGIN); + y_p1_im = shr_pos(y_p1_im, JACOB_MARGIN); + } + + /* prepare numerator real and imaginary parts*/ + N_re = sub(y_m1_re, y_p1_re); + N_im = sub(y_m1_im, y_p1_im); + + /* prepare denominator real and imaginary parts */ + + D_re = sub(sub(shl_pos(y_0_re, 1), y_m1_re), y_p1_re); + D_im = sub(sub(shl_pos(y_0_im, 1), y_m1_im), y_p1_im); + + /* REAL part of complex division */ + L_numer = L_mac0(L_mult0(N_re, D_re), N_im, D_im); + L_denom = L_mac0(L_mult0(D_re, D_re), D_im, D_im); + L_sign = L_xor(L_numer, L_denom); /* Preserve the sign since div_s() only takes positive arguments. */ + + L_numer = L_abs(L_numer); + L_denom = L_abs(L_denom); + + test(); + IF(L_numer != 0 && L_denom != 0) + { + + man = plc_phEcu_ratio_fx(L_numer, L_denom, &expo); /* The mantissa is considered in Q15 */ + + man = mult_r(man, C_JACOB_Q14); + posi = shr_sat( man, sub(expo, 2)); + /* to Q15 (and due to saturation, it is automatically bound inside [-1.0,1.0].) */ + + if (L_sign < 0) /* Restore the sign. */ + { + posi = negate(posi); + } + } + ELSE + { + posi = 0; move16(); /* flat top, division is not possible choose center freq */ + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return posi; /* Q15. The position either left or right relative to the index of the middle of the 3 given + data points. */ + } + + /* Convert 32 Bit FFT into 16 bit fft domain */ + static void intlvW32_2_flippedW16( + Word32 * L_x, /* i : interleaved coeffs DC, Fs/2, Re(1),Im(1), Re(2),Im(2), ... ] */ + const Word16 numPairs, /* i: typically (fft-size/2 -1), re/im coeffs to copy */ + const Word16 Lprot, /* i: fft size , including DC+fs/2 */ + Word16 * x /* o : flipped coeffs , [DC, Re(1),.. Re(N-1/2) , Fs/2, Im(N-1/2) ... Im(1) ] */ + ) + { + + /* reorder real and imag components, and apply fractional scale for 24/48Khz */ + Counter m; + Counter numPairsLocal; + Word32 *pX_L = &L_x[2]; /*ptr init*/ + Word16 *pX_Re = &x[1]; /*ptr init*/ + Word16 *pX_Im = &x[Lprot - 1]; /*ptr init*/ + +#define FHG_FFT_UPSHIFT 2 + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::intlvW32_2_flippedW16"); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_In("intlvW32_2_flippedW16", sizeof(struct { + Counter m; + Counter numPairsLocal; + Word32 *pX_L; + Word16 *pX_Re; + Word16 *pX_Im; + })); +#endif + + /* make the scaling of 8/3= 4*0.666 here for 24 kHz and 48 kHz using 16x16 instead or 32x16 ops + a limited loss of SNR */ + + test(); + IF(sub(numPairs, 383) == 0 || sub(numPairs, 191) == 0) + { /* 24,48 kHz , 16 ms , scale by 8/3 = .666*4 */ + numPairsLocal = s_min(numPairs, 383 - 63); /* do not copy bins above 20 kHz */ + /* for 48 kHz is to only go up to 40 kHz pairs , */ + FOR(m = 0; m < numPairsLocal; m++) + { + /* multiply by (8/3)*(2.^FHG_FFT_UPSHIFT) */ + /* note: multiplication by 2/3 need to preceed upshift , due to FFT scaling being very close to the 48/24 3 + * split kHz bit margin */ + *pX_Re++ = extract_h(L_shl_pos(Mpy_32_16_lc3plus(*pX_L++, FEC_TWOTHIRDS_Q15), FHG_FFT_UPSHIFT + 2)); + move16(); + *pX_Im-- = extract_h(L_shl_pos(Mpy_32_16_lc3plus(*pX_L++, FEC_TWOTHIRDS_Q15), FHG_FFT_UPSHIFT + 2)); + move16(); + } + /* Place the two real only components */ + x[0] = extract_h(L_shl_pos(Mpy_32_16_lc3plus(L_x[0], FEC_TWOTHIRDS_Q15), FHG_FFT_UPSHIFT + 2)); /* DC */ + move16(); + m = shr_pos_pos(Lprot, 1); + x[m] = extract_h(L_shl_pos(Mpy_32_16_lc3plus(L_x[1], FEC_TWOTHIRDS_Q15), FHG_FFT_UPSHIFT + 2)); /* fs/2 */ + move16(); + } + ELSE + { /* 8,16,32 kHz 16 ms no additional scaling by 8/3 */ + + FOR(m = 0; m < numPairs; m++) + { + *pX_Re++ = extract_h(L_shl_pos(*pX_L++, FHG_FFT_UPSHIFT)); + move16(); + *pX_Im-- = extract_h(L_shl_pos(*pX_L++, FHG_FFT_UPSHIFT)); + move16(); + } + + /* Place the two real only components */ + x[0] = extract_h(L_shl_pos(L_x[0], FHG_FFT_UPSHIFT)); /* DC */ move16(); + m = shr_pos_pos(Lprot, 1); + x[m] = extract_h(L_shl_pos(L_x[1], FHG_FFT_UPSHIFT)); /* fs/2 */ move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + static void flippedW16_2_intlvW32( + Word16 * x, /* i : flipped coeffs , [DC, Re(1),.. Re(N-1/2) , Fs/2, Im(N-1/2) ... Im(1) ] */ + const Word16 numPairs, /* i: typically (fft-size/2 -1), re/im coeffs to copy */ + const Word16 Lprot, /* i: fft size , including DC+fs/2 */ + Word32 * L_x /* o : interleaved coeffs DC, Fs/2, Re(1),Im(1), Re(2),Im(2), ... ] */ + ) + { + Counter i; + Counter numPairsLocal; + Word32 *pX_L; + Word16 *pX_re, *pX_im; +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::flippedW16_2_intlvW32"); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_In("flippedW16_2_intlvW32", sizeof(struct { + Counter i; + Counter numPairsLocal; + Word32 *pX_L; + Word16 *pX_re, *pX_im; + })); +#endif + + /* Convert stored 16 bit into 32bit for fft */ + /* Note during save FFT output was left shifted FHG_FFT_UPSHIFT */ + /* this needs to be restored before one calls ifft to avoid overflow */ + + pX_L = &L_x[2]; /*ptr init*/ + pX_re = &x[1]; /*ptr init*/ + pX_im = &x[Lprot - 1]; /*ptr init*/ + + numPairsLocal = s_min(320, numPairs); /* 48kHz optimization */ + FOR(i = 0; i < numPairsLocal; i++) + { + *pX_L++ = L_shr_pos(L_deposit_h(*pX_re++), FHG_FFT_UPSHIFT); move32(); + *pX_L++ = L_shr_pos(L_deposit_h(*pX_im--), FHG_FFT_UPSHIFT); move32(); + } + /* at 48KHz zero tail 2x63= 126 bins for Word32 IFFT input */ + basop_memset(pX_L, 0, sizeof(Word32) * shl_pos(sub(numPairs, numPairsLocal), 1)); + + /* Place the two real only components */ + L_x[0] = L_shr_pos(L_deposit_h(x[0]), FHG_FFT_UPSHIFT); move32(); + L_x[1] = L_shr_pos(L_deposit_h(x[Lprot / 2]), FHG_FFT_UPSHIFT); move32(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + + void get_sin_cosQ10opt(Word16 phase, /* Q10 0..1023 i.e. 1024=2*pi */ + Word16 * ptrSin, /* Q15 */ + Word16 * ptrCos /* Q15 */ + ) + { + Word16 sign_val, idx, idx2, idx3; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("get_sin_cosQ10", sizeof(struct { Word16 sign_val, idx, idx2, idx3; })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::get_sin_cosQ10opt"); +#endif + + /* sin table has a range up to pi/2 (256+1)=257 coeffs*/ + + sign_val = shr_pos_pos(phase, 9); /* highest bit is the sinus sign */ + idx = s_and(phase, 0x1ff); /* mask away sign */ + + idx2 = sub(idx, 256); + if (idx2 < 0) + { /*rising sine part */ + *ptrSin = sin_quarterQ15_fx[idx]; move16(); + } + + idx3 = sub(512, idx); + if (idx2 >= 0) + { /* decaying part, reverse idx */ + *ptrSin = sin_quarterQ15_fx[idx3]; move16(); + } + + if (sign_val != 0) + { + *ptrSin = negate(*ptrSin); /*no move when inlined , no sat as max in table is 32767 */ + } + + /*cos*/ + idx = add(phase, 256); /* +pi/2, i.e. move to cos phase */ + idx = s_and(idx, 0x3ff); /* wrap on 10 bits limit */ + + sign_val = shr_pos_pos(idx, 9); /* highest bit is the sign */ + idx = s_and(idx, 0x1ff); /* mask away sign */ + + idx2 = sub(idx, 256); + if (idx2 < 0) + { /*rising sine part */ + *ptrCos = sin_quarterQ15_fx[idx]; move16(); + } + + idx3 = sub(512, idx); + if (idx2 >= 0) + { /* decaying part, reverse idx*/ + *ptrCos = sin_quarterQ15_fx[idx3]; move16(); + } + + if (sign_val != 0) + { + *ptrCos = negate(*ptrCos); /* no move when inlined , no sat as max in table is 32767 */ + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + static Word16 plc_phEcu_nonpure_tone_ana_fx(const Word16* plocs, + const Word16 n_plocs, + const Word16* X, /*i: { DC, Re1,Re2 ,.....ReN , Fs/2, ImN... , Im2, Im1} */ + const Word32 *L_Xavg, /* i : Frequency group amp averages for tonal tilt analysis Max upshifted */ + const Word16 Lprot, + const Word16 fs_idx) + { +#ifdef DYNMEM_COUNT + Dyn_Mem_In("PhECU::nonpure_tone_ana", sizeof(struct { + Word16 nonpure_tone_detect; + Word16 n_ind, tone_ind, low_ind, high_ind; + Word16 peak_amp, peak_amp2, valley_amp, x_abs[(1 + 2 * ONE_SIDED_SINE_WIDTH + 2 * 1)]; + Word16 sineband_ind_low, sineband_ind_high; + Word16 i, N_grp; + Word16 tmp, tmp_dB; + Word32 L_tot_inc_HF, L_tot_inc_LF; + Word16* pRe; + Word16* pIm; + Word16* gwlpr_fxPlus1; + Word32 L_nf; + Word32 L_XavgL2_fx[MAX_LGW + 1]; + Word32 L_XavgUp_fx[MAX_LGW + 1]; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhEcu::nonpure_tone_ana_fx"); +#endif + + Word16 nonpure_tone_detect; /* output variable */ + Word16 n_ind, tone_ind, low_ind, high_ind; + Word16 peak_amp, peak_amp2, valley_amp, x_abs[(1 + 2 * ONE_SIDED_SINE_WIDTH + 2 * 1)]; + + Word16 sineband_ind_low, sineband_ind_high; + Word16 i, N_grp; + Word16 tmp; + + Word32 L_Ltot_inc_HF, L_Ltot_inc_LF; + Word32 L_tmp_dB; + + const Word16* pRe; + const Word16* pIm; + const Word16* gwlpr_fxPlus1; + Word32 L_nf; + Word32 L_XavgL2_fx[MAX_LGW + 1], L_tmp ; + Word32 L_XavgUp_fx[MAX_LGW + 1]; /* upscaled values , excluding peak band(s) */ + + /* use of a compressed hearing sensitivity curve allowing more energy deviation in highest and lowest bands */ + /* ROM table Word16 scATHFx[MAX_LGW - 1] */ + + /* init */ + nonpure_tone_detect = 0; move16(); /* Word16 register with decisions */ + + peak_amp = 0; move16(); + peak_amp2 = 0; move16(); + + /* limit single sine optimization to when 2 peaks are close enough to represent a single sinusoid */ + test(); + if ((sub(n_plocs, 2) == 0) && + (sub(sub(plocs[1], plocs[0]), ONE_SIDED_SINE_WIDTH) >= 0) + ) /* NB, plocs is an ordered vector */ + { + nonpure_tone_detect = s_or(nonpure_tone_detect, 0x01); + } + + /* local bin wise dynamics analysis, for 1 or 2 initial local maxima peaks , + if 2 peaks , we do the analysis based on the location of the largest abs peak */ + { + tone_ind = 0; move16(); /* one peak only , use position plocs[tone_ind], tone_ind==0 */ + + peak_amp = shr(abs_s(X[0]), 1); /* plocs[0]=0, simply multiply DC*0.5 to match scaling in function sqrtMagnApprox_fx */ + test(); + IF(plocs[0] != 0) + { + peak_amp = sqrtMagnApprox_fx(X[plocs[0]], X[sub(Lprot, plocs[0])]); + } + + IF(sub(n_plocs, 2) == 0) /* locate abs max peak */ + { + peak_amp2 = sqrtMagnApprox_fx(X[plocs[1]], X[sub(Lprot, plocs[1])]); /* Re-part and Im-part in different ends of array X */ + + tmp = sub(peak_amp, peak_amp2); + tone_ind = lshr(tmp, 15); /* mask out sign bit 0(for peak_amp0), 1( for peak_amp2), lshr --> no sign extension in shift */ + peak_amp = s_max(peak_amp, peak_amp2); + } + + low_ind = s_max(1, sub(plocs[tone_ind], (ONE_SIDED_SINE_WIDTH + 1))); /* DC is not allowed in the range */ + high_ind = s_min(sub(shr(Lprot, 1), 2), add(plocs[tone_ind], (ONE_SIDED_SINE_WIDTH + 1))); /* Fs/2 is not allowed in the range */ + + n_ind = add(sub(high_ind, low_ind), 1); + /* find lowest amplitude around the assumed main lobe center location */ + + pRe = &(X[low_ind]); /* ptr init */ + pIm = &(X[Lprot - low_ind]); /* ptr init*/ + FOR(i = 0; i < n_ind; i++) + { + x_abs[i] = sqrtMagnApprox_fx(*pRe++, *pIm--); move16(); /* x_abs is downscaled by 0.5 in abs(complex) approximation */ + } + + valley_amp = peak_amp; move16(); + FOR(i = 0; i < n_ind; i++) + { + valley_amp = s_min(x_abs[i], valley_amp); + } + + /* at least a localized amplitude ratio of 16 (24 dB) required to declare a pure noise-free sinusoid */ + if (sub(shr(peak_amp, 4), valley_amp) < 0) /* 1/16 */ + { + nonpure_tone_detect = s_or(nonpure_tone_detect, 0x02); /* not a pure tone due to too low local SNR P2V */ + } + } + + + /* analyze LF/ HF bands energy dynamics vs the assumed single tone band ( for one or two peaks found cases ) */ + { + /* Xavg , is a vector of rather rough MDCT based band amplitude estimates in perceptually motivated bands. from approx the last 26 ms of synthesis */ + + /* eval amplitude relations for assumed tonal band vs lower and higher bands */ + /*N_grp = xavg_N_grp[fs_idx];*/ /* { 4 NB , 5 WB , 6 SSWB , 7 SWB, 8 FB }; */ + N_grp = add(fs_idx, 4); + assert(fs_idx < 5); + + + /* establish band(s) with assumed sinusoid tone */ + /* if tone freq location is below first MDCT-band definition, use first band as band location anyway */ + + /* band 0 , 1 , 2 , 3 , ...*/ + /* dct-inds "c" "0"...11, 12...19, 20...35, 36 ... */ + /* gwplr_fx= [ 1 , 12(750Hz), 20(1250Hz) , 36 , ... */ /* lowest lim+1 in gwplr */ + + /* for-loop BASOP version */ + tmp = 0; move16(); + gwlpr_fxPlus1 = &(gwlpr_fx[1]); /* ptr init */ + FOR(i = 0; i < N_grp; i++) + { + if (sub(plocs[tone_ind], gwlpr_fxPlus1[i]) >= 0) + { + tmp = add(i, 1); + } + } + + sineband_ind_low = tmp; move16(); + sineband_ind_high = tmp; move16(); /* typically in the same band as low */ + + /* a single tone may end up on a band border + , handle case when assumed tone is more or less right in-between two perceptual bands +/- 4*62.5 Hz */ + + test(); logic16(); + if ((sineband_ind_high > 0) && + (sub(sub(plocs[tone_ind], ONE_SIDED_SINE_WIDTH), gwlpr_fx[add(sineband_ind_high, 1)]) >= 0) + ) + { + sineband_ind_low = sub(sineband_ind_high, 1); + } + + logic16(); + if ((sub(sineband_ind_low, sub(N_grp, 1)) < 0) && + (sub(add(plocs[tone_ind], ONE_SIDED_SINE_WIDTH), gwlpr_fx[add(sineband_ind_low, 1)]) >= 0) + ) + { + sineband_ind_high = add(sineband_ind_low, 1); + } + } + + /* intraframe(26 ms), weighted LB and HB envelope dynamics/variation analysis */ + /* envelope analysis , + require at least two HF or two LF bands in the envelope taper/roll-off analysis , otherwise skip this condition */ + + logic16(); + test(); logic16(); + IF( (nonpure_tone_detect == 0) && + ( (sub( add(sineband_ind_high, 2), N_grp) < 0 ) || + (sub(sineband_ind_low, 2+1 ) >= 0) + ) + ) + { + + /* delta taper-off analysis solution, less sensitive to input bandwidth limitation and levels */ + + /* test Xavg Word16 result above vs a high resolution Word32 L_Xavg */ + /* strong spectral tilt causes HF to be truncated in Word16 */ + + basop_memcpy(L_XavgUp_fx, L_Xavg, N_grp * sizeof(Word32) ) ; + + /* first remove all energy from the assumed tonal peak band(s) */ + L_XavgUp_fx[sineband_ind_low] = L_min(L_XavgUp_fx[sineband_ind_low], 1); move32(); + L_XavgUp_fx[sineband_ind_high] = L_min(L_XavgUp_fx[sineband_ind_high], 1); move32(); + + tmp = getScaleFactor32_0(L_XavgUp_fx, N_grp); /* o: measured headroom in range [0..32], 32 if all L_x[i] == 0 */ + if (sub(tmp, 32) == 0) + { + nonpure_tone_detect = s_or(nonpure_tone_detect, 0x100); /* also set a flag for an all zero L_Xavg coarse spectrum estimate signal */ + } + + + /* add noise floor to L_Xavg before log2 function call */ + L_nf = L_shl(1L, sub(tmp, 1)); + L_nf = L_max(L_nf, 1L); + for (i = 0; i < N_grp; i++) + { + L_XavgUp_fx[i] = L_shl_sat(L_XavgUp_fx[i], tmp); move32(); /* maximize precision before actual log2_fx(Word32) calc call */ + + L_tmp = L_XavgUp_fx[i]; move32(); + test(); + if (L_tmp <= 0) + { + L_tmp = L_nf; move32(); + } + + /* log2(Upshifted Word32) */ + /* maximize precision in BASOP Log2 function */ + L_XavgL2_fx[i] = BASOP_Util_Log2_lc3plus(L_tmp); /* L_input 1.0 or lower --> output always negative */ + /* add 31.0 to store as fractional bits of an upscaled positive Word32 integer input ) */ + L_XavgL2_fx[i] = L_add(31L << 25, L_XavgL2_fx[i]); /* only diffs added so 31.0 is cancelled out later , in total only values between +/- 2^6 = [-64 ... -64[ are possible */ + } /* band i for L_Xavg calc*/ + /* verify that an assumed clean sine does not have any odd HF content indications by thresholding the accumulated delta rise in LF/HF side lobes */ + L_Ltot_inc_HF = 0; move32(); + for (i = (sineband_ind_high + 1); i < (N_grp - 1); i++) + { + L_tmp_dB = 0; move32(); + if (L_sub(L_Xavg[i], L_Xavg[i + 1]) < 0) /* only increases are accumulated */ + { + L_tmp_dB = L_sub(L_XavgL2_fx[i + 1], L_XavgL2_fx[i]); /* obtain ratio in log2 domain */ + } + L_tmp = Mpy_32_16_lc3plus(L_tmp_dB, scATHFx[i]); /* scATHFx[i] is the ATH weight for band i and band i+1 */ + L_tmp = L_shr_pos(L_tmp, 1); /* Q25 -> Q24 */ + + L_Ltot_inc_HF = L_add(L_Ltot_inc_HF, L_tmp); /* Q24 */ + } + + /* verify that an assumed clean sine does not have any odd LF content by thresholding the accumulated LF reverse up tilt */ + + L_Ltot_inc_LF = 0; move32(); + tmp = s_max(0, sub(sineband_ind_low, 1)); /* could also be pointer init */ + for (i = tmp; i > 0; i--) + { + L_tmp_dB = 0; move32(); + if (L_sub(L_Xavg[i - 1], L_Xavg[i]) > 0) /* only increases are accumulated */ + { + L_tmp_dB = L_sub(L_XavgL2_fx[i - 1], L_XavgL2_fx[i]); /* obtain ratio in log2 domain */ + } + L_tmp = Mpy_32_16_lc3plus(L_tmp_dB, scATHFx[i-1]); /* scATHFx[i-1] is the ATH weight in between band i-1 and band i */ + L_tmp = L_shr_pos(L_tmp, 1); /* Q25 -> Q24 */ + L_Ltot_inc_LF = L_add(L_Ltot_inc_LF, L_tmp); /* Q24 */ + } + + if (L_sub(L_Ltot_inc_HF, SIDE_LIM) > 0) /* side_lim=round(Q24x*0.7474) */ + { + /* 4.5 dB in log2 is 0.7474 */ + nonpure_tone_detect = s_or(nonpure_tone_detect, 0x10); /* still not a pure tone, too great HF side increase */ + } + + if (L_sub(L_Ltot_inc_LF, SIDE_LIM) > 0) /* side_lim=round(Q24x*0.7474) */ + { + /* 4.5 dB in log2 is 0.7474 */ + nonpure_tone_detect = s_or(nonpure_tone_detect, 0x20); /* still not a pure tone, too great HF side increase */ + } + + /* verify that an assumed clean sine does not have any odd LF+HF content by thresholding the accumulated LF+HF unexpected tilt */ + if (L_sub(L_add_sat(L_Ltot_inc_LF, L_Ltot_inc_HF), LFHF_LIM) > 0) /* side_lim=round(Q24x*0.7474) */ + { + /* 6.0 dB in log2 is 0.996578428 */ + nonpure_tone_detect = s_or(nonpure_tone_detect, 0x40); /* still not a pure tone, too great LF+HF side increase */ + } + + } /* bands available*/ + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + + return nonpure_tone_detect; + } +#endif /* CR8_A_PLC_FADEOUT_TUNING plc_phecu_non_pure_ana_fx */ + + + + diff --git a/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c b/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c new file mode 100644 index 000000000..50b694e5c --- /dev/null +++ b/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c @@ -0,0 +1,202 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void plc_phEcu_LF_peak_analysis_fx(Word16 * plocs, /* i/o 0 ... Lprot/2 +1*/ + Word16 * n_plocs, /* i/o 0.. MAX_PLOCS */ + Word32 * L_f0estQ16, /* i/o Q16*/ + const Word16 *mag, /* i: Qx */ + const Word16 stPhECU_f0hzLtpBinQ7, const Word16 stPhECU_f0gainLtpQ15, + const Word16 nSubm, Word16 maxPlocs, + Word8 *scratchBuffer /* Size = 6 * MAX_PLOCS + 42 */ +) + +{ + Counter i, j; + Word16 n_plocs_ana, peakLF_Xval, tmp, f_abs_ind, plocsIntersectFlag; + + Word32 L_fQ7, *L_f0est_prelQ16; + Word16 num_prel = 0, *plocs_prel; + Word16 prel_low, prel_high, start, fin; + Word16 *plocs_old; + Word32 *L_plocsi_old; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("plc_phEcu_LF_peak_analysis_fx", sizeof(struct { + Counter i, j; + Word16 n_plocs_ana, peakLF_Xval, tmp, f_abs_ind, plocsIntersectFlag; + Word32 L_fQ7, *L_f0est_prelQ16; + Word16 num_prel, *plocs_prel; + Word16 prel_low, prel_high, start, fin; + Word16 *plocs_old; + Word32 *L_plocsi_old; + })); +#endif + + + + L_f0est_prelQ16 = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * 7 */ + plocs_prel = (Word16 *)scratchAlign(L_f0est_prelQ16, sizeof(*L_f0est_prelQ16) * 7); /* Size = 2 * 7 */ + plocs_old = (Word16 *)scratchAlign(plocs_prel, sizeof(*plocs_prel) * 7); /* Size = 2 * MAX_PLOCS */ + L_plocsi_old = (Word32 *)scratchAlign(plocs_old, sizeof(*plocs_old) * maxPlocs); /* Size = 4 * MAX_PLOCS */ + + test(); test(); + IF ((*n_plocs > 0) && sub(stPhECU_f0gainLtpQ15, ((Word16)(0.25 * 32768.0))) > 0 && + sub(stPhECU_f0hzLtpBinQ7, (Word16)(2.75 * 128.0)) < 0) + { + + /* % analyze/apply f0Ltp to avoid intermodulation effects below f0 of ~180 Hz + % we only do the f0Ltp-replacement(s) if there is already an established + % fft peak in the region ~fRes to 2.5*fres + fft_peak_eval_plocs = 1:3; + plocsIntersectFlag = intersect(plocs, fft_peak_eval_plocs ); % check for 1,2,3 in plocs */ + + plocsIntersectFlag = 0; move16(); + peakLF_Xval = 0; move16(); + n_plocs_ana = s_min(*n_plocs, 3); + FOR (i = 0; i < n_plocs_ana; i++) + { + tmp = plocs[i]; move16(); + if (sub(tmp, 2) <= 0) /* C index 0, 1,2 checked , [DC, 62.5 Hz, 125Hz ] */ + { + plocsIntersectFlag = add(i, 1); + } + peakLF_Xval = s_max(mag[tmp], peakLF_Xval); + } + + num_prel = 0; move16(); + IF (plocsIntersectFlag != 0) + { /* fft-peak at 0, 62 or 125 Hz */ + /* analyze if ltp-based f0 need to be added or not */ + peakLF_Xval = mult_r(peakLF_Xval, (Word16)(.375 * 32768.0)); /* now as a limit */ + + FOR (i = 1; i <= nSubm; i++) + { + L_fQ7 = L_mult0(i, stPhECU_f0hzLtpBinQ7); /* fractional index stored in L_plocsi */ + f_abs_ind = L_shr_pos(L_add(L_fQ7, 64), 7); /* integer bin index stored in plocs */ + + test(); + IF ((L_sub(L_fQ7, 819) <= 0) && /* % only apply up to ~400hz , 819 = 400/62.5*128 */ + (sub(mag[f_abs_ind], peakLF_Xval) > + 0)) /* % only set as preliminary if relative peak strength is signficant*/ + { + L_f0est_prelQ16[num_prel] = L_shl_pos(L_fQ7, 9); move32(); + plocs_prel[num_prel] = f_abs_ind; move16(); + num_prel = add(num_prel, 1); + } + } + } /*intersectFlag*/ + + /* now replace/ merge new preliminary added peaks with existing plocs and L_f0estQ16 */ + /* note that a previous fake/merged magnitude-determined peak may be replaced by two separated side peaks */ + + /* a general non-optimized list-merging solution below */ + test(); + IF ((num_prel > 0) && (sub(add(num_prel, *n_plocs), MAX_PLOCS) <= 0) /* skip in case plocs list is too large */ + ) + { + prel_low = plocs_prel[0]; move16(); + prel_high = plocs_prel[sub(num_prel, 1)]; move16(); + + /* initial assumption:: all original peaks (1 or 2 of them) are positioned below prel_low */ + start = (*n_plocs); /* at this point 'start' is the location_c where to add any harmonics peaks */ + + FOR (i = sub(*n_plocs, 1); i >= 0; i--) + { + if (sub(plocs[i], prel_low) >= 0) + { + start = i; move16(); + } + } + start = sub(start, 1); /* end of old section to copy before the added/merged section */ + start = s_max(start, -1); /* limit for loop later */ + /*% dbg check low part for a sucessful replace/merge */ + if (start >= 0 && start < *n_plocs) + { + ASSERT(plocs[start] < plocs_prel[0]); + } + + sub(0, 0); + IF (prel_high < plocs[0]) + { + fin = 0; move16(); /*% keep all plocs , just concat */ + } + ELSE + { + fin = *n_plocs; + FOR (i = 0; i < *n_plocs; i++) + { + sub(0, 0); + if (plocs[i] <= prel_high) + { + fin = i; move16(); + } + } + fin = add(fin, 1); /* first element in high part of old plocs to be copied */ + } + + /*% dbg check high part for a sucessful replace/merge */ + if (fin >= 0 && fin < *n_plocs) + { + ASSERT(plocs_prel[sub(num_prel, 1)] < plocs[fin]); + } + + /* + % actual replace/merge of added integer locations and fractional freqs. into plocs/f0list list ; + % three loops in BASOP + plocs = [ plocs(1:(start)) ; plocs_prel ; plocs((fin):end) ]; + f0est = [ f0est(1:(start)) ; f0est_prel; f0est((fin):end) ]; + */ + + FOR (i = 0; i < *n_plocs; i++) + { + plocs_old[i] = plocs[i]; move16(); + L_plocsi_old[i] = L_f0estQ16[i]; move32(); + } + + /* + j=0; + FOR(i=0; i <= start; i++) + { + plocs[i] = plocs_old[i]; move16(); + L_f0estQ16[i] = L_plocsi_old[i]; move32(); + j++; + } + */ + + j = add(start, 1); + + ASSERT(j>=0); + + FOR (i = 0; i < num_prel; i++) /* NB this section may both insert or overwrite old plocs */ + { + plocs[j] = plocs_prel[i]; move16(); + L_f0estQ16[j] = L_f0est_prelQ16[i]; move32(); + j++; + } + FOR (i = fin; i < *n_plocs; i++) /* copy the tail of the list */ + { + plocs[j] = plocs_old[i]; move16(); + L_f0estQ16[j] = L_plocsi_old[i]; move32(); + j++; + } + + *n_plocs = j; move16(); /* update total length */ + } /* num_prel >0*/ +} /* gain/hz Limits */ + +#ifdef DYNMEM_COUNT +Dyn_Mem_Out(); +#endif + +} + + diff --git a/lib_lc3plus/plc_phecu_peak_locator_fx.c b/lib_lc3plus/plc_phecu_peak_locator_fx.c new file mode 100644 index 000000000..531ee8f6f --- /dev/null +++ b/lib_lc3plus/plc_phecu_peak_locator_fx.c @@ -0,0 +1,385 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +#define RES_fx 1 /* fixed point resolution */ + +/*----------------------------------------------------------------------------- + * peak_locator_fx() + *----------------------------------------------------------------------------*/ +void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 ,Qx */ + const Word16 inp_len, /* i: length of inp */ + Word16 * int_plocs, /* o: array of filtered integer plocs Q0 */ + Word16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ + const Word16 sens, /* i sensitivity, Qx */ + const Word16 inp_high, /* i global high , Qx */ + const Word16 inp_low, /* i: global low, Qx */ + Word16 maxLprot_Red, /* i: optional size for wc memory alloc of scratch buffer */ + Word8 *scratchBuffer /* i: : scratch buffer 2* 3*(1+1+(maxLprot_Red/2)+1) */ +) +{ + Counter j, k, n, idx_high, idx_low; + Word16 inp_len_minus1 ; + Word16 pairs_start, pairs_end; + Word16 *p_tmp; + Word16 prev_delta, curr_delta; + Word16 delta_predc, delta_fin; + Word16 add_dc_flag, add_fin_flag; + Word16 low_val_cand_pairs, val_range; + Word16 num_pairs, n_tail_values; + Word16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; + + Word16 cand_high, prev_low; + Word16 *sc_idx; /* 1+ 128/2+1, or 1+ 256/2+1 ... 1+ 640/2+1 or 1+ 768/2+1*/ + Word16 *cand_pairs_buf ; /* actually lowVal + [DC ] + (368/2)pairs + [FS/2] */ + Word16 *cand_pairs; /* actually [DC ] + pairs + [FS/2] */ + Word16 * fsc_idx; /* list of high locations in sc__idx 1+368/2+1 */ + + + + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("peak_locator_fx", sizeof(struct { + Counter j, k, n, idx_high, idx_low; + Word16 inp_len_minus1; + Word16 pairs_start, pairs_end; + Word16 *p_tmp; + Word16 prev_delta, curr_delta; + Word16 delta_predc, delta_fin; + Word16 add_dc_flag, add_fin_flag; + Word16 low_val_cand_pairs, val_range; + Word16 num_pairs, n_tail_values; + Word16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; + Word16 cand_high, prev_low; + Word16 *sc_idx; + Word16 *cand_pairs_buf; + Word16 *cand_pairs; + Word16 *fsc_idx; + })); +#endif +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::peak_locator_fx(1st)"); +#endif + sc_idx = (Word16 *)scratchAlign(scratchBuffer, 0); /* ByteSize = 2 * (1+ inp_len+1) */ + cand_pairs_buf = (Word16 *)scratchAlign(sc_idx, sizeof(*sc_idx) * (1+inp_len+1)); /* ByteSize = 2 * (1+ 1+ inp_len+1 ) */ + fsc_idx = (Word16 *)scratchAlign(cand_pairs_buf , sizeof(*cand_pairs_buf) * (1+ 1+ inp_len+1)); /* ByteSize = 2 * ( 1+ inp_len + 1) */ + ASSERT((4 * maxLprot_Red) >= 3 * (1 + 1 + inp_len + 1)); /* basic buffer check */ + UNUSED(maxLprot_Red); + + inp_len_minus1 = sub(inp_len, 1); /* size of delta=derivative array ,and last index in inp */ + + cand_pairs = &cand_pairs_buf[1]; /* ptr init , make space for storing a lowest amplitude value in location -1 */ + pairs_start = 1; move16(); /* adjusted to zero or 1 or 2 when/if, DC is injected as sc_idx[0], or initial plateau skipped */ + + p_tmp = &(sc_idx[pairs_start]); /* ptr init */ + + + /* xor high/low pairs of delta_inp and save sign changes */ + prev_delta = sub(inp[1], inp[0]); /* precompute very first delta */ + + FOR(n = 1; n < inp_len_minus1; n++) + { /* sign change analysis */ + curr_delta = sub(inp[n + 1], inp[n]); /* n+1 ,n , are loop ptrs */ + if (s_xor(prev_delta, curr_delta) < 0) /* a "0" delta treated as a positive sign */ + { + *p_tmp++ = n; move16(); /* store sign change bin locations , location n in the inp[] signal */ + } + prev_delta = curr_delta; move16(); + } + + L_sub(0, 0); /* account for length calculaton */ + k = (Word16)(p_tmp - &(sc_idx[pairs_start])); + + + /* copy sign change location values to a pairs array */ + /* leave one initial sc_idx location open for a potential initial DC value */ + + ASSERT(pairs_start >= 0 && ((k - 1) + pairs_start) < (inp_len +2)); + FOR(j = 0; j < k; j++) + { + cand_pairs[j + pairs_start] = inp[sc_idx[j + pairs_start]]; move16(); move16(); /* the indirect should be calculated */ + } + + + /* filter away a potential single initial/trailing plateau + to enable correct analysis for adding DC or fs/2 bins */ + + logic16(); + IF((sub(k, 2) >= 0) && + (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) == 0)) + { + pairs_start = add(pairs_start, 1); + k = sub(k, 1); + } + + /* filter away potential single trailing plateu */ + pairs_end = sub(add(pairs_start,k), 1); /* point to last established sign change element */ + logic16(); + if ((sub(k, 2) >= 0) && + (sub(cand_pairs[sub(pairs_end,1)], cand_pairs[pairs_end]) == 0)) + { + k = sub(k, 1); + } + pairs_end = sub(add(pairs_start,k), 1); /* recalc ptr to last element */ + + + /* conditionally add high/lows on both sides of input (pre_dc or fin) as candidates */ + add_dc_flag = 0; move16(); + add_fin_flag = 0; move16(); + + + IF(sub(k, 1) == 0) /* one single sign change found special case */ + { + if (sub(inp[0], cand_pairs[pairs_start]) != 0) + { + add_dc_flag = 1; move16(); /* not plateau */ + } + + if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) != 0) + { + add_fin_flag = 1; move16(); /* not plateau */ + } + } + + IF(sub(k, 2) >= 0) + { + delta_predc = sub(cand_pairs[pairs_start + 1], cand_pairs[pairs_start]); + delta_fin = sub(cand_pairs[pairs_end], cand_pairs[pairs_end - 1]); + + /* plateaus are allowed to be detected by xor sign change, + but still not allowed at the start nor at the end */ + + add_dc_flag = 1; move16(); + if (sub(inp[0], cand_pairs[pairs_start]) == 0) + { + add_dc_flag = 0; move16(); /* plateau down or , plateus up., --> do not add DC */ + } + + logic16(); + if ((sub(inp[0], cand_pairs[pairs_start]) < 0) && (delta_predc > 0)) + { + add_dc_flag = -1; move16(); /*UP - up ... replace */ + } + logic16(); + if ((sub(inp[0], cand_pairs[pairs_start]) > 0) && (delta_predc < 0)) + { + add_dc_flag = -1; move16(); /* DOWN - down ... % replace */ + } + + add_fin_flag = 1; move16(); + if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) == 0) + { + add_fin_flag = 0; move16(); /* up - plateau ... */ + } + logic16(); + if ((delta_fin > 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) < 0)) + { + add_fin_flag = -1; move16(); /* up - UP ... % replace , hard to hit */ + } + logic16(); + if ((delta_fin < 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) > 0)) + { + add_fin_flag = -1; move16(); /*down - DOWN ... % replace */ + } + + } + + IF(add_dc_flag > 0) + { /* add DC */ + pairs_start = sub(pairs_start, 1); + cand_pairs[pairs_start] = inp[0]; move16(); + sc_idx[pairs_start] = 0; move16(); + ASSERT(pairs_start >= 0 && pairs_start <= 2); + k = add(k, 1); + } + IF(add_dc_flag < 0) + { /* -1 --> replace with DC*/ + cand_pairs[pairs_start] = inp[0]; move16(); + sc_idx[pairs_start] = 0; move16(); + ASSERT(pairs_start >=0 && pairs_start <= 2); + } + + IF(add_fin_flag > 0) + { /* add FS/2 */ + pairs_end = add(pairs_end, 1); + cand_pairs[pairs_end] = inp[inp_len_minus1]; move16(); + sc_idx[pairs_end] = inp_len_minus1; move16(); + k = add(k, 1); + } + IF(add_fin_flag < 0) + { /* -1, replace tail with FS/2*/ + cand_pairs[pairs_end] = inp[inp_len_minus1]; move16(); + sc_idx[pairs_end] = inp_len_minus1; move16(); + } + /* preliminary cand_pairs now only have highs , lows , no initial/trailing plateaus */ + + + /* we allow the DC/FsBy2 lows to be used as the candidatelLow */ + low_val_cand_pairs = inp_low; move16(); + val_range = sub( inp_high, low_val_cand_pairs); /* used to determine if search is useful at all */ + + logic16(); + if ((sub(val_range, RES_fx) < 0) || + (sub( inp_high, sens) < 0)) + { + k = 0; move16(); + } + + logic16(); + if ((k == 0) && (sub(val_range, sens) >= 0)) + { + k = 1; move16(); + } + + + IF(sub(k, 2) > 0) + { + /* low, high, low, ... or + high, low, high, ...*/ + + cand_phase_start = pairs_start; move16(); /*assume first candidate is a high */ + if (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) < 0) + { + cand_phase_start = add(pairs_start, 1); /* first is a low, --> skip to next higher cand */ + } + + /* high, low, high, ... */ + tmp = k; move16(); + if (sub(cand_phase_start, pairs_start) != 0) + { + tmp = sub(tmp, 1); + } + num_pairs = shr(tmp, 1); + n_tail_values = sub(tmp, shl(num_pairs, 1)); + + /* filter preliminary sign changes into sensitivity filtered sign changes */ + + *n_fsc = 0; move16(); /* counter of filtered fsc_idx */ + cand_high = low_val_cand_pairs; move16(); + cand_idx = -1; move16(); /* sentinel location for no high cand found yet. */ + cand_pairs[-1] = low_val_cand_pairs; move16(); + + prev_low = low_val_cand_pairs; move16(); + prev_low_plus_sens = add(prev_low, sens); + + /* filter loop for high - low sign change pairs */ + /* idx_high, idx_low are raw pointers into the cand_pairs and sc_idx arrays */ + + FOR( idx_high = cand_phase_start; idx_high < (cand_phase_start + 2 * num_pairs); idx_high += 2) + { + idx_low = idx_high+1; /* loop ptr increase */ + + /* new high candidate larger than previous candidate and */ + /* sensitivity still larger than the the previous low */ + tmp = s_max(cand_high, prev_low_plus_sens); + if(sub(cand_pairs[idx_high], tmp) > 0) + { + cand_idx = idx_high; move16(); /* enable or shift candidate position fwd */ + } + cand_high = cand_pairs[cand_idx]; move16(); /* NB, cand_pairs[-1] , has the low_val_cand_pairs value stored */ + + /* now check the fwd idx_low of the current {high,low} pair */ + prev_low = s_min(cand_pairs[idx_low], prev_low); + + tmp = sub(cand_high, sens); + IF(sub(tmp, cand_pairs[idx_low]) > 0) + { + /* this low point is now low enough to fix a previous high candidate */ + + fsc_idx[*n_fsc] = cand_idx; move16(); /*% add cand high idx -> output idx list*/ + *n_fsc = add(*n_fsc, 1); + + prev_low = cand_pairs[idx_low]; move16(); /* use this value as new low estimate */ + cand_idx = -1; move16(); /* no candidate until next pair or tail bin, and pt to lowVal */ + cand_high = low_val_cand_pairs; move16(); /* enable next candidate to be selected immediately */ + } + prev_low_plus_sens = add(prev_low, sens); + } /* { high, low} FOR loop */ + + logic16(); + IF((n_tail_values == 0) && (cand_idx >= 0)) + { + /* no tail low or high value to analyze + still may need to lock a non-locked but qualified candidate */ + fsc_idx[*n_fsc] = cand_idx; move16(); + *n_fsc = add(*n_fsc, 1); + } + + + /* cand_pairs vector may have a last orphan value */ + IF(n_tail_values > 0) + { + /* cand_pairs vector may have a last orphan tail value */ + /* + logic boils down to if (nTailValues > 0) && (cand_pairs(n_end) > tmp) + there is a last one trailing high to process + + a) the last high, may be a new high Peak if we have not yet + locked the current candidate + b) if we have locked the last candidate, the last high may also be + a highpeak if it is high enough from the(newly set previous) valley floor. + + tmp=a||b + */ + + tmp = s_max(cand_high, prev_low_plus_sens); + tmp = sub(cand_pairs[pairs_end], tmp); + IF(tmp > 0) + { + fsc_idx[*n_fsc] = pairs_end; move16(); + *n_fsc = add(*n_fsc, 1); + } + ELSE + { + IF(cand_idx >= 0) + { /* we have a previously established high candidate */ + fsc_idx[*n_fsc] = cand_idx; move16(); + *n_fsc = add(*n_fsc, 1); + } + + } + } + /* move high locations info from fsc_idx , to output */ + FOR(j = 0; j < *n_fsc; j++) + { + ASSERT(fsc_idx[j] >= 0 && fsc_idx[j] < (inp_len+2)); + int_plocs[j] = sc_idx[fsc_idx[j]]; move16(); move16(); /* the indirect moves are calculated */ + } + + } /* end of pairs + [tail] section filtering */ + ELSE + { + /* constant/single rise or constant decay or very low overall values, cases */ + *n_fsc = 0; move16(); + + logic16(); + tmp = sub(inp_high, sens); + IF((k != 0) && (sub(tmp, low_val_cand_pairs) > 0)) + { + /* low,high */ + /* high,low */ + tmp = plc_phEcu_find_ind_fx(inp, inp_len, inp_high); move16(); + int_plocs[0] = tmp; move16(); /* simply locate the high peak*/ + *n_fsc = 1; move16(); + if (tmp < 0) + { /*safety in case max value index was not found */ + *n_fsc = 0; move16(); + } + } + } +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} + diff --git a/lib_lc3plus/plc_phecu_setf0hz_fx.c b/lib_lc3plus/plc_phecu_setf0hz_fx.c new file mode 100644 index 000000000..6fffe632c --- /dev/null +++ b/lib_lc3plus/plc_phecu_setf0hz_fx.c @@ -0,0 +1,60 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +/* +st_PhECU_f0minLtp=55; % 55.4 Hz +st_PhECU_f0maxLtp=376; % 376.4706 Hz + +*/ + + +Word16 +plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits mantissa, 7 binomial" [0-255.9999] */ + Word16 fs_idx, Word16 old_pitch_int, Word16 old_pitch_fr) +{ + Word16 pitch_lagQ2, result, expo; + Word32 L_result, L_tmp; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("plc_phEcuSetF0Hz_fx", sizeof(struct { + Word16 pitch_lagQ2, result, expo; + Word32 L_result, L_tmp; + Word16 num_FsByResQ0[5]; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::plc_phEcuSetF0Hz_fx"); +#endif + + result = 0; move16(); + IF (old_pitch_int != 0) + { + pitch_lagQ2 = add( + old_pitch_fr, + shl(old_pitch_int, 2)); /* lag at the current fs_idx , max lag_value is is 228(+.75)*48/12.8 = 858 in Q0 */ + + L_result = plc_phEcu_ratio_fx(L_deposit_h(num_FsByResQ0[fs_idx]), L_deposit_h(pitch_lagQ2), &expo); + L_tmp = L_shl_sat(L_result, sub(11, expo)); /* move to Q7, in high word to allow round*/ + result = round_fx(L_tmp); + } +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + + return result; /*Q7*/ +} + + diff --git a/lib_lc3plus/plc_phecu_tools_fx.c b/lib_lc3plus/plc_phecu_tools_fx.c new file mode 100644 index 000000000..13e90fa49 --- /dev/null +++ b/lib_lc3plus/plc_phecu_tools_fx.c @@ -0,0 +1,247 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +/* initilize a short vector */ +void plc_phEcu_initWord16(Word16 * vec, /*i/o : short vector pointer */ + const Word16 value, /*i : short initialization value */ + const Word16 len) /*i : number of elements */ +{ + Counter n; + + FOR (n = 0; n < len; n++) + { + vec[n] = value; move16(); + } +} + +/* scale inplace with allowed saturation in upscaling , function not available in basop_util */ +void Scale_sig_sat(Word16 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +) +{ + Counter i; + Word16 tmp; + IF (exp0 > 0) + { + FOR (i = 0; i < lg; i++) + { + x[i] = shl_sat(x[i], exp0); move16(); /* no saturation warnings triggered here */ + } + return; + } + IF (exp0 < 0) + { + tmp = shl(-32768, s_max(exp0, -15)); /* we use negative to correctly represent 1.0 */ + FOR (i = 0; i < lg; i++) + { + x[i] = msu_r(0, x[i], tmp); move16(); /* msu instead of mac because factor is negative */ + } + return; + } +} + +void plc_phEcu_minval_fx(const Word16 *inp, /* i : vector */ + const Word16 len, /* i : length */ + Word16 *minvalPtr /* o : min value Ptr */ +) +{ + Word16 minTmp; + Counter pos; + + minTmp = inp[0]; move16(); + assert(len>1); + FOR (pos = 1; pos < len; pos++) + { + minTmp = s_min(inp[pos], minTmp); + } + + *minvalPtr = minTmp; move16(); +} + +void plc_phEcu_maxval_fx(const Word16 *inp, /* i : vector */ + const Word16 len, /* i : length */ + Word16 *maxvalPtr /* o : *maxvalPtr */ +) +{ + Word16 maxTmp; + Counter pos; + + maxTmp = inp[0]; move16(); + + assert(len>1); + FOR (pos = 1; pos < len; pos++) + { + maxTmp = s_max(inp[pos], maxTmp); + } + *maxvalPtr = maxTmp; move16(); +} + +/* in case a value (e.g max or min) is already known , find the first corresponding array index */ +Word16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const Word16 *inp, /* i : vector */ + const Word16 len, /* i : length */ + const Word16 val /* i : value to find */ +) +{ + Word16 val_ind; + Counter pos; + + val_ind = -1; move16(); + + FOR(pos = 0; pos < len; pos++) + { + if (sub(inp[pos], val) == 0) + { + val_ind = pos; move16(); + } + } + return val_ind; +} + +/*----------------------------------------------------------------------------- + * ratio_fx() + * + * Divide the numerator by the denominator. + *----------------------------------------------------------------------------*/ +Word16 plc_phEcu_ratio_fx( /* o : quotient in Q14 */ + const Word32 numer, /* i : numerator */ + const Word32 denom, /* i : denominator */ + Word16 *expo) /* o : req shift of quotient */ +{ + Word16 expNumer, expDenom; + Word16 manNumer, manDenom; + Word16 quotient; +#ifdef DYNMEM_COUNT + Dyn_Mem_In("plc_phEcu_ratio_fx", sizeof(struct { + Word16 expNumer, expDenom; + Word16 manNumer, manDenom; + Word16 quotient; + })); +#endif + + expDenom = norm_l(denom); /* exponent */ + manDenom = extract_h(L_shl(denom, expDenom)); /* mantissa */ + expNumer = norm_l(numer); /* exponent */ + manNumer = extract_h(L_shl(numer, expNumer)); /* mantissa */ + manNumer = shr_pos(manNumer, 1); /* Ensure the numerator < the denominator */ + quotient = div_s(manNumer, manDenom); /* in Q14 */ + + *expo = sub(expNumer, expDenom); +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + return quotient; /* Q14 */ +} + +Word32 winEnCalc( /* o: output summed energy Ltot */ + const Word16 *x, /* i: Input signal */ + const Word16 headroom_shift, /* i: headroom_shift */ + const Word16 *win, /* i: left side Window coefficients */ + const Word16 rectLength, /* i: Offset in between the 1st and 2nd symmetric halves of the Hamming window */ + const Word16 halfLength, /* i: Half of the total length of a complete Hamming window. */ + Word16 *exp /* i/o : i exp of Word16 variable x , o:Lexp of output Word32 sum */ + ) +{ + Counter i; + Word32 L_tot; + const Word16 *pX, *pW; + Word16 tmp, tmp_RL; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("PhEcu::GF::winEnCalc", sizeof(struct { + Counter i; + Word32 L_tot; + const Word16 *pX, *pW; + Word16 tmp, tmp_RL; + })); +#endif + + +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::winEnCalc"); +#endif + + L_tot = INT32_MAX; move32(); /*acc is on negative side , but as all accumulation is positive, we make use of one extra bit */ + pX = x; + pW = win; + + + assert( headroom_shift>=0 ); + FOR (i = 0; i < halfLength; i++) /* 1st symmetric half of the Hamming window */ + { + tmp = mult(*pX++, *pW++); + tmp = shr_pos(tmp, headroom_shift); /* shr may/create bias on the negative side , costly options are shr_r or use msu_r */ + L_tot = L_msu0(L_tot, tmp, tmp); /* acc on negative energy side */ + } + + /* Periodic filter - one more rect sample before end tapering */ + tmp_RL = add(rectLength, 1); + ASSERT(rectLength != 0); + + FOR (i = 0; i < tmp_RL; i++) /* If rectLength is zero, it's a pure Hamming window; otherwise Hamming-Rectangular. */ + { + tmp = shr_pos( *pX++, headroom_shift); + L_tot = L_msu0(L_tot, tmp, tmp); /* acc on negative side */ + } + + tmp_RL = sub(halfLength, 1); + ASSERT(rectLength != 0); + + FOR (i = 0; i < tmp_RL; i++) /* 2nd symmetric half of the Hamming window. */ + { + tmp = mult(*pX++, *(--pW)); + tmp = shr_pos(tmp, headroom_shift); + L_tot = L_msu0(L_tot, tmp, tmp); + } + + /* Lexp = 2*(incoming_exp + dnshift) + 1 , 2x for square + 1(for msu0 DSP dn shift)*/ + *exp = add(shl_pos(add(*exp, headroom_shift),1),1); + + /* handle wrap on zero point */ + IF( L_tot >= 0 ) + { /* L_tot positive --> less than 32 bits needed, */ + L_tot = L_add(L_tot,(INT32_MIN+1)); + if( L_tot == 0 ) + { + *exp = LTOT_MIN_EXP; /* WC is actually (-(15+4)*2 + 1 +1 -31) */ ; move16(); + } + L_tot = L_min(L_tot, -1); /* make sure there is energy for future ratio calculations */ + } + ELSE + { /* L_tot negative --> more than 31 bits needed for sum , scale 32 bit sum within 31 bits and adjust exp */ + + L_tot = L_shr_pos(L_add(L_tot,1),1); /* rnd by adding 1, then use 50% contribution from negative side */ + L_tot = L_add(L_tot, INT32_MIN>>1); /* add 50% contribution from positive side */ + + *exp = add(*exp, 1); move16(); + } + + L_tot = L_max( -(INT32_MAX), L_tot); /* guard against max accumulation on the negative side , should only occur for rectangle windows */ + L_tot = L_negate(L_tot); /* no saturation here */ + + /* activate when xfp_exp is not used any longer */ + /* pre-maximize the mantissa for the following steps in burst_ana_dx */ + tmp = norm_l(L_tot); + L_tot = L_shl(L_tot,tmp); + *exp = sub(*exp, tmp); move16(); + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + + return L_tot; +} + diff --git a/lib_lc3plus/plc_tdac_fx.c b/lib_lc3plus/plc_tdac_fx.c new file mode 100644 index 000000000..c27cc9e7a --- /dev/null +++ b/lib_lc3plus/plc_tdac_fx.c @@ -0,0 +1,217 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +/* + * processTdac_fx + * + * Parameters: + * ola_mem o: pointer of output signal Q0 + * ola_mem_exp o: exponent of output signal Q0 + * synth i: pointer of input signal Q0 + * synth_exp i: exponent of input signal Q0 + * win i: pointer of analysis and synthesis window Q0 + * la_zeroes i: number of zeroes Q0 + * frame_len i: frame length Q0 + * + * Function: + * + * + * Returns: + * void + */ +void processTdac_fx(Word16 *ola_mem, Word16 *ola_mem_exp, const Word16 *synth_inp, const Word16 synth_exp_inp, +#ifdef ENABLE_HR_MODE + const Word32 *win, +#else + const Word16 *win, +#endif + const Word16 la_zeroes, const Word16 frame_len, Word8 *scratchBuffer) +{ + Counter i; + Word16 s; + Word16 L; + Word16 N; + Word16 NZ; + Word16 LD2; + Word32 sz; + Word16 INV_NORM; + Word16 INV_NORM_E; + Word16 smax; + Word16 * synth; + Word16 synth_len; + Word16 synth_exp; +#ifdef ENABLE_HR_MODE + const Word32 *win1, *win2, *win3, *win4; +#else + const Word16 *win1, *win2, *win3, *win4; +#endif + const Word16 *synth1; + const Word16 *synth2; + Word16 * ola_mem1; + Word16 * ola_mem2; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processTdac_fx", sizeof(struct { + Counter i; + Word16 s; + Word16 L; + Word16 N; + Word16 NZ; + Word16 LD2; + Word32 sz; + Word16 INV_NORM; + Word16 INV_NORM_E; + Word16 smax; + Word16 * synth; + Word16 synth_len; + Word16 synth_exp; + const Word16 *win1; + const Word16 *win2; + const Word16 *win3; + const Word16 *win4; + const Word16 *synth1; + const Word16 *synth2; + Word16 * ola_mem1; + Word16 * ola_mem2; + })); +#endif + + synth = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN */ + + ASSERT(la_zeroes <= frame_len / 2); + + L = frame_len; move16(); + LD2 = shr_pos(L, 1); + NZ = sub(LD2, la_zeroes); + + /* inverse normalization of sqrt(2/N) inside window */ +#ifdef ENABLE_HR_MODE + IF ((sub(frame_len, 960) == 0) || (sub(frame_len, 720) == 0)) + { + INV_NORM = negate(shl_pos(frame_len, (15 - 10))); + INV_NORM_E = 3; move16(); + } + ELSE +#endif + { + INV_NORM = negate(shl_pos(frame_len, (15 - 9))); + INV_NORM_E = 2; move16(); + if (norm_s(INV_NORM) > 0) + { + INV_NORM = shl_pos(INV_NORM, 1); + INV_NORM_E = 1; move16(); + } + if (sub(frame_len, 120) <= 0) + { + INV_NORM_E = add(INV_NORM_E, 2); + } + if (sub(frame_len, 20) <= 0) + { + INV_NORM_E = add(INV_NORM_E, 2); + } + } + + /* Scale input */ + synth_len = sub(shl_pos(L, 1), la_zeroes); + s = getScaleFactor16(synth_inp, synth_len); + + FOR (i = 0; i < synth_len; i++) + { + synth[i] = shl(synth_inp[i], s); move16(); + } + synth_exp = sub(synth_exp_inp, s); + + /* calculate x_ov[L+la_zeroes] ... x_ov[2*L-1] */ + + win1 = &win[L + LD2 - 1]; + win2 = &win[L + LD2]; + + win3 = &win[LD2 - 1]; + win4 = &win[LD2]; + + synth1 = &synth[L + LD2 - 1 - la_zeroes]; + synth2 = &synth[L + LD2 - la_zeroes]; + + ola_mem1 = &ola_mem[LD2 - la_zeroes]; + ola_mem2 = &ola_mem[LD2 - la_zeroes - 1]; + + smax = 15; move16(); + + FOR (i = 0; i < NZ; i++) + { + /* analysis windowing + 2N -> N */ + sz = L_mac_sat(L_mult(*synth1, extractW16(*win1)), *synth2, extractW16(*win2)); + + /* N -> 2N + synthesis windowing */ + *ola_mem1 = round_fx(Mpy_32_16_lc3plus(sz, extractW16(*win3))); move16(); + *ola_mem2 = round_fx(Mpy_32_16_lc3plus(sz, extractW16(*win4))); move16(); + + /* determine headroom */ + s = norm_s(*ola_mem1); + if (*ola_mem1 != 0) + smax = s_min(smax, s); + s = norm_s(*ola_mem2); + if (*ola_mem2 != 0) + smax = s_min(smax, s); + + /* pointer update */ + win1--; + win2++; + win3--; + win4++; + synth1--; + synth2++; + ola_mem1++; + ola_mem2--; + } + + N = LD2; move16(); + + FOR (; i < N; i++) + { + /* analysis windowing + 2N -> N */ + sz = L_mult(*synth1, extractW16(*win1)); + + /* N -> 2N + synthesis windowing */ + *ola_mem1 = round_fx(Mpy_32_16_lc3plus(sz, extractW16(*win3))); move16(); + + /* determin headroom */ + s = norm_s(*ola_mem1); + if (*ola_mem1 != 0) + smax = s_min(smax, s); + + /* pointer update */ + win1--; + win2++; + win3--; + synth1--; + synth2++; + ola_mem1++; + } + + smax = s_min(smax, 15); + + N = add(N, NZ); + + FOR (i = 0; i < N; i++) + { + ola_mem[i] = round_fx(L_mult(shl(ola_mem[i], smax), INV_NORM)); move16(); + } + + *ola_mem_exp = sub(add(synth_exp, INV_NORM_E), smax); move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/plc_tdc_inverse_odft_fx.c b/lib_lc3plus/plc_tdc_inverse_odft_fx.c new file mode 100644 index 000000000..1e8e3191c --- /dev/null +++ b/lib_lc3plus/plc_tdc_inverse_odft_fx.c @@ -0,0 +1,130 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processInverseODFT_fx(Word32 *r_fx, Word16 *r_fx_exp, Word32 *d2_fx, Word16 d2_fx_exp, Word16 n_bands, + Word16 lpc_order, Word8 *scratchBuffer) +{ + Counter i; + Word16 s; + Word16 n_bands2; + Word32 * x; + const Word32 *inv_odft_twiddle_re; + const Word32 *inv_odft_twiddle_im; + Word8 * buffer_BASOP_rfftN; + + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processInverseODFT_fx", sizeof(struct { + Counter i; + Word16 s; + Word16 n_bands2; + Word32 * x; + const Word32 *inv_odft_twiddle_re; + const Word32 *inv_odft_twiddle_im; + Word8 * buffer_BASOP_rfftN; + Word32 * params[2]; + })); +#endif + + x = scratchAlign(scratchBuffer, 0); /* Size = 320 bytes */ + buffer_BASOP_rfftN = scratchAlign(x, sizeof(*x) * (MAX_BANDS_NUMBER_PLC + MAX_BANDS_NUMBER_PLC/2)); /* Size = 480 bytes */ + + ASSERT(lpc_order <= M); + ASSERT(n_bands == 80 || n_bands == 60 || n_bands == 40 || n_bands == 20); + + n_bands2 = shr_pos_pos(n_bands, 1); + + test(); + IF (sub(n_bands, 20) == 0 || sub(n_bands, 60) == 0) + { + /* sort input samples */ + FOR (i = 0; i < n_bands2; i++) + { + x[2*i] = d2_fx[2 * i]; move32(); + x[2*i+1] = 0; move32(); + x[n_bands + 2*i] = d2_fx[n_bands - 1 - 2 * i]; move32(); + x[n_bands + 2*i + 1] = 0; move32(); + } + BASOP_cfft_lc3plus(&x[0], &x[1], n_bands, 2, &d2_fx_exp, (Word32*)buffer_BASOP_rfftN); + } + ELSE + { + /* sort input samples */ + FOR (i = 0; i < n_bands2; i++) + { + x[i] = d2_fx[2 * i]; move32(); + x[n_bands2 + i] = d2_fx[n_bands - 1 - 2 * i]; move32(); + } + + BASOP_rfftN(x, n_bands, &d2_fx_exp, buffer_BASOP_rfftN); + } + + inv_odft_twiddle_re = inv_odft_twiddle_80_re; + inv_odft_twiddle_im = inv_odft_twiddle_80_im; + IF (sub(n_bands, 20) == 0) + { + inv_odft_twiddle_re = inv_odft_twiddle_20_re; + inv_odft_twiddle_im = inv_odft_twiddle_20_im; + } + ELSE IF (sub(n_bands, 40) == 0) + { + inv_odft_twiddle_re = inv_odft_twiddle_40_re; + inv_odft_twiddle_im = inv_odft_twiddle_40_im; + } + ELSE IF (sub(n_bands, 60) == 0) + { + inv_odft_twiddle_re = inv_odft_twiddle_60_re; + inv_odft_twiddle_im = inv_odft_twiddle_60_im; + } + + s = norm_l(x[0]); + + /* imag[0] is always zero */ + r_fx[0] = L_shl_pos(x[0], s); move32(); + + /* r_fx[0] = r_fx[0] * 1.0001 */ + r_fx[0] = Mpy_32_32_lc3plus(r_fx[0], 0x4001A36E); move32(); + IF (norm_l(r_fx[0]) > 0) + { + r_fx[0] = L_shl_pos(r_fx[0], 1); + } + ELSE + { + s = sub(s, 1); + } + + /* post-twiddle */ + FOR (i = 1; i <= lpc_order; i++) + { + r_fx[i] = L_add(Mpy_32_32_lc3plus(L_shl(x[2 * i], s), inv_odft_twiddle_re[i - 1]), + Mpy_32_32_lc3plus(L_shl(x[2 * i + 1], s), inv_odft_twiddle_im[i - 1])); move32(); + } + + *r_fx_exp = sub(d2_fx_exp, s); move16(); + + /* r_fx[0] must not be zero */ + IF (r_fx[0] == 0) + { + r_fx[0] = (Word32)0x7FFFFFFF; move32(); + FOR (i = 1; i <= lpc_order; i++) + { + r_fx[i] = 0; move32(); + } + *r_fx_exp = 0; move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/plc_tdc_lagwin_fx.c b/lib_lc3plus/plc_tdc_lagwin_fx.c new file mode 100644 index 000000000..e5bd94d66 --- /dev/null +++ b/lib_lc3plus/plc_tdc_lagwin_fx.c @@ -0,0 +1,32 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processLagwin_fx(Word32 r[], const Word32 w[], Word16 m) +{ + /* Start Processing */ + Counter i; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processLagwin_fx", sizeof(struct { Counter i; })); +#endif + + FOR (i = 0; i < m; i++) + { + r[i + 1] = Mpy_32_32_lc3plus(r[i + 1], w[i]); move32(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/plc_tdc_main_fx.c b/lib_lc3plus/plc_tdc_main_fx.c new file mode 100644 index 000000000..c6558dd1b --- /dev/null +++ b/lib_lc3plus/plc_tdc_main_fx.c @@ -0,0 +1,1257 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +/*****************************************************************************/ + +static Word16 TDC_Dot_product(const Word16 x[], const Word16 y[], const Word16 lg); +static Word32 TDC_L_Dot_product(const Word16 x[], const Word16 y[], const Word16 lg); +static void TDC_highPassFiltering_fx(const Word16 L_buffer, Word16 exc2[], const Word16 l_fir_fer, + const Word16 *hp_filt); +static Word32 TDC_calcGainp(Word16 x[], Word16 y[], Word16 lg); +static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 lg, Word16 frame_dms, Word16 lp_gainp, Word32 *lp_gainc); +static void TDC_random_fx(Word16 *seed, Word16 lg, Word16 *y); +static Word16 TDC_preemph(Word16 *x, const Word16 fac, const Word16 lg); +static void TDC_LPC_residu_fx(const Word16 *a, Word16 *x, Word16 *y, Word16 lg, Word16 m); +static void TDC_deemph_fx(const Word16 *x, Word16 *y, const Word16 fac, const Word16 lg, const Word16 mem); +static void TDC_LPC_synthesis_fx(const Word16 sh, const Word16 a[], const Word16 x[], Word16 y[], const Word16 lg, + const Word16 m); +static void TDC_normalize_energy_fx(Word16 *gain, Word16 *gain_exp, const Word16 *x, const Word16 lg); + +#ifdef CR8_G_ADD_75MS +const Word16 beforeNextIncArray_fx[4][4] = {{0,0,0,1}, + {0,1,0,1}, + {0,1,1,1}, + {1,1,1,1}}; +const Word16 nextIncArray_fx[4][4] = {{1,0,0,0}, + {1,0,1,0}, + {1,0,1,1}, + {1,1,1,1}}; +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR +static Word16 type_2_alpha_long(Word16 nbLostFramesInRow, Word16 frame_dms); +static Word16 powWord16rest(Word16 base, Word16 exp, Word16 rest); +#endif + +/*****************************************************************************/ + + +/* + * processTimeDomainConcealment_Apply_fx + * + * Parameters: + * pitch_int i : integer pitch lag Q0 + * preemphFac_fx i : preemphase factor Q15 + * A_fx i : lp filter coefficients Qx + * pcmbufHist_fx i : pointer to input signal Qq_fx_old_exp + * frame_length i : frame length Q0 + * fs_idx i : sample rate index Q0 + * nbLostFramesInRow i : number of consecutive lost frames Q0 + * overlap i : overlap length Q0 + * stabFac_fx i : stability factor Q15 + * fract i/o: fraction of lag Q0 + * seed_fx i/o: pointer to seed Q0 + * gain_p_fx i/o: pointer to gainp Q15 + * gain_c_fx i/o: pointer to gainc 15Q16 + * synth_fx o : pointer to synthesized signal Q_syn + * Q_syn o : exponent for synthesized signal Q0 + * alpha o : damping factor Q15 + * scratchBuffer i : scratch buffer + * + * Function: + * Perform the time domain concealment. + * + * Returns: + * void + */ +void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 preemphFac_fx, const Word16 *A_fx, + const Word16 lpc_order, const Word16 *pcmbufHist_fx, const Word16 frame_length, + const Word16 frame_dms, const Word16 fs_idx, const Word16 nbLostFramesInRow, + const Word16 overlap, const Word16 stabFac_fx, Word16 *fract, + Word16 *seed_fx, + Word32 *gain_c_fx, Word16 *synth_fx, Word16 *Q_syn, Word16 *alpha, Word16 max_len_pcm_plc, + Word16 harmonicBuf_fx[MAX_PITCH], Word16 synthHist_fx[M], Word16 *const harmonicBuf_Q, + Word8 *scratchBuffer +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,UWord8 plc_fadeout_type +#endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + ,Word16 * alpha_type_2_table +#endif +) +{ + Counter i; + Word16 s, s1, c1, c2, len, cnt, g_fx, ilen, Tc, nextInc, beforeNextInc; + Word32 tmp32, tmp32_2, gainc_tmp; + Word16 gain_p_fx; + Word32 gain_c_32_fx; + Word16 gain_c_16_fx, gain_c_16_fx_exp, gain_inov_fx, gain_inov_fx_exp, ilen_exp; + Word16 hpBlendFac; + Word16 len_pi_lf_2, frame_length_2, step_fx, step_n_fx, gain_h_fx, nbLostCmpt_loc, mem_deemph; + Word16 * synth_mem_fx, *synth_tmp_fx, *exc2_fx, *exc_fx, *pt_exc, *pt1_exc, *x_pre_fx; + Word16 * harmonicBufPtr; + Word16 Q_exc = 0, exp_scale; + const Word16 *hp_filt_fx, *TDC_high_harm; + Word16 alphaPrev_fx; + Word16 throttle; +#ifdef CR8_G_ADD_75MS + Word16 frame_dms_idx, nbLostFramesInRow_mod; +#endif + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processTimeDomainConcealment_Apply_fx", sizeof(struct { + Counter i; + Word16 s, s1, c1, c2, len, cnt, g_fx, ilen, Tc, nextInc, beforeNextInc; + Word32 tmp32, tmp32_2, gainc_tmp; + Word16 gain_p_fx; + Word32 gain_c_32_fx; + Word16 gain_c_16_fx, gain_c_16_fx_exp, gain_inov_fx, gain_inov_fx_exp, ilen_exp; + Word16 hpBlendFac; + Word16 len_pi_lf_2, frame_length_2, step_fx, step_n_fx, gain_h_fx, nbLostCmpt_loc, mem_deemph; + Word16 * synth_mem_fx, *synth_tmp_fx, *exc2_fx, *exc_fx, *pt_exc, *pt1_exc, *x_pre_fx; + Word16 * harmonicBufPtr; + Word16 Q_exc, exp_scale; + const Word16 *hp_filt_fx, *TDC_high_harm; + Word16 alphaPrev_fx; + Word16 throttle; + Word16 frame_dms_idx, nbLostFramesInRow_mod; + })); +#endif + +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + Word32 plc_fadeout_len = 0; +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + if (plc_fadeout_type >= 1){ +#else + if (plc_fadeout_type == 1){ +#endif + plc_fadeout_len = PLC_FADEOUT_TYPE_1_IN_MS; + } + else{ + plc_fadeout_len = PLC_FADEOUT_IN_MS; + } +#endif + + /* len of output signal */ + len = add(frame_length, overlap); + +#ifdef CR8_G_ADD_75MS + nbLostFramesInRow_mod = sub(nbLostFramesInRow, 1) & 0x0003; + + frame_dms_idx = mult(frame_dms, 0x051F); + nbLostCmpt_loc = add(shr(L_mult0(frame_dms_idx, sub(nbLostFramesInRow, 1)), 2), 1); + frame_dms_idx = sub(frame_dms_idx, 1); + beforeNextInc = beforeNextIncArray_fx[frame_dms_idx][nbLostFramesInRow_mod]; move16(); + nextInc = nextIncArray_fx [frame_dms_idx][nbLostFramesInRow_mod]; move16(); +#else + nbLostCmpt_loc = nbLostFramesInRow; move16(); + nextInc = 1; move16(); + beforeNextInc = 1; move16(); + SWITCH (frame_dms) + { + case 25: + nbLostCmpt_loc = shr(add(nbLostFramesInRow, 3), 2); + nextInc = (nbLostFramesInRow & 0x0003) == 1; move16(); + beforeNextInc = (nbLostFramesInRow & 0x0003) == 0; move16(); + BREAK; + case 50: + nbLostCmpt_loc = shr(add(nbLostFramesInRow, 1), 1); + nextInc = (nbLostFramesInRow & 0x0001) == 1; move16(); + beforeNextInc = (nbLostFramesInRow & 0x0001) == 0; move16(); + BREAK; + } +#endif + +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + IF (sub(nbLostCmpt_loc, plc_fadeout_len / 10) > 0) +#else + IF (sub(nbLostCmpt_loc, PLC_FADEOUT_IN_MS / 10) > 0) +#endif + { + gain_p_fx = 0; move16(); + *gain_c_fx = 0; move32(); + *Q_syn = 0; move16(); + *alpha = 0; move16(); + basop_memset(synth_fx, 0, len * sizeof(Word16)); +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + return; + } + + frame_length_2 = shr_pos(frame_length, 1); + + Tc = pitch_int; move16(); + if (sub(*fract, 0) > 0) + { + Tc = add(Tc, 1); + } + + len_pi_lf_2 = add(Tc, frame_length_2); + + /*---------------------------------------------------------------- + * Buffer Initialization + * + * exc_fx synth_mem_fx + * |--exc_buf_past--|--exc_buf_curr--|--syn_mem--|--x_pre--| + * |--exc2--| + * |--syn--| + * + *---------------------------------------------------------------*/ + + /* pointer inits */ + exc_fx = (Word16 *)scratchAlign(scratchBuffer, + sizeof(Word16) * len_pi_lf_2); /* MAX_PITCH+MAX_LEN/2 + MAX_LEN+MDCT_MEM_LEN_MAX */ + synth_mem_fx = (Word16 *)scratchAlign(exc_fx, sizeof(*exc_fx) * len); /* M */ + x_pre_fx = (Word16 *)scratchAlign(synth_mem_fx, sizeof(*synth_mem_fx) * lpc_order); /* MAX_PITCH+MAX_LEN/2+M+1 */ + exc2_fx = (Word16 *)scratchAlign(synth_mem_fx, sizeof(*synth_mem_fx) * lpc_order); /* MAX_LEN+MDCT_MEM_LEN_MAX+TDC_L_FIR_HP-1 */ + synth_tmp_fx = (Word16 *)scratchAlign(synth_mem_fx, sizeof(*synth_mem_fx) * lpc_order); /* MAX_LEN+MDCT_MEM_LEN_MAX */ + /* Buffers 'overlap' since they are not used at the same time */ + + /*---------------------------------------------------------------* + * LPC Residual * + *---------------------------------------------------------------*/ + IF (sub(nbLostFramesInRow, 1) == 0) + { + + /* copy buffer to pre-emphasis buffer */ + cnt = add(len_pi_lf_2, lpc_order + 1); + basop_memmove(&x_pre_fx[0], &pcmbufHist_fx[max_len_pcm_plc - cnt], cnt * sizeof(Word16)); + + /* apply pre-emphasis to the signal; x_pre = x_pre_flt * 2^(q_fx_old_exp-15-Q_exc+1) */ + Q_exc = TDC_preemph(&(x_pre_fx[1]), preemphFac_fx, sub(cnt, 1)); + + /* copy memory for LPC synth */ + basop_memmove(&synth_mem_fx[0], &x_pre_fx[len_pi_lf_2 + 1], lpc_order * sizeof(Word16)); + + /* LPC Residual; exc = exc_fx * 2^(q_fx_old_exp-15-Q_exc) */ + TDC_LPC_residu_fx(A_fx, &(x_pre_fx[lpc_order + 1]), &(exc_fx[-len_pi_lf_2]), len_pi_lf_2, lpc_order); + } + + /*---------------------------------------------------------------* + * Calculate gains * + *---------------------------------------------------------------*/ + + IF (sub(nbLostFramesInRow, 1) == 0) + { + IF (sub(pitch_int, Tc) == 0) + { + gain_p_fx = + round_fx_sat(L_shl_sat(TDC_calcGainp(&(x_pre_fx[lpc_order + Tc + 1]), &(x_pre_fx[lpc_order + 1]), frame_length_2), 15)); + } + ELSE + { + tmp32 = TDC_calcGainp(&(x_pre_fx[lpc_order + Tc + 1]), &(x_pre_fx[lpc_order + 2]), frame_length_2); + tmp32_2 = TDC_calcGainp(&(x_pre_fx[lpc_order + Tc + 1]), &(x_pre_fx[lpc_order + 1]), frame_length_2); + + IF (L_sub(tmp32, tmp32_2) > 0) + { + Tc = pitch_int; move16(); + gain_p_fx = round_fx_sat(L_shl_sat(tmp32, 15)); + *fract = 0; move16(); + } + ELSE + { + gain_p_fx = round_fx_sat(L_shl_sat(tmp32_2, 15)); + } + } + + if (gain_p_fx < 0) + { + gain_p_fx = 0; move16(); + } + + IF (sub(pitch_int, Tc) == 0) + { + /* gain_c = gain_c_32_fx * 2^(q_fx_old_exp-31) */ + TDC_calcGainc(exc_fx, Q_exc, Tc, frame_length_2, frame_dms, gain_p_fx, &gain_c_32_fx); + } + ELSE + { + TDC_calcGainc(exc_fx, Q_exc, pitch_int, frame_length_2, frame_dms, gain_p_fx, &tmp32); + TDC_calcGainc(exc_fx, Q_exc, Tc , frame_length_2, frame_dms, gain_p_fx, &gain_c_32_fx); + + gain_c_32_fx = L_min(gain_c_32_fx, tmp32); move32(); + } + } + ELSE + { + gain_c_32_fx = *gain_c_fx; move32(); + gain_p_fx = *alpha; + } + + /*---------------------------------------------------------------* + * Damping factor * + *---------------------------------------------------------------*/ + + alphaPrev_fx = 0x7FFF; move16(); + IF (sub(nbLostFramesInRow,1) > 0) + { + alphaPrev_fx = *alpha; move16(); + } +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + IF (sub(plc_fadeout_type,2) == 0 ){ +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + *alpha = alpha_type_2_table[nbLostFramesInRow]; +#else + IF (sub(frame_dms,50) == 0){ + IF (sub(nbLostFramesInRow,30) >= 0){ + *alpha = 0; move16(); + } ELSE { + *alpha = FADE_OUT_TYPE_2_ALPHA_5MS[nbLostFramesInRow]; move16(); + } + } + IF (sub(frame_dms,25) == 0){ + IF (sub(nbLostFramesInRow,60) >= 0){ + *alpha = 0; move16(); + } ELSE { + *alpha = FADE_OUT_TYPE_2_ALPHA_2_5MS[nbLostFramesInRow]; move16(); + } + } +#endif + } + ELSE{ +#endif + IF (nextInc != 0) + { + IF (sub(nbLostCmpt_loc, 1) == 0) + { + /* Threshold 31470 is 0.98^2 in Q15 format */ + IF (sub(gain_p_fx, 31470) > 0) + { + *alpha = 0x7D71; /*0.98f*/ + move16(); + } + /* Threshold 28037 is 0.925^2 in Q15 format */ + ELSE IF (sub(gain_p_fx, 28037) < 0) + { + *alpha = 0x7666; /*0.925f*/ + move16(); + } + ELSE + { + exp_scale = 0; + *alpha = Sqrt16_lc3plus(gain_p_fx, &exp_scale); move16(); + *alpha = shl(*alpha, exp_scale); + } + } + ELSE + { + SWITCH (nbLostCmpt_loc) + { + case 2: + c1 = 0x50A4; /*0.630f*/ + move16(); + c2 = 0x2CCD; /*0.350f*/ + move16(); + BREAK; + default: + c1 = 0x5375; /*0.652f*/ + move16(); + c2 = 0x29FC; /*0.328f*/ + move16(); + BREAK; + } + + *alpha = mult_r(stabFac_fx, c2); + *alpha = add(*alpha, c1); + + *alpha = mult(gain_p_fx, *alpha); + + + IF (sub(nbLostCmpt_loc, 2) == 0) + { + if (sub(*alpha, 0x75A2 /*0.919f*/) < 0) + { + *alpha = 0x75A2; move16(); + } + } + ELSE IF (sub(nbLostCmpt_loc, 5) > 0) + { + gain_p_fx = *alpha; move16(); + } + } + } + + IF (sub(nbLostCmpt_loc,3) > 0) + { + SWITCH (frame_dms) + { + case 25: *alpha = mult(*alpha, PLC34_ATTEN_FAC_025_FX); BREAK; +#ifdef CR9_J_SLOW_TDC_FADEOUT + case 50: *alpha = mult(*alpha, PLC34_ATTEN_FAC_025_FX); BREAK; +#else + case 50: *alpha = mult(*alpha, PLC34_ATTEN_FAC_050_FX); BREAK; +#endif +#ifdef CR8_G_ADD_75MS + case 75: *alpha = mult(*alpha, PLC34_ATTEN_FAC_075_FX); BREAK; +#endif + case 100: *alpha = mult(*alpha, PLC34_ATTEN_FAC_100_FX); BREAK; + } + } + if (sub(nbLostCmpt_loc, 5) > 0) + { + gain_p_fx = *alpha; move16(); + } +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + } +#endif + + /*---------------------------------------------------------------* + * Construct the harmonic part * + * Last pitch cycle of the previous frame is repeatedly copied. * + *---------------------------------------------------------------*/ + + pt_exc = harmonicBuf_fx; move16(); + pt1_exc = exc_fx - Tc; move16(); + s = s_min(len, Tc); move16(); + test(); + IF (sub(nbLostFramesInRow, 1) == 0) + { + *harmonicBuf_Q = Q_exc; move16(); + IF (sub(stabFac_fx, 32767 /*1.f Q15*/) >= 0) + { + basop_memmove(pt_exc, pt1_exc, Tc * sizeof(Word16)); + } + ELSE + { + /* These values are necessary for the last five filtered samples */ + basop_memmove(exc_fx, &exc_fx[-Tc], (TDC_L_FIR_HP-1)/2 * sizeof(Word16)); + TDC_high_harm = TDC_high_32_harm; + if (sub(fs_idx, 1) <= 0) + { + TDC_high_harm = TDC_high_16_harm; + } + FOR (i = 0; i < Tc; i++) + { + pt_exc[i] = TDC_Dot_product(&pt1_exc[i-(TDC_L_FIR_HP-1)/2], TDC_high_harm, TDC_L_FIR_HP); + } + } + } + ELSE + { + Q_exc = *harmonicBuf_Q; move16(); + } + + + /*---------------------------------------------------------------* + * Construct the random part of excitation * + *---------------------------------------------------------------*/ + + TDC_random_fx(seed_fx, add(len, sub(TDC_L_FIR_HP, 1)), exc2_fx); + + /* high pass noise */ + hp_filt_fx = TDC_high_32; + if (sub(fs_idx, 1) <= 0) + { + hp_filt_fx = TDC_high_16; + } + + IF (sub(nbLostFramesInRow, 1) == 0) + { + TDC_highPassFiltering_fx(len, exc2_fx, TDC_L_FIR_HP, hp_filt_fx); + } + ELSE + { + throttle = div_s(nbLostCmpt_loc, add(nbLostCmpt_loc, PLC3_HPBLENDTHROTTLE)); + hpBlendFac = mult(sub(0x7FFF, *alpha), throttle); + c1 = sub(0x7FFF, hpBlendFac); + FOR (i = 0; i < len; i++) + { + /* Return value of dot product is Q1 */ + tmp32 = Mpy_32_16_lc3plus(TDC_L_Dot_product(&exc2_fx[i], hp_filt_fx, TDC_L_FIR_HP), c1 /*Q15*/); + exc2_fx[i] = round_fx(L_mac0(tmp32, hpBlendFac, exc2_fx[i+TDC_L_FIR_HP/2])); move16(); + } + } + + /* normalize energy */ + TDC_normalize_energy_fx(&gain_inov_fx, &gain_inov_fx_exp, exc2_fx, frame_length); + tmp32 = Mpy_32_16_lc3plus( + L_sub(590558016l /*1.1 Q29*/, Mpy_32_16_lc3plus(L_shr_pos(L_deposit_h(gain_p_fx), 2), 24576 /*0.75*/)) /*Q29*/, + gain_inov_fx /*Q15,gain_inov_e*/); /*Q29,gain_inov_e*/ + s = norm_l(tmp32); + tmp32 = L_shl_pos(tmp32, s); + tmp32 = L_min(tmp32, 0x7FFEFFFF); + gain_inov_fx_exp = add(sub(gain_inov_fx_exp, s), 31 - 29); /*->Q31*/ + gain_inov_fx = round_fx(tmp32); /*Q15,gain_inov_e*/ + + /* gains */ + gain_h_fx = alphaPrev_fx; move16(); + + /* update steps */ + if (frame_length == 720) + { + ilen = BASOP_Util_Divide1616_Scale_lc3plus((Word16)1, 960, &ilen_exp); + } else { + ilen = BASOP_Util_Divide1616_Scale_lc3plus((Word16)1, frame_length, &ilen_exp); + } + step_fx = round_fx(L_shl(L_mult(sub(gain_h_fx, *alpha), ilen), ilen_exp)); + + s = norm_l(gain_c_32_fx); + tmp32 = L_shl_pos(gain_c_32_fx, s); + + gain_c_16_fx = extract_h(tmp32); + gain_c_16_fx_exp = sub(15, s); +#ifdef CR9_M_FIX_DIV_ZERO + gainc_tmp = L_mult (gain_c_16_fx, div_s(*alpha, s_max(alphaPrev_fx, 1))); +#else + gainc_tmp = L_mult (gain_c_16_fx, div_s(*alpha, alphaPrev_fx)); +#endif + tmp32 = L_sub (tmp32, gainc_tmp); + step_n_fx = round_fx(L_shl(Mpy_32_16_lc3plus(tmp32, ilen), ilen_exp)); + + /*---------------------------------------------------------------* + * Construct the total excitation * + *---------------------------------------------------------------*/ + + harmonicBufPtr = harmonicBuf_fx + ((nbLostFramesInRow - 1) * frame_length) % Tc; + + s1 = add(Q_exc, add(gain_inov_fx_exp, gain_c_16_fx_exp)); + cnt = add(frame_length, TDC_L_FIR_HP / 2); + + g_fx = mult_r(gain_c_16_fx, gain_inov_fx); + + FOR (i = 0; i < len; i++) + { + /* harmonic */ + if (harmonicBufPtr - harmonicBuf_fx >= Tc) { + harmonicBufPtr = harmonicBuf_fx; + } + exc_fx[i] = *harmonicBufPtr++; + tmp32 = L_mult(exc_fx[i], gain_h_fx); + /* random */ + tmp32_2 = L_shl_sat(L_mult(exc2_fx[i], g_fx), s1); + /* total */ + exc_fx[i] = round_fx_sat(L_add_sat(tmp32, tmp32_2)); move16(); + /* update */ + gain_h_fx = s_max(sub(gain_h_fx, step_fx), 0); + gain_c_16_fx = s_max(sub(gain_c_16_fx, step_n_fx), 0); + g_fx = mult_r(gain_c_16_fx, gain_inov_fx); + } + + /* update gain */ + *gain_c_fx = L_shl(gainc_tmp, sub(gain_c_16_fx_exp, 15)); move32(); + + + /*----------------------------------------------------------* + * Compute the synthesis speech * + *----------------------------------------------------------*/ + + /* introduce some headroom to avoid Overflows, 2 bit seem to be sufficient */ + *Q_syn = sub(Q_exc, 2); + *Q_syn = s_max(*Q_syn, -3); + + exp_scale = sub(*Q_syn, Q_exc - 1); + + IF (sub(nbLostFramesInRow, 1) != 0) + { + synth_mem_fx = synthHist_fx; + } + Copy_Scale_sig(synth_mem_fx, &synth_tmp_fx[-lpc_order], lpc_order, exp_scale); + TDC_LPC_synthesis_fx(sub(Q_exc, *Q_syn), A_fx, exc_fx, synth_tmp_fx, len, lpc_order); + + FOR (i=0; i= 0); + synth_fx[i] = mult(synth_fx[i], gain_h_fx); + gain_h_fx = sub(gain_h_fx, step_fx); + } + basop_memset(&synth_fx[frame_length], 0, overlap * sizeof(Word16)); + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + +/*****************************************************************************/ + +static Word32 syn_kern_2(Word32 L_tmp, const Word16 a[], const Word16 y[]) +{ + L_tmp = L_msu_sat(L_tmp, y[-1], a[1]); + L_tmp = L_msu_sat(L_tmp, y[-2], a[2]); + return L_tmp; +} + +static Word32 syn_kern_4(Word32 L_tmp, const Word16 a[], const Word16 y[]) +{ + L_tmp = syn_kern_2(L_tmp, a, y); + return syn_kern_2(L_tmp, a + 2, y - 2); +} + +static Word32 syn_kern_8(Word32 L_tmp, const Word16 a[], const Word16 y[]) +{ + L_tmp = syn_kern_4(L_tmp, a, y); + return syn_kern_4(L_tmp, a + 4, y - 4); +} + +static Word32 syn_kern_16(Word32 L_tmp, const Word16 a[], const Word16 y[]) +{ + L_tmp = syn_kern_8(L_tmp, a, y); + return syn_kern_8(L_tmp, a + 8, y - 8); +} + +/* + * TDC_Dot_product + * + * Parameters: + * x i: x vector Q0 + * y i: y vector Q0 + * lg i: vector length Q0 + * + * Function: + * dot product + * + * Returns: + * dot product Q0 + */ +static Word16 TDC_Dot_product(const Word16 x[], const Word16 y[], const Word16 lg) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word32 sum; + ); + + sum = L_mult(x[0], y[0]); + FOR (i = 1; i < lg-1; i++) + { + sum = L_mac_sat(sum, x[i], y[i]); + } + + sum = mac_r_sat(sum, x[lg-1], y[lg-1]); + + Dyn_Mem_Deluxe_Out(); + + return sum; +} + +/* + * TDC_L_Dot_product + * + * Parameters: + * x i: x vector Q0 + * y i: y vector Q0 + * lg i: vector length Q0 + * + * Function: + * dot product + * + * Returns: + * dot product Q1 + */ +static Word32 TDC_L_Dot_product(const Word16 x[], const Word16 y[], const Word16 lg) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word32 sum; + ); + + sum = L_mac0(1L, x[0], y[0]); + FOR (i = 1; i < lg; i++) + { + sum = L_mac0(sum, x[i], y[i]); + } + + Dyn_Mem_Deluxe_Out(); + + return sum; +} + +/* + * TDC_highPassFiltering_fx + * + * Parameters: + * L_buffer i: buffer length + * exc2 i: unvoiced excitation before the high pass filtering Qx/Qx+1 + * l_fir_fer i: length highpass filter + * hp_filt i: highpass filter coefficients Q15 + * + * Function: + * Highpass filter + * + * Returns: + * void + */ +static void TDC_highPassFiltering_fx(const Word16 L_buffer, Word16 exc2[], const Word16 l_fir_fer, + const Word16 *hp_filt) +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + + FOR (i = 0; i < L_buffer; i++) + { + exc2[i] = round_fx(L_sub(TDC_L_Dot_product(&exc2[i], hp_filt, l_fir_fer), 1)); move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +/* + * TDC_calcGainc + * + * Parameters: + * exc i: pointer to excitation buffer + * Q_exc i: Q format of excitation buffer + * old_fpitch i: pitch_int + * lg i: length + * lp_gainp i: gain p + * lp_gainc o: pointer to gain (15Q16) + * + * Function: + * Gain calculation + * + * Returns: + * void + */ +static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 lg, Word16 frame_dms, Word16 lp_gainp, Word32 *lp_gainc) +{ + Dyn_Mem_Deluxe_In( + Word16 tmp16, tmp_e, tmp2_e; + Word32 L_tmp, L_tmp_max; + Counter i; + ); + + L_tmp = L_deposit_l(0); + + FOR (i = 0; i < lg; i++) + { + /* gain_c += ( exc[-i-1] - *gain_p * exc[-i-1-pitch_int] ) * ( exc[-i-1] - *gain_p * exc[-i-1-pitch_int] ); */ + tmp16 = sub_sat(exc[i - lg] /*Q1*/, mult_r(lp_gainp /*Q15*/, exc[i - lg - old_fpitch] /*Q1*/) /*Q1*/); + L_tmp = L_mac0_sat(L_tmp, tmp16, tmp16); /*Q3*/ + } + + IF (sub(frame_dms, 100) < 0) + { + L_tmp_max = L_deposit_l(0); + FOR (i = 0; i < lg; i++) + { + L_tmp_max = L_mac0_sat(L_tmp_max, exc[i - lg], exc[i - lg]); /*Q3*/ + } + L_tmp = L_min(L_tmp, L_tmp_max); + } + + tmp_e = norm_l(L_tmp); + L_tmp = L_shl(L_tmp, tmp_e); + tmp_e = sub(sub(31, shl_pos(Q_exc, 1)), tmp_e); /*L_tmp is Q31, now*/ + tmp16 = BASOP_Util_Divide3216_Scale_lc3plus(L_tmp /*Q31,norm,tmp_e*/, lg /*Q15,15*/, &tmp2_e) /*Q15,tmp2_e+tmp_e-15*/; + tmp_e = sub(add(tmp2_e, tmp_e), 15); + + IF (tmp16 != 0) + { + tmp16 = Sqrt16_lc3plus(tmp16, &tmp_e); /*Q15,norm,tmp_e*/ + tmp_e = L_min(tmp_e, 15); + *lp_gainc = L_shl_pos(L_deposit_l(tmp16), add(tmp_e, 1)); /*15Q16*/ + move32(); + } + ELSE + { + *lp_gainc = 0; + } + + Dyn_Mem_Deluxe_Out(); +} + +/* + * TDC_calcGainp + * + * Parameters: + * x i: input signal + * y i: shifted input signal + * lg i: vector length + * + * Function: + * Gain calculation + * + * Returns: + * gain (15Q16) + */ +static Word32 TDC_calcGainp(Word16 x[], Word16 y[], Word16 lg) +{ + Dyn_Mem_Deluxe_In( + Word32 tcorr, tener, Lgain, L_tmp1, L_tmp2; + Word16 m_corr, m_ener, negative, Q_corr, Q_ener; + Counter i; + ); + + negative = 0; move16(); + + L_tmp1 = L_deposit_l(0); + L_tmp2 = L_deposit_l(0); + FOR (i = 0; i < lg; i += 2) + { + L_tmp1 = L_mac0_sat(L_tmp1, x[i], y[i]); + L_tmp2 = L_mac0_sat(L_tmp2, x[i + 1], y[i + 1]); + } + tcorr = L_add(L_shr_pos(L_tmp1, 1), L_shr_pos(L_tmp2, 1)); + Q_corr = norm_l(tcorr); + tcorr = L_shl(tcorr, Q_corr); + Q_corr = sub(2, Q_corr); + + L_tmp1 = L_deposit_l(0); + L_tmp2 = L_deposit_l(0); + FOR (i = 0; i < lg; i += 2) + { + L_tmp1 = L_mac0_sat(L_tmp1, y[i], y[i]); + L_tmp2 = L_mac0_sat(L_tmp2, y[i + 1], y[i + 1]); + } + tener = L_add(L_shr_pos(L_tmp1, 1), L_shr_pos(L_tmp2, 1)); + Q_ener = norm_l(tener); + tener = L_shl(tener, Q_ener); + Q_ener = sub(2, Q_ener); + + tener = L_max(tener, 1); + + if (tcorr <= 0) + { + negative = 1; move16(); + } + tcorr = L_abs(tcorr); + + m_corr = extract_h(tcorr); + + m_ener = extract_h(tener); + + IF (sub(m_corr, m_ener) > 0) + { + m_corr = shr_pos(m_corr, 1); + Q_corr = add(Q_corr, 1); + } + if (m_ener == 0) + { + move16(); + m_corr = 0x7FFF; + } + if (m_ener != 0) + { + m_corr = div_s(m_corr, m_ener); + } + + Q_corr = sub(Q_corr, Q_ener); + + Lgain = L_shl(L_deposit_l(m_corr), add(Q_corr, 1)); + + if (negative != 0) + { + Lgain = L_negate(Lgain); + } + + Dyn_Mem_Deluxe_Out(); + + return Lgain; +} + +/* + * TDC_LPC_synthesis_fx + * + * Parameters: + * sh i : scaling to apply for a[0] Q0 + * a[] i : LP filter coefficients Qx + * x[] i : input signal Qx + * y[] o : output signal Qx-s + * lg i : size of filtering Q0 + * m i : order of LP filter Q0 + * + * Function: + * Apply LP filtering to obtain synthesis signal. + * Memory size is always m. + * + * Returns: + * void + */ +static void TDC_LPC_synthesis_fx(const Word16 sh, const Word16 a[], const Word16 x[], Word16 y[], const Word16 lg, + const Word16 m) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word16 a0; + Word16 q; + Word32(*syn_kern)(Word32 L_tmp, const Word16 a[], const Word16 y[] + );); + + ASSERT(m == 16 || m == 8); + + if (sub(m, 16) == 0) + { + syn_kern = syn_kern_16; + } + if (sub(m, 8) == 0) + { + syn_kern = syn_kern_8; + } + + q = add(norm_s(a[0]), 1); + a0 = shr_sat(a[0], sh); + + FOR (i = 0; i < lg; i++) + { + y[i] = round_fx_sat(L_shl_sat(syn_kern(L_mult(a0, x[i]), a, &y[i]), q)); move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +/* TDC_LPC_residu_fx + * + * Parameters: + * a I: LP filter coefficients (Qx) + * x I: input signal + * y O: output signal + * lg I: size of filtering + * m I: lpc order + * + * Function: + * Apply inverse filtering to obtain LP residual signal. + * + * Returns: + * void + */ +static void TDC_LPC_residu_fx(const Word16 *a, Word16 *x, Word16 *y, Word16 lg, Word16 m) +{ + Dyn_Mem_Deluxe_In( + Word16 a_exp; + Word32 s; + Counter i; + ); + + ASSERT(m == 16 || m == 8); + + a_exp = add(norm_s(a[0]), 1); + a_exp = add(a_exp, 1); + + IF (sub(m, 16) == 0) + { + FOR (i = 0; i < lg; i++) + { + s = L_mult(x[i], a[0]); + s = L_mac_sat(s, x[i - 1], a[1]); + s = L_mac_sat(s, x[i - 2], a[2]); + s = L_mac_sat(s, x[i - 3], a[3]); + s = L_mac_sat(s, x[i - 4], a[4]); + s = L_mac_sat(s, x[i - 5], a[5]); + s = L_mac_sat(s, x[i - 6], a[6]); + s = L_mac_sat(s, x[i - 7], a[7]); + s = L_mac_sat(s, x[i - 8], a[8]); + s = L_mac_sat(s, x[i - 9], a[9]); + s = L_mac_sat(s, x[i - 10], a[10]); + s = L_mac_sat(s, x[i - 11], a[11]); + s = L_mac_sat(s, x[i - 12], a[12]); + s = L_mac_sat(s, x[i - 13], a[13]); + s = L_mac_sat(s, x[i - 14], a[14]); + s = L_mac_sat(s, x[i - 15], a[15]); + s = L_mac_sat(s, x[i - 16], a[16]); + + s = L_shl_sat(s, a_exp); + y[i] = round_fx_sat(s); move16(); + } + } + IF (sub(m, 8) == 0) + { + FOR (i = 0; i < lg; i++) + { + s = L_mult(x[i], a[0]); + s = L_mac_sat(s, x[i - 1], a[1]); + s = L_mac_sat(s, x[i - 2], a[2]); + s = L_mac_sat(s, x[i - 3], a[3]); + s = L_mac_sat(s, x[i - 4], a[4]); + s = L_mac_sat(s, x[i - 5], a[5]); + s = L_mac_sat(s, x[i - 6], a[6]); + s = L_mac_sat(s, x[i - 7], a[7]); + s = L_mac_sat(s, x[i - 8], a[8]); + + s = L_shl_sat(s, a_exp); + y[i] = round_fx_sat(s); move16(); + } + } + + Dyn_Mem_Deluxe_Out(); +} + +/* TDC_random_fx + * + * Parameters: + * seed i/o: seed for random number + * lg i : vector length + * y o : output values + * + * Function: + * Uniform distributed random generator. + * + * Returns: + * random number + */ +static void TDC_random_fx(Word16 *seed, Word16 lg, Word16 *y) +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + + FOR (i = 0; i < lg; i++) + { + *seed = extract_l(L_mac0(16831L, *seed, 12821)); + *y++ = *seed; move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +/* + * TDC_preemph + * + * Parameters: + * x i/o: signal Qx + * fac i: preemphasis factor Q15 + * lg i: vector length + * + * Function: + * Filtering through 1 - fac z^-1 + * + * Returns: + * Q-factor + */ +static Word16 TDC_preemph(Word16 *x, const Word16 fac, const Word16 lg) +{ + Dyn_Mem_Deluxe_In( + Word16 fac_sh, Q_max_value, Q_out; + Word32 max_val; + Counter i; + ); + + fac_sh = shr(fac, 3); + Q_max_value = 4096; move16(); + Q_out = 12; move16(); + + max_val = 0; move32(); + FOR (i = sub(lg, 1); i >= 0; i--) + { + max_val = L_max(L_abs(L_msu(L_mult(x[i], Q_max_value), x[i - 1], fac_sh)), max_val); + } + + IF (extract_h(max_val) != 0) + { + Q_out = s_min(s_max(sub(norm_s(extract_h(max_val)), 3), 0), 12); + } + + FOR (i = sub(lg, 1); i >= 0; i--) + { + x[i] = round_fx(L_shl(L_msu(L_mult(x[i], Q_max_value), x[i - 1], fac_sh), Q_out)); move16(); + } + + Dyn_Mem_Deluxe_Out(); + + return sub(Q_out, 2); +} + +/* + * TDC_deemph_fx + * + * Parameters: + * x i: input signal Qx + * y o: output signal Qx + * fac i: deemphasis factor Q15 + * lg i: size of filtering Q0 + * mem i: memory (x[-1]) + * + * Function: + * Filtering through 1/(1-fac z^-1) + * + * Returns: + * void + */ +static void TDC_deemph_fx(const Word16 *x, Word16 *y, const Word16 fac, const Word16 lg, const Word16 mem) +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + + y[0] = round_fx_sat(L_mac_sat(L_deposit_h(x[0]), mem, fac)); move16(); + FOR (i = 1; i < lg; i++) + { + y[i] = round_fx_sat(L_mac_sat(L_deposit_h(x[i]), y[i - 1], fac)); move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +/* + * TDC_normalize_energy_fx + * + * Parameters: + * gain o: gain + * gain_exp o: exponent of gain + * x i: input signal + * lg i: length of input signal + * + * Function: + * Normalizes the energy. + * + * Returns: + * void + */ +static void TDC_normalize_energy_fx(Word16 *gain, Word16 *gain_exp, const Word16 *x, const Word16 lg) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word16 c; + Word16 e; + Word16 e1; + Word16 e2; + Word32 tmp; + Word16 tmp16; + ); + + tmp = 0; move32(); + FOR (i = 0; i < lg; i++) + { + tmp16 = mult_r(x[i], 2048); + tmp = L_mac(tmp, tmp16, tmp16); + } + + e = norm_l(tmp); + tmp = L_shl_pos(tmp, e); + e1 = sub(sub(30, e), -8); move16(); + tmp16 = BASOP_Util_Divide3216_Scale_lc3plus(tmp, lg, &e2); + + e = 0; move16(); + if (tmp16 != 0) + { + e = sub(add(e1, e2), 15); + } + + c = 0x0148; /* 0.01 */ + move16(); + IF (e > 0) + { + c = shr(c, s_min(e, 15)); + } + ELSE + { + tmp16 = shr(tmp16, s_min(negate(e), 15)); + e = 0; move16(); + } + + e2 = 2; move16(); + if (s_and(e, 1)) + { + e2 = 1; move16(); + } + + tmp16 = add(shr_pos(tmp16, e2), shr_pos(c, e2)); + e = add(e, e2); + + tmp16 = Sqrt16_lc3plus(tmp16, &e); + + *gain = BASOP_Util_Divide1616_Scale_lc3plus((Word16)0x7FFF, tmp16, &e1); move16(); + *gain_exp = sub(e1, e); move16(); + + Dyn_Mem_Deluxe_Out(); +} + +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR +static Word16 type_2_alpha_long(Word16 nbLostFramesInRow, Word16 frame_dms) +{ + Word16 n_help; + Word32 n_shift; + + if (nbLostFramesInRow <= 3*(100.0/frame_dms)){ + n_help = (nbLostFramesInRow + (100/frame_dms) - 1) * frame_dms; + return powWord16rest(31129,n_help/100,n_help%100); + } + else { + n_shift = (nbLostFramesInRow - 3*(100/frame_dms)) * 50/frame_dms; + n_help = (n_shift + (100/frame_dms) - 1) * frame_dms; + return powWord16rest(22937,n_help/100,n_help%100); + } +} + +Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, Word16 frame_dms) +{ + Word16 n_help; + Word16 selector = PLC_FADEOUT_TYPE_2_SELECTOR * 2 * (100/frame_dms); + + if (selector >= nbLostFramesInRow){ + return type_2_alpha_long(nbLostFramesInRow, frame_dms); + } + else { + n_help = (nbLostFramesInRow + (100/frame_dms) - 1) * frame_dms; + return powWord16rest(16383,n_help/100, n_help%100); + } +} + +static Word16 powWord16rest(Word16 base, Word16 exp, Word16 rest) { + Word32 exp_result = 32767; + Word32 tmp_result; + Word16 root, i, exp2; + + FOR (i = 0; i < exp; ++i) { + tmp_result = (Word32)exp_result * base; + exp_result = (Word16)(tmp_result >> 15); + } + + IF (rest != 0) { + exp2 = 0; + SWITCH (rest) + { + case 50: + root = Sqrt16_lc3plus(base, &exp2); + shr(root,exp2); + exp_result = L_shr(exp_result * root,15); /* 0.5^1.5 = 0.5^(3/2) = 0.5^3*sqrt(0.5) */ + BREAK; + case 25: + root = Sqrt16_lc3plus(base, &exp2); + shr(root,exp2); + exp2 = 0; + root = Sqrt16_lc3plus(root, &exp2); + shr(root,exp2); + exp_result = L_shr(exp_result * root,15); /* 0.5^(1/4) = 0.5^sqrt(sqrt(0.5)) */ + BREAK; + case 75: + root = Sqrt16_lc3plus(base, &exp2); + shr(root,exp2); + exp2 = 0; + root = Sqrt16_lc3plus(root, &exp2); + shr(root,exp2); + tmp_result = powWord16rest(root, 3, 0); + exp_result = L_shr( exp_result * tmp_result,15); + BREAK; + } + } + return (Word16) exp_result; +} +#endif diff --git a/lib_lc3plus/plc_tdc_pre_emphasis_fx.c b/lib_lc3plus/plc_tdc_pre_emphasis_fx.c new file mode 100644 index 000000000..3a961acf7 --- /dev/null +++ b/lib_lc3plus/plc_tdc_pre_emphasis_fx.c @@ -0,0 +1,95 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 frame_dms, Word8 *scratchBuffer) +{ + Word16 s; + Word32 nrg; + Word16 smax; + Counter band; + const Word16 *pre_emph; + const Word16 *pre_emph_e; + Word16 * d2_band_fx_exp; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processPreEmphasis_fx", sizeof(struct { + Word16 s; + Word32 nrg; + Word16 smax; + Counter band; + const Word16 *pre_emph; + const Word16 *pre_emph_e; + Word16 * d2_band_fx_exp; + })); +#endif + + d2_band_fx_exp = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_BANDS_NUMBER_PLC = 160 bytes */ + + pre_emph = lpc_lin_pre_emphasis[fs_idx]; + pre_emph_e = lpc_lin_pre_emphasis_e[fs_idx]; + SWITCH (frame_dms) + { + case 25: + pre_emph = lpc_lin_pre_emphasis_2_5ms[fs_idx]; + pre_emph_e = lpc_lin_pre_emphasis_e_2_5ms[fs_idx]; + BREAK; + case 50: + pre_emph = lpc_lin_pre_emphasis_5ms[fs_idx]; + pre_emph_e = lpc_lin_pre_emphasis_e_5ms[fs_idx]; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + pre_emph = lpc_lin_pre_emphasis_7_5ms[fs_idx]; + pre_emph_e = lpc_lin_pre_emphasis_e_7_5ms[fs_idx]; + BREAK; +#endif + } + + ASSERT(n_bands==20 || n_bands==40 || n_bands==60 || n_bands ==80); + + /* start processing */ + smax = -31; move16(); + + FOR (band = 0; band < n_bands; band++) + { + nrg = Mpy_32_16_lc3plus(d2_fx[band], pre_emph[band]); + + if (nrg == 0) + { + s = 31; move16(); + } + + if (nrg != 0) + { + s = norm_l(nrg); + } + + d2_fx[band] = L_shl_pos(nrg, s); move32(); + d2_band_fx_exp[band] = sub(pre_emph_e[band], s); move16(); + + smax = s_max(smax, d2_band_fx_exp[band]); + } + +/* Rescale band energies */ + FOR (band = 0; band < n_bands; band++) + { + d2_fx[band] = L_shr_pos(d2_fx[band], s_min(sub(smax, d2_band_fx_exp[band]), 31)); move32(); + } + /* Save common exponent for all bands */ + *d2_fx_exp = add(*d2_fx_exp, smax); move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/plc_update_aft_imdct_fx.c b/lib_lc3plus/plc_update_aft_imdct_fx.c new file mode 100644 index 000000000..663f491c9 --- /dev/null +++ b/lib_lc3plus/plc_update_aft_imdct_fx.c @@ -0,0 +1,343 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +static void processPLCcomputeStabFac(Word16 scf_q[], Word16 old_scf_q[], Word16 prev_bfi, Word16 *stab_fac); + +void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concealMethod, Word16 xLen, Word16 fs_idx, + Word16 *nbLostFramesInRow, Word16 *prev_prev_bfi, Word16 *prev_bfi, Word16 bfi, Word16 scf_q[], + Word16 *ns_cum_alpha, AplcSetup *plcAd) +{ + Word16 oldLen, usedHistlen; + Word16 scale_fac_old, scale_fac_new, q_theo_new_old, q_theo_new_new, q_new, shift_old, shift_new; + Word16 frontLen, pastLen; + Word16 marginOldPast; + Word16 marginNewXlen, marginOldFront; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processPLCUpdateAfterIMDCT_fx", sizeof(struct { + Word16 oldLen, usedHistlen; + Counter i; + Word16 scale_fac_old, scale_fac_new, q_theo_new_old, q_theo_new_new, q_new, shift_old, shift_new; + Word16 frontLen, pastLen; + Word16 marginOldPast; + Word16 scale_fac_old_dual; + Word16 marginNewXlen, marginOldFront; + })); +#endif + + + + +#ifdef WMOPS + BASOP_sub_sub_start("processPLCUpdateAfterIMDCT "); +#endif + + + if (plcAd) + { + /* for short NB frames(2.5 ms) TDC-filtering requires more PCM samples than the plc_xcorr function */ + usedHistlen = plcAd->max_len_pcm_plc; + + + logic16(); + IF( (sub(bfi,1) == 0) && sub(concealMethod, LC3_CON_TEC_PHASE_ECU) == 0 && xLen == (Word16)(((double)LprotSzPtr[fs_idx])*0.625)) + { /* % reduced buffering update length during concealment method 2 as Xsav_fx is stored in the joint q_old_fx and pcmbufHist buffer */ + usedHistlen = sub(usedHistlen, sub(LprotSzPtr[fs_idx], s_min(MAX_BW_BIN, xLen))); + ASSERT(xLen == (Word16)(((double)LprotSzPtr[fs_idx])*0.625)); /*/ only enter here for 10 ms cases */ + + /* actually one can select to always update xLen(10 ms) less samples of x_old_tot, also in TDC-PLC bfi frames ,, and for PhECU.PLC */ + } + oldLen = sub(usedHistlen, xLen); + + /* update ltpf-free pcm history buffer for TD-PLC */ + + basop_memmove(&plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - usedHistlen], + &plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - usedHistlen + xLen], oldLen * sizeof(Word16)); + + basop_memcpy(&plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - xLen], &x_fx[0], xLen * sizeof(Word16)); + +#ifdef ENABLE_HR_MODE + frontLen = 0; + IF (sub(fs_idx, 5) < 0) +#endif + { + frontLen = sub(LprotSzPtr[fs_idx], xLen); /*16-10 = 6ms of the prev_synth/xfp part */ + } + pastLen = sub(oldLen, frontLen); /* ~11.8 ms*/ + + marginOldPast = getScaleFactor16_0(&(plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - usedHistlen]), pastLen); + marginOldFront = getScaleFactor16_0(&(plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - usedHistlen + pastLen]), frontLen); + + scale_fac_old = s_min(marginOldFront, marginOldPast); + + frontLen = 0; move16(); + logic16(); logic16(); + IF(bfi == 1 && *prev_bfi == 0 && sub(concealMethod, LC3_CON_TEC_PHASE_ECU) == 0) + { /* prepare localized margin_xfp value for a next bad concealment Method 2 frame */ + frontLen = *nbLostFramesInRow; + frontLen = add(hamm_len2Tab[fs_idx], shr(hamm_len2Tab[fs_idx], 2)); /* find margin in the 3.75 ms front part */ + pastLen = sub(xLen, frontLen); + scale_fac_new = getScaleFactor16_0(&(x_fx[0]), pastLen); + marginNewXlen = getScaleFactor16_0(&(x_fx[0]) + pastLen, frontLen); /* for pHEcuprev_synth in 2nd+ bfi frame */ + + scale_fac_new = s_min(scale_fac_new, marginNewXlen); + } + ELSE + { /* prepare margin value for any coming good frame or any coming first bad frame */ + + marginNewXlen = getScaleFactor16_0(&(x_fx[0]),xLen); /* prevsynth in first bfi frame */ + scale_fac_new = marginNewXlen; move16(); + } + + q_theo_new_old = s_max(plcAd->q_fx_old_exp - scale_fac_old, 0); + q_theo_new_new = s_max(q_fx_exp - scale_fac_new, 0); + + q_new = s_max(q_theo_new_old, q_theo_new_new); + + shift_old = plcAd->q_fx_old_exp - q_new; + shift_new = q_fx_exp - q_new; + + IF(shift_old != 0) + { + Scale_sig(&plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - usedHistlen], oldLen, shift_old); + logic16(); + test(); + IF ((sub(bfi,1) == 0) && (sub(concealMethod, LC3_CON_TEC_TDPLC) == 0)) + { + plcAd->harmonicBuf_Q -= shift_old; + plcAd->tdc_gain_c = L_shl_sat(plcAd->tdc_gain_c, shift_old); + } + move16(); /* count move to static RAM */ + + marginOldFront = s_min(16, sub(marginOldFront, shift_old)); + } + IF(shift_new) + { + Scale_sig(&plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - xLen], xLen, shift_new); /* positive shift_new means upshift=less margin */ + marginNewXlen = s_min(16, sub(marginNewXlen, shift_new)); + } + + plcAd->q_fx_old_exp = sub(q_fx_exp, shift_new); + + plcAd->PhECU_margin_xfp = s_min(marginNewXlen, marginOldFront); move16(); /* for pHECU winEncalc xfp energy calculations */ + if (frontLen != 0) + { /* prepare margin value for a first pHECU(16 ms) or a consecutive bad PhEcu frame (3.75ms) */ + plcAd->PhECU_margin_xfp = marginNewXlen; move16(); + } + if (sub(plcAd->PhECU_margin_xfp, 16) == 0) + { + plcAd->PhECU_margin_xfp = 1; move16(); /* "1" --> does not rescale the all-zero vector, inside PhECU */ + } + } + + /* Update PLC params */ + IF(sub(bfi, 1) != 0) + { + /* % reset counters in GF */ + *nbLostFramesInRow = 0; move16(); + *ns_cum_alpha = 32767; move16(); + + if (plcAd) + { + basop_memmove(plcAd->old_old_scf_q, plcAd->old_scf_q, M * sizeof(Word16)); + basop_memmove(plcAd->old_scf_q, scf_q, M * sizeof(Word16)); + + /* PLC fullband transient detector setting for non-bfi frames */ + plcAd->PhECU_short_flag_prev = 0; move16(); /* fullband transient not active */ + } + } + + /* values may be {0,1,2} */ + *prev_prev_bfi = *prev_bfi; move16(); + *prev_bfi = bfi; move16(); + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +void processPLCcomputeStabFac_main(Word16 scf_q[], Word16 old_scf_q[], Word16 old_old_scf_q[], Word16 bfi, Word16 prev_bfi, + Word16 prev_prev_bfi, Word16 *stab_fac) +{ + IF (sub(bfi, 1) == 0) + { + IF (sub(prev_bfi, 1) != 0) + { + processPLCcomputeStabFac(old_scf_q, old_old_scf_q, prev_prev_bfi, stab_fac); + } + } + ELSE IF(sub(bfi, 2) == 0) + { + processPLCcomputeStabFac(scf_q, old_scf_q, prev_bfi, stab_fac); + } +} + +static void processPLCcomputeStabFac(Word16 scf_q[], Word16 old_scf_q[], Word16 prev_bfi, Word16 *stab_fac) +{ + Counter i; + Word32 tmp32; + Word16 d; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("calculateStabFac", sizeof(struct { + Counter i; + Word32 tmp32; + Word16 d; + })); +#endif + + /* calculate stability factor */ + IF (sub(prev_bfi, 1) == 0) + { + *stab_fac = 26214; move16(); + } + ELSE + { + tmp32 = 0; move32(); + FOR (i = 0; i < M; i++) + { + d = sub(scf_q[i], old_scf_q[i]); + tmp32 = L_mac_sat(tmp32, d, d); + } + tmp32 = L_shl_sat(tmp32, 3); + IF (tmp32 > 0x7D000000 /*1.25*25*/) + { + *stab_fac = 0; move16(); + } + ELSE IF (tmp32 < 0x19003E82 /*0.25*25*/) + { + *stab_fac = 0x7FFF; move16(); + } + ELSE + { + tmp32 = L_shl_pos(L_sub(0x50000000 /*1.25/2*/, Mpy_32_16_lc3plus(tmp32, 0x51EC /*16/25*/)), 1); + *stab_fac = round_fx(tmp32); move16(); + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx, Word16 xfp_exp_fx, Word16 margin_xfp, + Word16 fs_idx, + Word32 *L_oold_xfp_w_E_fx, Word16 *oold_xfp_w_E_exp_fx, + Word32 *L_old_xfp_w_E_fx, Word16 *old_xfp_w_E_exp_fx, + + Word16 *oold_Ltot_exp_fx ,Word16 *old_Ltot_exp_fx ) + +{ + Word32 L_tot ; + Word16 dn_scale, exp_shift; + Word16 used_xfp_exp_fx; + Word16 exp_out ; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("PLCUpdateXFP_w_E_hist", sizeof(struct { + Word32 L_tot; + Word16 dn_scale, exp_shift; + Word16 used_xfp_exp_fx; + Word16 exp_out; + })); +#endif +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::UpdateXfp_w_E_hist_fx"); +#endif + + IF (sub(bfi,1) != 0) + { + + if (sub(prev_bfi,1) == 0) + { + /* only a single historic frame available in the next frame + , force artifical update of oold energy to be the same as old */ + *old_xfp_w_E_exp_fx = LTOT_INIT_FLAG ; move16(); + } + + /* Time shift energy state and xfp exp */ + IF (sub_sat(*old_xfp_w_E_exp_fx, LTOT_INIT_FLAG ) == 0) + { + *L_oold_xfp_w_E_fx = LTOT_MIN_MAN ; move32(); + *oold_xfp_w_E_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL ; move16(); + } + ELSE + { + *L_oold_xfp_w_E_fx = *L_old_xfp_w_E_fx; move32(); /* regular update */ + *oold_xfp_w_E_exp_fx = *old_xfp_w_E_exp_fx; move16(); + } + + /* Time shift L_tot energy state and L_tot_exp */ + IF (sub_sat(*old_Ltot_exp_fx, LTOT_INIT_FLAG ) == 0) + { + *L_oold_xfp_w_E_fx = LTOT_MIN_MAN ; move32(); + *oold_Ltot_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL ; move16(); + } + ELSE + { + *L_oold_xfp_w_E_fx = *L_old_xfp_w_E_fx; move32(); /* regular update */ + *oold_Ltot_exp_fx = *old_Ltot_exp_fx; move16(); + } + + + dn_scale = e_tot_headroom[fs_idx]; /* allowed minimum dn_scale for a max upshifted signal */ + used_xfp_exp_fx = xfp_exp_fx; + + IF( margin_xfp > 0 ) /* xfp_fx was normalized on a larger area than 16ms part of pcmBuffer */ + { + ASSERT(bfi !=1) ; /* if bfi was set the margin_xfp does not reflect the correct 16ms part of pcm_buf hist, prev_synth */ + dn_scale = s_max(0, sub(e_tot_headroom[fs_idx], margin_xfp)); + + exp_shift = sub(e_tot_headroom[fs_idx], dn_scale); + used_xfp_exp_fx = sub(xfp_exp_fx, exp_shift); /* the virtual change of the xfp_buffer due to reduced downscaling in L_tot calc */ + } + + /* use semifixed dn_scale as adjusted by margin_xfp in 16 ms region */ + exp_out = xfp_exp_fx; move16(); + L_tot = winEnCalc(xfp_fx, dn_scale , PhECU_wins[fs_idx][0], rectLengthTab[fs_idx], hamm_len2Tab[fs_idx], &exp_out ); + + *L_old_xfp_w_E_fx = L_tot; move32(); + + *old_xfp_w_E_exp_fx = used_xfp_exp_fx ; move16(); + /* this now needs to be in Q1 , used_fx_exp , (exp_out-1-2*e_tot_headroom[fs_idx])/2 */ + + *old_Ltot_exp_fx = exp_out; /* new proper _Ltot value from winEnCalc function */ + + + /* use true Word32 exponent of L_tot */ + + + /* restart oold and old from same state for init or prevBFI cases */ + logic16(); + IF (sub_sat(*oold_xfp_w_E_exp_fx, UNINIT_OR_UNSAFE_OOLD_SENTINEL) <= 0 || /* old xfp_Exp */ + sub_sat(*oold_Ltot_exp_fx, UNINIT_OR_UNSAFE_OOLD_SENTINEL) <= 0 ) /* new L_tot_exp */ + { + *L_oold_xfp_w_E_fx = L_tot; move32(); + *oold_xfp_w_E_exp_fx = used_xfp_exp_fx; move16(); + *oold_Ltot_exp_fx = *old_Ltot_exp_fx; /* use Ltot exp value */ + } + } + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + + diff --git a/lib_lc3plus/plc_update_fx.c b/lib_lc3plus/plc_update_fx.c new file mode 100644 index 000000000..fb05770d5 --- /dev/null +++ b/lib_lc3plus/plc_update_fx.c @@ -0,0 +1,224 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +void processPLCupdate_fx(AplcSetup *plcAd, Word16 x_fx[], Word16 q_fx_exp, Word16 concealMethod, Word16 frame_length, + Word16 fs_idx, Word16 *nbLostFramesInRow, Word16 *prev_prev_bfi, Word16 *prev_bfi, Word16 bfi, Word16 scf_q[], + Word16 *ns_cum_alpha +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif + ) +{ + processPLCUpdateAfterIMDCT_fx(x_fx, q_fx_exp, concealMethod, frame_length, fs_idx, nbLostFramesInRow, prev_prev_bfi, prev_bfi, bfi, + scf_q, ns_cum_alpha, plcAd); /* NB *prev_bfi updated here */ + + IF ( plcAd != 0 ) + { + /* reuse/inplace the most recent 16 ms of x_old_tot without additional rescaling, keep exponent aligned with tdc pitch buffer to save WMOPS */ + + +#ifdef ENABLE_HR_MODE + if (hrmode == 0) +#endif + { + ASSERT( (&plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - LprotSzPtr[fs_idx] ]) == plcAd->PhECU_xfp_fx ); + plcAd->PhECU_xfp_exp_fx = plcAd->q_fx_old_exp; move16(); /* exponent used by concealmethod 2 in prevBfi frames and also right after non bfi frames */ + } + } +} + +void processPLCupdateSpec_fx(Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 yLen) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word16 s; + ); + + /* save spectrum and the corresponding exponent */ + s = getScaleFactor32_lc3plus(q_d_fx, yLen); + + *q_old_fx_exp = sub(*q_fx_exp, s); + + + FOR (i = 0; i < yLen; i++) + { + q_old_d_fx[i] = round_fx_sat(L_shl_sat(q_d_fx[i], s)); /* */ + } + + Dyn_Mem_Deluxe_Out(); +} + +void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], Word16 yLen, + Word16 *stPhECU_oold_grp_shape_fx, Word16 *stPhECU_old_grp_shape_fx) + +#define L_GRP_DC 4 + +{ + Counter i,l; + Word16 *pX, tmp; + Word16 N_grp,l_grp; + Word16 man, expo; + Word32 L_acc; + Word32 L_tot; + Word32 L_grp_shape[MAX_LGW]; + Word16 grp_shape[MAX_LGW]; /**/ + Word16 fs_idx,local_prev_bfi; + + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("process_plc_spec_2_shape_fx", sizeof(struct { + Counter i,l; + Word16 *pX; + Word16 N_grp,l_grp; + Word32 L_acc; + Word32 L_tot; + Word32 L_grp_shape[MAX_LGW]; + Word16 fs_idx,local_prev_bfi; + })); +#endif +#ifdef WMOPS + BASOP_sub_sub_start("PhECU::GF::process_plc_spec_2_shape_fx"); +#endif + + IF(sub(bfi, 1) != 0) + { + fs_idx = mult(yLen, (Word16)(32768.0 / (99.0))); /* truncation needed , i.e no rounding can be applied here */ + N_grp = xavg_N_grp_fx[fs_idx]; move16(); + + local_prev_bfi = prev_bfi; move16(); + if (sub(local_prev_bfi, 2)==0) + { + local_prev_bfi = 0; move16(); + } + + if( stPhECU_oold_grp_shape_fx[0] < 0 ) + { + local_prev_bfi = 1 ; move16(); /* handle startup in the case 2nd frame is a BFI frame */ + } + + /* Copy old to oold grp shape */ + FOR( i=0; i < MAX_LGW ; i++) + { + stPhECU_oold_grp_shape_fx[i] = stPhECU_old_grp_shape_fx[i]; move16(); + } + + + /* Accumulate DC bin(s) to total */ + pX = q_old_d_fx; /* ptr setup */ + L_tot = L_deposit_h(0); /* acc on negative side */ + + FOR( i= 0; i < L_GRP_DC; i++) + { + tmp = shr_pos(*pX++ ,spec_shape_headroom[fs_idx]); /* scale down upscaled MDCT to create some headroom */ + L_tot = L_msu0(L_tot, tmp, tmp); + + } + + /* Accumulate middle subbands and add to total */ + FOR( i=0; i < sub(N_grp,1) ; i++) + { + + L_acc = L_deposit_h(0); /* acc on negative side */ + l_grp = sub(mdct_grp_bins_fx[i+1], mdct_grp_bins_fx[i]); move16(); + + + + FOR(l=0;l 0) + { + FOR(i=0; i < N_grp ; i++) + { + man = plc_phEcu_ratio_fx(L_grp_shape[i], L_tot, &expo); /* The mantissa is considered in Q15 output in Q14 */ + grp_shape[i] = shr_sat(man, sub(expo,1)); /* gfrom Q14 to in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ + } + } + ELSE + { + FOR(i=0; i < N_grp ; i++) + { + grp_shape[i] = GRP_SHAPE_INIT; move16(); + + } + } + + /* copy to output */ + FOR(i=0; i < N_grp ; i++) + { + stPhECU_old_grp_shape_fx[i] = grp_shape[i]; move16(); + } + FOR(i = N_grp; i < MAX_LGW ; i++) + { + stPhECU_old_grp_shape_fx[i] = GRP_SHAPE_INIT; move16(); + } + + + + /* handle oold states for the frame sequence BAD, GOOD, NEXT_BAD */ + if(sub(local_prev_bfi, 1)==0) + { + FOR( i=0; i < MAX_LGW ; i++) + { + stPhECU_oold_grp_shape_fx[i] = stPhECU_old_grp_shape_fx[i] ; move16(); + } + } + + } + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + +} + + + + diff --git a/lib_lc3plus/plc_xcorr_fx.c b/lib_lc3plus/plc_xcorr_fx.c new file mode 100644 index 000000000..720015295 --- /dev/null +++ b/lib_lc3plus/plc_xcorr_fx.c @@ -0,0 +1,250 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" +#include "functions.h" + +#define MAX_ACCS 3 /* sum(x.*y), sum(x.*x), sum(y.*y), nb of always nonsaturated shorter sub_blocks*/ +#define MAX_BLOCKS 8 +#define MAX_ACC_LEN_BITS 7 +#define MIN_ACC_LEN_BITS 5 +#define MAX_ACC_LEN (1 << MAX_ACC_LEN_BITS) +#define MIN_PITCH_8K 20 /* 8000* MIN_PITCH_12k8/12800 */ + +static const Word16 pitch_min_2[] = {2 * MIN_PITCH_8K , 2 * MIN_PITCH_8K * 2, 2 * MIN_PITCH_8K * 3, + 2 * MIN_PITCH_8K * 4, 2 * MIN_PITCH_8K * 6, 2 * MIN_PITCH_8K * 12}; + +/* req headroom in bits, for safe summing of block results w/o downshift */ +/* also the safe pre subblock acc downshift for various number of blocks */ +static const Word16 tab_req_headroom[MAX_BLOCKS + 1] = {0, 0, 1, 2, 2, 3, 3, 3, 3}; +/*(0, 1, 2, 3,4, 5,6,7,8)*/ + +static Word16 plc_norm_corr_blocks_fx(Word16 tot_len, Word16 l2_base_len, Word16 n_blocks, Word16 inshift, + Word16 *currFrame, Word16 *predFrame); + +Word16 plc_norm_corr_blocks_fx( /* o: norm_corr range [-1 ... 1.0[ in Q15 */ + Word16 tot_len, /* i: total correlation length in Q0 */ + Word16 l2_base_len, /* i: size of subblocks in log2 */ + Word16 n_blocks, /* i: number of accumulator sub_blocks */ + Word16 inshift, /* i: required inshift of curr/pred Q0 */ + Word16 *currFrame, /* i: ptr to most recent section */ + Word16 *predFrame) /* i: ptr to historic section */ +{ + Word16 scale0, scale1, scale2, scale_min, shift, prod_exp, acc_margin; + Word32 L_prod, L_inv, L_tmp0 = 0, L_tmp1 = 0, L_tmp2 = 0; + Word16 norm_corr, curr, pred; + Counter m, b; + Word32 L_ce[MAX_ACCS][MAX_BLOCKS]; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("plc_norm_corr_blocks_fx", sizeof(struct { + Word16 scale0, scale1, scale2, scale_min, shift, prod_exp, acc_margin; + Word32 L_prod, L_inv, L_tmp0, L_tmp1, L_tmp2; + Word16 norm_corr, curr, pred; + Counter m, b; + Word32 L_ce[MAX_ACCS][MAX_BLOCKS]; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("plc_norm_corr_blocks_fx"); +#endif + + /* Calculate normalized correlation with added shift and block interleaving possibility */ + ASSERT(n_blocks <= MAX_BLOCKS && n_blocks > 0); + ASSERT(((float)tot_len / (float)n_blocks) <= (float)(1 << l2_base_len)); + ASSERT(inshift > 0); + UNUSED(l2_base_len); + + FOR (b = 0; b < n_blocks; b++) + { /* block loop with fixed pre_down shifting(inshift) of input signal */ + curr = shr_pos(currFrame[b], inshift); + pred = shr_pos(predFrame[b], inshift); + L_tmp2 = L_deposit_l(0); + L_tmp0 = L_msu0(L_tmp2, curr, pred); /* acc L_tmp0 on negative side to avoid saturation for (-1*-1) */ + L_tmp1 = L_msu0(L_tmp2, pred, pred); /* acc_energy on negative side */ + L_tmp2 = L_msu0(L_tmp2, curr, curr); /* acc_energy on negative side */ + + FOR (m = (b + n_blocks); m < tot_len; m += n_blocks) + { /* interleaved accumulation over total length */ + curr = shr_pos(currFrame[m], inshift); + pred = shr_pos(predFrame[m], inshift); + L_tmp0 = L_msu0(L_tmp0, curr, pred); + L_tmp1 = L_msu0(L_tmp1, pred, pred); + L_tmp2 = L_msu0(L_tmp2, curr, curr); + } + + L_ce[0][b] = L_add(L_tmp0, 0); /* account for moves from register to stack memory */ + L_ce[1][b] = L_add(L_tmp1, 0); + L_ce[2][b] = L_add(L_tmp2, 0); + } + + /* aggregate interleaved subsections */ + IF (sub(n_blocks, 1) >= 0) + { /* 100% safe non saturating L_ce with a safe acc_margin */ + acc_margin = tab_req_headroom[n_blocks]; move16(); + + L_tmp0 = L_shr_pos(L_ce[0][0], acc_margin); + L_tmp1 = L_shr_pos(L_ce[1][0], acc_margin); + L_tmp2 = L_shr_pos(L_ce[2][0], acc_margin); + + FOR (b = 1; b < n_blocks; b++) + { + L_tmp0 = L_add(L_tmp0, L_shr_pos(L_ce[0][b], acc_margin)); /* add negative values */ + L_tmp1 = L_add(L_tmp1, L_shr_pos(L_ce[1][b], acc_margin)); /* add negative values */ + L_tmp2 = L_add(L_tmp2, L_shr_pos(L_ce[2][b], acc_margin)); /* add negative values */ + } + + /* evaluate headroom margin in coarse representation */ + scale0 = norm_l(L_tmp0); + scale1 = norm_l(L_tmp1); + scale2 = norm_l(L_tmp2); + + scale_min = s_min(scale0, scale1); + scale_min = s_min(scale_min, scale2); + + shift = sub(scale_min, acc_margin); + IF (shift >= 0) + { /* re-accumulate blocks with highest possible precision */ + L_tmp0 = L_add(L_ce[0][0], 0); /* add negative values */ + L_tmp1 = L_add(L_ce[1][0], 0); /* add negative values */ + L_tmp2 = L_add(L_ce[2][0], 0); /* add negative values */ + + FOR (b = 1; b < n_blocks; b++) + { + L_tmp0 = L_add(L_tmp0, L_ce[0][b]); /* add negative values */ + L_tmp1 = L_add(L_tmp1, L_ce[1][b]); /* add negative values */ + L_tmp2 = L_add(L_tmp2, L_ce[2][b]); /* add negative values */ + } + } + } + + /* quota: norm_corr = corr/sqrt(en1*en2) = negate(L_tmp1)/sqrt(-L_tmp1*-L_tmp2) */ + L_tmp1 = L_min(L_tmp1, -1); /* make sure there is negative energy */ + L_tmp2 = L_min(L_tmp2, -1); /* make sure there is negative energy */ + + ASSERT(L_tmp1 < 0 && L_tmp2 < 0); + + /* negate correlation, due to the used safe msu0 accumulation, with a saturation pre-check ctrl */ + L_tmp0 = L_max(L_tmp0, (MIN_32 + 1)); + L_tmp0 = L_negate(L_tmp0); + + scale0 = norm_l(L_tmp0); + scale1 = norm_l(L_tmp1); + scale2 = norm_l(L_tmp2); + + L_tmp1 = L_shl_pos(L_tmp1, scale1); + L_tmp2 = L_shl_pos(L_tmp2, scale2); + L_prod = Mpy_32_32_lc3plus(L_tmp1, L_tmp2); /* neg * neg -> positive */ + shift = norm_l(L_prod); + L_prod = L_shl_pos(L_prod, shift); + prod_exp = sub(62, add(add(scale1, scale2), shift)); + L_inv = Isqrt(L_prod, &prod_exp); + + L_tmp0 = L_shl_pos(L_tmp0, scale0); + L_prod = Mpy_32_32_lc3plus(L_tmp0, L_inv); + prod_exp = add(sub(31, scale0), prod_exp); + + norm_corr = 32767; move16(); /* as close to 1.0 as possible in Q15 */ + if (L_tmp0 < 0) + { + norm_corr = -32768; move16(); /*-1.0*/ + } + + test(); + IF (L_prod == 0 || sub(norm_l(L_prod), prod_exp) >= 0) + { + norm_corr = round_fx_sat(L_shl_sat(L_prod, prod_exp)); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return norm_corr; +} + +Word16 plc_xcorr_lc_fx( /* o: quantized output xcorr in Q15 [ 0 ..32767 ] = [0. 1.0[ */ + Word16 *pcmbuf_fx, /* i: NB should be an already dynamically upscaled pcm buffer with about + 0...1(2) bits margin */ + Word16 max_len_pcm_plc, /* i: Q0 physical size of pcmbuf_fx */ + Word16 pitch_int, /* i: Q0 in Fs, lag value to evaluate, corresponding to the current f0 in + pcm_buf_Fx */ + Word16 fs_idx /*i: */) +{ + Word16 *range1Ptr; + Word16 *range2Ptr; + Word16 corr_len_fx, inshift, l2_base_len, n_blocks, norm_xcorr_est_q, pcm_max_corr_len, max_corr_len; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("plc_xcorr_lc_fx", sizeof(struct { + Word16 *range1Ptr; + Word16 *range2Ptr; + Word16 corr_len_fx, inshift, l2_base_len, n_blocks, norm_xcorr_est_q, pcm_max_corr_len, max_corr_len; + })); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("plc_xcorr_lc_fx"); +#endif + + norm_xcorr_est_q = 0; move16(); + + IF (pitch_int > 0) + { + pcm_max_corr_len = sub(max_len_pcm_plc, pitch_int); + + max_corr_len = rectLengthTab[fs_idx]; /* maximum 10 ms */ + max_corr_len = s_min(max_corr_len, pcm_max_corr_len); + + corr_len_fx = s_min(max_corr_len, pitch_int); + corr_len_fx = s_max(corr_len_fx, pitch_min_2[fs_idx]); /* at least 5 ms (=2*pitchmin*) corr length */ + + ASSERT(corr_len_fx >= (pitch_min_2[fs_idx])); /* at least 2 x pitch min(fs) */ + ASSERT(corr_len_fx <= (MAX_ACC_LEN * MAX_BLOCKS)); + ASSERT(corr_len_fx <= max_corr_len); + ASSERT( max_len_pcm_plc - corr_len_fx - pitch_int + 1 > 0 ); + + range1Ptr = &(pcmbuf_fx[max_len_pcm_plc]) - corr_len_fx; /* ptr setup, start of head section */ + range2Ptr = range1Ptr - pitch_int; /* ptr setup, history = tail - lag distance */ + + /* assume 32 bit acc of up to 32 values -> sum(over 32, x_up>>2 * y_up>>2) */ + inshift = 2; move16(); + l2_base_len = MIN_ACC_LEN_BITS; move16(); + n_blocks = shr(add(corr_len_fx, (1 << MIN_ACC_LEN_BITS) - 1), MIN_ACC_LEN_BITS); + + IF (sub(n_blocks, MAX_BLOCKS) > 0) + { /* shift to 32 bit acc of up to 128 values -> sum(over 128, x_up>>3 * y_up>>3) */ + inshift = 3; move16(); + l2_base_len = MAX_ACC_LEN_BITS; move16(); + n_blocks = shr(add(corr_len_fx, ((1 << MAX_ACC_LEN_BITS) - 1)), MAX_ACC_LEN_BITS); + } + + ASSERT(n_blocks <= MAX_BLOCKS); /* MAX_BLOCKS*(32 or 128) is max possible total corr_length */ + ASSERT(n_blocks > 0); + + /* subblock accumulation of corr and energies, to achieve high low level precision */ + norm_xcorr_est_q = + plc_norm_corr_blocks_fx(corr_len_fx, l2_base_len, n_blocks, inshift, range1Ptr, /* curr_frame */ + range2Ptr); /* pred_frame = curr_frame-lag, i.e historic section */ + + norm_xcorr_est_q = s_max(0, norm_xcorr_est_q); /* do not allow negative output values */ + } +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + return norm_xcorr_est_q; +} + + diff --git a/lib_lc3plus/pvq_dec_fx.c b/lib_lc3plus/pvq_dec_fx.c new file mode 100644 index 000000000..d77aae809 --- /dev/null +++ b/lib_lc3plus/pvq_dec_fx.c @@ -0,0 +1,153 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +Word16 pvq_dec_deidx_fx( /* out BER detected 1 , ok==0 */ + Word16 * y, /* o: decoded vector (non-scaled int) */ + const Word16 k_val, /* i: number of allocated pulses */ + const Word16 dim, /* i: Length of vector */ + const Word16 LS_ind, /* i; lS index 1 bit */ + const UWord32 UL_MPVQ_ind /* i; MPVQ index */ +) +{ + Dyn_Mem_Deluxe_In( + Word16 BER_flag; + UWord32 h_mem[1 + KMAX_FX + 1]; + PvqEntry_fx entry; + ); + + BER_flag = 0; move16(); + + /* get_size will likely be called before this function, as the range decoder needs the size to fetch the index + */ + entry = get_size_mpvq_calc_offset_fx(dim, k_val, h_mem); /* TBD should be made into tables for N=16,10,6 */ + + entry.lead_sign_ind = LS_ind; move16(); + entry.index = L_deposit_l(0); /* only in case dim == 1 */ + IF (sub(dim, 1) != 0) + { + entry.index = UL_MPVQ_ind; + + /* safety check in case of bit errors */ + IF (L_sub(entry.index, entry.size) >= 0) + { + BER_flag = 1; move16(); + entry.index = 0; move16(); /* return something deterministic/valid, and LOW complex */ + } + } + mpvq_deindex_fx(&entry, h_mem, y); /* actual deindexing */ + + Dyn_Mem_Deluxe_Out(); + return BER_flag; +} + + + +#ifdef ENABLE_HR_MODE +void pvq_dec_scale_vec_fx(const Word32 *inQ29, Word16 adjGainQ13, Word32 *outQ) +#else +void pvq_dec_scale_vec_fx(const Word16 *inQ14, Word16 adjGainQ13, Word16 *outQ14) +#endif +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + FOR (i = 0; i < M; i++) + { +#ifdef ENABLE_HR_MODE + outQ[i] = L_shr(L_add(outQ[i], Mpy_32_16_lc3plus(inQ29[i], adjGainQ13)), 1); + move16(); +#else + outQ14[i] = add(outQ14[i], mult_r(adjGainQ13, inQ14[i])); move16(); +#endif + } + Dyn_Mem_Deluxe_Out(); +} + + +void pvq_dec_en1_normQ14_fx(/* Have to be used EXACTLY the same way in both both encoder and decoder */ +#ifdef ENABLE_HR_MODE + Word32 * xq, /* o: en1 normalized decoded vector (Q14) */ +#else + Word16 * xq, /* o: en1 normalized decoded vector (Q14) */ +#endif + const Word16 *y, /* i: decoded vector (non-scaled int) */ + const Word16 k_val_max, + /* i: max possible K in Q0 kO or kA */ /* OPT: not BE , use dynamic max pulse + amplitude */ + const Word16 dim /* i: Length of vector */ +) +{ +#ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_tmp; + Word16 shift_num, shift_tot; + Word32 isqrtQ31_local; + Word16 tmp, exp, exp_shift; + Word32 L_yy; + ); +#else + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_tmp; + Word16 shift_num, shift_tot; + Word16 isqrtQ16_local, tmp, exp, exp_shift; + Word32 L_yy; + ); +#endif + +/* energy normalization starts here */ + L_yy = L_mult0(y[0], y[0]); + FOR (i = 1; i < dim; i++) + { + L_yy = L_mac0(L_yy, y[i], y[i]); /* stay in Q0 */ /* OPT: reuse some energies from PVQ linear search */ + } + /* 16 bit */ + IF (L_sub(L_yy, SQRT_EN_MAX_FX) < 0) + { + ASSERT(L_yy > 4); /* Q16 isqrt table lookup not valid below 5 */ +#ifdef ENABLE_HR_MODE + isqrtQ31_local = isqrt_Q31tab[L_yy]; move16(); /* 1 cycle */ +#else + isqrtQ16_local = isqrt_Q16tab[L_yy]; move16(); /* 1 cycle */ +#endif + } + ELSE + { + /* about 8-9 cycles */ + exp = 15; move16(); /* set ISqrt16() exp_in to get delta exp out near 0 when Lyy is in Q0 */ + tmp = ISqrt16(extract_l(L_yy), + &exp); /* exp out is now a delta shift with a later tmp Q15 multiplication in mind */ +#ifdef ENABLE_HR_MODE + exp_shift = add(exp, 16); /* up to Q16 */ + isqrtQ31_local = L_shl(L_deposit_l(tmp), exp_shift); /* new mantissa in a fixed Q16 */ +#else + exp_shift = add(exp, 16 - 15); /* up to Q16 */ + isqrtQ16_local = shl(tmp, exp_shift); /* new mantissa in a fixed Q16 */ +#endif + } + + shift_num = norm_s(k_val_max); /* simply account for the preknown fixed max possible pulseamp in y */ + shift_tot = sub(14 - 1, shift_num); /* upshift to get to Q14 */ + FOR (i = 0; i < dim; i++) /* upshifted y[i] used */ + { +#ifdef ENABLE_HR_MODE + L_tmp = Mpy_32_16_lc3plus(isqrtQ31_local, shl_pos(y[i], shift_num)); /* Q(16+0+shift_num +1 = shift_num+1 */ + xq[i] = L_shl(L_tmp, shift_tot + 1); move32(); /* Q30 , */ +#else + L_tmp = L_mult(isqrtQ16_local, shl_pos(y[i], shift_num)); /* Q(16+0+shift_num +1 = shift_num+1 */ + xq[i] = round_fx(L_shl(L_tmp, shift_tot)); move16(); /* Q14 , */ +#endif + } + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/pvq_enc_fx.c b/lib_lc3plus/pvq_enc_fx.c new file mode 100644 index 000000000..9c164dda5 --- /dev/null +++ b/lib_lc3plus/pvq_enc_fx.c @@ -0,0 +1,369 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static void pvq_pyr_project(const Word16 dim_proj, /* end vector dimension+1 */ + const Word16 *xabs, /* absolute vector values */ + Word32 L_xsum, /* absolute vector sum over dim */ + Word16 num, /* target number of pulses */ + Word16 * y, /* projected output vector */ + Word16 *pulse_tot_ptr, Word32 *L_xy_ptr, /* accumulated correlation Q(in+0+1) = Qin+1 */ + Word32 *L_yy_ptr /* accumulated energy Q0 */ +) +{ + + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_tmp, L_num; + Word16 den, shift_num, shift_den, shift_delta, proj_fac; + ); + + *pulse_tot_ptr = 0; move16(); + *L_xy_ptr = L_deposit_l(0); + *L_yy_ptr = L_deposit_l(0); + + shift_den = norm_l(L_xsum); /* x_sum input Qin */ + den = extract_h(L_shl_pos(L_xsum, shift_den)); /* now in Qin+shift_den */ + + L_num = L_deposit_l(num); + shift_num = sub(norm_l(L_num), 1); + L_num = L_shl_pos(L_num, shift_num); /* now in Q0 +shift_num -1 */ + proj_fac = div_l(L_num, den); /* L_num always has to be less than den<<16 , norm_l-1 makes that happen */ + + shift_delta = sub(shift_num, shift_den); + FOR (i = 0; i < dim_proj; i++) + { + L_tmp = L_mult(proj_fac, xabs[i]); /* Q shift_delta + PVQ_SEARCH_QIN */ + y[i] = extract_h(L_shr(L_tmp, shift_delta)); move16(); /* to Q0 with floor , and potential sturation */ + ; + + *pulse_tot_ptr = add(*pulse_tot_ptr, y[i]); /* Q0 */ + *L_yy_ptr = L_mac0(*L_yy_ptr, y[i], y[i]); /* Energy, Q0 */ + *L_xy_ptr = L_mac(*L_xy_ptr, xabs[i], y[i]); /* Corr, Q0*Q12 +1 --> Q13 */ + } + + Dyn_Mem_Deluxe_Out(); +} + + +static __forceinline Word16 one_pulse_search(const Word16 dim_start, /* start vector dimension */ + const Word16 dim_end, /* end vector dimension+1 */ + const Word16 *x_abs, /* absolute vector values */ + Word16 * y, /* output vector */ + Word16 * pulse_tot_ptr, + Word32 * L_xy_ptr, /* accumulated correlation Q(12+0+1) = Q13 */ + Word32 * L_yy_ptr, /* accumulated energy Q0 */ + Word16 max_xabs) /* current max amplitude for target */ +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word16 corr_tmp, corr_sq_tmp, en_max_den, cmax_num, en_tmp; + Word32 L_tmp_en_lc, L_tmp_corr; + Word16 corr_up_shift, imax; + ); + + /* maximize correlation precision, prior to every unit pulse addition in the vector */ + corr_up_shift = norm_l(L_mac(*L_xy_ptr, 1, max_xabs)); /* pre analyze worst case L_xy update in the dim loop */ + imax = -1; /* not needed for search, only added to avoid compiler warning */ + { + en_max_den = 0; move16(); + cmax_num = -1; move16(); /* req. to force a 1st update for n==dim_start */ + + FOR (i = dim_start; i < dim_end; i++) + { + L_tmp_corr = L_shl_pos(L_mac(*L_xy_ptr, 1, x_abs[i]), corr_up_shift); /* actual in-loop target value */ + + corr_tmp = round_fx_sat(L_tmp_corr); + + corr_sq_tmp = mult(corr_tmp, corr_tmp); /* CorrSq_tmp for a 16bit low complexity cross multiplication */ + + L_tmp_en_lc = L_mac(*L_yy_ptr, 1, y[i]); /*Q0 x^2+ 2x , "+1" added once before loop , result , energy may + span up to ~14+1(Q1)+1(sign)=16 bits */ + /* extract_l without shift can always be used for this section as energy is guaranteed to stay in the lower + * word*/ + + en_tmp = extract_l(L_tmp_en_lc); /* L_shl + round_fx could also be used also but then adds an uphift cost */ + + /* 16/32 bit comparison WC (4 +1+1 + (1+1+1) = 9 */ + IF (L_msu(L_mult(corr_sq_tmp, en_max_den), cmax_num, en_tmp) > 0) /* use L_mult and then a L_msu */ + { + cmax_num = corr_sq_tmp; move16(); + en_max_den = en_tmp; move16(); + imax = i; move16(); + } + } /* dim */ + } + + + /* finally add found unit pulse contribution to past L_xy, Lyy, for next pulse loop */ + *L_xy_ptr = L_mac(*L_xy_ptr, x_abs[imax], 1); /* Qin+1 */ + *L_yy_ptr = L_mac(*L_yy_ptr, 1, y[imax]); + + y[imax] = add(y[imax], 1); move16(); /* Q0 added pulse */ + (*pulse_tot_ptr) = add((*pulse_tot_ptr), 1); /* increment total pulse sum */ + Dyn_Mem_Deluxe_Out(); + return imax; +} + + +void pvq_enc_search_fx( + const Word16 *x, /* i: target vector to quantize Qin */ + Word16 * y_far, /* o: outl_far o, raw pulses (non-scaled short) Q0 , length dim */ + Word16 * y, /* o: outl_near o, raw pulses (non-scaled short) Q0 , length dim */ + Word16 * yA, /* o: A section raw pulses (non-scaled short) Q0 , length dimA */ + Word16 * yB, /* o: B section raw pulses (non-scaled short) Q0 , length dim-dimA */ + Word32 * L_corr, /* o: 4 un-normalized correlation sums for outl_far, outl_near, A, AB */ + Word32 * L_search_en, /* o: 4 energy sums for outl_far, outl_near, A, AB */ + Word16 * pulses_fin, /* i: number of allocated pulses to outl_far, outl_near , A, AB sections */ + Word16 * pulses_proj, /* i: number of projection pulses for outl_far, outl_near, A, AB */ + + const Word16 dim, /* i: Length of outlier vector */ + const Word16 dimA /* i: Length of vector A section */ +) +{ + + Dyn_Mem_Deluxe_In( + Counter i; + Word16 pulse_tot_far, pulse_tot, pulse_totA, pulse_totB; + Word16 xabs[PVQ_MAX_VEC_SIZE]; + Word16 max_xabs, max_xabsA, max_xabsB; + Word32 L_xsum, L_xsumA; + Word32 L_yy, L_xy; + Word16 imax; + Counter k; + Word16 dim_m1; + Word16 dimB; + const Word16 *xBptr; + Word16 pulses_far, pulses, pulsesA, pulsesB; + ); + +#ifdef WMOPS + BASOP_sub_sub_start("pvq_enc_search_fx"); +#endif + + pulses_far = pulses_fin[0]; move16(); + pulses = pulses_fin[1]; move16(); + pulsesA = pulses_fin[2]; move16(); + pulsesB = pulses_fin[3]; move16(); + + FOR (i = 0; i < N_SCF_SHAPES_ST2; i++) + { + L_corr[i] = L_deposit_l(0); + L_search_en[i] = L_deposit_l(0); + } + + dimB = sub(dim, dimA); + + L_xsum = L_deposit_h(0); + + max_xabs = -1; move16(); + max_xabsA = -1; move16(); + max_xabsB = -1; move16(); + FOR (i = 0; i < dimA; i++) + { + xabs[i] = abs_s(x[i]); move16(); /* Qx */ + max_xabsA = s_max(max_xabsA, xabs[i]); /* for efficient search correlation scaling */ + L_xsum = L_mac0(L_xsum, 1, xabs[i]); /* stay in Qx */ + } + + basop_memset(y_far, 0, dim * sizeof(Word16)); + basop_memset(y, 0, dimA * sizeof(Word16)); + basop_memset(yA, 0, dimA * sizeof(Word16)); + + L_xsumA = L_add(L_xsum, 0); /* save for section A projection */ + + FOR (i = dimA; i < dim; i++) + { + xabs[i] = abs_s(x[i]); move16(); /* Qx */ + max_xabsB = s_max(max_xabsB, xabs[i]); /* for efficient search correlation scaling */ + L_xsum = L_mac0(L_xsum, 1, xabs[i]); /* stay in Qx */ + } + + basop_memset(&y[dimA], 0, (dim - dimA) * sizeof(Word16)); + + basop_memset(yB, 0, dimB * sizeof(Word16)); + + max_xabs = s_max(max_xabsA, max_xabsB); /* global max abs value */ + + test(); + IF (L_xsum == 0) + { /* no shape in any section, projection in outl_far, outl_near, A, AB not possible, any search meaningless */ + + dim_m1 = sub(dim, 1); + y_far[0] = shr_pos(pulses_far, 1); move16(); + y_far[dim_m1] = add(y_far[dim_m1], sub(pulses_far, y_far[0])); move16(); + + dim_m1 = sub(dim, 1); + y[0] = shr_pos(pulses, 1); move16(); + y[dim_m1] = add(y[dim_m1], sub(pulses, y[0])); move16(); + + dim_m1 = sub(dimA, 1); + yA[0] = shr_pos(pulsesA, 1); move16(); + yA[dim_m1] = add(yA[dim_m1], sub(pulsesA, yA[0])); move16(); + + dim_m1 = sub(dimB, 1); + yB[0] = shr_pos(pulsesB, 1); move16(); + yB[dim_m1] = add(yB[dim_m1], sub(pulsesB, yB[0])); move16(); + } + ELSE + { + ASSERT(pulses_proj[0] > 0); + ASSERT(L_xsum > 0); + + pvq_pyr_project(dim, xabs, L_xsum, pulses_proj[0], y_far, &pulse_tot_far, &L_xy, + &L_yy); /* outlier submode projection */ + + ASSERT(pulses_far <= 127); + FOR (k = pulse_tot_far; k < pulses_far; k++) + { + L_yy = L_add(L_yy, 1); /* pre add 1 in Q0 in L_yyQ0 = (x^2 + 2*x + 1) */ + imax = one_pulse_search(0, dim, xabs, y_far, &pulse_tot_far, &L_xy, &L_yy, max_xabs); + } + ASSERT(pulse_tot_far == pulses_far); + /* outlier far submode result vector in y_far[0...15] */ + L_corr[0] = L_shr_pos(L_xy, 1); /* to Qin*Q0 */ + + basop_memmove(y, y_far, dim * sizeof(Word16)); /*y_far->y */ + + pulse_tot = pulse_tot_far; move16(); + + ASSERT(pulses <= 127); + FOR (k = pulse_tot; k < pulses; k++) + { + L_yy = L_add(L_yy, 1); /* pre add 1 in Q0 in L_yyQ0 = (x^2 + 2*x + 1) */ + imax = one_pulse_search(0, dim, xabs, y, &pulse_tot, &L_xy, &L_yy, max_xabs); + } + + /* outlier near submode result vector in y[0...15] */ + L_corr[1] = L_shr_pos(L_xy, 1); /* to Qin*Q0 */ + + ASSERT(pulse_tot == pulses); + + IF (L_xsumA == 0) + { + /* no shape in A section, projection in A not possible, search meaningless */ + dim_m1 = sub(dimA, 1); + yA[0] = shr_pos(pulsesA, 1); move16(); + yA[dim_m1] = add(yA[dim_m1], sub(pulsesA, yA[0])); move16(); + } + ELSE + { + IF (pulses_proj[2] != 0) /* fixed setup if bitrate is fixed */ + { + ASSERT(pulses_proj[2] > 0); + ASSERT(L_xsumA > 0); + pvq_pyr_project(dimA, xabs, L_xsumA, pulses_proj[2], yA, &pulse_totA, &L_xy, + &L_yy); /* section A , in submode 1 projection */ + } + ELSE + { + /* default, otherwise recalculate A from outlier result (to remove any section B pulses influence) + */ + pulse_totA = 0; move16(); + L_xy = L_deposit_l(0); + L_yy = L_deposit_l(0); + + basop_memmove(yA, y, dimA * sizeof(Word16)); + FOR (i = 0; i < dimA; i++) + { + pulse_totA = add(pulse_totA, yA[i]); /* Q0 */ + L_xy = L_mac(L_xy, xabs[i], yA[i]); /* Corr, Q0*Q12 +1 --> Q13 */ + L_yy = L_mac(L_yy, yA[i], yA[i]); /* Energy, Q(0+0)+1)= Q1 */ + } + L_yy = L_shr_pos(L_yy, 1); /* En to Q0 */ + } + + /* search remaining pulses in regular section A */ + FOR (k = pulse_totA; k < pulsesA; k++) + { + L_yy = L_add(L_yy, 1); /* 1 added in Q0 */ + imax = one_pulse_search(0, dimA, xabs, yA, &pulse_totA, &L_xy, &L_yy, max_xabsA); + } + ASSERT(pulse_totA == pulsesA); + } /* L_xsumA!=0 */ + + /* reg Set A result vector now in yA[0...9] */ + L_corr[2] = L_shr_pos(L_xy, 1); /* to Qin*Q0 */ + + /* search remaining pulses in regular section B, even if energy in B is zero */ + ASSERT(pulses_proj[3] == 0); + pulse_totB = 0; move16(); + + IF (sub(pulsesB, 1) == 0) + { /* LC search, sufficient to find a single max, as pulses can not be stacked, when nb-pulses==1 */ + imax = 0; move16(); /* safety */ + FOR (i = dimA; i < dim; i++) + { + if (xabs[i] == max_xabsB) + { + imax = sub(i, dimA); + } + } + pulse_totB = 1; move16(); + yB[imax] = 1; move16(); /* reg set B result vector in yB[0...5] */ + L_xy = L_mac(L_xy, xabs[add(imax, dimA)], 1); /* calc total corr for A+B sections */ + L_yy = L_add(L_yy, 1); + } + ELSE + { /* more than one target pulse in section B */ + /* keep A pulses influence, search section B pulses influence */ + FOR (k = pulse_totB; k < pulsesB; k++) + { + L_yy = L_add(L_yy, 1); /* 1 added in Q0*/ + imax = one_pulse_search(dimA, dim, xabs, &(yB[-dimA]), &pulse_totB, &L_xy, &L_yy, max_xabsB); + } + } + + L_corr[3] = L_shr_pos(L_xy, 1); move32(); /* to Qin*Q0 , corr of combined A and B */ + + ASSERT(pulse_totB == pulsesB); + /* reg set B result vector now in yB[0...5] */ + } /* L_xsum != 0 */ + +/* apply sign of (x) to first orthant result */ + FOR (i = 0; i < dim; i++) + { + if (x[i] < 0) + { + y_far[i] = negate(y_far[i]); /* apply sign for outlier far */ + } + } + + FOR (i = 0; i < dim; i++) + { + if (x[i] < 0) + { + y[i] = negate(y[i]); /* apply sign for outliers near */ + } + } + + xBptr = &(x[dimA]); move32(); /* ptr init to B target section */ + FOR (i = 0; i < dimA; i++) + { + if (x[i] < 0) + { + yA[i] = negate(yA[i]); /* apply sign in N_SETA */ + } + } + + FOR (i = 0; i < (dimB); i++) + { + if (xBptr[i] < 0) + { + yB[i] = negate(yB[i]); /* apply sign in N_SETB */ + } + } + + Dyn_Mem_Deluxe_Out(); +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} + diff --git a/lib_lc3plus/pvq_index_fx.c b/lib_lc3plus/pvq_index_fx.c new file mode 100644 index 000000000..c7d63c840 --- /dev/null +++ b/lib_lc3plus/pvq_index_fx.c @@ -0,0 +1,513 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +#define SIGNBIT_FX 0x80000000u +#define SIGNBIT_SHRT_FX 0x8000 + +static void initOffsets_fx(Word16 dim_in, UWord32 *h_mem, + Word16 k_val_in) /* may be removed with tables for N=16,10,6 */ +{ + UWord32 k_val_prev, k_val_curr; + UWord32 k_val, UL_k_val_in; +#ifdef DYNMEM_COUNT + Dyn_Mem_In("initOffsets_fx", sizeof(struct { + UWord32 k_val_prev, k_val_curr; + UWord32 k_val, UL_k_val_in; + })); +#endif + + h_mem[0] = UL_deposit_l(0); + h_mem[1] = UL_deposit_l(1); + + UL_k_val_in = UL_deposit_l(k_val_in); + IF (sub(dim_in, 2) == 0) + { + FOR (k_val = 2; k_val <= UL_k_val_in; k_val++) + { + h_mem[k_val] = UL_subNsD(UL_lshl(k_val, 1), 1U); move32(); + } + h_mem[k_val] = UL_k_val_in; move32(); + } + ELSE + { + k_val_prev = UL_deposit_l(1U); + FOR (k_val_curr = 2; k_val_curr <= UL_k_val_in; k_val_curr++) + { + h_mem[k_val_curr] = UL_addNsD(1U, UL_Mpy_32_32(k_val_curr, UL_lshl(k_val_prev, 1))); move32(); + k_val_prev = UL_addNsD(k_val_curr, 0U); + } + h_mem[k_val_curr] = UL_Mpy_32_32(k_val_curr, k_val_prev); move32(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +static void a_fwd_fx(UWord32 *a_in, /* i/o: offsets */ + Word16 n_items /* i : items, k's */ +) +{ + UWord32 a_1, a_in0; + Counter i; + UWord32 *a_in_prev_ptr; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("a_fwd_fx", sizeof(struct { + UWord32 a_1, a_in0; + Counter i; + UWord32 *a_in_prev_ptr; + })); +#endif + + a_in0 = UL_deposit_l(1); + + a_in_prev_ptr = &(a_in[-1]); + FOR (i = 1; i <= n_items; i++) + { + a_1 = UL_addNsD(a_in0, UL_addNsD(a_in_prev_ptr[i], a_in[i])); + a_in_prev_ptr[i] = a_in0; move32(); + a_in0 = UL_addNsD(a_1, 0U); + } + a_in_prev_ptr[i] = a_in0; move32(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +static void a_bwd_fx(UWord32 *a_in, /* i/o: offsets */ + Word16 n_items /* i: n_items */ +) +{ + UWord32 a_1, a_in0; + Counter i; + UWord32 *a_in_prev_ptr; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("a_bwd_fx", sizeof(struct { + UWord32 a_1, a_in0; + Counter i; + UWord32 *a_in_prev_ptr; + })); +#endif + + a_in0 = UL_deposit_l(0); + a_in_prev_ptr = &(a_in[-1]); + + FOR (i = 1; i <= n_items; i++) + { + a_1 = UL_subNsD(UL_subNsD(a_in[i], a_in0), a_in_prev_ptr[i]); + a_in_prev_ptr[i] = a_in0; move32(); + a_in0 = UL_addNsD(a_1, 0U); + } + a_in_prev_ptr[i] = a_in0; move32(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +static void a_u_fwd_fx(UWord32 *a_u_in, Word16 k_val_in, Word16 mem_size_m1) +{ + UWord32 u_kp1_prev, u_kp1; + UWord32 u_k_prev; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("a_u_fwd_fx", sizeof(struct { + UWord32 u_kp1_prev, u_kp1; + UWord32 u_k_prev; + })); +#endif + + u_kp1_prev = a_u_in[mem_size_m1]; move32(); + u_k_prev = UL_lshr(a_u_in[k_val_in], 1); + + a_fwd_fx(&a_u_in[1], k_val_in); + + u_kp1 = UL_lshr(a_u_in[k_val_in], 1); + a_u_in[mem_size_m1] = UL_addNsD(1U, UL_addNsD(u_kp1_prev, UL_addNsD(u_k_prev, u_kp1))); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +static Word16 get_lead_sign_fx(UWord32 *ind) +{ + Word16 leading_sign; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("get_lead_sign_fx", sizeof(struct { Word16 leading_sign; })); +#endif + + leading_sign = 1; move16(); + if (UL_and(*ind, 1) != 0) + { + leading_sign = -1; move16(); + } + (*ind) = UL_lshr(*ind, 1); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + + return leading_sign; +} + +/*-------------------------------------------------------------------* + * mind2vec_one_fx() + *-------------------------------------------------------------------*/ +static void mind2vec_one_fx(Word16 k_val_in, /* i: nb unit pulses , [ 0...K_MAX ] */ + Word16 leading_sign, /* i: leading sign -1, 0, 1*/ + UWord32 ind, /* i: index */ /* parameter could be omitted */ + Word16 *vec_out /* o: pulse train */ +) +{ + *vec_out = (Word16)ind; /* dummy assignment to handle the common ind parameter warning */ + + if (leading_sign < 0) + { + k_val_in = negate(k_val_in); + } + *vec_out = k_val_in; move16(); +} + +static Word16 setval_update_sign_fx(Word16 k_delta, Word16 k_max_local, Word16 *leading_sign, UWord32 *ind_in, + Word16 *vec_out) +{ + IF (k_delta != 0) + { + mind2vec_one_fx(k_delta, *leading_sign, *ind_in, vec_out); + *leading_sign = get_lead_sign_fx(ind_in); + k_max_local = sub(k_max_local, k_delta); + } + return k_max_local; +} + +/*-------------------------------------------------------------------* + * mind2vec_fx() + *-------------------------------------------------------------------*/ +static void mind2vec_fx(Word16 dim_in, /* i: dimension */ + Word16 k_max_local, /* i: nb unit pulses */ + Word16 leading_sign, /* i: leading sign */ + UWord32 ind, /* i: index */ + Word16 * vec_out, /* o: pulse train */ + UWord32 *h_in /* i: offset vector A=1+2U */ +) +{ + Counter pos; + Word16 k_acc, k_delta; + UWord32 UL_tmp_offset, UL_diff; + UWord16 sgn; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("mind2vec_fx", sizeof(struct { + Counter pos; + Word16 k_acc, k_delta; + UWord32 UL_tmp_offset, UL_diff; + UWord16 sgn; + })); +#endif + + k_acc = k_max_local; move16(); + FOR (pos = 0; pos < dim_in; pos++) + { + + IF (ind != 0) + { + + k_acc = k_max_local; move16(); + + UL_tmp_offset = UL_addNsD(h_in[k_acc], 0U); + + UL_diff = UL_subNs(ind, UL_tmp_offset, &sgn); + + WHILE (sgn) + { + UL_diff = UL_subNs(ind, h_in[--k_acc], &sgn); + } + + ind = UL_addNsD(UL_diff, 0U); + + k_delta = sub(k_max_local, k_acc); + } + ELSE + { + mind2vec_one_fx(k_max_local, leading_sign, ind, &vec_out[pos]); + BREAK; + } + + k_max_local = setval_update_sign_fx(k_delta, k_max_local, &leading_sign, &ind, &vec_out[pos]); + + a_bwd_fx(h_in, add(k_max_local, 1)); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +PvqEntry_fx get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val */ + Word16 dim_in, /* i : dimension */ + Word16 k_val_in, /* i : nb unit pulses */ + UWord32 *h_mem /* o : offsets */ +) +{ + Counter i; + PvqEntry_fx entry; + Word16 kp1; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("get_size_mpvq_calc_offset_fx", sizeof(struct { + Counter i; + PvqEntry_fx entry; + Word16 kp1; + })); +#endif + + entry.dim = dim_in; move16(); + entry.k_val = k_val_in; move16(); + + entry.index = L_deposit_l(0); + entry.lead_sign_ind = 0; move16(); + + ASSERT(dim_in <= M); + ASSERT(tabledKMAX[dim_in] != 0); + + /* tabled values for worst case K */ /* made into table lookup for N=16, 10, 6 */ + kp1 = add(k_val_in, 1); + FOR (i = 0; i <= kp1; i++) /* A+U copying */ + { + h_mem[i] = + UL_addNsD(MPVQ_offs_ptr[dim_in][i], 0U); /* a vector copying is needed as MPVQ recursion is in place */ + } + /* special handling of last U offset in k+1 column */ + if (sub(k_val_in, tabledKMAX[dim_in]) != 0) + { + h_mem[kp1] = UL_lshr(h_mem[kp1], 1); /* (A+1)/2 , convert from A(K+1) to U(K+1) domain */ + } + entry.size = + UL_addNsD(1U, UL_addNsD(h_mem[kp1], UL_lshr(h_mem[k_val_in], 1))); /* MPVQ size calc. 1 + H(K+1) + (A(K)>>1) */ + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + + return entry; +} + +/*-------------------------------------------------------------------* + * mpvq_deindex_fx() + *-------------------------------------------------------------------*/ +void mpvq_deindex_fx( /* o : void */ + const PvqEntry_fx *entry, /* i : sign_ind, index, dim, k_val */ + UWord32 * h_mem, /* i : A/U offsets */ + Word16 * vec_out /* o : pulse train */ +) +{ + Word16 leading_sign; +#ifdef DYNMEM_COUNT + Dyn_Mem_In("mpvq_deindex_fx", sizeof(struct { Word16 leading_sign; })); +#endif +#ifdef WMOPS + BASOP_sub_sub_start("mpvq_deindex_fx"); +#endif + + basop_memset(vec_out, 0, (entry->dim) * sizeof(Word16)); + + leading_sign = 1; move16(); + if (entry->lead_sign_ind != 0) + { + leading_sign = -1; move16(); + } + + IF (entry->k_val != 0) + { + mind2vec_fx(entry->dim, entry->k_val, leading_sign, entry->index, vec_out, h_mem); + } +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +} + +/*-------------------------------------------------------------------* + * vec2mind_two_fx() + *-------------------------------------------------------------------*/ +static void vec2mind_two_fx(const Word16 *vec_in, /* i : PVQ pulse train */ + Word16 * k_val_out_ptr, /* o : number of unit pulses */ + UWord32 * next_sign_ind, /* i/o: next sign ind */ + UWord32 * ind /* o: MPVQ index */ +) +{ + UWord32 lead_sign_ind_add; + Word16 abs0, abs1, abs01, sptr; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("vec2mind_two_fx", sizeof(struct { + UWord32 lead_sign_ind_add; + Word16 abs0, abs1, abs01, sptr; + })); +#endif + + abs0 = abs_s(vec_in[0]); + abs1 = abs_s(vec_in[1]); + abs01 = add(abs0, abs1); + *k_val_out_ptr = abs01; move16(); + *ind = UL_deposit_l(0); + + *next_sign_ind = UL_deposit_h(SIGNBIT_SHRT_FX); + + IF (abs01 != 0) + { + sptr = 0; move16(); + *next_sign_ind = UL_deposit_l(sptr); + + test(); + IF (abs0 != 0 && abs1 != 0) + { + lead_sign_ind_add = UL_deposit_l(1); + if (vec_in[1] < 0) + { + lead_sign_ind_add = UL_deposit_l(2); + } + *ind = UL_addNsD(UL_deposit_l((UWord16)lshl(sub(abs1, 1), 1)), lead_sign_ind_add); + } + ELSE + { + IF (abs0 == 0) + { + *ind = UL_deposit_l((UWord16)sub(lshl(abs1, 1), 1)); + sptr = 1; move16(); + } + } + + if (vec_in[sptr] < 0) + { + *next_sign_ind = UL_deposit_l(1); + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +static void enc_push_sign(Word16 val, UWord32 *next_sign_ind, UWord32 *index) +{ + test(); + IF ((UL_and(*next_sign_ind, SIGNBIT_FX) == 0) && (val != 0)) + { + *index = UL_addNsD(UL_lshl(*index, 1), *next_sign_ind); + } + if (val < 0) + { + *next_sign_ind = UL_deposit_l(1); + } + if (val > 0) + { + *next_sign_ind = UL_deposit_l(0); + } +} + +static void vec2mind_fx(Word16 dim_in, /* i : dim */ + Word16 k_val_in, /* i : number of unit pulses */ + const Word16 *vec_in, /* i : PVQ pulse train */ + UWord32 * next_sign_ind, /* o : pushed leading sign */ + UWord32 * index, /* o : MPVQ index */ + UWord32 * N_MPVQ_ptr, /* o : size(N_MPVQ(dim,K_val_in))*/ + UWord32 * h_mem) /* o : offsets */ +{ + Counter pos; + Word16 mem_size_m1, k_val_acc, tmp_val; + UWord32 tmp_h; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("vec2mind_fx", sizeof(struct { + Counter pos; + Word16 mem_size_m1, k_val_acc, tmp_val; + UWord32 tmp_h; + })); +#endif + + mem_size_m1 = add(k_val_in, 1); + *next_sign_ind = UL_deposit_h(SIGNBIT_SHRT_FX); + + pos = sub(dim_in, 2); + vec2mind_two_fx(&vec_in[pos], &k_val_acc, next_sign_ind, index); + initOffsets_fx(3, h_mem, k_val_in); + + tmp_h = h_mem[k_val_acc]; move32(); + FOR (pos--; pos >= 0; pos--) + { + tmp_val = vec_in[pos]; move16(); + enc_push_sign(tmp_val, next_sign_ind, index); + + *index = UL_addNsD(*index, tmp_h); + + k_val_acc = add(k_val_acc, abs_s(tmp_val)); + + IF (pos != 0) + { + a_u_fwd_fx(h_mem, k_val_in, mem_size_m1); + } + tmp_h = UL_addNsD(h_mem[k_val_acc], 0U); + } + *N_MPVQ_ptr = UL_addNsD(1U, UL_addNsD(UL_lshr(tmp_h, 1), h_mem[mem_size_m1])); move32(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +PvqEntry_fx mpvq_index_fx( /* o : leading_sign_index, index, size, k_val */ + const Word16 *vec_in, /* i : signed pulse train */ + Word16 dim_in, /* i : dimension */ + Word16 k_val_local /* i : nb unit pulses */ +) +{ + PvqEntry_fx result; + UWord32 h_mem[1 + KMAX_FX + 1]; + UWord32 lead_sign_ind; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("mpvq_index_fx", sizeof(struct { + PvqEntry_fx result; + UWord32 h_mem[1 + KMAX_FX + 1]; + UWord32 lead_sign_ind; + })); +#endif +#ifdef WMOPS + BASOP_sub_sub_start("mpvq_index_fx"); +#endif + + ASSERT(k_val_local <= KMAX_FX); + + result.k_val = k_val_local; move16(); + result.dim = dim_in; move16(); + + vec2mind_fx(dim_in, k_val_local, vec_in, &lead_sign_ind, &result.index, &result.size, h_mem); + + result.lead_sign_ind = u_extract_l(lead_sign_ind); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + + return result; +} + diff --git a/lib_lc3plus/quantize_spec_fx.c b/lib_lc3plus/quantize_spec_fx.c new file mode 100644 index 000000000..4667cf146 --- /dev/null +++ b/lib_lc3plus/quantize_spec_fx.c @@ -0,0 +1,1167 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +# ifdef ENABLE_HR_MODE +void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word32 gain, Word16 gain_e, Word32 xq[], Word16 nt, Word16 target, + Word16 totalBits, Word16 *nBits, Word16 *nBits2, Word16 fs_idx, Word16 *lastnzout, + Word16 *codingdata, Word16 *lsbMode, Word16 mode, Word16 hrmode) +{ + + Word32 a1, b1, a1_i, b1_i; + Word16 t, lev1; + Word16 lastnz, lastnz2; + Word16 rateFlag; + Word32 nbits32, nbits232, target32; + Word16 nt_half; + Word32 c, ab_max, msb, a1_msb, b1_msb; + Word16 levmax; + Word16 s; + Word16 totBits, nbits_lsb; + Counter k, lev; + Word16 maxlevs; +# ifndef FUNCTION_quantizeSpec_func1 + Word16 tmp16; + Word32 offs32; + Counter i; +# else + Word32 ARM_params[3]; +# endif + +# ifdef DYNMEM_COUNT + Dyn_Mem_In("processQuantizeSpec_fx", sizeof(struct { + Word32 a1, b1, a1_i, b1_i, ab_max, c; + Word16 t, lev1; + Word16 lastnz, lastnz2; + Word16 rateFlag; + Word32 nbits32, nbits232; + Word16 nt_half; + Word16 msb, a1_msb, b1_msb, levmax; + Counter k, lev, i; + Word16 s; + Word16 tmp16; + Word32 offs32, target32; + Word16 totBits, nbits_lsb; + Word16 maxlevs; + })); +# endif + + assert(target >= 0); + + /* Quantization */ + gain = invFixp(gain, &gain_e); + + maxlevs = 21; + IF (hrmode) + { + s = sub(add(x_e, gain_e), 23); + s = s_min(s, 31); +# ifdef FUNCTION_quantizeSpec_func1 + ARM_params[0] = gain; + ARM_params[1] = s; + + quantizeSpec_func1_hr_ip(xq, x, nt, ARM_params); +# else + IF(s > 4) + { + s = sub(s, 4); /* Use extra bits of precision for fine calculation */ + FOR(i = 0; i < nt; i++) + { + offs32 = Mpy_32_32_lc3plus(L_shl_pos(x[i], s), gain); /* multiply */ + xq[i] = L_shr_r_pos(offs32, 4); /* Convert to Q0 with rounding */ + /* rounding is the equivalent of adding 0.5, which is the offset in hrmode */ + + move32(); + } + } + ELSE + { + FOR(i = 0; i < nt; i++) + { + offs32 = Mpy_32_32_lc3plus(x[i], gain); /* multiply */ + offs32 = L_shl(offs32, s); /* convert to 23Q8 */ + xq[i] = L_shr_r_pos(offs32, 8); /* Convert to Q0 with rounding */ + /* rounding is the equivalent of adding 0.5, which is the offset in hrmode */ + + move32(); + } + } +# endif /* FUNCTION_quantizeSpec_func1 */ + } + ELSE + { + s = sub(add(x_e, gain_e), 15); + s = s_max(s_min(s, 15), -15); +# ifdef FUNCTION_quantizeSpec_func1 + ARM_params[0] = gain; + ARM_params[1] = s; + ARM_params[2] = -4096; + quantizeSpec_func1_ip(xq, x, nt, ARM_params); +# else + FOR (i = 0; i < nt; i++) + { + offs32 = Mpy_32_32_lc3plus(L_abs(x[i]), gain); /* multiply */ + offs32 = L_shl(offs32, s); /* convert to 15Q16 */ + tmp16 = mac_r(offs32, -4096, 1); /* add offset and truncate */ + + if (x[i] < 0) + tmp16 = negate(tmp16); /* restore sign */ + + /* Normal quantization: xq[i] = x[i] / gg + sign(x[i]) * 0.375 + quant_offset is -0.125 in Q15 and round adds 0.5 in Q16. Hence + mac_r results in abs(x[i])/gain - 0.125 + 0.5 = abs(x[i])/gain + 0.375. + Due to the abs and negate combination this achieves the same result + as spec. + */ + + xq[i] = tmp16; + move16(); + } +# endif /* FUNCTION_quantizeSpec_func1 */ + } + /* Rate flag */ + rateFlag = 0; + move16(); + if (fs_idx != 5) + { + if (sub(totalBits, add(160, DEPR_i_mult(fs_idx, 160))) > 0) + { + rateFlag = 2 << NBITS_CONTEXT; + move16(); + } + } + + /* Init */ + nt_half = shr_pos(nt, 1); + c = 0; + move16(); + t = 0; + move16(); + a1_i = 0; + move16(); + b1_i = 1; + move16(); + target32 = L_shl_pos(L_deposit_l(target), SYM_BITS_Q); + nbits32 = L_negate(target32); + nbits232 = 0; + move32(); + nbits_lsb = 0; + move16(); + + if (fs_idx != 5) + { + IF (mode == 0 && sub(totalBits, add(480, DEPR_i_mult(fs_idx, 160))) >= 0) + { + mode = 1; + move16(); + } + } + + /* Find last non-zero tuple */ + lastnz = find_last_nz_pair(xq, nt); + IF (mode >= 0) + { + lastnz2 = 2; + } + ELSE + { + lastnz2 = lastnz; + } + + IF (mode < 0) + { + /* Main Loop through the 2-tuples */ + FOR (k = 0; k < lastnz; k += 2) + { + + /* Get context */ + t = add(c, rateFlag); + if (sub(k, nt_half) > 0) + { + t = add(t, 1 << NBITS_CONTEXT); + } + codingdata[0] = t; + move16(); + + /* Init current 2-tuple encoding */ + a1 = L_abs(xq[a1_i]); + b1 = L_abs(xq[b1_i]); + ab_max = L_max(a1, b1); + + IF (ab_max == 0) + { + codingdata[1] = -1; + move16(); + codingdata[2] = 0; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][0]); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (L_sub(ab_max, A_THRES) < 0) + { + codingdata[1] = 0; + move16(); + msb = L_add(a1, L_shl_pos(b1, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + c = L_add(shl_pos(s_and(c, 0xf), 4), L_add(L_add(a1, b1), 1)); + } + ELSE IF (L_sub(ab_max, 2 * A_THRES) < 0) + { + codingdata[1] = 1; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][VAL_ESC]); + nbits32 = L_add(nbits32, 2 << SYM_BITS_Q); + a1_msb = L_shr_pos_pos(a1, 1); + b1_msb = L_shr_pos_pos(b1, 1); + msb = L_add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + c = L_add(shl_pos(s_and(c, 0xf), 4), L_add(L_shl_pos(L_add(a1_msb, b1_msb), 1), 1)); + } + ELSE + { + levmax = sub(maxlevs, sub(norm_l(ab_max), 8)); + codingdata[1] = levmax; + move16(); + FOR (lev = 0; lev < levmax; lev++) + { + lev1 = s_min(lev, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][VAL_ESC]); + } + nbits32 = L_add(nbits32, L_shl_pos(L_deposit_l(levmax), SYM_BITS_Q + 1)); + a1_msb = L_shr(a1, levmax); + b1_msb = L_shr(b1, levmax); + msb = L_add(a1_msb, L_shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + lev1 = s_min(levmax, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(12, s_min(levmax, 3))); + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /* end of the 2-tuples loop */ + } + ELSE IF (mode == 0) + { + /* Main Loop through the 2-tuples */ + FOR (k = 0; k < lastnz; k += 2) + { + + /* Get context */ + t = add(c, rateFlag); + if (sub(k, nt_half) > 0) + { + t = add(t, 1 << NBITS_CONTEXT); + } + + codingdata[0] = t; + move16(); + + /* Init current 2-tuple encoding */ + a1 = L_abs(xq[a1_i]); + b1 = L_abs(xq[b1_i]); + ab_max = L_max(a1, b1); + + IF (ab_max == 0) + { + codingdata[1] = -1; + move16(); + codingdata[2] = 0; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][0]); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (L_sub(ab_max, A_THRES) < 0) + { + codingdata[1] = 0; + move16(); + msb = L_add(a1, L_shl_pos(b1, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + + c = L_add(shl_pos(s_and(c, 0xf), 4), L_add(L_add(a1, b1), 1)); + } + ELSE IF (L_sub(ab_max, 2 * A_THRES) < 0) + { + codingdata[1] = 1; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][VAL_ESC]); + nbits32 = L_add(nbits32, 2 << SYM_BITS_Q); + a1_msb = L_shr_pos_pos(a1, 1); + b1_msb = L_shr_pos_pos(b1, 1); + msb = L_add(a1_msb, L_shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + + c = add(shl_pos(s_and(c, 0xf), 4), L_add(L_shl_pos(L_add(a1_msb, b1_msb), 1), 1)); + } + ELSE + { + levmax = sub(maxlevs, sub(norm_l(ab_max), 8)); + codingdata[1] = levmax; + move16(); + FOR (lev = 0; lev < levmax; lev++) + { + lev1 = s_min(lev, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][VAL_ESC]); + } + nbits32 = L_add(nbits32, L_shl_pos(L_deposit_l(levmax), SYM_BITS_Q + 1)); + a1_msb = L_shr(a1, levmax); + b1_msb = L_shr(b1, levmax); + msb = L_add(a1_msb, L_shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + lev1 = s_min(levmax, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + + c = add(shl_pos(s_and(c, 0xf), 4), add(12, s_min(levmax, 3))); + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /* end of the 2-tuples loop */ + } + ELSE + { + /* Main Loop through the 2-tuples */ + FOR (k = 0; k < lastnz; k += 2) + { + + /* Get context */ + t = add(c, rateFlag); + + if (sub(k, nt_half) > 0) + { + t = add(t, 1 << NBITS_CONTEXT); + } + + codingdata[0] = t; + move16(); + + /* Init current 2-tuple encoding */ + a1 = L_abs(xq[a1_i]); + b1 = L_abs(xq[b1_i]); + ab_max = L_max(a1, b1); + + IF (ab_max == 0) + { + codingdata[1] = -1; + move16(); + codingdata[2] = 0; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][0]); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (L_sub(ab_max, A_THRES) < 0) + { + codingdata[1] = 0; + move16(); + msb = L_add(a1, L_shl_pos(b1, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + + c = add(shl_pos(s_and(c, 0xf), 4), add(add(a1, b1), 1)); + } + ELSE IF (L_sub(ab_max, 2 * A_THRES) < 0) + { + codingdata[1] = 1; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][VAL_ESC]); + a1_msb = L_shr_pos_pos(a1, 1); + b1_msb = L_shr_pos_pos(b1, 1); + msb = L_add(a1_msb, L_shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[1]]][msb]); + if (a1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + nbits_lsb = add(nbits_lsb, 2); + if (L_sub(a1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + if (L_sub(b1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + + c = add(shl_pos(s_and(c, 0xf), 4), add(shl_pos(add(a1_msb, b1_msb), 1), 1)); + } + ELSE + { + levmax = sub(maxlevs, sub(norm_l(ab_max), 8)); + codingdata[1] = levmax; + move16(); + FOR (lev = 0; lev < levmax; lev++) + { + lev1 = s_min(lev, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][VAL_ESC]); + } + nbits32 = L_add(nbits32, L_shl_pos(L_deposit_l(sub(levmax, 1)), SYM_BITS_Q + 1)); + a1_msb = L_shr(a1, levmax); + b1_msb = L_shr(b1, levmax); + msb = L_add(a1_msb, L_shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + lev1 = s_min(levmax, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][msb]); + a1_msb = L_shr_pos(a1, 1); + b1_msb = L_shr_pos(b1, 1); + if (a1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + nbits_lsb = add(nbits_lsb, 2); + if (L_sub(a1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + if (L_sub(b1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + + c = add(shl_pos(s_and(c, 0xf), 4), add(12, s_min(levmax, 3))); + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /* end of the 2-tuples loop */ + } + + /* Number of consumed bits */ + nbits32 = L_add(nbits32, target32); + totBits = add(extract_l(L_shr_pos_pos(L_sub(nbits32, 1), SYM_BITS_Q)), 1); + IF (mode > 0) + { + totBits = add(totBits, nbits_lsb); + } + IF (nBits != NULL) + { + *nBits = totBits; + } + IF (mode >= 0) + { + nbits232 = L_add(nbits232, target32); + *nBits2 = add(extract_l(L_shr_pos(L_sub(nbits232, 1), SYM_BITS_Q)), 1); + } + ELSE + { + *nBits2 = *nBits; + move16(); + } + IF (mode > 0) + { + *nBits2 = add(*nBits2, nbits_lsb); + } + *lastnzout = lastnz2; + + /* Truncation of high frequency coefficients */ + IF (lastnz > lastnz2) + { + basop_memset(&xq[lastnz2], 0, (lastnz - lastnz2) * sizeof(*xq)); + } + + /* Truncation of LSBs */ + test(); + IF (mode > 0 && sub(totBits, target) > 0) + { + *lsbMode = 1; + move16(); + } + ELSE + { + *lsbMode = 0; + move16(); + } + +# ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +# endif +} + +# else /* ENABLE_HR_MODE */ + +void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, Word16 xq[], Word16 nt, Word16 target, + Word16 totalBits, Word16 *nBits, Word16 *nBits2, Word16 fs_idx, Word16 *lastnzout, + Word16 *codingdata, Word16 *lsbMode, Word16 mode +) +{ + + Word16 a1, b1, a1_i, b1_i; + Word16 t, lev1; + Word16 lastnz, lastnz2; + Word16 rateFlag; + Word32 nbits32, nbits232, target32; + Word16 nt_half; + Word16 c, ab_max, msb, a1_msb, b1_msb, levmax; + Word16 s; + Word16 totBits, nbits_lsb; + Counter k, lev; + Word16 tmp16; + Word32 offs32; + Counter i; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processQuantizeSpec_fx", sizeof(struct { + Word16 a1, b1, a1_i, b1_i; + Word16 t, lev1; + Word16 lastnz, lastnz2; + Word16 rateFlag; + Word32 nbits32, nbits232; + Word16 nt_half; + Word16 c, ab_max, msb, a1_msb, b1_msb, levmax; + Counter k, lev, i; + Word16 s; + Word16 tmp16; + Word32 offs32, target32; + Word16 totBits, nbits_lsb; + })); +#endif + + /* Quantization */ + gain = Inv16_lc3plus(gain, &gain_e); + s = sub(add(x_e, gain_e), 15); + s = s_max(s_min(s, 15), -15); + + FOR (i = 0; i < nt; i++) + { + offs32 = Mpy_32_16_lc3plus(L_abs(x[i]), gain); /* multiply */ + offs32 = L_shl(offs32, s); /* convert to 15Q16 */ + tmp16 = extract_h(L_add(offs32, 0x00006000)); /* add offset and truncate */ + Word16 x_sign = (Word16) L_shr(x[i], 31); + xq[i] = sub(s_xor(tmp16, x_sign), x_sign); + move16(); + /* + Normal quantization: xq[i] = x[i] / gg + sign(x[i]) * 0.375 + -> 0.375 = 0x00006000 in 15Q16 + */ + } + + /* Rate flag */ + rateFlag = 0; + move16(); + if (sub(totalBits, add(160, DEPR_i_mult(fs_idx, 160))) > 0) + { + rateFlag = 2 << NBITS_CONTEXT; + move16(); + } + + /* Init */ + nt_half = shr_pos(nt, 1); + c = 0; + move16(); + t = 0; + move16(); + a1_i = 0; + move16(); + b1_i = 1; + move16(); + target32 = L_shl_pos(L_deposit_l(target), SYM_BITS_Q); + nbits32 = L_negate(target32); + nbits232 = 0; + move32(); + nbits_lsb = 0; + move16(); + IF (mode == 0 && sub(totalBits, add(480, DEPR_i_mult(fs_idx, 160))) >= 0) + { + mode = 1; + move16(); + } + + /* Find last non-zero tuple */ + lastnz = find_last_nz_pair(xq, nt); + IF (mode >= 0) + { + lastnz2 = 2; + } + ELSE + { + lastnz2 = lastnz; + } + + IF (mode < 0) + { + /* Main Loop through the 2-tuples */ + FOR (k = 0; k < lastnz; k += 2) + { + + /* Get context */ + t = add(c, rateFlag); + if (sub(k, nt_half) > 0) + { + t = add(t, 1 << NBITS_CONTEXT); + } + codingdata[0] = t; + move16(); + + /* Init current 2-tuple encoding */ + a1 = abs_s(xq[a1_i]); + b1 = abs_s(xq[b1_i]); + ab_max = s_max(a1, b1); + + IF (ab_max == 0) + { + codingdata[1] = -1; + move16(); + codingdata[2] = 0; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][0]); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (sub(ab_max, A_THRES) < 0) + { + codingdata[1] = 0; + move16(); + msb = add(a1, shl_pos(b1, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(add(a1, b1), 1)); + } + ELSE IF (sub(ab_max, 2 * A_THRES) < 0) + { + codingdata[1] = 1; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][VAL_ESC]); + nbits32 = L_add(nbits32, 2 << SYM_BITS_Q); + a1_msb = shr_pos_pos(a1, 1); + b1_msb = shr_pos_pos(b1, 1); + msb = add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(shl_pos(add(a1_msb, b1_msb), 1), 1)); + } + ELSE + { + levmax = sub(13, norm_s(ab_max)); + codingdata[1] = levmax; + move16(); + FOR (lev = 0; lev < levmax; lev++) + { + lev1 = s_min(lev, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][VAL_ESC]); + } + nbits32 = L_add(nbits32, L_shl_pos(L_deposit_l(levmax), SYM_BITS_Q + 1)); + a1_msb = shr(a1, levmax); + b1_msb = shr(b1, levmax); + msb = add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + lev1 = s_min(levmax, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(12, s_min(levmax, 3))); + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /* end of the 2-tuples loop */ + } + ELSE IF (mode == 0) + { + /* Main Loop through the 2-tuples */ + FOR (k = 0; k < lastnz; k += 2) + { + + /* Get context */ + t = add(c, rateFlag); + if (sub(k, nt_half) > 0) + { + t = add(t, 1 << NBITS_CONTEXT); + } + codingdata[0] = t; + move16(); + + /* Init current 2-tuple encoding */ + a1 = abs_s(xq[a1_i]); + b1 = abs_s(xq[b1_i]); + ab_max = s_max(a1, b1); + + IF (ab_max == 0) + { + codingdata[1] = -1; + move16(); + codingdata[2] = 0; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][0]); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (sub(ab_max, A_THRES) < 0) + { + codingdata[1] = 0; + move16(); + msb = add(a1, shl_pos(b1, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(add(a1, b1), 1)); + } + ELSE IF (sub(ab_max, 2 * A_THRES) < 0) + { + codingdata[1] = 1; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][VAL_ESC]); + nbits32 = L_add(nbits32, 2 << SYM_BITS_Q); + a1_msb = shr_pos_pos(a1, 1); + b1_msb = shr_pos_pos(b1, 1); + msb = add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(shl_pos(add(a1_msb, b1_msb), 1), 1)); + } + ELSE + { + levmax = sub(13, norm_s(ab_max)); + codingdata[1] = levmax; + move16(); + FOR (lev = 0; lev < levmax; lev++) + { + lev1 = s_min(lev, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][VAL_ESC]); + } + nbits32 = L_add(nbits32, L_shl_pos(L_deposit_l(levmax), SYM_BITS_Q + 1)); + a1_msb = shr(a1, levmax); + b1_msb = shr(b1, levmax); + msb = add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + lev1 = s_min(levmax, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(12, s_min(levmax, 3))); + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /* end of the 2-tuples loop */ + } + ELSE + { + /* Main Loop through the 2-tuples */ + FOR (k = 0; k < lastnz; k += 2) + { + + /* Get context */ + t = add(c, rateFlag); + if (sub(k, nt_half) > 0) + { + t = add(t, 1 << NBITS_CONTEXT); + } + codingdata[0] = t; + move16(); + + /* Init current 2-tuple encoding */ + a1 = abs_s(xq[a1_i]); + b1 = abs_s(xq[b1_i]); + ab_max = s_max(a1, b1); + + IF (ab_max == 0) + { + codingdata[1] = -1; + move16(); + codingdata[2] = 0; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][0]); + c = add(shl_pos(s_and(c, 0xf), 4), 1); + } + ELSE IF (sub(ab_max, A_THRES) < 0) + { + codingdata[1] = 0; + move16(); + msb = add(a1, shl_pos(b1, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][msb]); + if (a1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1 != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(add(a1, b1), 1)); + } + ELSE IF (sub(ab_max, 2 * A_THRES) < 0) + { + codingdata[1] = 1; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t]][VAL_ESC]); + a1_msb = shr_pos_pos(a1, 1); + b1_msb = shr_pos_pos(b1, 1); + msb = add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[1]]][msb]); + if (a1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + nbits_lsb = add(nbits_lsb, 2); + if (sub(a1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + if (sub(b1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(shl_pos(add(a1_msb, b1_msb), 1), 1)); + } + ELSE + { + levmax = sub(13, norm_s(ab_max)); + codingdata[1] = levmax; + move16(); + FOR (lev = 0; lev < levmax; lev++) + { + lev1 = s_min(lev, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][VAL_ESC]); + } + nbits32 = L_add(nbits32, L_shl_pos(L_deposit_l(sub(levmax, 1)), SYM_BITS_Q + 1)); + a1_msb = shr(a1, levmax); + b1_msb = shr(b1, levmax); + msb = add(a1_msb, shl_pos(b1_msb, A_THRES_SHIFT)); + codingdata[2] = msb; + move16(); + lev1 = s_min(levmax, 3); + nbits32 = L_add(nbits32, ari_spec_bits[ari_spec_lookup[t + Tab_esc_nb[lev1]]][msb]); + a1_msb = shr_pos(a1, 1); + b1_msb = shr_pos(b1, 1); + if (a1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + if (b1_msb != 0) + { + nbits32 = L_add(nbits32, 1 << SYM_BITS_Q); + } + nbits_lsb = add(nbits_lsb, 2); + if (sub(a1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + if (sub(b1, 1) == 0) + { + nbits_lsb = add(nbits_lsb, 1); + } + if (nbits32 <= 0) + { + lastnz2 = add(k, 2); + } + if (nbits32 <= 0) + { + nbits232 = nbits32; + move32(); + } + c = add(shl_pos(s_and(c, 0xf), 4), add(12, s_min(levmax, 3))); + } + + a1_i += 2; + b1_i += 2; + codingdata += 3; + + } /* end of the 2-tuples loop */ + } + + /* Number of consumed bits */ + nbits32 = L_add(nbits32, target32); + totBits = add(extract_l(L_shr_pos_pos(L_sub(nbits32, 1), SYM_BITS_Q)), 1); + IF (mode > 0) + { + totBits = add(totBits, nbits_lsb); + } + IF (nBits != NULL) + { + *nBits = totBits; + } + IF (mode >= 0) + { + nbits232 = L_add(nbits232, target32); + *nBits2 = add(extract_l(L_shr_pos(L_sub(nbits232, 1), SYM_BITS_Q)), 1); + } + ELSE + { + *nBits2 = *nBits; + move16(); + } + IF (mode > 0) + { + *nBits2 = add(*nBits2, nbits_lsb); + } + *lastnzout = lastnz2; + + /* Truncation of high frequency coefficients */ + IF (lastnz > lastnz2) + { + basop_memset(&xq[lastnz2], 0, (lastnz - lastnz2) * sizeof(*xq)); + } + + /* Truncation of LSBs */ + test(); + IF (mode > 0 && sub(totBits, target) > 0) + { + *lsbMode = 1; + move16(); + } + ELSE + { + *lsbMode = 0; + move16(); + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +# endif /* ENABLE_HR_MODE */ diff --git a/lib_lc3plus/reorder_bitstream_fx.c b/lib_lc3plus/reorder_bitstream_fx.c new file mode 100644 index 000000000..281eef325 --- /dev/null +++ b/lib_lc3plus/reorder_bitstream_fx.c @@ -0,0 +1,56 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "defines.h" + +#include "constants.h" +#include "functions.h" + + +void processReorderBitstream_fx(UWord8 *bytes, Word16 n_pccw, Word16 n_pc, Word16 b_left, Word8 *scratchBuffer) +{ + Word16 block_bytes; + UWord8 * bytes_tmp; + +#ifdef DYNMEM_COUNT + struct _dynmem + { + Word16 block_bits, block_bytes; + UWord8 * bytes_tmp; + }; + Dyn_Mem_In("processReorderBitstream_fx", sizeof(struct _dynmem)); +#endif + + bytes_tmp = (UWord8 *)scratchAlign(scratchBuffer, 0); /* Size = LC3PLUS_MAX_BYTES */ + + if (n_pccw == 0) + { +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + return; + } + + assert(b_left >= 0); + + /* set block size in bits and full bytes */ + block_bytes = shr_sat(add(n_pc, 1), 1); + + /* rearrange bitstream */ + basop_memmove(&bytes_tmp[0], &bytes[b_left], block_bytes * sizeof(UWord8)); + basop_memmove(&bytes_tmp[block_bytes], &bytes[0], b_left * sizeof(UWord8)); + + basop_memmove(&bytes[0], &bytes_tmp[0], add(block_bytes, b_left) * sizeof(UWord8)); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + + diff --git a/lib_lc3plus/resamp12k8_fx.c b/lib_lc3plus/resamp12k8_fx.c new file mode 100644 index 000000000..a54f6bc29 --- /dev/null +++ b/lib_lc3plus/resamp12k8_fx.c @@ -0,0 +1,121 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void process_resamp12k8_fx(Word16 x[], Word16 x_len, Word16 mem_in[], Word16 mem_in_len, Word32 mem_50[], + Word16 mem_out[], Word16 mem_out_len, Word16 y[], Word16 *y_len, Word16 fs_idx, + Word16 frame_dms, Word8 *scratchBuffer + , Word16 bps + ) +{ + Dyn_Mem_Deluxe_In( + Word16 * buf; + Word16 index_int, index_frac, len_12k8; + Word16 resamp_upfac, resamp_off_int, resamp_off_frac, resamp_delay; + const Word16 *resamp_filt; + const Word16 *filt_coeff; + Word16 * filt_input; + Word32 filt_output, mem_50_0, mem_50_1; + Counter n, m; + Word32 L_tmp; + ); + + buf = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * (MAX_LEN + MAX_LEN / 8) bytes */ + + /* resamp parameters : {upsample-factor, 120 / upsample-factor, down_sample_int_part, down_sample_frac_part } + upsample is to 384 kHz. upsample-facor = 192000 / samp-freq + Fractional downsample parameters are calculated from : downsample samp-freq to 128000 + At 48000 sampling frequency: + upsample-factor = 192000 / 48000 = 4 + 120 / upsample-factor = 120 / 4 = 30 + downsample-ratio = 48000 / 12800 = 3.75 + down_sample_int_part = 3 + down_sample_frac_part = int(0.75 * upsample-factor ) = 0.75 * 4 = 3 + */ + resamp_upfac = resamp_params[fs_idx][0]; move16(); + resamp_delay = resamp_params[fs_idx][1]; move16(); + resamp_off_int = resamp_params[fs_idx][2]; move16(); + resamp_off_frac = resamp_params[fs_idx][3]; move16(); + resamp_filt = resamp_filts[fs_idx]; move16(); + + len_12k8 = LEN_12K8 / 4 * (frame_dms / 25); move16(); + *y_len = len_12k8; move16(); + + /* Init Input Buffer */ + basop_memmove(buf, mem_in, mem_in_len * sizeof(Word16)); + basop_memmove(&buf[mem_in_len], x, x_len * sizeof(Word16)); + basop_memmove(mem_in, &buf[x_len], mem_in_len * sizeof(Word16)); + + /* Init Input Indices */ + index_int = 1; move16(); + index_frac = 0; move16(); + + /* Resampling */ + FOR (n = 0; n < len_12k8; n++) + { + /* Init Filtering */ + filt_input = &buf[index_int]; + filt_coeff = &resamp_filt[index_frac * resamp_delay * 2]; + +/* Perform Filtering */ + filt_output = L_mult0(*filt_input, *filt_coeff); + FOR (m = 1; m < resamp_delay * 2; m++) + { + filt_coeff++; + filt_input++; + if (*filt_coeff) + { + filt_output = L_mac0(filt_output, *filt_input, *filt_coeff); + } + } + y[n] = round_fx(filt_output); move16(); + + /* Update Input Indices */ + index_int = add(index_int, resamp_off_int); + index_frac = add(index_frac, resamp_off_frac); + IF (sub(resamp_upfac, index_frac) <= 0) + { + index_int = add(index_int, 1); + index_frac = sub(index_frac, resamp_upfac); + } + } + + /* High Pass Filtering (-3dB at 50Hz) */ + mem_50_0 = mem_50[0]; move32(); + mem_50_1 = mem_50[1]; move32(); + + FOR (n = 0; n < len_12k8; n++) + { + filt_output = L_mac0_sat(mem_50_0, highpass50_filt_num[0], y[n]); + L_tmp = L_mac0(Mpy_32_16_lc3plus(filt_output, highpass50_filt_den[0]), highpass50_filt_num[1], y[n]); + + IF (sub(bps, 24) == 0) + { + mem_50_0 = L_shl_sat(L_add_sat(L_shr_pos(mem_50_1,1), L_tmp), 1); + } ELSE + { + mem_50_0 = L_add_sat(mem_50_1, L_shl_sat(L_tmp, 1)); + } + + mem_50_1 = L_mac0(Mpy_32_16_lc3plus(filt_output, highpass50_filt_den[1]), highpass50_filt_num[2], y[n]); + y[n] = round_fx_sat(filt_output); move16(); + } + mem_50[0] = mem_50_0; move32(); + mem_50[1] = mem_50_1; move32(); + +/* Output Buffer */ + basop_memmove(buf, mem_out, mem_out_len * sizeof(Word16)); + basop_memmove(&buf[mem_out_len], y, len_12k8 * sizeof(Word16)); + basop_memmove(y, buf, (*y_len + 1) * sizeof(Word16)); + basop_memmove(mem_out, &buf[len_12k8], mem_out_len * sizeof(Word16)); + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/residual_coding_fx.c b/lib_lc3plus/residual_coding_fx.c new file mode 100644 index 000000000..2cb6c791f --- /dev/null +++ b/lib_lc3plus/residual_coding_fx.c @@ -0,0 +1,238 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +#ifdef ENABLE_HR_MODE + +void processResidualCoding_fx(Word16 x_e, Word32 x[], + Word32 xq[], Word32 gain, + Word16 gain_e, Word16 L_spec, + Word16 targetBits, Word16 nBits, UWord8 *resBits, Word16 *numResBits + , Word16 hrmode +) +{ + + Counter i; + Word16 s, n, m; + Word32 L_tmp; + Word16 iter = 0; + Counter idx; + Word16 N_nz = 0; + Word16 n1, n2; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processResidualCoding_fx", sizeof(struct { + Counter i; + Word16 s, n, m; + Word32 L_tmp; + Word16 iter; + Counter idx; + Word16 N_nz; + Word16 *nz_idx; + Word16 n1, n2; + })); +#endif + + n = 0; + move16(); + + IF (hrmode) + { + m = add(sub(targetBits, nBits), 14); + assert(m <= (MAX_RESBITS_LEN << RESBITS_PACK_SHIFT)); + } + ELSE + { + m = add(sub(targetBits, nBits), 4); + if (m > L_spec) + { + m = L_spec; + } + } + + basop_memset(resBits, 0, sizeof(*resBits)*((m + RESBITS_PACK_MASK) >> RESBITS_PACK_SHIFT)); + + s = sub(add(15, gain_e), x_e); + + IF(hrmode) + { + /* + x = xval * 2^(31 - x_e) + gain = gainval * 2^(15 - gain_e) + + To bring gain to the same q of x : + + gain (in_Qx_e) = gain * 2^(16 + gain_e - x_e) + + gain*offset (in Qx_e) = gain (in_Qx_e) * 0.25 = gain (in_Qx_e) / 4 = gain * 2^(16 - 2 + gain_e - x_e) + */ + Word16 shift_val; + shift_val = sub(sub(gain_e, x_e), 2); + + Word32 gain_offset; + + IF (shift_val <= -32) + gain_offset = 0; + ELSE + { + gain_offset = L_shl_sat(gain, shift_val); + } + + Word16 exit_iter = 0; + + Word16 nz_idx[MAX_LEN]; + + /* enumerate non-zero coefficients */ + FOR (i = 0; i < L_spec; i++) + { + IF (xq[i]) + { + nz_idx[N_nz] = i; move16(); + N_nz = add(N_nz, 1); + } + } + + s = sub(31, sub(x_e, gain_e)); + FOR (iter = 0; iter < EXT_RES_ITER_MAX; iter++) + { + FOR (i = 0; i < N_nz; i++) + { + idx = nz_idx[i]; + + L_tmp = L_sub(x[idx], Mpy_32_32_lc3plus(L_shl(xq[idx], s), gain)); + + IF (L_tmp >= 0) + { + n1 = shr(n, RESBITS_PACK_SHIFT); + n2 = s_and(n, RESBITS_PACK_MASK); + resBits[n1] = (UWord8)s_or(resBits[n1], shl(1, n2)); + move16(); + x[idx] = L_sub(x[idx], gain_offset); + move16(); + } + ELSE + { + move16(); + x[idx] = L_add(x[idx], gain_offset); + move16(); + } + n = add(n, 1); + IF (sub(n, m) == 0) + { + exit_iter = 1; + BREAK; + } + } + gain_offset = L_shr(gain_offset, 1); /* offset *= 0.5 */ + + IF (exit_iter) + { + BREAK; + } + } + } + ELSE + { + s = add(s, 16); + gain = round_fx(gain); + + FOR (i = 0; i < L_spec; i++) + { + IF (xq[i] != 0) + { + L_tmp = L_sub(x[i], Mpy_32_16_lc3plus(L_shl(xq[i], s), gain)); + if (L_tmp >= 0) + { + n1 = shr(n, RESBITS_PACK_SHIFT); + n2 = s_and(n, RESBITS_PACK_MASK); + resBits[n1] = (UWord8) s_or(resBits[n1], shl(1, n2)); + move16(); + } + n = add(n, 1); + IF (sub(n, m) == 0) + { + BREAK; + } + } + } + } + *numResBits = n; + move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +#else + +void processResidualCoding_fx(Word16 x_e, Word32 x[], + Word16 xq[], + Word16 gain, Word16 gain_e, Word16 L_spec, + Word16 targetBits, Word16 nBits, UWord8 *resBits, Word16 *numResBits +) +{ + + Counter i; + Word16 s, n, m; + Word32 L_tmp; +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processResidualCoding_fx", sizeof(struct { + Counter i; + Word16 s, n, m; + Word32 L_tmp; + })); +#endif + + n = 0; + move16(); + { + m = add(sub(targetBits, nBits), 4); + if (m > L_spec) + { + m = L_spec; + } + } + + + s = sub(add(15, gain_e), x_e); + { + FOR (i = 0; i < L_spec; i++) + { + IF (xq[i] != 0) + { + L_tmp = L_sub(x[i], L_shl(L_mult(xq[i], gain), s)); + if (L_tmp < 0) + { + resBits[n] = 0; + move16(); + } + if (L_tmp >= 0) + { + resBits[n] = 1; + move16(); + } + n = add(n, 1); + IF (sub(n, m) == 0) + { + BREAK; + } + } + } + } + *numResBits = n; + move16(); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +#endif diff --git a/lib_lc3plus/residual_decoding_fx.c b/lib_lc3plus/residual_decoding_fx.c new file mode 100644 index 000000000..686398cdd --- /dev/null +++ b/lib_lc3plus/residual_decoding_fx.c @@ -0,0 +1,207 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +#ifdef ENABLE_HR_MODE /* HRMODE enables packing of residual bits */ + +void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 prm[], Word16 resQBits +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +) +{ + + Counter i; + Word32 fac_m, fac_p; + Word16 s, bits; + Word32 tmp; + Counter idx; + Word16 N_nz = 0; + Word16 iter; + Word32 fac_hr; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processResidualDecoding_fx", sizeof(struct { + Counter i; + Word32 fac_m, fac_p; + Word16 s, bits; + Word32 tmp; + Counter idx; + Word16 N_nz; + Word16 *nz_idx; + Word16 iter; + })); +#endif + + tmp = 0; + s = sub(x_e, 1); + s = s_min(s, 31); + + IF (hrmode) + { + fac_hr = L_shr(0x10000000, s); /* 0.25 in 1Q30 */ + } + ELSE + { + fac_m = L_shr(0xC000000, s); /* 0.1875 in 1Q30 */ + fac_p = L_shr(0x14000000, s); /* 0.3125 in 1Q30 */ + } + + bits = 0; + move16(); + + Word16 nz_idx[MAX_LEN]; + + IF (hrmode) + { + FOR (i = 0; i < L_spec; i++) + { + IF (x[i]) + { + nz_idx[N_nz] = i; move16(); + N_nz = add(N_nz, 1); + } + } + FOR (iter = 0; iter < EXT_RES_ITER_MAX; iter++) + { + IF (sub(bits, resQBits) >= 0) + { + BREAK; + } + FOR (i = 0; i < N_nz; i++) + { + idx = nz_idx[i]; move16(); + + IF (sub(bits, resQBits) >= 0) + { + BREAK; + } + + IF (! (s_and(prm[shr(bits, RESBITS_PACK_SHIFT)], shl(1, s_and(bits, RESBITS_PACK_MASK))))) + { + tmp = L_sub_sat(x[idx], fac_hr); + } + ELSE + { + tmp = L_add_sat(x[idx], fac_hr); + } + x[idx] = tmp; + move32(); + bits = add(bits, 1); + } + fac_hr = L_shr(fac_hr, 1); + } + } + ELSE + { + FOR (i = 0; i < L_spec; i++) + { + IF (sub(bits, resQBits) >= 0) + { + BREAK; + } + + IF (x[i] != 0) + { + IF (! (s_and(prm[shr(bits, RESBITS_PACK_SHIFT)], shl(1, s_and(bits, RESBITS_PACK_MASK))))) + { + if (x[i] > 0) + tmp = L_sub(x[i], fac_m); + if (x[i] < 0) + tmp = L_sub(x[i], fac_p); + } + ELSE + { + if (x[i] > 0) + tmp = L_add(x[i], fac_p); + if (x[i] < 0) + tmp = L_add(x[i], fac_m); + } + x[i] = tmp; + move32(); + bits = add(bits, 1); + } + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +#else + +void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 prm[], Word16 resQBits +) +{ + + Counter i; + Word32 fac_m, fac_p; + Word16 s, bits; + Word32 tmp; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processResidualDecoding_fx", sizeof(struct { + Counter i; + Word32 fac_m, fac_p; + Word16 s, bits; + Word32 tmp; + })); +#endif + + tmp = 0; + s = sub(x_e, 1); + s = s_min(s, 31); + + { + fac_m = L_shr(0xC000000, s); /* 0.1875 in 1Q30 */ + fac_p = L_shr(0x14000000, s); /* 0.3125 in 1Q30 */ + } + + bits = 0; + move16(); + + { + FOR (i = 0; i < L_spec; i++) + { + IF (sub(bits, resQBits) >= 0) + { + BREAK; + } + + IF (x[i] != 0) + { + IF (prm[bits] == 0) + { + if (x[i] > 0) + tmp = L_sub(x[i], fac_m); + if (x[i] < 0) + tmp = L_sub(x[i], fac_p); + } + ELSE + { + if (x[i] > 0) + tmp = L_add(x[i], fac_p); + if (x[i] < 0) + tmp = L_add(x[i], fac_m); + } + x[i] = tmp; + move32(); + bits = add(bits, 1); + } + } + } + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +#endif diff --git a/lib_lc3plus/rom_basop_util.c b/lib_lc3plus/rom_basop_util.c new file mode 100644 index 000000000..e37b4bfad --- /dev/null +++ b/lib_lc3plus/rom_basop_util.c @@ -0,0 +1,2904 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "rom_basop_util.h" +#include "basop_util_lc3plus.h" +#include "functions.h" + + +/* clang-format off */ +# ifdef ENABLE_HR_MODE +# define STC(x) (x) +# define WTC(x) (x) +# define STCP(a, b) {{STC(a), STC(b)}} +# define WTCP(a, b) {{WTC(a), WTC(b)}} +# else +# define STC(x) WORD322WORD16(x) +# define WTC(x) WORD322WORD16(x) +# define STCP(a, b) {{STC(a), STC(b)}} +# define WTCP(a, b) {{WTC(a), WTC(b)}} +# endif +/* clang-format on */ + +/** + * \brief Lookup-Table for binary logarithm + */ +RAM_ALIGN const Word16 ldCoeff_lc3plus[7] = {-32768, -16384, -10923, -8192, -6554, -5461, -4681}; + +/** + \brief Lookup-Table for binary power algorithm + + This table is used for lookup 2^x with + x in range [0...1.0[ in steps of 1/32 +*/ +const UWord32 exp2_tab_long_lc3plus[32] = { + 0x40000000, 0x4166C34C, 0x42D561B4, 0x444C0740, 0x45CAE0F2, 0x47521CC6, 0x48E1E9BA, 0x4A7A77D4, + 0x4C1BF829, 0x4DC69CDD, 0x4F7A9930, 0x51382182, 0x52FF6B55, 0x54D0AD5A, 0x56AC1F75, 0x5891FAC1, + 0x5A82799A, 0x5C7DD7A4, 0x5E8451D0, 0x60962665, 0x62B39509, 0x64DCDEC3, 0x6712460B, 0x69540EC9, + 0x6BA27E65, 0x6DFDDBCC, 0x70666F76, 0x72DC8374, 0x75606374, 0x77F25CCE, 0x7A92BE8B, 0x7D41D96E, +}; + +/** + \brief Lookup-Table for binary power algorithm + + This table is used for lookup 2^x with + x in range [0...1/32[ in steps of 1/1024 +*/ +const UWord32 exp2w_tab_long_lc3plus[32] = { + 0x40000000, 0x400B1818, 0x4016321B, 0x40214E0C, 0x402C6BE9, 0x40378BB4, 0x4042AD6D, 0x404DD113, + 0x4058F6A8, 0x40641E2B, 0x406F479E, 0x407A7300, 0x4085A051, 0x4090CF92, 0x409C00C4, 0x40A733E6, + 0x40B268FA, 0x40BD9FFF, 0x40C8D8F5, 0x40D413DD, 0x40DF50B8, 0x40EA8F86, 0x40F5D046, 0x410112FA, + 0x410C57A2, 0x41179E3D, 0x4122E6CD, 0x412E3152, 0x41397DCC, 0x4144CC3B, 0x41501CA0, 0x415B6EFB, +}; + +/** + \brief Lookup-Table for binary power algorithm + + This table is used for lookup 2^x with + x in range [0...1/1024[ in steps of 1/32768 +*/ +const UWord32 exp2x_tab_long_lc3plus[32] = { + 0x40000000, 0x400058B9, 0x4000B173, 0x40010A2D, 0x400162E8, 0x4001BBA3, 0x4002145F, 0x40026D1B, + 0x4002C5D8, 0x40031E95, 0x40037752, 0x4003D011, 0x400428CF, 0x4004818E, 0x4004DA4E, 0x4005330E, + 0x40058BCE, 0x4005E48F, 0x40063D51, 0x40069613, 0x4006EED5, 0x40074798, 0x4007A05B, 0x4007F91F, + 0x400851E4, 0x4008AAA8, 0x4009036E, 0x40095C33, 0x4009B4FA, 0x400A0DC0, 0x400A6688, 0x400ABF4F, +}; + +/* square root tables */ +const Word32 SqrtTable_lc3plus[32] = { + /* Q31 */ + 0x5A82D429, 0x5BEA10FE, 0x5D4BE6E5, 0x5EA89270, 0x60004BE2, 0x615347A1, 0x62A1B68C, 0x63EBC651, + 0x6531A1B5, 0x667370D4, 0x67B1595F, 0x68EB7EC8, 0x6A220277, 0x6B5503F0, 0x6C84A0F9, 0x6DB0F5BD, + 0x6EDA1CE9, 0x70002FC7, 0x7123465A, 0x72437773, 0x7360D8C5, 0x747B7EFA, 0x75937DC4, 0x76A8E7EB, + 0x77BBCF60, 0x78CC4545, 0x79DA5A00, 0x7AE61D3E, 0x7BEF9E07, 0x7CF6EAC2, 0x7DFC113F, 0x7EFF1EC0, +}; + +const Word16 SqrtDiffTable_lc3plus[32] = { + /* Q21 */ + 0x59CF, 0x5875, 0x572B, 0x55EE, 0x54BF, 0x539C, 0x5284, 0x5177, 0x5074, 0x4F7A, 0x4E89, + 0x4DA1, 0x4CC0, 0x4BE7, 0x4B15, 0x4A4A, 0x4985, 0x48C6, 0x480C, 0x4758, 0x46AA, 0x4600, + 0x455B, 0x44BA, 0x441D, 0x4385, 0x42F1, 0x4260, 0x41D3, 0x414A, 0x40C3, 0x4040, +}; + +const Word32 ISqrtTable_lc3plus[32] = { + /* Q31 */ + 0x7FFE7F85, 0x7E0A4E25, 0x7C2C56C7, 0x7A63002C, 0x78ACD922, 0x7708939D, 0x75750088, 0x73F10C2D, + 0x727BBB1A, 0x71142774, 0x6FB97EA5, 0x6E6AFF54, 0x6D27F79D, 0x6BEFC388, 0x6AC1CBA4, 0x699D83DA, + 0x68826A53, 0x6770068E, 0x6665E882, 0x6563A7DF, 0x6468E364, 0x63754043, 0x62886999, 0x61A20FEE, + 0x60C1E8C8, 0x5FE7AE45, 0x5F131EBE, 0x5E43FC76, 0x5D7A0D4F, 0x5CB51A81, 0x5BF4F061, 0x5B395E26, +}; + +const Word16 ISqrtDiffTable_lc3plus[32] = { + /* Q21 */ + 0x7D0C, 0x777E, 0x7256, 0x6D8A, 0x6911, 0x64E5, 0x60FD, 0x5D54, 0x59E5, 0x56AA, 0x53A0, + 0x50C2, 0x4E0D, 0x4B7E, 0x4912, 0x46C6, 0x4499, 0x4288, 0x4090, 0x3EB1, 0x3CE9, 0x3B36, + 0x3996, 0x380A, 0x368F, 0x3524, 0x33C9, 0x327C, 0x313D, 0x300B, 0x2EE5, 0x2DCA, +}; + +/* 1/x tables */ +const Word32 InvTable_lc3plus[32] = { + /* Q31 */ + 0x7FFBFE40, 0x7C1B608E, 0x78752176, 0x750440BA, 0x71C44C49, 0x6EB14D0A, 0x6BC7B6B4, 0x69045A19, + 0x6664598A, 0x63E51EE2, 0x61845308, 0x5F3FD698, 0x5D15BB8E, 0x5B043FD0, 0x5909C861, 0x5724DD3C, + 0x555425B2, 0x53966532, 0x51EA787F, 0x504F5331, 0x4EC3FD84, 0x4D479267, 0x4BD93DBE, 0x4A783ADC, + 0x4923D31D, 0x47DB5CAE, 0x469E3974, 0x456BD608, 0x4443A8D9, 0x43253159, 0x420FF746, 0x41038A01, +}; + +#ifdef ENABLE_HR_MODE +const Word16 InvIntTable[74] = { + 32767, 32767, 16384, 10923, 8192, 6554, 5461, 4681, 4096, 3641, 3277, 2979, 2731, 2521, 2341, + 2185, 2048, 1928, 1820, 1725, 1638, 1560, 1489, 1425, 1365, 1311, 1260, 1214, 1170, 1130, + 1092, 1057, 1024, 993, 964, 936, 910, 886, 862, 840, 819, 799, 780, 762, 745, + 728, 712, 697, 683, 669, 655, 643, 630, 618, 607, 596, 585, 575, 565, 555, + 546, 537, 529, 520, 512, 504, 496, 489, 482, 475, 468, 462, 455, 449 +}; +#else +const Word16 InvIntTable[32] = { + 0x7FFF, 0x7FFF, 0x4000, 0x2AAB, 0x2000, 0x199A, 0x1555, 0x1249, 0x1000, 0x0E39, 0x0CCD, + 0x0BA3, 0x0AAB, 0x09D9, 0x0925, 0x0889, 0x0800, 0x0788, 0x071C, 0x06BD, 0x0666, 0x0618, + 0x05D1, 0x0591, 0x0555, 0x051F, 0x04EC, 0x04BE, 0x0492, 0x046A, 0x0444, 0x0421, +}; +#endif + +const Word16 InvDiffTable_lc3plus[32] = { + /* Q20 */ + 0x7C14, 0x74C8, 0x6E1C, 0x67FF, 0x6260, 0x5D33, 0x586C, 0x5400, 0x4FE7, 0x4C19, 0x4890, + 0x4543, 0x422F, 0x3F4F, 0x3C9D, 0x3A17, 0x37B8, 0x357E, 0x3365, 0x316B, 0x2F8D, 0x2DCB, + 0x2C20, 0x2A8D, 0x290F, 0x27A4, 0x264C, 0x2506, 0x23CF, 0x22A7, 0x218E, 0x2081, +}; + +/* + Sine tables + */ +# ifdef ENABLE_HR_MODE +const PWord32 SineTable480[] = { +# else +const PWord16 SineTable480[] = { +# endif + STCP(0x7fffffff, 0x00000000), STCP(0x7fffd315, 0x006b3b9b), STCP(0x7fff4c54, 0x00d676eb), + STCP(0x7ffe6bbf, 0x0141b1a5), STCP(0x7ffd3154, 0x01aceb7c), STCP(0x7ffb9d15, 0x02182427), + STCP(0x7ff9af04, 0x02835b5a), STCP(0x7ff76721, 0x02ee90c8), STCP(0x7ff4c56f, 0x0359c428), + STCP(0x7ff1c9ef, 0x03c4f52f), STCP(0x7fee74a2, 0x0430238f), STCP(0x7feac58d, 0x049b4f00), + STCP(0x7fe6bcb0, 0x05067734), STCP(0x7fe25a0f, 0x05719be2), STCP(0x7fdd9dad, 0x05dcbcbe), + STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd317b4, 0x06b2f1d2), STCP(0x7fcd4e24, 0x071e0575), + STCP(0x7fc72ae2, 0x07891418), STCP(0x7fc0adf2, 0x07f41d72), STCP(0x7fb9d759, 0x085f2137), + STCP(0x7fb2a71b, 0x08ca1f1b), STCP(0x7fab1d3d, 0x093516d4), STCP(0x7fa339c5, 0x09a00817), + STCP(0x7f9afcb9, 0x0a0af299), STCP(0x7f92661d, 0x0a75d60e), STCP(0x7f8975f9, 0x0ae0b22c), + STCP(0x7f802c52, 0x0b4b86a8), STCP(0x7f76892f, 0x0bb65336), STCP(0x7f6c8c96, 0x0c21178c), + STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f578721, 0x0cf68662), STCP(0x7f4c7e54, 0x0d61304e), + STCP(0x7f411c2f, 0x0dcbd0d5), STCP(0x7f3560b9, 0x0e3667ad), STCP(0x7f294bfd, 0x0ea0f48c), + STCP(0x7f1cde01, 0x0f0b7727), STCP(0x7f1016ce, 0x0f75ef33), STCP(0x7f02f66f, 0x0fe05c64), + STCP(0x7ef57cea, 0x104abe71), STCP(0x7ee7aa4c, 0x10b5150f), STCP(0x7ed97e9c, 0x111f5ff4), + STCP(0x7ecaf9e5, 0x11899ed3), STCP(0x7ebc1c31, 0x11f3d164), STCP(0x7eace58a, 0x125df75b), + STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e8d6d91, 0x13321c53), STCP(0x7e7d2c54, 0x139c1abf), + STCP(0x7e6c9251, 0x14060b68), STCP(0x7e5b9f93, 0x146fee03), STCP(0x7e4a5426, 0x14d9c245), + STCP(0x7e38b017, 0x154387e6), STCP(0x7e26b371, 0x15ad3e9a), STCP(0x7e145e42, 0x1616e618), + STCP(0x7e01b096, 0x16807e15), STCP(0x7deeaa7a, 0x16ea0646), STCP(0x7ddb4bfc, 0x17537e63), + STCP(0x7dc79529, 0x17bce621), STCP(0x7db3860f, 0x18263d36), STCP(0x7d9f1ebd, 0x188f8357), + STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d7547a7, 0x1961db9b), STCP(0x7d5fd801, 0x19caed29), + STCP(0x7d4a105d, 0x1a33ec9c), STCP(0x7d33f0ca, 0x1a9cd9ac), STCP(0x7d1d7958, 0x1b05b40f), + STCP(0x7d06aa16, 0x1b6e7b7a), STCP(0x7cef8315, 0x1bd72fa4), STCP(0x7cd80464, 0x1c3fd045), + STCP(0x7cc02e15, 0x1ca85d12), STCP(0x7ca80038, 0x1d10d5c2), STCP(0x7c8f7ade, 0x1d793a0b), + STCP(0x7c769e18, 0x1de189a6), STCP(0x7c5d69f7, 0x1e49c447), STCP(0x7c43de8e, 0x1eb1e9a7), + STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c0fc22a, 0x1f81f37c), STCP(0x7bf53153, 0x1fe9d75f), + STCP(0x7bda497d, 0x2051a4dd), STCP(0x7bbf0aba, 0x20b95bac), STCP(0x7ba3751d, 0x2120fb83), + STCP(0x7b8788ba, 0x2188841a), STCP(0x7b6b45a5, 0x21eff528), STCP(0x7b4eabf1, 0x22574e65), + STCP(0x7b31bbb2, 0x22be8f87), STCP(0x7b1474fd, 0x2325b847), STCP(0x7af6d7e6, 0x238cc85d), + STCP(0x7ad8e482, 0x23f3bf7e), STCP(0x7aba9ae6, 0x245a9d65), STCP(0x7a9bfb27, 0x24c161c7), + STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a5db997, 0x258e9ce0), STCP(0x7a3e17f2, 0x25f51307), + STCP(0x7a1e2082, 0x265b6e8a), STCP(0x79fdd35c, 0x26c1af22), STCP(0x79dd3098, 0x2727d486), + STCP(0x79bc384d, 0x278dde6e), STCP(0x799aea92, 0x27f3cc94), STCP(0x7979477d, 0x28599eb0), + STCP(0x79574f28, 0x28bf547b), STCP(0x793501a9, 0x2924edac), STCP(0x79125f19, 0x298a69fc), + STCP(0x78ef678f, 0x29efc925), STCP(0x78cc1b26, 0x2a550adf), STCP(0x78a879f4, 0x2aba2ee4), + STCP(0x78848414, 0x2b1f34eb), STCP(0x7860399e, 0x2b841caf), STCP(0x783b9aad, 0x2be8e5e8), + STCP(0x7816a759, 0x2c4d9050), STCP(0x77f15fbc, 0x2cb21ba0), STCP(0x77cbc3f2, 0x2d168792), + STCP(0x77a5d413, 0x2d7ad3de), STCP(0x777f903c, 0x2ddf0040), STCP(0x7758f886, 0x2e430c6f), + STCP(0x77320d0d, 0x2ea6f827), STCP(0x770acdec, 0x2f0ac320), STCP(0x76e33b3f, 0x2f6e6d16), + STCP(0x76bb5521, 0x2fd1f5c1), STCP(0x76931bae, 0x30355cdd), STCP(0x766a8f04, 0x3098a223), + STCP(0x7641af3d, 0x30fbc54d), STCP(0x76187c77, 0x315ec617), STCP(0x75eef6ce, 0x31c1a43b), + STCP(0x75c51e61, 0x32245f72), STCP(0x759af34c, 0x3286f779), STCP(0x757075ac, 0x32e96c09), + STCP(0x7545a5a0, 0x334bbcde), STCP(0x751a8346, 0x33ade9b3), STCP(0x74ef0ebc, 0x340ff242), + STCP(0x74c34820, 0x3471d647), STCP(0x74972f92, 0x34d3957e), STCP(0x746ac52f, 0x35352fa1), + STCP(0x743e0918, 0x3596a46c), STCP(0x7410fb6b, 0x35f7f39c), STCP(0x73e39c49, 0x36591cea), + STCP(0x73b5ebd1, 0x36ba2014), STCP(0x7387ea23, 0x371afcd5), STCP(0x73599760, 0x377bb2e9), + STCP(0x732af3a7, 0x37dc420c), STCP(0x72fbff1b, 0x383ca9fb), STCP(0x72ccb9db, 0x389cea72), + STCP(0x729d2409, 0x38fd032d), STCP(0x726d3dc6, 0x395cf3e9), STCP(0x723d0734, 0x39bcbc63), + STCP(0x720c8075, 0x3a1c5c57), STCP(0x71dba9ab, 0x3a7bd382), STCP(0x71aa82f7, 0x3adb21a1), + STCP(0x71790c7e, 0x3b3a4672), STCP(0x71474660, 0x3b9941b1), STCP(0x711530c2, 0x3bf8131c), + STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70b01790, 0x3cb5376b), STCP(0x707d1443, 0x3d1389cb), + STCP(0x7049c203, 0x3d71b14d), STCP(0x701620f5, 0x3dcfadb0), STCP(0x6fe2313c, 0x3e2d7eb1), + STCP(0x6fadf2fc, 0x3e8b240e), STCP(0x6f79665b, 0x3ee89d86), STCP(0x6f448b7e, 0x3f45ead8), + STCP(0x6f0f6289, 0x3fa30bc1), STCP(0x6ed9eba1, 0x40000000), STCP(0x6ea426ed, 0x405cc754), + STCP(0x6e6e1492, 0x40b9617d), STCP(0x6e37b4b6, 0x4115ce38), STCP(0x6e010780, 0x41720d46), + STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d92c59b, 0x422a0154), STCP(0x6d5b313b, 0x4285b5d4), + STCP(0x6d23501b, 0x42e13ba4), STCP(0x6ceb2261, 0x433c9283), STCP(0x6cb2a837, 0x4397ba32), + STCP(0x6c79e1c2, 0x43f2b271), STCP(0x6c40cf2c, 0x444d7aff), STCP(0x6c07709b, 0x44a8139e), + STCP(0x6bcdc639, 0x45027c0c), STCP(0x6b93d02e, 0x455cb40c), STCP(0x6b598ea3, 0x45b6bb5e), + STCP(0x6b1f01c0, 0x461091c2), STCP(0x6ae429ae, 0x466a36f9), STCP(0x6aa90697, 0x46c3aac5), + STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a31e000, 0x4775fd1f), STCP(0x69f5dcd3, 0x47cedb31), + STCP(0x69b98f48, 0x482786dc), STCP(0x697cf78a, 0x487fffe4), STCP(0x694015c3, 0x48d84609), + STCP(0x6902ea1d, 0x4930590f), STCP(0x68c574c4, 0x498838b6), STCP(0x6887b5e2, 0x49dfe4c2), + STCP(0x6849ada3, 0x4a375cf5), STCP(0x680b5c33, 0x4a8ea111), STCP(0x67ccc1be, 0x4ae5b0da), + STCP(0x678dde6e, 0x4b3c8c12), STCP(0x674eb271, 0x4b93327c), STCP(0x670f3df3, 0x4be9a3db), + STCP(0x66cf8120, 0x4c3fdff4), STCP(0x668f7c25, 0x4c95e688), STCP(0x664f2f2e, 0x4cebb75c), + STCP(0x660e9a6a, 0x4d415234), STCP(0x65cdbe05, 0x4d96b6d3), STCP(0x658c9a2d, 0x4debe4fe), + STCP(0x654b2f10, 0x4e40dc79), STCP(0x65097cdb, 0x4e959d08), STCP(0x64c783bd, 0x4eea2670), + STCP(0x648543e4, 0x4f3e7875), STCP(0x6442bd7e, 0x4f9292dc), STCP(0x63fff0ba, 0x4fe6756a), + STCP(0x63bcddc7, 0x503a1fe5), STCP(0x637984d4, 0x508d9211), STCP(0x6335e611, 0x50e0cbb4), + STCP(0x62f201ac, 0x5133cc94), STCP(0x62add7d6, 0x51869476), STCP(0x626968be, 0x51d92321), + STCP(0x6224b495, 0x522b7859), STCP(0x61dfbb8a, 0x527d93e6), STCP(0x619a7dce, 0x52cf758f), + STCP(0x6154fb91, 0x53211d18), STCP(0x610f3505, 0x53728a4a), STCP(0x60c92a5a, 0x53c3bcea), + STCP(0x6082dbc1, 0x5414b4c1), STCP(0x603c496c, 0x54657194), STCP(0x5ff5738d, 0x54b5f32c), + STCP(0x5fae5a55, 0x55063951), STCP(0x5f66fdf5, 0x555643c8), STCP(0x5f1f5ea1, 0x55a6125c), + STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e8f57e2, 0x5644faf4), STCP(0x5e46f0dd, 0x5694148b), + STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5db55c86, 0x57319135), STCP(0x5d6c2f99, 0x577ff3da), + STCP(0x5d22c11c, 0x57ce1917), STCP(0x5cd91140, 0x581c00b3), STCP(0x5c8f203b, 0x5869aa79), + STCP(0x5c44ee40, 0x58b71632), STCP(0x5bfa7b82, 0x590443a7), STCP(0x5bafc837, 0x595132a2), + STCP(0x5b64d492, 0x599de2ee), STCP(0x5b19a0c8, 0x59ea5454), STCP(0x5ace2d0f, 0x5a36869f), + STCP(0x5a82799a, 0x5a82799a), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineTable360[] = { +# else +const PWord16 SineTable360[] = { +# endif + STCP(0x7fffffff, 0x00000000), STCP(0x7fffb025, 0x008efa17), STCP(0x7ffec095, 0x011df37c), + STCP(0x7ffd3153, 0x01aceb7c), STCP(0x7ffb025f, 0x023be165), STCP(0x7ff833bc, 0x02cad485), + STCP(0x7ff4c56e, 0x0359c428), STCP(0x7ff0b779, 0x03e8af9e), STCP(0x7fec09e2, 0x04779632), + STCP(0x7fe6bcaf, 0x05067734), STCP(0x7fe0cfe6, 0x059551f1), STCP(0x7fda4390, 0x062425b6), + STCP(0x7fd317b3, 0x06b2f1d2), STCP(0x7fcb4c5a, 0x0741b592), STCP(0x7fc2e18d, 0x07d07044), + STCP(0x7fb9d758, 0x085f2136), STCP(0x7fb02dc5, 0x08edc7b7), STCP(0x7fa5e4e0, 0x097c6313), + STCP(0x7f9afcb8, 0x0a0af299), STCP(0x7f8f7558, 0x0a997597), STCP(0x7f834ecf, 0x0b27eb5c), + STCP(0x7f76892e, 0x0bb65336), STCP(0x7f692482, 0x0c44ac72), STCP(0x7f5b20de, 0x0cd2f660), + STCP(0x7f4c7e53, 0x0d61304e), STCP(0x7f3d3cf3, 0x0def5989), STCP(0x7f2d5cd0, 0x0e7d7162), + STCP(0x7f1cde00, 0x0f0b7727), STCP(0x7f0bc096, 0x0f996a26), STCP(0x7efa04a7, 0x102749ae), + STCP(0x7ee7aa4b, 0x10b5150f), STCP(0x7ed4b197, 0x1142cb98), STCP(0x7ec11aa4, 0x11d06c96), + STCP(0x7eace589, 0x125df75b), STCP(0x7e981261, 0x12eb6b35), STCP(0x7e82a145, 0x1378c774), + STCP(0x7e6c9250, 0x14060b68), STCP(0x7e55e59d, 0x1493365f), STCP(0x7e3e9b49, 0x152047ab), + STCP(0x7e26b370, 0x15ad3e9a), STCP(0x7e0e2e31, 0x163a1a7e), STCP(0x7df50baa, 0x16c6daa6), + STCP(0x7ddb4bfb, 0x17537e63), STCP(0x7dc0ef43, 0x17e00505), STCP(0x7da5f5a4, 0x186c6ddd), + STCP(0x7d8a5f3f, 0x18f8b83c), STCP(0x7d6e2c36, 0x1984e373), STCP(0x7d515cae, 0x1a10eed2), + STCP(0x7d33f0c9, 0x1a9cd9ac), STCP(0x7d15e8ac, 0x1b28a351), STCP(0x7cf7447e, 0x1bb44b13), + STCP(0x7cd80464, 0x1c3fd045), STCP(0x7cb82884, 0x1ccb3237), STCP(0x7c97b108, 0x1d56703b), + STCP(0x7c769e17, 0x1de189a5), STCP(0x7c54efdb, 0x1e6c7dc7), STCP(0x7c32a67d, 0x1ef74bf3), + STCP(0x7c0fc229, 0x1f81f37b), STCP(0x7bec430a, 0x200c73b4), STCP(0x7bc8294c, 0x2096cbf0), + STCP(0x7ba3751c, 0x2120fb83), STCP(0x7b7e26a9, 0x21ab01c0), STCP(0x7b583e20, 0x2234ddfa), + STCP(0x7b31bbb1, 0x22be8f87), STCP(0x7b0a9f8d, 0x234815ba), STCP(0x7ae2e9e3, 0x23d16fe8), + STCP(0x7aba9ae5, 0x245a9d64), STCP(0x7a91b2c6, 0x24e39d85), STCP(0x7a6831b9, 0x256c6f9f), + STCP(0x7a3e17f1, 0x25f51307), STCP(0x7a1365a4, 0x267d8713), STCP(0x79e81b05, 0x2705cb19), + STCP(0x79bc384c, 0x278dde6e), STCP(0x798fbdaf, 0x2815c069), STCP(0x7962ab66, 0x289d7061), + STCP(0x793501a8, 0x2924edab), STCP(0x7906c0af, 0x29ac37a0), STCP(0x78d7e8b5, 0x2a334d95), + STCP(0x78a879f3, 0x2aba2ee3), STCP(0x787874a6, 0x2b40dae2), STCP(0x7847d908, 0x2bc750e9), + STCP(0x7816a758, 0x2c4d9050), STCP(0x77e4dfd1, 0x2cd39870), STCP(0x77b282b3, 0x2d5968a2), + STCP(0x777f903b, 0x2ddf003f), STCP(0x774c08aa, 0x2e645ea0), STCP(0x7717ec40, 0x2ee9831f), + STCP(0x76e33b3e, 0x2f6e6d15), STCP(0x76adf5e5, 0x2ff31bdd), STCP(0x76781c79, 0x30778ed2), + STCP(0x7641af3c, 0x30fbc54d), STCP(0x760aae72, 0x317fbeaa), STCP(0x75d31a60, 0x32037a45), + STCP(0x759af34b, 0x3286f778), STCP(0x75623979, 0x330a35a1), STCP(0x7528ed31, 0x338d341a), + STCP(0x74ef0ebb, 0x340ff242), STCP(0x74b49e5f, 0x34926f74), STCP(0x74799c65, 0x3514ab0d), + STCP(0x743e0917, 0x3596a46c), STCP(0x7401e4c0, 0x36185aee), STCP(0x73c52faa, 0x3699cdf1), + STCP(0x7387ea22, 0x371afcd4), STCP(0x734a1474, 0x379be6f6), STCP(0x730baeec, 0x381c8bb5), + STCP(0x72ccb9da, 0x389cea71), STCP(0x728d358b, 0x391d028b), STCP(0x724d224e, 0x399cd362), + STCP(0x720c8074, 0x3a1c5c56), STCP(0x71cb504d, 0x3a9b9cc9), STCP(0x7189922b, 0x3b1a941c), + STCP(0x7147465f, 0x3b9941b0), STCP(0x71046d3d, 0x3c17a4e8), STCP(0x70c10717, 0x3c95bd25), + STCP(0x707d1442, 0x3d1389cb), STCP(0x70389513, 0x3d910a3c), STCP(0x6ff389de, 0x3e0e3ddb), + STCP(0x6fadf2fb, 0x3e8b240e), STCP(0x6f67d0c0, 0x3f07bc37), STCP(0x6f212384, 0x3f8405bb), + STCP(0x6ed9eba1, 0x3fffffff), STCP(0x6e92296d, 0x407baa69), STCP(0x6e49dd44, 0x40f7045f), + STCP(0x6e01077f, 0x41720d45), STCP(0x6db7a879, 0x41ecc483), STCP(0x6d6dc08e, 0x42672980), + STCP(0x6d23501a, 0x42e13ba3), STCP(0x6cd85779, 0x435afa54), STCP(0x6c8cd70a, 0x43d464fa), + STCP(0x6c40cf2b, 0x444d7aff), STCP(0x6bf4403a, 0x44c63bca), STCP(0x6ba72a97, 0x453ea6c7), + STCP(0x6b598ea2, 0x45b6bb5d), STCP(0x6b0b6cbc, 0x462e78f8), STCP(0x6abcc546, 0x46a5df02), + STCP(0x6a6d98a3, 0x471cece6), STCP(0x6a1de736, 0x4793a210), STCP(0x69cdb161, 0x4809fdeb), + STCP(0x697cf789, 0x487fffe3), STCP(0x692bba13, 0x48f5a767), STCP(0x68d9f964, 0x496af3e1), + STCP(0x6887b5e1, 0x49dfe4c2), STCP(0x6834eff2, 0x4a547975), STCP(0x67e1a7ff, 0x4ac8b16b), + STCP(0x678dde6e, 0x4b3c8c11), STCP(0x673993a8, 0x4bb008d8), STCP(0x66e4c817, 0x4c23272f), + STCP(0x668f7c24, 0x4c95e687), STCP(0x6639b03a, 0x4d084651), STCP(0x65e364c3, 0x4d7a45fd), + STCP(0x658c9a2d, 0x4debe4fe), STCP(0x653550e1, 0x4e5d22c5), STCP(0x64dd894f, 0x4ecdfec6), + STCP(0x648543e3, 0x4f3e7874), STCP(0x642c810b, 0x4fae8f42), STCP(0x63d34136, 0x501e42a5), + STCP(0x637984d4, 0x508d9211), STCP(0x631f4c54, 0x50fc7cfa), STCP(0x62c49826, 0x516b02d8), + STCP(0x626968be, 0x51d92320), STCP(0x620dbe8a, 0x5246dd48), STCP(0x61b19a00, 0x52b430c8), + STCP(0x6154fb90, 0x53211d17), STCP(0x60f7e3b0, 0x538da1ae), STCP(0x609a52d2, 0x53f9be04), + STCP(0x603c496c, 0x54657194), STCP(0x5fddc7f3, 0x54d0bbd6), STCP(0x5f7ecedd, 0x553b9c45), + STCP(0x5f1f5ea0, 0x55a6125b), STCP(0x5ebf77b4, 0x56101d94), STCP(0x5e5f1a90, 0x5679bd6b), + STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5d9cff82, 0x574bb8e6), STCP(0x5d3b428b, 0x57b41383), + STCP(0x5cd91140, 0x581c00b3), STCP(0x5c766c1c, 0x58837ff3), STCP(0x5c13539a, 0x58ea90c3), + STCP(0x5bafc836, 0x595132a2), STCP(0x5b4bca6c, 0x59b7650f), STCP(0x5ae75ab8, 0x5a1d278c), + STCP(0x5a827999, 0x5a827999), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineTable320[] = { +# else +const PWord16 SineTable320[] = { +# endif + STCP(0x7fffffff, 0x00000000), STCP(0x7fff9aef, 0x00a0d951), STCP(0x7ffe6bbf, 0x0141b1a5), + STCP(0x7ffc726f, 0x01e287fc), STCP(0x7ff9af04, 0x02835b5a), STCP(0x7ff62182, 0x03242abf), + STCP(0x7ff1c9ef, 0x03c4f52f), STCP(0x7feca851, 0x0465b9aa), STCP(0x7fe6bcb0, 0x05067734), + STCP(0x7fe00716, 0x05a72ccf), STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd03e23, 0x06e87c3f), + STCP(0x7fc72ae2, 0x07891418), STCP(0x7fbd4dda, 0x0829a00c), STCP(0x7fb2a71b, 0x08ca1f1b), + STCP(0x7fa736b4, 0x096a9049), STCP(0x7f9afcb9, 0x0a0af299), STCP(0x7f8df93c, 0x0aab450d), + STCP(0x7f802c52, 0x0b4b86a8), STCP(0x7f719611, 0x0bebb66c), STCP(0x7f62368f, 0x0c8bd35e), + STCP(0x7f520de6, 0x0d2bdc80), STCP(0x7f411c2f, 0x0dcbd0d5), STCP(0x7f2f6183, 0x0e6baf61), + STCP(0x7f1cde01, 0x0f0b7727), STCP(0x7f0991c4, 0x0fab272b), STCP(0x7ef57cea, 0x104abe71), + STCP(0x7ee09f95, 0x10ea3bfd), STCP(0x7ecaf9e5, 0x11899ed3), STCP(0x7eb48bfb, 0x1228e5f8), + STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e85580c, 0x13671d3d), STCP(0x7e6c9251, 0x14060b68), + STCP(0x7e5304f2, 0x14a4d9f4), STCP(0x7e38b017, 0x154387e6), STCP(0x7e1d93ea, 0x15e21445), + STCP(0x7e01b096, 0x16807e15), STCP(0x7de50646, 0x171ec45c), STCP(0x7dc79529, 0x17bce621), + STCP(0x7da95d6c, 0x185ae269), STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d6a9ad5, 0x199666a0), + STCP(0x7d4a105d, 0x1a33ec9c), STCP(0x7d28c00c, 0x1ad14938), STCP(0x7d06aa16, 0x1b6e7b7a), + STCP(0x7ce3ceb2, 0x1c0b826a), STCP(0x7cc02e15, 0x1ca85d12), STCP(0x7c9bc87a, 0x1d450a78), + STCP(0x7c769e18, 0x1de189a6), STCP(0x7c50af2b, 0x1e7dd9a4), STCP(0x7c29fbee, 0x1f19f97b), + STCP(0x7c02849f, 0x1fb5e836), STCP(0x7bda497d, 0x2051a4dd), STCP(0x7bb14ac5, 0x20ed2e7b), + STCP(0x7b8788ba, 0x2188841a), STCP(0x7b5d039e, 0x2223a4c5), STCP(0x7b31bbb2, 0x22be8f87), + STCP(0x7b05b13d, 0x2359436c), STCP(0x7ad8e482, 0x23f3bf7e), STCP(0x7aab55ca, 0x248e02cb), + STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a4df380, 0x25c1db44), STCP(0x7a1e2082, 0x265b6e8a), + STCP(0x79ed8cad, 0x26f4c53e), STCP(0x79bc384d, 0x278dde6e), STCP(0x798a23b1, 0x2826b928), + STCP(0x79574f28, 0x28bf547b), STCP(0x7923bb01, 0x2957af74), STCP(0x78ef678f, 0x29efc925), + STCP(0x78ba5524, 0x2a87a09d), STCP(0x78848414, 0x2b1f34eb), STCP(0x784df4b3, 0x2bb68522), + STCP(0x7816a759, 0x2c4d9050), STCP(0x77de9c5b, 0x2ce45589), STCP(0x77a5d413, 0x2d7ad3de), + STCP(0x776c4edb, 0x2e110a62), STCP(0x77320d0d, 0x2ea6f827), STCP(0x76f70f05, 0x2f3c9c40), + STCP(0x76bb5521, 0x2fd1f5c1), STCP(0x767edfbe, 0x306703bf), STCP(0x7641af3d, 0x30fbc54d), + STCP(0x7603c3fd, 0x31903982), STCP(0x75c51e61, 0x32245f72), STCP(0x7585becb, 0x32b83634), + STCP(0x7545a5a0, 0x334bbcde), STCP(0x7504d345, 0x33def287), STCP(0x74c34820, 0x3471d647), + STCP(0x74810499, 0x35046736), STCP(0x743e0918, 0x3596a46c), STCP(0x73fa5607, 0x36288d03), + STCP(0x73b5ebd1, 0x36ba2014), STCP(0x7370cae2, 0x374b5cb9), STCP(0x732af3a7, 0x37dc420c), + STCP(0x72e4668f, 0x386ccf2a), STCP(0x729d2409, 0x38fd032d), STCP(0x72552c85, 0x398cdd32), + STCP(0x720c8075, 0x3a1c5c57), STCP(0x71c3204c, 0x3aab7fb7), STCP(0x71790c7e, 0x3b3a4672), + STCP(0x712e457f, 0x3bc8afa5), STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70969fca, 0x3ce465f3), + STCP(0x7049c203, 0x3d71b14d), STCP(0x6ffc32eb, 0x3dfe9ba1), STCP(0x6fadf2fc, 0x3e8b240e), + STCP(0x6f5f02b2, 0x3f1749b8), STCP(0x6f0f6289, 0x3fa30bc1), STCP(0x6ebf12ff, 0x402e694c), + STCP(0x6e6e1492, 0x40b9617d), STCP(0x6e1c67c4, 0x4143f379), STCP(0x6dca0d14, 0x41ce1e65), + STCP(0x6d770506, 0x4257e166), STCP(0x6d23501b, 0x42e13ba4), STCP(0x6cceeed8, 0x436a2c45), + STCP(0x6c79e1c2, 0x43f2b271), STCP(0x6c242960, 0x447acd50), STCP(0x6bcdc639, 0x45027c0c), + STCP(0x6b76b8d6, 0x4589bdcf), STCP(0x6b1f01c0, 0x461091c2), STCP(0x6ac6a180, 0x4696f710), + STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a13e7b8, 0x47a27271), STCP(0x69b98f48, 0x482786dc), + STCP(0x695e8fe5, 0x48ac2957), STCP(0x6902ea1d, 0x4930590f), STCP(0x68a69e81, 0x49b41533), + STCP(0x6849ada3, 0x4a375cf5), STCP(0x67ec1817, 0x4aba2f84), STCP(0x678dde6e, 0x4b3c8c12), + STCP(0x672f013f, 0x4bbe71d1), STCP(0x66cf8120, 0x4c3fdff4), STCP(0x666f5ea6, 0x4cc0d5ae), + STCP(0x660e9a6a, 0x4d415234), STCP(0x65ad3505, 0x4dc154bb), STCP(0x654b2f10, 0x4e40dc79), + STCP(0x64e88926, 0x4ebfe8a5), STCP(0x648543e4, 0x4f3e7875), STCP(0x64215fe5, 0x4fbc8b22), + STCP(0x63bcddc7, 0x503a1fe5), STCP(0x6357be2a, 0x50b735f8), STCP(0x62f201ac, 0x5133cc94), + STCP(0x628ba8ef, 0x51afe2f6), STCP(0x6224b495, 0x522b7859), STCP(0x61bd253f, 0x52a68bfb), + STCP(0x6154fb91, 0x53211d18), STCP(0x60ec3830, 0x539b2af0), STCP(0x6082dbc1, 0x5414b4c1), + STCP(0x6018e6eb, 0x548db9cb), STCP(0x5fae5a55, 0x55063951), STCP(0x5f4336a7, 0x557e3292), + STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e6b2ca8, 0x566c8f55), STCP(0x5dfe47ad, 0x56e2f15d), + STCP(0x5d90ce45, 0x5758ca31), STCP(0x5d22c11c, 0x57ce1917), STCP(0x5cb420e0, 0x5842dd54), + STCP(0x5c44ee40, 0x58b71632), STCP(0x5bd529eb, 0x592ac2f7), STCP(0x5b64d492, 0x599de2ee), + STCP(0x5af3eee6, 0x5a107561), STCP(0x5a82799a, 0x5a82799a), +}; + + +# ifdef ENABLE_HR_MODE +#ifdef CR8_G_ADD_75MS + const PWord32 SineTable720[] = { + STCP(0x7fffffff, 0x00000000), STCP(0x7fffec08, 0x00477d17), STCP(0x7fffb025, 0x008efa17), + STCP(0x7fff4c53, 0x00d676eb), STCP(0x7ffec095, 0x011df37c), STCP(0x7ffe0cea, 0x01656fb4), + STCP(0x7ffd3153, 0x01aceb7c), STCP(0x7ffc2dcf, 0x01f466bf), STCP(0x7ffb025f, 0x023be165), + STCP(0x7ff9af03, 0x02835b59), STCP(0x7ff833bc, 0x02cad485), STCP(0x7ff6908a, 0x03124cd1), + STCP(0x7ff4c56e, 0x0359c428), STCP(0x7ff2d268, 0x03a13a74), STCP(0x7ff0b779, 0x03e8af9e), + STCP(0x7fee74a1, 0x0430238f), STCP(0x7fec09e2, 0x04779632), STCP(0x7fe9773c, 0x04bf0771), + STCP(0x7fe6bcaf, 0x05067734), STCP(0x7fe3da3d, 0x054de566), STCP(0x7fe0cfe6, 0x059551f1), + STCP(0x7fdd9dac, 0x05dcbcbe), STCP(0x7fda4390, 0x062425b6), STCP(0x7fd6c192, 0x066b8cc5), + STCP(0x7fd317b3, 0x06b2f1d2), STCP(0x7fcf45f6, 0x06fa54c9), STCP(0x7fcb4c5a, 0x0741b592), + STCP(0x7fc72ae1, 0x07891418), STCP(0x7fc2e18d, 0x07d07044), STCP(0x7fbe705f, 0x0817ca01), + STCP(0x7fb9d758, 0x085f2136), STCP(0x7fb51679, 0x08a675d0), STCP(0x7fb02dc5, 0x08edc7b7), + STCP(0x7fab1d3c, 0x093516d4), STCP(0x7fa5e4e0, 0x097c6313), STCP(0x7fa084b4, 0x09c3ac5c), + STCP(0x7f9afcb8, 0x0a0af299), STCP(0x7f954cee, 0x0a5235b4), STCP(0x7f8f7558, 0x0a997597), + STCP(0x7f8975f8, 0x0ae0b22c), STCP(0x7f834ecf, 0x0b27eb5c), STCP(0x7f7cffe1, 0x0b6f2112), + STCP(0x7f76892e, 0x0bb65336), STCP(0x7f6feab8, 0x0bfd81b3), STCP(0x7f692482, 0x0c44ac72), + STCP(0x7f62368e, 0x0c8bd35e), STCP(0x7f5b20de, 0x0cd2f660), STCP(0x7f53e374, 0x0d1a1562), + STCP(0x7f4c7e53, 0x0d61304e), STCP(0x7f44f17c, 0x0da8470d), STCP(0x7f3d3cf3, 0x0def5989), + STCP(0x7f3560b8, 0x0e3667ad), STCP(0x7f2d5cd0, 0x0e7d7162), STCP(0x7f25313c, 0x0ec47692), + STCP(0x7f1cde00, 0x0f0b7727), STCP(0x7f14631c, 0x0f52730a), STCP(0x7f0bc096, 0x0f996a26), + STCP(0x7f02f66e, 0x0fe05c64), STCP(0x7efa04a7, 0x102749ae), STCP(0x7ef0eb45, 0x106e31ef), + STCP(0x7ee7aa4b, 0x10b5150f), STCP(0x7ede41ba, 0x10fbf2fa), STCP(0x7ed4b197, 0x1142cb98), + STCP(0x7ecaf9e4, 0x11899ed3), STCP(0x7ec11aa4, 0x11d06c96), STCP(0x7eb713da, 0x121734cb), + STCP(0x7eace589, 0x125df75b), STCP(0x7ea28fb5, 0x12a4b431), STCP(0x7e981261, 0x12eb6b35), + STCP(0x7e8d6d90, 0x13321c53), STCP(0x7e82a145, 0x1378c774), STCP(0x7e77ad84, 0x13bf6c82), + STCP(0x7e6c9250, 0x14060b68), STCP(0x7e614fac, 0x144ca40e), STCP(0x7e55e59d, 0x1493365f), + STCP(0x7e4a5425, 0x14d9c245), STCP(0x7e3e9b49, 0x152047ab), STCP(0x7e32bb0b, 0x1566c679), + STCP(0x7e26b370, 0x15ad3e9a), STCP(0x7e1a847b, 0x15f3aff8), STCP(0x7e0e2e31, 0x163a1a7e), + STCP(0x7e01b095, 0x16807e14), STCP(0x7df50baa, 0x16c6daa6), STCP(0x7de83f76, 0x170d301d), + STCP(0x7ddb4bfb, 0x17537e63), STCP(0x7dce313e, 0x1799c562), STCP(0x7dc0ef43, 0x17e00505), + STCP(0x7db3860e, 0x18263d35), STCP(0x7da5f5a4, 0x186c6ddd), STCP(0x7d983e08, 0x18b296e7), + STCP(0x7d8a5f3f, 0x18f8b83c), STCP(0x7d7c594d, 0x193ed1c8), STCP(0x7d6e2c36, 0x1984e373), + STCP(0x7d5fd800, 0x19caed28), STCP(0x7d515cae, 0x1a10eed2), STCP(0x7d42ba45, 0x1a56e85b), + STCP(0x7d33f0c9, 0x1a9cd9ac), STCP(0x7d25003f, 0x1ae2c2b0), STCP(0x7d15e8ac, 0x1b28a351), + STCP(0x7d06aa15, 0x1b6e7b7a), STCP(0x7cf7447e, 0x1bb44b13), STCP(0x7ce7b7ec, 0x1bfa1209), + STCP(0x7cd80464, 0x1c3fd045), STCP(0x7cc829ea, 0x1c8585b0), STCP(0x7cb82884, 0x1ccb3237), + STCP(0x7ca80037, 0x1d10d5c1), STCP(0x7c97b108, 0x1d56703b), STCP(0x7c873afb, 0x1d9c018f), + STCP(0x7c769e17, 0x1de189a5), STCP(0x7c65da60, 0x1e27086a), STCP(0x7c54efdb, 0x1e6c7dc7), + STCP(0x7c43de8d, 0x1eb1e9a6), STCP(0x7c32a67d, 0x1ef74bf3), STCP(0x7c2147af, 0x1f3ca496), + STCP(0x7c0fc229, 0x1f81f37b), STCP(0x7bfe15f0, 0x1fc7388d), STCP(0x7bec430a, 0x200c73b4), + STCP(0x7bda497c, 0x2051a4dd), STCP(0x7bc8294c, 0x2096cbf0), STCP(0x7bb5e27f, 0x20dbe8da), + STCP(0x7ba3751c, 0x2120fb83), STCP(0x7b90e128, 0x216603d7), STCP(0x7b7e26a9, 0x21ab01c0), + STCP(0x7b6b45a4, 0x21eff528), STCP(0x7b583e20, 0x2234ddfa), STCP(0x7b451022, 0x2279bc21), + STCP(0x7b31bbb1, 0x22be8f87), STCP(0x7b1e40d3, 0x23035817), STCP(0x7b0a9f8d, 0x234815ba), + STCP(0x7af6d7e5, 0x238cc85c), STCP(0x7ae2e9e3, 0x23d16fe8), STCP(0x7aced58b, 0x24160c47), + STCP(0x7aba9ae5, 0x245a9d64), STCP(0x7aa639f7, 0x249f232b), STCP(0x7a91b2c6, 0x24e39d85), + STCP(0x7a7d055a, 0x25280c5d), STCP(0x7a6831b9, 0x256c6f9f), STCP(0x7a5337e9, 0x25b0c734), + STCP(0x7a3e17f1, 0x25f51307), STCP(0x7a28d1d8, 0x26395303), STCP(0x7a1365a4, 0x267d8713), + STCP(0x79fdd35b, 0x26c1af21), STCP(0x79e81b05, 0x2705cb19), STCP(0x79d23ca9, 0x2749dae4), + STCP(0x79bc384c, 0x278dde6e), STCP(0x79a60df7, 0x27d1d5a2), STCP(0x798fbdaf, 0x2815c069), + STCP(0x7979477c, 0x28599eb0), STCP(0x7962ab66, 0x289d7061), STCP(0x794be972, 0x28e13566), + STCP(0x793501a8, 0x2924edab), STCP(0x791df40f, 0x2968991b), STCP(0x7906c0af, 0x29ac37a0), + STCP(0x78ef678e, 0x29efc925), STCP(0x78d7e8b5, 0x2a334d95), STCP(0x78c04429, 0x2a76c4dc), + STCP(0x78a879f3, 0x2aba2ee3), STCP(0x78908a1a, 0x2afd8b97), STCP(0x787874a6, 0x2b40dae2), + STCP(0x7860399d, 0x2b841caf), STCP(0x7847d908, 0x2bc750e9), STCP(0x782f52ef, 0x2c0a777b), + STCP(0x7816a758, 0x2c4d9050), STCP(0x77fdd64b, 0x2c909b54), STCP(0x77e4dfd1, 0x2cd39870), + STCP(0x77cbc3f1, 0x2d168792), STCP(0x77b282b3, 0x2d5968a2), STCP(0x77991c1e, 0x2d9c3b8e), + STCP(0x777f903b, 0x2ddf003f), STCP(0x7765df12, 0x2e21b6a2), STCP(0x774c08aa, 0x2e645ea0), + STCP(0x77320d0c, 0x2ea6f826), STCP(0x7717ec40, 0x2ee9831f), STCP(0x76fda64e, 0x2f2bff76), + STCP(0x76e33b3e, 0x2f6e6d15), STCP(0x76c8ab18, 0x2fb0cbea), STCP(0x76adf5e5, 0x2ff31bdd), + STCP(0x76931bae, 0x30355cdc), STCP(0x76781c79, 0x30778ed2), STCP(0x765cf850, 0x30b9b1a9), + STCP(0x7641af3c, 0x30fbc54d), STCP(0x76264144, 0x313dc9aa), STCP(0x760aae72, 0x317fbeaa), + STCP(0x75eef6ce, 0x31c1a43a), STCP(0x75d31a60, 0x32037a45), STCP(0x75b71931, 0x324540b6), + STCP(0x759af34b, 0x3286f778), STCP(0x757ea8b5, 0x32c89e78), STCP(0x75623979, 0x330a35a1), + STCP(0x7545a59f, 0x334bbcde), STCP(0x7528ed31, 0x338d341a), STCP(0x750c1038, 0x33ce9b42), + STCP(0x74ef0ebb, 0x340ff242), STCP(0x74d1e8c5, 0x34513903), STCP(0x74b49e5f, 0x34926f74), + STCP(0x74972f91, 0x34d3957e), STCP(0x74799c65, 0x3514ab0d), STCP(0x745be4e4, 0x3555b00e), + STCP(0x743e0917, 0x3596a46c), STCP(0x74200908, 0x35d78813), STCP(0x7401e4c0, 0x36185aee), + STCP(0x73e39c48, 0x36591cea), STCP(0x73c52faa, 0x3699cdf1), STCP(0x73a69ef0, 0x36da6df1), + STCP(0x7387ea22, 0x371afcd4), STCP(0x7369114b, 0x375b7a87), STCP(0x734a1474, 0x379be6f6), + STCP(0x732af3a6, 0x37dc420c), STCP(0x730baeec, 0x381c8bb5), STCP(0x72ec4650, 0x385cc3de), + STCP(0x72ccb9da, 0x389cea71), STCP(0x72ad0995, 0x38dcff5d), STCP(0x728d358b, 0x391d028b), + STCP(0x726d3dc5, 0x395cf3e9), STCP(0x724d224e, 0x399cd362), STCP(0x722ce330, 0x39dca0e2), + STCP(0x720c8074, 0x3a1c5c56), STCP(0x71ebfa25, 0x3a5c05aa), STCP(0x71cb504d, 0x3a9b9cc9), + STCP(0x71aa82f6, 0x3adb21a0), STCP(0x7189922b, 0x3b1a941c), STCP(0x71687df5, 0x3b59f428), + STCP(0x7147465f, 0x3b9941b0), STCP(0x7125eb74, 0x3bd87ca1), STCP(0x71046d3d, 0x3c17a4e8), + STCP(0x70e2cbc5, 0x3c56ba70), STCP(0x70c10717, 0x3c95bd25), STCP(0x709f1f3d, 0x3cd4acf5), + STCP(0x707d1442, 0x3d1389cb), STCP(0x705ae630, 0x3d525394), STCP(0x70389513, 0x3d910a3c), + STCP(0x701620f4, 0x3dcfadaf), STCP(0x6ff389de, 0x3e0e3ddb), STCP(0x6fd0cfdd, 0x3e4cbaac), + STCP(0x6fadf2fb, 0x3e8b240e), STCP(0x6f8af343, 0x3ec979ed), STCP(0x6f67d0c0, 0x3f07bc37), + STCP(0x6f448b7d, 0x3f45ead7), STCP(0x6f212384, 0x3f8405bb), STCP(0x6efd98e2, 0x3fc20ccf), + STCP(0x6ed9eba1, 0x3fffffff), STCP(0x6eb61bcb, 0x403ddf39), STCP(0x6e92296d, 0x407baa69), + STCP(0x6e6e1492, 0x40b9617c), STCP(0x6e49dd44, 0x40f7045f), STCP(0x6e25838f, 0x413492fd), + STCP(0x6e01077f, 0x41720d45), STCP(0x6ddc691e, 0x41af7323), STCP(0x6db7a879, 0x41ecc483), + STCP(0x6d92c59a, 0x422a0154), STCP(0x6d6dc08e, 0x42672980), STCP(0x6d48995f, 0x42a43cf7), + STCP(0x6d23501a, 0x42e13ba3), STCP(0x6cfde4c9, 0x431e2573), STCP(0x6cd85779, 0x435afa54), + STCP(0x6cb2a836, 0x4397ba32), STCP(0x6c8cd70a, 0x43d464fa), STCP(0x6c66e403, 0x4410fa9a), + STCP(0x6c40cf2b, 0x444d7aff), STCP(0x6c1a988f, 0x4489e615), STCP(0x6bf4403a, 0x44c63bca), + STCP(0x6bcdc639, 0x45027c0c), STCP(0x6ba72a97, 0x453ea6c7), STCP(0x6b806d61, 0x457abbe8), + STCP(0x6b598ea2, 0x45b6bb5d), STCP(0x6b328e67, 0x45f2a513), STCP(0x6b0b6cbc, 0x462e78f8), + STCP(0x6ae429ad, 0x466a36f9), STCP(0x6abcc546, 0x46a5df02), STCP(0x6a953f94, 0x46e17102), + STCP(0x6a6d98a3, 0x471cece6), STCP(0x6a45d080, 0x4758529c), STCP(0x6a1de736, 0x4793a210), + STCP(0x69f5dcd2, 0x47cedb30), STCP(0x69cdb161, 0x4809fdeb), STCP(0x69a564ef, 0x48450a2d), + STCP(0x697cf789, 0x487fffe3), STCP(0x6954693b, 0x48badefd), STCP(0x692bba13, 0x48f5a767), + STCP(0x6902ea1c, 0x4930590e), STCP(0x68d9f964, 0x496af3e1), STCP(0x68b0e7f6, 0x49a577ce), + STCP(0x6887b5e1, 0x49dfe4c2), STCP(0x685e6331, 0x4a1a3aaa), STCP(0x6834eff2, 0x4a547975), + STCP(0x680b5c33, 0x4a8ea111), STCP(0x67e1a7ff, 0x4ac8b16b), STCP(0x67b7d363, 0x4b02aa71), + STCP(0x678dde6e, 0x4b3c8c11), STCP(0x6763c92b, 0x4b76563a), STCP(0x673993a8, 0x4bb008d8), + STCP(0x670f3df2, 0x4be9a3db), STCP(0x66e4c817, 0x4c23272f), STCP(0x66ba3223, 0x4c5c92c4), + STCP(0x668f7c24, 0x4c95e687), STCP(0x6664a627, 0x4ccf2267), STCP(0x6639b03a, 0x4d084651), + STCP(0x660e9a69, 0x4d415233), STCP(0x65e364c3, 0x4d7a45fd), STCP(0x65b80f55, 0x4db3219c), + STCP(0x658c9a2d, 0x4debe4fe), STCP(0x65610557, 0x4e249011), STCP(0x653550e1, 0x4e5d22c5), + STCP(0x65097cda, 0x4e959d07), STCP(0x64dd894f, 0x4ecdfec6), STCP(0x64b1764d, 0x4f0647f0), + STCP(0x648543e3, 0x4f3e7874), STCP(0x6458f21d, 0x4f769040), STCP(0x642c810b, 0x4fae8f42), + STCP(0x63fff0b9, 0x4fe6756a), STCP(0x63d34136, 0x501e42a5), STCP(0x63a6728f, 0x5055f6e2), + STCP(0x637984d4, 0x508d9211), STCP(0x634c7810, 0x50c5141e), STCP(0x631f4c54, 0x50fc7cfa), + STCP(0x62f201ac, 0x5133cc94), STCP(0x62c49826, 0x516b02d8), STCP(0x62970fd2, 0x51a21fb7), + STCP(0x626968be, 0x51d92320), STCP(0x623ba2f6, 0x52100d01), STCP(0x620dbe8a, 0x5246dd48), + STCP(0x61dfbb89, 0x527d93e6), STCP(0x61b19a00, 0x52b430c8), STCP(0x618359fd, 0x52eab3de), + STCP(0x6154fb90, 0x53211d17), STCP(0x61267ec7, 0x53576c62), STCP(0x60f7e3b0, 0x538da1ae), + STCP(0x60c92a59, 0x53c3bce9), STCP(0x609a52d2, 0x53f9be04), STCP(0x606b5d28, 0x542fa4ed), + STCP(0x603c496c, 0x54657194), STCP(0x600d17aa, 0x549b23e7), STCP(0x5fddc7f3, 0x54d0bbd6), + STCP(0x5fae5a54, 0x55063950), STCP(0x5f7ecedd, 0x553b9c45), STCP(0x5f4f259c, 0x5570e4a3), + STCP(0x5f1f5ea0, 0x55a6125b), STCP(0x5eef79f8, 0x55db255b), STCP(0x5ebf77b4, 0x56101d94), + STCP(0x5e8f57e2, 0x5644faf4), STCP(0x5e5f1a90, 0x5679bd6b), STCP(0x5e2ebfcf, 0x56ae64e9), + STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5dcdb239, 0x571762b6), STCP(0x5d9cff82, 0x574bb8e6), + STCP(0x5d6c2f99, 0x577ff3da), STCP(0x5d3b428b, 0x57b41383), STCP(0x5d0a3868, 0x57e817d1), + STCP(0x5cd91140, 0x581c00b3), STCP(0x5ca7cd21, 0x584fce19), STCP(0x5c766c1c, 0x58837ff3), + STCP(0x5c44ee3f, 0x58b71631), STCP(0x5c13539a, 0x58ea90c3), STCP(0x5be19c3c, 0x591def98), + STCP(0x5bafc836, 0x595132a2), STCP(0x5b7dd796, 0x598459ce), STCP(0x5b4bca6c, 0x59b7650f), + STCP(0x5b19a0c7, 0x59ea5454), STCP(0x5ae75ab8, 0x5a1d278c), STCP(0x5ab4f84f, 0x5a4fdea9), + STCP(0x5a827999, 0x5a827999) +}; +#endif +const PWord32 SineTable960[] = { + STCP(0x7fffffff, 0x00000000), STCP(0x7ffff4c4, 0x00359dd2), STCP(0x7fffd314, 0x006b3b9b), + STCP(0x7fff9aee, 0x00a0d951), STCP(0x7fff4c53, 0x00d676eb), STCP(0x7ffee743, 0x010c1460), + STCP(0x7ffe6bbe, 0x0141b1a5), STCP(0x7ffdd9c3, 0x01774eb2), STCP(0x7ffd3153, 0x01aceb7c), + STCP(0x7ffc726e, 0x01e287fc), STCP(0x7ffb9d14, 0x02182427), STCP(0x7ffab146, 0x024dbff4), + STCP(0x7ff9af03, 0x02835b59), STCP(0x7ff8964c, 0x02b8f64e), STCP(0x7ff76720, 0x02ee90c8), + STCP(0x7ff62181, 0x03242abf), STCP(0x7ff4c56e, 0x0359c428), STCP(0x7ff352e7, 0x038f5cfb), + STCP(0x7ff1c9ee, 0x03c4f52e), STCP(0x7ff02a81, 0x03fa8cb8), STCP(0x7fee74a1, 0x0430238f), + STCP(0x7feca850, 0x0465b9aa), STCP(0x7feac58c, 0x049b4f00), STCP(0x7fe8cc56, 0x04d0e386), + STCP(0x7fe6bcaf, 0x05067734), STCP(0x7fe49697, 0x053c0a01), STCP(0x7fe25a0e, 0x05719be2), + STCP(0x7fe00715, 0x05a72ccf), STCP(0x7fdd9dac, 0x05dcbcbe), STCP(0x7fdb1dd4, 0x06124ba5), + STCP(0x7fd8878d, 0x0647d97c), STCP(0x7fd5dad7, 0x067d6639), STCP(0x7fd317b3, 0x06b2f1d2), + STCP(0x7fd03e22, 0x06e87c3f), STCP(0x7fcd4e23, 0x071e0575), STCP(0x7fca47b8, 0x07538d6b), + STCP(0x7fc72ae1, 0x07891418), STCP(0x7fc3f79f, 0x07be9973), STCP(0x7fc0adf1, 0x07f41d72), + STCP(0x7fbd4dd9, 0x0829a00b), STCP(0x7fb9d758, 0x085f2136), STCP(0x7fb64a6d, 0x0894a0e9), + STCP(0x7fb2a71a, 0x08ca1f1b), STCP(0x7faeed5e, 0x08ff9bc2), STCP(0x7fab1d3c, 0x093516d4), + STCP(0x7fa736b3, 0x096a9049), STCP(0x7fa339c4, 0x09a00817), STCP(0x7f9f2670, 0x09d57e35), + STCP(0x7f9afcb8, 0x0a0af299), STCP(0x7f96bc9b, 0x0a40653a), STCP(0x7f92661c, 0x0a75d60e), + STCP(0x7f8df93b, 0x0aab450d), STCP(0x7f8975f8, 0x0ae0b22c), STCP(0x7f84dc54, 0x0b161d63), + STCP(0x7f802c51, 0x0b4b86a8), STCP(0x7f7b65ee, 0x0b80edf1), STCP(0x7f76892e, 0x0bb65336), + STCP(0x7f719610, 0x0bebb66c), STCP(0x7f6c8c95, 0x0c21178c), STCP(0x7f676cbf, 0x0c56768a), + STCP(0x7f62368e, 0x0c8bd35e), STCP(0x7f5cea04, 0x0cc12dff), STCP(0x7f578720, 0x0cf68662), + STCP(0x7f520de5, 0x0d2bdc80), STCP(0x7f4c7e53, 0x0d61304e), STCP(0x7f46d86b, 0x0d9681c2), + STCP(0x7f411c2e, 0x0dcbd0d5), STCP(0x7f3b499c, 0x0e011d7c), STCP(0x7f3560b8, 0x0e3667ad), + STCP(0x7f2f6182, 0x0e6baf61), STCP(0x7f294bfc, 0x0ea0f48c), STCP(0x7f232025, 0x0ed63727), + STCP(0x7f1cde00, 0x0f0b7727), STCP(0x7f16858d, 0x0f40b483), STCP(0x7f1016cd, 0x0f75ef32), + STCP(0x7f0991c3, 0x0fab272b), STCP(0x7f02f66e, 0x0fe05c64), STCP(0x7efc44cf, 0x10158ed4), + STCP(0x7ef57cea, 0x104abe71), STCP(0x7eee9ebd, 0x107feb33), STCP(0x7ee7aa4b, 0x10b5150f), + STCP(0x7ee09f94, 0x10ea3bfd), STCP(0x7ed97e9b, 0x111f5ff3), STCP(0x7ed24760, 0x115480e9), + STCP(0x7ecaf9e4, 0x11899ed3), STCP(0x7ec39629, 0x11beb9aa), STCP(0x7ebc1c30, 0x11f3d164), + STCP(0x7eb48bfa, 0x1228e5f7), STCP(0x7eace589, 0x125df75b), STCP(0x7ea528df, 0x12930586), + STCP(0x7e9d55fb, 0x12c8106e), STCP(0x7e956ce0, 0x12fd180b), STCP(0x7e8d6d90, 0x13321c53), + STCP(0x7e85580b, 0x13671d3d), STCP(0x7e7d2c53, 0x139c1abf), STCP(0x7e74ea69, 0x13d114d0), + STCP(0x7e6c9250, 0x14060b68), STCP(0x7e642407, 0x143afe7b), STCP(0x7e5b9f92, 0x146fee02), + STCP(0x7e5304f1, 0x14a4d9f3), STCP(0x7e4a5425, 0x14d9c245), STCP(0x7e418d31, 0x150ea6ef), + STCP(0x7e38b016, 0x154387e6), STCP(0x7e2fbcd5, 0x15786522), STCP(0x7e26b370, 0x15ad3e9a), + STCP(0x7e1d93e9, 0x15e21444), STCP(0x7e145e41, 0x1616e618), STCP(0x7e0b1279, 0x164bb40b), + STCP(0x7e01b095, 0x16807e14), STCP(0x7df83894, 0x16b5442b), STCP(0x7deeaa79, 0x16ea0646), + STCP(0x7de50645, 0x171ec45c), STCP(0x7ddb4bfb, 0x17537e63), STCP(0x7dd17b9b, 0x17883452), + STCP(0x7dc79528, 0x17bce621), STCP(0x7dbd98a3, 0x17f193c5), STCP(0x7db3860e, 0x18263d35), + STCP(0x7da95d6b, 0x185ae269), STCP(0x7d9f1ebc, 0x188f8357), STCP(0x7d94ca02, 0x18c41ff6), + STCP(0x7d8a5f3f, 0x18f8b83c), STCP(0x7d7fde75, 0x192d4c21), STCP(0x7d7547a6, 0x1961db9b), + STCP(0x7d6a9ad4, 0x199666a0), STCP(0x7d5fd800, 0x19caed28), STCP(0x7d54ff2d, 0x19ff6f2a), + STCP(0x7d4a105c, 0x1a33ec9c), STCP(0x7d3f0b8f, 0x1a686575), STCP(0x7d33f0c9, 0x1a9cd9ac), + STCP(0x7d28c00b, 0x1ad14938), STCP(0x7d1d7957, 0x1b05b40e), STCP(0x7d121caf, 0x1b3a1a27), + STCP(0x7d06aa15, 0x1b6e7b7a), STCP(0x7cfb218b, 0x1ba2d7fc), STCP(0x7cef8314, 0x1bd72fa4), + STCP(0x7ce3ceb1, 0x1c0b826a), STCP(0x7cd80464, 0x1c3fd045), STCP(0x7ccc242f, 0x1c74192a), + STCP(0x7cc02e14, 0x1ca85d12), STCP(0x7cb42216, 0x1cdc9bf2), STCP(0x7ca80037, 0x1d10d5c1), + STCP(0x7c9bc879, 0x1d450a78), STCP(0x7c8f7add, 0x1d793a0b), STCP(0x7c831766, 0x1dad6473), + STCP(0x7c769e17, 0x1de189a5), STCP(0x7c6a0ef1, 0x1e15a99a), STCP(0x7c5d69f6, 0x1e49c447), + STCP(0x7c50af2a, 0x1e7dd9a3), STCP(0x7c43de8d, 0x1eb1e9a6), STCP(0x7c36f823, 0x1ee5f447), + STCP(0x7c29fbed, 0x1f19f97b), STCP(0x7c1ce9ee, 0x1f4df93a), STCP(0x7c0fc229, 0x1f81f37b), + STCP(0x7c02849f, 0x1fb5e835), STCP(0x7bf53152, 0x1fe9d75f), STCP(0x7be7c846, 0x201dc0ef), + STCP(0x7bda497c, 0x2051a4dd), STCP(0x7bccb4f7, 0x2085831e), STCP(0x7bbf0ab9, 0x20b95bac), + STCP(0x7bb14ac4, 0x20ed2e7b), STCP(0x7ba3751c, 0x2120fb83), STCP(0x7b9589c2, 0x2154c2bb), + STCP(0x7b8788b9, 0x2188841a), STCP(0x7b797204, 0x21bc3f97), STCP(0x7b6b45a4, 0x21eff528), + STCP(0x7b5d039d, 0x2223a4c5), STCP(0x7b4eabf0, 0x22574e65), STCP(0x7b403ea1, 0x228af1fe), + STCP(0x7b31bbb1, 0x22be8f87), STCP(0x7b232324, 0x22f226f8), STCP(0x7b1474fc, 0x2325b847), + STCP(0x7b05b13c, 0x2359436c), STCP(0x7af6d7e5, 0x238cc85c), STCP(0x7ae7e8fb, 0x23c04710), + STCP(0x7ad8e481, 0x23f3bf7e), STCP(0x7ac9ca79, 0x2427319d), STCP(0x7aba9ae5, 0x245a9d64), + STCP(0x7aab55c9, 0x248e02ca), STCP(0x7a9bfb26, 0x24c161c7), STCP(0x7a8c8b00, 0x24f4ba50), + STCP(0x7a7d055a, 0x25280c5d), STCP(0x7a6d6a36, 0x255b57e6), STCP(0x7a5db997, 0x258e9ce0), + STCP(0x7a4df37f, 0x25c1db43), STCP(0x7a3e17f1, 0x25f51307), STCP(0x7a2e26f1, 0x26284421), + STCP(0x7a1e2081, 0x265b6e8a), STCP(0x7a0e04a3, 0x268e9238), STCP(0x79fdd35b, 0x26c1af21), + STCP(0x79ed8cac, 0x26f4c53e), STCP(0x79dd3097, 0x2727d485), STCP(0x79ccbf21, 0x275adcee), + STCP(0x79bc384c, 0x278dde6e), STCP(0x79ab9c1b, 0x27c0d8fe), STCP(0x799aea91, 0x27f3cc94), + STCP(0x798a23b0, 0x2826b928), STCP(0x7979477c, 0x28599eb0), STCP(0x796855f8, 0x288c7d24), + STCP(0x79574f27, 0x28bf547a), STCP(0x7946330b, 0x28f224aa), STCP(0x793501a8, 0x2924edab), + STCP(0x7923bb00, 0x2957af74), STCP(0x79125f18, 0x298a69fc), STCP(0x7900edf1, 0x29bd1d3a), + STCP(0x78ef678e, 0x29efc925), STCP(0x78ddcbf4, 0x2a226db4), STCP(0x78cc1b25, 0x2a550adf), + STCP(0x78ba5523, 0x2a87a09c), STCP(0x78a879f3, 0x2aba2ee3), STCP(0x78968997, 0x2aecb5ab), + STCP(0x78848413, 0x2b1f34eb), STCP(0x78726969, 0x2b51ac9a), STCP(0x7860399d, 0x2b841caf), + STCP(0x784df4b2, 0x2bb68521), STCP(0x783b9aac, 0x2be8e5e8), STCP(0x78292b8c, 0x2c1b3efb), + STCP(0x7816a758, 0x2c4d9050), STCP(0x78040e11, 0x2c7fd9df), STCP(0x77f15fbb, 0x2cb21ba0), + STCP(0x77de9c5a, 0x2ce45589), STCP(0x77cbc3f1, 0x2d168792), STCP(0x77b8d683, 0x2d48b1b1), + STCP(0x77a5d413, 0x2d7ad3de), STCP(0x7792bca4, 0x2dacee10), STCP(0x777f903b, 0x2ddf003f), + STCP(0x776c4eda, 0x2e110a62), STCP(0x7758f885, 0x2e430c6f), STCP(0x77458d3f, 0x2e75065e), + STCP(0x77320d0c, 0x2ea6f826), STCP(0x771e77ef, 0x2ed8e1bf), STCP(0x770acdeb, 0x2f0ac320), + STCP(0x76f70f04, 0x2f3c9c3f), STCP(0x76e33b3e, 0x2f6e6d15), STCP(0x76cf529b, 0x2fa03599), + STCP(0x76bb5520, 0x2fd1f5c1), STCP(0x76a742d0, 0x3003ad85), STCP(0x76931bae, 0x30355cdc), + STCP(0x767edfbd, 0x306703be), STCP(0x766a8f03, 0x3098a222), STCP(0x76562981, 0x30ca37ff), + STCP(0x7641af3c, 0x30fbc54d), STCP(0x762d2037, 0x312d4a02), STCP(0x76187c76, 0x315ec617), + STCP(0x7603c3fc, 0x31903982), STCP(0x75eef6ce, 0x31c1a43a), STCP(0x75da14ee, 0x31f30638), + STCP(0x75c51e60, 0x32245f72), STCP(0x75b01329, 0x3255afe0), STCP(0x759af34b, 0x3286f778), + STCP(0x7585beca, 0x32b83634), STCP(0x757075ab, 0x32e96c09), STCP(0x755b17f1, 0x331a98ef), + STCP(0x7545a59f, 0x334bbcde), STCP(0x75301eba, 0x337cd7cc), STCP(0x751a8345, 0x33ade9b2), + STCP(0x7504d344, 0x33def287), STCP(0x74ef0ebb, 0x340ff242), STCP(0x74d935ad, 0x3440e8da), + STCP(0x74c3481f, 0x3471d647), STCP(0x74ad4614, 0x34a2ba80), STCP(0x74972f91, 0x34d3957e), + STCP(0x74810498, 0x35046736), STCP(0x746ac52e, 0x35352fa1), STCP(0x74547157, 0x3565eeb6), + STCP(0x743e0917, 0x3596a46c), STCP(0x74278c71, 0x35c750bb), STCP(0x7410fb6a, 0x35f7f39b), + STCP(0x73fa5606, 0x36288d03), STCP(0x73e39c48, 0x36591cea), STCP(0x73ccce35, 0x3689a347), + STCP(0x73b5ebd0, 0x36ba2013), STCP(0x739ef51e, 0x36ea9345), STCP(0x7387ea22, 0x371afcd4), + STCP(0x7370cae1, 0x374b5cb8), STCP(0x7359975f, 0x377bb2e8), STCP(0x73424f9f, 0x37abff5c), + STCP(0x732af3a6, 0x37dc420c), STCP(0x73138379, 0x380c7aee), STCP(0x72fbff1a, 0x383ca9fb), + STCP(0x72e4668e, 0x386ccf29), STCP(0x72ccb9da, 0x389cea71), STCP(0x72b4f901, 0x38ccfbcb), + STCP(0x729d2408, 0x38fd032d), STCP(0x72853af2, 0x392d008f), STCP(0x726d3dc5, 0x395cf3e9), + STCP(0x72552c84, 0x398cdd32), STCP(0x723d0733, 0x39bcbc62), STCP(0x7224cdd7, 0x39ec9171), + STCP(0x720c8074, 0x3a1c5c56), STCP(0x71f41f0e, 0x3a4c1d09), STCP(0x71dba9aa, 0x3a7bd381), + STCP(0x71c3204b, 0x3aab7fb6), STCP(0x71aa82f6, 0x3adb21a0), STCP(0x7191d1b0, 0x3b0ab937), + STCP(0x71790c7d, 0x3b3a4671), STCP(0x71603360, 0x3b69c947), STCP(0x7147465f, 0x3b9941b0), + STCP(0x712e457e, 0x3bc8afa4), STCP(0x711530c1, 0x3bf8131b), STCP(0x70fc082d, 0x3c276c0c), + STCP(0x70e2cbc5, 0x3c56ba70), STCP(0x70c97b8f, 0x3c85fe3c), STCP(0x70b0178f, 0x3cb5376b), + STCP(0x70969fc9, 0x3ce465f2), STCP(0x707d1442, 0x3d1389cb), STCP(0x706374fe, 0x3d42a2ec), + STCP(0x7049c202, 0x3d71b14d), STCP(0x702ffb53, 0x3da0b4e6), STCP(0x701620f4, 0x3dcfadaf), + STCP(0x6ffc32ea, 0x3dfe9ba0), STCP(0x6fe2313b, 0x3e2d7eb0), STCP(0x6fc81be9, 0x3e5c56d8), + STCP(0x6fadf2fb, 0x3e8b240e), STCP(0x6f93b675, 0x3eb9e64b), STCP(0x6f79665a, 0x3ee89d86), + STCP(0x6f5f02b1, 0x3f1749b7), STCP(0x6f448b7d, 0x3f45ead7), STCP(0x6f2a00c3, 0x3f7480dd), + STCP(0x6f0f6288, 0x3fa30bc0), STCP(0x6ef4b0d0, 0x3fd18b79), STCP(0x6ed9eba1, 0x3fffffff), + STCP(0x6ebf12fe, 0x402e694b), STCP(0x6ea426ed, 0x405cc754), STCP(0x6e892772, 0x408b1a12), + STCP(0x6e6e1492, 0x40b9617c), STCP(0x6e52ee51, 0x40e79d8c), STCP(0x6e37b4b6, 0x4115ce38), + STCP(0x6e1c67c3, 0x4143f378), STCP(0x6e01077f, 0x41720d45), STCP(0x6de593ed, 0x41a01b96), + STCP(0x6dca0d14, 0x41ce1e64), STCP(0x6dae72f6, 0x41fc15a6), STCP(0x6d92c59a, 0x422a0154), + STCP(0x6d770505, 0x4257e166), STCP(0x6d5b313a, 0x4285b5d4), STCP(0x6d3f4a3f, 0x42b37e95), + STCP(0x6d23501a, 0x42e13ba3), STCP(0x6d0742ce, 0x430eecf5), STCP(0x6ceb2260, 0x433c9283), + STCP(0x6cceeed7, 0x436a2c44), STCP(0x6cb2a836, 0x4397ba32), STCP(0x6c964e82, 0x43c53c43), + STCP(0x6c79e1c1, 0x43f2b270), STCP(0x6c5d61f8, 0x44201cb2), STCP(0x6c40cf2b, 0x444d7aff), + STCP(0x6c24295f, 0x447acd50), STCP(0x6c07709b, 0x44a8139d), STCP(0x6beaa4e1, 0x44d54dde), + STCP(0x6bcdc639, 0x45027c0c), STCP(0x6bb0d4a6, 0x452f9e1e), STCP(0x6b93d02d, 0x455cb40c), + STCP(0x6b76b8d5, 0x4589bdce), STCP(0x6b598ea2, 0x45b6bb5d), STCP(0x6b3c5199, 0x45e3acb1), + STCP(0x6b1f01bf, 0x461091c1), STCP(0x6b019f19, 0x463d6a86), STCP(0x6ae429ad, 0x466a36f9), + STCP(0x6ac6a180, 0x4696f710), STCP(0x6aa90696, 0x46c3aac5), STCP(0x6a8b58f6, 0x46f0520f), + STCP(0x6a6d98a3, 0x471cece6), STCP(0x6a4fc5a5, 0x47497b44), STCP(0x6a31dfff, 0x4775fd1f), + STCP(0x6a13e7b7, 0x47a27270), STCP(0x69f5dcd2, 0x47cedb30), STCP(0x69d7bf56, 0x47fb3757), + STCP(0x69b98f47, 0x482786dc), STCP(0x699b4cac, 0x4853c9b8), STCP(0x697cf789, 0x487fffe3), + STCP(0x695e8fe4, 0x48ac2956), STCP(0x694015c2, 0x48d84609), STCP(0x69218928, 0x490455f3), + STCP(0x6902ea1c, 0x4930590e), STCP(0x68e438a3, 0x495c4f51), STCP(0x68c574c3, 0x498838b6), + STCP(0x68a69e80, 0x49b41533), STCP(0x6887b5e1, 0x49dfe4c2), STCP(0x6868baeb, 0x4a0ba75a), + STCP(0x6849ada3, 0x4a375cf4), STCP(0x682a8e0e, 0x4a630589), STCP(0x680b5c33, 0x4a8ea111), + STCP(0x67ec1816, 0x4aba2f83), STCP(0x67ccc1bd, 0x4ae5b0d9), STCP(0x67ad592e, 0x4b11250b), + STCP(0x678dde6e, 0x4b3c8c11), STCP(0x676e5182, 0x4b67e5e4), STCP(0x674eb270, 0x4b93327b), + STCP(0x672f013f, 0x4bbe71d0), STCP(0x670f3df2, 0x4be9a3db), STCP(0x66ef6890, 0x4c14c894), + STCP(0x66cf811f, 0x4c3fdff3), STCP(0x66af87a4, 0x4c6ae9f1), STCP(0x668f7c24, 0x4c95e687), + STCP(0x666f5ea5, 0x4cc0d5ad), STCP(0x664f2f2e, 0x4cebb75c), STCP(0x662eedc2, 0x4d168b8b), + STCP(0x660e9a69, 0x4d415233), STCP(0x65ee3528, 0x4d6c0b4e), STCP(0x65cdbe05, 0x4d96b6d3), + STCP(0x65ad3504, 0x4dc154bb), STCP(0x658c9a2d, 0x4debe4fe), STCP(0x656bed84, 0x4e166795), + STCP(0x654b2f0f, 0x4e40dc78), STCP(0x652a5ed5, 0x4e6b43a1), STCP(0x65097cda, 0x4e959d07), + STCP(0x64e88925, 0x4ebfe8a4), STCP(0x64c783bc, 0x4eea266f), STCP(0x64a66ca4, 0x4f145662), + STCP(0x648543e3, 0x4f3e7874), STCP(0x6464097e, 0x4f688c9f), STCP(0x6442bd7d, 0x4f9292db), + STCP(0x64215fe4, 0x4fbc8b21), STCP(0x63fff0b9, 0x4fe6756a), STCP(0x63de7003, 0x501051ad), + STCP(0x63bcddc6, 0x503a1fe4), STCP(0x639b3a0a, 0x5063e008), STCP(0x637984d4, 0x508d9211), + STCP(0x6357be29, 0x50b735f7), STCP(0x6335e610, 0x50e0cbb4), STCP(0x6313fc8f, 0x510a5340), + STCP(0x62f201ac, 0x5133cc94), STCP(0x62cff56c, 0x515d37a8), STCP(0x62add7d5, 0x51869476), + STCP(0x628ba8ef, 0x51afe2f5), STCP(0x626968be, 0x51d92320), STCP(0x62471748, 0x520254ee), + STCP(0x6224b494, 0x522b7859), STCP(0x620240a8, 0x52548d58), STCP(0x61dfbb89, 0x527d93e6), + STCP(0x61bd253e, 0x52a68bfa), STCP(0x619a7dcd, 0x52cf758e), STCP(0x6177c53c, 0x52f8509a), + STCP(0x6154fb90, 0x53211d17), STCP(0x613220d1, 0x5349daff), STCP(0x610f3504, 0x53728a49), + STCP(0x60ec382f, 0x539b2aef), STCP(0x60c92a59, 0x53c3bce9), STCP(0x60a60b87, 0x53ec4032), + STCP(0x6082dbc0, 0x5414b4c0), STCP(0x605f9b0b, 0x543d1a8e), STCP(0x603c496c, 0x54657194), + STCP(0x6018e6ea, 0x548db9cb), STCP(0x5ff5738c, 0x54b5f32c), STCP(0x5fd1ef58, 0x54de1db0), + STCP(0x5fae5a54, 0x55063950), STCP(0x5f8ab486, 0x552e4605), STCP(0x5f66fdf4, 0x555643c8), + STCP(0x5f4336a6, 0x557e3291), STCP(0x5f1f5ea0, 0x55a6125b), STCP(0x5efb75ea, 0x55cde31d), + STCP(0x5ed77c89, 0x55f5a4d2), STCP(0x5eb37284, 0x561d5771), STCP(0x5e8f57e2, 0x5644faf4), + STCP(0x5e6b2ca8, 0x566c8f54), STCP(0x5e46f0dc, 0x5694148a), STCP(0x5e22a487, 0x56bb8a8f), + STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5dd9da55, 0x570a48eb), STCP(0x5db55c85, 0x57319134), + STCP(0x5d90ce44, 0x5758ca31), STCP(0x5d6c2f99, 0x577ff3da), STCP(0x5d478089, 0x57a70e29), + STCP(0x5d22c11b, 0x57ce1916), STCP(0x5cfdf156, 0x57f5149c), STCP(0x5cd91140, 0x581c00b3), + STCP(0x5cb420df, 0x5842dd54), STCP(0x5c8f203a, 0x5869aa78), STCP(0x5c6a0f58, 0x5890681a), + STCP(0x5c44ee3f, 0x58b71631), STCP(0x5c1fbcf5, 0x58ddb4b7), STCP(0x5bfa7b81, 0x590443a6), + STCP(0x5bd529ea, 0x592ac2f6), STCP(0x5bafc836, 0x595132a2), STCP(0x5b8a566b, 0x597792a1), + STCP(0x5b64d491, 0x599de2ed), STCP(0x5b3f42ae, 0x59c42380), STCP(0x5b19a0c7, 0x59ea5454), + STCP(0x5af3eee5, 0x5a107560), STCP(0x5ace2d0e, 0x5a36869f), STCP(0x5aa85b48, 0x5a5c8809), + STCP(0x5a827999, 0x5a827999), +}; +# endif + +/* + Sine windows + */ + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow20[10] = { +# else +const PWord16 SineWindow20[10] = { +# endif + WTCP(0x7fe6bcaf, 0x5067734), WTCP(0x7f1cde00, 0xf0b7727), WTCP(0x7d8a5f3f, 0x18f8b83c), + WTCP(0x7b31bbb1, 0x22be8f87), WTCP(0x7816a758, 0x2c4d9050), WTCP(0x743e0917, 0x3596a46c), + WTCP(0x6fadf2fb, 0x3e8b240e), WTCP(0x6a6d98a3, 0x471cece6), WTCP(0x648543e3, 0x4f3e7874), + WTCP(0x5dfe47ad, 0x56e2f15d), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow40[20] = { +# else +const PWord16 SineWindow40[20] = { +# endif + WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7f62368f, 0x0c8bd35e), + WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7e01b096, 0x16807e15), WTCP(0x7d06aa16, 0x1b6e7b7a), + WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x78ef678f, 0x29efc925), + WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x732af3a7, 0x37dc420c), + WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6bcdc639, 0x45027c0c), + WTCP(0x6902ea1d, 0x4930590f), WTCP(0x660e9a6a, 0x4d415234), WTCP(0x62f201ac, 0x5133cc94), + WTCP(0x5fae5a55, 0x55063951), WTCP(0x5c44ee40, 0x58b71632), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow60[30] = { +# else +const PWord16 SineWindow60[30] = { +# endif + WTCP(0x7ffd3153, 0x1aceb7c), WTCP(0x7fe6bcaf, 0x5067734), WTCP(0x7fb9d758, 0x85f2136), + WTCP(0x7f76892e, 0xbb65336), WTCP(0x7f1cde00, 0xf0b7727), WTCP(0x7eace589, 0x125df75b), + WTCP(0x7e26b370, 0x15ad3e9a), WTCP(0x7d8a5f3f, 0x18f8b83c), WTCP(0x7cd80464, 0x1c3fd045), + WTCP(0x7c0fc229, 0x1f81f37b), WTCP(0x7b31bbb1, 0x22be8f87), WTCP(0x7a3e17f1, 0x25f51307), + WTCP(0x793501a8, 0x2924edab), WTCP(0x7816a758, 0x2c4d9050), WTCP(0x76e33b3e, 0x2f6e6d15), + WTCP(0x759af34b, 0x3286f778), WTCP(0x743e0917, 0x3596a46c), WTCP(0x72ccb9da, 0x389cea71), + WTCP(0x7147465f, 0x3b9941b0), WTCP(0x6fadf2fb, 0x3e8b240e), WTCP(0x6e01077f, 0x41720d45), + WTCP(0x6c40cf2b, 0x444d7aff), WTCP(0x6a6d98a3, 0x471cece6), WTCP(0x6887b5e1, 0x49dfe4c2), + WTCP(0x668f7c24, 0x4c95e687), WTCP(0x648543e3, 0x4f3e7874), WTCP(0x626968be, 0x51d92320), + WTCP(0x603c496c, 0x54657194), WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5bafc836, 0x595132a2), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow80[40] = { +# else +const PWord16 SineWindow80[40] = { +# endif + WTCP(0x7ffe6bbf, 0x0141b1a5), WTCP(0x7ff1c9ef, 0x03c4f52f), WTCP(0x7fd8878e, 0x0647d97c), + WTCP(0x7fb2a71b, 0x08ca1f1b), WTCP(0x7f802c52, 0x0b4b86a8), WTCP(0x7f411c2f, 0x0dcbd0d5), + WTCP(0x7ef57cea, 0x104abe71), WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7e38b017, 0x154387e6), + WTCP(0x7dc79529, 0x17bce621), WTCP(0x7d4a105d, 0x1a33ec9c), WTCP(0x7cc02e15, 0x1ca85d12), + WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7b8788ba, 0x2188841a), WTCP(0x7ad8e482, 0x23f3bf7e), + WTCP(0x7a1e2082, 0x265b6e8a), WTCP(0x79574f28, 0x28bf547b), WTCP(0x78848414, 0x2b1f34eb), + WTCP(0x77a5d413, 0x2d7ad3de), WTCP(0x76bb5521, 0x2fd1f5c1), WTCP(0x75c51e61, 0x32245f72), + WTCP(0x74c34820, 0x3471d647), WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x729d2409, 0x38fd032d), + WTCP(0x71790c7e, 0x3b3a4672), WTCP(0x7049c203, 0x3d71b14d), WTCP(0x6f0f6289, 0x3fa30bc1), + WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6c79e1c2, 0x43f2b271), WTCP(0x6b1f01c0, 0x461091c2), + WTCP(0x69b98f48, 0x482786dc), WTCP(0x6849ada3, 0x4a375cf5), WTCP(0x66cf8120, 0x4c3fdff4), + WTCP(0x654b2f10, 0x4e40dc79), WTCP(0x63bcddc7, 0x503a1fe5), WTCP(0x6224b495, 0x522b7859), + WTCP(0x6082dbc1, 0x5414b4c1), WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5d22c11c, 0x57ce1917), + WTCP(0x5b64d492, 0x599de2ee), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow120[60] = { +# else +const PWord16 SineWindow120[60] = { +# endif + WTCP(0x7fff4c54, 0x00d676eb), WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fee74a2, 0x0430238f), + WTCP(0x7fdd9dad, 0x05dcbcbe), WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7fab1d3d, 0x093516d4), + WTCP(0x7f8975f9, 0x0ae0b22c), WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7f3560b9, 0x0e3667ad), + WTCP(0x7f02f66f, 0x0fe05c64), WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7e8d6d91, 0x13321c53), + WTCP(0x7e4a5426, 0x14d9c245), WTCP(0x7e01b096, 0x16807e15), WTCP(0x7db3860f, 0x18263d36), + WTCP(0x7d5fd801, 0x19caed29), WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7ca80038, 0x1d10d5c2), + WTCP(0x7c43de8e, 0x1eb1e9a7), WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7b6b45a5, 0x21eff528), + WTCP(0x7af6d7e6, 0x238cc85d), WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x79fdd35c, 0x26c1af22), + WTCP(0x7979477d, 0x28599eb0), WTCP(0x78ef678f, 0x29efc925), WTCP(0x7860399e, 0x2b841caf), + WTCP(0x77cbc3f2, 0x2d168792), WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x76931bae, 0x30355cdd), + WTCP(0x75eef6ce, 0x31c1a43b), WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x74972f92, 0x34d3957e), + WTCP(0x73e39c49, 0x36591cea), WTCP(0x732af3a7, 0x37dc420c), WTCP(0x726d3dc6, 0x395cf3e9), + WTCP(0x71aa82f7, 0x3adb21a1), WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x701620f5, 0x3dcfadb0), + WTCP(0x6f448b7e, 0x3f45ead8), WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6d92c59b, 0x422a0154), + WTCP(0x6cb2a837, 0x4397ba32), WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6ae429ae, 0x466a36f9), + WTCP(0x69f5dcd3, 0x47cedb31), WTCP(0x6902ea1d, 0x4930590f), WTCP(0x680b5c33, 0x4a8ea111), + WTCP(0x670f3df3, 0x4be9a3db), WTCP(0x660e9a6a, 0x4d415234), WTCP(0x65097cdb, 0x4e959d08), + WTCP(0x63fff0ba, 0x4fe6756a), WTCP(0x62f201ac, 0x5133cc94), WTCP(0x61dfbb8a, 0x527d93e6), + WTCP(0x60c92a5a, 0x53c3bcea), WTCP(0x5fae5a55, 0x55063951), WTCP(0x5e8f57e2, 0x5644faf4), + WTCP(0x5d6c2f99, 0x577ff3da), WTCP(0x5c44ee40, 0x58b71632), WTCP(0x5b19a0c8, 0x59ea5454), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow160[80] = { +# else +const PWord16 SineWindow160[80] = { +# endif + WTCP(0x7fff9aef, 0x00a0d951), WTCP(0x7ffc726f, 0x01e287fc), WTCP(0x7ff62182, 0x03242abf), + WTCP(0x7feca851, 0x0465b9aa), WTCP(0x7fe00716, 0x05a72ccf), WTCP(0x7fd03e23, 0x06e87c3f), + WTCP(0x7fbd4dda, 0x0829a00c), WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f8df93c, 0x0aab450d), + WTCP(0x7f719611, 0x0bebb66c), WTCP(0x7f520de6, 0x0d2bdc80), WTCP(0x7f2f6183, 0x0e6baf61), + WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7ee09f95, 0x10ea3bfd), WTCP(0x7eb48bfb, 0x1228e5f8), + WTCP(0x7e85580c, 0x13671d3d), WTCP(0x7e5304f2, 0x14a4d9f4), WTCP(0x7e1d93ea, 0x15e21445), + WTCP(0x7de50646, 0x171ec45c), WTCP(0x7da95d6c, 0x185ae269), WTCP(0x7d6a9ad5, 0x199666a0), + WTCP(0x7d28c00c, 0x1ad14938), WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7c9bc87a, 0x1d450a78), + WTCP(0x7c50af2b, 0x1e7dd9a4), WTCP(0x7c02849f, 0x1fb5e836), WTCP(0x7bb14ac5, 0x20ed2e7b), + WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7b05b13d, 0x2359436c), WTCP(0x7aab55ca, 0x248e02cb), + WTCP(0x7a4df380, 0x25c1db44), WTCP(0x79ed8cad, 0x26f4c53e), WTCP(0x798a23b1, 0x2826b928), + WTCP(0x7923bb01, 0x2957af74), WTCP(0x78ba5524, 0x2a87a09d), WTCP(0x784df4b3, 0x2bb68522), + WTCP(0x77de9c5b, 0x2ce45589), WTCP(0x776c4edb, 0x2e110a62), WTCP(0x76f70f05, 0x2f3c9c40), + WTCP(0x767edfbe, 0x306703bf), WTCP(0x7603c3fd, 0x31903982), WTCP(0x7585becb, 0x32b83634), + WTCP(0x7504d345, 0x33def287), WTCP(0x74810499, 0x35046736), WTCP(0x73fa5607, 0x36288d03), + WTCP(0x7370cae2, 0x374b5cb9), WTCP(0x72e4668f, 0x386ccf2a), WTCP(0x72552c85, 0x398cdd32), + WTCP(0x71c3204c, 0x3aab7fb7), WTCP(0x712e457f, 0x3bc8afa5), WTCP(0x70969fca, 0x3ce465f3), + WTCP(0x6ffc32eb, 0x3dfe9ba1), WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6ebf12ff, 0x402e694c), + WTCP(0x6e1c67c4, 0x4143f379), WTCP(0x6d770506, 0x4257e166), WTCP(0x6cceeed8, 0x436a2c45), + WTCP(0x6c242960, 0x447acd50), WTCP(0x6b76b8d6, 0x4589bdcf), WTCP(0x6ac6a180, 0x4696f710), + WTCP(0x6a13e7b8, 0x47a27271), WTCP(0x695e8fe5, 0x48ac2957), WTCP(0x68a69e81, 0x49b41533), + WTCP(0x67ec1817, 0x4aba2f84), WTCP(0x672f013f, 0x4bbe71d1), WTCP(0x666f5ea6, 0x4cc0d5ae), + WTCP(0x65ad3505, 0x4dc154bb), WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x64215fe5, 0x4fbc8b22), + WTCP(0x6357be2a, 0x50b735f8), WTCP(0x628ba8ef, 0x51afe2f6), WTCP(0x61bd253f, 0x52a68bfb), + WTCP(0x60ec3830, 0x539b2af0), WTCP(0x6018e6eb, 0x548db9cb), WTCP(0x5f4336a7, 0x557e3292), + WTCP(0x5e6b2ca8, 0x566c8f55), WTCP(0x5d90ce45, 0x5758ca31), WTCP(0x5cb420e0, 0x5842dd54), + WTCP(0x5bd529eb, 0x592ac2f7), WTCP(0x5af3eee6, 0x5a107561), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow180[90] = { +# else +const PWord16 SineWindow180[90] = { +# endif + WTCP(0x7fffb025, 0x008efa17), WTCP(0x7ffd3153, 0x01aceb7c), WTCP(0x7ff833bc, 0x02cad485), + WTCP(0x7ff0b779, 0x03e8af9e), WTCP(0x7fe6bcaf, 0x05067734), WTCP(0x7fda4390, 0x062425b6), + WTCP(0x7fcb4c5a, 0x0741b592), WTCP(0x7fb9d758, 0x085f2136), WTCP(0x7fa5e4e0, 0x097c6313), + WTCP(0x7f8f7558, 0x0a997597), WTCP(0x7f76892e, 0x0bb65336), WTCP(0x7f5b20de, 0x0cd2f660), + WTCP(0x7f3d3cf3, 0x0def5989), WTCP(0x7f1cde00, 0x0f0b7727), WTCP(0x7efa04a7, 0x102749ae), + WTCP(0x7ed4b197, 0x1142cb98), WTCP(0x7eace589, 0x125df75b), WTCP(0x7e82a145, 0x1378c774), + WTCP(0x7e55e59d, 0x1493365f), WTCP(0x7e26b370, 0x15ad3e9a), WTCP(0x7df50baa, 0x16c6daa6), + WTCP(0x7dc0ef43, 0x17e00505), WTCP(0x7d8a5f3f, 0x18f8b83c), WTCP(0x7d515cae, 0x1a10eed2), + WTCP(0x7d15e8ac, 0x1b28a351), WTCP(0x7cd80464, 0x1c3fd045), WTCP(0x7c97b108, 0x1d56703b), + WTCP(0x7c54efdb, 0x1e6c7dc7), WTCP(0x7c0fc229, 0x1f81f37b), WTCP(0x7bc8294c, 0x2096cbf0), + WTCP(0x7b7e26a9, 0x21ab01c0), WTCP(0x7b31bbb1, 0x22be8f87), WTCP(0x7ae2e9e3, 0x23d16fe8), + WTCP(0x7a91b2c6, 0x24e39d85), WTCP(0x7a3e17f1, 0x25f51307), WTCP(0x79e81b05, 0x2705cb19), + WTCP(0x798fbdaf, 0x2815c069), WTCP(0x793501a8, 0x2924edab), WTCP(0x78d7e8b5, 0x2a334d95), + WTCP(0x787874a6, 0x2b40dae2), WTCP(0x7816a758, 0x2c4d9050), WTCP(0x77b282b3, 0x2d5968a2), + WTCP(0x774c08aa, 0x2e645ea0), WTCP(0x76e33b3e, 0x2f6e6d15), WTCP(0x76781c79, 0x30778ed2), + WTCP(0x760aae72, 0x317fbeaa), WTCP(0x759af34b, 0x3286f778), WTCP(0x7528ed31, 0x338d341a), + WTCP(0x74b49e5f, 0x34926f74), WTCP(0x743e0917, 0x3596a46c), WTCP(0x73c52faa, 0x3699cdf1), + WTCP(0x734a1474, 0x379be6f6), WTCP(0x72ccb9da, 0x389cea71), WTCP(0x724d224e, 0x399cd362), + WTCP(0x71cb504d, 0x3a9b9cc9), WTCP(0x7147465f, 0x3b9941b0), WTCP(0x70c10717, 0x3c95bd25), + WTCP(0x70389513, 0x3d910a3c), WTCP(0x6fadf2fb, 0x3e8b240e), WTCP(0x6f212384, 0x3f8405bb), + WTCP(0x6e92296d, 0x407baa69), WTCP(0x6e01077f, 0x41720d45), WTCP(0x6d6dc08e, 0x42672980), + WTCP(0x6cd85779, 0x435afa54), WTCP(0x6c40cf2b, 0x444d7aff), WTCP(0x6ba72a97, 0x453ea6c7), + WTCP(0x6b0b6cbc, 0x462e78f8), WTCP(0x6a6d98a3, 0x471cece6), WTCP(0x69cdb161, 0x4809fdeb), + WTCP(0x692bba13, 0x48f5a767), WTCP(0x6887b5e1, 0x49dfe4c2), WTCP(0x67e1a7ff, 0x4ac8b16b), + WTCP(0x673993a8, 0x4bb008d8), WTCP(0x668f7c24, 0x4c95e687), WTCP(0x65e364c3, 0x4d7a45fd), + WTCP(0x653550e1, 0x4e5d22c5), WTCP(0x648543e3, 0x4f3e7874), WTCP(0x63d34136, 0x501e42a5), + WTCP(0x631f4c54, 0x50fc7cfa), WTCP(0x626968be, 0x51d92320), WTCP(0x61b19a00, 0x52b430c8), + WTCP(0x60f7e3b0, 0x538da1ae), WTCP(0x603c496c, 0x54657194), WTCP(0x5f7ecedd, 0x553b9c45), + WTCP(0x5ebf77b4, 0x56101d94), WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5d3b428b, 0x57b41383), + WTCP(0x5c766c1c, 0x58837ff3), WTCP(0x5bafc836, 0x595132a2), WTCP(0x5ae75ab8, 0x5a1d278c), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow240[120] = { +# else +const PWord16 SineWindow240[120] = { +# endif + WTCP(0x7fffd315, 0x006b3b9b), WTCP(0x7ffe6bbf, 0x0141b1a5), WTCP(0x7ffb9d15, 0x02182427), + WTCP(0x7ff76721, 0x02ee90c8), WTCP(0x7ff1c9ef, 0x03c4f52f), WTCP(0x7feac58d, 0x049b4f00), + WTCP(0x7fe25a0f, 0x05719be2), WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7fcd4e24, 0x071e0575), + WTCP(0x7fc0adf2, 0x07f41d72), WTCP(0x7fb2a71b, 0x08ca1f1b), WTCP(0x7fa339c5, 0x09a00817), + WTCP(0x7f92661d, 0x0a75d60e), WTCP(0x7f802c52, 0x0b4b86a8), WTCP(0x7f6c8c96, 0x0c21178c), + WTCP(0x7f578721, 0x0cf68662), WTCP(0x7f411c2f, 0x0dcbd0d5), WTCP(0x7f294bfd, 0x0ea0f48c), + WTCP(0x7f1016ce, 0x0f75ef33), WTCP(0x7ef57cea, 0x104abe71), WTCP(0x7ed97e9c, 0x111f5ff4), + WTCP(0x7ebc1c31, 0x11f3d164), WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7e7d2c54, 0x139c1abf), + WTCP(0x7e5b9f93, 0x146fee03), WTCP(0x7e38b017, 0x154387e6), WTCP(0x7e145e42, 0x1616e618), + WTCP(0x7deeaa7a, 0x16ea0646), WTCP(0x7dc79529, 0x17bce621), WTCP(0x7d9f1ebd, 0x188f8357), + WTCP(0x7d7547a7, 0x1961db9b), WTCP(0x7d4a105d, 0x1a33ec9c), WTCP(0x7d1d7958, 0x1b05b40f), + WTCP(0x7cef8315, 0x1bd72fa4), WTCP(0x7cc02e15, 0x1ca85d12), WTCP(0x7c8f7ade, 0x1d793a0b), + WTCP(0x7c5d69f7, 0x1e49c447), WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7bf53153, 0x1fe9d75f), + WTCP(0x7bbf0aba, 0x20b95bac), WTCP(0x7b8788ba, 0x2188841a), WTCP(0x7b4eabf1, 0x22574e65), + WTCP(0x7b1474fd, 0x2325b847), WTCP(0x7ad8e482, 0x23f3bf7e), WTCP(0x7a9bfb27, 0x24c161c7), + WTCP(0x7a5db997, 0x258e9ce0), WTCP(0x7a1e2082, 0x265b6e8a), WTCP(0x79dd3098, 0x2727d486), + WTCP(0x799aea92, 0x27f3cc94), WTCP(0x79574f28, 0x28bf547b), WTCP(0x79125f19, 0x298a69fc), + WTCP(0x78cc1b26, 0x2a550adf), WTCP(0x78848414, 0x2b1f34eb), WTCP(0x783b9aad, 0x2be8e5e8), + WTCP(0x77f15fbc, 0x2cb21ba0), WTCP(0x77a5d413, 0x2d7ad3de), WTCP(0x7758f886, 0x2e430c6f), + WTCP(0x770acdec, 0x2f0ac320), WTCP(0x76bb5521, 0x2fd1f5c1), WTCP(0x766a8f04, 0x3098a223), + WTCP(0x76187c77, 0x315ec617), WTCP(0x75c51e61, 0x32245f72), WTCP(0x757075ac, 0x32e96c09), + WTCP(0x751a8346, 0x33ade9b3), WTCP(0x74c34820, 0x3471d647), WTCP(0x746ac52f, 0x35352fa1), + WTCP(0x7410fb6b, 0x35f7f39c), WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x73599760, 0x377bb2e9), + WTCP(0x72fbff1b, 0x383ca9fb), WTCP(0x729d2409, 0x38fd032d), WTCP(0x723d0734, 0x39bcbc63), + WTCP(0x71dba9ab, 0x3a7bd382), WTCP(0x71790c7e, 0x3b3a4672), WTCP(0x711530c2, 0x3bf8131c), + WTCP(0x70b01790, 0x3cb5376b), WTCP(0x7049c203, 0x3d71b14d), WTCP(0x6fe2313c, 0x3e2d7eb1), + WTCP(0x6f79665b, 0x3ee89d86), WTCP(0x6f0f6289, 0x3fa30bc1), WTCP(0x6ea426ed, 0x405cc754), + WTCP(0x6e37b4b6, 0x4115ce38), WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6d5b313b, 0x4285b5d4), + WTCP(0x6ceb2261, 0x433c9283), WTCP(0x6c79e1c2, 0x43f2b271), WTCP(0x6c07709b, 0x44a8139e), + WTCP(0x6b93d02e, 0x455cb40c), WTCP(0x6b1f01c0, 0x461091c2), WTCP(0x6aa90697, 0x46c3aac5), + WTCP(0x6a31e000, 0x4775fd1f), WTCP(0x69b98f48, 0x482786dc), WTCP(0x694015c3, 0x48d84609), + WTCP(0x68c574c4, 0x498838b6), WTCP(0x6849ada3, 0x4a375cf5), WTCP(0x67ccc1be, 0x4ae5b0da), + WTCP(0x674eb271, 0x4b93327c), WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x664f2f2e, 0x4cebb75c), + WTCP(0x65cdbe05, 0x4d96b6d3), WTCP(0x654b2f10, 0x4e40dc79), WTCP(0x64c783bd, 0x4eea2670), + WTCP(0x6442bd7e, 0x4f9292dc), WTCP(0x63bcddc7, 0x503a1fe5), WTCP(0x6335e611, 0x50e0cbb4), + WTCP(0x62add7d6, 0x51869476), WTCP(0x6224b495, 0x522b7859), WTCP(0x619a7dce, 0x52cf758f), + WTCP(0x610f3505, 0x53728a4a), WTCP(0x6082dbc1, 0x5414b4c1), WTCP(0x5ff5738d, 0x54b5f32c), + WTCP(0x5f66fdf5, 0x555643c8), WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5e46f0dd, 0x5694148b), + WTCP(0x5db55c86, 0x57319135), WTCP(0x5d22c11c, 0x57ce1917), WTCP(0x5c8f203b, 0x5869aa79), + WTCP(0x5bfa7b82, 0x590443a7), WTCP(0x5b64d492, 0x599de2ee), WTCP(0x5ace2d0f, 0x5a36869f), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow320[160] = { +# else +const PWord16 SineWindow320[160] = { +# endif + WTCP(0x7fffe6bc, 0x00506cb9), WTCP(0x7fff1c9b, 0x00f145ab), WTCP(0x7ffd885a, 0x01921d20), + WTCP(0x7ffb29fd, 0x0232f21a), WTCP(0x7ff80186, 0x02d3c39b), WTCP(0x7ff40efa, 0x037490a5), + WTCP(0x7fef5260, 0x0415583b), WTCP(0x7fe9cbc0, 0x04b6195d), WTCP(0x7fe37b22, 0x0556d30f), + WTCP(0x7fdc608f, 0x05f78453), WTCP(0x7fd47c14, 0x06982c2b), WTCP(0x7fcbcdbc, 0x0738c998), + WTCP(0x7fc25596, 0x07d95b9e), WTCP(0x7fb813b0, 0x0879e140), WTCP(0x7fad081b, 0x091a597e), + WTCP(0x7fa132e8, 0x09bac35d), WTCP(0x7f949429, 0x0a5b1dde), WTCP(0x7f872bf3, 0x0afb6805), + WTCP(0x7f78fa5b, 0x0b9ba0d5), WTCP(0x7f69ff76, 0x0c3bc74f), WTCP(0x7f5a3b5e, 0x0cdbda79), + WTCP(0x7f49ae2a, 0x0d7bd954), WTCP(0x7f3857f6, 0x0e1bc2e4), WTCP(0x7f2638db, 0x0ebb962c), + WTCP(0x7f1350f8, 0x0f5b5231), WTCP(0x7effa069, 0x0ffaf5f6), WTCP(0x7eeb274d, 0x109a807e), + WTCP(0x7ed5e5c6, 0x1139f0cf), WTCP(0x7ebfdbf5, 0x11d945eb), WTCP(0x7ea909fc, 0x12787ed8), + WTCP(0x7e917000, 0x13179a9b), WTCP(0x7e790e25, 0x13b69836), WTCP(0x7e5fe493, 0x145576b1), + WTCP(0x7e45f371, 0x14f43510), WTCP(0x7e2b3ae8, 0x1592d257), WTCP(0x7e0fbb22, 0x16314d8e), + WTCP(0x7df3744b, 0x16cfa5b9), WTCP(0x7dd6668f, 0x176dd9de), WTCP(0x7db8921c, 0x180be904), + WTCP(0x7d99f721, 0x18a9d231), WTCP(0x7d7a95cf, 0x1947946c), WTCP(0x7d5a6e57, 0x19e52ebb), + WTCP(0x7d3980ec, 0x1a82a026), WTCP(0x7d17cdc2, 0x1b1fe7b3), WTCP(0x7cf5550e, 0x1bbd046c), + WTCP(0x7cd21707, 0x1c59f557), WTCP(0x7cae13e4, 0x1cf6b97c), WTCP(0x7c894bde, 0x1d934fe5), + WTCP(0x7c63bf2f, 0x1e2fb79a), WTCP(0x7c3d6e13, 0x1ecbefa4), WTCP(0x7c1658c5, 0x1f67f70b), + WTCP(0x7bee7f85, 0x2003ccdb), WTCP(0x7bc5e290, 0x209f701c), WTCP(0x7b9c8226, 0x213adfda), + WTCP(0x7b725e8a, 0x21d61b1e), WTCP(0x7b4777fe, 0x227120f3), WTCP(0x7b1bcec4, 0x230bf065), + WTCP(0x7aef6323, 0x23a6887f), WTCP(0x7ac23561, 0x2440e84d), WTCP(0x7a9445c5, 0x24db0edb), + WTCP(0x7a659496, 0x2574fb36), WTCP(0x7a362220, 0x260eac6a), WTCP(0x7a05eead, 0x26a82186), + WTCP(0x79d4fa89, 0x27415996), WTCP(0x79a34602, 0x27da53a9), WTCP(0x7970d165, 0x28730ecd), + WTCP(0x793d9d03, 0x290b8a12), WTCP(0x7909a92d, 0x29a3c485), WTCP(0x78d4f634, 0x2a3bbd37), + WTCP(0x789f846b, 0x2ad37338), WTCP(0x78695428, 0x2b6ae598), WTCP(0x783265c0, 0x2c021369), + WTCP(0x77fab989, 0x2c98fbba), WTCP(0x77c24fdb, 0x2d2f9d9f), WTCP(0x77892910, 0x2dc5f829), + WTCP(0x774f4581, 0x2e5c0a6b), WTCP(0x7714a58b, 0x2ef1d377), WTCP(0x76d94989, 0x2f875262), + WTCP(0x769d31d9, 0x301c863f), WTCP(0x76605edb, 0x30b16e23), WTCP(0x7622d0ef, 0x31460922), + WTCP(0x75e48874, 0x31da5651), WTCP(0x75a585cf, 0x326e54c7), WTCP(0x7565c962, 0x3302039b), + WTCP(0x75255392, 0x339561e1), WTCP(0x74e424c5, 0x34286eb3), WTCP(0x74a23d62, 0x34bb2927), + WTCP(0x745f9dd1, 0x354d9057), WTCP(0x741c467b, 0x35dfa35a), WTCP(0x73d837ca, 0x3671614b), + WTCP(0x7393722a, 0x3702c942), WTCP(0x734df607, 0x3793da5b), WTCP(0x7307c3d0, 0x382493b0), + WTCP(0x72c0dbf3, 0x38b4f45d), WTCP(0x72793edf, 0x3944fb7e), WTCP(0x7230ed07, 0x39d4a82f), + WTCP(0x71e7e6dc, 0x3a63f98d), WTCP(0x719e2cd2, 0x3af2eeb7), WTCP(0x7153bf5d, 0x3b8186ca), + WTCP(0x71089ef2, 0x3c0fc0e6), WTCP(0x70bccc09, 0x3c9d9c28), WTCP(0x70704718, 0x3d2b17b3), + WTCP(0x7023109a, 0x3db832a6), WTCP(0x6fd52907, 0x3e44ec22), WTCP(0x6f8690db, 0x3ed14349), + WTCP(0x6f374891, 0x3f5d373e), WTCP(0x6ee750a8, 0x3fe8c724), WTCP(0x6e96a99d, 0x4073f21d), + WTCP(0x6e4553ef, 0x40feb74f), WTCP(0x6df35020, 0x418915de), WTCP(0x6da09eb1, 0x42130cf0), + WTCP(0x6d4d4023, 0x429c9bab), WTCP(0x6cf934fc, 0x4325c135), WTCP(0x6ca47dbf, 0x43ae7cb7), + WTCP(0x6c4f1af2, 0x4436cd58), WTCP(0x6bf90d1d, 0x44beb240), WTCP(0x6ba254c7, 0x45462a9a), + WTCP(0x6b4af279, 0x45cd358f), WTCP(0x6af2e6bc, 0x4653d24b), WTCP(0x6a9a321d, 0x46d9fff8), + WTCP(0x6a40d527, 0x475fbdc3), WTCP(0x69e6d067, 0x47e50ad8), WTCP(0x698c246c, 0x4869e665), + WTCP(0x6930d1c4, 0x48ee4f98), WTCP(0x68d4d900, 0x497245a1), WTCP(0x68783ab1, 0x49f5c7ae), + WTCP(0x681af76a, 0x4a78d4f0), WTCP(0x67bd0fbd, 0x4afb6c98), WTCP(0x675e843e, 0x4b7d8dd8), + WTCP(0x66ff5584, 0x4bff37e2), WTCP(0x669f8425, 0x4c8069ea), WTCP(0x663f10b7, 0x4d012324), + WTCP(0x65ddfbd3, 0x4d8162c4), WTCP(0x657c4613, 0x4e012800), WTCP(0x6519f010, 0x4e80720e), + WTCP(0x64b6fa66, 0x4eff4025), WTCP(0x645365b2, 0x4f7d917c), WTCP(0x63ef3290, 0x4ffb654d), + WTCP(0x638a619e, 0x5078bad1), WTCP(0x6324f37d, 0x50f59141), WTCP(0x62bee8cc, 0x5171e7d9), + WTCP(0x6258422c, 0x51edbdd4), WTCP(0x61f1003f, 0x5269126e), WTCP(0x618923a9, 0x52e3e4e6), + WTCP(0x6120ad0d, 0x535e3479), WTCP(0x60b79d10, 0x53d80065), WTCP(0x604df459, 0x545147eb), + WTCP(0x5fe3b38d, 0x54ca0a4b), WTCP(0x5f78db56, 0x554246c6), WTCP(0x5f0d6c5b, 0x55b9fc9e), + WTCP(0x5ea16747, 0x56312b17), WTCP(0x5e34ccc3, 0x56a7d174), WTCP(0x5dc79d7c, 0x571deefa), + WTCP(0x5d59da1e, 0x579382ee), WTCP(0x5ceb8355, 0x58088c96), WTCP(0x5c7c99d1, 0x587d0b3b), + WTCP(0x5c0d1e41, 0x58f0fe23), WTCP(0x5b9d1154, 0x59646498), WTCP(0x5b2c73bb, 0x59d73de3), + WTCP(0x5abb4629, 0x5a498950), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow360[180] = { +# else +const PWord16 SineWindow360[180] = { +# endif + WTCP(0x7fffec08, 0x00477d17), WTCP(0x7fff4c53, 0x00d676eb), WTCP(0x7ffe0cea, 0x01656fb4), + WTCP(0x7ffc2dcf, 0x01f466bf), WTCP(0x7ff9af03, 0x02835b59), WTCP(0x7ff6908a, 0x03124cd1), + WTCP(0x7ff2d268, 0x03a13a74), WTCP(0x7fee74a1, 0x0430238f), WTCP(0x7fe9773c, 0x04bf0771), + WTCP(0x7fe3da3d, 0x054de566), WTCP(0x7fdd9dac, 0x05dcbcbe), WTCP(0x7fd6c192, 0x066b8cc5), + WTCP(0x7fcf45f6, 0x06fa54c9), WTCP(0x7fc72ae1, 0x07891418), WTCP(0x7fbe705f, 0x0817ca01), + WTCP(0x7fb51679, 0x08a675d0), WTCP(0x7fab1d3c, 0x093516d4), WTCP(0x7fa084b4, 0x09c3ac5c), + WTCP(0x7f954cee, 0x0a5235b4), WTCP(0x7f8975f8, 0x0ae0b22c), WTCP(0x7f7cffe1, 0x0b6f2112), + WTCP(0x7f6feab8, 0x0bfd81b3), WTCP(0x7f62368e, 0x0c8bd35e), WTCP(0x7f53e374, 0x0d1a1562), + WTCP(0x7f44f17c, 0x0da8470d), WTCP(0x7f3560b8, 0x0e3667ad), WTCP(0x7f25313c, 0x0ec47692), + WTCP(0x7f14631c, 0x0f52730a), WTCP(0x7f02f66e, 0x0fe05c64), WTCP(0x7ef0eb45, 0x106e31ef), + WTCP(0x7ede41ba, 0x10fbf2fa), WTCP(0x7ecaf9e4, 0x11899ed3), WTCP(0x7eb713da, 0x121734cb), + WTCP(0x7ea28fb5, 0x12a4b431), WTCP(0x7e8d6d90, 0x13321c53), WTCP(0x7e77ad84, 0x13bf6c82), + WTCP(0x7e614fac, 0x144ca40e), WTCP(0x7e4a5425, 0x14d9c245), WTCP(0x7e32bb0b, 0x1566c679), + WTCP(0x7e1a847b, 0x15f3aff8), WTCP(0x7e01b095, 0x16807e14), WTCP(0x7de83f76, 0x170d301d), + WTCP(0x7dce313e, 0x1799c562), WTCP(0x7db3860e, 0x18263d35), WTCP(0x7d983e08, 0x18b296e7), + WTCP(0x7d7c594d, 0x193ed1c8), WTCP(0x7d5fd800, 0x19caed28), WTCP(0x7d42ba45, 0x1a56e85b), + WTCP(0x7d25003f, 0x1ae2c2b0), WTCP(0x7d06aa15, 0x1b6e7b7a), WTCP(0x7ce7b7ec, 0x1bfa1209), + WTCP(0x7cc829ea, 0x1c8585b0), WTCP(0x7ca80037, 0x1d10d5c1), WTCP(0x7c873afb, 0x1d9c018f), + WTCP(0x7c65da60, 0x1e27086a), WTCP(0x7c43de8d, 0x1eb1e9a6), WTCP(0x7c2147af, 0x1f3ca496), + WTCP(0x7bfe15f0, 0x1fc7388d), WTCP(0x7bda497c, 0x2051a4dd), WTCP(0x7bb5e27f, 0x20dbe8da), + WTCP(0x7b90e128, 0x216603d7), WTCP(0x7b6b45a4, 0x21eff528), WTCP(0x7b451022, 0x2279bc21), + WTCP(0x7b1e40d3, 0x23035817), WTCP(0x7af6d7e5, 0x238cc85c), WTCP(0x7aced58b, 0x24160c47), + WTCP(0x7aa639f7, 0x249f232b), WTCP(0x7a7d055a, 0x25280c5d), WTCP(0x7a5337e9, 0x25b0c734), + WTCP(0x7a28d1d8, 0x26395303), WTCP(0x79fdd35b, 0x26c1af21), WTCP(0x79d23ca9, 0x2749dae4), + WTCP(0x79a60df7, 0x27d1d5a2), WTCP(0x7979477c, 0x28599eb0), WTCP(0x794be972, 0x28e13566), + WTCP(0x791df40f, 0x2968991b), WTCP(0x78ef678e, 0x29efc925), WTCP(0x78c04429, 0x2a76c4dc), + WTCP(0x78908a1a, 0x2afd8b97), WTCP(0x7860399d, 0x2b841caf), WTCP(0x782f52ef, 0x2c0a777b), + WTCP(0x77fdd64b, 0x2c909b54), WTCP(0x77cbc3f1, 0x2d168792), WTCP(0x77991c1e, 0x2d9c3b8e), + WTCP(0x7765df12, 0x2e21b6a2), WTCP(0x77320d0c, 0x2ea6f826), WTCP(0x76fda64e, 0x2f2bff76), + WTCP(0x76c8ab18, 0x2fb0cbea), WTCP(0x76931bae, 0x30355cdc), WTCP(0x765cf850, 0x30b9b1a9), + WTCP(0x76264144, 0x313dc9aa), WTCP(0x75eef6ce, 0x31c1a43a), WTCP(0x75b71931, 0x324540b6), + WTCP(0x757ea8b5, 0x32c89e78), WTCP(0x7545a59f, 0x334bbcde), WTCP(0x750c1038, 0x33ce9b42), + WTCP(0x74d1e8c5, 0x34513903), WTCP(0x74972f91, 0x34d3957e), WTCP(0x745be4e4, 0x3555b00e), + WTCP(0x74200908, 0x35d78813), WTCP(0x73e39c48, 0x36591cea), WTCP(0x73a69ef0, 0x36da6df1), + WTCP(0x7369114b, 0x375b7a87), WTCP(0x732af3a6, 0x37dc420c), WTCP(0x72ec4650, 0x385cc3de), + WTCP(0x72ad0995, 0x38dcff5d), WTCP(0x726d3dc5, 0x395cf3e9), WTCP(0x722ce330, 0x39dca0e2), + WTCP(0x71ebfa25, 0x3a5c05aa), WTCP(0x71aa82f6, 0x3adb21a0), WTCP(0x71687df5, 0x3b59f428), + WTCP(0x7125eb74, 0x3bd87ca1), WTCP(0x70e2cbc5, 0x3c56ba70), WTCP(0x709f1f3d, 0x3cd4acf5), + WTCP(0x705ae630, 0x3d525394), WTCP(0x701620f4, 0x3dcfadaf), WTCP(0x6fd0cfdd, 0x3e4cbaac), + WTCP(0x6f8af343, 0x3ec979ed), WTCP(0x6f448b7d, 0x3f45ead7), WTCP(0x6efd98e2, 0x3fc20ccf), + WTCP(0x6eb61bcb, 0x403ddf39), WTCP(0x6e6e1492, 0x40b9617c), WTCP(0x6e25838f, 0x413492fd), + WTCP(0x6ddc691e, 0x41af7323), WTCP(0x6d92c59a, 0x422a0154), WTCP(0x6d48995f, 0x42a43cf7), + WTCP(0x6cfde4c9, 0x431e2573), WTCP(0x6cb2a836, 0x4397ba32), WTCP(0x6c66e403, 0x4410fa9a), + WTCP(0x6c1a988f, 0x4489e615), WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6b806d61, 0x457abbe8), + WTCP(0x6b328e67, 0x45f2a513), WTCP(0x6ae429ad, 0x466a36f9), WTCP(0x6a953f94, 0x46e17102), + WTCP(0x6a45d080, 0x4758529c), WTCP(0x69f5dcd2, 0x47cedb30), WTCP(0x69a564ef, 0x48450a2d), + WTCP(0x6954693b, 0x48badefd), WTCP(0x6902ea1c, 0x4930590e), WTCP(0x68b0e7f6, 0x49a577ce), + WTCP(0x685e6331, 0x4a1a3aaa), WTCP(0x680b5c33, 0x4a8ea111), WTCP(0x67b7d363, 0x4b02aa71), + WTCP(0x6763c92b, 0x4b76563a), WTCP(0x670f3df2, 0x4be9a3db), WTCP(0x66ba3223, 0x4c5c92c4), + WTCP(0x6664a627, 0x4ccf2267), WTCP(0x660e9a69, 0x4d415233), WTCP(0x65b80f55, 0x4db3219c), + WTCP(0x65610557, 0x4e249011), WTCP(0x65097cda, 0x4e959d07), WTCP(0x64b1764d, 0x4f0647f0), + WTCP(0x6458f21d, 0x4f769040), WTCP(0x63fff0b9, 0x4fe6756a), WTCP(0x63a6728f, 0x5055f6e2), + WTCP(0x634c7810, 0x50c5141e), WTCP(0x62f201ac, 0x5133cc94), WTCP(0x62970fd2, 0x51a21fb7), + WTCP(0x623ba2f6, 0x52100d01), WTCP(0x61dfbb89, 0x527d93e6), WTCP(0x618359fd, 0x52eab3de), + WTCP(0x61267ec7, 0x53576c62), WTCP(0x60c92a59, 0x53c3bce9), WTCP(0x606b5d28, 0x542fa4ed), + WTCP(0x600d17aa, 0x549b23e7), WTCP(0x5fae5a54, 0x55063950), WTCP(0x5f4f259c, 0x5570e4a3), + WTCP(0x5eef79f8, 0x55db255b), WTCP(0x5e8f57e2, 0x5644faf4), WTCP(0x5e2ebfcf, 0x56ae64e9), + WTCP(0x5dcdb239, 0x571762b6), WTCP(0x5d6c2f99, 0x577ff3da), WTCP(0x5d0a3868, 0x57e817d1), + WTCP(0x5ca7cd21, 0x584fce19), WTCP(0x5c44ee3f, 0x58b71631), WTCP(0x5be19c3c, 0x591def98), + WTCP(0x5b7dd796, 0x598459ce), WTCP(0x5b19a0c7, 0x59ea5454), WTCP(0x5ab4f84f, 0x5a4fdea9), +}; + +# ifdef ENABLE_HR_MODE +const PWord32 SineWindow480[240] = { +# else +const PWord16 SineWindow480[240] = { +# endif + WTCP(0x7ffff4c5, 0x00359dd2), WTCP(0x7fff9aef, 0x00a0d951), WTCP(0x7ffee744, 0x010c1460), + WTCP(0x7ffdd9c4, 0x01774eb2), WTCP(0x7ffc726f, 0x01e287fc), WTCP(0x7ffab147, 0x024dbff4), + WTCP(0x7ff8964d, 0x02b8f64e), WTCP(0x7ff62182, 0x03242abf), WTCP(0x7ff352e8, 0x038f5cfb), + WTCP(0x7ff02a82, 0x03fa8cb8), WTCP(0x7feca851, 0x0465b9aa), WTCP(0x7fe8cc57, 0x04d0e386), + WTCP(0x7fe49698, 0x053c0a01), WTCP(0x7fe00716, 0x05a72ccf), WTCP(0x7fdb1dd5, 0x06124ba5), + WTCP(0x7fd5dad8, 0x067d6639), WTCP(0x7fd03e23, 0x06e87c3f), WTCP(0x7fca47b9, 0x07538d6b), + WTCP(0x7fc3f7a0, 0x07be9973), WTCP(0x7fbd4dda, 0x0829a00c), WTCP(0x7fb64a6e, 0x0894a0ea), + WTCP(0x7faeed5f, 0x08ff9bc2), WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f9f2671, 0x09d57e35), + WTCP(0x7f96bc9c, 0x0a40653a), WTCP(0x7f8df93c, 0x0aab450d), WTCP(0x7f84dc55, 0x0b161d63), + WTCP(0x7f7b65ef, 0x0b80edf1), WTCP(0x7f719611, 0x0bebb66c), WTCP(0x7f676cc0, 0x0c56768a), + WTCP(0x7f5cea05, 0x0cc12dff), WTCP(0x7f520de6, 0x0d2bdc80), WTCP(0x7f46d86c, 0x0d9681c2), + WTCP(0x7f3b499d, 0x0e011d7c), WTCP(0x7f2f6183, 0x0e6baf61), WTCP(0x7f232026, 0x0ed63727), + WTCP(0x7f16858e, 0x0f40b483), WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7efc44d0, 0x10158ed4), + WTCP(0x7eee9ebe, 0x107feb33), WTCP(0x7ee09f95, 0x10ea3bfd), WTCP(0x7ed24761, 0x115480e9), + WTCP(0x7ec3962a, 0x11beb9aa), WTCP(0x7eb48bfb, 0x1228e5f8), WTCP(0x7ea528e0, 0x12930586), + WTCP(0x7e956ce1, 0x12fd180b), WTCP(0x7e85580c, 0x13671d3d), WTCP(0x7e74ea6a, 0x13d114d0), + WTCP(0x7e642408, 0x143afe7b), WTCP(0x7e5304f2, 0x14a4d9f4), WTCP(0x7e418d32, 0x150ea6ef), + WTCP(0x7e2fbcd6, 0x15786522), WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7e0b127a, 0x164bb40b), + WTCP(0x7df83895, 0x16b5442b), WTCP(0x7de50646, 0x171ec45c), WTCP(0x7dd17b9c, 0x17883452), + WTCP(0x7dbd98a4, 0x17f193c5), WTCP(0x7da95d6c, 0x185ae269), WTCP(0x7d94ca03, 0x18c41ff6), + WTCP(0x7d7fde76, 0x192d4c21), WTCP(0x7d6a9ad5, 0x199666a0), WTCP(0x7d54ff2e, 0x19ff6f2a), + WTCP(0x7d3f0b90, 0x1a686575), WTCP(0x7d28c00c, 0x1ad14938), WTCP(0x7d121cb0, 0x1b3a1a28), + WTCP(0x7cfb218c, 0x1ba2d7fc), WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7ccc2430, 0x1c74192a), + WTCP(0x7cb42217, 0x1cdc9bf2), WTCP(0x7c9bc87a, 0x1d450a78), WTCP(0x7c831767, 0x1dad6473), + WTCP(0x7c6a0ef2, 0x1e15a99a), WTCP(0x7c50af2b, 0x1e7dd9a4), WTCP(0x7c36f824, 0x1ee5f447), + WTCP(0x7c1ce9ef, 0x1f4df93a), WTCP(0x7c02849f, 0x1fb5e836), WTCP(0x7be7c847, 0x201dc0ef), + WTCP(0x7bccb4f8, 0x2085831f), WTCP(0x7bb14ac5, 0x20ed2e7b), WTCP(0x7b9589c3, 0x2154c2bb), + WTCP(0x7b797205, 0x21bc3f97), WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7b403ea2, 0x228af1fe), + WTCP(0x7b232325, 0x22f226f8), WTCP(0x7b05b13d, 0x2359436c), WTCP(0x7ae7e8fc, 0x23c04710), + WTCP(0x7ac9ca7a, 0x2427319d), WTCP(0x7aab55ca, 0x248e02cb), WTCP(0x7a8c8b01, 0x24f4ba50), + WTCP(0x7a6d6a37, 0x255b57e6), WTCP(0x7a4df380, 0x25c1db44), WTCP(0x7a2e26f2, 0x26284422), + WTCP(0x7a0e04a4, 0x268e9238), WTCP(0x79ed8cad, 0x26f4c53e), WTCP(0x79ccbf22, 0x275adcee), + WTCP(0x79ab9c1c, 0x27c0d8fe), WTCP(0x798a23b1, 0x2826b928), WTCP(0x796855f9, 0x288c7d24), + WTCP(0x7946330c, 0x28f224ab), WTCP(0x7923bb01, 0x2957af74), WTCP(0x7900edf2, 0x29bd1d3a), + WTCP(0x78ddcbf5, 0x2a226db5), WTCP(0x78ba5524, 0x2a87a09d), WTCP(0x78968998, 0x2aecb5ac), + WTCP(0x7872696a, 0x2b51ac9a), WTCP(0x784df4b3, 0x2bb68522), WTCP(0x78292b8d, 0x2c1b3efb), + WTCP(0x78040e12, 0x2c7fd9e0), WTCP(0x77de9c5b, 0x2ce45589), WTCP(0x77b8d683, 0x2d48b1b1), + WTCP(0x7792bca5, 0x2dacee11), WTCP(0x776c4edb, 0x2e110a62), WTCP(0x77458d40, 0x2e75065e), + WTCP(0x771e77f0, 0x2ed8e1c0), WTCP(0x76f70f05, 0x2f3c9c40), WTCP(0x76cf529c, 0x2fa03599), + WTCP(0x76a742d1, 0x3003ad85), WTCP(0x767edfbe, 0x306703bf), WTCP(0x76562982, 0x30ca3800), + WTCP(0x762d2038, 0x312d4a03), WTCP(0x7603c3fd, 0x31903982), WTCP(0x75da14ef, 0x31f30638), + WTCP(0x75b01329, 0x3255afe0), WTCP(0x7585becb, 0x32b83634), WTCP(0x755b17f2, 0x331a98ef), + WTCP(0x75301ebb, 0x337cd7cd), WTCP(0x7504d345, 0x33def287), WTCP(0x74d935ae, 0x3440e8da), + WTCP(0x74ad4615, 0x34a2ba81), WTCP(0x74810499, 0x35046736), WTCP(0x74547158, 0x3565eeb6), + WTCP(0x74278c72, 0x35c750bc), WTCP(0x73fa5607, 0x36288d03), WTCP(0x73ccce36, 0x3689a348), + WTCP(0x739ef51f, 0x36ea9346), WTCP(0x7370cae2, 0x374b5cb9), WTCP(0x73424fa0, 0x37abff5d), + WTCP(0x73138379, 0x380c7aee), WTCP(0x72e4668f, 0x386ccf2a), WTCP(0x72b4f902, 0x38ccfbcb), + WTCP(0x72853af3, 0x392d008f), WTCP(0x72552c85, 0x398cdd32), WTCP(0x7224cdd8, 0x39ec9172), + WTCP(0x71f41f0f, 0x3a4c1d09), WTCP(0x71c3204c, 0x3aab7fb7), WTCP(0x7191d1b1, 0x3b0ab937), + WTCP(0x71603361, 0x3b69c947), WTCP(0x712e457f, 0x3bc8afa5), WTCP(0x70fc082d, 0x3c276c0d), + WTCP(0x70c97b90, 0x3c85fe3d), WTCP(0x70969fca, 0x3ce465f3), WTCP(0x706374ff, 0x3d42a2ec), + WTCP(0x702ffb54, 0x3da0b4e7), WTCP(0x6ffc32eb, 0x3dfe9ba1), WTCP(0x6fc81bea, 0x3e5c56d8), + WTCP(0x6f93b676, 0x3eb9e64b), WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6f2a00c4, 0x3f7480dd), + WTCP(0x6ef4b0d1, 0x3fd18b7a), WTCP(0x6ebf12ff, 0x402e694c), WTCP(0x6e892772, 0x408b1a12), + WTCP(0x6e52ee52, 0x40e79d8c), WTCP(0x6e1c67c4, 0x4143f379), WTCP(0x6de593ee, 0x41a01b97), + WTCP(0x6dae72f7, 0x41fc15a6), WTCP(0x6d770506, 0x4257e166), WTCP(0x6d3f4a40, 0x42b37e96), + WTCP(0x6d0742cf, 0x430eecf6), WTCP(0x6cceeed8, 0x436a2c45), WTCP(0x6c964e83, 0x43c53c44), + WTCP(0x6c5d61f9, 0x44201cb2), WTCP(0x6c242960, 0x447acd50), WTCP(0x6beaa4e2, 0x44d54ddf), + WTCP(0x6bb0d4a7, 0x452f9e1e), WTCP(0x6b76b8d6, 0x4589bdcf), WTCP(0x6b3c519a, 0x45e3acb1), + WTCP(0x6b019f1a, 0x463d6a87), WTCP(0x6ac6a180, 0x4696f710), WTCP(0x6a8b58f6, 0x46f0520f), + WTCP(0x6a4fc5a6, 0x47497b44), WTCP(0x6a13e7b8, 0x47a27271), WTCP(0x69d7bf57, 0x47fb3757), + WTCP(0x699b4cad, 0x4853c9b9), WTCP(0x695e8fe5, 0x48ac2957), WTCP(0x69218929, 0x490455f4), + WTCP(0x68e438a4, 0x495c4f52), WTCP(0x68a69e81, 0x49b41533), WTCP(0x6868baec, 0x4a0ba75b), + WTCP(0x682a8e0f, 0x4a63058a), WTCP(0x67ec1817, 0x4aba2f84), WTCP(0x67ad592f, 0x4b11250c), + WTCP(0x676e5183, 0x4b67e5e4), WTCP(0x672f013f, 0x4bbe71d1), WTCP(0x66ef6891, 0x4c14c894), + WTCP(0x66af87a4, 0x4c6ae9f2), WTCP(0x666f5ea6, 0x4cc0d5ae), WTCP(0x662eedc3, 0x4d168b8b), + WTCP(0x65ee3529, 0x4d6c0b4e), WTCP(0x65ad3505, 0x4dc154bb), WTCP(0x656bed84, 0x4e166795), + WTCP(0x652a5ed6, 0x4e6b43a2), WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x64a66ca5, 0x4f145662), + WTCP(0x6464097f, 0x4f688ca0), WTCP(0x64215fe5, 0x4fbc8b22), WTCP(0x63de7003, 0x501051ae), + WTCP(0x639b3a0b, 0x5063e008), WTCP(0x6357be2a, 0x50b735f8), WTCP(0x6313fc90, 0x510a5340), + WTCP(0x62cff56c, 0x515d37a9), WTCP(0x628ba8ef, 0x51afe2f6), WTCP(0x62471749, 0x520254ef), + WTCP(0x620240a8, 0x52548d59), WTCP(0x61bd253f, 0x52a68bfb), WTCP(0x6177c53c, 0x52f8509b), + WTCP(0x613220d2, 0x5349daff), WTCP(0x60ec3830, 0x539b2af0), WTCP(0x60a60b88, 0x53ec4032), + WTCP(0x605f9b0b, 0x543d1a8e), WTCP(0x6018e6eb, 0x548db9cb), WTCP(0x5fd1ef59, 0x54de1db1), + WTCP(0x5f8ab487, 0x552e4605), WTCP(0x5f4336a7, 0x557e3292), WTCP(0x5efb75ea, 0x55cde31e), + WTCP(0x5eb37285, 0x561d5771), WTCP(0x5e6b2ca8, 0x566c8f55), WTCP(0x5e22a487, 0x56bb8a90), + WTCP(0x5dd9da55, 0x570a48ec), WTCP(0x5d90ce45, 0x5758ca31), WTCP(0x5d47808a, 0x57a70e29), + WTCP(0x5cfdf157, 0x57f5149d), WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5c6a0f59, 0x5890681a), + WTCP(0x5c1fbcf6, 0x58ddb4b8), WTCP(0x5bd529eb, 0x592ac2f7), WTCP(0x5b8a566c, 0x597792a1), + WTCP(0x5b3f42ae, 0x59c42381), WTCP(0x5af3eee6, 0x5a107561), WTCP(0x5aa85b48, 0x5a5c880a), +}; + +# ifdef ENABLE_HR_MODE +#ifdef CR8_G_ADD_75MS +const PWord32 SineWindow720[360] = { + WTCP(0x7ffffb01, 0x0023be8d), WTCP(0x7fffd314, 0x006b3b9b), WTCP(0x7fff833a, 0x00b2b888), + WTCP(0x7fff0b72, 0x00fa353e), WTCP(0x7ffe6bbe, 0x0141b1a5), WTCP(0x7ffda41c, 0x01892da8), + WTCP(0x7ffcb48e, 0x01d0a930), WTCP(0x7ffb9d14, 0x02182427), WTCP(0x7ffa5dae, 0x025f9e77), + WTCP(0x7ff8f65d, 0x02a7180a), WTCP(0x7ff76720, 0x02ee90c8), WTCP(0x7ff5aff9, 0x0336089d), + WTCP(0x7ff3d0e8, 0x037d7f71), WTCP(0x7ff1c9ee, 0x03c4f52e), WTCP(0x7fef9b0a, 0x040c69bf), + WTCP(0x7fed443f, 0x0453dd0c), WTCP(0x7feac58c, 0x049b4f00), WTCP(0x7fe81ef2, 0x04e2bf83), + WTCP(0x7fe55073, 0x052a2e81), WTCP(0x7fe25a0e, 0x05719be2), WTCP(0x7fdf3bc6, 0x05b90791), + WTCP(0x7fdbf59a, 0x06007176), WTCP(0x7fd8878d, 0x0647d97c), WTCP(0x7fd4f19f, 0x068f3f8d), + WTCP(0x7fd133d0, 0x06d6a392), WTCP(0x7fcd4e23, 0x071e0575), WTCP(0x7fc94099, 0x0765651f), + WTCP(0x7fc50b33, 0x07acc27b), WTCP(0x7fc0adf1, 0x07f41d72), WTCP(0x7fbc28d6, 0x083b75ee), + WTCP(0x7fb77be3, 0x0882cbd8), WTCP(0x7fb2a71a, 0x08ca1f1b), WTCP(0x7fadaa7b, 0x09116fa0), + WTCP(0x7fa88608, 0x0958bd51), WTCP(0x7fa339c4, 0x09a00817), WTCP(0x7f9dc5b0, 0x09e74fdd), + WTCP(0x7f9829cc, 0x0a2e948c), WTCP(0x7f92661c, 0x0a75d60e), WTCP(0x7f8c7aa1, 0x0abd144d), + WTCP(0x7f86675c, 0x0b044f32), WTCP(0x7f802c51, 0x0b4b86a8), WTCP(0x7f79c980, 0x0b92ba97), + WTCP(0x7f733eeb, 0x0bd9eaeb), WTCP(0x7f6c8c95, 0x0c21178c), WTCP(0x7f65b280, 0x0c684064), + WTCP(0x7f5eb0ae, 0x0caf655e), WTCP(0x7f578720, 0x0cf68662), WTCP(0x7f5035da, 0x0d3da35c), + WTCP(0x7f48bcde, 0x0d84bc34), WTCP(0x7f411c2e, 0x0dcbd0d5), WTCP(0x7f3953cb, 0x0e12e128), + WTCP(0x7f3163ba, 0x0e59ed17), WTCP(0x7f294bfc, 0x0ea0f48c), WTCP(0x7f210c93, 0x0ee7f771), + WTCP(0x7f18a583, 0x0f2ef5b0), WTCP(0x7f1016cd, 0x0f75ef32), WTCP(0x7f076075, 0x0fbce3e2), + WTCP(0x7efe827e, 0x1003d3a9), WTCP(0x7ef57cea, 0x104abe71), WTCP(0x7eec4fbb, 0x1091a424), + WTCP(0x7ee2faf5, 0x10d884ad), WTCP(0x7ed97e9b, 0x111f5ff3), WTCP(0x7ecfdaaf, 0x116635e3), + WTCP(0x7ec60f35, 0x11ad0665), WTCP(0x7ebc1c30, 0x11f3d164), WTCP(0x7eb201a2, 0x123a96c9), + WTCP(0x7ea7bf90, 0x1281567f), WTCP(0x7e9d55fb, 0x12c8106e), WTCP(0x7e92c4e8, 0x130ec482), + WTCP(0x7e880c5a, 0x135572a5), WTCP(0x7e7d2c53, 0x139c1abf), WTCP(0x7e7224d8, 0x13e2bcbb), + WTCP(0x7e66f5ec, 0x14295884), WTCP(0x7e5b9f92, 0x146fee02), WTCP(0x7e5021ce, 0x14b67d21), + WTCP(0x7e447ca3, 0x14fd05c9), WTCP(0x7e38b016, 0x154387e6), WTCP(0x7e2cbc29, 0x158a0360), + WTCP(0x7e20a0e1, 0x15d07823), WTCP(0x7e145e41, 0x1616e618), WTCP(0x7e07f44d, 0x165d4d28), + WTCP(0x7dfb6309, 0x16a3ad3f), WTCP(0x7deeaa79, 0x16ea0646), WTCP(0x7de1caa1, 0x17305827), + WTCP(0x7dd4c384, 0x1776a2cd), WTCP(0x7dc79528, 0x17bce621), WTCP(0x7dba3f90, 0x1803220d), + WTCP(0x7dacc2c0, 0x1849567c), WTCP(0x7d9f1ebc, 0x188f8357), WTCP(0x7d915389, 0x18d5a889), + WTCP(0x7d83612b, 0x191bc5fc), WTCP(0x7d7547a6, 0x1961db9b), WTCP(0x7d6706ff, 0x19a7e94e), + WTCP(0x7d589f3a, 0x19edef00), WTCP(0x7d4a105c, 0x1a33ec9c), WTCP(0x7d3b5a69, 0x1a79e20c), + WTCP(0x7d2c7d66, 0x1abfcf39), WTCP(0x7d1d7957, 0x1b05b40e), WTCP(0x7d0e4e41, 0x1b4b9076), + WTCP(0x7cfefc29, 0x1b91645a), WTCP(0x7cef8314, 0x1bd72fa4), WTCP(0x7cdfe306, 0x1c1cf23f), + WTCP(0x7cd01c05, 0x1c62ac16), WTCP(0x7cc02e14, 0x1ca85d12), WTCP(0x7cb0193a, 0x1cee051d), + WTCP(0x7c9fdd7b, 0x1d33a422), WTCP(0x7c8f7add, 0x1d793a0b), WTCP(0x7c7ef164, 0x1dbec6c3), + WTCP(0x7c6e4115, 0x1e044a33), WTCP(0x7c5d69f6, 0x1e49c447), WTCP(0x7c4c6c0d, 0x1e8f34e8), + WTCP(0x7c3b475d, 0x1ed49c00), WTCP(0x7c29fbed, 0x1f19f97b), WTCP(0x7c1889c3, 0x1f5f4d42), + WTCP(0x7c06f0e2, 0x1fa49740), WTCP(0x7bf53152, 0x1fe9d75f), WTCP(0x7be34b17, 0x202f0d8a), + WTCP(0x7bd13e38, 0x207439aa), WTCP(0x7bbf0ab9, 0x20b95bac), WTCP(0x7bacb0a0, 0x20fe7378), + WTCP(0x7b9a2ff4, 0x214380f9), WTCP(0x7b8788b9, 0x2188841a), WTCP(0x7b74baf7, 0x21cd7cc5), + WTCP(0x7b61c6b2, 0x22126ae5), WTCP(0x7b4eabf0, 0x22574e65), WTCP(0x7b3b6ab8, 0x229c272e), + WTCP(0x7b28030f, 0x22e0f52b), WTCP(0x7b1474fc, 0x2325b847), WTCP(0x7b00c085, 0x236a706d), + WTCP(0x7aece5af, 0x23af1d86), WTCP(0x7ad8e481, 0x23f3bf7e), WTCP(0x7ac4bd02, 0x2438563f), + WTCP(0x7ab06f36, 0x247ce1b4), WTCP(0x7a9bfb26, 0x24c161c7), WTCP(0x7a8760d7, 0x2505d663), + WTCP(0x7a72a050, 0x254a3f72), WTCP(0x7a5db997, 0x258e9ce0), WTCP(0x7a48acb2, 0x25d2ee97), + WTCP(0x7a3379a8, 0x26173481), WTCP(0x7a1e2081, 0x265b6e8a), WTCP(0x7a08a141, 0x269f9c9c), + WTCP(0x79f2fbf1, 0x26e3bea1), WTCP(0x79dd3097, 0x2727d485), WTCP(0x79c73f3a, 0x276bde33), + WTCP(0x79b127e0, 0x27afdb94), WTCP(0x799aea91, 0x27f3cc94), WTCP(0x79848753, 0x2837b11e), + WTCP(0x796dfe2d, 0x287b891c), WTCP(0x79574f27, 0x28bf547a), WTCP(0x79407a47, 0x29031322), + WTCP(0x79297f95, 0x2946c4ff), WTCP(0x79125f18, 0x298a69fc), WTCP(0x78fb18d6, 0x29ce0204), + WTCP(0x78e3acd8, 0x2a118d01), WTCP(0x78cc1b25, 0x2a550adf), WTCP(0x78b463c3, 0x2a987b89), + WTCP(0x789c86bb, 0x2adbdee9), WTCP(0x78848413, 0x2b1f34eb), WTCP(0x786c5bd4, 0x2b627d79), + WTCP(0x78540e04, 0x2ba5b87f), WTCP(0x783b9aac, 0x2be8e5e8), WTCP(0x782301d2, 0x2c2c059e), + WTCP(0x780a4380, 0x2c6f178d), WTCP(0x77f15fbb, 0x2cb21ba0), WTCP(0x77d8568d, 0x2cf511c2), + WTCP(0x77bf27fd, 0x2d37f9dd), WTCP(0x77a5d413, 0x2d7ad3de), WTCP(0x778c5ad6, 0x2dbd9faf), + WTCP(0x7772bc4f, 0x2e005d3c), WTCP(0x7758f885, 0x2e430c6f), WTCP(0x773f0f81, 0x2e85ad34), + WTCP(0x7725014b, 0x2ec83f76), WTCP(0x770acdeb, 0x2f0ac320), WTCP(0x76f07569, 0x2f4d381e), + WTCP(0x76d5f7cd, 0x2f8f9e5a), WTCP(0x76bb5520, 0x2fd1f5c1), WTCP(0x76a08d6a, 0x30143e3d), + WTCP(0x7685a0b2, 0x305677ba), WTCP(0x766a8f03, 0x3098a222), WTCP(0x764f5863, 0x30dabd63), + WTCP(0x7633fcdc, 0x311cc966), WTCP(0x76187c76, 0x315ec617), WTCP(0x75fcd739, 0x31a0b362), + WTCP(0x75e10d2f, 0x31e29131), WTCP(0x75c51e60, 0x32245f72), WTCP(0x75a90ad4, 0x32661e0e), + WTCP(0x758cd295, 0x32a7ccf2), WTCP(0x757075ab, 0x32e96c09), WTCP(0x7553f41f, 0x332afb3e), + WTCP(0x75374dfa, 0x336c7a7d), WTCP(0x751a8345, 0x33ade9b2), WTCP(0x74fd9409, 0x33ef48c8), + WTCP(0x74e0804f, 0x343097ab), WTCP(0x74c3481f, 0x3471d647), WTCP(0x74a5eb84, 0x34b30487), + WTCP(0x74886a86, 0x34f42256), WTCP(0x746ac52e, 0x35352fa1), WTCP(0x744cfb86, 0x35762c53), + WTCP(0x742f0d97, 0x35b71858), WTCP(0x7410fb6a, 0x35f7f39b), WTCP(0x73f2c509, 0x3638be09), + WTCP(0x73d46a7d, 0x3679778d), WTCP(0x73b5ebd0, 0x36ba2013), WTCP(0x7397490b, 0x36fab787), + WTCP(0x73788237, 0x373b3dd5), WTCP(0x7359975f, 0x377bb2e8), WTCP(0x733a888b, 0x37bc16ad), + WTCP(0x731b55c6, 0x37fc690f), WTCP(0x72fbff1a, 0x383ca9fb), WTCP(0x72dc848f, 0x387cd95b), + WTCP(0x72bce631, 0x38bcf71d), WTCP(0x729d2408, 0x38fd032d), WTCP(0x727d3e1f, 0x393cfd75), + WTCP(0x725d347f, 0x397ce5e3), WTCP(0x723d0733, 0x39bcbc62), WTCP(0x721cb645, 0x39fc80df), + WTCP(0x71fc41be, 0x3a3c3345), WTCP(0x71dba9aa, 0x3a7bd381), WTCP(0x71baee11, 0x3abb617f), + WTCP(0x719a0eff, 0x3afadd2b), WTCP(0x71790c7d, 0x3b3a4671), WTCP(0x7157e696, 0x3b799d3e), + WTCP(0x71369d54, 0x3bb8e17d), WTCP(0x711530c1, 0x3bf8131b), WTCP(0x70f3a0e8, 0x3c373205), + WTCP(0x70d1edd4, 0x3c763e26), WTCP(0x70b0178f, 0x3cb5376b), WTCP(0x708e1e23, 0x3cf41dc0), + WTCP(0x706c019b, 0x3d32f112), WTCP(0x7049c202, 0x3d71b14d), WTCP(0x70275f63, 0x3db05e5d), + WTCP(0x7004d9c7, 0x3deef830), WTCP(0x6fe2313b, 0x3e2d7eb0), WTCP(0x6fbf65c8, 0x3e6bf1cc), + WTCP(0x6f9c7779, 0x3eaa516f), WTCP(0x6f79665a, 0x3ee89d86), WTCP(0x6f563276, 0x3f26d5fd), + WTCP(0x6f32dbd7, 0x3f64fac2), WTCP(0x6f0f6288, 0x3fa30bc0), WTCP(0x6eebc694, 0x3fe108e5), + WTCP(0x6ec80808, 0x401ef21d), WTCP(0x6ea426ed, 0x405cc754), WTCP(0x6e80234e, 0x409a8878), + WTCP(0x6e5bfd38, 0x40d83575), WTCP(0x6e37b4b6, 0x4115ce38), WTCP(0x6e1349d2, 0x415352ad), + WTCP(0x6deebc98, 0x4190c2c3), WTCP(0x6dca0d14, 0x41ce1e64), WTCP(0x6da53b50, 0x420b657f), + WTCP(0x6d804759, 0x42489800), WTCP(0x6d5b313a, 0x4285b5d4), WTCP(0x6d35f8ff, 0x42c2bee7), + WTCP(0x6d109eb2, 0x42ffb328), WTCP(0x6ceb2260, 0x433c9283), WTCP(0x6cc58415, 0x43795ce4), + WTCP(0x6c9fc3dc, 0x43b6123a), WTCP(0x6c79e1c1, 0x43f2b270), WTCP(0x6c53ddd0, 0x442f3d75), + WTCP(0x6c2db815, 0x446bb335), WTCP(0x6c07709b, 0x44a8139d), WTCP(0x6be1076e, 0x44e45e9b), + WTCP(0x6bba7c9b, 0x4520941b), WTCP(0x6b93d02d, 0x455cb40c), WTCP(0x6b6d0232, 0x4598be59), + WTCP(0x6b4612b3, 0x45d4b2f1), WTCP(0x6b1f01bf, 0x461091c1), WTCP(0x6af7cf60, 0x464c5ab6), + WTCP(0x6ad07ba4, 0x46880dbd), WTCP(0x6aa90696, 0x46c3aac5), WTCP(0x6a817043, 0x46ff31b9), + WTCP(0x6a59b8b7, 0x473aa288), WTCP(0x6a31dfff, 0x4775fd1f), WTCP(0x6a09e626, 0x47b1416c), + WTCP(0x69e1cb3a, 0x47ec6f5b), WTCP(0x69b98f47, 0x482786dc), WTCP(0x6991325a, 0x486287da), + WTCP(0x6968b47e, 0x489d7245), WTCP(0x694015c2, 0x48d84609), WTCP(0x69175630, 0x49130314), + WTCP(0x68ee75d7, 0x494da953), WTCP(0x68c574c3, 0x498838b6), WTCP(0x689c5300, 0x49c2b128), + WTCP(0x6873109c, 0x49fd1298), WTCP(0x6849ada3, 0x4a375cf4), WTCP(0x68202a22, 0x4a71902a), + WTCP(0x67f68626, 0x4aabac27), WTCP(0x67ccc1bd, 0x4ae5b0d9), WTCP(0x67a2dcf3, 0x4b1f9e2f), + WTCP(0x6778d7d5, 0x4b597416), WTCP(0x674eb270, 0x4b93327b), WTCP(0x67246cd3, 0x4bccd94e), + WTCP(0x66fa0708, 0x4c06687c), WTCP(0x66cf811f, 0x4c3fdff3), WTCP(0x66a4db24, 0x4c793fa1), + WTCP(0x667a1524, 0x4cb28775), WTCP(0x664f2f2e, 0x4cebb75c), WTCP(0x6624294d, 0x4d24cf44), + WTCP(0x65f90390, 0x4d5dcf1c), WTCP(0x65cdbe05, 0x4d96b6d3), WTCP(0x65a258b7, 0x4dcf8655), + WTCP(0x6576d3b6, 0x4e083d93), WTCP(0x654b2f0f, 0x4e40dc78), WTCP(0x651f6acf, 0x4e7962f6), + WTCP(0x64f38704, 0x4eb1d0f8), WTCP(0x64c783bc, 0x4eea266f), WTCP(0x649b6104, 0x4f226348), + WTCP(0x646f1eeb, 0x4f5a8772), WTCP(0x6442bd7d, 0x4f9292db), WTCP(0x64163cc9, 0x4fca8572), + WTCP(0x63e99cdd, 0x50025f26), WTCP(0x63bcddc6, 0x503a1fe4), WTCP(0x638fff93, 0x5071c79c), + WTCP(0x63630252, 0x50a9563d), WTCP(0x6335e610, 0x50e0cbb4), WTCP(0x6308aadc, 0x511827f0), + WTCP(0x62db50c4, 0x514f6ae1), WTCP(0x62add7d5, 0x51869476), WTCP(0x6280401f, 0x51bda49c), + WTCP(0x625289af, 0x51f49b42), WTCP(0x6224b494, 0x522b7859), WTCP(0x61f6c0dc, 0x52623bcd), + WTCP(0x61c8ae94, 0x5298e58f), WTCP(0x619a7dcd, 0x52cf758e), WTCP(0x616c2e93, 0x5305ebb8), + WTCP(0x613dc0f6, 0x533c47fc), WTCP(0x610f3504, 0x53728a49), WTCP(0x60e08acb, 0x53a8b28f), + WTCP(0x60b1c25b, 0x53dec0bc), WTCP(0x6082dbc0, 0x5414b4c0), WTCP(0x6053d70c, 0x544a8e8a), + WTCP(0x6024b44b, 0x54804e09), WTCP(0x5ff5738c, 0x54b5f32c), WTCP(0x5fc614df, 0x54eb7de2), + WTCP(0x5f969852, 0x5520ee1c), WTCP(0x5f66fdf4, 0x555643c8), WTCP(0x5f3745d4, 0x558b7ed5), + WTCP(0x5f077001, 0x55c09f33), WTCP(0x5ed77c89, 0x55f5a4d2), WTCP(0x5ea76b7c, 0x562a8fa0), + WTCP(0x5e773ce8, 0x565f5f8e), WTCP(0x5e46f0dc, 0x5694148a), WTCP(0x5e168769, 0x56c8ae85), + WTCP(0x5de6009c, 0x56fd2d6e), WTCP(0x5db55c85, 0x57319134), WTCP(0x5d849b33, 0x5765d9c8), + WTCP(0x5d53bcb5, 0x579a0719), WTCP(0x5d22c11b, 0x57ce1916), WTCP(0x5cf1a874, 0x58020fb0), + WTCP(0x5cc072ce, 0x5835ead6), WTCP(0x5c8f203a, 0x5869aa78), WTCP(0x5c5db0c7, 0x589d4e87), + WTCP(0x5c2c2484, 0x58d0d6f0), WTCP(0x5bfa7b81, 0x590443a6), WTCP(0x5bc8b5cd, 0x59379497), + WTCP(0x5b96d378, 0x596ac9b5), WTCP(0x5b64d491, 0x599de2ed), WTCP(0x5b32b928, 0x59d0e032), + WTCP(0x5b00814c, 0x5a03c172), WTCP(0x5ace2d0e, 0x5a36869f), WTCP(0x5a9bbc7c, 0x5a692fa7) +}; +#endif + +const PWord32 SineWindow960[480] = { + WTCP(0x7ffffd30, 0x001aceea), WTCP(0x7fffe6bb, 0x00506cb9), WTCP(0x7fffb9d0, 0x00860a79), + WTCP(0x7fff7670, 0x00bba822), WTCP(0x7fff1c9a, 0x00f145ab), WTCP(0x7ffeac4f, 0x0126e309), + WTCP(0x7ffe258f, 0x015c8033), WTCP(0x7ffd8859, 0x01921d20), WTCP(0x7ffcd4af, 0x01c7b9c6), + WTCP(0x7ffc0a90, 0x01fd561d), WTCP(0x7ffb29fc, 0x0232f21a), WTCP(0x7ffa32f3, 0x02688db4), + WTCP(0x7ff92576, 0x029e28e2), WTCP(0x7ff80185, 0x02d3c39b), WTCP(0x7ff6c71f, 0x03095dd5), + WTCP(0x7ff57646, 0x033ef786), WTCP(0x7ff40ef9, 0x037490a5), WTCP(0x7ff29139, 0x03aa292a), + WTCP(0x7ff0fd06, 0x03dfc109), WTCP(0x7fef525f, 0x0415583b), WTCP(0x7fed9147, 0x044aeeb5), + WTCP(0x7febb9bc, 0x0480846e), WTCP(0x7fe9cbbf, 0x04b6195d), WTCP(0x7fe7c751, 0x04ebad79), + WTCP(0x7fe5ac71, 0x052140b7), WTCP(0x7fe37b21, 0x0556d30f), WTCP(0x7fe13360, 0x058c6478), + WTCP(0x7fded52f, 0x05c1f4e7), WTCP(0x7fdc608e, 0x05f78453), WTCP(0x7fd9d57e, 0x062d12b3), + WTCP(0x7fd73400, 0x06629ffe), WTCP(0x7fd47c13, 0x06982c2b), WTCP(0x7fd1adb8, 0x06cdb72f), + WTCP(0x7fcec8f0, 0x07034101), WTCP(0x7fcbcdbb, 0x0738c998), WTCP(0x7fc8bc1a, 0x076e50eb), + WTCP(0x7fc5940d, 0x07a3d6f0), WTCP(0x7fc25595, 0x07d95b9e), WTCP(0x7fbf00b2, 0x080edeec), + WTCP(0x7fbb9566, 0x084460cf), WTCP(0x7fb813af, 0x0879e140), WTCP(0x7fb47b90, 0x08af6033), + WTCP(0x7fb0cd09, 0x08e4dda0), WTCP(0x7fad081a, 0x091a597e), WTCP(0x7fa92cc4, 0x094fd3c3), + WTCP(0x7fa53b08, 0x09854c66), WTCP(0x7fa132e7, 0x09bac35d), WTCP(0x7f9d1460, 0x09f0389f), + WTCP(0x7f98df76, 0x0a25ac22), WTCP(0x7f949428, 0x0a5b1dde), WTCP(0x7f903278, 0x0a908dc9), + WTCP(0x7f8bba65, 0x0ac5fbd9), WTCP(0x7f872bf2, 0x0afb6805), WTCP(0x7f82871e, 0x0b30d244), + WTCP(0x7f7dcbeb, 0x0b663a8c), WTCP(0x7f78fa5a, 0x0b9ba0d5), WTCP(0x7f74126a, 0x0bd10513), + WTCP(0x7f6f141e, 0x0c06673f), WTCP(0x7f69ff75, 0x0c3bc74f), WTCP(0x7f64d472, 0x0c71253a), + WTCP(0x7f5f9314, 0x0ca680f5), WTCP(0x7f5a3b5d, 0x0cdbda79), WTCP(0x7f54cd4e, 0x0d1131ba), + WTCP(0x7f4f48e7, 0x0d4686b1), WTCP(0x7f49ae29, 0x0d7bd954), WTCP(0x7f43fd17, 0x0db12998), + WTCP(0x7f3e35af, 0x0de67776), WTCP(0x7f3857f5, 0x0e1bc2e4), WTCP(0x7f3263e8, 0x0e510bd7), + WTCP(0x7f2c5989, 0x0e865248), WTCP(0x7f2638da, 0x0ebb962c), WTCP(0x7f2001dc, 0x0ef0d77b), + WTCP(0x7f19b490, 0x0f26162a), WTCP(0x7f1350f7, 0x0f5b5231), WTCP(0x7f0cd711, 0x0f908b86), + WTCP(0x7f0646e1, 0x0fc5c220), WTCP(0x7effa068, 0x0ffaf5f6), WTCP(0x7ef8e3a5, 0x103026fe), + WTCP(0x7ef2109c, 0x1065552e), WTCP(0x7eeb274c, 0x109a807e), WTCP(0x7ee427b8, 0x10cfa8e5), + WTCP(0x7edd11e0, 0x1104ce58), WTCP(0x7ed5e5c5, 0x1139f0cf), WTCP(0x7ecea36a, 0x116f1040), + WTCP(0x7ec74ace, 0x11a42ca2), WTCP(0x7ebfdbf4, 0x11d945eb), WTCP(0x7eb856dd, 0x120e5c13), + WTCP(0x7eb0bb89, 0x12436f10), WTCP(0x7ea909fb, 0x12787ed8), WTCP(0x7ea14234, 0x12ad8b63), + WTCP(0x7e996435, 0x12e294a7), WTCP(0x7e916fff, 0x13179a9a), WTCP(0x7e896594, 0x134c9d34), + WTCP(0x7e8144f5, 0x13819c6b), WTCP(0x7e790e24, 0x13b69836), WTCP(0x7e70c123, 0x13eb908c), + WTCP(0x7e685df1, 0x14208562), WTCP(0x7e5fe492, 0x145576b1), WTCP(0x7e575507, 0x148a646e), + WTCP(0x7e4eaf50, 0x14bf4e91), WTCP(0x7e45f370, 0x14f43510), WTCP(0x7e3d2168, 0x152917e1), + WTCP(0x7e34393a, 0x155df6fc), WTCP(0x7e2b3ae7, 0x1592d257), WTCP(0x7e222671, 0x15c7a9ea), + WTCP(0x7e18fbd9, 0x15fc7da9), WTCP(0x7e0fbb21, 0x16314d8e), WTCP(0x7e06644b, 0x1666198d), + WTCP(0x7dfcf758, 0x169ae19f), WTCP(0x7df3744a, 0x16cfa5b9), WTCP(0x7de9db22, 0x170465d2), + WTCP(0x7de02be3, 0x173921e2), WTCP(0x7dd6668e, 0x176dd9de), WTCP(0x7dcc8b24, 0x17a28dbe), + WTCP(0x7dc299a8, 0x17d73d79), WTCP(0x7db8921b, 0x180be904), WTCP(0x7dae747f, 0x18409058), + WTCP(0x7da440d5, 0x1875336a), WTCP(0x7d99f720, 0x18a9d231), WTCP(0x7d8f9761, 0x18de6ca5), + WTCP(0x7d85219b, 0x191302bb), WTCP(0x7d7a95ce, 0x1947946c), WTCP(0x7d6ff3fd, 0x197c21ac), + WTCP(0x7d653c2a, 0x19b0aa75), WTCP(0x7d5a6e56, 0x19e52ebb), WTCP(0x7d4f8a84, 0x1a19ae76), + WTCP(0x7d4490b5, 0x1a4e299c), WTCP(0x7d3980eb, 0x1a82a025), WTCP(0x7d2e5b29, 0x1ab71208), + WTCP(0x7d231f6f, 0x1aeb7f3a), WTCP(0x7d17cdc1, 0x1b1fe7b3), WTCP(0x7d0c6620, 0x1b544b6a), + WTCP(0x7d00e88e, 0x1b88aa55), WTCP(0x7cf5550d, 0x1bbd046c), WTCP(0x7ce9aba0, 0x1bf159a4), + WTCP(0x7cddec47, 0x1c25a9f5), WTCP(0x7cd21706, 0x1c59f557), WTCP(0x7cc62bde, 0x1c8e3bbe), + WTCP(0x7cba2ad2, 0x1cc27d23), WTCP(0x7cae13e3, 0x1cf6b97c), WTCP(0x7ca1e714, 0x1d2af0c0), + WTCP(0x7c95a466, 0x1d5f22e6), WTCP(0x7c894bdd, 0x1d934fe5), WTCP(0x7c7cdd7a, 0x1dc777b3), + WTCP(0x7c70593f, 0x1dfb9a48), WTCP(0x7c63bf2e, 0x1e2fb79a), WTCP(0x7c570f4a, 0x1e63cfa0), + WTCP(0x7c4a4995, 0x1e97e251), WTCP(0x7c3d6e12, 0x1ecbefa3), WTCP(0x7c307cc1, 0x1efff78f), + WTCP(0x7c2375a7, 0x1f33fa0a), WTCP(0x7c1658c4, 0x1f67f70b), WTCP(0x7c09261c, 0x1f9bee8a), + WTCP(0x7bfbddb0, 0x1fcfe07d), WTCP(0x7bee7f84, 0x2003ccdb), WTCP(0x7be10b98, 0x2037b39b), + WTCP(0x7bd381f0, 0x206b94b4), WTCP(0x7bc5e28f, 0x209f701c), WTCP(0x7bb82d75, 0x20d345cb), + WTCP(0x7baa62a7, 0x210715b8), WTCP(0x7b9c8225, 0x213adfda), WTCP(0x7b8e8bf4, 0x216ea426), + WTCP(0x7b808014, 0x21a26295), WTCP(0x7b725e89, 0x21d61b1d), WTCP(0x7b642755, 0x2209cdb6), + WTCP(0x7b55da7b, 0x223d7a55), WTCP(0x7b4777fd, 0x227120f3), WTCP(0x7b38ffdd, 0x22a4c185), + WTCP(0x7b2a721e, 0x22d85c03), WTCP(0x7b1bcec3, 0x230bf064), WTCP(0x7b0d15cf, 0x233f7e9f), + WTCP(0x7afe4743, 0x237306ab), WTCP(0x7aef6323, 0x23a6887e), WTCP(0x7ae06970, 0x23da0410), + WTCP(0x7ad15a2f, 0x240d7958), WTCP(0x7ac23560, 0x2440e84c), WTCP(0x7ab2fb08, 0x247450e4), + WTCP(0x7aa3ab28, 0x24a7b316), WTCP(0x7a9445c4, 0x24db0eda), WTCP(0x7a84cadd, 0x250e6427), + WTCP(0x7a753a78, 0x2541b2f3), WTCP(0x7a659495, 0x2574fb35), WTCP(0x7a55d939, 0x25a83ce5), + WTCP(0x7a460867, 0x25db77fa), WTCP(0x7a36221f, 0x260eac6a), WTCP(0x7a262667, 0x2641da2c), + WTCP(0x7a16153f, 0x26750139), WTCP(0x7a05eeac, 0x26a82185), WTCP(0x79f5b2b0, 0x26db3b0a), + WTCP(0x79e5614e, 0x270e4dbd), WTCP(0x79d4fa88, 0x27415996), WTCP(0x79c47e62, 0x27745e8b), + WTCP(0x79b3ecdf, 0x27a75c95), WTCP(0x79a34601, 0x27da53a9), WTCP(0x799289cb, 0x280d43bf), + WTCP(0x7981b841, 0x28402cce), WTCP(0x7970d164, 0x28730ecd), WTCP(0x795fd539, 0x28a5e9b3), + WTCP(0x794ec3c2, 0x28d8bd78), WTCP(0x793d9d02, 0x290b8a11), WTCP(0x792c60fd, 0x293e4f77), + WTCP(0x791b0fb4, 0x29710da1), WTCP(0x7909a92c, 0x29a3c485), WTCP(0x78f82d67, 0x29d6741a), + WTCP(0x78e69c68, 0x2a091c59), WTCP(0x78d4f633, 0x2a3bbd37), WTCP(0x78c33aca, 0x2a6e56ac), + WTCP(0x78b16a31, 0x2aa0e8af), WTCP(0x789f846a, 0x2ad37338), WTCP(0x788d897a, 0x2b05f63d), + WTCP(0x787b7963, 0x2b3871b5), WTCP(0x78695427, 0x2b6ae598), WTCP(0x785719cb, 0x2b9d51dd), + WTCP(0x7844ca52, 0x2bcfb67b), WTCP(0x783265bf, 0x2c021368), WTCP(0x781fec14, 0x2c34689e), + WTCP(0x780d5d56, 0x2c66b611), WTCP(0x77fab988, 0x2c98fbba), WTCP(0x77e800ac, 0x2ccb3990), + WTCP(0x77d532c6, 0x2cfd6f8a), WTCP(0x77c24fda, 0x2d2f9d9f), WTCP(0x77af57eb, 0x2d61c3c6), + WTCP(0x779c4afb, 0x2d93e1f7), WTCP(0x7789290f, 0x2dc5f829), WTCP(0x7775f229, 0x2df80653), + WTCP(0x7762a64e, 0x2e2a0c6b), WTCP(0x774f4580, 0x2e5c0a6b), WTCP(0x773bcfc3, 0x2e8e0047), + WTCP(0x7728451b, 0x2ebfedf9), WTCP(0x7714a58a, 0x2ef1d377), WTCP(0x7700f114, 0x2f23b0b8), + WTCP(0x76ed27bd, 0x2f5585b4), WTCP(0x76d94988, 0x2f875262), WTCP(0x76c55679, 0x2fb916b9), + WTCP(0x76b14e92, 0x2fead2b0), WTCP(0x769d31d9, 0x301c863f), WTCP(0x7689004f, 0x304e315d), + WTCP(0x7674b9f9, 0x307fd401), WTCP(0x76605eda, 0x30b16e22), WTCP(0x764beef7, 0x30e2ffb9), + WTCP(0x76376a51, 0x311488bb), WTCP(0x7622d0ee, 0x31460921), WTCP(0x760e22d0, 0x317780e2), + WTCP(0x75f95ffb, 0x31a8eff5), WTCP(0x75e48874, 0x31da5651), WTCP(0x75cf9c3c, 0x320bb3ee), + WTCP(0x75ba9b59, 0x323d08c3), WTCP(0x75a585ce, 0x326e54c7), WTCP(0x75905b9f, 0x329f97f2), + WTCP(0x757b1ccf, 0x32d0d23b), WTCP(0x7565c961, 0x3302039a), WTCP(0x7550615b, 0x33332c06), + WTCP(0x753ae4bf, 0x33644b76), WTCP(0x75255392, 0x339561e1), WTCP(0x750fadd6, 0x33c66f3f), + WTCP(0x74f9f390, 0x33f77388), WTCP(0x74e424c5, 0x34286eb3), WTCP(0x74ce4176, 0x345960b6), + WTCP(0x74b849a9, 0x348a498b), WTCP(0x74a23d61, 0x34bb2927), WTCP(0x748c1ca3, 0x34ebff83), + WTCP(0x7475e771, 0x351ccc95), WTCP(0x745f9dd0, 0x354d9056), WTCP(0x74493fc4, 0x357e4abd), + WTCP(0x7432cd51, 0x35aefbc1), WTCP(0x741c467a, 0x35dfa35a), WTCP(0x7405ab44, 0x3610417e), + WTCP(0x73eefbb2, 0x3640d627), WTCP(0x73d837c9, 0x3671614a), WTCP(0x73c15f8c, 0x36a1e2e0), + WTCP(0x73aa7300, 0x36d25ae0), WTCP(0x73937229, 0x3702c942), WTCP(0x737c5d0a, 0x37332dfc), + WTCP(0x736533a8, 0x37638907), WTCP(0x734df606, 0x3793da5a), WTCP(0x7336a42a, 0x37c421ed), + WTCP(0x731f3e16, 0x37f45fb7), WTCP(0x7307c3cf, 0x382493b0), WTCP(0x72f03559, 0x3854bdce), + WTCP(0x72d892b9, 0x3884de0b), WTCP(0x72c0dbf2, 0x38b4f45d), WTCP(0x72a91108, 0x38e500bb), + WTCP(0x72913200, 0x3915031e), WTCP(0x72793edf, 0x3944fb7d), WTCP(0x726137a7, 0x3974e9d0), + WTCP(0x72491c5d, 0x39a4ce0e), WTCP(0x7230ed06, 0x39d4a82e), WTCP(0x7218a9a6, 0x3a047829), + WTCP(0x72005241, 0x3a343df6), WTCP(0x71e7e6db, 0x3a63f98d), WTCP(0x71cf6779, 0x3a93aae5), + WTCP(0x71b6d41f, 0x3ac351f5), WTCP(0x719e2cd1, 0x3af2eeb7), WTCP(0x71857194, 0x3b228120), + WTCP(0x716ca26b, 0x3b520929), WTCP(0x7153bf5c, 0x3b8186ca), WTCP(0x713ac86a, 0x3bb0f9f9), + WTCP(0x7121bd9b, 0x3be062b0), WTCP(0x71089ef1, 0x3c0fc0e5), WTCP(0x70ef6c73, 0x3c3f1490), + WTCP(0x70d62624, 0x3c6e5da9), WTCP(0x70bccc08, 0x3c9d9c28), WTCP(0x70a35e25, 0x3cccd004), + WTCP(0x7089dc7e, 0x3cfbf935), WTCP(0x70704718, 0x3d2b17b3), WTCP(0x70569df7, 0x3d5a2b75), + WTCP(0x703ce121, 0x3d893473), WTCP(0x70231099, 0x3db832a5), WTCP(0x70092c64, 0x3de72603), + WTCP(0x6fef3487, 0x3e160e85), WTCP(0x6fd52906, 0x3e44ec22), WTCP(0x6fbb09e6, 0x3e73bed1), + WTCP(0x6fa0d72b, 0x3ea2868c), WTCP(0x6f8690da, 0x3ed14349), WTCP(0x6f6c36f7, 0x3efff500), + WTCP(0x6f51c988, 0x3f2e9baa), WTCP(0x6f374890, 0x3f5d373e), WTCP(0x6f1cb415, 0x3f8bc7b3), + WTCP(0x6f020c1b, 0x3fba4d02), WTCP(0x6ee750a7, 0x3fe8c723), WTCP(0x6ecc81bd, 0x4017360d), + WTCP(0x6eb19f63, 0x404599b8), WTCP(0x6e96a99c, 0x4073f21d), WTCP(0x6e7ba06e, 0x40a23f32), + WTCP(0x6e6083dd, 0x40d080f0), WTCP(0x6e4553ef, 0x40feb74f), WTCP(0x6e2a10a7, 0x412ce246), + WTCP(0x6e0eba0b, 0x415b01ce), WTCP(0x6df3501f, 0x418915de), WTCP(0x6dd7d2e9, 0x41b71e6e), + WTCP(0x6dbc426d, 0x41e51b77), WTCP(0x6da09eb0, 0x42130cf0), WTCP(0x6d84e7b6, 0x4240f2d1), + WTCP(0x6d691d86, 0x426ecd12), WTCP(0x6d4d4022, 0x429c9baa), WTCP(0x6d314f92, 0x42ca5e93), + WTCP(0x6d154bd8, 0x42f815c4), WTCP(0x6cf934fb, 0x4325c135), WTCP(0x6cdd0aff, 0x435360de), + WTCP(0x6cc0cde9, 0x4380f4b6), WTCP(0x6ca47dbe, 0x43ae7cb6), WTCP(0x6c881a83, 0x43dbf8d7), + WTCP(0x6c6ba43d, 0x4409690f), WTCP(0x6c4f1af2, 0x4436cd57), WTCP(0x6c327ea5, 0x446425a7), + WTCP(0x6c15cf5c, 0x449171f7), WTCP(0x6bf90d1c, 0x44beb240), WTCP(0x6bdc37eb, 0x44ebe678), + WTCP(0x6bbf4fcc, 0x45190e99), WTCP(0x6ba254c6, 0x45462a9a), WTCP(0x6b8546dd, 0x45733a73), + WTCP(0x6b682617, 0x45a03e1d), WTCP(0x6b4af278, 0x45cd358f), WTCP(0x6b2dac05, 0x45fa20c2), + WTCP(0x6b1052c5, 0x4626ffae), WTCP(0x6af2e6bb, 0x4653d24a), WTCP(0x6ad567ee, 0x46809890), + WTCP(0x6ab7d662, 0x46ad5277), WTCP(0x6a9a321c, 0x46d9fff7), WTCP(0x6a7c7b22, 0x4706a109), + WTCP(0x6a5eb179, 0x473335a5), WTCP(0x6a40d526, 0x475fbdc2), WTCP(0x6a22e62f, 0x478c3959), + WTCP(0x6a04e498, 0x47b8a863), WTCP(0x69e6d067, 0x47e50ad7), WTCP(0x69c8a9a1, 0x481160ae), + WTCP(0x69aa704b, 0x483da9e0), WTCP(0x698c246b, 0x4869e664), WTCP(0x696dc606, 0x48961634), + WTCP(0x694f5522, 0x48c23948), WTCP(0x6930d1c3, 0x48ee4f98), WTCP(0x69123bf0, 0x491a591b), + WTCP(0x68f393ad, 0x494655cb), WTCP(0x68d4d8ff, 0x497245a0), WTCP(0x68b60bed, 0x499e2892), + WTCP(0x68972c7c, 0x49c9fe99), WTCP(0x68783ab1, 0x49f5c7ad), WTCP(0x68593691, 0x4a2183c7), + WTCP(0x683a2022, 0x4a4d32e0), WTCP(0x681af769, 0x4a78d4ef), WTCP(0x67fbbc6c, 0x4aa469ed), + WTCP(0x67dc6f31, 0x4acff1d2), WTCP(0x67bd0fbc, 0x4afb6c97), WTCP(0x679d9e13, 0x4b26da34), + WTCP(0x677e1a3d, 0x4b523aa1), WTCP(0x675e843e, 0x4b7d8dd7), WTCP(0x673edc1b, 0x4ba8d3cf), + WTCP(0x671f21db, 0x4bd40c7f), WTCP(0x66ff5584, 0x4bff37e2), WTCP(0x66df7719, 0x4c2a55ef), + WTCP(0x66bf86a2, 0x4c55669f), WTCP(0x669f8424, 0x4c8069ea), WTCP(0x667f6fa4, 0x4cab5fc9), + WTCP(0x665f4928, 0x4cd64834), WTCP(0x663f10b6, 0x4d012324), WTCP(0x661ec653, 0x4d2bf090), + WTCP(0x65fe6a05, 0x4d56b073), WTCP(0x65ddfbd2, 0x4d8162c3), WTCP(0x65bd7bc0, 0x4dac077b), + WTCP(0x659ce9d3, 0x4dd69e91), WTCP(0x657c4612, 0x4e0127ff), WTCP(0x655b9083, 0x4e2ba3be), + WTCP(0x653ac92a, 0x4e5611c5), WTCP(0x6519f00f, 0x4e80720d), WTCP(0x64f90537, 0x4eaac48f), + WTCP(0x64d808a7, 0x4ed50944), WTCP(0x64b6fa65, 0x4eff4024), WTCP(0x6495da78, 0x4f296927), + WTCP(0x6474a8e5, 0x4f538447), WTCP(0x645365b1, 0x4f7d917c), WTCP(0x643210e3, 0x4fa790be), + WTCP(0x6410aa80, 0x4fd18206), WTCP(0x63ef328f, 0x4ffb654c), WTCP(0x63cda915, 0x50253a8b), + WTCP(0x63ac0e18, 0x504f01b9), WTCP(0x638a619e, 0x5078bad0), WTCP(0x6368a3ac, 0x50a265c8), + WTCP(0x6346d44a, 0x50cc029b), WTCP(0x6324f37c, 0x50f59140), WTCP(0x63030149, 0x511f11b1), + WTCP(0x62e0fdb7, 0x514883e6), WTCP(0x62bee8cb, 0x5171e7d8), WTCP(0x629cc28c, 0x519b3d80), + WTCP(0x627a8aff, 0x51c484d6), WTCP(0x6258422b, 0x51edbdd3), WTCP(0x6235e815, 0x5216e870), + WTCP(0x62137cc4, 0x524004a6), WTCP(0x61f1003e, 0x5269126e), WTCP(0x61ce7289, 0x529211c0), + WTCP(0x61abd3aa, 0x52bb0295), WTCP(0x618923a8, 0x52e3e4e5), WTCP(0x61666289, 0x530cb8ab), + WTCP(0x61439053, 0x53357dde), WTCP(0x6120ad0c, 0x535e3478), WTCP(0x60fdb8ba, 0x5386dc71), + WTCP(0x60dab364, 0x53af75c2), WTCP(0x60b79d0f, 0x53d80064), WTCP(0x609475c2, 0x54007c50), + WTCP(0x60713d83, 0x5428e97f), WTCP(0x604df458, 0x545147ea), WTCP(0x602a9a47, 0x54799789), + WTCP(0x60072f56, 0x54a1d856), WTCP(0x5fe3b38d, 0x54ca0a4a), WTCP(0x5fc026f0, 0x54f22d5d), + WTCP(0x5f9c8986, 0x551a4188), WTCP(0x5f78db55, 0x554246c5), WTCP(0x5f551c64, 0x556a3d0c), + WTCP(0x5f314cb9, 0x55922457), WTCP(0x5f0d6c5b, 0x55b9fc9d), WTCP(0x5ee97b4e, 0x55e1c5da), + WTCP(0x5ec5799b, 0x56098004), WTCP(0x5ea16746, 0x56312b16), WTCP(0x5e7d4457, 0x5658c709), + WTCP(0x5e5910d4, 0x568053d5), WTCP(0x5e34ccc3, 0x56a7d173), WTCP(0x5e10782a, 0x56cf3fdd), + WTCP(0x5dec1310, 0x56f69f0c), WTCP(0x5dc79d7b, 0x571deef9), WTCP(0x5da31772, 0x57452f9d), + WTCP(0x5d7e80fb, 0x576c60f0), WTCP(0x5d59da1d, 0x579382ed), WTCP(0x5d3522dd, 0x57ba958c), + WTCP(0x5d105b43, 0x57e198c6), WTCP(0x5ceb8355, 0x58088c96), WTCP(0x5cc69b18, 0x582f70f2), + WTCP(0x5ca1a295, 0x585645d6), WTCP(0x5c7c99d0, 0x587d0b3a), WTCP(0x5c5780d2, 0x58a3c117), + WTCP(0x5c3257a0, 0x58ca6767), WTCP(0x5c0d1e40, 0x58f0fe22), WTCP(0x5be7d4ba, 0x59178542), + WTCP(0x5bc27b13, 0x593dfcc1), WTCP(0x5b9d1153, 0x59646497), WTCP(0x5b779780, 0x598abcbe), + WTCP(0x5b520da0, 0x59b1052e), WTCP(0x5b2c73ba, 0x59d73de2), WTCP(0x5b06c9d6, 0x59fd66d3), + WTCP(0x5ae10ff8, 0x5a237ff9), WTCP(0x5abb4628, 0x5a49894f), WTCP(0x5a956c6d, 0x5a6f82cd), +}; +# endif + +// fs 48 32 24 16 8 +// ms +-------------------- +// 10.0 | 480 320 240 160 80 +// 7.5 | 360 240 180 120 60 +// 5.0 | 240 160 120 80 40 +// 2.5 | 120 80 60 40 20 + +void BASOP_getTables( +#ifdef ENABLE_HR_MODE + const PWord32 **twiddle, const PWord32 **sin, +#else + const PWord16 **twiddle, const PWord16 **sin, +#endif + Word16 *sin_step, Word16 length) +{ + SWITCH (length) + { + case 20: + *sin = SineTable320; + move16(); + *sin_step = 32; + move16(); + *twiddle = SineWindow20; + move16(); + BREAK; + case 40: + *sin = SineTable320; + move16(); + *sin_step = 16; + move16(); + *twiddle = SineWindow40; + move16(); + BREAK; + case 60: + *sin = SineTable480; + move16(); + *sin_step = 16; + move16(); + *twiddle = SineWindow60; + move16(); + BREAK; + case 80: + *sin = SineTable320; + move16(); + *sin_step = 8; + move16(); + *twiddle = SineWindow80; + move16(); + BREAK; + case 120: + *sin = SineTable480; + move16(); + *sin_step = 8; + move16(); + *twiddle = SineWindow120; + move16(); + BREAK; + case 160: + *sin = SineTable320; + move16(); + *sin_step = 4; + move16(); + *twiddle = SineWindow160; + move16(); + BREAK; + case 180: + *sin = SineTable360; + move16(); + *sin_step = 4; + move16(); + *twiddle = SineWindow180; + move16(); + BREAK; + case 240: + *sin = SineTable480; + move16(); + *sin_step = 4; + move16(); + *twiddle = SineWindow240; + move16(); + BREAK; + case 320: + *sin = SineTable320; + move16(); + *sin_step = 2; + move16(); + *twiddle = SineWindow320; + move16(); + BREAK; + case 360: + *sin = SineTable360; + move16(); + *sin_step = 2; + move16(); + *twiddle = SineWindow360; + move16(); + BREAK; + case 480: + *sin = SineTable480; + move16(); + *sin_step = 2; + move16(); + *twiddle = SineWindow480; + move16(); + BREAK; +#ifdef ENABLE_HR_MODE +# ifdef CR8_G_ADD_75MS + case 720: + *sin = SineTable720; + move16(); + *sin_step = 2; + move16(); + *twiddle = SineWindow720; + move16(); + break; +# endif + case 960: + *sin = SineTable960; + move16(); + *sin_step = 2; + move16(); + *twiddle = SineWindow960; + move16(); + break; +#endif + default: ASSERT(0); + } +} + +const Word32 RealFFT32_twid[10] = { + 0x7fffffff, 0x00000000, 0x7d8a5f40, 0x18f8b83c, 0x7641af3d, + 0x30fbc54d, 0x6a6d98a4, 0x471cece7, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT40_twid[12] = { + 0x7fffffff, 0x00000000, 0x7e6c9251, 0x14060b68, 0x79bc384d, 0x278dde6e, + 0x720c8075, 0x3a1c5c57, 0x678dde6e, 0x4b3c8c12, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT64_twid[18] = { + 0x7fffffff, 0x00000000, 0x7f62368f, 0x0c8bd35e, 0x7d8a5f40, 0x18f8b83c, 0x7a7d055b, 0x25280c5e, 0x7641af3d, + 0x30fbc54d, 0x70e2cbc6, 0x3c56ba70, 0x6a6d98a4, 0x471cece7, 0x62f201ac, 0x5133cc94, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT80_twid[22] = { + 0x7fffffff, 0x00000000, 0x7f9afcb9, 0x0a0af299, 0x7e6c9251, 0x14060b68, 0x7c769e18, 0x1de189a6, + 0x79bc384d, 0x278dde6e, 0x7641af3d, 0x30fbc54d, 0x720c8075, 0x3a1c5c57, 0x6d23501b, 0x42e13ba4, + 0x678dde6e, 0x4b3c8c12, 0x6154fb91, 0x53211d18, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT96_twid[26] = { + 0x7fffffff, 0x00000000, 0x7fb9d759, 0x085f2137, 0x7ee7aa4c, 0x10b5150f, 0x7d8a5f40, 0x18f8b83c, 0x7ba3751d, + 0x2120fb83, 0x793501a9, 0x2924edac, 0x7641af3d, 0x30fbc54d, 0x72ccb9db, 0x389cea72, 0x6ed9eba1, 0x40000000, + 0x6a6d98a4, 0x471cece7, 0x658c9a2d, 0x4debe4fe, 0x603c496c, 0x54657194, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT128_twid[34] = { + 0x7fffffff, 0x00000000, 0x7fd8878e, 0x0647d97c, 0x7f62368f, 0x0c8bd35e, 0x7e9d55fc, 0x12c8106f, 0x7d8a5f40, + 0x18f8b83c, 0x7c29fbee, 0x1f19f97b, 0x7a7d055b, 0x25280c5e, 0x78848414, 0x2b1f34eb, 0x7641af3d, 0x30fbc54d, + 0x73b5ebd1, 0x36ba2014, 0x70e2cbc6, 0x3c56ba70, 0x6dca0d14, 0x41ce1e65, 0x6a6d98a4, 0x471cece7, 0x66cf8120, + 0x4c3fdff4, 0x62f201ac, 0x5133cc94, 0x5ed77c8a, 0x55f5a4d2, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT192_twid[50] = { + 0x7fffffff, 0x00000000, 0x7fee74a2, 0x0430238f, 0x7fb9d759, 0x085f2137, 0x7f62368f, 0x0c8bd35e, 0x7ee7aa4c, + 0x10b5150f, 0x7e4a5426, 0x14d9c245, 0x7d8a5f40, 0x18f8b83c, 0x7ca80038, 0x1d10d5c2, 0x7ba3751d, 0x2120fb83, + 0x7a7d055b, 0x25280c5e, 0x793501a9, 0x2924edac, 0x77cbc3f2, 0x2d168792, 0x7641af3d, 0x30fbc54d, 0x74972f92, + 0x34d3957e, 0x72ccb9db, 0x389cea72, 0x70e2cbc6, 0x3c56ba70, 0x6ed9eba1, 0x40000000, 0x6cb2a837, 0x4397ba32, + 0x6a6d98a4, 0x471cece7, 0x680b5c33, 0x4a8ea111, 0x658c9a2d, 0x4debe4fe, 0x62f201ac, 0x5133cc94, 0x603c496c, + 0x54657194, 0x5d6c2f99, 0x577ff3da, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT256_twid[66] = { + 0x7fffffff, 0x00000000, 0x7ff62182, 0x03242abf, 0x7fd8878e, 0x0647d97c, 0x7fa736b4, 0x096a9049, 0x7f62368f, + 0x0c8bd35e, 0x7f0991c4, 0x0fab272b, 0x7e9d55fc, 0x12c8106f, 0x7e1d93ea, 0x15e21445, 0x7d8a5f40, 0x18f8b83c, + 0x7ce3ceb2, 0x1c0b826a, 0x7c29fbee, 0x1f19f97b, 0x7b5d039e, 0x2223a4c5, 0x7a7d055b, 0x25280c5e, 0x798a23b1, + 0x2826b928, 0x78848414, 0x2b1f34eb, 0x776c4edb, 0x2e110a62, 0x7641af3d, 0x30fbc54d, 0x7504d345, 0x33def287, + 0x73b5ebd1, 0x36ba2014, 0x72552c85, 0x398cdd32, 0x70e2cbc6, 0x3c56ba70, 0x6f5f02b2, 0x3f1749b8, 0x6dca0d14, + 0x41ce1e65, 0x6c242960, 0x447acd50, 0x6a6d98a4, 0x471cece7, 0x68a69e81, 0x49b41533, 0x66cf8120, 0x4c3fdff4, + 0x64e88926, 0x4ebfe8a5, 0x62f201ac, 0x5133cc94, 0x60ec3830, 0x539b2af0, 0x5ed77c8a, 0x55f5a4d2, 0x5cb420e0, + 0x5842dd54, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT384_twid[98] = { + 0x7fffffff, 0x00000000, 0x7ffb9d15, 0x02182427, 0x7fee74a2, 0x0430238f, 0x7fd8878e, 0x0647d97c, 0x7fb9d759, + 0x085f2137, 0x7f92661d, 0x0a75d60e, 0x7f62368f, 0x0c8bd35e, 0x7f294bfd, 0x0ea0f48c, 0x7ee7aa4c, 0x10b5150f, + 0x7e9d55fc, 0x12c8106f, 0x7e4a5426, 0x14d9c245, 0x7deeaa7a, 0x16ea0646, 0x7d8a5f40, 0x18f8b83c, 0x7d1d7958, + 0x1b05b40f, 0x7ca80038, 0x1d10d5c2, 0x7c29fbee, 0x1f19f97b, 0x7ba3751d, 0x2120fb83, 0x7b1474fd, 0x2325b847, + 0x7a7d055b, 0x25280c5e, 0x79dd3098, 0x2727d486, 0x793501a9, 0x2924edac, 0x78848414, 0x2b1f34eb, 0x77cbc3f2, + 0x2d168792, 0x770acdec, 0x2f0ac320, 0x7641af3d, 0x30fbc54d, 0x757075ac, 0x32e96c09, 0x74972f92, 0x34d3957e, + 0x73b5ebd1, 0x36ba2014, 0x72ccb9db, 0x389cea72, 0x71dba9ab, 0x3a7bd382, 0x70e2cbc6, 0x3c56ba70, 0x6fe2313c, + 0x3e2d7eb1, 0x6ed9eba1, 0x40000000, 0x6dca0d14, 0x41ce1e65, 0x6cb2a837, 0x4397ba32, 0x6b93d02e, 0x455cb40c, + 0x6a6d98a4, 0x471cece7, 0x694015c3, 0x48d84609, 0x680b5c33, 0x4a8ea111, 0x66cf8120, 0x4c3fdff4, 0x658c9a2d, + 0x4debe4fe, 0x6442bd7e, 0x4f9292dc, 0x62f201ac, 0x5133cc94, 0x619a7dce, 0x52cf758f, 0x603c496c, 0x54657194, + 0x5ed77c8a, 0x55f5a4d2, 0x5d6c2f99, 0x577ff3da, 0x5bfa7b82, 0x590443a7, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT512_twid[130] = { + 0x7fffffff, 0x00000000, 0x7ffd885a, 0x01921d20, 0x7ff62182, 0x03242abf, 0x7fe9cbc0, 0x04b6195d, 0x7fd8878e, + 0x0647d97c, 0x7fc25596, 0x07d95b9e, 0x7fa736b4, 0x096a9049, 0x7f872bf3, 0x0afb6805, 0x7f62368f, 0x0c8bd35e, + 0x7f3857f6, 0x0e1bc2e4, 0x7f0991c4, 0x0fab272b, 0x7ed5e5c6, 0x1139f0cf, 0x7e9d55fc, 0x12c8106f, 0x7e5fe493, + 0x145576b1, 0x7e1d93ea, 0x15e21445, 0x7dd6668f, 0x176dd9de, 0x7d8a5f40, 0x18f8b83c, 0x7d3980ec, 0x1a82a026, + 0x7ce3ceb2, 0x1c0b826a, 0x7c894bde, 0x1d934fe5, 0x7c29fbee, 0x1f19f97b, 0x7bc5e290, 0x209f701c, 0x7b5d039e, + 0x2223a4c5, 0x7aef6323, 0x23a6887f, 0x7a7d055b, 0x25280c5e, 0x7a05eead, 0x26a82186, 0x798a23b1, 0x2826b928, + 0x7909a92d, 0x29a3c485, 0x78848414, 0x2b1f34eb, 0x77fab989, 0x2c98fbba, 0x776c4edb, 0x2e110a62, 0x76d94989, + 0x2f875262, 0x7641af3d, 0x30fbc54d, 0x75a585cf, 0x326e54c7, 0x7504d345, 0x33def287, 0x745f9dd1, 0x354d9057, + 0x73b5ebd1, 0x36ba2014, 0x7307c3d0, 0x382493b0, 0x72552c85, 0x398cdd32, 0x719e2cd2, 0x3af2eeb7, 0x70e2cbc6, + 0x3c56ba70, 0x7023109a, 0x3db832a6, 0x6f5f02b2, 0x3f1749b8, 0x6e96a99d, 0x4073f21d, 0x6dca0d14, 0x41ce1e65, + 0x6cf934fc, 0x4325c135, 0x6c242960, 0x447acd50, 0x6b4af279, 0x45cd358f, 0x6a6d98a4, 0x471cece7, 0x698c246c, + 0x4869e665, 0x68a69e81, 0x49b41533, 0x67bd0fbd, 0x4afb6c98, 0x66cf8120, 0x4c3fdff4, 0x65ddfbd3, 0x4d8162c4, + 0x64e88926, 0x4ebfe8a5, 0x63ef3290, 0x4ffb654d, 0x62f201ac, 0x5133cc94, 0x61f1003f, 0x5269126e, 0x60ec3830, + 0x539b2af0, 0x5fe3b38d, 0x54ca0a4b, 0x5ed77c8a, 0x55f5a4d2, 0x5dc79d7c, 0x571deefa, 0x5cb420e0, 0x5842dd54, + 0x5b9d1154, 0x59646498, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RealFFT768_twid[194] = { + 0x7fffffff, 0x00000000, 0x7ffee744, 0x010c1460, 0x7ffb9d15, 0x02182427, 0x7ff62182, 0x03242abf, 0x7fee74a2, + 0x0430238f, 0x7fe49698, 0x053c0a01, 0x7fd8878e, 0x0647d97c, 0x7fca47b9, 0x07538d6b, 0x7fb9d759, 0x085f2137, + 0x7fa736b4, 0x096a9049, 0x7f92661d, 0x0a75d60e, 0x7f7b65ef, 0x0b80edf1, 0x7f62368f, 0x0c8bd35e, 0x7f46d86c, + 0x0d9681c2, 0x7f294bfd, 0x0ea0f48c, 0x7f0991c4, 0x0fab272b, 0x7ee7aa4c, 0x10b5150f, 0x7ec3962a, 0x11beb9aa, + 0x7e9d55fc, 0x12c8106f, 0x7e74ea6a, 0x13d114d0, 0x7e4a5426, 0x14d9c245, 0x7e1d93ea, 0x15e21445, 0x7deeaa7a, + 0x16ea0646, 0x7dbd98a4, 0x17f193c5, 0x7d8a5f40, 0x18f8b83c, 0x7d54ff2e, 0x19ff6f2a, 0x7d1d7958, 0x1b05b40f, + 0x7ce3ceb2, 0x1c0b826a, 0x7ca80038, 0x1d10d5c2, 0x7c6a0ef2, 0x1e15a99a, 0x7c29fbee, 0x1f19f97b, 0x7be7c847, + 0x201dc0ef, 0x7ba3751d, 0x2120fb83, 0x7b5d039e, 0x2223a4c5, 0x7b1474fd, 0x2325b847, 0x7ac9ca7a, 0x2427319d, + 0x7a7d055b, 0x25280c5e, 0x7a2e26f2, 0x26284422, 0x79dd3098, 0x2727d486, 0x798a23b1, 0x2826b928, 0x793501a9, + 0x2924edac, 0x78ddcbf5, 0x2a226db5, 0x78848414, 0x2b1f34eb, 0x78292b8d, 0x2c1b3efb, 0x77cbc3f2, 0x2d168792, + 0x776c4edb, 0x2e110a62, 0x770acdec, 0x2f0ac320, 0x76a742d1, 0x3003ad85, 0x7641af3d, 0x30fbc54d, 0x75da14ef, + 0x31f30638, 0x757075ac, 0x32e96c09, 0x7504d345, 0x33def287, 0x74972f92, 0x34d3957e, 0x74278c72, 0x35c750bc, + 0x73b5ebd1, 0x36ba2014, 0x73424fa0, 0x37abff5d, 0x72ccb9db, 0x389cea72, 0x72552c85, 0x398cdd32, 0x71dba9ab, + 0x3a7bd382, 0x71603361, 0x3b69c947, 0x70e2cbc6, 0x3c56ba70, 0x706374ff, 0x3d42a2ec, 0x6fe2313c, 0x3e2d7eb1, + 0x6f5f02b2, 0x3f1749b8, 0x6ed9eba1, 0x40000000, 0x6e52ee52, 0x40e79d8c, 0x6dca0d14, 0x41ce1e65, 0x6d3f4a40, + 0x42b37e96, 0x6cb2a837, 0x4397ba32, 0x6c242960, 0x447acd50, 0x6b93d02e, 0x455cb40c, 0x6b019f1a, 0x463d6a87, + 0x6a6d98a4, 0x471cece7, 0x69d7bf57, 0x47fb3757, 0x694015c3, 0x48d84609, 0x68a69e81, 0x49b41533, 0x680b5c33, + 0x4a8ea111, 0x676e5183, 0x4b67e5e4, 0x66cf8120, 0x4c3fdff4, 0x662eedc3, 0x4d168b8b, 0x658c9a2d, 0x4debe4fe, + 0x64e88926, 0x4ebfe8a5, 0x6442bd7e, 0x4f9292dc, 0x639b3a0b, 0x5063e008, 0x62f201ac, 0x5133cc94, 0x62471749, + 0x520254ef, 0x619a7dce, 0x52cf758f, 0x60ec3830, 0x539b2af0, 0x603c496c, 0x54657194, 0x5f8ab487, 0x552e4605, + 0x5ed77c8a, 0x55f5a4d2, 0x5e22a487, 0x56bb8a90, 0x5d6c2f99, 0x577ff3da, 0x5cb420e0, 0x5842dd54, 0x5bfa7b82, + 0x590443a7, 0x5b3f42ae, 0x59c42381, 0x5a82799a, 0x5a82799a, +}; + +const Word32 RotVector_32_32[2 * 20] = { + 0x7d8a5f00, 0xe70747c0, 0x7641b000, 0xcf043ac0, 0x6a6d9900, 0xb8e31300, 0x5a827980, 0xa57d8680, + 0x471ced80, 0x95926780, 0x30fbc600, 0x89be5100, 0x18f8b800, 0x8275a100, 0x7641b000, 0xcf043ac0, + 0x5a827980, 0xa57d8680, 0x30fbc600, 0x89be5100, 0xcf043b00, 0x89be5100, 0xa57d8680, 0xa57d8680, + 0x89be5100, 0xcf043ac0, 0x6a6d9900, 0xb8e31300, 0x30fbc600, 0x89be5100, 0xe7074800, 0x8275a100, + 0xa57d8680, 0xa57d8680, 0x8275a100, 0xe70747c0, 0x89be5000, 0x30fbc540, 0xb8e31280, 0x6a6d9880, +}; + +const Word32 RotVector_40_32[2 * 28] = { + 0x7e6c9251, 0x14060b68, 0x79bc384d, 0x278dde6e, 0x720c8075, 0x3a1c5c57, 0x678dde6e, 0x4b3c8c12, + 0x79bc384d, 0x278dde6e, 0x678dde6e, 0x4b3c8c12, 0x4b3c8c12, 0x678dde6e, 0x278dde6e, 0x79bc384d, + 0x720c8075, 0x3a1c5c57, 0x4b3c8c12, 0x678dde6e, 0x14060b68, 0x7e6c9251, 0xd8722192, 0x79bc384d, + 0x678dde6e, 0x4b3c8c12, 0x278dde6e, 0x79bc384d, 0xd8722192, 0x79bc384d, 0x98722192, 0x4b3c8c12, + 0x5a82799a, 0x5a82799a, 0x00000000, 0x7fffffff, 0xa57d8666, 0x5a82799a, 0x80000000, 0x00000000, + 0x4b3c8c12, 0x678dde6e, 0xd8722192, 0x79bc384d, 0x8643c7b3, 0x278dde6e, 0x98722192, 0xb4c373ee, + 0x3a1c5c57, 0x720c8075, 0xb4c373ee, 0x678dde6e, 0x81936daf, 0xebf9f498, 0xd8722192, 0x8643c7b3, +}; + +# ifdef ENABLE_HR_MODE +const Word32 RotVector_480[2 * (480 - 30)] = { +# else +const Word16 RotVector_480[2 * (480 - 30)] = { +# endif + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ff4c56f), SHC(0xfca63bd8), SHC(0x7fd317b4), SHC(0xf94d0e2e), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7ddb4bfc), SHC(0xe8ac819d), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7aba9ae6), SHC(0xdba5629b), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x78a879f4), SHC(0xd545d11c), SHC(0x777f903c), SHC(0xd220ffc0), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x7387ea23), SHC(0xc8e5032b), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x707d1443), SHC(0xc2ec7635), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x697cf78a), SHC(0xb780001c), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x637984d4), SHC(0xaf726def), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x5cd91140), SHC(0xa7e3ff4d), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6b598ea3), SHC(0xba4944a2), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x637984d4), SHC(0xaf726def), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x508d9211), SHC(0x9c867b2c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x45b6bb5e), SHC(0x94a6715d), SHC(0x40000000), SHC(0x9126145f), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x340ff242), SHC(0x8b10f144), SHC(0x2ddf0040), SHC(0x88806fc4), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x06b2f1d2), SHC(0x802ce84c), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7e6c9251), SHC(0xebf9f498), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x678dde6e), SHC(0xb4c373ee), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x53211d18), SHC(0x9eab046f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x3a1c5c57), SHC(0x8df37f8b), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1de189a6), SHC(0x838961e8), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0a0af299), SHC(0x80650347), SHC(0x00000000), SHC(0x80000000), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xebf9f498), SHC(0x81936daf), SHC(0xe21e765a), SHC(0x838961e8), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb4c373ee), SHC(0x98722192), SHC(0xacdee2e8), SHC(0x9eab046f), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x55a6125c), SHC(0xa0e0a15f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x40000000), SHC(0x9126145f), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0x00000000), SHC(0x80000000), SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe5632654), SHC(0x82cc0f36), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcbf00dbe), SHC(0x8b10f144), SHC(0xc0000000), SHC(0x9126145f), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0xa0e0a15f), SHC(0xaa59eda4), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x9126145f), SHC(0xc0000000), SHC(0x8b10f144), SHC(0xcbf00dbe), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x80b381ac), SHC(0xf29ecfb2), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x658c9a2d), SHC(0xb2141b02), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x40000000), SHC(0x9126145f), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x10b5150f), SHC(0x811855b4), + SHC(0x00000000), SHC(0x80000000), SHC(0xef4aeaf1), SHC(0x811855b4), SHC(0xdedf047d), SHC(0x845c8ae3), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc0000000), SHC(0x9126145f), SHC(0xb2141b02), SHC(0x9a7365d3), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9a7365d3), SHC(0xb2141b02), SHC(0x9126145f), SHC(0xc0000000), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x811855b4), SHC(0xef4aeaf1), + SHC(0x80000000), SHC(0x00000000), SHC(0x811855b4), SHC(0x10b5150f), SHC(0x845c8ae3), SHC(0x2120fb83), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9126145f), SHC(0x40000000), SHC(0x9a7365d3), SHC(0x4debe4fe), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x278dde6e), SHC(0x8643c7b3), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x00000000), SHC(0x80000000), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8df37f8b), SHC(0xc5e3a3a9), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x81936daf), SHC(0xebf9f498), SHC(0x80000000), SHC(0x00000000), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8df37f8b), SHC(0x3a1c5c57), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0xa57d8666), SHC(0x5a82799a), SHC(0xb4c373ee), SHC(0x678dde6e), + SHC(0xc5e3a3a9), SHC(0x720c8075), SHC(0xd8722192), SHC(0x79bc384d), SHC(0xebf9f498), SHC(0x7e6c9251), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ddb4bfc), SHC(0xe8ac819d), SHC(0x777f903c), SHC(0xd220ffc0), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x245a9d65), SHC(0x8545651a), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xc8e5032b), SHC(0x8c7815dd), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xa326eec0), SHC(0xa7e3ff4d), SHC(0x94a6715d), SHC(0xba4944a2), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x800b3a91), SHC(0xfca63bd8), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8757860c), SHC(0x2aba2ee4), SHC(0x9126145f), SHC(0x40000000), + SHC(0x9eab046f), SHC(0x53211d18), SHC(0xaf726def), SHC(0x637984d4), SHC(0xc2ec7635), SHC(0x707d1443), + SHC(0xd8722192), SHC(0x79bc384d), SHC(0xef4aeaf1), SHC(0x7ee7aa4c), SHC(0x06b2f1d2), SHC(0x7fd317b4), + SHC(0x1de189a6), SHC(0x7c769e18), SHC(0x340ff242), SHC(0x74ef0ebc), SHC(0x487fffe4), SHC(0x697cf78a), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffd3154), SHC(0xfe531484), SHC(0x7ff4c56f), SHC(0xfca63bd8), + SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7fb9d759), SHC(0xf7a0dec9), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f76892f), SHC(0xf449acca), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7eace58a), SHC(0xeda208a5), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7e26b371), SHC(0xea52c166), SHC(0x7ddb4bfc), SHC(0xe8ac819d), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7cd80464), SHC(0xe3c02fbb), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7c0fc22a), SHC(0xe07e0c84), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x7aba9ae6), SHC(0xdba5629b), SHC(0x7a3e17f2), SHC(0xda0aecf9), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x793501a9), SHC(0xd6db1254), SHC(0x78a879f4), SHC(0xd545d11c), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x76e33b3f), SHC(0xd09192ea), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7f9afcb9), SHC(0xf5f50d67), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x743e0918), SHC(0xca695b94), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x6d23501b), SHC(0xbd1ec45c), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x648543e4), SHC(0xb0c1878b), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5dfe47ad), SHC(0xa91d0ea3), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x53211d18), SHC(0x9eab046f), SHC(0x4f3e7875), SHC(0x9b7abc1c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x471cece7), SHC(0x9592675c), SHC(0x42e13ba4), SHC(0x92dcafe5), + SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x3596a46c), SHC(0x8bc1f6e8), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb9d759), SHC(0xf7a0dec9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x793501a9), SHC(0xd6db1254), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x54657194), SHC(0x9fc3b694), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x471cece7), SHC(0x9592675c), SHC(0x40000000), SHC(0x9126145f), SHC(0x389cea72), SHC(0x8d334625), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2924edac), SHC(0x86cafe57), SHC(0x2120fb83), SHC(0x845c8ae3), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x10b5150f), SHC(0x811855b4), SHC(0x085f2137), SHC(0x804628a7), + SHC(0x00000000), SHC(0x80000000), SHC(0xf7a0dec9), SHC(0x804628a7), SHC(0xef4aeaf1), SHC(0x811855b4), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd6db1254), SHC(0x86cafe57), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f76892f), SHC(0xf449acca), SHC(0x7ddb4bfc), SHC(0xe8ac819d), + SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x72ccb9db), SHC(0xc763158e), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x668f7c25), SHC(0xb36a1978), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x444d7aff), SHC(0x93bf30d4), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x2f6e6d16), SHC(0x891cc4c1), SHC(0x245a9d65), SHC(0x8545651a), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x01aceb7c), SHC(0x8002ceac), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xea52c166), SHC(0x81d94c8f), SHC(0xdedf047d), SHC(0x845c8ae3), + SHC(0xd3b26fb0), SHC(0x87e958a7), SHC(0xc8e5032b), SHC(0x8c7815dd), SHC(0xbe8df2ba), SHC(0x91fef880), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xab9a8e6c), SHC(0x9fc3b694), SHC(0xa326eec0), SHC(0xa7e3ff4d), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x94a6715d), SHC(0xba4944a2), SHC(0x8eb8b9a0), SHC(0xc466be4f), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x4b3c8c12), SHC(0x98722192), + SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x22be8f87), SHC(0x84ce444e), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x05067734), SHC(0x80194350), SHC(0xf5f50d67), SHC(0x80650347), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xca695b94), SHC(0x8bc1f6e8), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb0c1878b), SHC(0x9b7abc1c), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8bc1f6e8), SHC(0xca695b94), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80650347), SHC(0xf5f50d67), + SHC(0x80194350), SHC(0x05067734), SHC(0x81936daf), SHC(0x14060b68), SHC(0x84ce444e), SHC(0x22be8f87), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7eace58a), SHC(0xeda208a5), SHC(0x7aba9ae6), SHC(0xdba5629b), + SHC(0x743e0918), SHC(0xca695b94), SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x53211d18), SHC(0x9eab046f), SHC(0x444d7aff), SHC(0x93bf30d4), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x22be8f87), SHC(0x84ce444e), SHC(0x10b5150f), SHC(0x811855b4), SHC(0xfe531484), SHC(0x8002ceac), + SHC(0xebf9f498), SHC(0x81936daf), SHC(0xda0aecf9), SHC(0x85c1e80e), SHC(0xc8e5032b), SHC(0x8c7815dd), + SHC(0xb8e31319), SHC(0x9592675c), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0x9d969742), SHC(0xae26dcdf), + SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8a650cb4), SHC(0xcd790887), SHC(0x845c8ae3), SHC(0xdedf047d), + SHC(0x80e321ff), SHC(0xf0f488d9), SHC(0x800b3a91), SHC(0x0359c428), SHC(0x81d94c8f), SHC(0x15ad3e9a), + SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8d334625), SHC(0x389cea72), SHC(0x96830876), SHC(0x487fffe4), + SHC(0xa201b853), SHC(0x56e2f15d), SHC(0xaf726def), SHC(0x637984d4), SHC(0xbe8df2ba), SHC(0x6e010780), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e26b371), SHC(0xea52c166), SHC(0x78a879f4), SHC(0xd545d11c), + SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x637984d4), SHC(0xaf726def), SHC(0x54657194), SHC(0x9fc3b694), + SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x2f6e6d16), SHC(0x891cc4c1), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x05067734), SHC(0x80194350), SHC(0xef4aeaf1), SHC(0x811855b4), SHC(0xda0aecf9), SHC(0x85c1e80e), + SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb36a1978), SHC(0x997083db), SHC(0xa326eec0), SHC(0xa7e3ff4d), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x8b10f144), SHC(0xcbf00dbe), SHC(0x83f03dd6), SHC(0xe07e0c84), + SHC(0x80650347), SHC(0xf5f50d67), SHC(0x808976d1), SHC(0x0bb65336), SHC(0x845c8ae3), SHC(0x2120fb83), + SHC(0x8bc1f6e8), SHC(0x3596a46c), SHC(0x96830876), SHC(0x487fffe4), SHC(0xa45037c9), SHC(0x595132a2), + SHC(0xb4c373ee), SHC(0x678dde6e), SHC(0xc763158e), SHC(0x72ccb9db), SHC(0xdba5629b), SHC(0x7aba9ae6), + SHC(0xf0f488d9), SHC(0x7f1cde01), SHC(0x06b2f1d2), SHC(0x7fd317b4), SHC(0x1c3fd045), SHC(0x7cd80464), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x471cece7), SHC(0x9592675c), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x00000000), SHC(0x80000000), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xb8e31319), SHC(0x9592675c), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9592675c), SHC(0xb8e31319), SHC(0x89be50c3), SHC(0xcf043ab3), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80000000), SHC(0x00000000), SHC(0x8275a0c0), SHC(0x18f8b83c), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9592675c), SHC(0x471cece7), SHC(0xa57d8666), SHC(0x5a82799a), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xcf043ab3), SHC(0x7641af3d), SHC(0xe70747c4), SHC(0x7d8a5f40), + SHC(0x00000000), SHC(0x7fffffff), SHC(0x18f8b83c), SHC(0x7d8a5f40), SHC(0x30fbc54d), SHC(0x7641af3d), + SHC(0x471cece7), SHC(0x6a6d98a4), SHC(0x5a82799a), SHC(0x5a82799a), SHC(0x6a6d98a4), SHC(0x471cece7)}; + +# ifdef ENABLE_HR_MODE +#ifdef CR8_G_ADD_75MS +const Word32 RotVector_720[2 * (720 - 30)] = { + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffb0260), SHC(0xfdc41e9b), SHC(0x7fec09e3), SHC(0xfb8869ce), + SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7fb02dc6), SHC(0xf7123849), SHC(0x7f834ed0), SHC(0xf4d814a4), + SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7f0bc097), SHC(0xf06695da), SHC(0x7ec11aa5), SHC(0xee2f9369), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7e0e2e32), SHC(0xe9c5e582), SHC(0x7da5f5a5), SHC(0xe7939223), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7cb82885), SHC(0xe334cdc9), SHC(0x7c32a67e), SHC(0xe108b40d), + SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), SHC(0x7a6831ba), SHC(0xda939061), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7906c0b0), SHC(0xd653c860), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x76adf5e6), SHC(0xd00ce422), SHC(0x75d31a61), SHC(0xcdfc85bb), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x7401e4c1), SHC(0xc9e7a512), SHC(0x730baeed), SHC(0xc7e3744b), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x6ff389df), SHC(0xc1f1c224), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fec09e3), SHC(0xfb8869ce), SHC(0x7fb02dc6), SHC(0xf7123849), + SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7ec11aa5), SHC(0xee2f9369), SHC(0x7e0e2e32), SHC(0xe9c5e582), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7c32a67e), SHC(0xe108b40d), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7847d909), SHC(0xd438af17), SHC(0x76adf5e6), SHC(0xd00ce422), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x730baeed), SHC(0xc7e3744b), SHC(0x71046d3e), SHC(0xc3e85b18), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6c8cd70b), SHC(0xbc2b9b05), SHC(0x6a1de737), SHC(0xb86c5df0), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x64dd8950), SHC(0xb1320139), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x5c13539b), SHC(0xa7156f3c), SHC(0x58ea90c4), SHC(0xa3ecac65), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x5246dd49), SHC(0x9df24175), SHC(0x4ecdfec7), SHC(0x9b2276b0), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x4793a210), SHC(0x95e218c9), SHC(0x43d464fb), SHC(0x937328f5), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6b598ea3), SHC(0xba4944a2), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x637984d4), SHC(0xaf726def), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x508d9211), SHC(0x9c867b2c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x45b6bb5e), SHC(0x94a6715d), SHC(0x40000000), SHC(0x9126145f), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x340ff242), SHC(0x8b10f144), SHC(0x2ddf0040), SHC(0x88806fc4), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x06b2f1d2), SHC(0x802ce84c), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb02dc6), SHC(0xf7123849), SHC(0x7ec11aa5), SHC(0xee2f9369), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x6c8cd70b), SHC(0xbc2b9b05), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x620dbe8b), SHC(0xadb922b7), SHC(0x5c13539b), SHC(0xa7156f3c), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x4ecdfec7), SHC(0x9b2276b0), SHC(0x4793a210), SHC(0x95e218c9), + SHC(0x40000000), SHC(0x9126145f), SHC(0x381c8bb5), SHC(0x8cf45113), SHC(0x2ff31bde), SHC(0x89520a1a), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1ef74bf3), SHC(0x83cd5982), SHC(0x163a1a7e), SHC(0x81f1d1ce), + SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x04779632), SHC(0x8013f61d), SHC(0xfb8869ce), SHC(0x8013f61d), + SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe9c5e582), SHC(0x81f1d1ce), SHC(0xe108b40d), SHC(0x83cd5982), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xd00ce422), SHC(0x89520a1a), SHC(0xc7e3744b), SHC(0x8cf45113), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f834ed0), SHC(0xf4d814a4), SHC(0x7e0e2e32), SHC(0xe9c5e582), + SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7847d909), SHC(0xd438af17), SHC(0x7401e4c1), SHC(0xc9e7a512), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x68d9f964), SHC(0xb6950c1e), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x5246dd49), SHC(0x9df24175), SHC(0x496af3e2), SHC(0x9726069c), + SHC(0x40000000), SHC(0x9126145f), SHC(0x36185aee), SHC(0x8bfe1b3f), SHC(0x2bc750e9), SHC(0x87b826f7), + SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x163a1a7e), SHC(0x81f1d1ce), SHC(0x0b27eb5c), SHC(0x807cb130), + SHC(0x00000000), SHC(0x80000000), SHC(0xf4d814a4), SHC(0x807cb130), SHC(0xe9c5e582), SHC(0x81f1d1ce), + SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd438af17), SHC(0x87b826f7), SHC(0xc9e7a512), SHC(0x8bfe1b3f), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xb6950c1e), SHC(0x9726069c), SHC(0xadb922b7), SHC(0x9df24175), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9df24175), SHC(0xadb922b7), SHC(0x9726069c), SHC(0xb6950c1e), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x55a6125c), SHC(0xa0e0a15f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x40000000), SHC(0x9126145f), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0x00000000), SHC(0x80000000), SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe5632654), SHC(0x82cc0f36), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcbf00dbe), SHC(0x8b10f144), SHC(0xc0000000), SHC(0x9126145f), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0xa0e0a15f), SHC(0xaa59eda4), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x9126145f), SHC(0xc0000000), SHC(0x8b10f144), SHC(0xcbf00dbe), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x80b381ac), SHC(0xf29ecfb2), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f0bc097), SHC(0xf06695da), SHC(0x7c32a67e), SHC(0xe108b40d), + SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x68d9f964), SHC(0xb6950c1e), + SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x53f9be05), SHC(0x9f65ad2d), SHC(0x4793a210), SHC(0x95e218c9), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x2bc750e9), SHC(0x87b826f7), SHC(0x1ccb3237), SHC(0x8347d77b), + SHC(0x0d61304e), SHC(0x80b381ac), SHC(0xfdc41e9b), SHC(0x8004fda0), SHC(0xee2f9369), SHC(0x813ee55b), + SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd00ce422), SHC(0x89520a1a), SHC(0xc1f1c224), SHC(0x900c7621), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xa8b4471a), SHC(0xa263007d), SHC(0x9df24175), SHC(0xadb922b7), + SHC(0x94a6715d), SHC(0xba4944a2), SHC(0x8cf45113), SHC(0xc7e3744b), SHC(0x86f93f50), SHC(0xd653c860), + SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x807cb130), SHC(0xf4d814a4), SHC(0x8013f61d), SHC(0x04779632), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x84f56073), SHC(0x234815ba), SHC(0x8a2ce59f), SHC(0x32037a45), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ec11aa5), SHC(0xee2f9369), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6c8cd70b), SHC(0xbc2b9b05), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x4793a210), SHC(0x95e218c9), SHC(0x381c8bb5), SHC(0x8cf45113), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x163a1a7e), SHC(0x81f1d1ce), SHC(0x04779632), SHC(0x8013f61d), + SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe108b40d), SHC(0x83cd5982), SHC(0xd00ce422), SHC(0x89520a1a), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xb1320139), SHC(0x9b2276b0), SHC(0xa3ecac65), SHC(0xa7156f3c), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8efb92c2), SHC(0xc3e85b18), SHC(0x87b826f7), SHC(0xd438af17), + SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x804fd23a), SHC(0xf7123849), SHC(0x804fd23a), SHC(0x08edc7b7), + SHC(0x82cc0f36), SHC(0x1a9cd9ac), SHC(0x87b826f7), SHC(0x2bc750e9), SHC(0x8efb92c2), SHC(0x3c17a4e8), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0xa3ecac65), SHC(0x58ea90c4), SHC(0xb1320139), SHC(0x64dd8950), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x278dde6e), SHC(0x8643c7b3), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x00000000), SHC(0x80000000), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8df37f8b), SHC(0xc5e3a3a9), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x81936daf), SHC(0xebf9f498), SHC(0x80000000), SHC(0x00000000), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8df37f8b), SHC(0x3a1c5c57), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0xa57d8666), SHC(0x5a82799a), SHC(0xb4c373ee), SHC(0x678dde6e), + SHC(0xc5e3a3a9), SHC(0x720c8075), SHC(0xd8722192), SHC(0x79bc384d), SHC(0xebf9f498), SHC(0x7e6c9251), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e0e2e32), SHC(0xe9c5e582), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x620dbe8b), SHC(0xadb922b7), SHC(0x5246dd49), SHC(0x9df24175), + SHC(0x40000000), SHC(0x9126145f), SHC(0x2bc750e9), SHC(0x87b826f7), SHC(0x163a1a7e), SHC(0x81f1d1ce), + SHC(0x00000000), SHC(0x80000000), SHC(0xe9c5e582), SHC(0x81f1d1ce), SHC(0xd438af17), SHC(0x87b826f7), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xadb922b7), SHC(0x9df24175), SHC(0x9df24175), SHC(0xadb922b7), + SHC(0x9126145f), SHC(0xc0000000), SHC(0x87b826f7), SHC(0xd438af17), SHC(0x81f1d1ce), SHC(0xe9c5e582), + SHC(0x80000000), SHC(0x00000000), SHC(0x81f1d1ce), SHC(0x163a1a7e), SHC(0x87b826f7), SHC(0x2bc750e9), + SHC(0x9126145f), SHC(0x40000000), SHC(0x9df24175), SHC(0x5246dd49), SHC(0xadb922b7), SHC(0x620dbe8b), + SHC(0xc0000000), SHC(0x6ed9eba1), SHC(0xd438af17), SHC(0x7847d909), SHC(0xe9c5e582), SHC(0x7e0e2e32), + SHC(0x00000000), SHC(0x7fffffff), SHC(0x163a1a7e), SHC(0x7e0e2e32), SHC(0x2bc750e9), SHC(0x7847d909), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7da5f5a5), SHC(0xe7939223), SHC(0x76adf5e6), SHC(0xd00ce422), + SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x5c13539b), SHC(0xa7156f3c), SHC(0x496af3e2), SHC(0x9726069c), + SHC(0x340ff242), SHC(0x8b10f144), SHC(0x1ccb3237), SHC(0x8347d77b), SHC(0x04779632), SHC(0x8013f61d), + SHC(0xebf9f498), SHC(0x81936daf), SHC(0xd438af17), SHC(0x87b826f7), SHC(0xbe133b7c), SHC(0x92485786), + SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0x99c64fc5), SHC(0xb2f7b9af), SHC(0x8cf45113), SHC(0xc7e3744b), + SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x804fd23a), SHC(0xf7123849), SHC(0x80f43f69), SHC(0x0f996a26), + SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x900c7621), SHC(0x3e0e3ddc), SHC(0x9df24175), SHC(0x5246dd49), + SHC(0xaf726def), SHC(0x637984d4), SHC(0xc3e85b18), SHC(0x71046d3e), SHC(0xda939061), SHC(0x7a6831ba), + SHC(0xf29ecfb2), SHC(0x7f4c7e54), SHC(0x0b27eb5c), SHC(0x7f834ed0), SHC(0x234815ba), SHC(0x7b0a9f8d), + SHC(0x3a1c5c57), SHC(0x720c8075), SHC(0x4ecdfec7), SHC(0x64dd8950), SHC(0x609a52d3), SHC(0x53f9be05), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x4b3c8c12), SHC(0x98722192), + SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x22be8f87), SHC(0x84ce444e), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x05067734), SHC(0x80194350), SHC(0xf5f50d67), SHC(0x80650347), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xca695b94), SHC(0x8bc1f6e8), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb0c1878b), SHC(0x9b7abc1c), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8bc1f6e8), SHC(0xca695b94), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80650347), SHC(0xf5f50d67), + SHC(0x80194350), SHC(0x05067734), SHC(0x81936daf), SHC(0x14060b68), SHC(0x84ce444e), SHC(0x22be8f87), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7eace58a), SHC(0xeda208a5), SHC(0x7aba9ae6), SHC(0xdba5629b), + SHC(0x743e0918), SHC(0xca695b94), SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x53211d18), SHC(0x9eab046f), SHC(0x444d7aff), SHC(0x93bf30d4), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x22be8f87), SHC(0x84ce444e), SHC(0x10b5150f), SHC(0x811855b4), SHC(0xfe531484), SHC(0x8002ceac), + SHC(0xebf9f498), SHC(0x81936daf), SHC(0xda0aecf9), SHC(0x85c1e80e), SHC(0xc8e5032b), SHC(0x8c7815dd), + SHC(0xb8e31319), SHC(0x9592675c), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0x9d969742), SHC(0xae26dcdf), + SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8a650cb4), SHC(0xcd790887), SHC(0x845c8ae3), SHC(0xdedf047d), + SHC(0x80e321ff), SHC(0xf0f488d9), SHC(0x800b3a91), SHC(0x0359c428), SHC(0x81d94c8f), SHC(0x15ad3e9a), + SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8d334625), SHC(0x389cea72), SHC(0x96830876), SHC(0x487fffe4), + SHC(0xa201b853), SHC(0x56e2f15d), SHC(0xaf726def), SHC(0x637984d4), SHC(0xbe8df2ba), SHC(0x6e010780), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e26b371), SHC(0xea52c166), SHC(0x78a879f4), SHC(0xd545d11c), + SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x637984d4), SHC(0xaf726def), SHC(0x54657194), SHC(0x9fc3b694), + SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x2f6e6d16), SHC(0x891cc4c1), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x05067734), SHC(0x80194350), SHC(0xef4aeaf1), SHC(0x811855b4), SHC(0xda0aecf9), SHC(0x85c1e80e), + SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb36a1978), SHC(0x997083db), SHC(0xa326eec0), SHC(0xa7e3ff4d), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x8b10f144), SHC(0xcbf00dbe), SHC(0x83f03dd6), SHC(0xe07e0c84), + SHC(0x80650347), SHC(0xf5f50d67), SHC(0x808976d1), SHC(0x0bb65336), SHC(0x845c8ae3), SHC(0x2120fb83), + SHC(0x8bc1f6e8), SHC(0x3596a46c), SHC(0x96830876), SHC(0x487fffe4), SHC(0xa45037c9), SHC(0x595132a2), + SHC(0xb4c373ee), SHC(0x678dde6e), SHC(0xc763158e), SHC(0x72ccb9db), SHC(0xdba5629b), SHC(0x7aba9ae6), + SHC(0xf0f488d9), SHC(0x7f1cde01), SHC(0x06b2f1d2), SHC(0x7fd317b4), SHC(0x1c3fd045), SHC(0x7cd80464), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x471cece7), SHC(0x9592675c), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x00000000), SHC(0x80000000), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xb8e31319), SHC(0x9592675c), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9592675c), SHC(0xb8e31319), SHC(0x89be50c3), SHC(0xcf043ab3), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80000000), SHC(0x00000000), SHC(0x8275a0c0), SHC(0x18f8b83c), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9592675c), SHC(0x471cece7), SHC(0xa57d8666), SHC(0x5a82799a), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xcf043ab3), SHC(0x7641af3d), SHC(0xe70747c4), SHC(0x7d8a5f40), + SHC(0x00000000), SHC(0x7fffffff), SHC(0x18f8b83c), SHC(0x7d8a5f40), SHC(0x30fbc54d), SHC(0x7641af3d), + SHC(0x471cece7), SHC(0x6a6d98a4), SHC(0x5a82799a), SHC(0x5a82799a), SHC(0x6a6d98a4), SHC(0x471cece7), + SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), + SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), + SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0x00007fff), SHC(0xfb887fec), SHC(0xf7127fb0), + SHC(0xf29f7f4c), SHC(0xee307ec1), SHC(0xe9c67e0e), SHC(0xe5637d34), SHC(0xe1097c33), SHC(0xdcb87b0b), + SHC(0xd87279bc), SHC(0xd4397848), SHC(0xd00d76ae), SHC(0xcbf074ef), SHC(0xc7e3730c), SHC(0xc3e87104), + SHC(0x00007fff), SHC(0xf7127fb0), SHC(0xee307ec1), SHC(0xe5637d34), SHC(0xdcb87b0b), SHC(0xd4397848), + SHC(0xcbf074ef), SHC(0xc3e87104), SHC(0xbc2c6c8d), SHC(0xb4c3678e), SHC(0xadb9620e), SHC(0xa7155c13), + SHC(0xa0e155a6), SHC(0x9b224ece), SHC(0x95e24794), SHC(0x00007fff), SHC(0xf29f7f4c), SHC(0xe5637d34), + SHC(0xd87279bc), SHC(0xcbf074ef), SHC(0xc0006eda), SHC(0xb4c3678e), SHC(0xaa5a5f1f), SHC(0xa0e155a6), + SHC(0x98724b3d), SHC(0x91264000), SHC(0x8b113410), SHC(0x8644278e), SHC(0x82cc1a9d), SHC(0x80b40d61), + SHC(0x00007fff), SHC(0xee307ec1), SHC(0xdcb87b0b), SHC(0xcbf074ef), SHC(0xbc2c6c8d), SHC(0xadb9620e), + SHC(0xa0e155a6), SHC(0x95e24794), SHC(0x8cf4381d), SHC(0x8644278e), SHC(0x81f2163a), SHC(0x80140478), + SHC(0x80b4f29f), SHC(0x83cde109), SHC(0x8952d00d), SHC(0x00007fff), SHC(0xe9c67e0e), SHC(0xd4397848), + SHC(0xc0006eda), SHC(0xadb9620e), SHC(0x9df25247), SHC(0x91264000), SHC(0x87b82bc7), SHC(0x81f2163a), + SHC(0x80000000), SHC(0x81f2e9c6), SHC(0x87b8d439), SHC(0x9126c000), SHC(0x9df2adb9), SHC(0xadb99df2), + SHC(0x00007fff), SHC(0xe5637d34), SHC(0xcbf074ef), SHC(0xb4c3678e), SHC(0xa0e155a6), SHC(0x91264000), + SHC(0x8644278e), SHC(0x80b40d61), SHC(0x80b4f29f), SHC(0x8644d872), SHC(0x9126c000), SHC(0xa0e1aa5a), + SHC(0xb4c39872), SHC(0xcbf08b11), SHC(0xe56382cc), SHC(0x00007fff), SHC(0xe1097c33), SHC(0xc3e87104), + SHC(0xaa5a5f1f), SHC(0x95e24794), SHC(0x87b82bc7), SHC(0x80b40d61), SHC(0x813fee30), SHC(0x8952d00d), + SHC(0x9872b4c3), SHC(0xadb99df2), SHC(0xc7e38cf4), SHC(0xe56382cc), SHC(0x04788014), SHC(0x234884f5), + SHC(0x00007fff), SHC(0xdcb87b0b), SHC(0xbc2c6c8d), SHC(0xa0e155a6), SHC(0x8cf4381d), SHC(0x81f2163a), + SHC(0x80b4f29f), SHC(0x8952d00d), SHC(0x9b22b132), SHC(0xb4c39872), SHC(0xd43987b8), SHC(0xf7128050), + SHC(0x1a9d82cc), SHC(0x3c188efc), SHC(0x58eba3ed), SHC(0x00007fff), SHC(0xd87279bc), SHC(0xb4c3678e), + SHC(0x98724b3d), SHC(0x8644278e), SHC(0x80000000), SHC(0x8644d872), SHC(0x9872b4c3), SHC(0xb4c39872), + SHC(0xd8728644), SHC(0x00008000), SHC(0x278e8644), SHC(0x4b3d9872), SHC(0x678eb4c3), SHC(0x79bcd872), + SHC(0x00007fff), SHC(0xd4397848), SHC(0xadb9620e), SHC(0x91264000), SHC(0x81f2163a), SHC(0x81f2e9c6), + SHC(0x9126c000), SHC(0xadb99df2), SHC(0xd43987b8), SHC(0x00008000), SHC(0x2bc787b8), SHC(0x52479df2), + SHC(0x6edac000), SHC(0x7e0ee9c6), SHC(0x7e0e163a), SHC(0x00007fff), SHC(0xd00d76ae), SHC(0xa7155c13), + SHC(0x8b113410), SHC(0x80140478), SHC(0x87b8d439), SHC(0xa0e1aa5a), SHC(0xc7e38cf4), SHC(0xf7128050), + SHC(0x278e8644), SHC(0x52479df2), SHC(0x7104c3e8), SHC(0x7f4cf29f), SHC(0x7b0b2348), SHC(0x64de4ece), + SHC(0x00007fff), SHC(0xe21e7c77), SHC(0xc5e4720d), SHC(0xacdf6155), SHC(0x98724b3d), SHC(0x89be30fc), + SHC(0x81931406), SHC(0x8065f5f5), SHC(0x8644d872), SHC(0x92ddbd1f), SHC(0xa57ea57e), SHC(0xbd1f92dd), + SHC(0xd8728644), SHC(0xf5f58065), SHC(0x14068193), SHC(0x00007fff), SHC(0xdba57abb), SHC(0xba496b5a), + SHC(0x9eab5321), SHC(0x8b113410), SHC(0x811810b5), SHC(0x8193ebfa), SHC(0x8c78c8e5), SHC(0xa0e1aa5a), + SHC(0xbd1f92dd), SHC(0xdedf845d), SHC(0x035a800b), SHC(0x278e8644), SHC(0x48809683), SHC(0x637aaf72), + SHC(0x00007fff), SHC(0xd54678a8), SHC(0xaf72637a), SHC(0x92dd42e1), SHC(0x82cc1a9d), SHC(0x8118ef4b), + SHC(0x8df3c5e4), SHC(0xa7e4a327), SHC(0xcbf08b11), SHC(0xf5f58065), SHC(0x2121845d), SHC(0x48809683), + SHC(0x678eb4c3), SHC(0x7abbdba5), SHC(0x7fd306b3), SHC(0x00007fff), SHC(0xcf047642), SHC(0xa57e5a82), + SHC(0x89be30fc), SHC(0x80000000), SHC(0x89becf04), SHC(0xa57ea57e), SHC(0xcf0489be), SHC(0x00008000), + SHC(0x30fc89be), SHC(0x5a82a57e), SHC(0x7642cf04), SHC(0x7fff0000), SHC(0x764230fc), SHC(0x5a825a82), + SHC(0xe2e1004b), SHC(0x00000000), SHC(0x00000000), SHC(0x6fb076e0), SHC(0x002fba9c), SHC(0x6fb079d0), + SHC(0x8d92be50), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0xffffffff), + SHC(0x00010000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0xffffffff), SHC(0x00010000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0xeabee318), SHC(0x00000000), SHC(0x4d55545a), + SHC(0000000000), SHC(0000000000), SHC(0x00000000), SHC(0x00000000), SHC(0xffffffff), SHC(0x904f882f), + SHC(0x4d55545a), SHC(0x00000000), SHC(0x00000000), SHC(0x006f5dd8), SHC(0x40000000), SHC(0x00666004), + SHC(0x006ec0b0), SHC(0x00660000), SHC(0x006f5dd8), SHC(0x42000000), SHC(0x00665fa0), SHC(0x006ec080), + SHC(0x6fb07880), SHC(0x00660000), SHC(0x00660000), SHC(0x00309ca0), SHC(0x00000000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), + SHC(0xffffffff), SHC(0x00010000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x0d888000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), + SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), SHC(0x00000000), + SHC(0x00000170), SHC(0x00000000), SHC(0x00000000), SHC(0x6fb07880), SHC(0x6fb078a8), SHC(0x8d926000), + SHC(0x0d888000), SHC(0x8d888000), SHC(0x6fb079e0), SHC(0x00000000), SHC(0000000000), SHC(0x002f8000), + SHC(0x00000001), SHC(0x6fb07b40), SHC(0x00000000), SHC(0x6fb07b54), SHC(0x6fb07b70), SHC(0x6fb07b80), + SHC(0x6fb07b94), SHC(0x6fb07bcd), SHC(0x6fb07be6), SHC(0x6fb07c0e), SHC(0x6fb07c43), SHC(0x6fb07c4d), + SHC(0x6fb07c8f), SHC(0x6fb07d49), SHC(0x6fb07d71), SHC(0x6fb07d9e), SHC(0x6fb07daf), SHC(0x6fb07dbd), + SHC(0x6fb07dcc), SHC(0x6fb07ddf), SHC(0x6fb07de7), SHC(0x6fb07df8), SHC(0x6fb07e05), SHC(0x6fb07e45), + SHC(0x00000000), SHC(0x6fb07b18), SHC(0x6fb07e60), SHC(0x6fb07e70), SHC(0x6fb07e8f), SHC(0x6fb07ec4), + SHC(0x6fb07ee1), SHC(0x6fb07f17), SHC(0x6fb07f3e), SHC(0x6fb07f67), SHC(0x6fb07fa2), SHC(0x6fb07fdf), + SHC(0x6fb07fed), SHC(0x00000000), SHC(0x63657865), SHC(0x705f656c), SHC(0x65672f2e), SHC(0x6f526574), + SHC(0x00726f74), SHC(0x65672f2e), SHC(0x6f526574), SHC(0x00726f74), SHC(0x4f52505f), SHC(0x7070413d), + SHC(0x696d7265), SHC(0x4c454853), SHC(0x622f6e69), SHC(0x4d524554), SHC(0x322d6d72), SHC(0x00726f6c), + SHC(0x2f3d5249), SHC(0x646c6f66), SHC(0x6e2f3238), SHC(0x36737636), SHC(0x78663431), SHC(0x3031785f), + SHC(0x2f542f33), SHC(0x52505f4d), SHC(0x45565f4d), SHC(0x34343d4e), SHC(0x44575044), SHC(0x2f737265), + SHC(0x636f442f), SHC(0x6c2f7374), SHC(0x65747361), SHC(0x535f4d52), SHC(0x495f4e4f), SHC(0x34323939), + SHC(0x2d364133), SHC(0x4345382d), SHC(0x43344233), SHC(0x55003845), SHC(0x6d676c73), SHC(0x5455415f), + SHC(0x2f3d4b43), SHC(0x2f657461), SHC(0x2e6d6f63), SHC(0x616c2e65), SHC(0x64722e64), SHC(0x4b776b7a), + SHC(0x656e6574), SHC(0x3d485441), SHC(0x6d6f682f), SHC(0x69622f77), SHC(0x6c2f7273), SHC(0x6e69622f), + SHC(0x69622f72), SHC(0x2f3a6e69), SHC(0x6e696273), SHC(0x2f3a6e69), SHC(0x656d6f68), SHC(0x6e69622f), + SHC(0x31582f74), SHC(0x4c2f3a6e), SHC(0x412f7972), SHC(0x7273752f), SHC(0x70412f3a), SHC(0x6f697461), + SHC(0x61757369), SHC(0x6f696475), SHC(0x70612e65), SHC(0x6e65746e), SHC(0x756f7365), SHC(0x7070612f), + SHC(0x435f5f00), SHC(0x49656c64), SHC(0x65696669), SHC(0x70612e6d), SHC(0x6d726554), SHC(0x44575000), + SHC(0x2f737265), SHC(0x636f442f), SHC(0x6c2f7374), SHC(0x65747361), SHC(0x74706972), SHC(0x643d474e), + SHC(0x4654552e), SHC(0x465f4350), SHC(0x3078303d), SHC(0x40755c3d), SHC(0x00202477), SHC(0x56524553), + SHC(0x454d414e), SHC(0x4c564c48), SHC(0x3d454d4f), SHC(0x732f7372), SHC(0x4e474f4c), SHC(0x6d676c73), + SHC(0x59414c50), SHC(0x74617669), SHC(0x6f632f70), SHC(0x2e656c70), SHC(0x2e646863), SHC(0x53386438) + }; +#endif +const Word32 RotVector_960[2 * (480 - 60)] = { + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffd3154), SHC(0xfe531484), SHC(0x7ff4c56f), SHC(0xfca63bd8), + SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7fb9d759), SHC(0xf7a0dec9), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f76892f), SHC(0xf449acca), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7eace58a), SHC(0xeda208a5), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7e26b371), SHC(0xea52c166), SHC(0x7ddb4bfc), SHC(0xe8ac819d), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7cd80464), SHC(0xe3c02fbb), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7c0fc22a), SHC(0xe07e0c84), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x7aba9ae6), SHC(0xdba5629b), SHC(0x7a3e17f2), SHC(0xda0aecf9), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x793501a9), SHC(0xd6db1254), SHC(0x78a879f4), SHC(0xd545d11c), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x76e33b3f), SHC(0xd09192ea), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x759af34c), SHC(0xcd790887), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x743e0918), SHC(0xca695b94), SHC(0x7387ea23), SHC(0xc8e5032b), SHC(0x72ccb9db), SHC(0xc763158e), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x71474660), SHC(0xc466be4f), SHC(0x707d1443), SHC(0xc2ec7635), + SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6e010780), SHC(0xbe8df2ba), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x6c40cf2c), SHC(0xbbb28501), SHC(0x6b598ea3), SHC(0xba4944a2), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x697cf78a), SHC(0xb780001c), SHC(0x6887b5e2), SHC(0xb6201b3e), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x668f7c25), SHC(0xb36a1978), SHC(0x658c9a2d), SHC(0xb2141b02), + SHC(0x648543e4), SHC(0xb0c1878b), SHC(0x637984d4), SHC(0xaf726def), SHC(0x626968be), SHC(0xae26dcdf), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x603c496c), SHC(0xab9a8e6c), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x5dfe47ad), SHC(0xa91d0ea3), SHC(0x5cd91140), SHC(0xa7e3ff4d), SHC(0x5bafc837), SHC(0xa6aecd5e), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ff4c56f), SHC(0xfca63bd8), SHC(0x7fd317b4), SHC(0xf94d0e2e), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7ddb4bfc), SHC(0xe8ac819d), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7aba9ae6), SHC(0xdba5629b), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x78a879f4), SHC(0xd545d11c), SHC(0x777f903c), SHC(0xd220ffc0), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x7387ea23), SHC(0xc8e5032b), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x707d1443), SHC(0xc2ec7635), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x697cf78a), SHC(0xb780001c), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x637984d4), SHC(0xaf726def), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x5cd91140), SHC(0xa7e3ff4d), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x581c00b3), SHC(0xa326eec0), SHC(0x55a6125c), SHC(0xa0e0a15f), + SHC(0x53211d18), SHC(0x9eab046f), SHC(0x508d9211), SHC(0x9c867b2c), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x487fffe4), SHC(0x96830876), SHC(0x45b6bb5e), SHC(0x94a6715d), + SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x40000000), SHC(0x9126145f), SHC(0x3d1389cb), SHC(0x8f82ebbd), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x371afcd5), SHC(0x8c7815dd), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2ddf0040), SHC(0x88806fc4), SHC(0x2aba2ee4), SHC(0x8757860c), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x245a9d65), SHC(0x8545651a), SHC(0x2120fb83), SHC(0x845c8ae3), + SHC(0x1de189a6), SHC(0x838961e8), SHC(0x1a9cd9ac), SHC(0x82cc0f36), SHC(0x17537e63), SHC(0x8224b404), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x10b5150f), SHC(0x811855b4), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0x0a0af299), SHC(0x80650347), SHC(0x06b2f1d2), SHC(0x802ce84c), SHC(0x0359c428), SHC(0x800b3a91), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7f9afcb9), SHC(0xf5f50d67), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x743e0918), SHC(0xca695b94), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x6d23501b), SHC(0xbd1ec45c), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x648543e4), SHC(0xb0c1878b), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5dfe47ad), SHC(0xa91d0ea3), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x53211d18), SHC(0x9eab046f), SHC(0x4f3e7875), SHC(0x9b7abc1c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x471cece7), SHC(0x9592675c), SHC(0x42e13ba4), SHC(0x92dcafe5), + SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x3596a46c), SHC(0x8bc1f6e8), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2c4d9050), SHC(0x87e958a7), SHC(0x278dde6e), SHC(0x8643c7b3), + SHC(0x22be8f87), SHC(0x84ce444e), SHC(0x1de189a6), SHC(0x838961e8), SHC(0x18f8b83c), SHC(0x8275a0c0), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0f0b7727), SHC(0x80e321ff), SHC(0x0a0af299), SHC(0x80650347), + SHC(0x05067734), SHC(0x80194350), SHC(0x00000000), SHC(0x80000000), SHC(0xfaf988cc), SHC(0x80194350), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xf0f488d9), SHC(0x80e321ff), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xe21e765a), SHC(0x838961e8), SHC(0xdd417079), SHC(0x84ce444e), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xd3b26fb0), SHC(0x87e958a7), SHC(0xcf043ab3), SHC(0x89be50c3), + SHC(0xca695b94), SHC(0x8bc1f6e8), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xc174dbf2), SHC(0x90520d04), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb8e31319), SHC(0x9592675c), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0xb0c1878b), SHC(0x9b7abc1c), SHC(0xacdee2e8), SHC(0x9eab046f), SHC(0xa91d0ea3), SHC(0xa201b853), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6b598ea3), SHC(0xba4944a2), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x637984d4), SHC(0xaf726def), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x508d9211), SHC(0x9c867b2c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x45b6bb5e), SHC(0x94a6715d), SHC(0x40000000), SHC(0x9126145f), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x340ff242), SHC(0x8b10f144), SHC(0x2ddf0040), SHC(0x88806fc4), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x06b2f1d2), SHC(0x802ce84c), + SHC(0x00000000), SHC(0x80000000), SHC(0xf94d0e2e), SHC(0x802ce84c), SHC(0xf29ecfb2), SHC(0x80b381ac), + SHC(0xebf9f498), SHC(0x81936daf), SHC(0xe5632654), SHC(0x82cc0f36), SHC(0xdedf047d), SHC(0x845c8ae3), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xd220ffc0), SHC(0x88806fc4), SHC(0xcbf00dbe), SHC(0x8b10f144), + SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xc0000000), SHC(0x9126145f), SHC(0xba4944a2), SHC(0x94a6715d), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xaf726def), SHC(0x9c867b2c), SHC(0xaa59eda4), SHC(0xa0e0a15f), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0xa0e0a15f), SHC(0xaa59eda4), SHC(0x9c867b2c), SHC(0xaf726def), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x94a6715d), SHC(0xba4944a2), SHC(0x9126145f), SHC(0xc0000000), + SHC(0x8df37f8b), SHC(0xc5e3a3a9), SHC(0x8b10f144), SHC(0xcbf00dbe), SHC(0x88806fc4), SHC(0xd220ffc0), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x82cc0f36), SHC(0xe5632654), + SHC(0x81936daf), SHC(0xebf9f498), SHC(0x80b381ac), SHC(0xf29ecfb2), SHC(0x802ce84c), SHC(0xf94d0e2e), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb9d759), SHC(0xf7a0dec9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x793501a9), SHC(0xd6db1254), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x54657194), SHC(0x9fc3b694), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x471cece7), SHC(0x9592675c), SHC(0x40000000), SHC(0x9126145f), SHC(0x389cea72), SHC(0x8d334625), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2924edac), SHC(0x86cafe57), SHC(0x2120fb83), SHC(0x845c8ae3), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x10b5150f), SHC(0x811855b4), SHC(0x085f2137), SHC(0x804628a7), + SHC(0x00000000), SHC(0x80000000), SHC(0xf7a0dec9), SHC(0x804628a7), SHC(0xef4aeaf1), SHC(0x811855b4), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd6db1254), SHC(0x86cafe57), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc763158e), SHC(0x8d334625), SHC(0xc0000000), SHC(0x9126145f), + SHC(0xb8e31319), SHC(0x9592675c), SHC(0xb2141b02), SHC(0x9a7365d3), SHC(0xab9a8e6c), SHC(0x9fc3b694), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9fc3b694), SHC(0xab9a8e6c), SHC(0x9a7365d3), SHC(0xb2141b02), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x9126145f), SHC(0xc0000000), SHC(0x8d334625), SHC(0xc763158e), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x86cafe57), SHC(0xd6db1254), SHC(0x845c8ae3), SHC(0xdedf047d), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x811855b4), SHC(0xef4aeaf1), SHC(0x804628a7), SHC(0xf7a0dec9), + SHC(0x80000000), SHC(0x00000000), SHC(0x804628a7), SHC(0x085f2137), SHC(0x811855b4), SHC(0x10b5150f), + SHC(0x8275a0c0), SHC(0x18f8b83c), SHC(0x845c8ae3), SHC(0x2120fb83), SHC(0x86cafe57), SHC(0x2924edac), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x8d334625), SHC(0x389cea72), SHC(0x9126145f), SHC(0x40000000), + SHC(0x9592675c), SHC(0x471cece7), SHC(0x9a7365d3), SHC(0x4debe4fe), SHC(0x9fc3b694), SHC(0x54657194), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7e6c9251), SHC(0xebf9f498), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x678dde6e), SHC(0xb4c373ee), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x53211d18), SHC(0x9eab046f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x3a1c5c57), SHC(0x8df37f8b), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1de189a6), SHC(0x838961e8), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0a0af299), SHC(0x80650347), SHC(0x00000000), SHC(0x80000000), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xebf9f498), SHC(0x81936daf), SHC(0xe21e765a), SHC(0x838961e8), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb4c373ee), SHC(0x98722192), SHC(0xacdee2e8), SHC(0x9eab046f), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9eab046f), SHC(0xacdee2e8), SHC(0x98722192), SHC(0xb4c373ee), + SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8df37f8b), SHC(0xc5e3a3a9), SHC(0x89be50c3), SHC(0xcf043ab3), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x838961e8), SHC(0xe21e765a), SHC(0x81936daf), SHC(0xebf9f498), + SHC(0x80650347), SHC(0xf5f50d67), SHC(0x80000000), SHC(0x00000000), SHC(0x80650347), SHC(0x0a0af299), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x838961e8), SHC(0x1de189a6), SHC(0x8643c7b3), SHC(0x278dde6e), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x8df37f8b), SHC(0x3a1c5c57), SHC(0x92dcafe5), SHC(0x42e13ba4), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0x9eab046f), SHC(0x53211d18), SHC(0xa57d8666), SHC(0x5a82799a), + SHC(0xacdee2e8), SHC(0x6154fb91), SHC(0xb4c373ee), SHC(0x678dde6e), SHC(0xbd1ec45c), SHC(0x6d23501b), + SHC(0xc5e3a3a9), SHC(0x720c8075), SHC(0xcf043ab3), SHC(0x7641af3d), SHC(0xd8722192), SHC(0x79bc384d), + SHC(0xe21e765a), SHC(0x7c769e18), SHC(0xebf9f498), SHC(0x7e6c9251), SHC(0xf5f50d67), SHC(0x7f9afcb9), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f76892f), SHC(0xf449acca), SHC(0x7ddb4bfc), SHC(0xe8ac819d), + SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x72ccb9db), SHC(0xc763158e), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x668f7c25), SHC(0xb36a1978), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x444d7aff), SHC(0x93bf30d4), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x2f6e6d16), SHC(0x891cc4c1), SHC(0x245a9d65), SHC(0x8545651a), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x01aceb7c), SHC(0x8002ceac), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xea52c166), SHC(0x81d94c8f), SHC(0xdedf047d), SHC(0x845c8ae3), + SHC(0xd3b26fb0), SHC(0x87e958a7), SHC(0xc8e5032b), SHC(0x8c7815dd), SHC(0xbe8df2ba), SHC(0x91fef880), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xab9a8e6c), SHC(0x9fc3b694), SHC(0xa326eec0), SHC(0xa7e3ff4d), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x94a6715d), SHC(0xba4944a2), SHC(0x8eb8b9a0), SHC(0xc466be4f), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x85c1e80e), SHC(0xda0aecf9), SHC(0x82cc0f36), SHC(0xe5632654), + SHC(0x80e321ff), SHC(0xf0f488d9), SHC(0x800b3a91), SHC(0xfca63bd8), SHC(0x804628a7), SHC(0x085f2137), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x83f03dd6), SHC(0x1f81f37c), SHC(0x8757860c), SHC(0x2aba2ee4), + SHC(0x8bc1f6e8), SHC(0x3596a46c), SHC(0x9126145f), SHC(0x40000000), SHC(0x97784a1e), SHC(0x49dfe4c2), + SHC(0x9eab046f), SHC(0x53211d18), SHC(0xa6aecd5e), SHC(0x5bafc837), SHC(0xaf726def), SHC(0x637984d4), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xc2ec7635), SHC(0x707d1443), SHC(0xcd790887), SHC(0x759af34c), + SHC(0xd8722192), SHC(0x79bc384d), SHC(0xe3c02fbb), SHC(0x7cd80464), SHC(0xef4aeaf1), SHC(0x7ee7aa4c), + SHC(0xfaf988cc), SHC(0x7fe6bcb0), SHC(0x06b2f1d2), SHC(0x7fd317b4), SHC(0x125df75b), SHC(0x7eace58a), + SHC(0x1de189a6), SHC(0x7c769e18), SHC(0x2924edac), SHC(0x793501a9), SHC(0x340ff242), SHC(0x74ef0ebc), + SHC(0x3e8b240e), SHC(0x6fadf2fc), SHC(0x487fffe4), SHC(0x697cf78a), SHC(0x51d92321), SHC(0x626968be)}; +# endif + +#ifdef ENABLE_FFT_30X16 +/* Twiddle coefficients for 30x16 FFTs, generated by fft_tables.py */ +# ifdef ENABLE_HR_MODE +const Word32 RotVector_30_16[2 * (480 - 30)] = { + + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffd3154), SHC(0xfe531484), SHC(0x7ff4c56f), SHC(0xfca63bd8), + SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7fb9d759), SHC(0xf7a0dec9), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f76892f), SHC(0xf449acca), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7eace58a), SHC(0xeda208a5), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7e26b371), SHC(0xea52c166), SHC(0x7ddb4bfc), SHC(0xe8ac819d), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7cd80464), SHC(0xe3c02fbb), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7c0fc22a), SHC(0xe07e0c84), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x7aba9ae6), SHC(0xdba5629b), SHC(0x7a3e17f2), SHC(0xda0aecf9), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x793501a9), SHC(0xd6db1254), SHC(0x78a879f4), SHC(0xd545d11c), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x76e33b3f), SHC(0xd09192ea), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ff4c56f), SHC(0xfca63bd8), SHC(0x7fd317b4), SHC(0xf94d0e2e), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7ddb4bfc), SHC(0xe8ac819d), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7aba9ae6), SHC(0xdba5629b), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x78a879f4), SHC(0xd545d11c), SHC(0x777f903c), SHC(0xd220ffc0), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x7387ea23), SHC(0xc8e5032b), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x707d1443), SHC(0xc2ec7635), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x697cf78a), SHC(0xb780001c), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x637984d4), SHC(0xaf726def), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x5cd91140), SHC(0xa7e3ff4d), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7f9afcb9), SHC(0xf5f50d67), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x743e0918), SHC(0xca695b94), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x6d23501b), SHC(0xbd1ec45c), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x648543e4), SHC(0xb0c1878b), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5dfe47ad), SHC(0xa91d0ea3), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x53211d18), SHC(0x9eab046f), SHC(0x4f3e7875), SHC(0x9b7abc1c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x471cece7), SHC(0x9592675c), SHC(0x42e13ba4), SHC(0x92dcafe5), + SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x3596a46c), SHC(0x8bc1f6e8), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6b598ea3), SHC(0xba4944a2), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x637984d4), SHC(0xaf726def), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x508d9211), SHC(0x9c867b2c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x45b6bb5e), SHC(0x94a6715d), SHC(0x40000000), SHC(0x9126145f), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x340ff242), SHC(0x8b10f144), SHC(0x2ddf0040), SHC(0x88806fc4), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x06b2f1d2), SHC(0x802ce84c), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb9d759), SHC(0xf7a0dec9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x793501a9), SHC(0xd6db1254), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x54657194), SHC(0x9fc3b694), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x471cece7), SHC(0x9592675c), SHC(0x40000000), SHC(0x9126145f), SHC(0x389cea72), SHC(0x8d334625), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2924edac), SHC(0x86cafe57), SHC(0x2120fb83), SHC(0x845c8ae3), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x10b5150f), SHC(0x811855b4), SHC(0x085f2137), SHC(0x804628a7), + SHC(0x00000000), SHC(0x80000000), SHC(0xf7a0dec9), SHC(0x804628a7), SHC(0xef4aeaf1), SHC(0x811855b4), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd6db1254), SHC(0x86cafe57), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7e6c9251), SHC(0xebf9f498), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x678dde6e), SHC(0xb4c373ee), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x53211d18), SHC(0x9eab046f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x3a1c5c57), SHC(0x8df37f8b), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1de189a6), SHC(0x838961e8), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0a0af299), SHC(0x80650347), SHC(0x00000000), SHC(0x80000000), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xebf9f498), SHC(0x81936daf), SHC(0xe21e765a), SHC(0x838961e8), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb4c373ee), SHC(0x98722192), SHC(0xacdee2e8), SHC(0x9eab046f), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f76892f), SHC(0xf449acca), SHC(0x7ddb4bfc), SHC(0xe8ac819d), + SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x72ccb9db), SHC(0xc763158e), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x668f7c25), SHC(0xb36a1978), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x444d7aff), SHC(0x93bf30d4), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x2f6e6d16), SHC(0x891cc4c1), SHC(0x245a9d65), SHC(0x8545651a), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x01aceb7c), SHC(0x8002ceac), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xea52c166), SHC(0x81d94c8f), SHC(0xdedf047d), SHC(0x845c8ae3), + SHC(0xd3b26fb0), SHC(0x87e958a7), SHC(0xc8e5032b), SHC(0x8c7815dd), SHC(0xbe8df2ba), SHC(0x91fef880), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xab9a8e6c), SHC(0x9fc3b694), SHC(0xa326eec0), SHC(0xa7e3ff4d), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x94a6715d), SHC(0xba4944a2), SHC(0x8eb8b9a0), SHC(0xc466be4f), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x55a6125c), SHC(0xa0e0a15f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x40000000), SHC(0x9126145f), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0x00000000), SHC(0x80000000), SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe5632654), SHC(0x82cc0f36), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcbf00dbe), SHC(0x8b10f144), SHC(0xc0000000), SHC(0x9126145f), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0xa0e0a15f), SHC(0xaa59eda4), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x9126145f), SHC(0xc0000000), SHC(0x8b10f144), SHC(0xcbf00dbe), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x80b381ac), SHC(0xf29ecfb2), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x4b3c8c12), SHC(0x98722192), + SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x22be8f87), SHC(0x84ce444e), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x05067734), SHC(0x80194350), SHC(0xf5f50d67), SHC(0x80650347), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xca695b94), SHC(0x8bc1f6e8), + SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb0c1878b), SHC(0x9b7abc1c), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8bc1f6e8), SHC(0xca695b94), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80650347), SHC(0xf5f50d67), + SHC(0x80194350), SHC(0x05067734), SHC(0x81936daf), SHC(0x14060b68), SHC(0x84ce444e), SHC(0x22be8f87), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x658c9a2d), SHC(0xb2141b02), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x40000000), SHC(0x9126145f), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x10b5150f), SHC(0x811855b4), + SHC(0x00000000), SHC(0x80000000), SHC(0xef4aeaf1), SHC(0x811855b4), SHC(0xdedf047d), SHC(0x845c8ae3), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc0000000), SHC(0x9126145f), SHC(0xb2141b02), SHC(0x9a7365d3), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9a7365d3), SHC(0xb2141b02), SHC(0x9126145f), SHC(0xc0000000), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x811855b4), SHC(0xef4aeaf1), + SHC(0x80000000), SHC(0x00000000), SHC(0x811855b4), SHC(0x10b5150f), SHC(0x845c8ae3), SHC(0x2120fb83), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9126145f), SHC(0x40000000), SHC(0x9a7365d3), SHC(0x4debe4fe), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7eace58a), SHC(0xeda208a5), SHC(0x7aba9ae6), SHC(0xdba5629b), + SHC(0x743e0918), SHC(0xca695b94), SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x53211d18), SHC(0x9eab046f), SHC(0x444d7aff), SHC(0x93bf30d4), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x22be8f87), SHC(0x84ce444e), SHC(0x10b5150f), SHC(0x811855b4), SHC(0xfe531484), SHC(0x8002ceac), + SHC(0xebf9f498), SHC(0x81936daf), SHC(0xda0aecf9), SHC(0x85c1e80e), SHC(0xc8e5032b), SHC(0x8c7815dd), + SHC(0xb8e31319), SHC(0x9592675c), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0x9d969742), SHC(0xae26dcdf), + SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8a650cb4), SHC(0xcd790887), SHC(0x845c8ae3), SHC(0xdedf047d), + SHC(0x80e321ff), SHC(0xf0f488d9), SHC(0x800b3a91), SHC(0x0359c428), SHC(0x81d94c8f), SHC(0x15ad3e9a), + SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8d334625), SHC(0x389cea72), SHC(0x96830876), SHC(0x487fffe4), + SHC(0xa201b853), SHC(0x56e2f15d), SHC(0xaf726def), SHC(0x637984d4), SHC(0xbe8df2ba), SHC(0x6e010780), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x278dde6e), SHC(0x8643c7b3), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x00000000), SHC(0x80000000), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8df37f8b), SHC(0xc5e3a3a9), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x81936daf), SHC(0xebf9f498), SHC(0x80000000), SHC(0x00000000), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8df37f8b), SHC(0x3a1c5c57), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0xa57d8666), SHC(0x5a82799a), SHC(0xb4c373ee), SHC(0x678dde6e), + SHC(0xc5e3a3a9), SHC(0x720c8075), SHC(0xd8722192), SHC(0x79bc384d), SHC(0xebf9f498), SHC(0x7e6c9251), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e26b371), SHC(0xea52c166), SHC(0x78a879f4), SHC(0xd545d11c), + SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x637984d4), SHC(0xaf726def), SHC(0x54657194), SHC(0x9fc3b694), + SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x2f6e6d16), SHC(0x891cc4c1), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x05067734), SHC(0x80194350), SHC(0xef4aeaf1), SHC(0x811855b4), SHC(0xda0aecf9), SHC(0x85c1e80e), + SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb36a1978), SHC(0x997083db), SHC(0xa326eec0), SHC(0xa7e3ff4d), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x8b10f144), SHC(0xcbf00dbe), SHC(0x83f03dd6), SHC(0xe07e0c84), + SHC(0x80650347), SHC(0xf5f50d67), SHC(0x808976d1), SHC(0x0bb65336), SHC(0x845c8ae3), SHC(0x2120fb83), + SHC(0x8bc1f6e8), SHC(0x3596a46c), SHC(0x96830876), SHC(0x487fffe4), SHC(0xa45037c9), SHC(0x595132a2), + SHC(0xb4c373ee), SHC(0x678dde6e), SHC(0xc763158e), SHC(0x72ccb9db), SHC(0xdba5629b), SHC(0x7aba9ae6), + SHC(0xf0f488d9), SHC(0x7f1cde01), SHC(0x06b2f1d2), SHC(0x7fd317b4), SHC(0x1c3fd045), SHC(0x7cd80464), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ddb4bfc), SHC(0xe8ac819d), SHC(0x777f903c), SHC(0xd220ffc0), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x245a9d65), SHC(0x8545651a), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xc8e5032b), SHC(0x8c7815dd), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xa326eec0), SHC(0xa7e3ff4d), SHC(0x94a6715d), SHC(0xba4944a2), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x800b3a91), SHC(0xfca63bd8), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8757860c), SHC(0x2aba2ee4), SHC(0x9126145f), SHC(0x40000000), + SHC(0x9eab046f), SHC(0x53211d18), SHC(0xaf726def), SHC(0x637984d4), SHC(0xc2ec7635), SHC(0x707d1443), + SHC(0xd8722192), SHC(0x79bc384d), SHC(0xef4aeaf1), SHC(0x7ee7aa4c), SHC(0x06b2f1d2), SHC(0x7fd317b4), + SHC(0x1de189a6), SHC(0x7c769e18), SHC(0x340ff242), SHC(0x74ef0ebc), SHC(0x487fffe4), SHC(0x697cf78a), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x471cece7), SHC(0x9592675c), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x00000000), SHC(0x80000000), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xb8e31319), SHC(0x9592675c), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9592675c), SHC(0xb8e31319), SHC(0x89be50c3), SHC(0xcf043ab3), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80000000), SHC(0x00000000), SHC(0x8275a0c0), SHC(0x18f8b83c), + SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9592675c), SHC(0x471cece7), SHC(0xa57d8666), SHC(0x5a82799a), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xcf043ab3), SHC(0x7641af3d), SHC(0xe70747c4), SHC(0x7d8a5f40), + SHC(0x00000000), SHC(0x7fffffff), SHC(0x18f8b83c), SHC(0x7d8a5f40), SHC(0x30fbc54d), SHC(0x7641af3d), + SHC(0x471cece7), SHC(0x6a6d98a4), SHC(0x5a82799a), SHC(0x5a82799a), SHC(0x6a6d98a4), SHC(0x471cece7)}; +# endif +#endif + +# ifdef ENABLE_HR_MODE +const Word32 RotVector_360[2 * (360 - 30)] = { +# else +const Word16 RotVector_360[2 * (360 - 30)] = { +# endif + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffb0260), SHC(0xfdc41e9b), SHC(0x7fec09e3), SHC(0xfb8869ce), + SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7fb02dc6), SHC(0xf7123849), SHC(0x7f834ed0), SHC(0xf4d814a4), + SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7f0bc097), SHC(0xf06695da), SHC(0x7ec11aa5), SHC(0xee2f9369), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7e0e2e32), SHC(0xe9c5e582), SHC(0x7da5f5a5), SHC(0xe7939223), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7cb82885), SHC(0xe334cdc9), SHC(0x7c32a67e), SHC(0xe108b40d), + SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), SHC(0x7a6831ba), SHC(0xda939061), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7906c0b0), SHC(0xd653c860), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x76adf5e6), SHC(0xd00ce422), SHC(0x75d31a61), SHC(0xcdfc85bb), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x7401e4c1), SHC(0xc9e7a512), SHC(0x730baeed), SHC(0xc7e3744b), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x6ff389df), SHC(0xc1f1c224), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fec09e3), SHC(0xfb8869ce), SHC(0x7fb02dc6), SHC(0xf7123849), + SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7ec11aa5), SHC(0xee2f9369), SHC(0x7e0e2e32), SHC(0xe9c5e582), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7c32a67e), SHC(0xe108b40d), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7847d909), SHC(0xd438af17), SHC(0x76adf5e6), SHC(0xd00ce422), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x730baeed), SHC(0xc7e3744b), SHC(0x71046d3e), SHC(0xc3e85b18), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6c8cd70b), SHC(0xbc2b9b05), SHC(0x6a1de737), SHC(0xb86c5df0), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x64dd8950), SHC(0xb1320139), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x5c13539b), SHC(0xa7156f3c), SHC(0x58ea90c4), SHC(0xa3ecac65), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x5246dd49), SHC(0x9df24175), SHC(0x4ecdfec7), SHC(0x9b2276b0), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x4793a210), SHC(0x95e218c9), SHC(0x43d464fb), SHC(0x937328f5), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fd317b4), SHC(0xf94d0e2e), SHC(0x7f4c7e54), SHC(0xf29ecfb2), + SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7ba3751d), SHC(0xdedf047d), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6b598ea3), SHC(0xba4944a2), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x637984d4), SHC(0xaf726def), SHC(0x5f1f5ea1), SHC(0xaa59eda4), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x508d9211), SHC(0x9c867b2c), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x45b6bb5e), SHC(0x94a6715d), SHC(0x40000000), SHC(0x9126145f), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x340ff242), SHC(0x8b10f144), SHC(0x2ddf0040), SHC(0x88806fc4), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x06b2f1d2), SHC(0x802ce84c), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb02dc6), SHC(0xf7123849), SHC(0x7ec11aa5), SHC(0xee2f9369), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x6c8cd70b), SHC(0xbc2b9b05), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x620dbe8b), SHC(0xadb922b7), SHC(0x5c13539b), SHC(0xa7156f3c), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x4ecdfec7), SHC(0x9b2276b0), SHC(0x4793a210), SHC(0x95e218c9), + SHC(0x40000000), SHC(0x9126145f), SHC(0x381c8bb5), SHC(0x8cf45113), SHC(0x2ff31bde), SHC(0x89520a1a), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1ef74bf3), SHC(0x83cd5982), SHC(0x163a1a7e), SHC(0x81f1d1ce), + SHC(0x0d61304e), SHC(0x80b381ac), SHC(0x04779632), SHC(0x8013f61d), SHC(0xfb8869ce), SHC(0x8013f61d), + SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe9c5e582), SHC(0x81f1d1ce), SHC(0xe108b40d), SHC(0x83cd5982), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xd00ce422), SHC(0x89520a1a), SHC(0xc7e3744b), SHC(0x8cf45113), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f834ed0), SHC(0xf4d814a4), SHC(0x7e0e2e32), SHC(0xe9c5e582), + SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7847d909), SHC(0xd438af17), SHC(0x7401e4c1), SHC(0xc9e7a512), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x68d9f964), SHC(0xb6950c1e), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x5246dd49), SHC(0x9df24175), SHC(0x496af3e2), SHC(0x9726069c), + SHC(0x40000000), SHC(0x9126145f), SHC(0x36185aee), SHC(0x8bfe1b3f), SHC(0x2bc750e9), SHC(0x87b826f7), + SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x163a1a7e), SHC(0x81f1d1ce), SHC(0x0b27eb5c), SHC(0x807cb130), + SHC(0x00000000), SHC(0x80000000), SHC(0xf4d814a4), SHC(0x807cb130), SHC(0xe9c5e582), SHC(0x81f1d1ce), + SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd438af17), SHC(0x87b826f7), SHC(0xc9e7a512), SHC(0x8bfe1b3f), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xb6950c1e), SHC(0x9726069c), SHC(0xadb922b7), SHC(0x9df24175), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9df24175), SHC(0xadb922b7), SHC(0x9726069c), SHC(0xb6950c1e), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f4c7e54), SHC(0xf29ecfb2), SHC(0x7d33f0ca), SHC(0xe5632654), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x55a6125c), SHC(0xa0e0a15f), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x40000000), SHC(0x9126145f), SHC(0x340ff242), SHC(0x8b10f144), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1a9cd9ac), SHC(0x82cc0f36), SHC(0x0d61304e), SHC(0x80b381ac), + SHC(0x00000000), SHC(0x80000000), SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe5632654), SHC(0x82cc0f36), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xcbf00dbe), SHC(0x8b10f144), SHC(0xc0000000), SHC(0x9126145f), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0xa0e0a15f), SHC(0xaa59eda4), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x9126145f), SHC(0xc0000000), SHC(0x8b10f144), SHC(0xcbf00dbe), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x80b381ac), SHC(0xf29ecfb2), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f0bc097), SHC(0xf06695da), SHC(0x7c32a67e), SHC(0xe108b40d), + SHC(0x777f903c), SHC(0xd220ffc0), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x68d9f964), SHC(0xb6950c1e), + SHC(0x5f1f5ea1), SHC(0xaa59eda4), SHC(0x53f9be05), SHC(0x9f65ad2d), SHC(0x4793a210), SHC(0x95e218c9), + SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x2bc750e9), SHC(0x87b826f7), SHC(0x1ccb3237), SHC(0x8347d77b), + SHC(0x0d61304e), SHC(0x80b381ac), SHC(0xfdc41e9b), SHC(0x8004fda0), SHC(0xee2f9369), SHC(0x813ee55b), + SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd00ce422), SHC(0x89520a1a), SHC(0xc1f1c224), SHC(0x900c7621), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xa8b4471a), SHC(0xa263007d), SHC(0x9df24175), SHC(0xadb922b7), + SHC(0x94a6715d), SHC(0xba4944a2), SHC(0x8cf45113), SHC(0xc7e3744b), SHC(0x86f93f50), SHC(0xd653c860), + SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x807cb130), SHC(0xf4d814a4), SHC(0x8013f61d), SHC(0x04779632), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x84f56073), SHC(0x234815ba), SHC(0x8a2ce59f), SHC(0x32037a45), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ec11aa5), SHC(0xee2f9369), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6c8cd70b), SHC(0xbc2b9b05), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x4793a210), SHC(0x95e218c9), SHC(0x381c8bb5), SHC(0x8cf45113), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x163a1a7e), SHC(0x81f1d1ce), SHC(0x04779632), SHC(0x8013f61d), + SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe108b40d), SHC(0x83cd5982), SHC(0xd00ce422), SHC(0x89520a1a), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xb1320139), SHC(0x9b2276b0), SHC(0xa3ecac65), SHC(0xa7156f3c), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8efb92c2), SHC(0xc3e85b18), SHC(0x87b826f7), SHC(0xd438af17), + SHC(0x82cc0f36), SHC(0xe5632654), SHC(0x804fd23a), SHC(0xf7123849), SHC(0x804fd23a), SHC(0x08edc7b7), + SHC(0x82cc0f36), SHC(0x1a9cd9ac), SHC(0x87b826f7), SHC(0x2bc750e9), SHC(0x8efb92c2), SHC(0x3c17a4e8), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0xa3ecac65), SHC(0x58ea90c4), SHC(0xb1320139), SHC(0x64dd8950), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x278dde6e), SHC(0x8643c7b3), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x00000000), SHC(0x80000000), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8df37f8b), SHC(0xc5e3a3a9), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x81936daf), SHC(0xebf9f498), SHC(0x80000000), SHC(0x00000000), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x8df37f8b), SHC(0x3a1c5c57), + SHC(0x98722192), SHC(0x4b3c8c12), SHC(0xa57d8666), SHC(0x5a82799a), SHC(0xb4c373ee), SHC(0x678dde6e), + SHC(0xc5e3a3a9), SHC(0x720c8075), SHC(0xd8722192), SHC(0x79bc384d), SHC(0xebf9f498), SHC(0x7e6c9251), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e0e2e32), SHC(0xe9c5e582), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x620dbe8b), SHC(0xadb922b7), SHC(0x5246dd49), SHC(0x9df24175), + SHC(0x40000000), SHC(0x9126145f), SHC(0x2bc750e9), SHC(0x87b826f7), SHC(0x163a1a7e), SHC(0x81f1d1ce), + SHC(0x00000000), SHC(0x80000000), SHC(0xe9c5e582), SHC(0x81f1d1ce), SHC(0xd438af17), SHC(0x87b826f7), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xadb922b7), SHC(0x9df24175), SHC(0x9df24175), SHC(0xadb922b7), + SHC(0x9126145f), SHC(0xc0000000), SHC(0x87b826f7), SHC(0xd438af17), SHC(0x81f1d1ce), SHC(0xe9c5e582), + SHC(0x80000000), SHC(0x00000000), SHC(0x81f1d1ce), SHC(0x163a1a7e), SHC(0x87b826f7), SHC(0x2bc750e9), + SHC(0x9126145f), SHC(0x40000000), SHC(0x9df24175), SHC(0x5246dd49), SHC(0xadb922b7), SHC(0x620dbe8b), + SHC(0xc0000000), SHC(0x6ed9eba1), SHC(0xd438af17), SHC(0x7847d909), SHC(0xe9c5e582), SHC(0x7e0e2e32), + SHC(0x00000000), SHC(0x7fffffff), SHC(0x163a1a7e), SHC(0x7e0e2e32), SHC(0x2bc750e9), SHC(0x7847d909), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7da5f5a5), SHC(0xe7939223), SHC(0x76adf5e6), SHC(0xd00ce422), + SHC(0x6b598ea3), SHC(0xba4944a2), SHC(0x5c13539b), SHC(0xa7156f3c), SHC(0x496af3e2), SHC(0x9726069c), + SHC(0x340ff242), SHC(0x8b10f144), SHC(0x1ccb3237), SHC(0x8347d77b), SHC(0x04779632), SHC(0x8013f61d), + SHC(0xebf9f498), SHC(0x81936daf), SHC(0xd438af17), SHC(0x87b826f7), SHC(0xbe133b7c), SHC(0x92485786), + SHC(0xaa59eda4), SHC(0xa0e0a15f), SHC(0x99c64fc5), SHC(0xb2f7b9af), SHC(0x8cf45113), SHC(0xc7e3744b), + SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x804fd23a), SHC(0xf7123849), SHC(0x80f43f69), SHC(0x0f996a26), + SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x900c7621), SHC(0x3e0e3ddc), SHC(0x9df24175), SHC(0x5246dd49), + SHC(0xaf726def), SHC(0x637984d4), SHC(0xc3e85b18), SHC(0x71046d3e), SHC(0xda939061), SHC(0x7a6831ba), + SHC(0xf29ecfb2), SHC(0x7f4c7e54), SHC(0x0b27eb5c), SHC(0x7f834ed0), SHC(0x234815ba), SHC(0x7b0a9f8d), + SHC(0x3a1c5c57), SHC(0x720c8075), SHC(0x4ecdfec7), SHC(0x64dd8950), SHC(0x609a52d3), SHC(0x53f9be05)}; + +# ifdef ENABLE_HR_MODE +const Word32 RotVector_320[2 * (320 - 20)] = { +# else +const Word16 RotVector_320[2 * (320 - 20)] = { +# endif + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7f9afcb9), SHC(0xf5f50d67), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x743e0918), SHC(0xca695b94), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x6d23501b), SHC(0xbd1ec45c), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x648543e4), SHC(0xb0c1878b), + SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5dfe47ad), SHC(0xa91d0ea3), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x720c8075), SHC(0xc5e3a3a9), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x6154fb91), SHC(0xacdee2e8), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x53211d18), SHC(0x9eab046f), SHC(0x4b3c8c12), SHC(0x98722192), + SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x1de189a6), SHC(0x838961e8), SHC(0x14060b68), SHC(0x81936daf), + SHC(0x0a0af299), SHC(0x80650347), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f1cde01), SHC(0xf0f488d9), + SHC(0x7c769e18), SHC(0xe21e765a), SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x720c8075), SHC(0xc5e3a3a9), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x56e2f15d), SHC(0xa201b853), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x22be8f87), SHC(0x84ce444e), SHC(0x14060b68), SHC(0x81936daf), SHC(0x05067734), SHC(0x80194350), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xd8722192), SHC(0x8643c7b3), + SHC(0xca695b94), SHC(0x8bc1f6e8), SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xb0c1878b), SHC(0x9b7abc1c), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x79bc384d), SHC(0xd8722192), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x4b3c8c12), SHC(0x98722192), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x278dde6e), SHC(0x8643c7b3), + SHC(0x14060b68), SHC(0x81936daf), SHC(0x00000000), SHC(0x80000000), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8df37f8b), SHC(0xc5e3a3a9), + SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x81936daf), SHC(0xebf9f498), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x471cece7), SHC(0x9592675c), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x00000000), SHC(0x80000000), SHC(0xe70747c4), SHC(0x8275a0c0), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xb8e31319), SHC(0x9592675c), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x8275a0c0), SHC(0xe70747c4), + SHC(0x80000000), SHC(0x00000000), SHC(0x8275a0c0), SHC(0x18f8b83c), SHC(0x89be50c3), SHC(0x30fbc54d), + SHC(0x9592675c), SHC(0x471cece7), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x4b3c8c12), SHC(0x98722192), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x14060b68), SHC(0x81936daf), SHC(0xf5f50d67), SHC(0x80650347), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x8643c7b3), SHC(0xd8722192), SHC(0x80650347), SHC(0xf5f50d67), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x98722192), SHC(0x4b3c8c12), + SHC(0xacdee2e8), SHC(0x6154fb91), SHC(0xc5e3a3a9), SHC(0x720c8075), SHC(0xe21e765a), SHC(0x7c769e18), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x6d23501b), SHC(0xbd1ec45c), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x18f8b83c), SHC(0x8275a0c0), + SHC(0xf5f50d67), SHC(0x80650347), SHC(0xd3b26fb0), SHC(0x87e958a7), SHC(0xb4c373ee), SHC(0x98722192), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x80e321ff), SHC(0xf0f488d9), + SHC(0x81936daf), SHC(0x14060b68), SHC(0x8bc1f6e8), SHC(0x3596a46c), SHC(0x9eab046f), SHC(0x53211d18), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xd8722192), SHC(0x79bc384d), SHC(0xfaf988cc), SHC(0x7fe6bcb0), + SHC(0x1de189a6), SHC(0x7c769e18), SHC(0x3e8b240e), SHC(0x6fadf2fc), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7ff9af04), SHC(0xfd7ca4a6), SHC(0x7fe6bcb0), SHC(0xfaf988cc), SHC(0x7fc72ae2), SHC(0xf876ebe8), + SHC(0x7f9afcb9), SHC(0xf5f50d67), SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7f1cde01), SHC(0xf0f488d9), + SHC(0x7ecaf9e5), SHC(0xee76612d), SHC(0x7e6c9251), SHC(0xebf9f498), SHC(0x7e01b096), SHC(0xe97f81eb), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7d06aa16), SHC(0xe4918486), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x7bda497d), SHC(0xdfae5b23), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x7a7d055b), SHC(0xdad7f3a2), + SHC(0x79bc384d), SHC(0xd8722192), SHC(0x78ef678f), SHC(0xd61036db), SHC(0x7816a759), SHC(0xd3b26fb0), + SHC(0x77320d0d), SHC(0xd15907d9), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fc72ae2), SHC(0xf876ebe8), + SHC(0x7f1cde01), SHC(0xf0f488d9), SHC(0x7e01b096), SHC(0xe97f81eb), SHC(0x7c769e18), SHC(0xe21e765a), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x7545a5a0), SHC(0xccb44322), + SHC(0x720c8075), SHC(0xc5e3a3a9), SHC(0x6e6e1492), SHC(0xbf469e83), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x660e9a6a), SHC(0xb2beadcc), SHC(0x6154fb91), SHC(0xacdee2e8), SHC(0x5c44ee40), SHC(0xa748e9ce), + SHC(0x56e2f15d), SHC(0xa201b853), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x4b3c8c12), SHC(0x98722192), + SHC(0x45027c0c), SHC(0x943239c7), SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x37dc420c), SHC(0x8cd50c59), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x70e2cbc6), SHC(0xc3a94590), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x471cece7), SHC(0x9592675c), SHC(0x3c56ba70), SHC(0x8f1d343a), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x25280c5e), SHC(0x8582faa5), SHC(0x18f8b83c), SHC(0x8275a0c0), + SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0x00000000), SHC(0x80000000), SHC(0xf3742ca2), SHC(0x809dc971), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdad7f3a2), SHC(0x8582faa5), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7ecaf9e5), SHC(0xee76612d), SHC(0x7b31bbb2), SHC(0xdd417079), SHC(0x7545a5a0), SHC(0xccb44322), + SHC(0x6d23501b), SHC(0xbd1ec45c), SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x56e2f15d), SHC(0xa201b853), + SHC(0x4930590f), SHC(0x96fd15e3), SHC(0x3a1c5c57), SHC(0x8df37f8b), SHC(0x29efc925), SHC(0x87109871), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x07891418), SHC(0x8038d51e), SHC(0xf5f50d67), SHC(0x80650347), + SHC(0xe4918486), SHC(0x82f955ea), SHC(0xd3b26fb0), SHC(0x87e958a7), SHC(0xc3a94590), SHC(0x8f1d343a), + SHC(0xb4c373ee), SHC(0x98722192), SHC(0xa748e9ce), SHC(0xa3bb11c0), SHC(0x9b7abc1c), SHC(0xb0c1878b), + SHC(0x9191eb6e), SHC(0xbf469e83), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e01b096), SHC(0xe97f81eb), + SHC(0x7816a759), SHC(0xd3b26fb0), SHC(0x6e6e1492), SHC(0xbf469e83), SHC(0x6154fb91), SHC(0xacdee2e8), + SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x3e8b240e), SHC(0x90520d04), SHC(0x29efc925), SHC(0x87109871), + SHC(0x14060b68), SHC(0x81936daf), SHC(0xfd7ca4a6), SHC(0x800650fc), SHC(0xe70747c4), SHC(0x8275a0c0), + SHC(0xd15907d9), SHC(0x88cdf2f3), SHC(0xbd1ec45c), SHC(0x92dcafe5), SHC(0xaaf9c6af), SHC(0xa051a5ab), + SHC(0x9b7abc1c), SHC(0xb0c1878b), SHC(0x8f1d343a), SHC(0xc3a94590), SHC(0x8643c7b3), SHC(0xd8722192), + SHC(0x8135061b), SHC(0xee76612d), SHC(0x80194350), SHC(0x05067734), SHC(0x82f955ea), SHC(0x1b6e7b7a), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7d06aa16), SHC(0xe4918486), SHC(0x743e0918), SHC(0xca695b94), + SHC(0x660e9a6a), SHC(0xb2beadcc), SHC(0x53211d18), SHC(0x9eab046f), SHC(0x3c56ba70), SHC(0x8f1d343a), + SHC(0x22be8f87), SHC(0x84ce444e), SHC(0x07891418), SHC(0x8038d51e), SHC(0xebf9f498), SHC(0x81936daf), + SHC(0xd15907d9), SHC(0x88cdf2f3), SHC(0xb8e31319), SHC(0x9592675c), SHC(0xa3bb11c0), SHC(0xa748e9ce), + SHC(0x92dcafe5), SHC(0xbd1ec45c), SHC(0x87109871), SHC(0xd61036db), SHC(0x80e321ff), SHC(0xf0f488d9), + SHC(0x809dc971), SHC(0x0c8bd35e), SHC(0x8643c7b3), SHC(0x278dde6e), SHC(0x9191eb6e), SHC(0x40b9617d), + SHC(0xa201b853), SHC(0x56e2f15d), SHC(0xb6cfa6f1), SHC(0x6902ea1d), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7bda497d), SHC(0xdfae5b23), SHC(0x6fadf2fc), SHC(0xc174dbf2), SHC(0x5c44ee40), SHC(0xa748e9ce), + SHC(0x42e13ba4), SHC(0x92dcafe5), SHC(0x25280c5e), SHC(0x8582faa5), SHC(0x05067734), SHC(0x80194350), + SHC(0xe4918486), SHC(0x82f955ea), SHC(0xc5e3a3a9), SHC(0x8df37f8b), SHC(0xaaf9c6af), SHC(0xa051a5ab), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x87109871), SHC(0xd61036db), SHC(0x80650347), SHC(0xf5f50d67), + SHC(0x81fe4f6a), SHC(0x16807e15), SHC(0x8bc1f6e8), SHC(0x3596a46c), SHC(0x9d0dfe54), SHC(0x5133cc94), + SHC(0xb4c373ee), SHC(0x678dde6e), SHC(0xd15907d9), SHC(0x77320d0d), SHC(0xf0f488d9), SHC(0x7f1cde01), + SHC(0x11899ed3), SHC(0x7ecaf9e5), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7a7d055b), SHC(0xdad7f3a2), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xc3a94590), SHC(0x8f1d343a), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x8f1d343a), SHC(0xc3a94590), SHC(0x8275a0c0), SHC(0xe70747c4), + SHC(0x809dc971), SHC(0x0c8bd35e), SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9d0dfe54), SHC(0x5133cc94), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xdad7f3a2), SHC(0x7a7d055b), SHC(0x00000000), SHC(0x7fffffff), + SHC(0x25280c5e), SHC(0x7a7d055b), SHC(0x471cece7), SHC(0x6a6d98a4), SHC(0x62f201ac), SHC(0x5133cc94)}; + + +/* Twiddle coefficients for 32x8 FFTs, generated by fft_tables.py */ +# ifdef ENABLE_HR_MODE +const Word32 RotVector_32_8[2 * (256 - 32)] = { +# else +const Word16 RotVector_32_8[2 * (256 - 32)] = { +# endif + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ff62182), SHC(0xfcdbd541), SHC(0x7fd8878e), SHC(0xf9b82684), + SHC(0x7fa736b4), SHC(0xf6956fb7), SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7f0991c4), SHC(0xf054d8d5), + SHC(0x7e9d55fc), SHC(0xed37ef91), SHC(0x7e1d93ea), SHC(0xea1debbb), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7ce3ceb2), SHC(0xe3f47d96), SHC(0x7c29fbee), SHC(0xe0e60685), SHC(0x7b5d039e), SHC(0xdddc5b3b), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x798a23b1), SHC(0xd7d946d8), SHC(0x78848414), SHC(0xd4e0cb15), + SHC(0x776c4edb), SHC(0xd1eef59e), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x7504d345), SHC(0xcc210d79), + SHC(0x73b5ebd1), SHC(0xc945dfec), SHC(0x72552c85), SHC(0xc67322ce), SHC(0x70e2cbc6), SHC(0xc3a94590), + SHC(0x6f5f02b2), SHC(0xc0e8b648), SHC(0x6dca0d14), SHC(0xbe31e19b), SHC(0x6c242960), SHC(0xbb8532b0), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x68a69e81), SHC(0xb64beacd), SHC(0x66cf8120), SHC(0xb3c0200c), + SHC(0x64e88926), SHC(0xb140175b), SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x60ec3830), SHC(0xac64d510), + SHC(0x5ed77c8a), SHC(0xaa0a5b2e), SHC(0x5cb420e0), SHC(0xa7bd22ac), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7fd8878e), SHC(0xf9b82684), SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7e9d55fc), SHC(0xed37ef91), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7c29fbee), SHC(0xe0e60685), SHC(0x7a7d055b), SHC(0xdad7f3a2), + SHC(0x78848414), SHC(0xd4e0cb15), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x73b5ebd1), SHC(0xc945dfec), + SHC(0x70e2cbc6), SHC(0xc3a94590), SHC(0x6dca0d14), SHC(0xbe31e19b), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x66cf8120), SHC(0xb3c0200c), SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x5ed77c8a), SHC(0xaa0a5b2e), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x55f5a4d2), SHC(0xa1288376), SHC(0x5133cc94), SHC(0x9d0dfe54), + SHC(0x4c3fdff4), SHC(0x99307ee0), SHC(0x471cece7), SHC(0x9592675c), SHC(0x41ce1e65), SHC(0x9235f2ec), + SHC(0x3c56ba70), SHC(0x8f1d343a), SHC(0x36ba2014), SHC(0x8c4a142f), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x2b1f34eb), SHC(0x877b7bec), SHC(0x25280c5e), SHC(0x8582faa5), SHC(0x1f19f97b), SHC(0x83d60412), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x12c8106f), SHC(0x8162aa04), SHC(0x0c8bd35e), SHC(0x809dc971), + SHC(0x0647d97c), SHC(0x80277872), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fa736b4), SHC(0xf6956fb7), + SHC(0x7e9d55fc), SHC(0xed37ef91), SHC(0x7ce3ceb2), SHC(0xe3f47d96), SHC(0x7a7d055b), SHC(0xdad7f3a2), + SHC(0x776c4edb), SHC(0xd1eef59e), SHC(0x73b5ebd1), SHC(0xc945dfec), SHC(0x6f5f02b2), SHC(0xc0e8b648), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x64e88926), SHC(0xb140175b), SHC(0x5ed77c8a), SHC(0xaa0a5b2e), + SHC(0x5842dd54), SHC(0xa34bdf20), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x49b41533), SHC(0x9759617f), + SHC(0x41ce1e65), SHC(0x9235f2ec), SHC(0x398cdd32), SHC(0x8daad37b), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x2826b928), SHC(0x8675dc4f), SHC(0x1f19f97b), SHC(0x83d60412), SHC(0x15e21445), SHC(0x81e26c16), + SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0x03242abf), SHC(0x8009de7e), SHC(0xf9b82684), SHC(0x80277872), + SHC(0xf054d8d5), SHC(0x80f66e3c), SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdddc5b3b), SHC(0x84a2fc62), + SHC(0xd4e0cb15), SHC(0x877b7bec), SHC(0xcc210d79), SHC(0x8afb2cbb), SHC(0xc3a94590), SHC(0x8f1d343a), + SHC(0xbb8532b0), SHC(0x93dbd6a0), SHC(0xb3c0200c), SHC(0x99307ee0), SHC(0xac64d510), SHC(0x9f13c7d0), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x70e2cbc6), SHC(0xc3a94590), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x471cece7), SHC(0x9592675c), SHC(0x3c56ba70), SHC(0x8f1d343a), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x25280c5e), SHC(0x8582faa5), SHC(0x18f8b83c), SHC(0x8275a0c0), + SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0x00000000), SHC(0x80000000), SHC(0xf3742ca2), SHC(0x809dc971), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdad7f3a2), SHC(0x8582faa5), SHC(0xcf043ab3), SHC(0x89be50c3), + SHC(0xc3a94590), SHC(0x8f1d343a), SHC(0xb8e31319), SHC(0x9592675c), SHC(0xaecc336c), SHC(0x9d0dfe54), + SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9d0dfe54), SHC(0xaecc336c), SHC(0x9592675c), SHC(0xb8e31319), + SHC(0x8f1d343a), SHC(0xc3a94590), SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x8582faa5), SHC(0xdad7f3a2), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x809dc971), SHC(0xf3742ca2), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7f0991c4), SHC(0xf054d8d5), SHC(0x7c29fbee), SHC(0xe0e60685), SHC(0x776c4edb), SHC(0xd1eef59e), + SHC(0x70e2cbc6), SHC(0xc3a94590), SHC(0x68a69e81), SHC(0xb64beacd), SHC(0x5ed77c8a), SHC(0xaa0a5b2e), + SHC(0x539b2af0), SHC(0x9f13c7d0), SHC(0x471cece7), SHC(0x9592675c), SHC(0x398cdd32), SHC(0x8daad37b), + SHC(0x2b1f34eb), SHC(0x877b7bec), SHC(0x1c0b826a), SHC(0x831c314e), SHC(0x0c8bd35e), SHC(0x809dc971), + SHC(0xfcdbd541), SHC(0x8009de7e), SHC(0xed37ef91), SHC(0x8162aa04), SHC(0xdddc5b3b), SHC(0x84a2fc62), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc0e8b648), SHC(0x90a0fd4e), SHC(0xb3c0200c), SHC(0x99307ee0), + SHC(0xa7bd22ac), SHC(0xa34bdf20), SHC(0x9d0dfe54), SHC(0xaecc336c), SHC(0x93dbd6a0), SHC(0xbb8532b0), + SHC(0x8c4a142f), SHC(0xc945dfec), SHC(0x8675dc4f), SHC(0xd7d946d8), SHC(0x8275a0c0), SHC(0xe70747c4), + SHC(0x8058c94c), SHC(0xf6956fb7), SHC(0x80277872), SHC(0x0647d97c), SHC(0x81e26c16), SHC(0x15e21445), + SHC(0x8582faa5), SHC(0x25280c5e), SHC(0x8afb2cbb), SHC(0x33def287), SHC(0x9235f2ec), SHC(0x41ce1e65), + SHC(0x9b1776da), SHC(0x4ebfe8a5), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e9d55fc), SHC(0xed37ef91), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x73b5ebd1), SHC(0xc945dfec), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x5ed77c8a), SHC(0xaa0a5b2e), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x41ce1e65), SHC(0x9235f2ec), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x1f19f97b), SHC(0x83d60412), SHC(0x0c8bd35e), SHC(0x809dc971), + SHC(0xf9b82684), SHC(0x80277872), SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xd4e0cb15), SHC(0x877b7bec), + SHC(0xc3a94590), SHC(0x8f1d343a), SHC(0xb3c0200c), SHC(0x99307ee0), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x99307ee0), SHC(0xb3c0200c), SHC(0x8f1d343a), SHC(0xc3a94590), SHC(0x877b7bec), SHC(0xd4e0cb15), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80277872), SHC(0xf9b82684), SHC(0x809dc971), SHC(0x0c8bd35e), + SHC(0x83d60412), SHC(0x1f19f97b), SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9235f2ec), SHC(0x41ce1e65), + SHC(0x9d0dfe54), SHC(0x5133cc94), SHC(0xaa0a5b2e), SHC(0x5ed77c8a), SHC(0xb8e31319), SHC(0x6a6d98a4), + SHC(0xc945dfec), SHC(0x73b5ebd1), SHC(0xdad7f3a2), SHC(0x7a7d055b), SHC(0xed37ef91), SHC(0x7e9d55fc), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e1d93ea), SHC(0xea1debbb), SHC(0x78848414), SHC(0xd4e0cb15), + SHC(0x6f5f02b2), SHC(0xc0e8b648), SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x539b2af0), SHC(0x9f13c7d0), + SHC(0x41ce1e65), SHC(0x9235f2ec), SHC(0x2e110a62), SHC(0x8893b125), SHC(0x18f8b83c), SHC(0x8275a0c0), + SHC(0x03242abf), SHC(0x8009de7e), SHC(0xed37ef91), SHC(0x8162aa04), SHC(0xd7d946d8), SHC(0x8675dc4f), + SHC(0xc3a94590), SHC(0x8f1d343a), SHC(0xb140175b), SHC(0x9b1776da), SHC(0xa1288376), SHC(0xaa0a5b2e), + SHC(0x93dbd6a0), SHC(0xbb8532b0), SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x831c314e), SHC(0xe3f47d96), + SHC(0x80277872), SHC(0xf9b82684), SHC(0x80f66e3c), SHC(0x0fab272b), SHC(0x8582faa5), SHC(0x25280c5e), + SHC(0x8daad37b), SHC(0x398cdd32), SHC(0x99307ee0), SHC(0x4c3fdff4), SHC(0xa7bd22ac), SHC(0x5cb420e0), + SHC(0xb8e31319), SHC(0x6a6d98a4), SHC(0xcc210d79), SHC(0x7504d345), SHC(0xe0e60685), SHC(0x7c29fbee), + SHC(0xf6956fb7), SHC(0x7fa736b4), SHC(0x0c8bd35e), SHC(0x7f62368f), SHC(0x2223a4c5), SHC(0x7b5d039e), + SHC(0x36ba2014), SHC(0x73b5ebd1), SHC(0x49b41533), SHC(0x68a69e81)}; + + +# ifdef ENABLE_HR_MODE +const Word32 RotVector_15_6[2 * (90 - 15)] = { +# else +const Word16 RotVector_15_6[2 * (90 - 15)] = { +# endif + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb02dc6), SHC(0xf7123849), SHC(0x7ec11aa5), SHC(0xee2f9369), + SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), SHC(0x7847d909), SHC(0xd438af17), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x71046d3e), SHC(0xc3e85b18), SHC(0x6c8cd70b), SHC(0xbc2b9b05), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x620dbe8b), SHC(0xadb922b7), SHC(0x5c13539b), SHC(0xa7156f3c), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x4ecdfec7), SHC(0x9b2276b0), SHC(0x4793a210), SHC(0x95e218c9), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ec11aa5), SHC(0xee2f9369), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), + SHC(0x74ef0ebc), SHC(0xcbf00dbe), SHC(0x6c8cd70b), SHC(0xbc2b9b05), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x4793a210), SHC(0x95e218c9), SHC(0x381c8bb5), SHC(0x8cf45113), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x163a1a7e), SHC(0x81f1d1ce), SHC(0x04779632), SHC(0x8013f61d), + SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xe108b40d), SHC(0x83cd5982), SHC(0xd00ce422), SHC(0x89520a1a), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7d33f0ca), SHC(0xe5632654), SHC(0x74ef0ebc), SHC(0xcbf00dbe), + SHC(0x678dde6e), SHC(0xb4c373ee), SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x40000000), SHC(0x9126145f), + SHC(0x278dde6e), SHC(0x8643c7b3), SHC(0x0d61304e), SHC(0x80b381ac), SHC(0xf29ecfb2), SHC(0x80b381ac), + SHC(0xd8722192), SHC(0x8643c7b3), SHC(0xc0000000), SHC(0x9126145f), SHC(0xaa59eda4), SHC(0xa0e0a15f), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x8b10f144), SHC(0xcbf00dbe), SHC(0x82cc0f36), SHC(0xe5632654), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7b0a9f8d), SHC(0xdcb7ea46), SHC(0x6c8cd70b), SHC(0xbc2b9b05), + SHC(0x55a6125c), SHC(0xa0e0a15f), SHC(0x381c8bb5), SHC(0x8cf45113), SHC(0x163a1a7e), SHC(0x81f1d1ce), + SHC(0xf29ecfb2), SHC(0x80b381ac), SHC(0xd00ce422), SHC(0x89520a1a), SHC(0xb1320139), SHC(0x9b2276b0), + SHC(0x98722192), SHC(0xb4c373ee), SHC(0x87b826f7), SHC(0xd438af17), SHC(0x804fd23a), SHC(0xf7123849), + SHC(0x82cc0f36), SHC(0x1a9cd9ac), SHC(0x8efb92c2), SHC(0x3c17a4e8), SHC(0xa3ecac65), SHC(0x58ea90c4), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7847d909), SHC(0xd438af17), SHC(0x620dbe8b), SHC(0xadb922b7), + SHC(0x40000000), SHC(0x9126145f), SHC(0x163a1a7e), SHC(0x81f1d1ce), SHC(0xe9c5e582), SHC(0x81f1d1ce), + SHC(0xc0000000), SHC(0x9126145f), SHC(0x9df24175), SHC(0xadb922b7), SHC(0x87b826f7), SHC(0xd438af17), + SHC(0x80000000), SHC(0x00000000), SHC(0x87b826f7), SHC(0x2bc750e9), SHC(0x9df24175), SHC(0x5246dd49), + SHC(0xc0000000), SHC(0x6ed9eba1), SHC(0xe9c5e582), SHC(0x7e0e2e32), SHC(0x163a1a7e), SHC(0x7e0e2e32)}; + +#if defined(SUBSET_SSWB) || defined(SUBSET_SWB) || defined(SUBSET_FB) +/* Twiddle coefficients for 32x12 FFTs, generated by fft_tables.py */ +# ifdef ENABLE_HR_MODE +const Word32 RotVector_32_12[2 * (384 - 32)] = { +# else +const Word16 RotVector_32_12[2 * (384 - 32)] = { +# endif + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffb9d15), SHC(0xfde7dbd9), SHC(0x7fee74a2), SHC(0xfbcfdc71), + SHC(0x7fd8878e), SHC(0xf9b82684), SHC(0x7fb9d759), SHC(0xf7a0dec9), SHC(0x7f92661d), SHC(0xf58a29f2), + SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7f294bfd), SHC(0xf15f0b74), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7e9d55fc), SHC(0xed37ef91), SHC(0x7e4a5426), SHC(0xeb263dbb), SHC(0x7deeaa7a), SHC(0xe915f9ba), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7d1d7958), SHC(0xe4fa4bf1), SHC(0x7ca80038), SHC(0xe2ef2a3e), + SHC(0x7c29fbee), SHC(0xe0e60685), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7b1474fd), SHC(0xdcda47b9), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x79dd3098), SHC(0xd8d82b7a), SHC(0x793501a9), SHC(0xd6db1254), + SHC(0x78848414), SHC(0xd4e0cb15), SHC(0x77cbc3f2), SHC(0xd2e9786e), SHC(0x770acdec), SHC(0xd0f53ce0), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x757075ac), SHC(0xcd1693f7), SHC(0x74972f92), SHC(0xcb2c6a82), + SHC(0x73b5ebd1), SHC(0xc945dfec), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x71dba9ab), SHC(0xc5842c7e), + SHC(0x70e2cbc6), SHC(0xc3a94590), SHC(0x6fe2313c), SHC(0xc1d2814f), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7fee74a2), SHC(0xfbcfdc71), SHC(0x7fb9d759), SHC(0xf7a0dec9), SHC(0x7f62368f), SHC(0xf3742ca2), + SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7e4a5426), SHC(0xeb263dbb), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7ca80038), SHC(0xe2ef2a3e), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7a7d055b), SHC(0xdad7f3a2), + SHC(0x793501a9), SHC(0xd6db1254), SHC(0x77cbc3f2), SHC(0xd2e9786e), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x74972f92), SHC(0xcb2c6a82), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x70e2cbc6), SHC(0xc3a94590), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x6cb2a837), SHC(0xbc6845ce), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x680b5c33), SHC(0xb5715eef), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x62f201ac), SHC(0xaecc336c), + SHC(0x603c496c), SHC(0xab9a8e6c), SHC(0x5d6c2f99), SHC(0xa8800c26), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x577ff3da), SHC(0xa293d067), SHC(0x54657194), SHC(0x9fc3b694), SHC(0x5133cc94), SHC(0x9d0dfe54), + SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x4a8ea111), SHC(0x97f4a3cd), SHC(0x471cece7), SHC(0x9592675c), + SHC(0x4397ba32), SHC(0x934d57c9), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fd8878e), SHC(0xf9b82684), + SHC(0x7f62368f), SHC(0xf3742ca2), SHC(0x7e9d55fc), SHC(0xed37ef91), SHC(0x7d8a5f40), SHC(0xe70747c4), + SHC(0x7c29fbee), SHC(0xe0e60685), SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x78848414), SHC(0xd4e0cb15), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x73b5ebd1), SHC(0xc945dfec), SHC(0x70e2cbc6), SHC(0xc3a94590), + SHC(0x6dca0d14), SHC(0xbe31e19b), SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x66cf8120), SHC(0xb3c0200c), + SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x5ed77c8a), SHC(0xaa0a5b2e), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x55f5a4d2), SHC(0xa1288376), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x4c3fdff4), SHC(0x99307ee0), + SHC(0x471cece7), SHC(0x9592675c), SHC(0x41ce1e65), SHC(0x9235f2ec), SHC(0x3c56ba70), SHC(0x8f1d343a), + SHC(0x36ba2014), SHC(0x8c4a142f), SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2b1f34eb), SHC(0x877b7bec), + SHC(0x25280c5e), SHC(0x8582faa5), SHC(0x1f19f97b), SHC(0x83d60412), SHC(0x18f8b83c), SHC(0x8275a0c0), + SHC(0x12c8106f), SHC(0x8162aa04), SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0x0647d97c), SHC(0x80277872), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7fb9d759), SHC(0xf7a0dec9), SHC(0x7ee7aa4c), SHC(0xef4aeaf1), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x793501a9), SHC(0xd6db1254), + SHC(0x7641af3d), SHC(0xcf043ab3), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x6ed9eba1), SHC(0xc0000000), + SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x603c496c), SHC(0xab9a8e6c), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x54657194), SHC(0x9fc3b694), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x471cece7), SHC(0x9592675c), SHC(0x40000000), SHC(0x9126145f), SHC(0x389cea72), SHC(0x8d334625), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x2924edac), SHC(0x86cafe57), SHC(0x2120fb83), SHC(0x845c8ae3), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x10b5150f), SHC(0x811855b4), SHC(0x085f2137), SHC(0x804628a7), + SHC(0x00000000), SHC(0x80000000), SHC(0xf7a0dec9), SHC(0x804628a7), SHC(0xef4aeaf1), SHC(0x811855b4), + SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd6db1254), SHC(0x86cafe57), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc763158e), SHC(0x8d334625), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7f92661d), SHC(0xf58a29f2), SHC(0x7e4a5426), SHC(0xeb263dbb), SHC(0x7c29fbee), SHC(0xe0e60685), + SHC(0x793501a9), SHC(0xd6db1254), SHC(0x757075ac), SHC(0xcd1693f7), SHC(0x70e2cbc6), SHC(0xc3a94590), + SHC(0x6b93d02e), SHC(0xbaa34bf4), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x5ed77c8a), SHC(0xaa0a5b2e), + SHC(0x577ff3da), SHC(0xa293d067), SHC(0x4f9292dc), SHC(0x9bbd4282), SHC(0x471cece7), SHC(0x9592675c), + SHC(0x3e2d7eb1), SHC(0x901dcec4), SHC(0x34d3957e), SHC(0x8b68d06e), SHC(0x2b1f34eb), SHC(0x877b7bec), + SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x16ea0646), SHC(0x82115586), SHC(0x0c8bd35e), SHC(0x809dc971), + SHC(0x02182427), SHC(0x800462eb), SHC(0xf7a0dec9), SHC(0x804628a7), SHC(0xed37ef91), SHC(0x8162aa04), + SHC(0xe2ef2a3e), SHC(0x8357ffc8), SHC(0xd8d82b7a), SHC(0x8622cf68), SHC(0xcf043ab3), SHC(0x89be50c3), + SHC(0xc5842c7e), SHC(0x8e245655), SHC(0xbc6845ce), SHC(0x934d57c9), SHC(0xb3c0200c), SHC(0x99307ee0), + SHC(0xab9a8e6c), SHC(0x9fc3b694), SHC(0xa405847e), SHC(0xa6fbbc59), SHC(0x9d0dfe54), SHC(0xaecc336c), + SHC(0x96bfea3d), SHC(0xb727b9f7), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f62368f), SHC(0xf3742ca2), + SHC(0x7d8a5f40), SHC(0xe70747c4), SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x70e2cbc6), SHC(0xc3a94590), SHC(0x6a6d98a4), SHC(0xb8e31319), SHC(0x62f201ac), SHC(0xaecc336c), + SHC(0x5a82799a), SHC(0xa57d8666), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x471cece7), SHC(0x9592675c), + SHC(0x3c56ba70), SHC(0x8f1d343a), SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x25280c5e), SHC(0x8582faa5), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0x00000000), SHC(0x80000000), + SHC(0xf3742ca2), SHC(0x809dc971), SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xdad7f3a2), SHC(0x8582faa5), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xc3a94590), SHC(0x8f1d343a), SHC(0xb8e31319), SHC(0x9592675c), + SHC(0xaecc336c), SHC(0x9d0dfe54), SHC(0xa57d8666), SHC(0xa57d8666), SHC(0x9d0dfe54), SHC(0xaecc336c), + SHC(0x9592675c), SHC(0xb8e31319), SHC(0x8f1d343a), SHC(0xc3a94590), SHC(0x89be50c3), SHC(0xcf043ab3), + SHC(0x8582faa5), SHC(0xdad7f3a2), SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x809dc971), SHC(0xf3742ca2), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7f294bfd), SHC(0xf15f0b74), SHC(0x7ca80038), SHC(0xe2ef2a3e), + SHC(0x78848414), SHC(0xd4e0cb15), SHC(0x72ccb9db), SHC(0xc763158e), SHC(0x6b93d02e), SHC(0xbaa34bf4), + SHC(0x62f201ac), SHC(0xaecc336c), SHC(0x590443a7), SHC(0xa405847e), SHC(0x4debe4fe), SHC(0x9a7365d3), + SHC(0x41ce1e65), SHC(0x9235f2ec), SHC(0x34d3957e), SHC(0x8b68d06e), SHC(0x2727d486), SHC(0x8622cf68), + SHC(0x18f8b83c), SHC(0x8275a0c0), SHC(0x0a75d60e), SHC(0x806d99e3), SHC(0xfbcfdc71), SHC(0x80118b5e), + SHC(0xed37ef91), SHC(0x8162aa04), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xd0f53ce0), SHC(0x88f53214), + SHC(0xc3a94590), SHC(0x8f1d343a), SHC(0xb727b9f7), SHC(0x96bfea3d), SHC(0xab9a8e6c), SHC(0x9fc3b694), + SHC(0xa1288376), SHC(0xaa0a5b2e), SHC(0x97f4a3cd), SHC(0xb5715eef), SHC(0x901dcec4), SHC(0xc1d2814f), + SHC(0x89be50c3), SHC(0xcf043ab3), SHC(0x84eb8b03), SHC(0xdcda47b9), SHC(0x81b5abda), SHC(0xeb263dbb), + SHC(0x80277872), SHC(0xf9b82684), SHC(0x804628a7), SHC(0x085f2137), SHC(0x82115586), SHC(0x16ea0646), + SHC(0x8582faa5), SHC(0x25280c5e), SHC(0x8a8f8a54), SHC(0x32e96c09), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7ee7aa4c), SHC(0xef4aeaf1), SHC(0x7ba3751d), SHC(0xdedf047d), SHC(0x7641af3d), SHC(0xcf043ab3), + SHC(0x6ed9eba1), SHC(0xc0000000), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x5a82799a), SHC(0xa57d8666), + SHC(0x4debe4fe), SHC(0x9a7365d3), SHC(0x40000000), SHC(0x9126145f), SHC(0x30fbc54d), SHC(0x89be50c3), + SHC(0x2120fb83), SHC(0x845c8ae3), SHC(0x10b5150f), SHC(0x811855b4), SHC(0x00000000), SHC(0x80000000), + SHC(0xef4aeaf1), SHC(0x811855b4), SHC(0xdedf047d), SHC(0x845c8ae3), SHC(0xcf043ab3), SHC(0x89be50c3), + SHC(0xc0000000), SHC(0x9126145f), SHC(0xb2141b02), SHC(0x9a7365d3), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x9a7365d3), SHC(0xb2141b02), SHC(0x9126145f), SHC(0xc0000000), SHC(0x89be50c3), SHC(0xcf043ab3), + SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x811855b4), SHC(0xef4aeaf1), SHC(0x80000000), SHC(0x00000000), + SHC(0x811855b4), SHC(0x10b5150f), SHC(0x845c8ae3), SHC(0x2120fb83), SHC(0x89be50c3), SHC(0x30fbc54d), + SHC(0x9126145f), SHC(0x40000000), SHC(0x9a7365d3), SHC(0x4debe4fe), SHC(0xa57d8666), SHC(0x5a82799a), + SHC(0xb2141b02), SHC(0x658c9a2d), SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e9d55fc), SHC(0xed37ef91), + SHC(0x7a7d055b), SHC(0xdad7f3a2), SHC(0x73b5ebd1), SHC(0xc945dfec), SHC(0x6a6d98a4), SHC(0xb8e31319), + SHC(0x5ed77c8a), SHC(0xaa0a5b2e), SHC(0x5133cc94), SHC(0x9d0dfe54), SHC(0x41ce1e65), SHC(0x9235f2ec), + SHC(0x30fbc54d), SHC(0x89be50c3), SHC(0x1f19f97b), SHC(0x83d60412), SHC(0x0c8bd35e), SHC(0x809dc971), + SHC(0xf9b82684), SHC(0x80277872), SHC(0xe70747c4), SHC(0x8275a0c0), SHC(0xd4e0cb15), SHC(0x877b7bec), + SHC(0xc3a94590), SHC(0x8f1d343a), SHC(0xb3c0200c), SHC(0x99307ee0), SHC(0xa57d8666), SHC(0xa57d8666), + SHC(0x99307ee0), SHC(0xb3c0200c), SHC(0x8f1d343a), SHC(0xc3a94590), SHC(0x877b7bec), SHC(0xd4e0cb15), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80277872), SHC(0xf9b82684), SHC(0x809dc971), SHC(0x0c8bd35e), + SHC(0x83d60412), SHC(0x1f19f97b), SHC(0x89be50c3), SHC(0x30fbc54d), SHC(0x9235f2ec), SHC(0x41ce1e65), + SHC(0x9d0dfe54), SHC(0x5133cc94), SHC(0xaa0a5b2e), SHC(0x5ed77c8a), SHC(0xb8e31319), SHC(0x6a6d98a4), + SHC(0xc945dfec), SHC(0x73b5ebd1), SHC(0xdad7f3a2), SHC(0x7a7d055b), SHC(0xed37ef91), SHC(0x7e9d55fc), + SHC(0x7fffffff), SHC(0x00000000), SHC(0x7e4a5426), SHC(0xeb263dbb), SHC(0x793501a9), SHC(0xd6db1254), + SHC(0x70e2cbc6), SHC(0xc3a94590), SHC(0x658c9a2d), SHC(0xb2141b02), SHC(0x577ff3da), SHC(0xa293d067), + SHC(0x471cece7), SHC(0x9592675c), SHC(0x34d3957e), SHC(0x8b68d06e), SHC(0x2120fb83), SHC(0x845c8ae3), + SHC(0x0c8bd35e), SHC(0x809dc971), SHC(0xf7a0dec9), SHC(0x804628a7), SHC(0xe2ef2a3e), SHC(0x8357ffc8), + SHC(0xcf043ab3), SHC(0x89be50c3), SHC(0xbc6845ce), SHC(0x934d57c9), SHC(0xab9a8e6c), SHC(0x9fc3b694), + SHC(0x9d0dfe54), SHC(0xaecc336c), SHC(0x9126145f), SHC(0xc0000000), SHC(0x88343c0e), SHC(0xd2e9786e), + SHC(0x8275a0c0), SHC(0xe70747c4), SHC(0x80118b5e), SHC(0xfbcfdc71), SHC(0x811855b4), SHC(0x10b5150f), + SHC(0x8582faa5), SHC(0x25280c5e), SHC(0x8d334625), SHC(0x389cea72), SHC(0x97f4a3cd), SHC(0x4a8ea111), + SHC(0xa57d8666), SHC(0x5a82799a), SHC(0xb5715eef), SHC(0x680b5c33), SHC(0xc763158e), SHC(0x72ccb9db), + SHC(0xdad7f3a2), SHC(0x7a7d055b), SHC(0xef4aeaf1), SHC(0x7ee7aa4c), SHC(0x0430238f), SHC(0x7fee74a2), + SHC(0x18f8b83c), SHC(0x7d8a5f40), SHC(0x2d168792), SHC(0x77cbc3f2), SHC(0x7fffffff), SHC(0x00000000), + SHC(0x7deeaa7a), SHC(0xe915f9ba), SHC(0x77cbc3f2), SHC(0xd2e9786e), SHC(0x6dca0d14), SHC(0xbe31e19b), + SHC(0x603c496c), SHC(0xab9a8e6c), SHC(0x4f9292dc), SHC(0x9bbd4282), SHC(0x3c56ba70), SHC(0x8f1d343a), + SHC(0x2727d486), SHC(0x8622cf68), SHC(0x10b5150f), SHC(0x811855b4), SHC(0xf9b82684), SHC(0x80277872), + SHC(0xe2ef2a3e), SHC(0x8357ffc8), SHC(0xcd1693f7), SHC(0x8a8f8a54), SHC(0xb8e31319), SHC(0x9592675c), + SHC(0xa6fbbc59), SHC(0xa405847e), SHC(0x97f4a3cd), SHC(0xb5715eef), SHC(0x8c4a142f), SHC(0xc945dfec), + SHC(0x845c8ae3), SHC(0xdedf047d), SHC(0x806d99e3), SHC(0xf58a29f2), SHC(0x809dc971), SHC(0x0c8bd35e), + SHC(0x84eb8b03), SHC(0x2325b847), SHC(0x8d334625), SHC(0x389cea72), SHC(0x99307ee0), SHC(0x4c3fdff4), + SHC(0xa8800c26), SHC(0x5d6c2f99), SHC(0xbaa34bf4), SHC(0x6b93d02e), SHC(0xcf043ab3), SHC(0x7641af3d), + SHC(0xe4fa4bf1), SHC(0x7d1d7958), SHC(0xfbcfdc71), SHC(0x7fee74a2), SHC(0x12c8106f), SHC(0x7e9d55fc), + SHC(0x2924edac), SHC(0x793501a9), SHC(0x3e2d7eb1), SHC(0x6fe2313c), SHC(0x5133cc94), SHC(0x62f201ac), + SHC(0x619a7dce), SHC(0x52cf758f)}; + + +# endif /* !defined(__XTENSA__) */ + + +/* Inverse square root table for operands running from 0.5 to ~1.0 + + (Word32) (0.5 + 1.0/sqrt((op)/CDKpow(2.0,31))) + + Note: First value is not rounded for accuracy reasons + + Implicit exponent is 1 + + Example: 0x5A82799A = Isqrt(0x40000000), exponent=1 +*/ +const Word32 isqrt_table[128 + 2] = { + 0x5A827999, 0x5A287E03, 0x59CF8CBC, 0x5977A0AC, 0x5920B4DF, 0x58CAC480, 0x5875CADE, 0x5821C364, 0x57CEA99D, + 0x577C7930, 0x572B2DE0, 0x56DAC38E, 0x568B3632, 0x563C81E0, 0x55EEA2C4, 0x55A19522, 0x55555555, 0x5509DFD0, + 0x54BF311A, 0x547545D0, 0x542C1AA4, 0x53E3AC5B, 0x539BF7CD, 0x5354F9E7, 0x530EAFA5, 0x52C91618, 0x52842A5F, + 0x523FE9AC, 0x51FC5140, 0x51B95E6B, 0x51770E8F, 0x51355F1A, 0x50F44D89, 0x50B3D768, 0x5073FA50, 0x5034B3E7, + 0x4FF601E0, 0x4FB7E1FA, 0x4F7A5202, 0x4F3D4FCF, 0x4F00D944, 0x4EC4EC4F, 0x4E8986EA, 0x4E4EA718, 0x4E144AE9, + 0x4DDA7073, 0x4DA115DA, 0x4D683948, 0x4D2FD8F4, 0x4CF7F31B, 0x4CC08605, 0x4C899000, 0x4C530F65, 0x4C1D0294, + 0x4BE767F5, 0x4BB23DF9, 0x4B7D8317, 0x4B4935CF, 0x4B1554A6, 0x4AE1DE2A, 0x4AAED0F0, 0x4A7C2B93, 0x4A49ECB3, + 0x4A1812FA, 0x49E69D16, 0x49B589BB, 0x4984D7A4, 0x49548592, 0x49249249, 0x48F4FC97, 0x48C5C34B, 0x4896E53D, + 0x48686148, 0x483A364D, 0x480C6332, 0x47DEE6E1, 0x47B1C049, 0x4784EE60, 0x4758701C, 0x472C447C, 0x47006A81, + 0x46D4E130, 0x46A9A794, 0x467EBCBA, 0x46541FB4, 0x4629CF98, 0x45FFCB80, 0x45D6128A, 0x45ACA3D5, 0x45837E88, + 0x455AA1CB, 0x45320CC8, 0x4509BEB0, 0x44E1B6B4, 0x44B9F40B, 0x449275ED, 0x446B3B96, 0x44444444, 0x441D8F3B, + 0x43F71BBF, 0x43D0E917, 0x43AAF68F, 0x43854374, 0x435FCF15, 0x433A98C6, 0x43159FDC, 0x42F0E3AE, 0x42CC6398, + 0x42A81EF6, 0x42841527, 0x4260458E, 0x423CAF8D, 0x4219528B, 0x41F62DF2, 0x41D3412A, 0x41B08BA2, 0x418E0CC8, + 0x416BC40D, 0x4149B0E5, 0x4127D2C3, 0x41062920, 0x40E4B374, 0x40C3713B, 0x40A261EF, 0x40818512, 0x4060DA22, + 0x404060A1, 0x40201814, 0x40000000, 0x3FE017EC, +}; + +const Word32 Log2_16_table1[16] = { + 0, 2934766, 5701737, 8319067, 10802114, 13163988, 15415967, 17567824, + 19628084, 21604229, 23502857, 25329821, 27090336, 28789065, 30430199, 32017515, +}; + +const Word16 Log2_16_table2[16] = { + 1433, 1351, 1278, 1212, 1153, 1099, 1051, 1006, 965, 927, 892, 860, 829, 801, 775, 750, +}; + +const Word32 InvLog2_16_table1[64] = { + 1073741824, 1085434106, 1097253708, 1109202018, 1121280436, 1133490379, 1145833280, 1158310587, + 1170923762, 1183674286, 1196563654, 1209593378, 1222764986, 1236080024, 1249540052, 1263146652, + 1276901417, 1290805962, 1304861917, 1319070932, 1333434672, 1347954824, 1362633090, 1377471191, + 1392470869, 1407633882, 1422962010, 1438457051, 1454120821, 1469955159, 1485961921, 1502142985, + 1518500250, 1535035634, 1551751076, 1568648537, 1585730000, 1602997467, 1620452965, 1638098541, + 1655936265, 1673968228, 1692196547, 1710623359, 1729250827, 1748081133, 1767116489, 1786359126, + 1805811301, 1825475297, 1845353420, 1865448001, 1885761398, 1906295993, 1927054196, 1948038440, + 1969251188, 1990694927, 2012372174, 2034285470, 2056437387, 2078830522, 2101467502, 2124350982, +}; + +const Word16 InvLog2_16_table2[64] = { + 11418, 11543, 11668, 11795, 11924, 12054, 12185, 12318, 12452, 12587, 12724, 12863, 13003, 13145, 13288, 13432, + 13579, 13727, 13876, 14027, 14180, 14334, 14490, 14648, 14808, 14969, 15132, 15297, 15463, 15632, 15802, 15974, + 16148, 16324, 16501, 16681, 16863, 17046, 17232, 17420, 17609, 17801, 17995, 18191, 18389, 18589, 18792, 18996, + 19203, 19412, 19624, 19837, 20053, 20272, 20492, 20716, 20941, 21169, 21400, 21633, 21868, 22106, 22347, 22590, +}; + +const UWord8 gf16_mult_table[256] = { + /* gf16_mult_table[a | (b << 4)] contains the product of a and b in GF(16) */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 0, 2, 4, 6, 8, 10, 12, 14, 3, 1, 7, 5, 11, 9, 15, 13, 0, 3, 6, 5, 12, 15, 10, 9, 11, 8, + 13, 14, 7, 4, 1, 2, 0, 4, 8, 12, 3, 7, 11, 15, 6, 2, 14, 10, 5, 1, 13, 9, 0, 5, 10, 15, 7, 2, 13, + 8, 14, 11, 4, 1, 9, 12, 3, 6, 0, 6, 12, 10, 11, 13, 7, 1, 5, 3, 9, 15, 14, 8, 2, 4, 0, 7, 14, 9, + 15, 8, 1, 6, 13, 10, 3, 4, 2, 5, 12, 11, 0, 8, 3, 11, 6, 14, 5, 13, 12, 4, 15, 7, 10, 2, 9, 1, 0, + 9, 1, 8, 2, 11, 3, 10, 4, 13, 5, 12, 6, 15, 7, 14, 0, 10, 7, 13, 14, 4, 9, 3, 15, 5, 8, 2, 1, 11, + 6, 12, 0, 11, 5, 14, 10, 1, 15, 4, 7, 12, 2, 9, 13, 6, 8, 3, 0, 12, 11, 7, 5, 9, 14, 2, 10, 6, 1, + 13, 15, 3, 4, 8, 0, 13, 9, 4, 1, 12, 8, 5, 2, 15, 11, 6, 3, 14, 10, 7, 0, 14, 15, 1, 13, 3, 2, 12, + 9, 7, 6, 8, 4, 10, 11, 5, 0, 15, 13, 2, 9, 6, 4, 11, 1, 14, 12, 3, 8, 7, 5, 10, +}; + +const UWord8 rs16_elp_deg2_table[256] = { + /* If the polynomial x^2 + ax + b has distinct non-zero roots z1 and z2 in GF(16), * + * then table entry a + 16*b contains log_g(z1) | log_g(z2) << 4, and otherwise it * + * contains 0. */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 105, 195, 0, 210, 0, 225, 0, 180, 120, 0, 0, 121, 0, 16, 0, 211, 0, 0, 181, 0, 0, 106, + 196, 226, 0, 0, 0, 214, 64, 0, 199, 0, 0, 0, 0, 0, 49, 184, 0, 154, 0, 229, 0, 227, + 182, 0, 0, 32, 0, 0, 0, 197, 0, 0, 122, 0, 212, 152, 0, 203, 0, 158, 128, 0, 0, 0, + 98, 113, 218, 0, 0, 0, 53, 0, 0, 65, 0, 0, 185, 110, 215, 80, 0, 0, 200, 0, 50, 0, + 0, 0, 0, 130, 205, 115, 0, 0, 160, 190, 145, 0, 0, 0, 0, 0, 0, 100, 0, 0, 168, 198, + 0, 183, 33, 0, 0, 48, 228, 213, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 179, 0, 224, 104, + 0, 194, 149, 0, 0, 209, 0, 0, 0, 189, 99, 84, 0, 129, 0, 0, 0, 144, 0, 0, 234, 114, + 0, 0, 82, 0, 0, 0, 0, 217, 202, 0, 112, 52, 232, 0, 97, 0, 0, 0, 126, 0, 81, 201, + 0, 36, 216, 186, 0, 0, 0, 96, 0, 0, 0, 0, 0, 88, 0, 0, 0, 103, 0, 148, 178, 0, + 208, 193, 0, 58, 0, 0, 0, 0, 0, 161, 206, 0, 116, 0, 101, 0, 0, 56, 146, 176, 0, 0, + 147, 162, 222, 0, 132, 0, 0, 0, 0, 0, 177, 117, 192, 0, +}; + +const UWord16 rs16_elp_deg3_table[256] = { + /* If the polynomial x^3 + ax + b has distinct roots z1, z2 and z3 in GF(16), * + * then table entry a + 16*b contains z1) | z2 << 4 | z3 << 8, and otherwise it * + * contains 0. */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1889, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2977, 0, 0, 0, 0, 0, 3990, 1859, 0, + 0, 0, 0, 0, 0, 0, 3521, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1874, 0, 3718, 0, 0, 0, + 0, 0, 0, 2433, 0, 0, 1619, 0, 0, 0, 0, 3495, 0, 0, 0, 0, 0, 0, 4065, 0, 0, 0, + 0, 0, 0, 3255, 0, 0, 0, 1602, 0, 3735, 0, 0, 0, 0, 3238, 801, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3510, 0, 0, 0, 0, 1345, 3975, 0, 0, 0, 0, 0, 0, 0, 0, 3778, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2947, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3476, 0, 4005, 0, 3461, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3748, 0, 0, 2962, 0, 0, 0, 0, 4035, 0, 0, 4020, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3221, 0, 0, 0, 0, 0, 0, 2690, + 0, 0, 0, 3795, 0, 0, 0, 4050, 0, 0, 0, 0, 0, 3204, 3765, 0, 0, 0, 0, 0, 2707, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +#ifdef ENABLE_HR_MODE +const Word32 invSqrtTab[(128 + 2)] = { + 0x5A827999, 0x5A287E03, 0x59CF8CBC, 0x5977A0AC, 0x5920B4DF, 0x58CAC480, 0x5875CADE, 0x5821C364, 0x57CEA99D, + 0x577C7930, 0x572B2DE0, 0x56DAC38E, 0x568B3632, 0x563C81E0, 0x55EEA2C4, 0x55A19522, 0x55555555, 0x5509DFD0, + 0x54BF311A, 0x547545D0, 0x542C1AA4, 0x53E3AC5B, 0x539BF7CD, 0x5354F9E7, 0x530EAFA5, 0x52C91618, 0x52842A5F, + 0x523FE9AC, 0x51FC5140, 0x51B95E6B, 0x51770E8F, 0x51355F1A, 0x50F44D89, 0x50B3D768, 0x5073FA50, 0x5034B3E7, + 0x4FF601E0, 0x4FB7E1FA, 0x4F7A5202, 0x4F3D4FCF, 0x4F00D944, 0x4EC4EC4F, 0x4E8986EA, 0x4E4EA718, 0x4E144AE9, + 0x4DDA7073, 0x4DA115DA, 0x4D683948, 0x4D2FD8F4, 0x4CF7F31B, 0x4CC08605, 0x4C899000, 0x4C530F65, 0x4C1D0294, + 0x4BE767F5, 0x4BB23DF9, 0x4B7D8317, 0x4B4935CF, 0x4B1554A6, 0x4AE1DE2A, 0x4AAED0F0, 0x4A7C2B93, 0x4A49ECB3, + 0x4A1812FA, 0x49E69D16, 0x49B589BB, 0x4984D7A4, 0x49548592, 0x49249249, 0x48F4FC97, 0x48C5C34B, 0x4896E53D, + 0x48686148, 0x483A364D, 0x480C6332, 0x47DEE6E1, 0x47B1C049, 0x4784EE60, 0x4758701C, 0x472C447C, 0x47006A81, + 0x46D4E130, 0x46A9A794, 0x467EBCBA, 0x46541FB4, 0x4629CF98, 0x45FFCB80, 0x45D6128A, 0x45ACA3D5, 0x45837E88, + 0x455AA1CB, 0x45320CC8, 0x4509BEB0, 0x44E1B6B4, 0x44B9F40B, 0x449275ED, 0x446B3B96, 0x44444444, 0x441D8F3B, + 0x43F71BBF, 0x43D0E917, 0x43AAF68F, 0x43854374, 0x435FCF15, 0x433A98C6, 0x43159FDC, 0x42F0E3AE, 0x42CC6398, + 0x42A81EF6, 0x42841527, 0x4260458E, 0x423CAF8D, 0x4219528B, 0x41F62DF2, 0x41D3412A, 0x41B08BA2, 0x418E0CC8, + 0x416BC40D, 0x4149B0E5, 0x4127D2C3, 0x41062920, 0x40E4B374, 0x40C3713B, 0x40A261EF, 0x40818512, 0x4060DA22, + 0x404060A1, 0x40201814, 0x40000000, 0x3FE017EC /* , 0x3FC05F61 */ +}; +#endif diff --git a/lib_lc3plus/rom_basop_util.h b/lib_lc3plus/rom_basop_util.h new file mode 100644 index 000000000..6e757c339 --- /dev/null +++ b/lib_lc3plus/rom_basop_util.h @@ -0,0 +1,172 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef __BASOP_UTIL_ROM_H__ +#define __BASOP_UTIL_ROM_H__ + +#include "basop_util_lc3plus.h" +#include "functions.h" + +#define LD_INT_TAB_LEN 120 +#define INV_TABLE_SIZE 256 +#define SQRT_TABLE_SIZE 256 + +#ifndef CHEAP_NORM_SIZE +#define CHEAP_NORM_SIZE 161 +#endif + +#define MINSFTAB 7 +#define MAXSFTAB 25 + +#ifdef ENABLE_HR_MODE +#define SHC(x) ((Word32)x) +#else +#define SHC(x) WORD322WORD16((Word32)x) +#endif + +/** + * \brief Lookup-Table for binary logarithm + */ +extern const Word16 ldCoeff_lc3plus[7]; + +/** + \brief Lookup-Table for binary power algorithm +*/ +extern const UWord32 exp2_tab_long_lc3plus[32]; + +/** + \brief Lookup-Table for binary power algorithm +*/ +extern const UWord32 exp2w_tab_long_lc3plus[32]; + +/** + \brief Lookup-Table for binary power algorithm +*/ +extern const UWord32 exp2x_tab_long_lc3plus[32]; + +/** + * \brief 1/x, x=[0,1,2,3...] table + */ +#ifdef ENABLE_HR_MODE +extern const Word16 InvIntTable[74]; +#else +extern const Word16 InvIntTable[32]; +#endif + +/** + * \ brief Lookup for sine tables and windows. + */ +void BASOP_getTables( +#ifdef ENABLE_HR_MODE + const PWord32 **ptwiddle, + const PWord32 **sin_twiddle, +#else + const PWord16 **ptwiddle, + const PWord16 **sin_twiddle, +#endif + Word16 *sin_step, + Word16 length); + +extern const Word32 RealFFT20_twid[6]; +extern const Word32 RealFFT32_twid[10]; +extern const Word32 RealFFT40_twid[12]; +extern const Word32 RealFFT60_twid[17]; +extern const Word32 RealFFT64_twid[18]; +extern const Word32 RealFFT80_twid[22]; +extern const Word32 RealFFT96_twid[26]; +extern const Word32 RealFFT128_twid[34]; +extern const Word32 RealFFT192_twid[50]; +extern const Word32 RealFFT256_twid[66]; +extern const Word32 RealFFT384_twid[98]; +extern const Word32 RealFFT512_twid[130]; +extern const Word32 RealFFT768_twid[194]; + +#ifdef ENABLE_HR_MODE +extern const PWord32 SineTable480[241]; +extern const PWord32 SineTable320[161]; +extern const PWord32 SineTable960[481]; +#else +extern const PWord16 SineTable480[241]; +extern const PWord16 SineTable320[161]; +extern const PWord16 SineTable960[481]; +#endif + +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_15_6[2 * (90 - 15)]; +#else +extern const Word16 RotVector_15_6[2 * (90 - 15)]; +#endif + +extern const Word32 RotVector_32_32[2 * 20]; +extern const Word32 RotVector_40_32[2 * 28]; + +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_320[2 * (320 - 20)]; +#else +extern const Word16 RotVector_320[2 * (320 - 20)]; +#endif + +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_360[2 * (360 - 30)]; +#else +extern const Word16 RotVector_360[2 * (360 - 30)]; +#endif + +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_480[2 * (480 - 30)]; +#else +extern const Word16 RotVector_480[2 * (480 - 30)]; +#endif + +#ifdef ENABLE_HR_MODE +#ifdef CR8_G_ADD_75MS +extern const Word32 RotVector_720[2 * (720 - 30)]; +#endif +extern const Word32 RotVector_960[2 * (480 - 60)]; +#else +extern const Word16 RotVector_960[2 * (480 - 60)]; +#endif + +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_30_16[2 * (480 - 30)]; +#endif + +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_32_8[2 * (256 - 32)]; +#else +extern const Word16 RotVector_32_8[2 * (256 - 32)]; +#endif + +#if defined(SUBSET_SSWB) || defined(SUBSET_SWB) || defined(SUBSET_FB) +#ifdef ENABLE_HR_MODE +extern const Word32 RotVector_32_12[2 * (384 - 32)]; +#else +extern const Word16 RotVector_32_12[2 * (384 - 32)]; +#endif +#else +#define RotVector_32_12 NULL +#endif + +extern const Word32 isqrt_table[128 + 2]; + +extern const Word32 Log2_16_table1[16]; +extern const Word16 Log2_16_table2[16]; + +extern const Word32 InvLog2_16_table1[64]; +extern const Word16 InvLog2_16_table2[64]; + +extern const UWord8 gf16_mult_table[256]; +extern const UWord8 rs16_elp_deg2_table[256]; +extern const UWord16 rs16_elp_deg3_table[256]; + +#ifdef ENABLE_HR_MODE +extern const Word32 invSqrtTab[(128 + 2)]; +#endif + +#endif diff --git a/lib_lc3plus/scale_signal24_fx.c b/lib_lc3plus/scale_signal24_fx.c new file mode 100644 index 000000000..548788d2a --- /dev/null +++ b/lib_lc3plus/scale_signal24_fx.c @@ -0,0 +1,121 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void scale_signal24_fx(Word32 x[], /* i: time input signal */ +#ifdef ENABLE_HR_MODE + Word32 x_scaled[], +#else + Word16 x_scaled[], +#endif + Word16 *x_exp, +#ifdef ENABLE_HR_MODE + Word32 mdct_mem[], +#else + Word16 mdct_mem[], +#endif + Word16 mdct_mem_len, + Word16 resample_mem_in[], Word16 resample_mem_in_len, Word32 resample_mem_in50[], + Word16 resample_mem_out[], Word16 resample_mem_out_len, Word32 mdct_mem32[], Word16 N, + Word32 resamp_mem32[], Word16 mem_s12k8[], Word16 *resamp_scale) +{ + Word16 i; + Word16 s; + Word16 scales[6]; + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("scale_signal24_fx", sizeof(struct { + Word16 i; + Word16 s; + Word16 scales[6]; + })); +#endif + + /* Scale input for 24 bit case */ + /* assure 24 bit input */ + FOR (i = 0; i < N; i++) + { + IF (x[i] >= 0) + { + x[i] = L_and(x[i], 0x007fffff); + } + ELSE + { + x[i] = (Word32)L_or( (UWord32)x[i], 0xff800000); + } + } + + /* Find maximum exponent */ + scales[0] = sub(15 + 8, getScaleFactor32_0(x, N)); + scales[1] = sub(15 + 8, getScaleFactor32_0(mdct_mem32, mdct_mem_len)); + scales[2] = sub(15 + 8, getScaleFactor32_0(resamp_mem32, resample_mem_in_len)); + scales[3] = sub(sub(*resamp_scale, 2), getScaleFactor32_0(resample_mem_in50, 2)); + scales[4] = sub(sub(*resamp_scale, 2), getScaleFactor16_0(resample_mem_out, resample_mem_out_len)); + scales[5] = sub(sub(*resamp_scale, 2), getScaleFactor16_0(mem_s12k8, 3)); + *x_exp = 7; move16(); + FOR (i = 0; i < 6; i++) + { + *x_exp = s_max(*x_exp, scales[i]); move16(); + } + + /* Shift input buffers */ + s = sub(15 + 8, *x_exp); + FOR (i = 0; i < N; i++) + { +#ifdef ENABLE_HR_MODE + x_scaled[i] = L_shl(x[i], s); +#else + x_scaled[i] = round_fx_sat(L_shl(x[i], s)); +#endif + } + + FOR (i = 0; i < mdct_mem_len; i++) + { +#ifdef ENABLE_HR_MODE + mdct_mem[i] = L_shl(mdct_mem32[i], s); +#else + mdct_mem[i] = round_fx_sat(L_shl(mdct_mem32[i], s)); +#endif + } + + FOR (i = 0; i < resample_mem_in_len; i++) + { + resample_mem_in[i] = round_fx_sat(L_shl(resamp_mem32[i], s)); + } + + /* Adjust resampler filter and output buffers */ + s = sub(sub(*resamp_scale, 2), *x_exp); + *resamp_scale = add(*x_exp, 2); + + IF (s) + { + FOR (i = 0; i < 2; i++) + { + resample_mem_in50[i] = L_shl(resample_mem_in50[i], s); + } + FOR (i = 0; i < resample_mem_out_len; i++) + { + resample_mem_out[i] = shl(resample_mem_out[i], s); + } + + FOR (i = 0; i < 3; i++) + { + mem_s12k8[i] = shl(mem_s12k8[i], s); + } + } + /* Store part of current frame as mdct memory buffer and resampler input buffer for next frame */ + basop_memcpy(mdct_mem32, &x[N - mdct_mem_len], mdct_mem_len * sizeof(Word32)); + basop_memmove(resamp_mem32, &x[N - resample_mem_in_len], resample_mem_in_len * sizeof(Word32)); + +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + diff --git a/lib_lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3.c new file mode 100644 index 000000000..1d2849f56 --- /dev/null +++ b/lib_lc3plus/setup_dec_lc3.c @@ -0,0 +1,539 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include "setup_dec_lc3.h" + +/* if decoder is null only size is reported */ +/*assume 10ms for memory allocation for now */ +int alloc_decoder(LC3PLUS_Dec *decoder, int samplerate, int channels) +{ + int ch = 0; + size_t size = sizeof(LC3PLUS_Dec); + void * ltpf_mem_x = NULL, *ltpf_mem_y = NULL, *stDec_ola_mem_fx = NULL; + int max_len = DYN_MAX_LEN_EXT(samplerate); /*NB sing 80 as minimum value changes BE for NB */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word32 * plc_longterm_advc_tdc = NULL, *plc_longterm_advc_ns = NULL; + Word16 longterm_analysis_counter_max = 0, longterm_analysis_counter_max_bytebuffer = 0; +#endif + + void *q_old_res_fx = NULL; + Word16 *sharedBuf = NULL; +#if defined(ENABLE_PC) + void *q_old_d_fx = NULL; +#endif + void *plcAd = NULL, *PhECU_f0est = NULL, *PhECU_plocs = NULL; + + for (ch = 0; ch < channels; ch++) + { + DecSetup *setup = balloc(decoder, &size, sizeof(DecSetup)); +#ifdef ENABLE_HR_MODE + int q_old_len = MIN(CODEC_FS(samplerate) * 100 / 10000, MAX_BW_HR); +#else + int q_old_len = MIN(CODEC_FS(samplerate) * 100 / 10000, MAX_BW ); +#endif + int x_old_len = DYN_MAX_LEN_PCM_PLC(samplerate); /* max(pitchmax + frame ms, M+1 + pitchmax + frame/2) */ + int fs_idx = (samplerate / 10000); /* floor= integer truncation is needed here */ + + ltpf_mem_x = balloc(decoder, &size, sizeof(*setup->ltpf_mem_x) * (max_len + max_len / 40 - 2)); + ltpf_mem_y = + balloc(decoder, &size, + sizeof(*setup->ltpf_mem_y) * (max_len + CEILING(MAX_PITCH_12K8 * max_len, 128) + (max_len / 80))); + + stDec_ola_mem_fx = balloc(decoder, &size, sizeof(*setup->stDec_ola_mem_fx) * DYN_MAX_MDCT_LEN(samplerate)); + +#if defined(ENABLE_PC) + q_old_d_fx = balloc(decoder, &size, sizeof(*setup->q_old_d_fx) * q_old_len); +#endif + sharedBuf = balloc(decoder, &size, sizeof(*setup->q_old_d_fx) * q_old_len + sizeof(*setup->plcAd->x_old_tot_fx) * x_old_len); + + /* To save static RAM, a large buffer sharedBuf is used to share + * space for q_old_d_fx, x_old_tot_fx and X_sav_fx (note: + * PHASE_ECU operates only at 10ms and standard precision) + * + * If partial Concealment is active, q_old_d_fx is saved in a separate buffer + * + * The following graph provides an overview about the memory + * sharing for 10ms and normal resolution: + */ + + /* Total buffer | <--- sharedBuf ---> | */ + /* ConcealMethod 3or4 | <---q_old_d_fx---> | <-------------------- x_old_tot_fx ------------------> | */ + /* ConcealMethod 3 | <---q_old_d_fx---> | |<------- M+1+pitch_max+ (frame_len/2)----------> | */ /* first BFI-frame only? */ + /* Meth 2,prevBfi=0 | | <------- 16 ms xfp ------->| */ + /* Meth 2 | ^ X_sav_fx ptr | <-------- maintained old_tot_fx ---------> | */ /* pitchmax samples maintained */ + /* Meth 2 | <----- X_sav 16 ms ----------> | ^xfp_fx ptr | */ + /* Meth2 ,prevBfi=1 | | <-12.25(forTDC),3.75(PLC2)->| */ /*the part used by PhECU is 3.75ms */ + /* ConcealMethod 2 |<- <10ms ->| */ + int max_plocs = DYN_MAX_PLOCS(samplerate); + plcAd = balloc(decoder, &size, sizeof(*setup->plcAd)); + PhECU_f0est = balloc(decoder, &size, sizeof(*setup->plcAd->PhECU_f0est) * max_plocs); + PhECU_plocs = balloc(decoder, &size, sizeof(*setup->plcAd->PhECU_plocs) * max_plocs); +#ifdef ENABLE_HR_MODE + q_old_res_fx = balloc(decoder, &size, sizeof(*setup->q_old_res_fx) * max_len); +#else + q_old_res_fx = balloc(decoder, &size, sizeof(*setup->q_old_res_fx) * MIN(max_len, MAX_BW)); +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +/* longterm_analysis_counter_max = PLC_LONGTERM_ANALYSIS_MS * (100.0f / 25.0f);*/ +/* assert(longterm_analysis_counter_max == (PLC_LONGTERM_ANALYSIS_MS * (100 /25))); */ /* test integer division for compatibility */ +/* longterm_analysis_counter_max_bytebuffer = floor(longterm_analysis_counter_max / 30.0); */ +/* assert(longterm_analysis_counter_max_bytebuffer == (longterm_analysis_counter_max / 30)); */ /* test integer division for compatibility */ + +/* longterm_analysis_counter_max = (longterm_analysis_counter_max_bytebuffer+1) * 30; */ + + longterm_analysis_counter_max = plc_fadeout_param_maxlen[0]; + longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[0]; + + plc_longterm_advc_tdc = balloc(decoder, &size, sizeof(Word32) * longterm_analysis_counter_max_bytebuffer); + plc_longterm_advc_ns = balloc(decoder, &size, sizeof(Word32) * longterm_analysis_counter_max_bytebuffer); +#endif + + if (decoder) + { + decoder->channel_setup[ch] = setup; + setup->ltpf_mem_x = ltpf_mem_x; + setup->ltpf_mem_y = ltpf_mem_y; + setup->stDec_ola_mem_fx = stDec_ola_mem_fx; + setup->q_old_res_fx = q_old_res_fx; +#if defined(ENABLE_PC) + setup->q_old_d_fx = q_old_d_fx; +#else + setup->q_old_d_fx = sharedBuf; +#endif + setup->plcAd = plcAd; + } + if (decoder && plcAd) + { +#ifdef ENABLE_HR_MODE + if (fs_idx > 4) + { + fs_idx = 4; + } +#endif + + setup->plcAd->x_old_tot_fx = &sharedBuf[q_old_len]; + setup->plcAd->PhECU_f0est = PhECU_f0est; + setup->plcAd->PhECU_xfp_fx = &(setup->plcAd->x_old_tot_fx[x_old_len-LprotSzPtr[fs_idx]]); /* point to the last 16ms of the x_old_tot_fx */ + setup->plcAd->PhECU_X_sav_fx = sharedBuf; /* reuse of lprot(=num_FsByResQ0[fs_idx]) values from this point fwd, i.e beyond the end of q_old_fx */ + setup->plcAd->PhECU_plocs = PhECU_plocs; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->plcAd->longterm_analysis_counter_max = longterm_analysis_counter_max; + setup->plcAd->longterm_analysis_counter_max_bytebuffer = longterm_analysis_counter_max_bytebuffer; + + setup->plcAd->plc_longterm_advc_tdc = plc_longterm_advc_tdc; + setup->plcAd->plc_longterm_advc_ns = plc_longterm_advc_ns; +#endif + } + } + + return (int)size; +} + +LC3PLUS_Error FillDecSetup(LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + ) +{ + int ch = 0; + + memset(decoder, 0, lc3plus_dec_get_size(samplerate, channels, plc_mode)); + alloc_decoder(decoder, samplerate, channels); + +#ifdef ENABLE_HR_MODE + decoder->hrmode = hrmode != 0; +#endif + + decoder->fs = CODEC_FS(samplerate); + decoder->fs_out = samplerate; + decoder->fs_idx = FS2FS_IDX(decoder->fs); + decoder->channels = channels; + decoder->frame_dms = 100; + decoder->plcMeth = plc_mode; + { + decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; + } + decoder->ltpf_mem_x_len = extract_l(L_shr_pos(Mpy_32_16_lc3plus(L_max(16000, decoder->fs), 16778), 11)) - 2; + decoder->ltpf_mem_y_len = extract_l(L_shr_pos(Mpy_32_16_lc3plus(decoder->fs, 18678) - 1, 5)) + 1 + + extract_l(L_shr_pos(Mpy_32_16_lc3plus(L_max(16000, decoder->fs), 16778), 12)); + + set_dec_frame_params(decoder); + + for (ch = 0; ch < decoder->channels; ch++) + { + DecSetup *setup = decoder->channel_setup[ch]; + setup->plc_damping = 32767; + setup->ltpf_mem_scale_fac_idx = -1; + move16(); + + setup->pc_seed = 24607; + setup->ns_seed = 24607; + setup->ns_cum_alpha = 32767; + + int i = 0; + /* 0 = 0kHz 1= 8kHz, 2= 16 kHz 3= 24 , 4 = 32 5=40 6=48kHz */ +#if (PHECU_XFP_LA == 0) + Word16 oneMsTab_LA[5] = {0, 0, 0, 0, 0}; +#else +# if (PHECU_XFP_LA == 4) + Word16 oneMsTab_LA[7] = {0 /*unused*/, 2, 4, 6, 8, 10 /*unused*/, 12}; +# else + Word16 oneMsTab_LA[7] = {0 /*unused*/, 8, 16, 24, 32, 40 /*unused*/, 48}; +# endif +#endif + Word16 oneMsTab[5] = {8, 16, 24, 32, 48}; + + setup->plcAd->stab_fac = 32767; + setup->plcAd->tdc_seed = 24607; + setup->plcAd->tdc_preemph_fac = plc_preemph_fac[decoder->fs_idx]; + setup->plcAd->tdc_lpc_order = 16; + setup->plcAd->PhECU_fs_idx_fx = + mult(decoder->frame_length, + (Word16)(32768.0 / 99.0)); /* truncation needed , i.e no rounding can be applied here */ + /* idx=frame/80, 0=8kHZ, 1=16kHz, 2=24 kHz, 3=32 kHz 5=*, 4=48 */ + + setup->plcAd->max_len_pcm_plc = DYN_MAX_LEN_PCM_PLC(decoder->fs); + + if ((decoder->hrmode == 0) && (samplerate <= 48000)) + { + setup->plcAd->PhECU_frame_ms = (Word16)( + decoder->frame_dms * 0.1); /* needed in PLCUpdate and PLC main functions, adjusted in first frame */ + setup->plcAd->PhECU_seed_fx = 21845; + setup->plcAd->PhECU_LprotOrg_fx = + shl_pos(oneMsTab[setup->plcAd->PhECU_fs_idx_fx], 4); /* 16 *1ms = 1.6 *framelength */ + setup->plcAd->PhECU_Lprot_fx = setup->plcAd->PhECU_LprotOrg_fx; + setup->plcAd->PhECU_LA = oneMsTab_LA[setup->plcAd->PhECU_fs_idx_fx]; + setup->plcAd->PhECU_whr_tot_taper = sub(setup->plcAd->PhECU_Lprot_fx, decoder->frame_length); /* 3+3 ms */ + setup->plcAd->PhECU_whr_tot_flat = decoder->frame_length; /* 10 ms */ + setup->plcAd->PhECU_LDWIN_OLAP = shr_pos(decoder->frame_length, 2); /* 2.5 ms */ + setup->plcAd->max_lprot = DYN_MAX_LPROT(decoder->fs); + setup->plcAd->max_plocs = DYN_MAX_PLOCS(decoder->fs); + setup->plcAd->PhECU_margin_xfp = 0; + setup->plcAd->PhECU_L_oold_xfp_w_E_fx = LTOT_MIN_MAN; + setup->plcAd->PhECU_L_old_xfp_w_E_fx = LTOT_MIN_MAN; + + setup->plcAd->PhECU_oold_xfp_w_E_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL; + setup->plcAd->PhECU_old_xfp_w_E_exp_fx = LTOT_INIT_FLAG; + + setup->plcAd->PhECU_oold_Ltot_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL; + setup->plcAd->PhECU_old_Ltot_exp_fx = LTOT_INIT_FLAG; + + + for (i = 0; i < MAX_LGW; i++) + { + setup->plcAd->PhECU_oold_grp_shape_fx[i] = + GRP_SHAPE_INIT; /* negative value will be replaced in very first calculation */ + setup->plcAd->PhECU_old_grp_shape_fx[i] = GRP_SHAPE_INIT; + } + /* t_adv=ctrl.FRAME/2 + ctrl.PhECU.LprotOrg/2 - ctrl.PhECU.LA + LDWIN_OLAP/2; */ + i = add(add(decoder->frame_length, setup->plcAd->PhECU_LprotOrg_fx), setup->plcAd->PhECU_LDWIN_OLAP); + setup->plcAd->PhECU_t_adv = sub(shr_pos(i, 1), setup->plcAd->PhECU_LA); + + for (i = 0; i < MAX_LGW; i++) + { + setup->plcAd->PhECU_mag_chg_1st[i] = 32767; + } + setup->plcAd->PhECU_beta_mute = 16384; +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->plcAd->PhECU_nonpure_tone_flag = -1; +#endif + } + } + + lc3plus_dec_set_ep_enabled(decoder, 0); + return LC3PLUS_OK; +} + +/* set frame config params */ +void set_dec_frame_params(LC3PLUS_Dec *decoder) +{ +# ifdef CR8_G_ADD_75MS + Word16 tmp = 0; +# endif +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + Word16 n; +#endif + + decoder->frame_length = extract_l(L_shr_pos(Mpy_32_16_lc3plus(decoder->fs, 20972), 6)); /* fs * 0.01*2^6 */ + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + decoder->BW_cutoff_bits = 0; + } +#endif + + SWITCH (decoder->frame_dms) + { + case 25: + decoder->frame_length = shr_pos(decoder->frame_length, 2); + decoder->la_zeroes = LowDelayShapes_n960_la_zeroes_2_5ms[decoder->fs_idx]; + decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + decoder->bands_number = bands_number_2_5ms_HR[decoder->fs_idx]; + decoder->bands_offset = bands_offset_2_5ms_HR[decoder->fs_idx - 4]; + decoder->W_fx = LowDelayShapes_n960_HRA_2_5ms[decoder->fs_idx - 4]; + decoder->W_size = LowDelayShapes_n960_len_2_5ms[decoder->fs_idx]; + decoder->yLen = decoder->frame_length; + } + else +#endif + { + decoder->bands_number = bands_number_2_5ms[decoder->fs_idx]; + decoder->bands_offset = bands_offset_2_5ms[decoder->fs_idx]; + decoder->W_fx = LowDelayShapes_n960_2_5ms[decoder->fs_idx]; + decoder->W_size = LowDelayShapes_n960_len_2_5ms[decoder->fs_idx]; + decoder->yLen = s_min(MAX_BW >> 2, decoder->frame_length); + } + + if (decoder->fs_idx == 0) + { + int ch; + for (ch = 0; ch < decoder->channels; ch++) + { + DecSetup *setup = decoder->channel_setup[ch]; + if (setup->plcAd != NULL) + { + setup->plcAd->tdc_lpc_order = 8; + } + } + } + BREAK; + case 50: + decoder->frame_length = shr_pos(decoder->frame_length, 1); + decoder->la_zeroes = LowDelayShapes_n960_la_zeroes_5ms[decoder->fs_idx]; + decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + decoder->bands_offset = bands_offset_5ms_HR[decoder->fs_idx - 4]; + decoder->W_fx = LowDelayShapes_n960_HRA_5ms[decoder->fs_idx - 4]; + decoder->W_size = LowDelayShapes_n960_len_5ms[decoder->fs_idx]; + decoder->yLen = decoder->frame_length; + decoder->bands_number = bands_number_5ms[decoder->fs_idx]; + } + else +#endif + { + decoder->bands_offset = bands_offset_5ms[decoder->fs_idx]; + decoder->W_fx = LowDelayShapes_n960_5ms[decoder->fs_idx]; + decoder->W_size = LowDelayShapes_n960_len_5ms[decoder->fs_idx]; + decoder->yLen = s_min(MAX_BW >> 1, decoder->frame_length); + decoder->bands_number = bands_number_5ms[decoder->fs_idx]; + } + BREAK; + +#ifdef CR8_G_ADD_75MS + case 75: + tmp = shr_pos(decoder->frame_length, 2); + decoder->frame_length = add(tmp, add(tmp, tmp)); + decoder->la_zeroes = LowDelayShapes_n960_la_zeroes_7_5ms[decoder->fs_idx]; + decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); +# ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + decoder->bands_offset = bands_offset_7_5ms_HR[decoder->fs_idx - 4]; + decoder->W_fx = LowDelayShapes_n960_HRA_7_5ms[decoder->fs_idx - 4]; + decoder->W_size = LowDelayShapes_n960_len_7_5ms[decoder->fs_idx]; + decoder->yLen = decoder->frame_length; + decoder->bands_number = bands_number_7_5ms[decoder->fs_idx]; + } + else +# endif + { + decoder->bands_offset = bands_offset_7_5ms[decoder->fs_idx]; + decoder->W_fx = LowDelayShapes_n960_7_5ms[decoder->fs_idx]; + decoder->W_size = LowDelayShapes_n960_len_7_5ms[decoder->fs_idx]; + decoder->yLen = s_min((MAX_BW >> 2) * 3, decoder->frame_length); + decoder->bands_number = bands_number_7_5ms[decoder->fs_idx]; + } + BREAK; +# endif + + case 100: + decoder->la_zeroes = LowDelayShapes_n960_la_zeroes[decoder->fs_idx]; + decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); + decoder->bands_number = 64; + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + decoder->bands_offset = bands_offset_HR[decoder->fs_idx - 4]; + decoder->W_fx = LowDelayShapes_n960_HRA[decoder->fs_idx - 4]; + decoder->W_size = LowDelayShapes_n960_len[decoder->fs_idx]; + decoder->yLen = decoder->frame_length; + } + else +#endif + { + decoder->W_fx = LowDelayShapes_n960[decoder->fs_idx]; + decoder->W_size = LowDelayShapes_n960_len[decoder->fs_idx]; + decoder->bands_offset = bands_offset[decoder->fs_idx]; + decoder->yLen = s_min(MAX_BW, decoder->frame_length); + } + BREAK; + } + + { + int ch; + for (ch = 0; ch < decoder->channels; ch++) + { + DecSetup *setup = decoder->channel_setup[ch]; + if (setup->plcAd != NULL) + { /*only set if plcAd was actually allocated */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->plcAd->longterm_analysis_counter_max = plc_fadeout_param_maxlen[(decoder->frame_dms / 25) - 1]; + setup->plcAd->longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[(decoder->frame_dms / 25) - 1]; + +#endif + setup->plcAd->PhECU_frame_ms = (Word16)( + decoder->frame_dms * + 0.1); /* needed in processPLCupdate_fx(), now set properly set in first frame /second time */ + } + } + } +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + FOR (n=0; n < PLC_FADEOUT_TYPE_1_IN_MS*10/decoder->frame_dms;n++){ + decoder->alpha_type_2_table[n] = type_2_fadeout_fx(n, decoder->frame_dms); + } +#endif +} + +LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes) +{ + int tmp = 0, totalBits = 0; + int channel_bytes = 0; + int minBytes, maxBytes; + + DecSetup *setup = decoder->channel_setup[ch]; + channel_bytes = nBytes; + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + SWITCH (decoder->frame_dms) + { + case 25: + maxBytes = 210; + minBytes = MIN_NBYTES; + BREAK; + case 50: + maxBytes = 375; + minBytes = MIN_NBYTES; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + maxBytes = 625; + minBytes = MIN_NBYTES; + BREAK; +#endif + case 100: + maxBytes = 625; + minBytes = MIN_NBYTES; + BREAK; + default: return LC3PLUS_HRMODE_ERROR; + } + } + else +#endif + { + minBytes = MIN_NBYTES; + maxBytes = MAX_NBYTES_100; + } + + if (channel_bytes < minBytes || channel_bytes > maxBytes) + { + return LC3PLUS_NUMBYTES_ERROR; + } + + setup->targetBytes = channel_bytes; + move16(); + setup->total_bits = shl(setup->targetBytes, 3); + setup->enable_lpc_weighting = (setup->total_bits < 480); + setup->quantizedGainOff = + -(s_min(115, setup->total_bits / (10 * (decoder->fs_idx + 1))) + 105 + 5 * (decoder->fs_idx + 1)); + tmp = DEPR_i_mult(80, decoder->fs_idx); + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode && decoder->fs_idx == 5) + { + setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); + } +#endif + + totalBits = setup->total_bits; + + + SWITCH (decoder->frame_dms) + { + case 25: + setup->enable_lpc_weighting = 0; + /* total_bits * 2.4 */ + totalBits = extract_l(L_shr(L_mult0(19661, setup->total_bits), 13)); + BREAK; + case 50: + setup->enable_lpc_weighting = setup->total_bits < 240; + totalBits = sub(DEPR_i_mult(setup->total_bits, 2), 160); + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + setup->enable_lpc_weighting = setup->total_bits < 360; + totalBits = L_shr(L_mult0(10923, setup->total_bits), 13); + BREAK; +# endif + case 100: + BREAK; + } + + + if (sub(totalBits, add(320, tmp)) < 0) + { + setup->ltpf_scale_fac_idx = 0; + move16(); + } + else if (sub(totalBits, add(400, tmp)) < 0) + { + setup->ltpf_scale_fac_idx = 1; + move16(); + } + else if (sub(totalBits, add(480, tmp)) < 0) + { + setup->ltpf_scale_fac_idx = 2; + move16(); + } + else if (sub(totalBits, add(560, tmp)) < 0) + { + setup->ltpf_scale_fac_idx = 3; + move16(); + } + else + { + setup->ltpf_scale_fac_idx = -1; + move16(); + } + +#ifdef ENABLE_HR_MODE + /* No LTPF in hrmode */ + if (decoder->hrmode) + { + setup->ltpf_scale_fac_idx = -1; + move16(); + } +#endif + + return LC3PLUS_OK; +} + diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h new file mode 100644 index 000000000..5c36163d3 --- /dev/null +++ b/lib_lc3plus/setup_dec_lc3.h @@ -0,0 +1,185 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef SETUP_DEC_LC3_H +#define SETUP_DEC_LC3_H + +#include "constants.h" + +typedef struct +{ + Word16 *x_old_tot_fx; /* MAX_LEN_PCM_PLC_TOT */ + Word32 *PhECU_f0est; /* MAX_PLOCS interpolated plocs */ + Word16 *PhECU_xfp_fx; /* MAX_LPROT */ + Word16 *PhECU_X_sav_fx; /* MAX_LPROT */ + Word16 *PhECU_plocs; /* MAX_PLOCS */ + Word16 *PhECU_fg_wintaper; /* MDCT_MEM_LEN_MAX */ + Word16 *PhECU_win_pre_tda; /* MAX_WIN_PRE_TDA */ + Word32 tdc_gain_c; + Word16 stab_fac; + Word16 tdc_fract; + Word16 tdc_seed; + Word16 tdc_preemph_fac; + Word16 tdc_lpc_order; + Word16 cum_fflcAtten; + Word16 harmonicBuf_fx[MAX_PITCH] ALIGN_BUFFER_STRUCT; + Word16 harmonicBuf_Q; + Word16 synthHist_fx[M] ALIGN_BUFFER_STRUCT; + Word16 cum_fading_slow; + Word16 cum_fading_fast; + Word16 PhECU_LprotOrg_fx; /* needed to change the Prot size adaptively */ + Word16 PhECU_Lprot_fx; + Word16 PhECU_fs_idx_fx; + Word16 PhECU_frame_ms; /* needed in PLC_Update and PLCMain functons*/ + Word16 PhECU_seed_fx; + Word16 PhECU_xfp_exp_fx; + Word16 PhECU_time_offs; + Word16 PhECU_X_savQ_fx; + Word16 PhECU_num_plocs; + Word16 PhECU_f0hzLtpBinQ7; /* ltp F0 in bins if available */ + Word16 PhECU_short_flag_prev; + Word16 PhECU_whr_tot_taper; + Word16 PhECU_whr_tot_flat; + Word16 PhECU_LDWIN_OLAP; + Word16 PhECU_LA; + Word16 PhECU_t_adv; + Word16 PhECU_beta_mute; + Word16 norm_corrQ15_fx; + Word16 q_fx_old_exp; + Word16 max_len_pcm_plc; + Word16 max_lprot; + Word16 max_plocs; + + /* Word32 L_tot W_energy sum exponent */ + Word16 PhECU_oold_Ltot_exp_fx; + Word16 PhECU_old_Ltot_exp_fx; + Word32 PhECU_L_oold_xfp_w_E_fx; + Word32 PhECU_L_old_xfp_w_E_fx; + Word16 PhECU_oold_xfp_w_E_exp_fx; /* input Word16 xfp exponnet */ + Word16 PhECU_old_xfp_w_E_exp_fx; + Word16 PhECU_oold_grp_shape_fx[MAX_LGW] ALIGN_BUFFER_STRUCT; + Word16 PhECU_old_grp_shape_fx[MAX_LGW] ALIGN_BUFFER_STRUCT; + Word16 PhECU_margin_xfp; +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 PhECU_nonpure_tone_flag; /* non-pure single tone indicator state */ +#endif + Word16 PhECU_mag_chg_1st[MAX_LGW] ALIGN_BUFFER_STRUCT; + Word16 PhECU_Xavg[MAX_LGW] ALIGN_BUFFER_STRUCT; + Word16 old_scf_q[M] ALIGN_BUFFER_STRUCT; + Word16 old_old_scf_q[M] ALIGN_BUFFER_STRUCT; + Word16 tdc_A[M + 1] ALIGN_BUFFER_STRUCT; + /* for now 20 ms saved Q14 or ptr to a combined ifft win and MDCT preTDA synthesis window 16 ms */ + +#ifdef CR8_A_PLC_FADEOUT_TUNING + Word16 longterm_counter_plcTdc; +# ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + Word16 longterm_counter_plcPhaseEcu; +# endif + Word16 longterm_counter_plcNsAdv; + Word16 longterm_analysis_counter_max; /* Maximum longterm frames number */ + Word16 longterm_analysis_counter_max_bytebuffer; /* Same as above but reduced for circular bit-buffer */ + Word32 *plc_longterm_advc_tdc; + Word32 *plc_longterm_advc_ns; + UWord8 plc_fadeout_type; + Word16 overall_counter; + Word8 longterm_counter_byte_position; + Word8 longterm_counter_bit_position; +#endif +} AplcSetup; + +/* Channel state and bitrate-derived values go in this struct */ +typedef struct +{ + Word16 *ltpf_mem_x; /* LTPF_MEM_X_LEN */ + Word16 *ltpf_mem_y; /* LTPF_MEM_Y_LEN */ +#ifdef ENABLE_HR_MODE + Word32 *stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ +#else + Word16 *stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ +#endif + AplcSetup *plcAd; + Word16 * q_old_d_fx; /* MAX_BW */ + Word16 q_old_fx_exp; + Word16 ns_seed; + Word16 ns_cum_alpha; + Word16 pc_nbLostFramesInRow; + Word16 pc_seed; + Word16 *q_old_res_fx; + Word16 q_old_res_fx_exp; + Word16 prev_gg; + Word16 prev_gg_e; + Word16 prev_BW_cutoff_idx_nf; + Word16 prev_fac_ns_fx; + Word16 total_bits; + Word16 enable_lpc_weighting; + Word16 stDec_ola_mem_fx_exp; + Word16 targetBytes; + Word16 ltpf_mem_e; + Word16 ltpf_mem_pitch_int; + Word16 ltpf_mem_pitch_fr; + Word16 ltpf_mem_gain; + Word16 ltpf_mem_active; + Word16 ltpf_scale_fac_idx; + Word16 ltpf_mem_scale_fac_idx; + Word16 quantizedGainOff; + Word16 prev_bfi; + Word16 prev_prev_bfi; + Word16 concealMethod; + Word16 nbLostFramesInRow; + Word16 plc_damping; + Word16 last_size; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + Word32 rel_pitch_change; +#endif +} DecSetup; + +/* Constants and sampling rate derived values go in this struct */ +struct LC3PLUS_Dec +{ + DecSetup * channel_setup[MAX_CHANNELS]; +#ifdef ENABLE_HR_MODE + const Word32 *W_fx; +#else + const Word16 *W_fx; +#endif + const Word16 *bands_offset; + Word32 fs; /* sampling rate, 44.1 maps to 48 */ + Word32 fs_out; /* output sampling rate */ + Word16 fs_idx; /* sampling rate index */ + Word16 frame_length; /* sampling rate index */ + Word16 channels; /* number of channels */ + Word16 plcMeth; /* PLC method for all channels */ + Word16 frame_dms; /* frame length in dms (decimilliseconds, 10^-4)*/ + Word16 last_size; /* size of last frame, without error protection */ + Word16 ep_enabled; /* error protection enabled */ + Word16 error_report; /* corrected errors in last frame or -1 on error */ + + Word16 n_pccw; + Word16 be_bp_left; + Word16 be_bp_right; + Word16 n_pc; + Word16 m_fec; + Word16 epmr; + Word16 combined_channel_coding; + + Word16 yLen; + Word16 W_size; + Word16 la_zeroes; + Word16 stDec_ola_mem_fx_len; + Word16 bands_number; + Word16 ltpf_mem_x_len; + Word16 ltpf_mem_y_len; + Word16 BW_cutoff_bits; + Word16 hrmode; +#ifdef CR10_A_ATTENUATION_CURVE_SELECTOR + Word16 alpha_type_2_table[80];/* PLC_FADEOUT_TYPE_1_IN_MS*10/25 */ +#endif +}; + +#endif diff --git a/lib_lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3.c new file mode 100644 index 000000000..7e20912bb --- /dev/null +++ b/lib_lc3plus/setup_enc_lc3.c @@ -0,0 +1,760 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" +#include "setup_enc_lc3.h" + +/* if encoder is null only size is reported */ +int alloc_encoder(LC3PLUS_Enc *encoder, int samplerate, int channels) +{ + int ch = 0; + size_t size = sizeof(LC3PLUS_Enc); + void * mdct_mem32 = NULL, *stEnc_mdct_mem = NULL; + + for (ch = 0; ch < channels; ch++) + { + EncSetup *setup = balloc(encoder, &size, sizeof(EncSetup)); + mdct_mem32 = balloc(encoder, &size, sizeof(*setup->mdct_mem32) * DYN_MAX_MDCT_LEN(samplerate)); + stEnc_mdct_mem = balloc(encoder, &size, sizeof(*setup->stEnc_mdct_mem) * DYN_MAX_MDCT_LEN(samplerate)); + if (encoder) + { + encoder->channel_setup[ch] = setup; + setup->mdct_mem32 = mdct_mem32; + setup->stEnc_mdct_mem = stEnc_mdct_mem; + } + } + + return (int)size; +} + +LC3PLUS_Error FillEncSetup(LC3PLUS_Enc *encoder, int samplerate, int channels +#ifdef ENABLE_HR_MODE + , int hrmode +#endif + , int32_t lfe_channel_array[] + ) +{ + int ch = 0; + + memset(encoder, 0, lc3plus_enc_get_size(samplerate, channels)); + alloc_encoder(encoder, samplerate, channels); + + encoder->fs = CODEC_FS(samplerate); + encoder->fs_in = samplerate; + encoder->fs_idx = FS2FS_IDX(encoder->fs); + +# ifdef ENABLE_HR_MODE + if (encoder->fs_idx > 4) + { + encoder->fs_idx = 5; + } + encoder->hrmode = hrmode != 0; +# endif + + encoder->channels = channels; + encoder->frame_dms = 100; + encoder->envelope_bits = 38; + encoder->global_gain_bits = 8; + encoder->noise_fac_bits = 3; + encoder->r12k8_mem_in_len = extract_l(L_shr_pos(Mpy_32_16_lc3plus(encoder->fs, 20972), 9)); + encoder->r12k8_mem_out_len = 24; + encoder->epmr = LC3PLUS_EPMR_ZERO; + encoder->bw_ctrl_active = 0; + encoder->bandwidth = L_shr_pos(encoder->fs, 1); + encoder->bandwidth_preset = L_shr_pos(encoder->fs, 1); + + for (ch = 0; ch < encoder->channels; ch++) + { + encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0; + } + + + for (ch = 0; ch < encoder->channels; ch++) + { + encoder->channel_setup[ch]->x_exp = 15; + encoder->channel_setup[ch]->resamp_exp = 17; + } + + set_enc_frame_params(encoder); + + return lc3plus_enc_set_ep_mode(encoder, LC3PLUS_EP_OFF); /* also calls update_enc_bitrate */ +} + +/* set frame config params */ +void set_enc_frame_params(LC3PLUS_Enc *encoder) +{ +#ifdef CR8_G_ADD_75MS +# ifdef ENABLE_075_DMS_MODE + Word16 tmp; +# endif +#endif + + encoder->frame_length = extract_l(L_shr_pos(Mpy_32_16_lc3plus(encoder->fs, 20972), 6)); /* fs * 0.01*2^6 */ + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + encoder->BW_cutoff_bits = 0; + } + else +# endif + { + encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; + } + + SWITCH (encoder->frame_dms) + { + case 25: + encoder->frame_length = shr_pos(encoder->frame_length, 2); + encoder->la_zeroes = LowDelayShapes_n960_la_zeroes_2_5ms[encoder->fs_idx]; + encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); + encoder->nSubdivisions = 2; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 2); + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + encoder->bands_number = bands_number_2_5ms_HR[encoder->fs_idx]; + encoder->bands_offset = bands_offset_2_5ms_HR[encoder->fs_idx - 4]; + encoder->W_fx = LowDelayShapes_n960_HRA_2_5ms[encoder->fs_idx - 4]; + encoder->W_size = LowDelayShapes_n960_len_2_5ms[encoder->fs_idx]; + encoder->yLen = encoder->frame_length; + } + else +# endif + { + encoder->yLen = s_min(MAX_BW >> 2, encoder->frame_length); + encoder->W_fx = LowDelayShapes_n960_2_5ms[encoder->fs_idx]; + encoder->W_size = LowDelayShapes_n960_len_2_5ms[encoder->fs_idx]; + encoder->bands_number = bands_number_2_5ms[encoder->fs_idx]; + encoder->bands_offset = bands_offset_2_5ms[encoder->fs_idx]; + encoder->near_nyquist_index = encoder->bands_number - 2; + encoder->near_nyquist_flag = 0; + } + + BREAK; + case 50: + encoder->frame_length = shr_pos(encoder->frame_length, 1); + encoder->la_zeroes = LowDelayShapes_n960_la_zeroes_5ms[encoder->fs_idx]; + encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); + encoder->nSubdivisions = 2; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 1); + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + encoder->bands_offset = bands_offset_5ms_HR[encoder->fs_idx - 4]; + encoder->W_fx = LowDelayShapes_n960_HRA_5ms[encoder->fs_idx - 4]; + encoder->W_size = LowDelayShapes_n960_len_5ms[encoder->fs_idx]; + encoder->yLen = encoder->frame_length; + encoder->bands_number = bands_number_5ms[encoder->fs_idx]; + } + else +# endif + { + encoder->yLen = s_min(MAX_BW >> 1, encoder->frame_length); + encoder->W_fx = LowDelayShapes_n960_5ms[encoder->fs_idx]; + encoder->W_size = LowDelayShapes_n960_len_5ms[encoder->fs_idx]; + encoder->bands_number = bands_number_5ms[encoder->fs_idx]; + encoder->bands_offset = bands_offset_5ms[encoder->fs_idx]; + encoder->near_nyquist_index = encoder->bands_number - 3; + encoder->near_nyquist_flag = 0; + } + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; + BREAK; + +#ifdef CR8_G_ADD_75MS + case 75: + tmp = shr_pos(encoder->frame_length, 2); + encoder->frame_length = add(tmp, add(tmp, tmp)); + encoder->la_zeroes = LowDelayShapes_n960_la_zeroes_7_5ms[encoder->fs_idx]; + encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); + encoder->bands_number = bands_number_7_5ms[encoder->fs_idx]; + encoder->nSubdivisions = 3; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; + encoder->attdec_nblocks = 3; + encoder->attdec_damping = 9830; + encoder->attdec_hangover_thresh = 1; + encoder->r12k8_mem_out_len = 44; + encoder->near_nyquist_index = encoder->bands_number - 4; + encoder->near_nyquist_flag = 0; +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + encoder->yLen = encoder->frame_length; + encoder->W_fx = LowDelayShapes_n960_HRA_7_5ms[encoder->fs_idx - 4]; + encoder->W_size = LowDelayShapes_n960_len_7_5ms[encoder->fs_idx]; + encoder->bands_number = bands_number_7_5ms[encoder->fs_idx]; + encoder->bands_offset = bands_offset_7_5ms_HR[encoder->fs_idx - 4]; + } + else +# endif + { + encoder->yLen = s_min((MAX_BW >> 2) * 3, encoder->frame_length); + encoder->W_fx = LowDelayShapes_n960_7_5ms[encoder->fs_idx]; + encoder->W_size = LowDelayShapes_n960_len_7_5ms[encoder->fs_idx]; + encoder->bands_number = bands_number_7_5ms[encoder->fs_idx]; + encoder->bands_offset = bands_offset_7_5ms[encoder->fs_idx]; + } + BREAK; +# endif + + case 100: + encoder->la_zeroes = LowDelayShapes_n960_la_zeroes[encoder->fs_idx]; + encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); + encoder->bands_number = 64; + encoder->nSubdivisions = 3; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; + encoder->attdec_nblocks = 4; + encoder->attdec_damping = 16384; + encoder->attdec_hangover_thresh = 2; + encoder->near_nyquist_index = encoder->bands_number - 2; + encoder->near_nyquist_flag = 0; + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + encoder->bands_offset = bands_offset_HR[encoder->fs_idx - 4]; + encoder->W_fx = LowDelayShapes_n960_HRA[encoder->fs_idx - 4]; + encoder->W_size = LowDelayShapes_n960_len[encoder->fs_idx]; + encoder->yLen = encoder->frame_length; + } + else +# endif + { + encoder->yLen = s_min(MAX_BW, encoder->frame_length); + encoder->W_fx = LowDelayShapes_n960[encoder->fs_idx]; + encoder->W_size = LowDelayShapes_n960_len[encoder->fs_idx]; + encoder->bands_offset = bands_offset[encoder->fs_idx]; + } + BREAK; + } +} + +/* change encoder bitrate */ +LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) +{ + int ch = 0; + int totalBytes = 0, maxBR = 0, minBR = 0, max_bytes = 0; + int channel_bytes = 0; + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + switch (encoder->frame_dms) + { + case 25: + maxBR = 672000; + if (encoder->fs == 48000) + { + minBR = MIN_BR_25MS_48KHZ_HR; + } + else if (encoder->fs == 96000) + { + minBR = MIN_BR_25MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; + case 50: + maxBR = 600000; + if (encoder->fs == 48000) + { + minBR = MIN_BR_50MS_48KHZ_HR; + } + else if (encoder->fs == 96000) + { + minBR = MIN_BR_50MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; +# ifdef CR8_G_ADD_75MS + case 75: + maxBR = 500000; + if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;} + else {return LC3PLUS_HRMODE_ERROR;} + BREAK; +# endif + case 100: + maxBR = 500000; + if (encoder->fs == 48000) + { + minBR = MIN_BR_100MS_48KHZ_HR; + } + else if (encoder->fs == 96000) + { + minBR = MIN_BR_100MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; + default: return LC3PLUS_HRMODE_ERROR; + } + } + else + { + minBR = (MIN_NBYTES << 3); + maxBR = MAX_BR; + + switch (encoder->frame_dms) + { + case 25: + minBR = MIN_BR_025DMS; + maxBR = MAX_BR; + BREAK; + case 50: + minBR = MIN_BR_050DMS; + maxBR = MAX_BR; + /* have additional limitations for 5.0ms */ + SWITCH (encoder->fs_in) + { +# ifdef SUBSET_NB + case 8000: maxBR = MAX_BR_050DMS_NB; BREAK; +# endif + default: BREAK; + } + BREAK; +# ifdef CR8_G_ADD_75MS + case 75: + minBR = MIN_BR_075DMS; + maxBR = MAX_BR_075DMS; // special value for maxBR @ 7.5ms + /* have additional limitations for 7.5ms */ + SWITCH (encoder->fs_in) + { +# ifdef SUBSET_NB + case 8000: maxBR = MAX_BR_075DMS_NB ; BREAK; +# endif +# ifdef SUBSET_WB + case 16000: maxBR = MAX_BR_075DMS_WB ; BREAK; +# endif +# ifdef SUBSET_SSWB + case 24000: maxBR = MAX_BR_075DMS_SSWB; BREAK; +# endif + default: BREAK; + } + BREAK; +# endif + case 100: + /* have additional limitations for 10ms */ + minBR = MIN_BR_100DMS; + maxBR = MAX_BR; + SWITCH (encoder->fs_in) + { +# ifdef SUBSET_NB + case 8000: maxBR = MAX_BR_100DMS_NB ; BREAK; +# endif +# ifdef SUBSET_WB + case 16000: maxBR = MAX_BR_100DMS_WB ; BREAK; +# endif +# ifdef SUBSET_SSWB + case 24000: maxBR = MAX_BR_100DMS_SSWB; BREAK; +# endif + default: maxBR = MAX_BR; BREAK; + } + BREAK; + default: return LC3PLUS_FRAMEMS_ERROR; + } + + /* 441/480 in Q31 and 1000/75 in Q23 */ + if (encoder->fs_in == 44100) + { + minBR = Mpy_32_32_lc3plus(minBR, 1973000602); + maxBR = Mpy_32_32_lc3plus(maxBR, 1973000602); + } + } +#else /* ENABLE_HR_MODE */ + minBR = (MIN_NBYTES << 3); + maxBR = MAX_BR; + + switch (encoder->frame_dms) + { + case 25: + minBR = MIN_BR_025DMS; + maxBR = MAX_BR; + BREAK; + case 50: + minBR = MIN_BR_050DMS; + maxBR = MAX_BR; + /* have additional limitations for 5.0ms */ + SWITCH (encoder->fs_in) + { +# ifdef SUBSET_NB + case 8000: maxBR = MAX_BR_050DMS_NB; BREAK; +# endif + default: BREAK; + } + BREAK; +# ifdef CR8_G_ADD_75MS + case 75: + minBR = MIN_BR_075DMS; + maxBR = MAX_BR_075DMS; // special value for maxBR @ 7.5ms + /* have additional limitations for 7.5ms */ + SWITCH (encoder->fs_in) + { +# ifdef SUBSET_NB + case 8000: maxBR = MAX_BR_075DMS_NB ; BREAK; +# endif +# ifdef SUBSET_WB + case 16000: maxBR = MAX_BR_075DMS_WB ; BREAK; +# endif +# ifdef SUBSET_SSWB + case 24000: maxBR = MAX_BR_075DMS_SSWB; BREAK; +# endif + default: BREAK; + } + BREAK; +# endif + case 100: + /* have additional limitations for 10ms */ + minBR = MIN_BR_100DMS; + maxBR = MAX_BR; + SWITCH (encoder->fs_in) + { +# ifdef SUBSET_NB + case 8000: maxBR = MAX_BR_100DMS_NB ; BREAK; +# endif +# ifdef SUBSET_WB + case 16000: maxBR = MAX_BR_100DMS_WB ; BREAK; +# endif +# ifdef SUBSET_SSWB + case 24000: maxBR = MAX_BR_100DMS_SSWB; BREAK; +# endif + default: maxBR = MAX_BR; BREAK; + } + BREAK; + default: return LC3PLUS_FRAMEMS_ERROR; + } + + /* 441/480 in Q31 and 1000/75 in Q23 */ + if (encoder->fs_in == 44100) + { + minBR = Mpy_32_32_lc3plus(minBR, 1973000602); + maxBR = Mpy_32_32_lc3plus(maxBR, 1973000602); + } +#endif /* ENABLE_HR_MODE */ + + minBR *= encoder->channels; + maxBR *= encoder->channels; + + if (bitrate < minBR || bitrate > maxBR) + { + return LC3PLUS_BITRATE_ERROR; + } + + encoder->bitrate = bitrate; + encoder->lc3_br_set = 1; + + /* move stuff to encoder->channel_setup */ + + encoder->combined_channel_coding = 0; + if (encoder->channels > 1 && encoder->epmode) + { + if (encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in) <= 160) + { + encoder->combined_channel_coding = 1; + } + } + + if (encoder->epmode > 0) + { + max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); + + if (max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX) + { + return LC3PLUS_BITRATE_ERROR; + } + } + + if (encoder->combined_channel_coding) + { + totalBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, + bitrate * (Word32)encoder->frame_length / (8 * encoder->fs_in)); + + encoder->channel_setup[0]->n_pccw = + fec_get_n_pccw(bitrate * (Word32)encoder->frame_length / (8 * encoder->fs_in), encoder->epmode, + encoder->combined_channel_coding); + + encoder->channel_setup[0]->n_pc = fec_get_n_pc(encoder->epmode, encoder->channel_setup[0]->n_pccw, + bitrate * (Word32)encoder->frame_length / (8 * encoder->fs_in)); + } + else + { + totalBytes = bitrate * (Word32)encoder->frame_length / (8 * encoder->fs_in); + } + + for (ch = 0; ch < encoder->channels; ch++) + { + EncSetup *setup = encoder->channel_setup[ch]; + channel_bytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + + if (encoder->combined_channel_coding) + { + setup->targetBytes = channel_bytes; + } + else + { + setup->targetBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, channel_bytes); + setup->n_pccw = fec_get_n_pccw(channel_bytes, encoder->epmode, encoder->combined_channel_coding); + setup->n_pc = fec_get_n_pc(encoder->epmode, setup->n_pccw, channel_bytes); + } + /* reduce bandwith to 12kHz if bitrate is low */ + if (sub(encoder->frame_dms, 100) == 0 && + ((sub(setup->targetBytes, 40) < 0 && L_sub(encoder->fs, 48000) == 0) || + (sub(setup->targetBytes, 36) < 0 && L_sub(encoder->fs, 32000) == 0))) + { + encoder->bandwidth = L_min(12000, encoder->bandwidth_preset); + } + else + { + /* channel with highest index has lowest bitrate. + For a second channel with lower targetBytes, bandwidth is overwritten */ + encoder->bandwidth = encoder->bandwidth_preset; + } + + { + Word16 tmp; + + SWITCH(encoder->frame_dms) + { + case 25: tmp = 1; BREAK; + case 50: tmp = 2; BREAK; + case 75: tmp = 3; BREAK; + default : tmp = 4; BREAK; + } + + encoder->bw_ctrl_cutoff_bin = L_mult0(Mpy_32_32_lc3plus(encoder->bandwidth, 10737419), tmp); /* bandwidth * frame_dms / 5000 */ + } + + encoder->bw_index = sub( Mpy_32_32_lc3plus(encoder->bandwidth, 536871), 1); /* (bandwidth / 4000 ) - 1 */ + switch (encoder->frame_dms) + { + case 25: max_bytes = MAX_NBYTES_025; break; + case 50: max_bytes = MAX_NBYTES_050; break; +#ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS + case 75: max_bytes = MAX_NBYTES_075; BREAK; +# endif +#endif + case 100: max_bytes = MAX_NBYTES_100; break; + } +#ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + max_bytes = MAX_NBYTES_RED_HR; + } +#endif + if (setup->targetBytes < MIN_NBYTES || setup->targetBytes > max_bytes) + { + return LC3PLUS_BITRATE_ERROR; + } + + setup->total_bits = shl(setup->targetBytes, 3); + setup->targetBitsInit = + sub(setup->total_bits, + add(encoder->envelope_bits, + add(encoder->global_gain_bits, add(encoder->noise_fac_bits, encoder->BW_cutoff_bits)))); + setup->targetBitsInit = sub(setup->targetBitsInit, sub(17, norm_s(sub(encoder->yLen, 1)))); + if (setup->total_bits > 1280) + { + setup->targetBitsInit = sub(setup->targetBitsInit, 1); + } + if (setup->total_bits > 2560) + { + setup->targetBitsInit = sub(setup->targetBitsInit, 1); + } + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + setup->targetBitsInit -= 1; + } +# endif + + setup->targetBitsAri = setup->total_bits; + + SWITCH (encoder->frame_dms) + { + case 25: + /* 9830 = 2.4 * 2^12 */ + setup->ltpf_enable = + sub(extract_l(L_shr(L_mult0(9830, setup->total_bits), 12)), add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = 0; + BREAK; + case 50: + setup->ltpf_enable = sub(sub(DEPR_i_mult(setup->total_bits, 2), 160), add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = setup->total_bits < 240; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + setup->ltpf_enable = sub(L_shr(L_mult0(10923, setup->total_bits), 13), add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = setup->total_bits < 360; + BREAK; +# endif + case 100: + setup->enable_lpc_weighting = setup->total_bits < 480; + setup->ltpf_enable = sub(setup->total_bits, add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; + BREAK; + } + + setup->quantizedGainOff = + -(s_min(115, setup->total_bits / (10 * (encoder->fs_idx + 1))) + 105 + 5 * (encoder->fs_idx + 1)); + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode && encoder->fs_idx == 5) + { + setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); + } +# endif + +# ifdef ENABLE_HR_MODE + if (encoder->frame_dms == 100 && + ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || + (encoder->fs_in == 32000 && setup->targetBytes >= 81)) + && setup->targetBytes < 340 + && (encoder->hrmode == 0)) +# else + if (encoder->frame_dms == 100 && + ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || + (encoder->fs_in == 32000 && setup->targetBytes >= 81)) + && setup->targetBytes < 340 + ) +# endif + { + setup->attack_handling = 1; + } + else if (encoder->frame_dms == 75 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 75) || + (encoder->fs_in == 32000 && setup->targetBytes >= 61)) && setup->targetBytes < 150 +# ifdef ENABLE_HR_MODE + && encoder->hrmode == 0 +# endif + ) + { + setup->attack_handling = 1; + } + else + { + /* reset attack detector for bitrate switching */ + setup->attack_handling = 0; + setup->attdec_filter_mem[0] = 0; + setup->attdec_filter_mem[1] = 0; + setup->attdec_detected = 0; + setup->attdec_position = 0; + setup->attdec_acc_energy = 0; + setup->attdec_scaling = 0; + } + +# ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + setup->ltpf_enable = 0; + } +# endif + encoder->sns_damping = SNS_DAMPING; + +# ifdef ENABLE_HR_MODE + IF (encoder->hrmode) + { + encoder->sns_damping = SNS_DAMPING_HRMODE; + IF (encoder->fs_idx >= 4) + { + IF ((encoder->frame_dms == 100) & (setup->total_bits > 4400)) + { + encoder->sns_damping = SNS_DAMPING_HRMODE_UB_10MS; + } +#ifdef CR8_G_ADD_75MS + IF ((encoder->frame_dms == 75) & (setup->total_bits > 3300)) + { + encoder->sns_damping = SNS_DAMPING_HRMODE_UB_7_5MS; + } +#endif + IF ((encoder->frame_dms == 50) & (setup->total_bits > 2300)) + { + encoder->sns_damping = SNS_DAMPING_HRMODE_UB_5MS; + } + IF ((encoder->frame_dms == 25) & (setup->total_bits > 1150)) + { + encoder->sns_damping = SNS_DAMPING_HRMODE_UB_2_5MS; + } + } + } + + if (encoder->hrmode && encoder->fs_idx >= 4) + { + int real_rate = setup->targetBytes * 8 * 10000 / encoder->frame_dms; + setup->regBits = real_rate / 12500; + + if (encoder->fs_idx == 5) + { + if (encoder->frame_dms == 100) + { + setup->regBits += 2; + } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_dms == 75) + { + setup->regBits +=1; + } +#endif + if (encoder->frame_dms == 25) + { + setup->regBits -= 6; + } + } + else + { + if (encoder->frame_dms == 25) + { + setup->regBits -= 6; + } + else if (encoder->frame_dms == 50) + { + setup->regBits += 0; + } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_dms == 75) + { + setup->regBits +=2; + } +#endif + if (encoder->frame_dms == 100) + { + setup->regBits += 5; + } + } + + + if (setup->regBits < 6) + { + setup->regBits = 6; + } + if (setup->regBits > 23) + { + setup->regBits = 23; + } + } + else + { + setup->regBits = -1; + } +# endif + } + + encoder->bitrate = bitrate; + + return LC3PLUS_OK; +} + diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h new file mode 100644 index 000000000..5e89829da --- /dev/null +++ b/lib_lc3plus/setup_enc_lc3.h @@ -0,0 +1,131 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef SETUP_ENC_LC3_H +#define SETUP_ENC_LC3_H + +#include "constants.h" + +/* Channel state and bitrate-derived values go in this struct */ +typedef struct +{ +#ifdef ENABLE_HR_MODE + Word32 *stEnc_mdct_mem; /* MDCT_MEM_LEN_MAX */ +#else + Word16 *stEnc_mdct_mem; /* MDCT_MEM_LEN_MAX */ +#endif + Word32 *mdct_mem32; /* MDCT_MEM_LEN_MAX */ + Word32 targetBitsOff; + Word16 targetBytes; + Word16 total_bits; + Word16 targetBitsInit; + Word16 targetBitsAri; + Word16 enable_lpc_weighting; + Word16 ltpf_enable; + Word16 quantizedGainOff; + Word16 tns_bits; + Word16 targetBitsQuant; + Word16 olpa_mem_s6k4_exp; + Word16 olpa_mem_pitch; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + Word16 pitch_flag; +#endif + Word16 ltpf_mem_in_exp; + Word16 ltpf_mem_normcorr; + Word16 ltpf_mem_mem_normcorr; + Word16 ltpf_mem_ltpf_on; + Word16 ltpf_mem_pitch; + Word16 mem_targetBits; + Word16 mem_specBits; + Word16 x_exp; + Word16 resamp_exp; + Word16 attack_handling; /* flag to enable attack handling */ + Word16 attdec_filter_mem[2]; + Word16 attdec_detected; + Word16 attdec_position; + Word32 attdec_acc_energy; + Word16 attdec_scaling; +#ifdef ENABLE_HR_MODE + Word16 regBits; + Word32 resamp_mem32[120] ALIGN_BUFFER_STRUCT; +#else + Word32 resamp_mem32[60] ALIGN_BUFFER_STRUCT; +#endif +#ifdef ENABLE_HR_MODE + Word16 r12k8_mem_in[120] ALIGN_BUFFER_STRUCT; +#else + Word16 r12k8_mem_in[60] ALIGN_BUFFER_STRUCT; +#endif + Word32 r12k8_mem_50[2] ALIGN_BUFFER_STRUCT; +#ifdef CR8_G_ADD_75MS + Word16 r12k8_mem_out[44] ALIGN_BUFFER_STRUCT; +#else + Word16 r12k8_mem_out[24] ALIGN_BUFFER_STRUCT; +#endif + Word16 olpa_mem_s12k8[3] ALIGN_BUFFER_STRUCT; + Word16 olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16] ALIGN_BUFFER_STRUCT; + Word16 ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1] ALIGN_BUFFER_STRUCT; + Word16 n_pccw; + Word16 n_pc; + + Word16 lfe; +} EncSetup; + +/* Constants and sampling rate derived values go in this struct */ +struct LC3PLUS_Enc +{ + EncSetup *channel_setup[MAX_CHANNELS]; +#ifdef ENABLE_HR_MODE + const Word32 *W_fx; +#else + const Word16 *W_fx; +#endif + const Word16 *bands_offset; + + Word32 fs; /* encoder sampling rate 44.1 -> 48 */ + Word32 fs_in; /* input sampling rate */ + Word32 bitrate; /* global bitrate */ + Word16 fs_idx; /* sampling rate index */ + Word16 frame_length; /* audio samples / frame */ + Word16 channels; /* number of channels */ + Word16 epmode; /* error protection mode */ + Word16 frame_dms; /* frame length in dms (decimilliseconds, 10^-4)*/ + Word8 lc3_br_set; /* indicate if bitrate has been set */ + + Word16 yLen; + Word16 W_size; + Word16 la_zeroes; + Word16 stEnc_mdct_mem_len; + Word16 bands_number; + Word16 nSubdivisions; + Word16 ltpf_mem_in_len; + Word16 envelope_bits; + Word16 global_gain_bits; + Word16 noise_fac_bits; + Word16 BW_cutoff_bits; + Word16 r12k8_mem_in_len; + Word16 r12k8_mem_out_len; + Word16 near_nyquist_index; + Word16 near_nyquist_flag; + + Word16 epmr; + Word16 combined_channel_coding; + Word32 bandwidth; + Word32 bandwidth_preset; + Word32 bw_ctrl_active; + Word16 bw_ctrl_cutoff_bin; + Word16 bw_index; + Word16 attdec_nblocks; + Word16 attdec_damping; + Word16 attdec_hangover_thresh; + Word16 hrmode; + Word16 sns_damping; +}; + +#endif diff --git a/lib_lc3plus/sns_compute_scf_fx.c b/lib_lc3plus/sns_compute_scf_fx.c new file mode 100644 index 000000000..d56a1a7f8 --- /dev/null +++ b/lib_lc3plus/sns_compute_scf_fx.c @@ -0,0 +1,166 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 *scf, + Word16 scf_smoothing_enabled, Word16 attdec_damping_factor, Word8 *scratchBuffer, Word16 sns_damping + ) +{ + Dyn_Mem_Deluxe_In( + Word16 i, s, s2, nf, tmp; + Word32 L_mean, L_tmp; + Word32 *d3_fx; + Word16 *d3_fx_exp; + Word16 *d4_fx; + Word16 *scf_smooth; + ); + + UNUSED(attdec_damping_factor); + + d3_fx = scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_BANDS_NUMBER = 256 bytes */ + d3_fx_exp = scratchAlign(d3_fx, sizeof(*d3_fx) * MAX_BANDS_NUMBER); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ + d4_fx = scratchAlign(d3_fx_exp, sizeof(*d3_fx_exp) * MAX_BANDS_NUMBER); /* Size = 2 * MAX_BANDS_NUMBER = 128bytes */ + scf_smooth = scratchAlign(d4_fx, sizeof(*d4_fx) * MAX_BANDS_NUMBER); /* Size = 2 * 16 */ + +/* Smoothing and Pre-emphasis */ + IF (sub(n_bands, 32) < 0) + { + L_tmp = sub(32, n_bands); + FOR (i = sub(n_bands, 1); i >= L_tmp; i--) + { + d2_fx[(i + L_tmp) * 2 + 1] = d2_fx[i]; move32(); + d2_fx[(i + L_tmp) * 2 + 0] = d2_fx[i]; move32(); + } + FOR (i = sub(L_tmp, 1); i >= 0; i--) + { + d2_fx[i * 4 + 3] = d2_fx[i]; move32(); + d2_fx[i * 4 + 2] = d2_fx[i]; move32(); + d2_fx[i * 4 + 1] = d2_fx[i]; move32(); + d2_fx[i * 4 + 0] = d2_fx[i]; move32(); + } + n_bands = 64; move16(); + } + ELSE + IF (sub(n_bands, 64) < 0) + { + L_tmp = sub(64, n_bands); + FOR (i = sub(n_bands, 1); i >= L_tmp; i--) + { + d2_fx[i + L_tmp] = d2_fx[i]; move32(); + } + FOR (i = sub(L_tmp, 1); i >= 0; i--) + { + d2_fx[i * 2 + 1] = d2_fx[i]; move32(); + d2_fx[i * 2 + 0] = d2_fx[i]; move32(); + } + n_bands = 64; move16(); + } + + L_tmp = L_add(Mpy_32_16_lc3plus(d2_fx[0], 24576), L_shr_pos(d2_fx[1], 2)); + d3_fx[0] = Mpy_32_16_lc3plus(L_tmp, lpc_pre_emphasis[fs_idx][0]); move32(); + d3_fx_exp[0] = add(d2_fx_exp, lpc_pre_emphasis_e[fs_idx][0]); move16(); + FOR (i = 1; i < n_bands - 1; i++) + { + L_tmp = L_add(L_shr_pos(d2_fx[i], 1), L_add(L_shr_pos(d2_fx[i - 1], 2), L_shr_pos(d2_fx[i + 1], 2))); + d3_fx[i] = Mpy_32_16_lc3plus(L_tmp, lpc_pre_emphasis[fs_idx][i]); move32(); + d3_fx_exp[i] = add(d2_fx_exp, lpc_pre_emphasis_e[fs_idx][i]); move16(); + } + L_tmp = L_add(Mpy_32_16_lc3plus(d2_fx[n_bands - 1], 24576), L_shr_pos(d2_fx[n_bands - 2], 2)); + d3_fx[n_bands - 1] = Mpy_32_16_lc3plus(L_tmp, lpc_pre_emphasis[fs_idx][n_bands - 1]); move32(); + d3_fx_exp[n_bands - 1] = add(d2_fx_exp, lpc_pre_emphasis_e[fs_idx][n_bands - 1]); move16(); + + /* Mean */ + s = d3_fx_exp[MAX_BANDS_NUMBER - 1]; + s2 = add(s, 6); + + L_mean = L_shr(d3_fx[0], sub(s2, d3_fx_exp[0])); + FOR (i = 1; i < MAX_BANDS_NUMBER; i++) + { + L_mean = L_add(L_mean, L_shr(d3_fx[i], sub(s2, d3_fx_exp[i]))); + } + + /* Noise floor at -40dB */ + nf = BASOP_Util_Log2_16(L_mean, s); + nf = sub(s_max(nf, -25965), 6803); + +/* Log-domain */ + FOR (i = 0; i < MAX_BANDS_NUMBER; i++) + { + d4_fx[i] = s_max(nf, BASOP_Util_Log2_16(d3_fx[i], d3_fx_exp[i])); move16(); + } + + /* Downsampling */ + L_tmp = L_mult(d4_fx[0], 8192); + L_tmp = L_mac(L_tmp, d4_fx[1], 8192); + L_tmp = L_mac(L_tmp, d4_fx[2], 8192); + L_tmp = L_mac(L_tmp, d4_fx[3], 5461); + d3_fx[0] = L_mac(L_tmp, d4_fx[4], 2731); move32(); + FOR (i = 1; i < M - 1; i++) + { + L_tmp = L_mult(d4_fx[i * 4 - 1], 2731); + L_tmp = L_mac(L_tmp, d4_fx[i * 4 + 0], 5461); + L_tmp = L_mac(L_tmp, d4_fx[i * 4 + 1], 8192); + L_tmp = L_mac(L_tmp, d4_fx[i * 4 + 2], 8192); + L_tmp = L_mac(L_tmp, d4_fx[i * 4 + 3], 5461); + d3_fx[i] = L_mac(L_tmp, d4_fx[i * 4 + 4], 2731); move32(); + } + L_tmp = L_mult(d4_fx[59], 2731); + L_tmp = L_mac(L_tmp, d4_fx[60], 5461); + L_tmp = L_mac(L_tmp, d4_fx[61], 8192); + L_tmp = L_mac(L_tmp, d4_fx[62], 8192); + d3_fx[M - 1] = L_mac(L_tmp, d4_fx[63], 8192); move32(); + +/* Remove mean and scaling */ + L_mean = L_shr_pos(d3_fx[0], 4); + FOR (i = 1; i < M; i++) + { + L_mean = L_add(L_mean, L_shr_pos(d3_fx[i], 4)); + } + + FOR (i = 0; i < M; i++) + { + scf[i] = mult_r(sns_damping, round_fx(L_shl_pos(L_sub(d3_fx[i], L_mean), 1))); + move16(); + } + + /* scale factor smoothing */ + IF (scf_smoothing_enabled) + { + scf_smooth[0] = L_shr(L_mult0(L_add(L_add(scf[0], scf[1]), scf[2]), 10923), 15); + L_mean = scf_smooth[0]; move16(); + scf_smooth[1] = L_shr(L_add(L_add(L_add(scf[0], scf[1]), scf[2]), scf[3]), 2); + L_mean = L_add(L_mean, scf_smooth[1]); + FOR (i = 2; i < M - 2; i++) + { + L_tmp = L_add(L_add(L_add(L_add(scf[i - 2], scf[i - 1]), scf[i]), scf[i + 1]), scf[i + 2]); + tmp = norm_s(L_shr(L_abs(L_tmp), 15)); + if (tmp > 0) { + tmp = sub(16, tmp); + L_tmp = L_shr(L_tmp, tmp); + } + scf_smooth[i] = L_shr(L_mult0(L_tmp, 13107), sub(16, tmp)); + L_mean = L_add(L_mean, scf_smooth[i]); + } + scf_smooth[M - 2] = L_shr(L_add(L_add(L_add(scf[M - 4], scf[M - 3]), scf[M - 2]), scf[M - 1]), 2); + L_mean = L_add(L_mean, scf_smooth[M - 2]); + scf_smooth[M - 1] = L_shr(L_mult0(L_add(L_add(scf[M - 3], scf[M - 2]), scf[M - 1]), 10923), 15); + L_mean = L_add(L_mean, scf_smooth[M - 1]); + + L_mean = L_shr(L_mean, 4); + + FOR (i = 0; i < M; i++) + { + scf[i] = mult_r(attdec_damping_factor, sub(scf_smooth[i], L_mean)); + } + } + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/sns_interpolate_scf_fx.c b/lib_lc3plus/sns_interpolate_scf_fx.c new file mode 100644 index 000000000..e71825d07 --- /dev/null +++ b/lib_lc3plus/sns_interpolate_scf_fx.c @@ -0,0 +1,154 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +void processSnsInterpolateScf_fx( +#ifdef ENABLE_HR_MODE + Word32 *scf_q, Word32 mdct_scf[], +#else + Word16 *scf_q, Word16 mdct_scf[], +#endif + Word16 mdct_scf_exp[], Word16 inv_scf, + Word16 n_bands, Word8 *scratchBuffer) +{ +#ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In( + Word32 i, tmp2; + Word32 *scf_int; + Word32 tmp; + Word32 *scf_tmp; + ); +#else + Dyn_Mem_Deluxe_In( + Word16 i, tmp2; + Word16 *scf_int; + Word16 tmp; + Word16 *scf_tmp; + ); +#endif + +#ifdef ENABLE_HR_MODE + scf_int = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ + scf_tmp = (Word32 *)scratchAlign(scf_int, 4 * MAX_BANDS_NUMBER); /* 2 * MAX_BANDS_NUMBER = 128 bytes */ +#else + scf_int = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ + scf_tmp = (Word16 *)scratchAlign(scf_int, 2 * MAX_BANDS_NUMBER); /* 2 * MAX_BANDS_NUMBER = 128 bytes */ +#endif + + /* Interpolation */ + scf_int[0] = scf_q[0]; + scf_int[1] = scf_q[0]; + FOR (i = 1; i < M; i++) + { +#ifdef ENABLE_HR_MODE + tmp = L_sub(scf_q[i], scf_q[i - 1]); + tmp2 = L_shr(tmp, 2); + tmp = L_shr(tmp, 3); + scf_int[i * 4 - 2] = L_add(scf_q[i - 1], tmp); + scf_int[i * 4 - 1] = L_add(scf_int[i * 4 - 2], tmp2); + scf_int[i * 4] = L_add(scf_int[i * 4 - 1], tmp2); + scf_int[i * 4 + 1] = L_add(scf_int[i * 4], tmp2); +#else + tmp = sub(scf_q[i], scf_q[i - 1]); + tmp2 = mult_r(tmp, 8192); + tmp = mult_r(tmp, 4096); + scf_int[i * 4 - 2] = add(scf_q[i - 1], tmp); + scf_int[i * 4 - 1] = add(scf_int[i * 4 - 2], tmp2); + scf_int[i * 4] = add(scf_int[i * 4 - 1], tmp2); + scf_int[i * 4 + 1] = add(scf_int[i * 4], tmp2); +#endif + } +#ifdef ENABLE_HR_MODE + scf_int[62] = L_add(scf_int[61], tmp2); + scf_int[63] = L_add(scf_int[62], tmp2); +#else + scf_int[62] = add(scf_int[61], tmp2); + scf_int[63] = add(scf_int[62], tmp2); +#endif + + /* 8 kHz mode for 2.5 ms */ + IF (sub(n_bands, 32) < 0) + { +#ifdef ENABLE_HR_MODE + basop_memmove(scf_tmp, scf_int, 64 * sizeof(Word32)); +#else + basop_memmove(scf_tmp, scf_int, 64 * sizeof(Word16)); +#endif + tmp = sub(32, n_bands); + FOR (i = 0; i < tmp; i++) + { +#ifdef ENABLE_HR_MODE + scf_int[i] = L_add(L_shr(L_add(scf_tmp[4 * i], scf_tmp[4 * i + 1]), 2), + L_shr(L_add(scf_tmp[4 * i + 2], scf_tmp[4 * i + 3]), 2)); +#else + /* 8192 = 0.25 * 2^15 */ + scf_int[i] = add(mac_r(L_mult(scf_tmp[4 * i], 8192), scf_tmp[4 * i + 1], 8192), + mac_r(L_mult(scf_tmp[4 * i + 2], 8192), scf_tmp[4 * i + 3], 8192)); +#endif + } + + FOR (i = 0; i < n_bands - tmp; i++) + { +#ifdef ENABLE_HR_MODE + scf_int[tmp + i] = L_shr(L_add(scf_tmp[4 * tmp + 2 * i], scf_tmp[4 * tmp + 2 * i + 1]), 1); +#else + scf_int[tmp + i] = mac_r(L_mult(scf_tmp[4 * tmp + 2 * i], 16384), scf_tmp[4 * tmp + 2 * i + 1], 16384); +#endif + } + } + ELSE + /* For 5ms */ + IF (sub(n_bands, 64) < 0) + { + tmp = sub(64, n_bands); + FOR (i = 0; i < tmp; i++) + { +#ifdef ENABLE_HR_MODE + scf_int[i] = L_shr(L_add(scf_int[2 * i], scf_int[2 * i + 1]), 1); +#else + scf_int[i] = mac_r(L_mult(scf_int[2 * i], 16384), scf_int[2 * i + 1], 16384); +#endif + } + FOR (; i < n_bands; i++) + { + scf_int[i] = scf_int[tmp + i]; move16(); + } +#ifdef ENABLE_HR_MODE + move16(); // 32 bit operations have twice the complexity weight of 16 bit operations +#endif + } + + /* Inversion at encoder-side*/ + IF (inv_scf == 1) + { + FOR (i = 0; i < n_bands; i++) + { +#ifdef ENABLE_HR_MODE + scf_int[i] = L_negate(scf_int[i]); +#else + scf_int[i] = negate(scf_int[i]); +#endif + } + } + +/* Linear Domain */ + FOR (i = 0; i < n_bands; i++) + { +#ifdef ENABLE_HR_MODE + /* scf_int is in Q26, BASOP_Util_InvLog2_pos requires Q25 data */ + mdct_scf[i] = BASOP_Util_InvLog2_pos(L_shr(scf_int[i], 1), &mdct_scf_exp[i]); +#else + mdct_scf[i] = BASOP_Util_InvLog2_16(scf_int[i], &mdct_scf_exp[i]); +#endif + } + + Dyn_Mem_Deluxe_Out(); +} + diff --git a/lib_lc3plus/sns_quantize_scf_fx.c b/lib_lc3plus/sns_quantize_scf_fx.c new file mode 100644 index 000000000..991381285 --- /dev/null +++ b/lib_lc3plus/sns_quantize_scf_fx.c @@ -0,0 +1,834 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static Word16 stage1_base( /* o : idx */ + const Word16 *t, /* i : target SCFs */ +#ifdef ENABLE_HR_MODE + const Word32 *cdbk, /* i : SCFs cdbk */ +#else + const Word16 *cdbk, /* i : SCFs cdbk */ +#endif + const Word16 R /* i : number of rows in codebook */ +) +{ + Counter row; + Word16 k_ptr, idx; + Word32 L_min_mse, L_mse; + Counter col; +#ifdef ENABLE_HR_MODE + Word32 err; +#else + Word16 err; +#endif + +#ifdef DYNMEM_COUNT + Dyn_Mem_In("stage1_base", sizeof(struct { + Counter row, col; + Word16 k_ptr, idx, err; + Word32 L_min_mse, L_mse; + })); +#endif +#ifdef WMOPS + BASOP_sub_sub_start("stage1_base"); +#endif + +/* find first vector error energy for */ +/* loop probably works with saturation , but it should not occur anyway */ + L_min_mse = L_add(0, 0); /* init acc with absolute min mse sofar */ + FOR (col = 0; col < M / 2; col++) /* fixed to 8 elements */ + { +#ifdef ENABLE_HR_MODE + err = L_sub(cdbk[col], L_deposit_h(t[col])); /* cdbk max abs value is 2048 = 2.^11 , max nb col is 2^3 max + target is approx similar (2.^14/M)*2 = +/- 2048 , errmax is 4096 */ + L_min_mse = L_add(L_min_mse, Mpy_32_32_lc3plus(err, err)); +#else + err = sub(cdbk[col], t[col]); /* cdbk max abs value is 2048 = 2.^11 , max nb col is 2^3 max target is approx + similar (2.^14/M)*2 = +/- 2048 , errmax is 4096 */ + L_min_mse = L_mac0(L_min_mse, err, err); /* max L_min_mse is 8*4096*4096 =2.^(3+12+12) = 2.^27 */ +#endif + } + + idx = 0; move16(); + + k_ptr = M / 2; move16(); /* ptr init to second row */ + FOR (row = 1; row < R; row++) + { + /* loop probably works with saturation , but it should not occur anyway */ + + L_mse = L_add(L_min_mse, 0); /* init acc with min mse sofar , */ + FOR (col = 0; col < M / 2; col++) /* fixed to 8 elements */ + { +#ifdef ENABLE_HR_MODE + err = L_sub(cdbk[k_ptr++], L_deposit_h(t[col])); + L_mse = L_sub(L_mse, Mpy_32_32_lc3plus(err, err)); +#else + err = sub(cdbk[k_ptr++], t[col]); + L_mse = L_msu0(L_mse, err, + err); /* NB subtraction from best MSE error sofar in acc , saturation may not occur */ +#endif + } + + L_min_mse = L_sub(L_min_mse, L_max(L_mse, 0L)); /* ALWAYS update best MSE error sofar */ + + if (L_mse > 0L) /* if acc value still is positive a new lower error energy vector was found in this row */ + { + idx = row; move16(); /* update 1-8 bits idx */ + } + + /* this inner loop(always updating L_min_mse), (L_msu, if ) consumes AV 19, WC ~20 STL cycles , + compared to a conventional(L_mac, IF( ) ) AV 21 WC ~23 STL cycles per + loop */ + } + ASSERT(idx >= 0 && idx < R); + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + + return idx; +} + +static void first_stage_split_search( +#ifdef ENABLE_HR_MODE + const Word32 *cbk_LF, const Word32 *cbk_HF, +#else + const Word16 *cbk_LF, const Word16 *cbk_HF, +#endif + const Word16 *target, + const Word16 nbCbkEntries, Word16 *idxLF, Word16 *idxHF) +{ + /* find base index for each SCF split */ + *idxLF = stage1_base(target, cbk_LF, nbCbkEntries); + *idxHF = stage1_base((&target[M / 2]), cbk_HF, nbCbkEntries); +} + +static void processDeQuantize_stage1ScfDecStage1_fx( +#ifdef ENABLE_HR_MODE + const Word32 *cbk_LF, const Word32 *cbk_HF, +#else + const Word16 *cbk_LF, const Word16 *cbk_HF, +#endif + Word16 st1_idx0, Word16 st1_idx1, +#ifdef ENABLE_HR_MODE + Word32 *st1_vector +#else + Word16 *st1_vector +#endif + ) +{ + Counter col; + Word16 offset0, offset1; +#ifdef DYNMEM_COUNT + Dyn_Mem_In("processDeQuantize_stage1ScfDecStage1_fx", sizeof(struct { + Word16 offset0, offset1; + Counter col; + })); +#endif + + offset0 = shl_pos(st1_idx0, 3); /* mult by M/2 */ + offset1 = shl_pos(st1_idx1, 3); + FOR (col = 0; col < M / 2; col++) + { + st1_vector[col] = cbk_LF[offset0++]; move16(); + st1_vector[col + 8] = cbk_HF[offset1++]; move16(); +#ifdef ENABLE_HR_MODE + move16(); + move16(); +#endif + } +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif +} + +void downshift_w32_arr(Word32 *w32_arr, Word16 *w16_arr, Word16 shft_val, Word32 len) +{ + Word32 i; + FOR (i = 0; i < len; i++) + { + w16_arr[i] = extract_l(L_shr_pos(w32_arr[i], shft_val)); + move16(); + } + return; +} + +void round_w32tow16_arr(Word32 *w32_arr, Word16 *w16_arr,Word32 len) +{ + Word32 i; + FOR (i = 0; i < len; i++) + { + w16_arr[i] = round_fx(w32_arr[i]); + move16(); + } + return; +} + +static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, +#ifdef ENABLE_HR_MODE + Word32 *st1_vector, +#else + Word16 *st1_vector, +#endif + Word16 *st1_idx0Ptr, Word16 *st1_idx1Ptr) + +{ +#ifdef WMOPS + BASOP_sub_sub_start("processQuantize_stage1ScfEncStage1_fx"); +#endif + +#ifdef ENABLE_HR_MODE + first_stage_split_search(st1SCF0_7_base5_32x8_Q27, st1SCF8_15_base5_32x8_Q27, target_st1, SCF_STAGE1_NBCDKENTRIES, + st1_idx0Ptr, st1_idx1Ptr); + + processDeQuantize_stage1ScfDecStage1_fx(st1SCF0_7_base5_32x8_Q27, st1SCF8_15_base5_32x8_Q27, *st1_idx0Ptr, + *st1_idx1Ptr, st1_vector); +#else + first_stage_split_search(st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, target_st1, SCF_STAGE1_NBCDKENTRIES, + st1_idx0Ptr, st1_idx1Ptr); + + processDeQuantize_stage1ScfDecStage1_fx(st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, *st1_idx0Ptr, + *st1_idx1Ptr, st1_vector); +#endif + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + + return; +} + +/* gain-shape MSE search in warped SCF-residual domain, synthesis in SCF resiudal domain allows for easy weighting */ + +static void pvq_enc_find_best_submode_pre_post_fx( +#ifdef ENABLE_HR_MODE + const Word32 *target_st2, /* this target is in the linearized warped domain , same as input to PVQ search */ +#else + const Word16 *target_st2, /* this target is in the linearized warped domain , same as input to PVQ search */ +#endif + const Word16 *enc_pulses_far, Word16 *enc_pulses_near, const Word16 *enc_pulsesA, const Word16 *enc_pulsesB, + Word16 *sub_mode_ptr, Word16 *i_gain_ptr, +#ifdef ENABLE_HR_MODE + Word32 *enc_adj_glob_warped_vec, +#else + Word16 *enc_adj_glob_warped_vec, +#endif + Word8 *scratchBuffer) /* Size = 18 * M */ +{ + + Counter L_section, idx; +#ifdef ENABLE_HR_MODE + const Word32 *search_en1shape[N_SCF_SHAPES_ST2]; +#else + const Word16 *search_en1shape[N_SCF_SHAPES_ST2]; +#endif + const Word16 *search_gainTab[N_SCF_SHAPES_ST2]; + Word16 search_n_gains[N_SCF_SHAPES_ST2]; + Word32 L_mse, L_mse_min, L_idx; + Word16 * pulses_far, *pulses_near, *pulsesAB, *pulsesA; +#ifdef ENABLE_HR_MODE + Word32 * target_w, *shape_far, *shape_near, *shapeAB, *shapeA; +#else + Word16 * target_w, *shape_far, *shape_near, *shapeAB, *shapeA; +#endif +#ifdef ENABLE_HR_MODE + Word32 tmp, err; +#else + Word16 tmp, err; +#endif + Counter i; + +#ifdef DYNMEM_COUNT +#ifdef ENABLE_HR_MODE + Dyn_Mem_In("pvq_enc_find_best_submode_pre_post_fx", sizeof(struct { + Counter i, L_section, idx; + Word32 *search_en1shape[N_SCF_SHAPES_ST2]; + Word16 *search_gainTab[N_SCF_SHAPES_ST2]; + Word16 search_n_gains[N_SCF_SHAPES_ST2]; + Word32 L_mse, L_mse_min, L_idx; + Word16 *pulses_far, *pulses_near, *pulsesAB, *pulsesA; + Word32 *target_w, *shape_far, *shape_near, *shapeAB, *shapeA; + Word32 tmp, err; + })); +#else + Dyn_Mem_In("pvq_enc_find_best_submode_pre_post_fx", sizeof(struct { + Counter i, L_section, idx; + Word16 *search_en1shape[N_SCF_SHAPES_ST2]; + Word16 *search_gainTab[N_SCF_SHAPES_ST2]; + Word16 search_n_gains[N_SCF_SHAPES_ST2]; + Word32 L_mse, L_mse_min, L_idx; + Word16 *pulses_far, *pulses_near, *pulsesAB, *pulsesA; + Word16 *target_w, *shape_far, *shape_near, *shapeAB, *shapeA; + Word16 tmp, err; + })); +#endif /* ENABLE_HR_MODE */ +#endif /* DYNMEM_COUNT */ + + pulses_near = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * M */ + + pulsesAB = (Word16 *)scratchAlign(pulses_near, sizeof(*pulses_near) * M); /* Size = 2 * M */ + + pulsesA = (Word16 *)scratchAlign(pulsesAB, sizeof(*pulsesAB) * M); /* Size = 2 * M */ + +#ifdef ENABLE_HR_MODE + target_w = (Word32 *)scratchAlign(pulsesA, sizeof(*pulsesA) * M); /* Size = 2 * M */ + + shape_near = (Word32 *)scratchAlign(target_w, sizeof(*target_w) * M); /* Size = 4 * M */ + + shapeAB = (Word32 *)scratchAlign(shape_near, sizeof(*shape_near) * M); /* Size = 4 * M */ + + shapeA = (Word32 *)scratchAlign(shapeAB, sizeof(*shapeAB) * M); /* Size = 4 * M */ +#else + target_w = (Word16 *)scratchAlign(pulsesA, sizeof(*pulsesA) * M); /* Size = 2 * M */ + + shape_near = (Word16 *)scratchAlign(target_w, sizeof(*target_w) * M); /* Size = 2 * M */ + + shapeAB = (Word16 *)scratchAlign(shape_near, sizeof(*shape_near) * M); /* Size = 2 * M */ + + shapeA = (Word16 *)scratchAlign(shapeAB, sizeof(*shapeAB) * M); /* Size = 2 * M */ +#endif + + pulses_far = (Word16 *)scratchAlign(shapeA, sizeof(*shapeA) * M); /* Size = 2 * M */ + +#ifdef ENABLE_HR_MODE + shape_far = (Word32 *)scratchAlign(pulses_far, sizeof(*pulses_far) * M); /* Size = 2 * M */ +#else + shape_far = (Word16 *)scratchAlign(pulses_far, sizeof(*pulses_far) * M); /* Size = 2 * M */ +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("pvq_enc_find_best_submode_pre_post_fx"); +#endif + + /* construct pulse vectors and en1 normalized shape vectors */ /* use shape Q in Q14 */ + basop_memmove(pulses_far, enc_pulses_far, M * sizeof(*pulses_far)); + basop_memmove(pulses_near, enc_pulses_near, M * sizeof(*pulses_near)); + basop_memmove(target_w, target_st2, M * sizeof(*target_w)); + + pvq_dec_en1_normQ14_fx(shape_near, pulses_near, sns_Kval[2][0], M); /* near outlier mode */ + pvq_dec_en1_normQ14_fx(shape_far, pulses_far, sns_Kval[3][0], M); /* far outlier mode */ + + /* regular mode(with a split), prepare vectors of full length M */ + basop_memmove(pulsesAB, enc_pulsesA, N_SETA * sizeof(*pulsesAB)); + basop_memmove(pulsesA, enc_pulsesA, N_SETA * sizeof(*pulsesA)); + + FOR (i = N_SETA; i < M; i++) + { + pulsesAB[i] = enc_pulsesB[sub(i, N_SETA)]; move16(); + } + + IF (M > N_SETA) + { + basop_memset(&pulsesA[N_SETA], 0, (M - N_SETA) * sizeof(*pulsesA)); + } + + pvq_dec_en1_normQ14_fx(shapeAB, pulsesAB, sns_Kval[0][0], M); + /* regular AB , b_pulses = 1 ;*/ /* OPT: combine with shapeA */ + + pvq_dec_en1_normQ14_fx(shapeA, pulsesA, sns_Kval[1][0], M); + /* regular A , b_pulses = 0 */ /* OPT: M-> N_SETA */ + + /* setup search structure */ + + /* now aligned with order of j {regular=0, regular_lf=1, outlier_near=2, outlier far=3} */ + + search_en1shape[0] = shapeAB; + search_gainTab[0] = sns_gaintabPtr[0]; + search_n_gains[0] = sns_gainSz[0]; /* assumes whole bits */ + + search_en1shape[1] = shapeA; + search_gainTab[1] = sns_gaintabPtr[1]; + search_n_gains[1] = sns_gainSz[1]; /* assumes whole bits */ + + search_en1shape[2] = shape_near; + search_gainTab[2] = sns_gaintabPtr[2]; + search_n_gains[2] = sns_gainSz[2]; /*assume whole bits */ + + search_en1shape[3] = shape_far; + search_gainTab[3] = sns_gaintabPtr[3]; + search_n_gains[3] = sns_gainSz[3]; /*assume whole bits */ + + /* start actual search loop */ + + /* basic raw MSE loop, */ + L_mse_min = INT32_MAX; move32(); + L_idx = L_deposit_l(-1); /* section in low 2 bits* gain idx above */ + + FOR (L_section = 0; L_section < N_SCF_SHAPES_ST2; L_section++) + { + /* raw MSE over gain and shape */ + FOR (idx = 0; idx < search_n_gains[L_section]; idx++) + { + /* MSE ( proc_target_local[i]-adjGain[i]*en1Shape[i] ) */ + + L_mse = L_deposit_l(0); + FOR (i = 0; i < M; i++) + { +#ifdef ENABLE_HR_MODE + tmp = Mpy_32_16_lc3plus(search_en1shape[L_section][i], search_gainTab[L_section][idx]); /* Q30 + 14 - 15 = Q29 */ + err = L_sub(target_w[i], tmp); /* both in Q29 */ + L_mse = L_add(L_mse, L_shr_pos(Mpy_32_32_lc3plus(err, err), 1)); /* Q29+29-31 = Q27 */ +#else + tmp = mult_r(search_gainTab[L_section][idx], search_en1shape[L_section][i]); /* Q15+14+1-16= Q14 */ + err = sub(target_w[i], tmp); /* both in Q14 */ + L_mse = L_mac0(L_mse, err, err); /* Q14+14 = Q28 */ +#endif /* Q14+14 = Q28 */ + } + + IF (L_sub(L_mse, L_mse_min) < 0) /* OPT: always update L_mse_min) */ + { + L_mse_min = L_mse; move32(); + L_idx = L_mac0(L_section, idx, 1 << 2); /* save both section and gain idx */ + } + } /* gains */ + } /*submodes*/ + + L_section = L_and(0x3L, L_idx); /* section was stored in two lowest bits */ + ASSERT(L_section >= 0 && L_section <= 3); + *i_gain_ptr = extract_l(L_shr_pos(L_idx, 2)); /*1,2,3 bit gain */ + ASSERT(*i_gain_ptr >= 0 && *i_gain_ptr <= 7); + + /* returns a scaled and transformed vector, ___EXACTLY__ as a decoder would scale it */ + ASSERT(enc_adj_glob_warped_vec != NULL); + { + /* warp/rotate search result to SCF residual domain */ +#ifdef ENABLE_HR_MODE + idct32_32_fx(search_en1shape[L_section], target_w); +#else + idct16_fx(search_en1shape[L_section], target_w); /* fwd synthesis warping */ +#endif + /* actual synthesis gain scaling in SCF-residual domain, for easy weighting analysis */ + pvq_dec_scale_vec_fx(target_w, search_gainTab[L_section][*i_gain_ptr], enc_adj_glob_warped_vec); + } + + *sub_mode_ptr = extract_l(L_section); + move16(); /* 0,1,2,3 */ + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + return; +} + +static void processQuantize_stage2ScfEncStage2_fx( +#ifdef ENABLE_HR_MODE + const Word32 *target_st2, Word32 *st2_vector, +#else + const Word16 *target_st2, Word16 *st2_vector, +#endif + Word32 *L_prm_idx, + Word16 submodes, Word8 *scratchBuffer) /* Size = 26 * M + 48 */ +{ /*func */ +#ifdef ENABLE_HR_MODE + Word32 *proc_target; +#else + Word16 *proc_target; +#endif + + Word16 *enc_pulses_far, *enc_pulses_near, *enc_pulsesA, *enc_pulsesB; + + Word16 *pulses_fin, *pulses_proj; + Word32 L_tmp; + + Word8 *buffer_pvq_enc_find_best_submode_pre_post_fx; + + PvqEntry_fx enc_PVQ_OA, enc_PVQ_B; + Word16 submode, i_gain, submodeMSB, submodeLSB; + Word32 * L_search_corr, *L_search_en; +#ifdef ENABLE_HR_MODE + Word16 * proc_target_lp; +#endif + +#ifdef DYNMEM_COUNT +#ifdef ENABLE_HR_MODE + Dyn_Mem_In("processQuantize_stage2ScfEncStage2_fx", sizeof(struct { + Word32 *proc_target; + Word16 *enc_pulses_far, *enc_pulses_near, *enc_pulsesA, *enc_pulsesB; + Word16 *pulses_fin, *pulses_proj; + Word32 L_tmp; + Word8 *buffer_pvq_enc_find_best_submode_pre_post_fx; + PvqEntry_fx enc_PVQ_OA, enc_PVQ_B; + Word16 submode, i_gain, submodeMSB, submodeLSB; + Word32 * L_search_corr, *L_search_en; + Word16 * proc_target_lp; + })); +#else + Dyn_Mem_In("processQuantize_stage2ScfEncStage2_fx", sizeof(struct { + Word16 *proc_target; + Word16 *enc_pulses_far, *enc_pulses_near, *enc_pulsesA, *enc_pulsesB; + Word16 *pulses_fin, *pulses_proj; + Word32 L_tmp; + Word8 *buffer_pvq_enc_find_best_submode_pre_post_fx; + PvqEntry_fx enc_PVQ_OA, enc_PVQ_B; + Word16 submode, i_gain, submodeMSB, submodeLSB; + Word32 * L_search_corr, *L_search_en; + })); +#endif /* ENABLE_HR_MODE */ +#endif /* DYNMEM_COUNT */ + +#ifdef ENABLE_HR_MODE + buffer_pvq_enc_find_best_submode_pre_post_fx = (Word8 *) scratchAlign(scratchBuffer, 0); + proc_target = (Word32 *) scratchAlign(buffer_pvq_enc_find_best_submode_pre_post_fx, sizeof(*buffer_pvq_enc_find_best_submode_pre_post_fx) * 28 * M); +#else + buffer_pvq_enc_find_best_submode_pre_post_fx = scratchAlign(scratchBuffer, 0); /* Size = 18 * M */ + proc_target = + (Word16 *)scratchAlign(buffer_pvq_enc_find_best_submode_pre_post_fx, + sizeof(*buffer_pvq_enc_find_best_submode_pre_post_fx) * 18 * M); /* Size = 2 * M */ +#endif + + enc_pulses_near = (Word16 *)scratchAlign(proc_target, sizeof(*proc_target) * M); /* Size = 2 * M */ + enc_pulsesA = (Word16 *)scratchAlign(enc_pulses_near, sizeof(*enc_pulses_near) * M); /* Size = 2 * N_SETA */ + enc_pulsesB = (Word16 *)scratchAlign(enc_pulsesA, sizeof(*enc_pulsesA) * N_SETA); /* Size = 2 * N_SETB */ + pulses_fin = (Word16 *)scratchAlign(enc_pulsesB, sizeof(*enc_pulsesB) * N_SETB); /* Size = 2 * N_SCF_SHAPES_ST2 */ + pulses_proj = + (Word16 *)scratchAlign(pulses_fin, sizeof(*pulses_fin) * N_SCF_SHAPES_ST2); /* Size = 2 * N_SCF_SHAPES_ST2 */ + L_search_corr = + (Word32 *)scratchAlign(pulses_proj, sizeof(*pulses_proj) * N_SCF_SHAPES_ST2); /* Size = 4 * N_SCF_SHAPES_ST2 */ + L_search_en = (Word32 *)scratchAlign(L_search_corr, + sizeof(*L_search_corr) * N_SCF_SHAPES_ST2); /* Size = 4 * N_SCF_SHAPES_ST2 */ + enc_pulses_far = (Word16 *)scratchAlign(L_search_en, sizeof(*L_search_en) * N_SCF_SHAPES_ST2); /* Size = 2 * M */ + +#ifdef ENABLE_HR_MODE + proc_target_lp = (Word16 *)buffer_pvq_enc_find_best_submode_pre_post_fx; /* size = 2*M */ +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("processQuantize_stage2ScfEncStage2_fx"); +#endif + + /* fixed setup for a given bitrate of 38 , no moves needed */ + /* k_far = sns_Kval[3][0]; */ + /* k_near = sns_Kval[2][0]; */ + /* kA = sns_Kval[1][0]; */ /* regular, regular_lf */ + /* kB is always 1 */ + + /* NB these search indecese do not correspond exactly to specification shape_index j */ + + pulses_fin[0] = sns_Kval[3][0]; /* far 6 */ + pulses_fin[1] = sns_Kval[2][0]; /* near 8 */ + pulses_fin[2] = sns_Kval[1][0]; /* section A 10 */ + pulses_fin[3] = sns_Kval[0][1]; /* section B 1 */ + + pulses_proj[0] = sns_Kval[3][0]; + pulses_proj[1] = 0; + pulses_proj[2] = 0; + pulses_proj[3] = 0; + + /* pre_process */ +#ifdef ENABLE_HR_MODE + dct32_fx(target_st2, proc_target); /* enc analysis */ + downshift_w32_arr(proc_target, proc_target_lp, 16, M); + + /* get the initial four integer shape candidate vectors, no normalization at this stage */ + pvq_enc_search_fx(proc_target_lp, enc_pulses_far, enc_pulses_near, enc_pulsesA, enc_pulsesB, L_search_corr, + L_search_en, pulses_fin, pulses_proj, M, N_SETA); +#else + Word32 target_st2_32[M]; Word32 proc_target_32[M]; int i; + + FOR (i = 0; i < M; i++) + { + target_st2_32[i] = L_shl_pos(target_st2[i], 16); + } + + dct32_fx(target_st2_32, proc_target_32); /* enc analysis */ + + downshift_w32_arr(proc_target_32, proc_target, 16, M); + + /* get the initial four integer shape candidate vectors, no normalization at this stage */ + pvq_enc_search_fx(proc_target, enc_pulses_far, enc_pulses_near, enc_pulsesA, enc_pulsesB, L_search_corr, + L_search_en, pulses_fin, pulses_proj, M, N_SETA); +#endif + + /* scale with gains a after a unit energy fwd transform */ + /* apply transform to each candidate shape vector priot to gain-shape search loop */ + submode = submodes; /* used as input solely to debug/unit test a specific shape mode */ + + /*target should be in a linearized residual domain target */ + /* search pre, synthesis post*/ + pvq_enc_find_best_submode_pre_post_fx(proc_target, enc_pulses_far, enc_pulses_near, enc_pulsesA, enc_pulsesB, + &submode, &i_gain, st2_vector, + buffer_pvq_enc_find_best_submode_pre_post_fx); /* Q14 tr out */ + + /* send parameters to multiplexor as a series/vector of Long Words */ + /* 0 : 0..3 submode */ + /* 1 : 0..7 gain_ind */ + /* 2 : 0..1 LeadSign ind */ + /* 3 : 25 bit MPVQ index outl_near or A part */ + /* 4 : 3.7 to 21 bits MPVQ index B part OR -2 */ + + L_prm_idx[0] = L_deposit_l(submode); /* complete submode fwd'ed to ari_codec as 0,1,2,3 */ + + submodeMSB = shr_pos(submode, 1); /* LSB of submode , sent as main submode bit */ + submodeLSB = s_and(submode, 0x1); /* LSB of submode */ /* sent via shape param */ + + /* gain, shape indicese , incl. calls to MPVQ indexing */ + IF (submodeMSB == 0) + { /* regular modes:: j=0(reg=AB) or 1(reg_lf A) */ /* regular mode, with two or one shape indices */ + + /* assume regular_lf part , shape_j == 1 */ + enc_PVQ_OA = + mpvq_index_fx(enc_pulsesA, N_SETA, sns_Kval[submode][0]); /* o : leading_sign_index, index, size, k_val */ + L_prm_idx[2] = L_deposit_l(enc_PVQ_OA.lead_sign_ind); /*LS set A */ + + ASSERT(enc_PVQ_OA.size == (UWord32)sns_MPVQ_Sz[submode][0]); + L_prm_idx[3] = L_add(0L, (Word32)enc_PVQ_OA.index); /* MPVQ shape index set A fractional */ + + /* section B always have low indexing dynamics and is combined into one joint single index */ + IF (submodeLSB == 0) + { /* regular AB , shape_j == 0*/ + L_prm_idx[1] = L_deposit_l(i_gain); /* full established gain idx fwd'ed */ /* 2 possible values */ + enc_PVQ_B = mpvq_index_fx(enc_pulsesB, N_SETB, 1); + ASSERT(((enc_PVQ_B.size << 1)) == + (sns_MPVQ_Sz[submode][1])); /* two lowest indeces indicate all_zero B section */ + + L_tmp = L_shl_pos((Word32)enc_PVQ_B.index, 1); /* 2*section B MPVQ index */ + L_prm_idx[4] = L_add(L_tmp, enc_PVQ_B.lead_sign_ind); move32(); /* add joint section B and LS index */ + + ASSERT(L_prm_idx[4] >= 0 && L_prm_idx[4] < (Word32)sns_MPVQ_Sz[submode][0]); + } + ELSE + { + L_prm_idx[1] = L_deposit_l(i_gain); + /* MSBs of established gain idx */ /* 2 or 4 total possible values */ + L_prm_idx[4] = L_deposit_l(-2); + } + } + ELSE + { + /* outlier modes shape_j= 2(near, LSB=0) or 3(far, LSB=1) */ + + IF (submodeLSB == 0) + { + L_prm_idx[1] = L_deposit_l(i_gain); /* established gain idx */ /* 4 possible values */ + enc_PVQ_OA = mpvq_index_fx(enc_pulses_near, M, + sns_Kval[submode][0]); /* o : leading_sign_index, index, size, k_val */ + ASSERT(enc_PVQ_OA.size == sns_MPVQ_Sz[submode][0]); + L_prm_idx[3] = L_add(0L, enc_PVQ_OA.index); /* MPVQ index fractional bits */ + L_prm_idx[4] = L_deposit_l(-1); /* no gain LSBs */ + } + ELSE + { + L_prm_idx[1] = L_deposit_l(i_gain); /* established gain idx MSBs */ /* all 4 or 8 possible values */ + enc_PVQ_OA = mpvq_index_fx(enc_pulses_far, M, + sns_Kval[submode][0]); /* o : leading_sign_index, index, size, k_val */ + ASSERT(enc_PVQ_OA.size == sns_MPVQ_Sz[submode][0]); + L_prm_idx[3] = L_add(0L, enc_PVQ_OA.index); /* MPVQ index fractional bits */ + L_prm_idx[4] = L_deposit_l(-2); /* */ + } + L_prm_idx[2] = L_deposit_l(enc_PVQ_OA.lead_sign_ind); /* LS shape single bit */ + } + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif +#ifdef DYNMEM_COUNT + Dyn_Mem_Out(); +#endif + return; +} + +static Word16 scfdec_stage2_fx( /* o: ber flag */ + const Word32 *L_prm_idx, /* set to -1 if not used */ +#ifdef ENABLE_HR_MODE + Word32 * st2_vector, /*o: Q14 */ +#else + Word16 * st2_vector, /*o: Q14 */ +#endif + Word8 * scratchBuffer) +{ + /* MPVQ deindexing, gainscaling transform and transform */ +#ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In( + Word16 submode; + Word16 submodeLSB, submodeMSB; + Word16 gValQ13; + Word16 idxB; + Word16 maxK; + Word16 BER_dec; + Word16 *dec_pulses; + Word32 *dec_en1_vec; + Word32 *dec_adj_glob_vec; + ); +#else + Dyn_Mem_Deluxe_In( + Word16 submode; + Word16 submodeLSB, submodeMSB; + Word16 gValQ13; + Word16 idxB; + Word16 maxK; + Word16 BER_dec; + Word16 *dec_pulses; + Word16 *dec_en1_vec; + Word16 *dec_adj_glob_vec; + ); +#endif + +#ifdef WMOPS + BASOP_sub_sub_start("scfdec_stage2_fx"); +#endif + + dec_pulses = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * M = 32 bytes */ +#ifdef ENABLE_HR_MODE + dec_en1_vec = (Word32 *)scratchAlign(dec_pulses, sizeof(*dec_pulses) * M); /* Size = 2 * M = 32 bytes */ + dec_adj_glob_vec = (Word32 *)scratchAlign(dec_en1_vec, sizeof(*dec_en1_vec) * M); /* Size = 2 * M = 32 bytes */ +#else + dec_en1_vec = (Word16 *)scratchAlign(dec_pulses, sizeof(*dec_pulses) * M); /* Size = 2 * M = 32 bytes */ + dec_adj_glob_vec = (Word16 *)scratchAlign(dec_en1_vec, sizeof(*dec_en1_vec) * M); /* Size = 2 * M = 32 bytes */ +#endif + + /* get submode */ + submode = extract_l(L_prm_idx[0]); /* 0..3 */ + + submodeLSB = s_and(submode, 0x1); + submodeMSB = shr_pos(submode, 1); + + /* get initial adjustment gain vector for regular, outl_near */ + ASSERT(L_prm_idx[1] >= 0 && L_prm_idx[1] < sns_gainSz[submode]); + gValQ13 = sns_gaintabPtr[submode][L_prm_idx[1]]; + ASSERT(gValQ13 >= 0); + + /* gain, shape indices, incl.calls to MPVQ deindexing */ + IF (submodeMSB != 0) + { + /* outlier_near or outlier_far mode decoding */ + maxK = sns_Kval[submode][0]; move16(); + BER_dec = pvq_dec_deidx_fx(dec_pulses, maxK, M, extract_l(L_prm_idx[2]), (UWord32)L_prm_idx[3]); + } + ELSE + { /* regular mode, with potentially two shape indices */ + + maxK = sns_Kval[submode][0]; move16(); + BER_dec = pvq_dec_deidx_fx(dec_pulses, maxK, N_SETA, extract_l(L_prm_idx[2]), (UWord32)L_prm_idx[3]); + + IF (submodeLSB == 0) + { + idxB = extract_l(L_prm_idx[4]); /* 0..11 */ + ASSERT(idxB >= 0 && idxB < (Word16)sns_MPVQ_Sz[0][1]); + BER_dec |= pvq_dec_deidx_fx(&(dec_pulses[N_SETA]), sns_Kval[submode][1], N_SETB, s_and(idxB, 0x1), + (UWord32)L_deposit_l(shr_pos(idxB, 1))); + /* maxK does not need to be increased as set B is not stacked */ + } + ELSE + { /* LSB gain bit already parsed */ + ASSERT(L_prm_idx[4] < 0); + basop_memset(&dec_pulses[N_SETA], 0, (N_SETB) * sizeof(*dec_pulses)); + } + } + + /* normalize decoded integer vector , exactly as on encoder side !! */ + pvq_dec_en1_normQ14_fx(dec_en1_vec, dec_pulses, maxK, M); + +#ifdef ENABLE_HR_MODE + idct32_32_fx(dec_en1_vec, dec_adj_glob_vec); +#else + idct16_fx(dec_en1_vec, dec_adj_glob_vec); /* fwd warping in unscaled domain */ +#endif + + /* scaling aligend with encoder search */ + pvq_dec_scale_vec_fx(dec_adj_glob_vec, gValQ13, st2_vector); + +#ifdef WMOPS + BASOP_sub_sub_end(); +#endif + Dyn_Mem_Deluxe_Out(); + return BER_dec; +} + +void processSnsQuantizeScfEncoder_fx(Word16 scf[], /* i: input scf M */ + Word32 *L_prm_idx, /* o: indeces . negative == unused */ +#ifdef ENABLE_HR_MODE + Word32 *scf_q, /* o: quantized scf M */ +#else + Word16 *scf_q, /* o: quantized scf M */ +#endif + Word8 * scratchBuffer) /* Size = 28 * M + 52 */ +{ +#ifdef ENABLE_HR_MODE + Dyn_Mem_Deluxe_In( + Word32 *target_st2; + Word16 *st1_idx; /* stage 1 indices */ + Word8 * buffer_processQuantize_stage2ScfEncStage2_fx; + Counter col; + ); +#else + Dyn_Mem_Deluxe_In( + Word16 *target_st2; + Word16 *st1_idx; /* stage 1 indices */ + Word8 * buffer_processQuantize_stage2ScfEncStage2_fx; + Counter col; + ); +#endif + +#ifdef ENABLE_HR_MODE + target_st2 = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * M */ +#else + target_st2 = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * M */ +#endif + st1_idx = (Word16 *)scratchAlign(target_st2, sizeof(*target_st2) * M); /* Size = 2 * 2 */ + buffer_processQuantize_stage2ScfEncStage2_fx = (Word8 *)scratchAlign(st1_idx, sizeof(*st1_idx) * M); + /* Size = 26 * M + 48 */ + + /* TBD needs update */ + + /* 1st stage trained VQ */ + processQuantize_stage1ScfEncStage1_fx(scf, scf_q, &st1_idx[0], &st1_idx[1]); + L_prm_idx[0] = L_deposit_l(st1_idx[0]); + L_prm_idx[1] = L_deposit_l(st1_idx[1]); + +/* 2nd stage PVQ-based SCF quantizer */ + FOR (col = 0; col < M; col++) + { +#ifdef ENABLE_HR_MODE + target_st2[col] = L_sub(L_deposit_h(scf[col]), scf_q[col]); +#else + target_st2[col] = sub(scf[col], scf_q[col]); +#endif + } + + processQuantize_stage2ScfEncStage2_fx(target_st2, scf_q, &L_prm_idx[2], VQMODES26, /* 0xF means all submodes */ + buffer_processQuantize_stage2ScfEncStage2_fx); /* PVQ in stage 2 */ + Dyn_Mem_Deluxe_Out(); +} + +Word16 processSnsQuantizeScfDecoder_fx( /* o: BER flag */ + Word32 *L_prm_idx, /* i: indeces */ +#ifdef ENABLE_HR_MODE + Word32 scf_q[], +#else + Word16 scf_q[], +#endif + Word8 *scratchBuffer) /* o: M */ +{ + Dyn_Mem_Deluxe_In( + Word16 BER_flag; + ); + + /* Decode First Stage */ +#ifdef ENABLE_HR_MODE + processDeQuantize_stage1ScfDecStage1_fx(st1SCF0_7_base5_32x8_Q27, st1SCF8_15_base5_32x8_Q27, + extract_l(L_prm_idx[0]), extract_l(L_prm_idx[1]), scf_q); +#else + processDeQuantize_stage1ScfDecStage1_fx(st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, + extract_l(L_prm_idx[0]), extract_l(L_prm_idx[1]), scf_q); +#endif + + /* Decode Second Stage */ + BER_flag = scfdec_stage2_fx(&(L_prm_idx[2]), scf_q, scratchBuffer); + + Dyn_Mem_Deluxe_Out(); + return BER_flag; +} + diff --git a/lib_lc3plus/tinywavein_c.h b/lib_lc3plus/tinywavein_c.h new file mode 100644 index 000000000..32789e314 --- /dev/null +++ b/lib_lc3plus/tinywavein_c.h @@ -0,0 +1,603 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef __TINYWAVEIN_C_H__ +#define __TINYWAVEIN_C_H__ + +/*#define SUPPORT_BWF*/ + +#include +#include +#include + +#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || defined(__arm__) || \ + defined(__aarch64__) +#define __TWI_LE /* _T_iny _W_ave _I_n _L_ittle _E_ndian */ +#endif + +#if defined(__POWERPC__) +#define __TWI_BE /* _T_iny _W_ave _I_n _B_ig _E_ndian */ +#endif + +#if !defined(__TWI_LE) && !defined(__TWI_BE) +#error unknown processor +#endif + +#define __TWI_SUCCESS (0) +#define __TWI_ERROR (-1) + +#ifdef SUPPORT_BWF +typedef struct +{ + float loudnessVal; + float loudnessRange; + float maxTruePeakLevel; + float maxMomentaryLoudnes; + float maxShortTermLoudness; +} WAVEIN_LOUDNESSINFO; +#endif + +typedef struct __tinyWaveInHandle +{ + FILE * theFile; + fpos_t dataChunkPos; + unsigned int position; + unsigned int length; + unsigned int bps; +#ifdef SUPPORT_BWF + WAVEIN_LOUDNESSINFO *loudnessInfo; +#endif +} __tinyWaveInHandle, WAVEFILEIN; + +typedef struct +{ + short compressionCode; + short numberOfChannels; + unsigned int sampleRate; + unsigned int averageBytesPerSecond; + short blockAlign; + short bitsPerSample; + /* short extraFormatBytes ; */ +} SWavInfo; + +#ifdef SUPPORT_BWF +typedef struct +{ + unsigned char description[256]; + unsigned char originator[32]; + unsigned char originatorReference[32]; + unsigned char originatorDate[10]; /* ASCII: <> */ + unsigned char originationTime[8]; /* ASCII: <> */ + unsigned int timeReferenceLow; + unsigned int timeReferenceHigh; + unsigned short version; + unsigned char UMID[64]; /* Binary Bytes of SMPTE UMID */ + + signed short loudnessVal; + signed short loudnessRange; + signed short maxTruePeakLevel; + signed short maxMomentaryLoudnes; + signed short maxShortTermLoudness; + + unsigned char Reserved[180]; + + unsigned char codingHistory; /* ASCII: <> */ +} SBwfWav; +#endif + +typedef struct +{ + char chunkID[4]; + unsigned int chunkSize; + /* long dataOffset ; */ /* never used */ +} SChunk; + +/* local wrapper, always returns correct endian */ +static size_t fread_LE(void *ptr, size_t size, size_t nmemb, FILE *stream); + +#ifdef __TWI_BE +static short BigEndian16(short v); +static int BigEndian32(int v); +#endif + +/*! + * \brief Read header from a WAVEfile. Host endianess is handled accordingly. + * \fp filepointer of type FILE*. + * \wavinfo SWavInfo struct where the decoded header info is stored into. + * \return 0 on success and non-zero on failure. + * + */ +static WAVEFILEIN *OpenWav(const char *filename, unsigned int *samplerate, short *channels, unsigned int *samplesInFile, + short *bps) +{ + WAVEFILEIN *self; + + SChunk fmt_chunk, data_chunk; + int offset; + unsigned int tmpSize; + char tmpFormat[4]; + SWavInfo wavinfo = {0, 0, 0, 0, 0, 0}; + + self = (WAVEFILEIN *)calloc(1, sizeof(WAVEFILEIN)); + if (!self) + goto bail; /* return NULL; */ + + if (!filename) + goto bail; + if (!samplerate) + goto bail; + if (!channels) + goto bail; + if (!samplesInFile) + goto bail; + if (!bps) + goto bail; + + self->theFile = fopen(filename, "rb"); + if (!self->theFile) + goto bail; + + /* read RIFF-chunk */ + if (fread(tmpFormat, 1, 4, self->theFile) != 4) + { + goto bail; + } + + if (strncmp("RIFF", tmpFormat, 4)) + { + goto bail; + } + + /* Read RIFF size. Ignored. */ + fread_LE(&tmpSize, 4, 1, self->theFile); + + /* read WAVE-chunk */ + if (fread(tmpFormat, 1, 4, self->theFile) != 4) + { + goto bail; + } + + if (strncmp("WAVE", tmpFormat, 4)) + { + goto bail; + } + + /* read format/bext-chunk */ + if (fread(fmt_chunk.chunkID, 1, 4, self->theFile) != 4) + { + goto bail; + } + +#ifdef SUPPORT_BWF + /* test for bext-chunk */ + if (!strncmp("bext", fmt_chunk.chunkID, 4)) + { + /*unsigned int i;*/ + unsigned int bextSize = 0; + + if (fread_LE(&bextSize, 1, 4, self->theFile) != 4) + { + goto bail; + } + + self->loudnessInfo = (WAVEIN_LOUDNESSINFO *)calloc(1, sizeof(WAVEIN_LOUDNESSINFO)); + + if (bextSize >= 602) + { /* minimum size bext-data, w/o 'CodingHistory' */ + int i; + signed short readBuf = 0; + signed int nulbuf = 0; + + /* first skip all descriptive data */ + for (i = 0; i < 412; i++) + { + if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) + { + goto bail; + } + bextSize -= 1; + } + /* second, read loudness data */ + fread_LE(&readBuf, 2, 1, self->theFile); + bextSize -= 2; + self->loudnessInfo->loudnessVal = (float)readBuf * 0.01f; + + fread_LE(&readBuf, 2, 1, self->theFile); + bextSize -= 2; + self->loudnessInfo->loudnessRange = (float)readBuf * 0.01f; + + fread_LE(&readBuf, 2, 1, self->theFile); + bextSize -= 2; + self->loudnessInfo->maxTruePeakLevel = (float)readBuf * 0.01f; + + fread_LE(&readBuf, 2, 1, self->theFile); + bextSize -= 2; + self->loudnessInfo->maxMomentaryLoudnes = (float)readBuf * 0.01f; + + fread_LE(&readBuf, 2, 1, self->theFile); + bextSize -= 2; + self->loudnessInfo->maxShortTermLoudness = (float)readBuf * 0.01f; + + /* skip reserved data */ + for (i = 0; i < 180; i++) + { + if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) + { + goto bail; + } + bextSize -= 1; + } + } + + /* skip remaining data */ + while (bextSize) + { + int nulbuf; + if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) + { + goto bail; + } + bextSize -= 1; + } + + /* read next chunk header */ + if (fread(fmt_chunk.chunkID, 1, 4, self->theFile) != 4) + { + goto bail; + } + } +#endif + + /* skip some potential chunks up to fmt chunk */ + + while (strncmp("fmt ", fmt_chunk.chunkID, 4) != 0) + { + unsigned int chunkSize = 0; + + if (fread_LE(&chunkSize, 1, 4, self->theFile) != 4) + { + goto bail; + } + + /* skip chunk data */ + while (chunkSize) + { + int nulbuf; + if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) + { + goto bail; + } + chunkSize -= 1; + } + + /* read next chunk header */ + if (fread(fmt_chunk.chunkID, 1, 4, self->theFile) != 4) + { + goto bail; + } + } + + /* go on with fmt-chunk */ + if (strncmp("fmt ", fmt_chunk.chunkID, 4)) + { + goto bail; + } + + if (fread_LE(&fmt_chunk.chunkSize, 4, 1, self->theFile) != 1) + { /* should be 16 for PCM-format (uncompressed) */ + goto bail; + } + + + /* read info */ + fread_LE(&(wavinfo.compressionCode), 2, 1, self->theFile); + fread_LE(&(wavinfo.numberOfChannels), 2, 1, self->theFile); + fread_LE(&(wavinfo.sampleRate), 4, 1, self->theFile); + fread_LE(&(wavinfo.averageBytesPerSecond), 4, 1, self->theFile); + fread_LE(&(wavinfo.blockAlign), 2, 1, self->theFile); + fread_LE(&(wavinfo.bitsPerSample), 2, 1, self->theFile); + + if (wavinfo.compressionCode == -2) + { + fseek(self->theFile, 8, SEEK_CUR); // skip channel mask + fread_LE(&(wavinfo.compressionCode), 2, 1, self->theFile); // part of GUID + fseek(self->theFile, 14, SEEK_CUR); // skip rest of GUID + offset = fmt_chunk.chunkSize - 40; + } + else + offset = fmt_chunk.chunkSize - 16; + + if (wavinfo.compressionCode == 0x01) + { + if ((wavinfo.bitsPerSample != 16) && (wavinfo.bitsPerSample != 24) && (wavinfo.bitsPerSample != 32)) + /* we do only support 16,24 and 32 bit PCM audio */ + goto bail; + } + else + { + /* if(wavinfo.bitsPerSample != 32) */ + printf("compressioncode: %02x\n", wavinfo.compressionCode); + puts("Error! We only support 16,24 and 32 bit PCM audio"); + exit(1); + goto bail; + } + + /* Skip rest of fmt header if any. */ + for (; offset > 0; offset--) + { + fread(&tmpSize, 1, 1, self->theFile); + } + + do + { + + /* Read data chunk ID */ + if (fread(data_chunk.chunkID, 1, 4, self->theFile) != 4) + { + goto bail; + } + + /* Read chunk length. */ + + if (fread_LE(&offset, 4, 1, self->theFile) != 1) + { + goto bail; + } + + /* Check for data chunk signature. */ + if (strncmp("data", data_chunk.chunkID, 4) == 0) + { + data_chunk.chunkSize = offset; + break; + } + + /* unused 1 byte present, if size is odd */ + /* see https://www.daubnet.com/en/file-format-riff */ + if (offset % 2) + { + offset++; + } + + /* Jump over non data chunk. */ + for (; offset > 0; offset--) + { + fread(&tmpSize, 1, 1, self->theFile); + } + + } while (!feof(self->theFile)); + + /* success so far */ + *samplerate = wavinfo.sampleRate; + *channels = wavinfo.numberOfChannels; + *samplesInFile = data_chunk.chunkSize / wavinfo.numberOfChannels; + *samplesInFile /= ((wavinfo.bitsPerSample + 7) / 8); + *bps = wavinfo.bitsPerSample; + + self->position = 0; + self->bps = wavinfo.bitsPerSample; + self->length = *samplesInFile * wavinfo.numberOfChannels; + + fgetpos(self->theFile, &self->dataChunkPos); + + return self; + +bail: + free(self); + return NULL; +} + +#ifdef SUPPORT_BWF +static void ReadBWF(WAVEFILEIN *self, WAVEIN_LOUDNESSINFO **wavInLoudness) +{ + *wavInLoudness = self->loudnessInfo; +} +#endif + +static int __ReadSample16(WAVEFILEIN *self, int *sample) +{ + size_t cnt; + short v = 0; + + cnt = fread(&v, 2, 1, self->theFile); + + if (cnt != 1) + { + return __TWI_ERROR; + } + + self->position += 1; + +#ifdef __TWI_BE + v = BigEndian16(v); +#endif + *sample = v; + return __TWI_SUCCESS; +} + +static int __ReadSample24(WAVEFILEIN *self, int *sample) +{ + size_t cnt; + int v = 0; + + cnt = fread(&v, 3, 1, self->theFile); + + if (cnt != 1) + { + return __TWI_ERROR; + } + + self->position += 1; + +#ifdef __TWI_BE + v = BigEndian32(v); +#endif + + if (v >= 0x800000) + { + v |= 0xff000000; + } + + *sample = v; + + return __TWI_SUCCESS; +} + +static int __ReadSample32(WAVEFILEIN *self, int *sample) +{ + size_t cnt; + int v = 0; + + cnt = fread(&v, 4, 1, self->theFile); + + if (cnt != 1) + { + return __TWI_ERROR; + } + + self->position += 1; + +#ifdef __TWI_BE + v = BigEndian32(v); +#endif + + *sample = v >> 8; + + return __TWI_SUCCESS; +} + +static int __ReadSampleInternal(WAVEFILEIN *self, int *sample, int scale) +{ + int err; + + if (!self) + { + return __TWI_ERROR; + } + + switch (scale) + { + + case 16: err = __ReadSample16(self, sample); break; + + case 24: err = __ReadSample24(self, sample); break; + + case 32: err = __ReadSample32(self, sample); break; + + default: err = __TWI_ERROR; break; + } + + return err; +} + +/* this function returns normalized values in the range +8388607..-8388608 */ +static int ReadWavInt(WAVEFILEIN *self, int sampleBuffer[], unsigned int nSamplesToRead, unsigned int *nSamplesRead) +{ + unsigned int i; + int err = __TWI_SUCCESS; + *nSamplesRead = 0; + + if (!sampleBuffer) + { + return __TWI_ERROR; + } + + /* check if we have enough samples left, if not, + set nSamplesToRead to number of samples left. */ + if (self->position + nSamplesToRead > self->length) + { + nSamplesToRead = self->length - self->position; + } + + for (i = 0; i < nSamplesToRead; i++) + { + + int tmp; + err = __ReadSampleInternal(self, &tmp, self->bps); + if (err != __TWI_SUCCESS) + { + return err; + } + sampleBuffer[i] = tmp; + *nSamplesRead += 1; + } + + return __TWI_SUCCESS; +} + +static int CloseWavIn(WAVEFILEIN *self) +{ + if (self) + { + if (self->theFile) + { + fclose(self->theFile); + } + } + free(self); + + return __TWI_SUCCESS; +} +/* +static int ResetWavIn(WAVEFILEIN* self) +{ + if (self) { + if (self->theFile) { + fsetpos(self->theFile, &self->dataChunkPos); + self->position = 0; + } + } + return __TWI_SUCCESS; +} +*/ +/*------------- local subs ----------------*/ + +static size_t fread_LE(void *ptr, size_t size, size_t nmemb, FILE *stream) +{ +#ifdef __TWI_LE + return fread(ptr, size, nmemb, stream); +#endif +#ifdef __TWI_BE + + unsigned char x[sizeof(int)]; + unsigned char *y = (unsigned char *)ptr; + int i; + int len; + + len = fread(x, size, nmemb, stream); + + for (i = 0; i < size * nmemb; i++) + { + *y++ = x[size * nmemb - i - 1]; + } + + return len; +#endif +} + +#ifdef __TWI_BE +static short BigEndian16(short v) +{ + short a = (v & 0x0ff); + short b = (v & 0x0ff00) >> 8; + + return a << 8 | b; +} + +static int BigEndian32(int v) +{ + int a = (v & 0x0ff); + int b = (v & 0x0ff00) >> 8; + int c = (v & 0x0ff0000) >> 16; + int d = (v & 0xff000000) >> 24; + + return a << 24 | b << 16 | c << 8 | d; +} +#endif + +#endif /* __TINYWAVEIN_C_H__ */ diff --git a/lib_lc3plus/tinywaveout_c.h b/lib_lc3plus/tinywaveout_c.h new file mode 100644 index 000000000..672254270 --- /dev/null +++ b/lib_lc3plus/tinywaveout_c.h @@ -0,0 +1,889 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#ifndef __TINYWAVEOUT_C_H__ +#define __TINYWAVEOUT_C_H__ + +/*#define TWO_SUPPORT_BWF*/ + +#include +#include +#include +#include +#ifdef TWO_SUPPORT_BWF +#include +#endif + +/***** Interface *********************************************************/ + +#ifndef TWO_UINT64 + #if !(defined(WIN32)) + #include + #define TWO_UINT64 uint64_t + #else + #define TWO_UINT64 unsigned __int64 + #endif +#endif + +typedef struct WAVEFILEOUT WAVEFILEOUT; +#ifdef TWO_SUPPORT_BWF +typedef struct WAVEOUT_LOUDNESSINFO WAVEOUT_LOUDNESSINFO; +#endif + +#define __TWO_SUCCESS (0) +#define __TWO_ERROR (-1) + +static WAVEFILEOUT* CreateWav( + const char *fileName, + const unsigned int sampleRate, + const unsigned int numChannels, + const unsigned int bps + ); + +#ifdef TWO_SUPPORT_BWF +static WAVEFILEOUT* CreateWavBWF( + const char *fileName, + const unsigned int sampleRate, + const unsigned int numChannels, + const unsigned int bps, + const WAVEOUT_LOUDNESSINFO *hBwfData + ); +#endif + +/* this function expects values in the 16 bit range +32767..-32768 */ +static int WriteWavShort( + WAVEFILEOUT* self, + short sampleBuffer[], + unsigned int nSamples + ); + +/* this function expects values in the 24 bit range +8388607..-8388608 */ +static int WriteWavLong( + WAVEFILEOUT* self, + int sampleBuffer[], + unsigned int nSamples + ); + +/* this function expects normalized values in the range +-1.0f */ +static int WriteWavFloat( + WAVEFILEOUT* self, + float sampleBuffer[], + unsigned int nSamples + ); + +static int CloseWav(WAVEFILEOUT* self); +#ifdef TWO_SUPPORT_BWF +static int CloseWavBWF(WAVEFILEOUT* self, WAVEOUT_LOUDNESSINFO bextData); +#endif + +/***** Implementation *********************************************************/ + +#if defined (__i386__) || defined (_M_IX86) || defined (_M_X64) || defined (__x86_64__) || defined (__arm__) || defined (__xtensa__) || defined (__aarch64__) || defined (__EMSCRIPTEN__) +#define __TWO_LE /* _T_iny _W_ave _O_ut _L_ittle _E_ndian */ +#endif + +#if defined (__POWERPC__) +#define __TWO_BE /* _T_iny _W_ave _O_ut _B_ig _E_ndian */ +#endif + +#if defined (__sparc__) +#define __TWO_BE /* _T_iny _W_ave _O_ut _B_ig _E_ndian */ +#endif + +#if ! defined (__TWO_LE) && ! defined (__TWO_BE) +#error unknown processor +#endif + +/*--- local types/structs ----------------------------------*/ + +#if defined(_MSC_VER) + #pragma pack(push, 1) +#else + #pragma pack(1) +#endif + + +#ifdef TWO_SUPPORT_BWF +struct WAVEOUT_LOUDNESSINFO { + float loudnessVal; + float loudnessRange; + float maxTruePeakLevel; + float maxMomentaryLoudnes; + float maxShortTermLoudness; +}; +#endif + + +typedef struct __tinyWaveOutHeader +{ + unsigned int riffType; /* 'RIFF/RF64' */ + unsigned int riffSize; /* file size/-1 */ + unsigned int waveType; /* 'WAVE' */ +} __tinyWaveOutHeader; + +typedef struct __tinyWaveOutDs64Chunk +{ + unsigned int formatType; /* = 'JUNK/ds64' */ + unsigned int formatSize; /* size info */ + TWO_UINT64 riffSize64; + TWO_UINT64 dataSize64; + TWO_UINT64 sampleCount64; + unsigned int tableLength; /* optional tables, always 0 for tinywaveout */ + /* here: optional tables */ +} __tinyWaveOutDs64Chunk; + +#ifdef TWO_SUPPORT_BWF +typedef struct __tinyWaveOutBextChunk +{ + unsigned int formatType; /* = 'bext' */ + unsigned int formatSize; /* size info */ + + unsigned char description[256]; + unsigned char originator[32]; + unsigned char originatorReference[32]; + unsigned char originatorDate[10]; /* ASCII: <> */ + unsigned char originationTime[8]; /* ASCII: <> */ + unsigned int timeReferenceLow; + unsigned int timeReferenceHigh; + unsigned short version; + unsigned char UMID[64]; /* Binary Bytes of SMPTE UMID */ + + signed short loudnessVal; + signed short loudnessRange; + signed short maxTruePeakLevel; + signed short maxMomentaryLoudnes; + signed short maxShortTermLoudness; + + unsigned char Reserved[180]; + + unsigned char codingHistory; /* ASCII: <> - undefined length! */ + /* for variable length, mve this out of this struct */ +} __tinyWaveOutBextChunk; +#endif + +typedef struct __tinyWaveOutFmtChunk +{ + unsigned int formatType; + unsigned int formatSize; + + unsigned short formatTag; + unsigned short numChannels; + unsigned int sampleRate; + unsigned int bytesPerSecond; + unsigned short blockAlignment; + unsigned short bitsPerSample; + + /* wav fmt ext hdr here */ +} __tinyWaveOutFmtChunk; + +typedef struct __tinyWaveOutDataChunk +{ + unsigned int dataType; + unsigned int dataSize; + +} __tinyWaveOutDataChunk; + + +struct WAVEFILEOUT { + /* for reasons of memory alignment, have 64 bit data types first */ + TWO_UINT64 dataSize; + TWO_UINT64 dataSizeLimit; /* maximum size for data chunk for 4 GB files */ + TWO_UINT64 dataSizeLimit64; /* maximum size for data chunk for 2^64 B addressable files */ + TWO_UINT64 clipCount; + FILE* theFile; + unsigned int junkChunkOffset; + unsigned int fmtChunkOffset; +#ifdef TWO_SUPPORT_BWF + unsigned int bextChunkOffset; +#endif + unsigned int dataChunkOffset; + unsigned int bps; + + /* only needed for RF64: */ + unsigned int blockAlign; /* only needed for close() of ds64 chunk */ +}; + + +/*--- local protos --------------------------------------------------*/ +static __inline unsigned int BigEndian32(char, char, char, char); +static __inline unsigned int LittleEndian32(unsigned int); +static __inline unsigned int LittleEndian32s(int); +static __inline short LittleEndian16(short); +static __inline TWO_UINT64 LittleEndian64(TWO_UINT64); +#ifdef TWO_SUPPORT_BWF +static unsigned int EncodeLoudness(float); +#endif +static __inline int __dataSizeChk( WAVEFILEOUT* self, int newbytes ); + +#if defined(_MSC_VER) + #pragma pack(pop) +#else + #pragma pack() +#endif + + +#ifdef TWO_SUPPORT_BWF +static void setDefaultLoudness(WAVEOUT_LOUDNESSINFO *x) +{ + x->loudnessVal = 1.0f; + x->loudnessRange = 2.0f; + x->maxTruePeakLevel = 3.0f; + x->maxMomentaryLoudnes = 4.0f; + x->maxShortTermLoudness = 5.0f; +} +#endif + +static WAVEFILEOUT* __CreateWavInternal( + const char *fileName, + const unsigned int sampleRate, + const unsigned int numChannels, + const unsigned int bps +#ifdef TWO_SUPPORT_BWF + , + const WAVEOUT_LOUDNESSINFO *hBwfData +#endif + ) +{ + WAVEFILEOUT* self = NULL; + __tinyWaveOutHeader whdr; + __tinyWaveOutDs64Chunk ds64ch; +#ifdef TWO_SUPPORT_BWF + __tinyWaveOutBextChunk wbextch; +#endif + __tinyWaveOutFmtChunk wfch; + __tinyWaveOutDataChunk wdch; + unsigned int blockAlignment = 0; + unsigned int ByteCnt = 0; /* Byte counter for fwrite */ + + /* pseudo use to avoid unused symbols */ + (void)WriteWavShort; + (void)WriteWavLong; + (void)WriteWavFloat; +#ifdef TWI_SUPPORT_BWF + (void)CreateWavBWF; + (void)CloseWavBWF; + (void)setDefaultLoudness; +#endif + + /* param check */ + if (!fileName) goto bail; + if (sampleRate == 0) goto bail; + if (sampleRate > 768000) goto bail; + if (numChannels == 0) goto bail; + if (numChannels > 64) goto bail; + if (bps != 16 && bps != 24 && bps != 32) goto bail; + + self = (WAVEFILEOUT*)calloc(1, sizeof(WAVEFILEOUT)); + if (!self) goto bail; /* return NULL; */ + + self->theFile = fopen(fileName, "wb+"); + if (!self->theFile) goto bail; + + /* WAV-Header */ + whdr.riffType = BigEndian32('R','I','F','F'); + whdr.riffSize = LittleEndian32(0xffffffff); /* set to maximum, if fseek() doesn't work later */ + whdr.waveType = BigEndian32('W','A','V','E'); + /* write to file */ + ByteCnt = 0; + ByteCnt += fwrite(&whdr, 1, sizeof(whdr), self->theFile); + + /* ds64/JUNK-Chunk */ + ds64ch.formatType = BigEndian32('J','U','N','K'); + ds64ch.formatSize = LittleEndian32(sizeof(__tinyWaveOutDs64Chunk) - 8); + ds64ch.riffSize64 = (TWO_UINT64) -1; + ds64ch.dataSize64 = (TWO_UINT64) -1; + ds64ch.sampleCount64 = (TWO_UINT64) -1; + ds64ch.tableLength = 0; + self->junkChunkOffset = ByteCnt; + ByteCnt += fwrite(&ds64ch, 1, sizeof(ds64ch), self->theFile); + +#ifdef TWO_SUPPORT_BWF + /* BEXT-Chunk */ + if (hBwfData) { + memset(&wbextch, 0, sizeof(__tinyWaveOutBextChunk)); + wbextch.formatType = BigEndian32('b','e','x','t'); + wbextch.formatSize = LittleEndian32(sizeof(__tinyWaveOutBextChunk) - 8); + wbextch.version = 0x0002; + wbextch.loudnessVal = EncodeLoudness(hBwfData->loudnessVal); + wbextch.loudnessRange = EncodeLoudness(hBwfData->loudnessRange); + wbextch.maxTruePeakLevel = EncodeLoudness(hBwfData->maxTruePeakLevel); + wbextch.maxMomentaryLoudnes = EncodeLoudness(hBwfData->maxMomentaryLoudnes); + wbextch.maxShortTermLoudness = EncodeLoudness(hBwfData->maxShortTermLoudness); + /* t.b.d.: more values */ + + /* write to file */ + self->bextChunkOffset = ByteCnt; + ByteCnt += fwrite(&wbextch, 1, sizeof(wbextch), self->theFile); + } +#endif + + /* FMT-Chunk */ + wfch.formatType = BigEndian32('f','m','t',' '); + wfch.formatSize = LittleEndian32(16); + switch (bps) { + case 16: + case 24: + wfch.formatTag = LittleEndian16(0x0001); /* WAVE_FORMAT_PCM */ + break; + case 32: + wfch.formatTag = LittleEndian16(0x0003); /* WAVE_FORMAT_IEEE_FLOAT */ + break; + default: + goto bail; + } + self->bps = bps; + wfch.bitsPerSample = LittleEndian16(bps); + wfch.numChannels = LittleEndian16(numChannels); + blockAlignment = numChannels * (bps >> 3); + wfch.blockAlignment = LittleEndian16(blockAlignment); + wfch.sampleRate = LittleEndian32(sampleRate); + wfch.bytesPerSecond = LittleEndian32(sampleRate * blockAlignment); + /* tbd: wavfmt ext hdr here */ + /* write to file */ + self->fmtChunkOffset = ByteCnt; + ByteCnt += fwrite(&wfch, 1, sizeof(wfch), self->theFile); + + /* DATA-Chunk */ + self->dataChunkOffset = ByteCnt; + wdch.dataType = BigEndian32('d','a','t','a'); + wdch.dataSize = LittleEndian32(0xffffffff - ByteCnt); /* yet unknown. set to maximum of 4 GB file */ + /* write to file */ + ByteCnt += fwrite(&wdch, 1, sizeof(wdch), self->theFile); + + self->dataSize = 0; + + /* self->dataSizeLimit = 0x7fffffff - ByteCnt; */ /* maximum size for data chunk for 2 GB files */ + self->dataSizeLimit = 0xffffffff - ByteCnt; /* maximum size for data chunk for 4 GB files */ + self->dataSizeLimit64 = 0xffffffffffffffff - ByteCnt; /* maximum size for data chunk for 64 bit addressable files */ + + self->clipCount = 0; + self->blockAlign = blockAlignment; + + return self; + + bail: + if ( NULL != self) { + free(self); + } + + return NULL; +} + +static WAVEFILEOUT* CreateWav( + const char* fileName, + const unsigned int sampleRate, + const unsigned int numChannels, + const unsigned int bps + ) +{ +#ifdef TWO_SUPPORT_BWF + return __CreateWavInternal(fileName, sampleRate, numChannels, bps, NULL); +#else + return __CreateWavInternal(fileName, sampleRate, numChannels, bps); +#endif +} + +#ifdef TWO_SUPPORT_BWF +static WAVEFILEOUT* CreateWavBWF( + const char *fileName, + const unsigned int sampleRate, + const unsigned int numChannels, + const unsigned int bps, + const WAVEOUT_LOUDNESSINFO *hBwfData + ) +{ + return __CreateWavInternal(fileName, sampleRate, numChannels, bps, hBwfData); +} +#endif + +#define MAX_PCM16 (+32767) +#define MIN_PCM16 (-32768) +static __inline int CLIP_PCM16(int sample, TWO_UINT64* clipcount) +{ + int tmp = sample; + + if (sample >= MAX_PCM16) { + tmp = MAX_PCM16; + (*clipcount)++; + } else { + if (sample <= MIN_PCM16) { + tmp = MIN_PCM16; + (*clipcount)++; + } + } + + return tmp; +} + +#define MAX_PCM24 (+8388607) +#define MIN_PCM24 (-8388608) +static __inline int CLIP_PCM24(int sample, TWO_UINT64* clipcount) +{ + int tmp = sample; + + if (sample >= MAX_PCM24) { + tmp = MAX_PCM24; + (*clipcount)++; + } else { + if (sample <= MIN_PCM24) { + tmp = MIN_PCM24; + (*clipcount)++; + } + } + + return tmp; +} + +#define MAX_FLOAT32 (+1.0f) +#define MIN_FLOAT32 (-1.0f) +static __inline float CLIP_FLOAT32(float sample, TWO_UINT64* clipcount) +{ + float tmp = sample; + + if (sample >= MAX_FLOAT32) { + tmp = MAX_FLOAT32; + (*clipcount)++; + } else { + if (sample <= MIN_FLOAT32) { + tmp = MIN_FLOAT32; + (*clipcount)++; + } + } + + return tmp; +} + + + +static int __WriteSample16( + WAVEFILEOUT* self, + int sample, + int scale + ) +{ + size_t cnt; + short v; + + if ((scale - 16) > 0) + sample = sample >> (scale - 16); + else + sample = (int) ((uint32_t) sample << (16 - scale)); + + v = (short)CLIP_PCM16(sample, &(self->clipCount)); +#ifdef __TWO_BE + v = LittleEndian16(v); +#endif + + cnt = fwrite(&v, sizeof(short), 1, self->theFile); + + if (cnt == 1) { + self->dataSize += 2; + return __TWO_SUCCESS; + } + + return __TWO_ERROR; +} + + +static int __WriteSample24( + WAVEFILEOUT* self, + int sample, + int scale + ) +{ + size_t cnt; + int v; + + if ((scale - 24) > 0) + sample = sample >> (scale - 24); + else + sample = (int) (((unsigned int)sample) << (24 - scale)); + + v = (int)CLIP_PCM24(sample, &(self->clipCount)); +#ifdef __TWO_BE + v = LittleEndian32s(v); +#endif + cnt = fwrite(&v, 3, 1, self->theFile); + + if (cnt == 1) { + self->dataSize += 3; + return __TWO_SUCCESS; + } + + return __TWO_ERROR; +} + + +static int __WriteSample32( + WAVEFILEOUT* self, + float sample + ) +{ + size_t cnt; + union fl_int { + float v_float; + int v_int; + }; + union fl_int v; + +#if CLIP_FLOAT + v.v_float = CLIP_FLOAT32(sample, &(self->clipCount)); +#else + v.v_float = sample; + if((sample > 1.0f) || (sample <-1.0f)) + self->clipCount++; +#endif + +#ifdef __TWO_BE + v.v_int = LittleEndian32s(v.v_int); +#endif + cnt = fwrite(&v, 4, 1, self->theFile); + + if (cnt == 1) { + self->dataSize += 4; + return __TWO_SUCCESS; + } + + return __TWO_ERROR; +} + + +static int __WriteSampleInt( + WAVEFILEOUT* self, + int sample, + int scale + ) +{ + int err; + + if (!self) return __TWO_ERROR; + + + switch (self->bps) { + + case 16: + err = __WriteSample16(self, sample, scale); + break; + + case 24: + err = __WriteSample24(self, sample, scale); + break; + + default: + err = __TWO_ERROR; + break; + } + + return err; +} + + +/* this function expects values in the 16 bit range +-32767/8 */ +static int WriteWavShort( + WAVEFILEOUT* self, + short sampleBuffer[], + unsigned int nSamples + ) +{ + unsigned long i; + int err = __TWO_SUCCESS; + + if (!self) return __TWO_ERROR; + if (!sampleBuffer) return __TWO_ERROR; + if (__dataSizeChk(self, nSamples * sizeof(short))) return __TWO_ERROR; + + for (i=0; i< nSamples; i++) { + if (self->bps == 32) + { + err = __WriteSample32(self, sampleBuffer[i] / 32768.0f); + } + else + { + err = __WriteSampleInt(self, (int)sampleBuffer[i], 16); + } + if (err != __TWO_SUCCESS) return err; + } + + return __TWO_SUCCESS; +} + + +/* this function expects values in the 24 bit range +-8388607/8 */ +static int WriteWavLong( + WAVEFILEOUT* self, + int sampleBuffer[], + unsigned int nSamples + ) +{ + unsigned long i; + int err = __TWO_SUCCESS; + + if (!self) return __TWO_ERROR; + if (!sampleBuffer) return __TWO_ERROR; + if (__dataSizeChk(self, nSamples * sizeof(int))) return __TWO_ERROR; + + for (i = 0; i < nSamples; i++) { + if (self->bps == 32) + { + err = __WriteSample32(self, sampleBuffer[i] / 8388608.0f); + } + else + { + err = __WriteSampleInt(self, sampleBuffer[i], 24); + } + if (err != __TWO_SUCCESS) return err; + } + + return __TWO_SUCCESS; +} + + +/* this function expects normalized values in the range +-1.0 */ +#define MAX_FL (+2.0f * 8388608.0f ) +#define MIN_FL (-2.0f * 8388608.0f ) +#define CLIP_FL(x) ( ((x) >= MAX_FL) ? MAX_FL : (((x) <= MIN_FL) ? MIN_FL : (x)) ) +static int WriteWavFloat( + WAVEFILEOUT* self, + float sampleBuffer[], + unsigned int nSamples + ) +{ + unsigned int i; + int err = __TWO_SUCCESS; + + if (!self) return __TWO_ERROR; + if (!sampleBuffer) return __TWO_ERROR; + if (__dataSizeChk(self, nSamples * sizeof(float))) return __TWO_ERROR; + + for (i=0; ibps == 32) + { + err = __WriteSample32(self, sampleBuffer[i]); + } + else + { + float tmp = CLIP_FL(sampleBuffer[i] * 8388608.0f); /* CLIP_FL is just to avoid an INT overrun before the actual cast to int, real clipping and counting is done below */ + err = __WriteSampleInt(self, (int) tmp, 24); + } + if (err != __TWO_SUCCESS) return err; + } + + return __TWO_SUCCESS; +} + + +static int CloseWav(WAVEFILEOUT* self) +{ + unsigned int riffSize_le = 0; + unsigned int dataSize_le = 0; + TWO_UINT64 riffSize64 = 0; + TWO_UINT64 dataSize64 = 0; + TWO_UINT64 sampleCount64 = 0; /* nr of samples in the WAVE sense: 1 sample are all pcm samples of all channels of one time slice */ + int mustWriteRF64 = 0; + + if (!self) return __TWO_ERROR; + + /* check for 4 GB (switch to RF64) */ + if ( self->dataSize > self->dataSizeLimit ) { + /* when we exceed 4 GB: switch from std wave header to RF64 header */ + mustWriteRF64 = 1; + } + + /* calc header values */ + if (mustWriteRF64 == 0) { + /* write padding byte if dataSize is uneven */ + int pad = 0; + if (self->dataSize % 2 > 0) { + char tmp= 0x00; + fwrite(&tmp, sizeof(char), 1, self->theFile); + pad = 1; + } + riffSize_le = LittleEndian32(self->dataChunkOffset - 8 + 8 + (unsigned int)self->dataSize + pad); /* sizeof(hdr) - (8 bytes of riff chunk header) + (8 bytes data chunk header) + sizeof(raw-pcm-data) + padding Byte */ + dataSize_le = LittleEndian32((unsigned int)self->dataSize); + } else { + riffSize_le = 0xffffffff; + dataSize_le = 0xffffffff; + riffSize64 = LittleEndian64( self->dataSize + (TWO_UINT64)self->dataChunkOffset ); + dataSize64 = LittleEndian64( self->dataSize ); + sampleCount64 = LittleEndian64( self->dataSize / (TWO_UINT64)self->blockAlign ); + } + + /* now overwrite length/size values in header with the actual/real ones */ + if (mustWriteRF64 == 0) { + /* riffsize32 */ + fseek(self->theFile, 4, SEEK_SET); + fwrite(&riffSize_le, sizeof(riffSize_le), 1, self->theFile); + /* datasize32 */ + fseek(self->theFile, self->dataChunkOffset + 4, SEEK_SET); + fwrite(&dataSize_le, sizeof(dataSize_le), 1, self->theFile); + } else { + unsigned int rf64sig = BigEndian32('R','F','6','4'); + unsigned int ds64sig = BigEndian32('d','s','6','4'); + + /* replace RIFF->RF64 */ + fseek(self->theFile, 0, SEEK_SET); + fwrite(&rf64sig, sizeof(rf64sig), 1, self->theFile); + + /* riffsize32 */ + fseek(self->theFile, 4, SEEK_SET); + fwrite(&riffSize_le, sizeof(riffSize_le), 1, self->theFile); + + /* replace JUNK->ds64 */ + fseek(self->theFile, self->junkChunkOffset, SEEK_SET); + fwrite(&ds64sig, sizeof(ds64sig), 1, self->theFile); + + /* riffSize64, dataSize64, sampleCount64 */ + fseek(self->theFile, self->junkChunkOffset + 8, SEEK_SET); + fwrite(&riffSize64, sizeof(riffSize64), 1, self->theFile); + fwrite(&dataSize64, sizeof(dataSize64), 1, self->theFile); + fwrite(&sampleCount64, sizeof(sampleCount64), 1, self->theFile); + + /* datasize32 */ + fseek(self->theFile, self->dataChunkOffset + 4, SEEK_SET); + fwrite(&dataSize_le, sizeof(dataSize_le), 1, self->theFile); + } + + fclose(self->theFile); + free(self); + + return __TWO_SUCCESS; +} + +#ifdef TWO_SUPPORT_BWF +static int CloseWavBWF( + WAVEFILEOUT* self, + WAVEOUT_LOUDNESSINFO bextData + ) +{ + int wordData; + + if (!self) return __TWO_ERROR; + + if (self->bextChunkOffset) { + /* Offset for Loudness Data in bext-chunk: 8: Chunk-Header, 412:prev.Data */ + fseek(self->theFile, self->bextChunkOffset+8+412, SEEK_SET); + + wordData = LittleEndian32(EncodeLoudness(bextData.loudnessVal)); + fwrite(&wordData, 2, 1, self->theFile); + + wordData = LittleEndian32(EncodeLoudness(bextData.loudnessRange)); + fwrite(&wordData, 2, 1, self->theFile); + + wordData = LittleEndian32(EncodeLoudness(bextData.maxTruePeakLevel)); + fwrite(&wordData, 2, 1, self->theFile); + + wordData = LittleEndian32(EncodeLoudness(bextData.maxMomentaryLoudnes)); + fwrite(&wordData, 2, 1, self->theFile); + + wordData = LittleEndian32(EncodeLoudness(bextData.maxShortTermLoudness)); + fwrite(&wordData, 2, 1, self->theFile); + } + + return CloseWav(self); +} +#endif + +/*------------- local subs ----------------*/ + +static __inline unsigned int BigEndian32(char a, char b, char c, char d) +{ +#ifdef __TWO_LE + return + (unsigned int) d << 24 | + (unsigned int) c << 16 | + (unsigned int) b << 8 | + (unsigned int) a ; +#else + return + (unsigned int) a << 24 | + (unsigned int) b << 16 | + (unsigned int) c << 8 | + (unsigned int) d ; +#endif +} + + +static __inline unsigned int LittleEndian32(unsigned int v) +{ +#ifdef __TWO_LE + return v; +#else + return + (v & 0x000000FF) << 24 | + (v & 0x0000FF00) << 8 | + (v & 0x00FF0000) >> 8 | + (v & 0xFF000000) >> 24 ; +#endif +} + + +/* signed version of the above */ +static __inline unsigned int LittleEndian32s(int v) +{ +#ifdef __TWO_LE + return v; +#else + return + (v & 0x000000FF) << 24 | + (v & 0x0000FF00) << 8 | + (v & 0x00FF0000) >> 8 | + (v & 0xFF000000) >> 24 ; +#endif +} + + +static __inline short LittleEndian16(short v) +{ +#ifdef __TWO_LE + return v; +#else + return ((v << 8) & 0xFF00) | ((v >> 8) & 0x00FF); +#endif +} + +static __inline TWO_UINT64 LittleEndian64(TWO_UINT64 v) +{ +#ifdef __TWO_LE + return v; +#else + return + (v & 0x00000000000000FF) << 56 | + (v & 0x000000000000FF00) << 40 | + (v & 0x0000000000FF0000) << 24 | + (v & 0x00000000FF000000) << 8 | + (v & 0x000000FF00000000) >> 8 | + (v & 0x0000FF0000000000) >> 24 | + (v & 0x00FF000000000000) >> 40 | + (v & 0xFF00000000000000) >> 56 ; +#endif +} + +#ifdef TWO_SUPPORT_BWF +static unsigned int EncodeLoudness(float x) +{ + int s = (x>0)-(x<0); + return (int)( x*100.0f + s*0.5f ); +} +#endif + +static __inline int __dataSizeChk( WAVEFILEOUT* self, int newbytes ) +{ + if (!self) return __TWO_ERROR; + + if ( (self->dataSize + ((TWO_UINT64)newbytes) ) > self->dataSizeLimit64 ) { + return __TWO_ERROR; + } + + return __TWO_SUCCESS; +} + +#endif /* __TINYWAVEOUT_C_H__ */ + + + diff --git a/lib_lc3plus/tns_coder_fx.c b/lib_lc3plus/tns_coder_fx.c new file mode 100644 index 000000000..640e246cc --- /dev/null +++ b/lib_lc3plus/tns_coder_fx.c @@ -0,0 +1,378 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static void Parcor2Index(const Word16 parCoeff[] /*Q15*/, Word16 index[], Word16 order); +static void Index2Parcor(const Word16 index[], Word16 parCoeff[], Word16 order); +static Word32 FIRLattice(Word16 order, const Word16 *parCoeff /*Q15*/, Word32 *state, Word32 x /* Q0 */); + +/*************************************************************************/ + +void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cutoff_idx, Word16 order[], + Word16 *numfilters, Word16 enable_lpc_weighting, Word16 nSubdivisions, Word16 frame_dms, + Word16 maxLen, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif + , Word16 near_nyquist_flag +) +{ + Dyn_Mem_Deluxe_In(Word16 * tmpbuf; Word32 * rxx, epsP, *state, L_tmp, *A, predictionGain, alpha; Word16 * RC, inv; + Word16 n, n2, headroom, shift, tmp, shifts, facs, facs_e, stopfreq, xLen, maxOrder; + Word16 startfreq[TNS_NUMFILTERS_MAX]; const Word16 *subdiv_startfreq, *subdiv_stopfreq; + Counter i, j, iSubdivisions, lag; Word8 * LevinsonBuffer;); + + /* Buffer alignment */ + tmpbuf = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN */ + + rxx = (Word32 *)scratchAlign(tmpbuf, sizeof(*tmpbuf) * maxLen); /* Size = 4 * (MAXLAG + 1) = 36 bytes */ + + state = (Word32 *)scratchAlign(rxx, sizeof(*rxx) * (MAXLAG + 1)); /* Size = 4 * MAXLAG = 32 bytes */ + + A = (Word32 *)scratchAlign(state, sizeof(*state) * MAXLAG); /* Size = 4 * (MAXLAG + 1) = 36 bytes */ + + RC = (Word16 *)scratchAlign(A, sizeof(*A) * (MAXLAG + 1)); /* Size = 2 * MAXLAG = 16 bytes */ + + LevinsonBuffer = (Word8 *)scratchAlign(RC, sizeof(*RC) * (MAXLAG)); /* Size = 4 * (M_LTPF + 1) = 100 bytes */ + + /* Init */ + *bits = 0; + move16(); + maxOrder = MAXLAG; + move16(); + *numfilters = 1; + move16(); + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + xLen = BW_cutoff_bin_all_HR[BW_cutoff_idx]; + } + else +#endif + { + xLen = BW_cutoff_bin_all[BW_cutoff_idx]; + } + move16(); + + SWITCH (frame_dms) + { + case 25: + startfreq[0] = 3; + move16(); + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + subdiv_startfreq = tns_subdiv_startfreq_2_5ms_HR[BW_cutoff_idx - 4]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq_2_5ms_HR[BW_cutoff_idx - 4]; + move16(); + } + else +#endif + { + subdiv_startfreq = tns_subdiv_startfreq_2_5ms[BW_cutoff_idx]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq_2_5ms[BW_cutoff_idx]; + move16(); + } + xLen = shr_pos(xLen, 2); + maxOrder = 4; + move16(); + BREAK; + case 50: + startfreq[0] = 6; + move16(); + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + subdiv_startfreq = tns_subdiv_startfreq_5ms_HR[BW_cutoff_idx - 4]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq_5ms_HR[BW_cutoff_idx - 4]; + move16(); + } + else +#endif + { + subdiv_startfreq = tns_subdiv_startfreq_5ms[BW_cutoff_idx]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq_5ms[BW_cutoff_idx]; + move16(); + } + xLen = shr_pos(xLen, 1); + maxOrder = 4; + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + startfreq[0] = 9; + move16(); + subdiv_startfreq = tns_subdiv_startfreq_7_5ms[BW_cutoff_idx]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq_7_5ms[BW_cutoff_idx]; + move16(); + tmp = shr_pos(xLen, 2); + xLen = add(tmp, add(tmp, tmp)); + maxOrder = 8; + BREAK; +#endif + default: /* 100 */ + startfreq[0] = 12; + move16(); + +#ifdef ENABLE_HR_MODE + if (hrmode) + { + subdiv_startfreq = tns_subdiv_startfreq_HR[BW_cutoff_idx - 4]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq_HR[BW_cutoff_idx - 4]; + move16(); + } + else +#endif + { + subdiv_startfreq = tns_subdiv_startfreq[BW_cutoff_idx]; + move16(); + subdiv_stopfreq = tns_subdiv_stopfreq[BW_cutoff_idx]; + move16(); + } + BREAK; + } + + IF (sub(BW_cutoff_idx, 3) >= 0 && frame_dms >= 50) + { + *numfilters = 2; + startfreq[1] = shr_pos(xLen, 1); + } + + basop_memset(state, 0, MAXLAG * sizeof(*state)); + + FOR (j = 0; j < *numfilters; j++) + { + basop_memset(rxx, 0, (maxOrder + 1) * sizeof(*rxx)); + + FOR (iSubdivisions = 0; iSubdivisions < nSubdivisions; iSubdivisions++) + { + n = sub(subdiv_stopfreq[nSubdivisions * j + iSubdivisions], + subdiv_startfreq[nSubdivisions * j + iSubdivisions]); + + /*norms[iFilter][iSubdivisions] = norm2FLOAT(pSpectrum+iStartLine, iEndLine-iStartLine);*/ + headroom = getScaleFactor32_lc3plus(x + subdiv_startfreq[nSubdivisions * j + iSubdivisions], n); + + /* Calculate norm of spectrum band */ + L_tmp = Norm32Norm(x + subdiv_startfreq[nSubdivisions * j + iSubdivisions], headroom, n, &shift); + + /* Rounding to avoid overflow when computing the autocorrelation below */ + tmp = sub(norm_l(L_tmp), 1); + L_tmp = L_shl(L_tmp, tmp); + shift = sub(shift, tmp); + L_tmp = L_add(L_tmp, 0x8000); + L_tmp = L_and(L_tmp, 0x7FFF0000); + + IF (L_tmp == 0) + { + rxx[0] = 0x7FFFFFFF; + move32(); + basop_memset(&rxx[1], 0, (maxOrder) * sizeof(*rxx)); + BREAK; + } + + /* get pre-shift for autocorrelation */ + tmp = sub(shift, norm_l(L_tmp)); /* exponent for normalized L_tmp */ + tmp = shr_pos(sub(1, tmp), 1); /* pre-shift to apply before autocorrelation */ + shifts = s_min(tmp, headroom); + + /* calc normalization factor */ + facs_e = shl_pos(sub(tmp, shifts), 1); + + SWITCH (frame_dms) + { + case 25: facs_e = add(facs_e, 1); BREAK; + case 50: facs_e = add(facs_e, 1); BREAK; +#ifdef CR8_G_ADD_75MS + case 75: BREAK; +#endif + case 100: BREAK; + } + + tmp = sub(1, shl_pos(tmp, 1)); /* exponent of autocorrelation */ + L_tmp = L_shl(L_tmp, sub(shift, tmp)); /* shift L_tmp to that exponent */ + /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ + facs = div_s(0x2000, round_fx(L_tmp)); /* L_tmp is >= 0x2000000 */ + + FOR (i = 0; i < n; i++) + { + tmpbuf[i] = round_fx_sat(L_shl_sat(x[subdiv_startfreq[nSubdivisions * j + iSubdivisions] + i], shifts)); + move16(); + } + + FOR (lag = 0; lag <= maxOrder; lag++) + { + n2 = sub(n, lag); + L_tmp = L_deposit_l(0); + FOR (i = 0; i < n2; i++) + { + L_tmp = L_mac0(L_tmp, tmpbuf[i], tmpbuf[i + lag]); + } + if (lag != 0) + L_tmp = Mpy_32_32_lc3plus(L_tmp, tnsAcfWindow_lc3plus[lag - 1]); + + L_tmp = Mpy_32_16_lc3plus(L_tmp, facs); + L_tmp = L_shl(L_tmp, facs_e); + + rxx[lag] = L_add(rxx[lag], L_tmp); + move32(); + } + } + + /* Levinson-Durbin */ + processLevinson_fx(A, rxx, maxOrder, RC, &epsP, LevinsonBuffer); + + /* Prediction Gain */ + shift = norm_l(epsP); + inv = div_s(16383, extract_h(L_shl_pos(epsP, shift))); + predictionGain = Mpy_32_32_lc3plus(rxx[0], Mpy_32_16_lc3plus(L_sub(MAX_32, Mpy_32_16_lc3plus(L_shl(epsP, shift), inv)), inv)); + + IF (L_sub(predictionGain, L_shr_pos_pos(0x30000000, shift)) > 0 && near_nyquist_flag == 0) + { + /* If Prediction Gain is low */ + test(); + IF (enable_lpc_weighting != 0 && L_sub(predictionGain, L_shr_pos_pos(0x40000000, shift)) < 0) + { + /* LPC weighting */ + alpha = L_add(0x6CCCCCCD, + Mpy_32_32_lc3plus(0x13333333, L_shl_pos(L_sub(L_shl_pos(predictionGain, shift), 0x30000000), 3))); + L_tmp = alpha; + FOR (i = 1; i < maxOrder; i++) + { + A[i] = Mpy_32_32_lc3plus(A[i], L_tmp); + move32(); + L_tmp = Mpy_32_32_lc3plus(L_tmp, alpha); + } + A[maxOrder] = Mpy_32_32_lc3plus(A[maxOrder], L_tmp); + move32(); + + /* LPC -> RC */ + lpc2rc(A, RC, maxOrder); + } + + /* Reflection Coefficients Quantization */ + Parcor2Index(RC, &indexes[MAXLAG * j], maxOrder); + + /* reduce filter order by truncating trailing zeros */ + i = sub(maxOrder, 1); + WHILE ((i >= 0) && (indexes[MAXLAG * j + i] == INDEX_SHIFT)) + { + i = sub(i, 1); + } + order[j] = add(i, 1); + + // Disable TNS if order is 0: + IF (order[j] == 0) { + // Jump to else statement + goto tns_disabled; + } + /* Count bits */ + L_tmp = L_deposit_l(ac_tns_order_bits[enable_lpc_weighting][order[j] - 1]); + FOR (i = 0; i < order[j]; i++) + { + L_tmp = L_add(L_tmp, L_deposit_l(ac_tns_coef_bits[i][indexes[MAXLAG * j + i]])); + } + *bits = add(*bits, add(2, extract_l(L_shr_pos(L_sub(L_tmp, 1), 11)))); + move16(); + + /* Unquantize Reflection Coefficients */ + Index2Parcor(&indexes[MAXLAG * j], RC, order[j]); + + /* Stop frequency */ + stopfreq = xLen; + move16(); + IF (sub(*numfilters, 2) == 0 && j == 0) + { + stopfreq = startfreq[1]; + } + + /* Filter */ + FOR (i = startfreq[j]; i < stopfreq; i++) + { + x[i] = FIRLattice(order[j], RC, state, x[i]); + move32(); + } + } + ELSE + { +tns_disabled: + /* TNS disabled */ + *bits = add(*bits, 1); + order[j] = 0; + } + } + + Dyn_Mem_Deluxe_Out(); +} + +/*************************************************************************/ + +static void Parcor2Index(const Word16 parCoeff[] /*Q15*/, Word16 index[], Word16 order) +{ + Dyn_Mem_Deluxe_In(Counter i; Word16 iIndex; Word16 x;); + + FOR (i = 0; i < order; i++) + { + move16(); + move16(); + iIndex = 1; + x = parCoeff[i]; + + WHILE ((iIndex < TNS_COEF_RES) && (x > tnsQuantThr[iIndex - 1])) + { + iIndex = add(iIndex, 1); + } + index[i] = sub(iIndex, 1); + move16(); + } + + Dyn_Mem_Deluxe_Out(); +} + +static void Index2Parcor(const Word16 index[], Word16 parCoeff[], Word16 order) +{ + Counter i; + FOR (i = 0; i < order; i++) + { + parCoeff[i] = tnsQuantPts[index[i]]; + move16(); + } +} + +static Word32 FIRLattice(Word16 order, const Word16 *parCoeff /*Q15*/, Word32 *state, Word32 x /* Q0 */) +{ + Dyn_Mem_Deluxe_In(Counter i; Word32 tmpSave, tmp;); + + tmpSave = L_add(x, 0); + + FOR (i = 0; i < order - 1; i++) + { + tmp = L_add(state[i], Mpy_32_16_lc3plus(x, parCoeff[i])); + x = L_add(x, Mpy_32_16_lc3plus(state[i], parCoeff[i])); /* exponent: 31+0 */ + state[i] = tmpSave; + move32(); + tmpSave = L_add(tmp, 0); + } + + /* last stage: only need half operations */ + x = L_add(x, Mpy_32_16_lc3plus(state[order - 1], parCoeff[order - 1])); + state[order - 1] = tmpSave; + move32(); + Dyn_Mem_Deluxe_Out(); + return x; +} + diff --git a/lib_lc3plus/tns_decoder_fx.c b/lib_lc3plus/tns_decoder_fx.c new file mode 100644 index 000000000..b138c4510 --- /dev/null +++ b/lib_lc3plus/tns_decoder_fx.c @@ -0,0 +1,150 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.5 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "functions.h" + +static Word32 IIRLattice(Word16 order, const Word16 *parCoeff, Word32 *state, Word32 x); + +/*************************************************************************/ + +void processTnsDecoder_fx(Word16 rc_idx[], Word32 x[], Word16 xLen, Word16 order[], Word16 *x_e, Word16 BW_stopband_idx, + Word16 frame_dms, Word8 *scratchBuffer +#ifdef ENABLE_HR_MODE + , Word16 hrmode +#endif +) +{ + Dyn_Mem_Deluxe_In( + Word32 *state; + Counter i, j; + Word16 s1, s2, s, *rc, f, stopfreq, BW_stopband; + Word16 numfilters, startfreq[TNS_NUMFILTERS_MAX]; + ); + + state = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = MAXLAG */ + rc = (Word16 *)scratchAlign(state, sizeof(*state) * MAXLAG); /* Size = MAXLAG */ + + numfilters = 1; + +#ifdef ENABLE_HR_MODE + if (hrmode == 1) + { + BW_stopband = BW_cutoff_bin_all_HR[BW_stopband_idx]; move16(); + } + else +#endif + { + BW_stopband = BW_cutoff_bin_all[BW_stopband_idx]; move16(); + } + + SWITCH (frame_dms) + { + case 25: + startfreq[0] = 3; move16(); + BW_stopband = shr_pos(BW_stopband, 2); + BREAK; + case 50: + startfreq[0] = 6; move16(); + BW_stopband = shr_pos(BW_stopband, 1); + BREAK; +#ifdef CR8_G_ADD_75MS + case 75: + startfreq[0] = 9; move16(); + BW_stopband = add(shr_pos(BW_stopband, 2), add(shr_pos(BW_stopband, 2), shr_pos(BW_stopband, 2))); + BREAK; +#endif + case 100: startfreq[0] = 12; BREAK; + } + + IF (sub(BW_stopband_idx, 3) >= 0 && frame_dms >= 50) + { + numfilters = 2; + startfreq[1] = shr_pos(BW_stopband, 1); + } + stopfreq = 0; + + test(); test(); + IF (order[0] > 0 || (sub(numfilters, 2) == 0 && order[1] > 0)) + { + /* Scaling */ + f = startfreq[0]; move16(); + test(); + IF (sub(numfilters, 2) == 0 && order[0] == 0) + { + f = startfreq[1]; move16(); + } + s1 = getScaleFactor32_lc3plus(x, f); + s2 = getScaleFactor32_lc3plus(x + f, sub(xLen, f)); + s = s_min(s1, sub(s2, 7)); /* 7 bits of headroom for IIR filtering */ + *x_e = sub(*x_e, s); + +/* Init Filter */ + basop_memset(state, 0, MAXLAG * sizeof(Word32)); + FOR (i = 0; i < f; i++) + { + x[i] = L_shl(x[i], s); move32(); + } + + FOR (j = 0; j < numfilters; j++) + { + IF (order[j] > 0) + { + /* Unquantize coefficients */ + FOR (i = 0; i < order[j]; i++) + { + rc[i] = tnsQuantPts[rc_idx[j * MAXLAG + i]]; move16(); + } + + /* Stop frequency */ + stopfreq = BW_stopband; move16(); + IF (sub(numfilters, 2) == 0 && j == 0) + { + stopfreq = startfreq[1]; + } + + /* Filter */ + FOR (i = startfreq[j]; i < stopfreq; i++) + { + x[i] = IIRLattice(order[j], rc, state, L_shl(x[i], s)); move32(); + } + } + } + FOR (i = stopfreq; i < xLen; i++) + { + x[i] = L_shl(x[i], s); move32(); + } + } + Dyn_Mem_Deluxe_Out(); +} + +/*************************************************************************/ +/*************************************************************************/ +/*************************************************************************/ + +static Word32 IIRLattice(Word16 order, const Word16 *parCoeff, Word32 *state, Word32 x) +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + + /* first stage: no need to calculate state[order-1] */ + x = L_sub_sat(x, Mpy_32_16_lc3plus(state[order - 1], parCoeff[order - 1])); + + FOR (i = order - 2; i >= 0; i--) + { + x = L_sub(x, Mpy_32_16_lc3plus(state[i], parCoeff[i])); + state[i + 1] = L_add(state[i], Mpy_32_16_lc3plus(x, parCoeff[i])); move32(); + } + + state[0] = x; move32(); + + Dyn_Mem_Deluxe_Out(); + return x; +} + diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4afd38886..4a62de19f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -89,52 +89,6 @@ ivas_error get_channel_config( #endif -/*----------------------------------------------------------------------------------* - * Limiter prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_limiter_open( - IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ -); - -void ivas_limiter_close( - IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ -); - -void ivas_limiter_dec -( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ -); -void ivas_limiter_dec_fx( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ - const Word16 num_channels, /* i : number of channels to be processed */ - const Word16 output_frame, /* i : number of samples per channel in the buffer */ - const Word16 BER_detect, /* i : BER detect flag */ - Word16 q_factor /* i : Q factor of the output samples */ -); -void limiter_process( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const float threshold, /* i : signal amplitude above which limiting starts to be applied */ - const int16_t BER_detect, /* i : BER detect flag */ - int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ -); -void limiter_process_fx( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const Word16 output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const Word32 threshold, /* i : signal amplitude above which limiting starts to be applied */ - const Word16 BER_detect, /* i : BER detect flag */ - Word16 *strong_saturation_cnt, /* i/o: counter of strong saturations (can be NULL) */ - Word16 q_factor /* i : Q factor of output samples */ -); /*----------------------------------------------------------------------------------* * TD decorr. function prototypes *----------------------------------------------------------------------------------*/ @@ -1620,26 +1574,6 @@ void ivas_headTrack_close_fx( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); -void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -); -void Euler2Quat_fx( - const Word32 yaw, /* i : yaw (x) Q22 */ - const Word32 pitch, /* i : pitch (y) Q22 */ - const Word32 roll, /* i : roll (z) Q22 */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -); -float deg2rad( - float degrees -); - -Word32 deg2rad_fx( - Word32 degrees -); - float rad2deg( float radians ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 758d787b1..8b938a7e0 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -239,53 +239,6 @@ void QuatToRotMat_fx( } -void Euler2Quat_fx( - const Word32 yaw, /* i : yaw (x) Q22 */ - const Word32 pitch, /* i : pitch (y) Q22 */ - const Word32 roll, /* i : roll (z) Q22 */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation Q19 */ -) -{ - Word16 cr = getCosWord16( extract_l( L_shr_r( roll, 10 ) ) ); // Q14 - Word16 sr = getSinWord16( extract_l( L_shr_r( roll, 10 ) ) ); - Word16 cp = getCosWord16( extract_l( L_shr_r( pitch, 10 ) ) ); - Word16 sp = getSinWord16( extract_l( L_shr_r( pitch, 10 ) ) ); - Word16 cy = getCosWord16( extract_l( L_shr_r( yaw, 10 ) ) ); - Word16 sy = getSinWord16( extract_l( L_shr_r( yaw, 10 ) ) ); - quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); // Q19 - move32(); - quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); // Q19 - move32(); - quat->y_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( sr, cp ), sy ), Mpy_32_16_1( L_mult0( cr, sp ), cy ) ), 5 ); // Q19 - move32(); - quat->z_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( cr, cp ), sy ), Mpy_32_16_1( L_mult0( sr, sp ), cy ) ), 5 ); // Q19 - move32(); - - return; -} - - -/*------------------------------------------------------------------------- - * deg2rad() - * - * Converts degrees to normalized radians - *------------------------------------------------------------------------*/ -Word32 deg2rad_fx( - Word32 degrees // Q23 -) -{ - WHILE( GE_32( degrees, DEGREE_180 ) ) - { - degrees = L_sub( degrees, DEGREE_360 ); - } - WHILE( LE_32( degrees, -DEGREE_180 ) ) - { - degrees = L_add( degrees, DEGREE_360 ); - } - - return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q23 -} - /*------------------------------------------------------------------------- * rad2deg() * diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 38b2fe524..15381d5bd 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -664,9 +664,16 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx Word32 ***filterTapsRightReal_fx; Word32 ***filterTapsRightImag_fx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 ****filterStatesLeftReal_fx; + Word32 ****filterStatesLeftImag_fx; + Word16 ****Q_filterStatesLeft; +#else Word32 ***filterStatesLeftReal_fx; Word32 ***filterStatesLeftImag_fx; Word16 ***Q_filterStatesLeft; +#endif + Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 74e6070b5..5af21427f 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -55,20 +55,6 @@ typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; typedef Word32 IVAS_REND_LfePanMtx_fx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -typedef struct -{ - Word16 numSamplesPerChannel; - Word16 numChannels; -} IVAS_REND_AudioBufferConfig; -typedef struct -{ - IVAS_REND_AudioBufferConfig config; - Word16 q_factor; - Word16 *pq_fact; - Word32 *data_fx; - // Word16 Q_data; -} IVAS_REND_AudioBuffer; - typedef struct { -- GitLab From 2f2d6f6db7dceb68f322c640a53285cbbe4d954d Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 28 Jan 2025 17:23:03 +1100 Subject: [PATCH 015/329] MSVS changes, not compiling yet --- Makefile | 92 +++-- Workspace_msvc/Workspace_msvc.sln | 6 + Workspace_msvc/decoder.vcxproj | 7 +- Workspace_msvc/lib_com.vcxproj | 8 +- Workspace_msvc/lib_dec.vcxproj | 4 +- Workspace_msvc/lib_enc.vcxproj | 4 +- Workspace_msvc/lib_rend.vcxproj | 9 +- Workspace_msvc/lib_util.vcxproj | 8 +- Workspace_msvc/renderer.vcxproj | 7 +- lib_com/common_api_types.h | 2 +- lib_com/ivas_rotation_com.c | 3 - lib_dec/ivas_binRenderer_internal.c | 473 +++++++++++++++++++++++- lib_isar/isar_stat.h | 2 +- lib_rend/ivas_stat_rend.h | 28 ++ lib_util/split_rend_bfi_file_reader.c | 162 ++++++++ lib_util/split_rend_bfi_file_reader.h | 60 +++ lib_util/split_render_file_read_write.c | 431 +++++++++++++++++++++ lib_util/split_render_file_read_write.h | 99 +++++ 18 files changed, 1348 insertions(+), 57 deletions(-) create mode 100644 lib_util/split_rend_bfi_file_reader.c create mode 100644 lib_util/split_rend_bfi_file_reader.h create mode 100644 lib_util/split_render_file_read_write.c create mode 100644 lib_util/split_render_file_read_write.h diff --git a/Makefile b/Makefile index 4e92bc951..92d3cd3f0 100644 --- a/Makefile +++ b/Makefile @@ -7,23 +7,31 @@ SRC_LIBDEBUG = lib_debug SRC_LIBDEC = lib_dec SRC_LIBENC = lib_enc SRC_LIBREND = lib_rend +SRC_LIBISAR = lib_isar +SRC_LC3PLUS = lib_lc3plus lib_lc3plus/fft SRC_LIBUTIL = lib_util SRC_APP = apps BUILD = build OBJDIR = obj -SRC_DIRS = $(sort -u $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBUTIL) $(SRC_APP)) +INCLUDE_SPLIT = 1 + +SRC_DIRS = $(sort -u $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBISAR) $(SRC_LC3PLUS) $(SRC_LIBUTIL) $(SRC_APP)) # Name of CLI binaries -CLI_APIDEC ?= IVAS_dec -CLI_APIENC ?= IVAS_cod -CLI_APIREND ?= IVAS_rend -LIB_LIBCOM ?= libivascom.a -LIB_LIBDEBUG ?= libivasdebug.a -LIB_LIBDEC ?= libivasdec.a -LIB_LIBENC ?= libivasenc.a -LIB_LIBREND ?= libivasrend.a -LIB_LIBUTIL ?= libivasutil.a +CLI_APIDEC ?= IVAS_dec +CLI_APIENC ?= IVAS_cod +CLI_APIREND ?= IVAS_rend +CLI_APIPOSTREND ?= ISAR_post_rend +LIB_LIBCOM ?= libivascom.a +LIB_LIBDEBUG ?= libivasdebug.a +LIB_LIBDEC ?= libivasdec.a +LIB_LIBENC ?= libivasenc.a +LIB_LIBREND ?= libivasrend.a +LIB_LIBISAR ?= libisar.a +LIB_LC3PLUS ?= liblc3plus.a +LIB_LIBUTIL ?= libivasutil.a + # Default tool settings CC ?= gcc @@ -124,8 +132,14 @@ CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR)) # Source file search paths VPATH = $(SRC_DIRS) -# Filter out files that are not part of the build -EXCLUDED_FILES = +# Split rendering files +SRCS_SPLIT_REND = ivas_CQMFDecoder.c ivas_CQMFEncoder.c ivas_PerceptualModel.c ivas_PredDecoder.c \ + ivas_PredEncoder.c ivas_RMSEnvGrouping.c ivas_MSPred.c ivas_NoiseGen.c \ + ivas_splitRend_lcld_dec.c ivas_splitRend_lcld_enc.c \ + ivas_splitRendererPLC.c ivas_splitRendererPost.c ivas_splitRendererPre.c \ + ivas_splitRenderer_utils.c split_rend_bfi_file_reader.c split_render_file_read_write.c \ + ivas_lcld_tables.c + ############################################################################### @@ -135,27 +149,36 @@ SRCS_LIBDEC = $(foreach DIR,$(SRC_LIBDEC),$(patsubst $(DIR)/%,%,$(wildcard $(D SRCS_LIBENC = $(foreach DIR,$(SRC_LIBENC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) SRCS_LIBREND = $(foreach DIR,$(SRC_LIBREND),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) SRCS_LIBUTIL = $(foreach DIR,$(SRC_LIBUTIL),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) - -SRCS_LIBENC := $(filter-out $(EXCLUDED_FILES),$(SRCS_LIBENC)) +SRCS_LIBISAR = $(foreach DIR,$(SRC_LIBISAR),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) +ifeq "$(INCLUDE_SPLIT)" "1" +SRCS_LC3PLUS = $(foreach DIR,$(SRC_LC3PLUS),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) +else +# SRCS_LIBREND := $(filter-out $(SRCS_SPLIT_REND),$(SRCS_LIBREND)) +# SRCS_LIBUTIL := $(filter-out $(SRCS_SPLIT_REND),$(SRCS_LIBUTIL)) +endif OBJS_LIBCOM = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.o)) OBJS_LIBDEBUG = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEBUG:.c=.o)) OBJS_LIBDEC = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEC:.c=.o)) OBJS_LIBENC = $(addprefix $(OBJDIR)/,$(SRCS_LIBENC:.c=.o)) OBJS_LIBREND = $(addprefix $(OBJDIR)/,$(SRCS_LIBREND:.c=.o)) +OBJS_LIBISAR = $(addprefix $(OBJDIR)/,$(SRCS_LIBISAR:.c=.o)) +OBJS_LC3PLUS = $(addprefix $(OBJDIR)/,$(SRCS_LC3PLUS:.c=.o)) OBJS_LIBUTIL = $(addprefix $(OBJDIR)/,$(SRCS_LIBUTIL:.c=.o)) OBJS_CLI_APIDEC = $(OBJDIR)/decoder.o OBJS_CLI_APIENC = $(OBJDIR)/encoder.o OBJS_CLI_APPREND = $(OBJDIR)/renderer.o +OBJS_CLI_APPPOSTREND = $(OBJDIR)/isar_post_rend.o DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.P) $(SRCS_LIBDEBUG:.c=.P) $(SRCS_LIBDEC:.c=.P) \ - $(SRCS_LIBENC:.c=.P) $(SRCS_LIBUTIL:.c=.P) $(SRCS_LIBREND:.c=.P)) + $(SRCS_LIBENC:.c=.P) $(SRCS_LIBUTIL:.c=.P) $(SRCS_LIBREND:.c=.P) $(SRCS_LIBISAR:.c=.P) \ + $(SRCS_LC3PLUS:.c=.P)) ############################################################################### .PHONY: all clean -all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) +all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(OBJDIR): $(QUIET)mkdir -p $(OBJDIR) @@ -163,37 +186,60 @@ $(OBJDIR): $(LIB_LIBCOM): $(OBJS_LIBCOM) $(QUIET_AR)$(AR) rcs $@ $^ -$(LIB_LIBDEC): $(OBJS_LIBDEC) $(OBJS_LIBREND) +$(LIB_LIBDEC): $(OBJS_LIBDEC) $(OBJS_LIBREND) $(OBJS_LIBISAR) $(QUIET_AR)$(AR) rcs $@ $^ $(LIB_LIBDEBUG): $(OBJS_LIBDEBUG) $(QUIET_AR)$(AR) rcs $@ $^ +$(LIB_LIBISAR): $(OBJS_LIBISAR) + $(QUIET_AR)$(AR) rcs $@ $^ + $(LIB_LIBENC): $(OBJS_LIBENC) $(QUIET_AR)$(AR) rcs $@ $^ -$(LIB_LIBREND): $(OBJS_LIBREND) +$(LIB_LIBREND): $(OBJS_LIBREND) $(OBJS_LIBISAR) + $(QUIET_AR)$(AR) rcs $@ $^ + +$(LIB_LC3PLUS): $(OBJS_LC3PLUS) +ifeq "$(INCLUDE_SPLIT)" "1" $(QUIET_AR)$(AR) rcs $@ $^ +else + +endif # Dependency on OBJS_LIBCOM added temporarily for unit-test to work $(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(OBJS_LIBCOM) $(QUIET_AR)$(AR) rcs $@ $^ -$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) +$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC) -$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) +$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) +ifeq "$(INCLUDE_SPLIT)" "1" + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC) +else $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasdec -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIDEC) +endif -$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) +$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR) +ifeq "$(INCLUDE_SPLIT)" "1" + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -lisar -livasdec -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIREND) +else $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -livasdec -livasutil -livasdebug -livascom $(LDLIBS) -o $(CLI_APIREND) +endif + +$(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBISAR) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) +ifeq "$(INCLUDE_SPLIT)" "1" + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPPOSTREND) -L. -lisar -livasutil -livasdebug -llc3plus -livascom $(LDLIBS) -o $(CLI_APIPOSTREND) +endif -libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBUTIL) +libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(LIB_LIBUTIL) clean: $(QUIET)$(RM) $(OBJS_LIBENC) $(OBJS_LIBDEC) $(DEPS) $(QUIET)$(RM) $(DEPS:.P=.d) $(QUIET)test ! -d $(OBJDIR) || rm -rf $(OBJDIR) - $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) + $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(OBJDIR)/%.o : %.c | $(OBJDIR) $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $< diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index a0783ddbf..5449368aa 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -20,11 +20,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder", "encoder.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderer", "renderer.vcxproj", "{12B4C8A5-1E06-4E30-B443-D1F916F52B47}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_lc3plus", "lib_lc3plus.vcxproj", "{95030B82-70CD-4C6B-84D4-61096035BEA2}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{51160D4C-55C9-4C16-A792-D94507225746}" ProjectSection(SolutionItems) = preProject ..\.clang-format = ..\.clang-format EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_isar", "lib_isar.vcxproj", "{869A305E-D99E-4C3A-BDB3-AA57ABCCE619}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "isar_post_rend", "isar_post_rend.vcxproj", "{12374ADC-0E5C-4FDD-B903-71D572413831}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index ca0d96f44..3ab058c29 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -112,7 +112,7 @@ Neither false false - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -157,6 +157,9 @@ {e822ddaf-0f5f-4cd0-a694-38ae69de74d3} false + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + {2fa8f384-0775-f3b7-f8c3-85209222fc70} false diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9182dd362..130a4a51d 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -59,8 +59,8 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions); EnableFastChecks MultiThreadedDebug @@ -94,7 +94,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -236,6 +236,8 @@ + + diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index d6e4a7c67..dd06dabb7 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -108,7 +108,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 1a706cfeb..c4862738c 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -111,7 +111,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index fa11b23be..5b50ade13 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -108,7 +108,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true @@ -148,7 +148,6 @@ - @@ -196,6 +195,10 @@ {54509728-928b-44d9-a118-a6f92f08b34f} false + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + false + diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 86730b859..ceb342b21 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -55,7 +55,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) false @@ -78,7 +78,7 @@ AnySuitable false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) true @@ -120,6 +120,8 @@ + + @@ -145,6 +147,8 @@ + + diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index 1f95040e1..663e1df3b 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -65,7 +65,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -109,7 +109,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -156,6 +156,9 @@ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} false + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + {2FA8F384-0775-F3B7-F8C3-85209222FC70} false diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 894b940b7..66aeb1721 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -142,7 +142,7 @@ typedef struct _IVAS_ISM_METADATA typedef struct { - float w, x, y, z; + // float w, x, y, z; Word32 w_fx, x_fx, y_fx, z_fx; Word16 q_fact; diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index d50eb4304..20eaf6188 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -42,8 +42,6 @@ #include "debug.h" #endif #include "wmc_auto.h" -#include "prot_fx2.h" -#include "basop_mpy.h" #include "basop_util.h" #include "enh64.h" /*------------------------------------------------------------------------- @@ -253,7 +251,6 @@ Word32 deg2rad_fx( return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q23 } -} float deg2rad( float degrees ) { diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index bc31e32e8..913b7c366 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -490,9 +490,11 @@ static ivas_error ivas_binRenderer_convModuleOpen( IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { /* set the memories to zero */ +#ifndef SPLIT_REND_WITH_HEAD_ROT set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); +#endif IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; @@ -503,10 +505,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( } ELSE { +#ifndef SPLIT_REND_WITH_HEAD_ROT /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; @@ -549,6 +553,21 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + } + } + } +#endif hBinRenderer->hBinRenConvModule = hBinRenConvModule; @@ -1100,6 +1119,112 @@ static void ivas_binaural_obtain_DMX_fx( return; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Allocate and initialize CLDFB fast conv renderer handle + *------------------------------------------------------------------------*/ + +ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) +{ + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand; + ivas_error error; + + error = IVAS_ERR_OK; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } + + if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); + } + + hBinRenderer->rotInCldfb = 1; + hBinRenderer->ivas_format = SBA_FORMAT; + + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); + + convBand = hBinRenderer->max_band; + move16(); + + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + move16(); + + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; + move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } + + hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; + hBinRenderer->hInputSetup->output_config = inConfig; + IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = pMultiBinPoseData->num_poses; + move16(); + } + ELSE + { + hBinRenderer->numPoses = 1; + move16(); + } + + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; + move16(); + + + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* Allocate memories and buffers needed for convolutional module in CICP19 */ + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, 1, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } + + pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); + move32(); + hBinRenderer->hReverb = NULL; + move32(); + hBinRenderer->hEFAPdata = NULL; + move32(); + pCldfbRend->hCldfbRend = hBinRenderer; + move32(); + + return error; +} +#endif + /*------------------------------------------------------------------------- * ivas_binRenderer_open() * @@ -1137,6 +1262,18 @@ ivas_error ivas_binRenderer_open_fx( move16(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } + else + { + hBinRenderer->numPoses = 1; + move16(); + } +#endif /* Declare some common variables needed for renderer */ /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ @@ -1193,11 +1330,17 @@ ivas_error ivas_binRenderer_open_fx( IVAS_OUTPUT_SETUP out_setup; /* Allocate memories and buffers needed for convolutional module in CICP19 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { return error; } - +#endif ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); IF( st_ivas->hoa_dec_mtx == NULL ) @@ -1215,10 +1358,17 @@ ivas_error ivas_binRenderer_open_fx( ELSE { /* Allocate memories and buffers needed for convolutional module */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { return error; } +#endif IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { @@ -1320,10 +1470,18 @@ ivas_error ivas_binRenderer_open_fx( * Close convolution module handle of fastconv binaural renderer *------------------------------------------------------------------------*/ static void ivas_binRenderer_convModuleClose_fx( +#ifdef SPLIT_REND_WITH_HEAD_ROT + BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 num_poses /* i : number of poses */ +#else BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ +#endif ) { Word16 bandIdx, chIdx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 posIdx; +#endif BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; @@ -1361,6 +1519,42 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterTapsRightImag_fx ); hBinRenConvModule->filterTapsRightImag_fx = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) + { + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + { + FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + { + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; + + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; + + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; + } + + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; + + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; + + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; + } + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; + + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; + + free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; + } +#else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) @@ -1384,7 +1578,7 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->Q_filterStatesLeft[bandIdx] ); hBinRenConvModule->Q_filterStatesLeft[bandIdx] = NULL; } - +#endif free( hBinRenConvModule->filterStatesLeftReal_fx ); hBinRenConvModule->filterStatesLeftReal_fx = NULL; @@ -1417,7 +1611,11 @@ void ivas_binRenderer_close_fx( IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); +#else ivas_binRenderer_convModuleClose_fx( hBinRenderer ); +#endif } IF( ( *hBinRenderer )->hReverb != NULL ) @@ -1526,6 +1724,7 @@ void ivas_binaural_add_LFE_fx( ) { Word16 render_lfe, idx_lfe, gain_fx; + Word32 lfe_tc[L_FRAME48k]; IF( st_ivas->hBinRenderer != NULL ) { @@ -1562,15 +1761,15 @@ void ivas_binaural_add_LFE_fx( } FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { - v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); // q_input_fx - 1 + v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 /* copy LFE to left and right channels */ FOR( int idx = 0; idx < output_frame; idx++ ) { - input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx] = L_shl_sat( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx], 1 ); // saturating to keep same q + lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q move32(); - output_fx[0][idx] = L_add_sat( output_fx[0][idx], input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx] ); + output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); move32(); - output_fx[1][idx] = L_add_sat( output_fx[1][idx], input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx] ); + output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); move32(); } } @@ -1580,30 +1779,80 @@ void ivas_binaural_add_LFE_fx( } /*------------------------------------------------------------------------- - * ivas_binRenderer() + * ivas_binRenderer_fx() * * Fastconv binaural renderer main function *-------------------------------------------------------------------------*/ void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, +#endif + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ +#else Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ +#endif + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx, num_poses; + Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif + // to be checked: feasibility with 32 bit buffers Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + push_wmops( "fastconv_binaural_rendering" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + num_poses = hBinRenderer->numPoses; +#endif + /* Compute Convolution */ /* memory reset for the binaural output */ + +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + } + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + mvr2r( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + mvr2r( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } + } +#else FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { FOR( k = 0; k < numTimeSlots; k++ ) @@ -1614,6 +1863,7 @@ void ivas_binRenderer_fx( set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } +#endif /* Head rotation in HOA3 or CICPx */ test(); @@ -1651,7 +1901,12 @@ void ivas_binRenderer_fx( ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); +#else ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); +#endif FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -1659,13 +1914,118 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); +#else Cldfb_RealBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); Cldfb_ImagBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); +#endif + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( pMultiBinPoseData != NULL ) + { + IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) + { + IVAS_QUATERNION Quaternions_rel, Quaternions_abs, *Quaternions_ref; + Word32 Rmat_local[3][3]; + Word16 q_fact_orig; + + IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Quaternions_rel.w_fx = L_negate( 12582912 ); // Q22 + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + q_fact_orig = Quaternions_ref->q_fact; + + Quaternions_ref->w_fx = L_shl( Quaternions_ref->w_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 + Quaternions_ref->x_fx = L_shl( Quaternions_ref->x_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 + Quaternions_ref->y_fx = L_shl( Quaternions_ref->y_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 + Quaternions_ref->z_fx = L_shl( Quaternions_ref->z_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 + + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) + { + /*HOA signal already rotated by DirAC*/ + Quaternions_abs.x_fx = 0; + Quaternions_abs.y_fx = 0; + Quaternions_abs.z_fx = 0; + } + ELSE + { + /*euler*/ + Quat2EulerDegree_fx( *Quaternions_ref, &Quaternions_abs.z_fx, &Quaternions_abs.y_fx, &Quaternions_abs.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + } + + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } + } + Quaternions_rel.x_fx = L_sub( pMultiBinPoseData->relative_head_poses_fx[pos_idx][0], pMultiBinPoseData->relative_head_poses_fx[pos_idx - 1][0] ); + Quaternions_rel.y_fx = L_sub( pMultiBinPoseData->relative_head_poses_fx[pos_idx][1], pMultiBinPoseData->relative_head_poses_fx[pos_idx - 1][1] ); + Quaternions_rel.z_fx = L_sub( pMultiBinPoseData->relative_head_poses_fx[pos_idx][2], pMultiBinPoseData->relative_head_poses_fx[pos_idx - 1][2] ); + Quaternions_abs.x_fx = L_add( Quaternions_abs.x_fx, Quaternions_rel.x_fx ); + Quaternions_abs.y_fx = L_add( Quaternions_abs.y_fx, Quaternions_rel.y_fx ); + Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, Quaternions_rel.z_fx ); + + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + Quaternions_abs.w_fx = L_shl( Quaternions_abs.w_fx, Q7 ); // Q29 + Quaternions_abs.x_fx = L_shl( Quaternions_abs.x_fx, Q7 ); // Q29 + Quaternions_abs.y_fx = L_shl( Quaternions_abs.y_fx, Q7 ); // Q29 + Quaternions_abs.z_fx = L_shl( Quaternions_abs.z_fx, Q7 ); // Q29 + + QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + { + rotateFrame_sd_cldfb( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + else + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } + + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); + + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + } + } + } + } } } } +#endif + /* Obtain the binaural dmx and compute the reverb */ IF( hBinRenderer->hReverb != NULL ) { @@ -1706,12 +2066,99 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + /* Combine first and second parts to generate binaural output signal with room effect */ + v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + } +#else /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in v_add_32( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in +#endif } } } pop_wmops(); return; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_CldfbMultiBinRendProcess() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes, + Word16 *Q_in /* i : LS signals exp */ +) +{ + int16_t slot_idx, ch_idx, idx, pose_idx, i, j; + int16_t sf_idx; + Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) + { + Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + } + } + + if ( ( *pCombinedOrientationData ) != NULL ) + { + if ( ( low_res_pre_rend_rot ) && ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + ( *pCombinedOrientationData )->Quaternions[sf_idx] = ( *pCombinedOrientationData )->Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; + } + } + } + ( *pCombinedOrientationData )->shd_rot_max_order = -1; + } + + ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, Q_in ); + + FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q6, *Q_in ) ); // Q6 + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q6, *Q_in ) ); // Q6 + } + } + } + *Q_in = Q6; + } + + return; +} +#endif \ No newline at end of file diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index e94d23e18..4c3dd12e1 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -229,7 +229,7 @@ typedef struct isar_binaural_head_rot_split_post_rendering_struct typedef struct { int16_t num_poses; - float relative_head_poses[MAX_HEAD_ROT_POSES][3]; + // float relative_head_poses[MAX_HEAD_ROT_POSES][3]; Word32 relative_head_poses_fx[MAX_HEAD_ROT_POSES][3]; /* Q22 */ int16_t dof; int16_t hq_mode; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 15381d5bd..14139c534 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1334,6 +1334,34 @@ typedef struct ivas_binaural_crend_wrapper_struct } CREND_WRAPPER, *CREND_WRAPPER_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Fastconv binaural data structure */ +typedef struct ivas_binaural_rendering_struct +{ + /* Common variables for all modules */ + IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ + EFAP_HANDLE hEFAPdata; /* EFAP structure*/ + Word32 *hoa_dec_mtx; /* pointer to HOA decoder mtx */ /*Q29*/ + int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + int16_t max_band; /* band upto which rendering is performed */ + int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ + int16_t timeSlots; /* number of time slots of binaural renderer */ + int16_t nInChannels; /* number input channels */ + int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ + + /* Convolution module structure */ + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + + /* Variables related to reverberator module */ + Word32 earlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; + REVERB_STRUCT_HANDLE hReverb; + + Word16 numPoses; + +} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; +#endif + /*------------------------------------------------------------------------------------------* * HRTF structures - hrtfs from binary files *------------------------------------------------------------------------------------------*/ diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c new file mode 100644 index 000000000..96b78972f --- /dev/null +++ b/lib_util/split_rend_bfi_file_reader.c @@ -0,0 +1,162 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "split_rend_bfi_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" + +struct SplitRendBFIFileReader +{ + FILE *bfiFile; + int32_t frameCounter; + char *file_path; + bool fileRewind; + bool txtfile; +}; + + +/*-----------------------------------------------------------------------* + * SplitRendBFIFileReader_open() + * + * Allocate and initialize Split Renderer Frameloss file reader + *-----------------------------------------------------------------------*/ + +ivas_error SplitRendBFIFileReader_open( + char *bfiFilePath, /* i : frame loss file name */ + SplitRendBFIFileReader **SplitRendBFIReader /* o : SplitRendBFIFileReader handle */ +) +{ + SplitRendBFIFileReader *self; + FILE *bfiFile; + bool txtfile; + + /* Open bfi file */ + if ( strlen( bfiFilePath ) < 1 ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + bfiFile = fopen( bfiFilePath, "r" ); + + if ( !bfiFile ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + txtfile = ( strcmp( bfiFilePath + strlen( bfiFilePath ) - 4, ".txt" ) ? false : true ); + + self = calloc( sizeof( SplitRendBFIFileReader ), 1 ); + self->bfiFile = bfiFile; + self->frameCounter = 0; + self->file_path = calloc( sizeof( char ), strlen( bfiFilePath ) + 1 ); + strcpy( self->file_path, bfiFilePath ); + self->fileRewind = false; + self->txtfile = txtfile; + + *SplitRendBFIReader = self; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * SplitRendBFIFileReading() + * + * Read values from the bfi file + *-----------------------------------------------------------------------*/ + +ivas_error SplitRendBFIFileReading( + SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ + int16_t *bfi ) +{ + if ( SplitRendBFIReader->txtfile ? 1 != fscanf( SplitRendBFIReader->bfiFile, "%hd", bfi ) : 1 != fread( bfi, sizeof( *bfi ), 1, SplitRendBFIReader->bfiFile ) ) + { + if ( feof( SplitRendBFIReader->bfiFile ) ) + { + rewind( SplitRendBFIReader->bfiFile ); + SplitRendBFIReader->fileRewind = true; + return SplitRendBFIFileReading( SplitRendBFIReader, bfi ); + } + return IVAS_ERR_FAILED_FILE_PARSE; + } + + ( SplitRendBFIReader->frameCounter )++; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * SplitRendBFIationFileReader_close() + * + * Deallocates memory for the Head-Tracking reader + *-----------------------------------------------------------------------*/ + +void SplitRendBFIFileReader_close( + SplitRendBFIFileReader **SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +) +{ + if ( SplitRendBFIReader == NULL || *SplitRendBFIReader == NULL ) + { + return; + } + + fclose( ( *SplitRendBFIReader )->bfiFile ); + free( ( *SplitRendBFIReader )->file_path ); + free( *SplitRendBFIReader ); + *SplitRendBFIReader = NULL; + + return; +} + + +/*-----------------------------------------------------------------------* + * SplitRendBFIFileReader_getFilePath() + * + * + *-----------------------------------------------------------------------*/ + +const char *SplitRendBFIFileReader_getFilePath( + SplitRendBFIFileReader *SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +) +{ + if ( SplitRendBFIReader == NULL ) + { + return NULL; + } + + return SplitRendBFIReader->file_path; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h new file mode 100644 index 000000000..341ef3ed6 --- /dev/null +++ b/lib_util/split_rend_bfi_file_reader.h @@ -0,0 +1,60 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_SR_BFI_FILE_READER_H +#define IVAS_SR_BFI_FILE_READER_H + +#include "common_api_types.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT + +typedef struct SplitRendBFIFileReader SplitRendBFIFileReader; + +ivas_error SplitRendBFIFileReader_open( + char *trajFilePath, /* i : head rotation trajectory file name */ + SplitRendBFIFileReader **SplitRendBFIReader /* o : SplitRendBFIFileReader handle */ +); + +ivas_error SplitRendBFIFileReading( + SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ + int16_t *bfi ); + +void SplitRendBFIFileReader_close( + SplitRendBFIFileReader **SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +); + +const char *SplitRendBFIFileReader_getFilePath( + SplitRendBFIFileReader *SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +); + + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* IVAS_SR_BFI_FILE_READER_H */ diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c new file mode 100644 index 000000000..8a4dea8fd --- /dev/null +++ b/lib_util/split_render_file_read_write.c @@ -0,0 +1,431 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "split_render_file_read_write.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" + + +/*------------------------------------------------------------------------------------------* + * PreProc Macros + *------------------------------------------------------------------------------------------*/ + +#define SPLIT_RENDERER_FRAME_HEADER_LEN ( 12 ) + +/*------------------------------------------------------------------------------------------* + * Type definitions + *------------------------------------------------------------------------------------------*/ + +struct SplitFileReadWrite +{ + FILE *file; + uint32_t delay_ns; +}; + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_reader_open() + * + * open in read mode + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_reader_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + ISAR_SPLIT_REND_CODEC *codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, + int16_t *codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *isar_frame_size_ms, + int32_t *sampling_rate, + int16_t *lc3plus_highres +#endif +) +{ + SplitFileReadWrite *hSplitRendFileReadWrite; + size_t header_len, h; + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; + char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; + + if ( ( hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering writer\n" ) ); + } + + hSplitRendFileReadWrite->file = fopen( filename, "rb" ); + if ( hSplitRendFileReadWrite->file == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nCould not open split rend metadata file %s\n", filename ) ); + } + + header_len = strlen( header ); + + /*read frame header*/ + for ( h = 0; h < header_len; h++ ) + { + if ( fread( &header_read[h], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + } + + if ( strncmp( header_read, header, header_len ) ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nError split rend bitstream main header mismatch\n" ) ); + } + + fread( &hSplitRendFileReadWrite->delay_ns, sizeof( uint32_t ), 1, hSplitRendFileReadWrite->file ); + + /* read codec signalling */ + if ( fread( codec, sizeof( *codec ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + /* read pose correction signalling */ + if ( fread( poseCorrection, sizeof( *poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + /* read transport codec frame size signalling */ + if ( fread( codec_frame_size_ms, sizeof( *codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* read isar bitstream frame size signalling */ + if ( fread( isar_frame_size_ms, sizeof( *isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + /* read sampling rate signalling */ + if ( fread( sampling_rate, sizeof( *sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + /* read LC3plus highres signalling */ + if ( fread( lc3plus_highres, sizeof( *lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } +#endif + + *hhSplitRendFileReadWrite = hSplitRendFileReadWrite; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_writer_open() + * + * open in write mode + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_writer_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + const int16_t delayNumSamples, + const int32_t delayTimeScale, + ISAR_SPLIT_REND_CODEC codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, + int16_t codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, + const int32_t sampling_rate, + const int16_t lc3plus_highres +#endif +) +{ + SplitFileReadWrite *hSplitRendFileReadWrite; + size_t header_len, h; + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; + + if ( filename == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering writer\n" ) ); + } + + hSplitRendFileReadWrite->file = fopen( filename, "wb" ); + if ( hSplitRendFileReadWrite->file == NULL ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + header_len = strlen( header ); + + /* write frame header */ + for ( h = 0; h < header_len; h++ ) + { + if ( fwrite( &header[h], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_END_OF_FILE; + } + } + hSplitRendFileReadWrite->delay_ns = (int32_t) ( (float) delayNumSamples * 1000000000.0f / (float) delayTimeScale ); + fwrite( &hSplitRendFileReadWrite->delay_ns, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ); + + /* Write codec signalling */ + if ( fwrite( &codec, sizeof( codec ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + /* Write pose correction signalling */ + if ( fwrite( &poseCorrection, sizeof( poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + /* Write transport codec frame size signalling */ + if ( fwrite( &codec_frame_size_ms, sizeof( codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* Write isar bit stream frame size signalling */ + if ( fwrite( &isar_frame_size_ms, sizeof( isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + /* Write sampling rate signalling */ + if ( fwrite( &sampling_rate, sizeof( sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + /* Write LC3plus highres signalling */ + if ( fwrite( &lc3plus_highres, sizeof( lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } +#endif + + *hhSplitRendFileReadWrite = hSplitRendFileReadWrite; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_reader_writer_close() + * + * + *-----------------------------------------------------------------------------------------*/ + +void split_rend_reader_writer_close( + SplitFileReadWrite **hhSplitRendFileReadWrite ) +{ + if ( ( *hhSplitRendFileReadWrite ) != NULL ) + { + if ( ( *hhSplitRendFileReadWrite )->file != NULL ) + { + fclose( ( *hhSplitRendFileReadWrite )->file ); + ( *hhSplitRendFileReadWrite )->file = NULL; + } + + free( *hhSplitRendFileReadWrite ); + *hhSplitRendFileReadWrite = NULL; + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_write_bitstream_to_file() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_write_bitstream_to_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ) +{ + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME"; + size_t header_len, i, num_bytes; + uint8_t version = 0; + + if ( hSplitRendFileReadWrite == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + if ( hSplitRendFileReadWrite->file == NULL ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + header_len = strlen( header ); + + /* write frame header */ + for ( i = 0; i < header_len; i++ ) + { + if ( fwrite( &header[i], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + } + + /* Write versioning signalling */ + if ( fwrite( &version, 1, 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + /* write num bytes */ + if ( fwrite( bits_written, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + num_bytes = ( *bits_written + 7 ) >> 3; + if ( fwrite( bits, sizeof( uint8_t ), num_bytes, hSplitRendFileReadWrite->file ) != num_bytes ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + *bits_read = 0; + *bits_written = 0; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_read_bits_from_file() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ) +{ + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME"; + char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; + int32_t header_len, i, num_bytes, bit_len = 0; + uint8_t version; + + if ( hSplitRendFileReadWrite == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + if ( hSplitRendFileReadWrite->file == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + header_len = (int32_t) strlen( header ); + + /* read frame header */ + for ( i = 0; i < header_len; i++ ) + { + if ( fread( &header_read[i], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_END_OF_FILE; + } + } + + if ( strncmp( header_read, header, header_len ) ) + { + fprintf( stderr, "Error bitstream frame header mismatch\n" ); + return IVAS_ERR_FAILED_FILE_READ; + } + + /* read versioning signalling */ + if ( fread( &version, 1, 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + if ( version != 0 ) + { + fprintf( stderr, "Error bitstream version mismatch\n" ); + return IVAS_ERR_FAILED_FILE_READ; + } + + /* write num bytes */ + if ( fread( &bit_len, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + num_bytes = ( bit_len + 7 ) >> 3; + + if ( fread( bits, sizeof( uint8_t ), num_bytes, hSplitRendFileReadWrite->file ) != (uint32_t) num_bytes ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + for ( i = 0; i < ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ; i++ ) + { + bits[num_bytes + i] = 0; + } + + *bits_read = 0; + *bits_written = bit_len; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_read_pre_rend_delay_ns() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_read_pre_rend_delay_ns( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint32_t *delay_ns ) +{ + if ( hSplitRendFileReadWrite == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + *delay_ns = hSplitRendFileReadWrite->delay_ns; + + return IVAS_ERR_OK; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h new file mode 100644 index 000000000..1d6529ef2 --- /dev/null +++ b/lib_util/split_render_file_read_write.h @@ -0,0 +1,99 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef SPLIT_RENDER_FILE_READ_WRITE_H +#define SPLIT_RENDER_FILE_READ_WRITE_H + +#include "common_api_types.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT + +typedef struct SplitFileReadWrite SplitFileReadWrite; + +/* Allocates and initializes a a split renderer reader instance */ +ivas_error split_rend_reader_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + ISAR_SPLIT_REND_CODEC *codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, + int16_t *codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *isar_frame_size_ms, + int32_t *sampling_rate, + int16_t *lc3plus_highres +#endif +); + + +/* Allocates and initializes a a split renderer writer instance */ +ivas_error split_rend_writer_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + const int16_t delayNumSamples, + const int32_t delayTimeScale, + ISAR_SPLIT_REND_CODEC codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, + int16_t codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, + const int32_t sampling_rate, + const int16_t lc3plus_highres +#endif +); + + +/* Closes the split renderer reader/writer and deallocates memory */ +void split_rend_reader_writer_close( + SplitFileReadWrite **hhSplitRendFileReadWrite ); + +/*write split rend coded bitstream to file */ +ivas_error split_rend_write_bitstream_to_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ); + +/* read split rend coded bits from file */ +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ); + +/* read split pre rend delay */ +ivas_error split_rend_read_pre_rend_delay_ns( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint32_t *delay_ns ); + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* SPLIT_RENDER_FILE_READ_WRITE_H */ -- GitLab From 8f9f26cbe5fc748f3b85153f309129c4275a5156 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 29 Jan 2025 01:15:27 +1100 Subject: [PATCH 016/329] lib decoder split rendering BASOP updates --- apps/decoder.c | 76 ++-- lib_dec/lib_dec.h | 53 ++- lib_dec/lib_dec_fx.c | 687 ++++++++++++++++++++++++++++++++++- lib_isar/isar_stat.h | 2 +- lib_isar/lib_isar_pre_rend.c | 13 +- lib_isar/lib_isar_pre_rend.h | 1 - 6 files changed, 779 insertions(+), 53 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 65c949ace..77126067e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -181,7 +181,7 @@ int main( #endif #ifdef SPLIT_REND_WITH_HEAD_ROT - splitRendBits.bits_buf = splitRendBitsBuf; + splitRendBits.bits_buf = splitRendBitsBuf; #endif /*------------------------------------------------------------------------------------------* @@ -1463,14 +1463,14 @@ static void usage_dec( void ) *---------------------------------------------------------------------*/ static ivas_error initOnFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: */ - const DecArguments arg, /* i : */ - const int16_t numInitialBadFrames, /* i : */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: */ + const DecArguments arg, /* i : */ + const int16_t numInitialBadFrames, /* i : */ #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t *numOutSamples, /* i/o: */ int16_t *vec_pos_len, /* i/o: */ #else - const uint16_t numOutSamples, /* i : */ + const uint16_t numOutSamples, /* i : */ #endif int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ @@ -1484,7 +1484,7 @@ static ivas_error initOnFirstGoodFrame( uint16_t *pNumObj, /* o : */ SplitFileReadWrite **splitRendWriter #else - uint16_t *pNumObj /* o : */ + uint16_t *pNumObj /* o : */ #endif ) { @@ -1614,12 +1614,12 @@ static ivas_error initOnFirstGoodFrame( if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) { #endif - /* Open audio writer and write all previously skipped bad frames now that frame size is known */ - if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); - return error; - } + /* Open audio writer and write all previously skipped bad frames now that frame size is known */ + if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); + return error; + } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -1661,20 +1661,20 @@ static ivas_error initOnFirstGoodFrame( #else if ( *pRemainingDelayNumSamples < numOutSamples ) #endif - { + { #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) #else if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) #endif - { - fprintf( stderr, "\nOutput audio file writer error\n" ); - return error; + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + return error; + } + *pRemainingDelayNumSamples = 0; } - *pRemainingDelayNumSamples = 0; - } - else - { + else + { #ifdef SPLIT_REND_WITH_HEAD_ROT *pRemainingDelayNumSamples -= *numOutSamples; #else @@ -2034,7 +2034,7 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { - if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (Word16 *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2053,12 +2053,12 @@ static ivas_error decodeG192( if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) #endif - { - fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; + { + fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -2123,19 +2123,19 @@ static ivas_error decodeG192( if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) { #endif - if ( delayNumSamples < nOutSamples ) - { - if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + if ( delayNumSamples < nOutSamples ) { - fprintf( stderr, "\nOutput audio file writer error\n" ); - goto cleanup; + if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + goto cleanup; + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= nOutSamples; } - delayNumSamples = 0; - } - else - { - delayNumSamples -= nOutSamples; - } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 28fbe71b9..0b20e64f9 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -144,6 +144,46 @@ ivas_error IVAS_DEC_GetSamples( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error IVAS_DEC_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +); + +/*! r: decoder error code */ +ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ +#endif + Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + Word16 *pLc3plusHighRes /* o: pointer to LC3plus High-Res setting */ +#endif +); + +/*! r: decoder error code */ +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + Word32 *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ + Word32 *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ + IVAS_AUDIO_CONFIG *audio_config, /* o : audio configuration */ + Word16 *nOutSamples /* o : number of samples per channel written to output buffer */ +); + +int16_t IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle */ +); +int16_t IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); +#endif /*! r: error code */ ivas_error IVAS_DEC_GetObjectMetadata( @@ -165,7 +205,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ - const Word16 subframe_idx /* i : subframe index */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 subframe_idx, /* i : subframe index */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +#else + const Word16 subframe_idx /* i : subframe index */ +#endif ); /*! r: error code */ @@ -242,6 +287,12 @@ ivas_error IVAS_DEC_EnableVoIP( const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*! r: error code */ +ivas_error IVAS_DEC_EnableSplitRendering( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); +#endif ivas_error IVAS_DEC_SetRenderFramesize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7e2e69ec4..8e1edc657 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -40,6 +40,8 @@ #include "prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" +#include "isar_prot.h" +#include "lib_isar_pre_rend.h" #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" @@ -117,7 +119,11 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, cons static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); - +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); +static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); +#endif /*---------------------------------------------------------------------* * IVAS_DEC_Open() @@ -275,6 +281,46 @@ ivas_error IVAS_DEC_Open( return IVAS_ERR_WRONG_PARAMS; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------------* + * isar_set_split_rend_setup() + * + * Setup IVAS split rendering + *-------------------------------------------------------------------------*/ + +static ivas_error isar_set_split_rend_setup( + ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, + const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +{ + splitRendBits->bits_read = 0; + splitRendBits->bits_written = 0; + splitRendBits->buf_len = ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES; + splitRendBits->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRendBits->pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + splitRendBits->codec_frame_size_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + splitRendBits->isar_frame_size_ms = 0; + splitRendBits->lc3plus_highres = 0; +#endif + + if ( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } + + ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS ); + + if ( hCombinedOrientationData != NULL ) + { + isar_set_split_rend_ht_setup_fx( &hSplitBinRend->splitrend, hCombinedOrientationData->Quaternions, hCombinedOrientationData->Rmat_fx ); + } + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* * init_decoder_config() @@ -297,6 +343,10 @@ static void init_decoder_config( hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain_fx = 0; // Q15 hDecoderConfig->Opt_tsm = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hDecoderConfig->Opt_Limiter = 1; + move16(); +#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; @@ -343,6 +393,11 @@ void IVAS_DEC_Close( ( *phIvasDec )->hVoIP = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* destroy Split binaural renderer (ISAR) handle */ + ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); +#endif + IF( ( *phIvasDec )->st_ivas ) { ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); @@ -528,12 +583,31 @@ ivas_error IVAS_DEC_Configure( move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hDecoderConfig->Opt_Headrotation = TRUE; + move16(); + } +#endif + /* Set decoder parameters to initial values */ IF( NE_32( ( error = ivas_init_decoder_front( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* create ISAR handle */ + IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( ( error = ivas_create_handle_isar( &st_ivas->hSplitBinRend ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for ISAR handle" ); + } + } +#endif + if ( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { hIvasDec->st_ivas->ivas_format = MONO_FORMAT; @@ -555,6 +629,43 @@ ivas_error IVAS_DEC_Configure( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_EnableSplitRendering( ) + * + * Intitialize Split rendering + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_EnableSplitRendering( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + DECODER_CONFIG_HANDLE hDecoderConfig; + ivas_error error; + + error = IVAS_ERR_OK; + move32(); + + + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; + move32(); + + hDecoderConfig->Opt_Headrotation = 1; + move16(); + hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + move32(); + + hDecoderConfig->Opt_Limiter = 0; + move16(); + + return error; +} +#endif /*---------------------------------------------------------------------* * get_render_framesize_ms( ) @@ -599,6 +710,16 @@ ivas_error IVAS_DEC_SetRenderFramesize( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + IF( hIvasDec->st_ivas->hExtOrientationData != NULL ) + { + hIvasDec->st_ivas->hExtOrientationData->num_subframes = (Word16) render_framesize; + } + IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) + { + hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (Word16) render_framesize; + } + + hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; move16(); @@ -1006,6 +1127,21 @@ ivas_error IVAS_DEC_GetSamples( { return error; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*----------------------------------------------------------------* + * Binaural split rendering setup + *----------------------------------------------------------------*/ + + IF( EQ_32( hIvasDec->st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasDec->st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) + { + isar_set_split_rend_ht_setup_fx( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat_fx ); + } + } +#endif + hIvasDec->updateOrientation = false; move16(); } @@ -1168,6 +1304,276 @@ return IVAS_ERR_OK; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSplitBinauralBitstream( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error +IVAS_DEC_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + Word16 *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +) +{ + Decoder_Struct *st_ivas; + AUDIO_CONFIG output_config; + Word32 output_Fs; + Word32 *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + Word32 output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + FOR( Word32 i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + FOR( Word32 j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + FOR( Word32 k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural[i][j][k] = 0; + Cldfb_ImagBuffer_Binaural[i][j][k] = 0; + move32(); + move32(); + } + } + } + Word16 numSamplesPerChannelToDecode; + Word16 i, j; + ivas_error error; + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + Word16 max_band; + Word16 pcm_out_flag; + Word16 td_input; + Word16 numPoses; + Word16 slots_rendered, slots_rendered_new; + Word16 ro_md_flag; + IVAS_QUATERNION Quaternion; + + error = IVAS_ERR_OK; + st_ivas = hIvasDec->st_ivas; + output_config = st_ivas->hDecoderConfig->output_config; + output_Fs = st_ivas->hDecoderConfig->output_Fs; + numSamplesPerChannelToDecode = (Word16) ( output_Fs / FRAMES_PER_SEC ); // TODO remove division + + *needNewFrame = false; + hSplitBinRend = st_ivas->hSplitBinRend; + + if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + set32_fx( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + + numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + + IF( NE_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) && + ( EQ_32( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || + EQ_16( hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) + { + numSamplesPerChannelToDecode = (Word16) ( output_Fs / FRAMES_PER_SEC ); // TODO remove division + numSamplesPerChannelToDecode = (Word16) ( numSamplesPerChannelToDecode / MAX_PARAM_SPATIAL_SUBFRAMES ); // TODO remove division + numSamplesPerChannelToDecode *= (Word16) st_ivas->hDecoderConfig->render_framesize; + move16(); + move16(); + } + + IF( EQ_16( IVAS_DEC_is_split_rendering_enabled( hIvasDec ), 0 ) ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + IF( st_ivas->hTcBuffer == NULL || hIvasDec->hasBeenFedFrame ) + { + slots_rendered = 0; + } + ELSE + { + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // TODO remove division + } + else + { + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + } + } + + + /* Decode and render */ + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* change buffer layout */ + FOR( i = 0; i < numSamplesPerChannelToDecode; ++i ) + { + FOR( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) + { + output[j][i] = (Word32) pcmBuf[add( i_mult( i, i_mult( BINAURAL_CHANNELS, numPoses ) ), j )]; + move32(); + } + } + + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + pOutput[i] = output[i]; + move32(); + } + + IF( st_ivas->hTcBuffer == NULL ) + { + slots_rendered_new = 0; + move16(); + } + ELSE + { + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // TODO remove division + } + ELSE + { + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; // TODO remove division + } + } + + FOR( i = 0; i < i_mult( BINAURAL_CHANNELS, numPoses ); ++i ) + { + FOR( j = slots_rendered; j < slots_rendered_new; ++j ) + { + Copy32( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[i][j], Cldfb_RealBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + Copy32( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[i][j], Cldfb_ImagBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + } + } + + max_band = (Word16) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); // TODO remove division + move16(); + pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; + + IF( st_ivas->hBinRendererTd != NULL ) + { + ro_md_flag = 1; + move16(); + } + ELSE + { + ro_md_flag = 0; + move16(); + } + + IF( st_ivas->hHeadTrackData != NULL ) + { + Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + } + ELSE + { + Quaternion.w_fx = -12582912; + Quaternion.x_fx = 0; + Quaternion.y_fx = 0; + Quaternion.z_fx = 0; + } + Word16 q1 = 31, q2 = 31, Q_buff; + Word16 Q_out[CLDFB_NO_COL_MAX]; + Q_out[0] = 31; + Word16 num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + for ( i = 0; i < 16; i++ ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + q1 = s_min( q1, L_norm_arr( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + q2 = s_min( q2, L_norm_arr( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + } + } + Q_buff = s_min( q1, q2 ); + for ( i = 0; i < 16; i++ ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + scale_sig32( Cldfb_RealBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + } + } + Q_buff = Q_buff + Q6; + + IF( NE_16( td_input, 0 ) ) + { + /*TD input*/ + /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ + /* local float2fix, to be removed */ + num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + Q_out[0] = s_min( Q_out[0], L_norm_arr( output[i], L_FRAME48k ) ); + } + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + scale_sig32( output[i], Q_out[0], L_FRAME48k ); + } + } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, +#endif + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + + { + return error; + } + + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ + IF( pcm_out_flag ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + scale_sig32( pOutput[j], numSamplesPerChannelToDecode, sub( Q11, Q_out[j] ) ); // Q11 + } + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect, Q11 ); +#endif + } + else + { + ivas_limiter_dec_fx( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect, Q11 ); + } + + ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + } + + free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); + + return error; +} +#endif + + /*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * @@ -1836,7 +2242,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ - const Word16 subframe_idx /* i : subframe index */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 subframe_idx, /* i : subframe index */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +#else + const Word16 subframe_idx /* i : subframe index */ +#endif ) { HEAD_TRACK_DATA_HANDLE hHeadTrackData; @@ -1857,6 +2268,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( /* Move head-tracking data to the decoder handle */ /* check for Euler angle signaling */ + // TODO change euler angle to Q22 format IF( EQ_32( orientation.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) { Euler2Quat_fx( deg2rad_fx( orientation.x_fx ), deg2rad_fx( orientation.y_fx ), deg2rad_fx( orientation.z_fx ), &orientation ); @@ -1898,6 +2310,11 @@ ivas_error IVAS_DEC_FeedHeadTrackData( move32(); move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hHeadTrackData->sr_pose_pred_axis = rot_axis; + move32(); +#endif + hIvasDec->updateOrientation = true; move16(); @@ -2211,6 +2628,34 @@ static ivas_error copyRendererConfigStruct( Copy32( hRCin->roomAcoustics.pAcoustic_rt60_fx, hRCout->roomAcoustics.pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 Copy32( hRCin->roomAcoustics.pAcoustic_dsr_fx, hRCout->roomAcoustics.pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 Copy( hRCin->directivity_fx, hRCout->directivity_fx, 3 * MAX_NUM_OBJECTS ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.dof = 3; + hRCout->split_rend_config.hq_mode = 0; + hRCout->split_rend_config.codec_delay_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.isar_frame_size_ms = 20; + move16(); +#endif + hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ + hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.lc3plus_highres = hRCin->split_rend_config.lc3plus_highres; + move16(); +#endif + move32(); + move16(); + move16(); + move16(); + move16(); + move32(); + move32(); + move32(); +#endif + hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; move16(); @@ -2275,6 +2720,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_error error; +#endif test(); test(); @@ -2313,6 +2761,21 @@ ivas_error IVAS_DEC_FeedRenderConfig( Copy( renderConfig.directivity_fx, hRenderConfig->directivity_fx, 3 * MAX_NUM_OBJECTS ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRenderConfig->split_rend_config = renderConfig.split_rend_config; + + /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ + IF( hRenderConfig->split_rend_config.dof == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + + IF( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + return IVAS_ERR_OK; } @@ -2367,8 +2830,13 @@ ivas_error IVAS_DEC_GetDelay( } move32(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], hDecoderConfig->output_config ) ); + move16(); +#else nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0] ) ); move16(); +#endif nSamples[2] = extract_l( W_round64_L( W_mult0_32_32( L_shl( st_ivas->binaural_latency_ns, 1 ), out_fs_fx ) ) ); move16(); nSamples[0] = add( nSamples[1], nSamples[2] ); @@ -3265,7 +3733,11 @@ static ivas_error printConfigInfo_dec( test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else IF( ( EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#endif { fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); } @@ -3658,3 +4130,214 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERR_OK; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSplitRendBitstreamHeader() + * + * + *---------------------------------------------------------------------*/ + +ivas_error +IVAS_DEC_GetSplitRendBitstreamHeader( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ +#endif + Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + Word16 *pLc3plusHighRes +#endif +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; + *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; + *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; + *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; +#endif + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetCldfbSamples() + * + * API function to output CLDFB samples + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + Word32 *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ + Word32 *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ + AUDIO_CONFIG *audio_config, /* o : audio configuration */ + Word16 *nOutSamples /* o : number of samples per channel written to output buffer */ +) +{ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + Word16 ch, b, slot_idx, num_chs, maxBand, num_samples; + + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend; + num_samples = 0; + + IF( hSplitBinRend->hCldfbDataOut != NULL ) + { + *audio_config = hSplitBinRend->hCldfbDataOut->config; + IF( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) + { + num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); + maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + + FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + FOR( b = 0; b < maxBand; b++ ) + { + FOR( ch = 0; ch < num_chs; ch++ ) + { + *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][slot_idx][b]; + *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][slot_idx][b]; + } + } + } + num_samples = CLDFB_NO_COL_MAX * maxBand; + } + } + ELSE + { + *audio_config = IVAS_AUDIO_CONFIG_INVALID; + } + + *nOutSamples = num_samples; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_create_handle_isar() + * + * Initialize IVAS decoder split rend handle + *-------------------------------------------------------------------*/ + +static ivas_error ivas_create_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out /* o : ISAR split binaural rendering handle */ +) +{ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + + if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); + } + + isar_init_split_rend_handles( &hSplitBinRend->splitrend ); + + hSplitBinRend->hMultiBinCldfbData = NULL; + hSplitBinRend->hCldfbDataOut = NULL; + hSplitBinRend->numTdSamplesPerChannelCached = 0; + + *hSplitBinRend_out = hSplitBinRend; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_destroy_handle_isar() + * + * destroy IVAS decoder split rend handle + *-------------------------------------------------------------------*/ + +static void ivas_destroy_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */ +) +{ + IF( *hSplitBinRend != NULL ) + { + ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); + + IF( ( *hSplitBinRend )->hCldfbDataOut != NULL ) + { + free( ( *hSplitBinRend )->hCldfbDataOut ); + ( *hSplitBinRend )->hCldfbDataOut = NULL; + } + } + + return; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_is_split_rendering_enabled() + * + * + *---------------------------------------------------------------------*/ + +int16_t IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + Decoder_Struct *st_ivas; + Word16 isSplitRend; + + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasDec->st_ivas; + isSplitRend = 0; + + IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + isSplitRend = 1; + } + + return isSplitRend; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_is_split_rendering_coded_out() + * + * + *---------------------------------------------------------------------*/ + +Word16 IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + Decoder_Struct *st_ivas; + Word16 isSplitCoded; + + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasDec->st_ivas; + isSplitCoded = 0; + + IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + isSplitCoded = 1; + } + + return isSplitCoded; +} +#endif diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 4c3dd12e1..5487cf071 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -256,7 +256,7 @@ typedef struct ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc; CLDFB_HANDLES_WRAPPER_HANDLE hCldfbHandles; ISAR_LC3PLUS_ENC_HANDLE hLc3plusEnc; - float *lc3plusDelayBuffers[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* Used to time-align head pose correction metadata with LC3plus-coded reference audio */ + // float *lc3plusDelayBuffers[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* Used to time-align head pose correction metadata with LC3plus-coded reference audio */ Word32 *lc3plusDelayBuffers_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* Used to time-align head pose correction metadata with LC3plus-coded reference audio */ Word16 lc3plusDelayBuffers_q; Word32 lc3plusDelaySamples; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 2149d2225..447fed0ba 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -273,11 +273,6 @@ void ISAR_PRE_REND_close( FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { - IF( hSplitBinRend->lc3plusDelayBuffers[i] != NULL ) - { - free( hSplitBinRend->lc3plusDelayBuffers[i] ); - hSplitBinRend->lc3plusDelayBuffers[i] = NULL; - } if ( hSplitBinRend->lc3plusDelayBuffers_fx[i] != NULL ) { free( hSplitBinRend->lc3plusDelayBuffers_fx[i] ); @@ -288,10 +283,10 @@ void ISAR_PRE_REND_close( IF( pSplitRendEncBuffer != NULL ) { - IF( pSplitRendEncBuffer->data != NULL ) + IF( pSplitRendEncBuffer->data_fx != NULL ) { - free( pSplitRendEncBuffer->data ); - pSplitRendEncBuffer->data = NULL; + free( pSplitRendEncBuffer->data_fx ); + pSplitRendEncBuffer->data_fx = NULL; } pSplitRendEncBuffer->config.numChannels = 0; @@ -335,7 +330,6 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 max_bands, - float *output[], Word32 *pOutput_fx[], const Word16 low_res_pre_rend_rot, const Word16 cldfb_in_flag, @@ -361,7 +355,6 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( FILE *fp = fopen( "Float_code_output.txt", "ab+" ); FILE *fp1 = fopen( "Float_code_cldfb_state.txt", "ab+" );*/ #endif - output; Q_buff_re = Q_buff; move16(); Q_buff_im = Q_buff; diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index fe64e4911..928fb001d 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -79,7 +79,6 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ const Word16 max_bands, /* i: CLDFB bands */ - float *output[], /* i/o: PCM in/out buffer */ Word32 *pOutput_fx[], /* i: low time resolution pre-renderer flag */ const Word16 low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ const Word16 cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ -- GitLab From 3bd4f5e7013cb54f409ff570d62427c311ee468e Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 30 Jan 2025 02:03:44 +1100 Subject: [PATCH 017/329] lib rend changes --- lib_com/ivas_prot_fx.h | 19 + lib_com/ivas_rotation_com.c | 73 + lib_dec/ivas_binRenderer_internal.c | 13 +- lib_enc/lib_enc.c | 5 + lib_isar/isar_stat.h | 8 - lib_rend/ivas_crend.c | 703 ++++++- lib_rend/ivas_dirac_dec_binaural_functions.c | 1713 +++++++++++++++--- lib_rend/ivas_prot_rend.h | 121 +- lib_rend/ivas_stat_rend.h | 56 +- 9 files changed, 2359 insertions(+), 352 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5849bf97d..0fd85daae 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5938,6 +5938,25 @@ void Quat2EulerDegree_fx( Word32 *pitch_fx, /* o : pitch */ Word32 *roll_fx /* o : roll */ ); + +void Copy_Quat_fx( + const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat /* i : quaternion describing the rotation */ +); + +void modify_Quat_q_fx( + const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat, /* i : quaternion describing the rotation */ + Word16 q_new /* i : quaternion describing the rotation */ +); + +void modify_Rmat_q_fx( + const Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ + Word16 num_subframes, + Word16 q_cur, /* i : current q factor for rotation matrix */ + Word16 q_new /* i : target q factor for rotation matrix */ +); #endif #endif diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 20eaf6188..9e5d1a594 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -96,6 +96,79 @@ void Euler2Quat( #ifdef SPLIT_REND_WITH_HEAD_ROT + +/*------------------------------------------------------------------------- + * Copy_Quat_fx() + * + * Quaternion q factor modification + *------------------------------------------------------------------------*/ +void Copy_Quat_fx( + const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat /* i : quaternion describing the rotation */ +) +{ + out_quat->q_fact = in_quat->q_fact; + out_quat->w_fx = in_quat->w_fx; + out_quat->x_fx = in_quat->x_fx; + out_quat->y_fx = in_quat->y_fx; + out_quat->z_fx = in_quat->z_fx; + move16(); + move32(); + move32(); + move32(); + move32(); + + return; +} + +/*------------------------------------------------------------------------- + * Scale_Quat_fx() + * + * Quaternion q factor modification + *------------------------------------------------------------------------*/ +void modify_Quat_q_fx( + const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat, /* i : quaternion describing the rotation */ + Word16 q_new /* i : quaternion describing the rotation */ +) +{ + out_quat->w_fx = L_shl( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->x_fx = L_shl( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->y_fx = L_shl( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->z_fx = L_shl( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->q_fact = q_new; + return; +} + +/*------------------------------------------------------------------------- + * modify_Rmat_q_fx() + * + * Rotation matrix q factor modification + *------------------------------------------------------------------------*/ +void modify_Rmat_q_fx( + const Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ + Word16 num_subframes, + Word16 q_cur, /* i : current q factor for rotation matrix */ + Word16 q_new /* i : target q factor for rotation matrix */ +) +{ + Word16 i, j, k; + + FOR( i = 0; i < num_subframes; i++ ) + { + FOR( j = 0; j < 3; j++ ) + { + FOR( k = 0; k < 3; k++ ) + { + Rmat_out[i][j][k] = L_shl( Rmat_in[i][j][k], sub( q_new, q_cur ) ); + move32(); + } + } + } + return; +} + /*------------------------------------------------------------------------- * Quat2EulerDegree() * diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 913b7c366..040d9bf9d 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1945,10 +1945,7 @@ void ivas_binRenderer_fx( Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 q_fact_orig = Quaternions_ref->q_fact; - Quaternions_ref->w_fx = L_shl( Quaternions_ref->w_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 - Quaternions_ref->x_fx = L_shl( Quaternions_ref->x_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 - Quaternions_ref->y_fx = L_shl( Quaternions_ref->y_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 - Quaternions_ref->z_fx = L_shl( Quaternions_ref->z_fx, sub( Q22, Quaternions_ref->q_fact ) ); // Q22 + modify_Quat_q_fx( Quaternions_ref, Quaternions_ref, Q22 ); IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) { @@ -1981,13 +1978,13 @@ void ivas_binRenderer_fx( Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, Quaternions_rel.z_fx ); Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); - Quaternions_abs.w_fx = L_shl( Quaternions_abs.w_fx, Q7 ); // Q29 - Quaternions_abs.x_fx = L_shl( Quaternions_abs.x_fx, Q7 ); // Q29 - Quaternions_abs.y_fx = L_shl( Quaternions_abs.y_fx, Q7 ); // Q29 - Quaternions_abs.z_fx = L_shl( Quaternions_abs.z_fx, Q7 ); // Q29 + + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, MAX_PARAM_SPATIAL_SUBFRAMES, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) { rotateFrame_sd_cldfb( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index c78fbe107..8227d45dd 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1447,8 +1447,13 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + *delay = NS2SA( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, IVAS_AUDIO_CONFIG_INVALID ) ); + move16(); +#else *delay = NS2SA( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); move16(); +#endif *delay = imult1616( *delay, hEncoderConfig->nchan_inp ); move16(); diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 5487cf071..228bc94df 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -136,14 +136,6 @@ typedef struct isar_binaural_head_rot_split_pre_rendering_struct float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; ISAR_BIN_HR_SPLIT_REND_HUFF huff_cfg; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; -#endif - -#ifdef SPLIT_POSE_CORRECTION_DEBUG - BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; -#endif - } ISAR_BIN_HR_SPLIT_PRE_REND, *ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE; /*----------------------------------------------------------------------------------* * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index d8cfec1d1..4a4cce092 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -193,7 +193,11 @@ static ivas_error ivas_rend_initCrend_fx( test(); test(); - IF( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" ); } @@ -1397,10 +1401,19 @@ static ivas_error ivas_er_init_handle( *------------------------------------------------------------------------*/ ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend, + const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend +#endif +) { Word16 i; CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif IF( pCrend == NULL ) { @@ -1416,6 +1429,9 @@ ivas_error ivas_rend_initCrendWrapper( move32(); ( *pCrend )->hHrtfCrend = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) +#endif { hCrend = NULL; IF( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) @@ -1452,12 +1468,44 @@ ivas_error ivas_rend_initCrendWrapper( move32(); move32(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *pCrend )->hCrend[pos_idx] = hCrend; +#else ( *pCrend )->hCrend = hCrend; +#endif } return IVAS_ERR_OK; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_openMultiBinCrend() + * + * Allocate and initialize crend renderer handle + *------------------------------------------------------------------------*/ + +ivas_error ivas_rend_openMultiBinCrend( + CREND_WRAPPER_HANDLE *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) +{ + ivas_error error; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + + return error; +} +#endif /*------------------------------------------------------------------------- * ivas_rend_openCrend() @@ -1471,156 +1519,182 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, - const Word32 output_Fs ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word32 output_Fs, + const Word16 num_poses +#else + const Word32 output_Fs +#endif +) { Word16 i, subframe_length; Word16 max_total_ir_len; HRTFS_HANDLE hHrtf; CREND_HANDLE hCrend; ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif error = IVAS_ERR_OK; move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_rend_initCrendWrapper( pCrend ) ), IVAS_ERR_OK ) ) +#endif { return error; } subframe_length = extract_l( Mult_32_16( output_Fs, 164 ) ); /*( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES(i/o:164=(32768/FRAMES_PER_SEC)/MAX_PARAM_SPATIAL_SUBFRAMES*/ - IF( ( *pCrend )->hHrtfCrend == NULL ){ - IF( NE_32( ( error = ivas_rend_initCrend_fx( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ), IVAS_ERR_OK ) ){ + IF( ( *pCrend )->hHrtfCrend == NULL ) + { + IF( NE_32( ( error = ivas_rend_initCrend_fx( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ), IVAS_ERR_OK ) ) + { return error; -} -} - -{ - hCrend = ( *pCrend )->hCrend; - hHrtf = ( *pCrend )->hHrtfCrend; + } + } - IF( hHrtf != NULL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) +#endif { - max_total_ir_len = imult1616( hHrtf->max_num_iterations, subframe_length ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = ( *pCrend )->hCrend[pos_idx]; +#else + hCrend = ( *pCrend )->hCrend; +#endif + hHrtf = ( *pCrend )->hHrtfCrend; - FOR( i = 0; i < hHrtf->max_num_ir; i++ ) + IF( hHrtf != NULL ) { - IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); - IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + max_total_ir_len = imult1616( hHrtf->max_num_iterations, subframe_length ); + + FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); + IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); } - set_zero_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); - } - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); } - set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); - } - max_total_ir_len = imult1616( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); + max_total_ir_len = imult1616( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); - IF( max_total_ir_len > 0 ) - { - IF( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF( max_total_ir_len > 0 ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); + IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); } - set_zero_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); - IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + hCrend->freq_buffer_re_diffuse_fx = NULL; + hCrend->freq_buffer_im_diffuse_fx = NULL; } - set_zero_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); - } - ELSE - { - hCrend->freq_buffer_re_diffuse_fx = NULL; - hCrend->freq_buffer_im_diffuse_fx = NULL; - } - max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ - IF( max_total_ir_len > 0 ) - { - IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ + IF( max_total_ir_len > 0 ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); } - set_zero_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); - } - ELSE - { - hCrend->lfe_delay_line_fx = NULL; - } - - IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) + ELSE { - return error; + hCrend->lfe_delay_line_fx = NULL; } - IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - - /* Allocate memory for reflections */ - hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); - IF( !hCrend->reflections ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); - } - IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } - hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; - hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; - move16(); - move32(); + IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + { - /* Set sample rate and frame size */ + /* Allocate memory for reflections */ + hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); + IF( !hCrend->reflections ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); + } + IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) + { + return error; + } - hCrend->reflections->output_Fs_fx = output_Fs; // Q0 - move32(); + hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; + hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; + move16(); + move32(); - hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - move32(); + /* Set sample rate and frame size */ + + hCrend->reflections->output_Fs_fx = output_Fs; // Q0 + move32(); + + hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + move32(); - /* Init Shoebox */ - ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); + /* Init Shoebox */ + ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); - /* Init and compute Reflections */ - IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) + /* Init and compute Reflections */ + IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE { - return error; + hCrend->reflections = NULL; } } ELSE { - hCrend->reflections = NULL; + hCrend->hReverb = NULL; } - } - ELSE - { - hCrend->hReverb = NULL; + + ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); + move32(); } - ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); - move32(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *pCrend )->hCrend[pos_idx] = hCrend; +#else + ( *pCrend )->hCrend = hCrend; +#endif } - - ( *pCrend )->hCrend = hCrend; -} -return IVAS_ERR_OK; + return IVAS_ERR_OK; } /*------------------------------------------------------------------------- @@ -1630,9 +1704,18 @@ return IVAS_ERR_OK; *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend, + const Word16 num_poses +#else + CREND_WRAPPER_HANDLE *pCrend +#endif +) { Word16 i; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif CREND_HANDLE hCrend; test(); @@ -1646,8 +1729,15 @@ void ivas_rend_closeCrend( ivas_hrtf_close( &( *pCrend )->hHrtfCrend ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = ( *pCrend )->hCrend[pos_idx]; +#else hCrend = ( *pCrend )->hCrend; +#endif IF( hCrend != NULL ) { FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -1714,7 +1804,11 @@ void ivas_rend_closeCrend( } free( hCrend ); hCrend = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *pCrend )->hCrend[pos_idx] = hCrend; +#else ( *pCrend )->hCrend = hCrend; +#endif } } @@ -1725,6 +1819,30 @@ void ivas_rend_closeCrend( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_closeCldfbRend() + * + * Close CLDFB based fastconv binaural renderer memories + *------------------------------------------------------------------------*/ + +void ivas_rend_closeCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend ) +{ + IF( pCldfbRend->hCldfbRend->hInputSetup != NULL ) + { + free( pCldfbRend->hCldfbRend->hInputSetup ); + pCldfbRend->hCldfbRend->hInputSetup = NULL; + } + + ivas_binRenderer_close( &pCldfbRend->hCldfbRend ); + ivas_binaural_hrtf_close( &pCldfbRend->hHrtfFastConv ); + ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv ); + + return; +} +#endif + /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crendConvolver() * @@ -1738,7 +1856,13 @@ static ivas_error ivas_rend_crendConvolver( Word32 *pcm_in[], // Qx Word32 *pcm_out[], // Qx const Word32 output_Fs, - const Word16 i_ts ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 i_ts, + const Word16 pos_idx +#else + const Word16 i_ts +#endif +) { Word16 i, j, k, m; Word16 subframe_length, idx_in; @@ -1755,7 +1879,11 @@ static ivas_error ivas_rend_crendConvolver( ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend; +#endif IF( NE_32( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ), IVAS_ERR_OK ) ) { @@ -1933,7 +2061,12 @@ ivas_error ivas_rend_crendProcess( EFAP_HANDLE hEFAPdata, Word32 *output_fx[], /* i/o: input/output audio channels Qx */ const Word32 output_Fs, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 num_subframes /* i : number of subframes to render */, + const Word16 pos_idx +#else const Word16 num_subframes /* i : number of subframes to render */ +#endif ) { Word16 i, subframe_idx, subframe_len; @@ -1945,7 +2078,11 @@ ivas_error ivas_rend_crendProcess( ivas_error error; CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend; +#endif combinedOrientationEnabled = 0; move16(); @@ -2039,15 +2176,22 @@ ivas_error ivas_rend_crendProcess( test(); IF( EQ_16( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || EQ_16( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { - +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output_fx, p_pcm_tmp_fx, output_Fs, subframe_idx, pos_idx ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output_fx, p_pcm_tmp_fx, output_Fs, subframe_idx ) ), IVAS_ERR_OK ) ) +#endif { return error; } IF( hCrend->hReverb != NULL ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_reverb_process_fx( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, output_fx, p_pcm_tmp_fx, subframe_idx ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_process_fx( pCrend->hCrend->hReverb, inConfig, 1, output_fx, p_pcm_tmp_fx, subframe_idx ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -2090,6 +2234,10 @@ ivas_error ivas_rend_crendProcessSubframe( Word32 *output[], /* i/o: input/output audio channels Qx */ const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word32 output_Fs /* i : output sampling rate */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const Word16 pos_idx +#endif ) { Word16 subframe_idx, subframe_len; @@ -2101,7 +2249,11 @@ ivas_error ivas_rend_crendProcessSubframe( ivas_error error; Word8 combinedOrientationEnabled; CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend; +#endif combinedOrientationEnabled = 0; move16(); @@ -2190,13 +2342,24 @@ ivas_error ivas_rend_crendProcessSubframe( test(); IF( EQ_32( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || EQ_32( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { - +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local_fx, p_pcm_tmp_fx, output_Fs, 0, pos_idx ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local_fx, p_pcm_tmp_fx, output_Fs, 0 ) ), IVAS_ERR_OK ) ) - +#endif { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( pCrend->hCrend[0]->hReverb != NULL ) + { + IF( NE_32( ( error = ivas_reverb_process_fx( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, tc_local_fx, p_pcm_tmp_fx, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } +#else IF( pCrend->hCrend->hReverb != NULL ) { IF( NE_32( ( error = ivas_reverb_process_fx( pCrend->hCrend->hReverb, inConfig, 1, tc_local_fx, p_pcm_tmp_fx, 0 ) ), IVAS_ERR_OK ) ) @@ -2204,6 +2367,7 @@ ivas_error ivas_rend_crendProcessSubframe( return error; } } +#endif FOR( ch = 0; ch < nchan_in; ch++ ) { tc_local_fx[ch] += subframe_len; @@ -2222,7 +2386,12 @@ ivas_error ivas_rend_crendProcessSubframe( /* update combined orientation access index */ ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( pCrend->hCrend[0]->hReverb != NULL ) +#else IF( pCrend->hCrend->hReverb != NULL ) +#endif { *pCrend->p_io_qfactor = sub( *pCrend->p_io_qfactor, 2 ); move16(); @@ -2247,3 +2416,339 @@ ivas_error ivas_rend_crendProcessSubframe( return IVAS_ERR_OK; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crend_ProcessSplitBin() + * + * Process call for IVAS Crend renderer + *-----------------------------------------------------------------------------------------*/ + +ivas_error ivas_rend_crendProcessSplitBin( + const CREND_WRAPPER *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, + EFAP_HANDLE hEFAPdata, + Word32 *output[], + const Word32 output_Fs ) +{ + Word16 i, j; + Word16 sf; + Word16 pos_idx, output_frame; + ivas_error error; + Word32 gain_lfe; + Word32 tmpLfeBuffer[L_FRAME48k]; + Word32 tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; + Word32 tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + + output_frame = extract_l( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + + /* copy input */ + FOR( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + Copy32( output[i], tmpInputBuffer[i], output_frame ); + } + + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + p_tmpInputBuffer[i] = tmpInputBuffer[i]; + move32(); + } + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + move32(); + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + move32(); + IF( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + FOR( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) + { + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[0], &combinedOrientationDataLocal.Quaternions[sf] ); + FOR( i = 0; i < 3; i++ ) + { + FOR( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat_fx[sf][i][j] = combinedOrientationDataLocal.Rmat_fx[0][i][j]; + move32(); + } + } + } + } + + /* copy LFE to tmpLfeBuffer and apply gain only once */ + IF( GT_16( hIntSetup->num_lfe, 0 ) && NE_16( hIntSetup->index_lfe[0], -1 ) ) + { + Copy32( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, output_frame ); + gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe_fx : GAIN_LFE_FX; + v_multc_fixed_16( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, output_frame ); // q_input_fx - 1 + Scale_sig32( tmpLfeBuffer, output_frame, 1 ); // q_input_fx + } + ELSE + { + set32_fx( tmpLfeBuffer, 0, output_frame ); + } + + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) + { + /* Update head positions */ + + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[i], &Quaternions_orig[i] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + move32(); + modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Q22 ); + Quat2EulerDegree_fx( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z_fx, &Quaternions_abs.y_fx, &Quaternions_abs.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x_fx = L_add( Quaternions_abs.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_abs.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + move32(); + move32(); + move32(); + move32(); + modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Quaternions_orig[i].q_fact ); + QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + } + modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx, combinedOrientationDataLocal.Rmat_fx, MAX_PARAM_SPATIAL_SUBFRAMES, sub( shl( Quaternions_orig[0].q_fact, 1 ), 32 ), Q30 ); + + + /* render inplace to first two channels of tmpInputBuffer */ + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + move32(); + + FOR( i = 0; i < 3; i++ ) + { + Copy32( hCombinedOrientationData->Rmat_prev_fx[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev_fx[0][i], 3 ); + } + + IF( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, hIntSetup, hEFAPdata, + NULL, p_tmpInputBuffer, p_tmpInputBuffer, output_frame, output_Fs, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + FOR( i = 0; i < 3; i++ ) + { + Copy32( pCombinedOrientationDataLocal->Rmat_prev_fx[0][i], hCombinedOrientationData->Rmat_prev_fx[pos_idx][i], 3 ); + } + + FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + /* accumulate LFE to output */ + v_add_fx( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], output_frame ); + + /* move to split bin output buffer */ + Copy32( tmpInputBuffer[i], tmpSplitBinBuffer[add( i_mult( pos_idx, BINAURAL_CHANNELS ), i )], output_frame ); + } + + /* overwrite rendered channels with input again for next iteration */ + FOR( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + Copy32( output[i], tmpInputBuffer[i], output_frame ); + } + + /* restore original headrotation data */ + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Copy_Quat_fx( &Quaternions_orig[i], &combinedOrientationDataLocal.Quaternions[i] ); + } + } + + /* copy split binaural rendered signals to final output */ + FOR( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) + { + Copy32( tmpSplitBinBuffer[i], output[i], output_frame ); + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crend_ProcessSubframesSplitBin() + * + * Process call for IVAS Crend renderer + *-----------------------------------------------------------------------------------------*/ + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + Word32 *input_f[], /* i : transport channels */ + Word32 *output[], /* i/o: input/output audio channels */ + const Word16 n_samples_to_render, /* i : output frame length per channel */ + const Word32 output_Fs /* i : output sampling rate */ +) +{ + Word16 i, j; + Word16 sf; + Word16 pos_idx; + ivas_error error; + Word32 gain_lfe; + Word32 tmpLfeBuffer[L_FRAME48k]; + Word16 original_subframes_rendered, original_slots_rendered; + Word32 tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; + Word32 tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + original_subframes_rendered = hTcBuffer->subframes_rendered; + move16(); + original_slots_rendered = hTcBuffer->slots_rendered; + move16(); + + /* copy input */ + FOR( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + Copy32( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + p_tmpInputBuffer[i] = tmpInputBuffer[i]; + move32(); + } + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + move32(); + move32(); + IF( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + FOR( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) + { + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[0], &combinedOrientationDataLocal.Quaternions[sf] ); + FOR( i = 0; i < 3; i++ ) + { + FOR( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat_fx[sf][i][j] = combinedOrientationDataLocal.Rmat_fx[0][i][j]; + move32(); + } + } + } + } + + /* copy LFE to tmpLfeBuffer and apply gain only once */ + IF( GT_16( hIntSetup->num_lfe, 0 ) && NE_16( hIntSetup->index_lfe[0], -1 ) ) + { + Copy32( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, n_samples_to_render ); + gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe_fx : GAIN_LFE_FX; + v_multc_fixed_16( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, n_samples_to_render ); // q_input_fx - 1 + Scale_sig32( tmpLfeBuffer, n_samples_to_render, 1 ); // q_input_fx + } + ELSE + { + set32_fx( tmpLfeBuffer, 0, n_samples_to_render ); + } + + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) + { + /* Update head positions */ + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[i], &Quaternions_orig[i] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + move32(); + modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Q22 ); + Quat2EulerDegree_fx( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z_fx, &Quaternions_abs.y_fx, &Quaternions_abs.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x_fx = L_add( Quaternions_abs.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_abs.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + move32(); + move32(); + move32(); + move32(); + modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Quaternions_orig[i].q_fact ); + QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + } + modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx, combinedOrientationDataLocal.Rmat_fx, MAX_PARAM_SPATIAL_SUBFRAMES, sub( shl( Quaternions_orig[0].q_fact, 1 ), 32 ), Q30 ); + + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + move32(); + + hTcBuffer->subframes_rendered = original_subframes_rendered; + hTcBuffer->slots_rendered = original_slots_rendered; + move16(); + move16(); + + /* update combined orientation access index */ + ivas_combined_orientation_set_to_start_index( pCombinedOrientationDataLocal ); + + FOR( i = 0; i < 3; i++ ) + { + Copy32( hCombinedOrientationData->Rmat_prev_fx[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev_fx[0][i], 3 ); + } + + IF( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, + hIntSetup, hEFAPdata, hTcBuffer, p_tmpInputBuffer, p_tmpInputBuffer, n_samples_to_render, output_Fs, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + FOR( i = 0; i < 3; i++ ) + { + Copy32( pCombinedOrientationDataLocal->Rmat_prev_fx[0][i], hCombinedOrientationData->Rmat_prev_fx[pos_idx][i], 3 ); + } + + FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + /* accumulate LFE to output */ + v_add_fx( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], n_samples_to_render ); + + /* move to split bin output buffer */ + Copy32( tmpInputBuffer[i], tmpSplitBinBuffer[add( i_mult( pos_idx, BINAURAL_CHANNELS ), i )], n_samples_to_render ); + } + + /* overwrite rendered channels with input again for next iteration */ + FOR( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + Copy32( output[i], tmpInputBuffer[i], n_samples_to_render ); + } + + /* restore original headrotation data */ + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Copy_Quat_fx( &Quaternions_orig[i], &combinedOrientationDataLocal.Quaternions[i] ); + } + } + + /* copy split binaural rendered signals to final output */ + FOR( i = 0; i < i_mult( BINAURAL_CHANNELS, pMultiBinPoseData->num_poses ); ++i ) + { + Copy32( tmpSplitBinBuffer[i], output[i], n_samples_to_render ); + } + + /* update main combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_to_render ); + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index d90728d58..8ec066dc9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -112,11 +112,21 @@ static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBIN static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const Word16 num_freq_bands, const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME] /*q_inp*/[CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 decIm[] /*q_inp*/[CLDFB_NO_CHANNELS_MAX] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, Word16 q ); + +static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 Rmat[3][3], const Word16 subframe, const Word16 isHeadtracked, const Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, const Word32 *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +#else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 Rmat_fx[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData, Word16 q ); +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat, Word32 outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word8 recompute ); +#else static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat ); +#endif static void adaptTransportSignalsHeadtracked_fx( COMBINED_ORIENTATION_HANDLE hHeadTrackData, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word16 q_inp, const Word16 nBins, const Word16 nSlots, Word32 Rmat[3][3] /*Q30*/ ); @@ -125,7 +135,13 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, const Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 useCachedValue ); static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3] /*Q30*/, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); +#else static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 subframe ); +#endif + static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_fx /*q_Ein*/, Word16 q_Ein, Word32 CinRe_fx /*q_Cin*/, Word32 CinIm_fx /*q_Cin*/, Word16 q_Cin, Word32 Eout1_fx /*q_Eout*/, Word32 Eout2_fx /*q_Eout*/, Word16 q_Eout, Word32 CoutRe_fx /*q_Cout*/, Word32 CoutIm_fx /*q_Cout*/, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*Q31*/, Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word16 *q_M, const Word16 regularizationFactor_fx /*Q14*/ ); static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); @@ -153,189 +169,226 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( Word16 tmp_e; Word16 tmp2; ivas_error error; - hDiracDecBin = st_ivas->hDiracDecBin; - IF( hDiracDecBin == NULL ) - { - IF( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 num_poses, pos_idx; - hDiracDecBin->hTdDecorr = NULL; - hDiracDecBin->hReverb = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; + num_poses = 1; + IF( st_ivas->hSplitBinRend != NULL ) + { + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); } - output_Fs = st_ivas->hDecoderConfig->output_Fs; - move32(); - nBins = st_ivas->hSpatParamRendCom->num_freq_bands; - move16(); - renderer_type = st_ivas->renderer_type; - move32(); - - FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) - { - set16_fx( hDiracDecBin->processMtxRe_fx[j][k], 0, nBins ); - set16_fx( hDiracDecBin->processMtxIm_fx[j][k], 0, nBins ); - set16_fx( hDiracDecBin->processMtxRePrev_fx[j][k], 0, nBins ); - set16_fx( hDiracDecBin->processMtxImPrev_fx[j][k], 0, nBins ); - } + hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; + move32(); +#else + hDiracDecBin = st_ivas->hDiracDecBin; +#endif - FOR( k = 0; k < BINAURAL_CHANNELS; k++ ) + IF( hDiracDecBin == NULL ) { - set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k], 0, nBins ); - set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k], 0, nBins ); - } - set32_fx( hDiracDecBin->ChEnePrev_fx[j], 0, nBins ); - set32_fx( hDiracDecBin->ChEneOutPrev_fx[j], 0, nBins ); - set16_fx( hDiracDecBin->ChEnePrev_e[j], 0, nBins ); - set16_fx( hDiracDecBin->ChEneOutPrev_e[j], 0, nBins ); - } - set32_fx( hDiracDecBin->ChCrossRePrev_fx, 0, nBins ); - set32_fx( hDiracDecBin->ChCrossImPrev_fx, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossRePrev_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossImPrev_e, 0, nBins ); - set32_fx( hDiracDecBin->ChCrossReOutPrev_fx, 0, nBins ); - set32_fx( hDiracDecBin->ChCrossImOutPrev_fx, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossReOutPrev_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossImOutPrev_e, 0, nBins ); - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - move16(); - - hDiracDecBin->q_processMtx = Q15; - hDiracDecBin->q_processMtxSCCR = Q15; - hDiracDecBin->q_processMtxPrev = Q15; - hDiracDecBin->q_processMtxPrevSCCR = Q15; - hDiracDecBin->q_processMtxDec = Q15; - hDiracDecBin->q_processMtxDecPrev = Q15; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); + IF( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + } - FOR( bin = 0; bin < nBins; bin++ ) - { - binCenterFreq_fx = L_mult0( extract_l( L_shr( output_Fs, 1 ) ), div_s( add( shl( bin, 1 ), 1 ), shl( nBins, 1 ) ) ) /*( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f )*/; /*Q15*/ - /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ - tmp = BASOP_Util_Divide3232_Scale( binCenterFreq_fx, 2700 << Q15, &tmp_e ); - IF( tmp_e < 0 ) - { - tmp = shl( tmp, tmp_e ); /*q15*/ - tmp_e = 0; - move16(); + hDiracDecBin->hTdDecorr = NULL; + hDiracDecBin->hReverb = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; } - tmpFloat_fx = s_max( 0, sub( shl_sat( 1, sub( 15, tmp_e ) ), tmp ) ) /*max( 0.0f, 1.0f - binCenterFreq / 2700.0f )*/; /*Q15-tmp_e*/ - tmp2 = extract_l( Mult_32_32( binCenterFreq_fx, 1952258 /*=2^31*180/(550)/360*/ ) % 32767 ); /* Q15 */ //*binCenterFreq_fx * EVS_PI / 550.0f*/ - hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( L_mult0( divide3232( tmpFloat_fx, Mult_32_16( binCenterFreq_fx, 187 /*2^15*pi/550*/ ) ), getSineWord16R2( tmp2 ) ), tmp_e ); /*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/ /* Q30 */ - hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( hDiracDecBin->diffuseFieldCoherence_fx[bin], 1 ); /* Q31 */ - move32(); - move32(); - } - FOR( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) - { - hDiracDecBin->diffuseFieldCoherenceX_fx[bin] = L_add( hDiracDecBin->diffuseFieldCoherence_fx[bin], diffuseFieldCoherenceDifferenceX_fx[bin] ); - hDiracDecBin->diffuseFieldCoherenceY_fx[bin] = L_add( hDiracDecBin->diffuseFieldCoherence_fx[bin], diffuseFieldCoherenceDifferenceY_fx[bin] ); - hDiracDecBin->diffuseFieldCoherenceZ_fx[bin] = L_add( hDiracDecBin->diffuseFieldCoherence_fx[bin], diffuseFieldCoherenceDifferenceZ_fx[bin] ); - move32(); + output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + move16(); + renderer_type = st_ivas->renderer_type; move32(); - } - IF( EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) /* Indication of binaural rendering without room effect */ - { - set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->q_earlyPartEneCorrection = Q28; + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + { + set16_fx( hDiracDecBin->processMtxRe_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxIm_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxRePrev_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxImPrev_fx[j][k], 0, nBins ); + } + + FOR( k = 0; k < BINAURAL_CHANNELS; k++ ) + { + set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k], 0, nBins ); + } + set32_fx( hDiracDecBin->ChEnePrev_fx[j], 0, nBins ); + set32_fx( hDiracDecBin->ChEneOutPrev_fx[j], 0, nBins ); + set16_fx( hDiracDecBin->ChEnePrev_e[j], 0, nBins ); + set16_fx( hDiracDecBin->ChEneOutPrev_e[j], 0, nBins ); + } + set32_fx( hDiracDecBin->ChCrossRePrev_fx, 0, nBins ); + set32_fx( hDiracDecBin->ChCrossImPrev_fx, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossRePrev_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossImPrev_e, 0, nBins ); + set32_fx( hDiracDecBin->ChCrossReOutPrev_fx, 0, nBins ); + set32_fx( hDiracDecBin->ChCrossImOutPrev_fx, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossReOutPrev_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossImOutPrev_e, 0, nBins ); + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; move16(); - hDiracDecBin->hReverb = NULL; - } - ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ - { - Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); - hDiracDecBin->q_earlyPartEneCorrection = Q28; + + hDiracDecBin->q_processMtx = Q15; + hDiracDecBin->q_processMtxSCCR = Q15; + hDiracDecBin->q_processMtxPrev = Q15; + hDiracDecBin->q_processMtxPrevSCCR = Q15; + hDiracDecBin->q_processMtxDec = Q15; + hDiracDecBin->q_processMtxDecPrev = Q15; move16(); - /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ - test(); - test(); - IF( hDiracDecBin->hReverb != NULL && ( ( NE_16( hDiracDecBin->hReverb->numBins, nBins ) ) || - ( NE_16( hDiracDecBin->hReverb->blockSize, CLDFB_SLOTS_PER_SUBFRAME ) ) ) ) + move16(); + move16(); + move16(); + move16(); + move16(); + + FOR( bin = 0; bin < nBins; bin++ ) + { + binCenterFreq_fx = L_mult0( extract_l( L_shr( output_Fs, 1 ) ), div_s( add( shl( bin, 1 ), 1 ), shl( nBins, 1 ) ) ) /*( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f )*/; /*Q15*/ + /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ + tmp = BASOP_Util_Divide3232_Scale( binCenterFreq_fx, 2700 << Q15, &tmp_e ); + IF( tmp_e < 0 ) + { + tmp = shl( tmp, tmp_e ); /*q15*/ + tmp_e = 0; + move16(); + } + tmpFloat_fx = s_max( 0, sub( shl_sat( 1, sub( 15, tmp_e ) ), tmp ) ) /*max( 0.0f, 1.0f - binCenterFreq / 2700.0f )*/; /*Q15-tmp_e*/ + tmp2 = extract_l( Mult_32_32( binCenterFreq_fx, 1952258 /*=2^31*180/(550)/360*/ ) % 32767 ); /* Q15 */ //*binCenterFreq_fx * EVS_PI / 550.0f*/ + hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( L_mult0( divide3232( tmpFloat_fx, Mult_32_16( binCenterFreq_fx, 187 /*2^15*pi/550*/ ) ), getSineWord16R2( tmp2 ) ), tmp_e ); /*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/ /* Q30 */ + hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( hDiracDecBin->diffuseFieldCoherence_fx[bin], 1 ); /* Q31 */ + move32(); + move32(); + } + + FOR( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) { - ivas_binaural_reverb_close_fx( &( hDiracDecBin->hReverb ) ); + hDiracDecBin->diffuseFieldCoherenceX_fx[bin] = L_add( hDiracDecBin->diffuseFieldCoherence_fx[bin], diffuseFieldCoherenceDifferenceX_fx[bin] ); + hDiracDecBin->diffuseFieldCoherenceY_fx[bin] = L_add( hDiracDecBin->diffuseFieldCoherence_fx[bin], diffuseFieldCoherenceDifferenceY_fx[bin] ); + hDiracDecBin->diffuseFieldCoherenceZ_fx[bin] = L_add( hDiracDecBin->diffuseFieldCoherence_fx[bin], diffuseFieldCoherenceDifferenceZ_fx[bin] ); + move32(); + move32(); + move32(); } - IF( hDiracDecBin->hReverb == NULL ) + IF( EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) /* Indication of binaural rendering without room effect */ + { + set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->q_earlyPartEneCorrection = Q28; + move16(); + hDiracDecBin->hReverb = NULL; + } + ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) + Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); + hDiracDecBin->q_earlyPartEneCorrection = Q28; + move16(); + /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ + test(); + test(); + IF( hDiracDecBin->hReverb != NULL && ( ( NE_16( hDiracDecBin->hReverb->numBins, nBins ) ) || + ( NE_16( hDiracDecBin->hReverb->blockSize, CLDFB_SLOTS_PER_SUBFRAME ) ) ) ) { - return error; + ivas_binaural_reverb_close_fx( &( hDiracDecBin->hReverb ) ); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( hDiracDecBin->hReverb == NULL && EQ_16( pos_idx, 0 ) ) /* open reverb only for the main direction */ +#else + IF( hDiracDecBin->hReverb == NULL ) +#endif + { + /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ + IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) + { + return error; + } } } - } - ELSE IF( EQ_32( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->q_earlyPartEneCorrection = Q28; - hDiracDecBin->hReverb = NULL; - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; - move16(); - move16(); - } - ELSE /* Not valid renderer type for this renderer */ - { - assert( false ); - } + ELSE IF( EQ_32( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + { + set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->q_earlyPartEneCorrection = Q28; + hDiracDecBin->hReverb = NULL; + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; + move16(); + move16(); + } + ELSE /* Not valid renderer type for this renderer */ + { + assert( false ); + } - hDiracDecBin->hDiffuseDist = NULL; /* Memory is allocated from stack during runtime when needed */ + hDiracDecBin->hDiffuseDist = NULL; /* Memory is allocated from stack during runtime when needed */ - if ( hDiracDecBin->hTdDecorr == NULL ) - { - hDiracDecBin->useTdDecorr = 0; - move16(); - } + if ( hDiracDecBin->hTdDecorr == NULL ) + { + hDiracDecBin->useTdDecorr = 0; + move16(); + } - IF( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); - } + IF( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); + } - IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) - { - return error; - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ + { +#endif + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - test(); - test(); - IF( !hDiracDecBin->useTdDecorr && !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) ) - { - Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; - ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); - - IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis_fx, - BINAURAL_CHANNELS, - output_Fs ) ), - IVAS_ERR_OK ) ) + test(); + test(); + IF( !hDiracDecBin->useTdDecorr && !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) ) + { + Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; + ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); + + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis_fx, + BINAURAL_CHANNELS, + output_Fs ) ), + IVAS_ERR_OK ) ) + { + return error; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } + else { - return error; + hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ } - } +#endif - hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */ - move16(); + hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */ + move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + st_ivas->hDiracDecBin[pos_idx] = hDiracDecBin; + } +#else st_ivas->hDiracDecBin = hDiracDecBin; +#endif /* allocate transport channels */ IF( st_ivas->hTcBuffer == NULL ) @@ -376,13 +429,37 @@ void ivas_dirac_dec_close_binaural_data( DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ) { - +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif test(); IF( hBinaural == NULL || *hBinaural == NULL ) { return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + IF( hBinaural[pos_idx] != NULL ) + { + IF( hBinaural[pos_idx]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); + } + + ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); + + if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); + } + + free( hBinaural[pos_idx] ); + hBinaural[pos_idx] = NULL; + } + } +#else IF( ( *hBinaural )->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &( ( *hBinaural )->hReverb ) ); @@ -396,6 +473,7 @@ void ivas_dirac_dec_close_binaural_data( free( *hBinaural ); *hBinaural = NULL; +#endif return; } @@ -603,7 +681,24 @@ static void ivas_dirac_dec_binaural_internal_fx( Word16 nBins, offsetSamples; Word16 i, j; Word16 q_mat, q_out; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + Word32 tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* these allow re-using the reverb and freq-domain decorrelator signals from ivas_dirac_dec_binaural_process_output() in split rendering for the side renderings */ + Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 decorrRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 decorrIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX]; + Word32 IIReneLimiter_fx[CLDFB_NO_CHANNELS_MAX]; + + hDiracDecBin = st_ivas->hDiracDecBin[0]; +#else hDiracDecBin = st_ivas->hDiracDecBin; +#endif assert( hDiracDecBin ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; @@ -904,13 +999,18 @@ static void ivas_dirac_dec_binaural_internal_fx( IF( EQ_16( nchan_transport, 2 ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ +#endif adaptTransportSignalsHeadtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); } } test(); +#ifndef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData, q_inp ); +#endif IF( EQ_32( config_data.ivas_format, ISM_FORMAT ) ) { @@ -928,6 +1028,13 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, subframe, + subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, q_inp ); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_fx, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); +#endif nchanSeparateChannels = 0; move16(); @@ -994,91 +1101,991 @@ static void ivas_dirac_dec_binaural_internal_fx( hDiracDecBin->q_processMtxDecPrev = q_mat; move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + pMultiBinPoseData = NULL; + IF( st_ivas->hSplitBinRend != NULL ) + { + pMultiBinPoseData = &st_ivas->hSplitBinRend->splitrend.multiBinPoseData; + move32(); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) +#endif + { + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, + tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) + { + Copy32( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + Copy32( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + } + } + } + ELSE + { + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + } +#else ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); +#endif + hDiracDecBin->hDiffuseDist = NULL; + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + { + /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ + IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; + Word32 Rmat_local[3][3]; + + if ( hCombinedOrientationData ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Copy_Quat_fx( Quaternions_ref, &Quaternions_abs ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, Q22 ); + Quaternions_rot.w_fx = L_negate( 12582912 ); /* signal to use Euler */ + Quat2EulerDegree_fx( Quaternions_abs, &Quaternions_abs.z_fx, &Quaternions_abs.y_fx, &Quaternions_abs.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + Quaternions_abs.w_fx = L_negate( 12582912 ); /* signal to use Euler */ + + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + Quaternions_rot.x_fx = L_add( Quaternions_abs.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_rot.y_fx = L_add( Quaternions_abs.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_rot.z_fx = L_add( Quaternions_abs.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + move32(); + move32(); + move32(); + modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact ); + QuatToRotMat_fx( Quaternions_rot, Rmat_local ); + + hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; + assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); + if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) + { + hDiracDecBin->hDiffuseDist = &diffuseDistData; + } + + /* re-use input covariance for the side renderings */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Copy32( st_ivas->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands ); + } + Copy32( st_ivas->hDiracDecBin[0]->ChCrossRe_fx, hDiracDecBin->ChCrossRe_fx, hSpatParamRendCom->num_freq_bands ); + Copy32( st_ivas->hDiracDecBin[0]->ChCrossIm_fx, hDiracDecBin->ChCrossIm_fx, hSpatParamRendCom->num_freq_bands ); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); + + ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + nchanSeparateChannels, st_ivas->hMasaIsmData ); + + + q_mat = hDiracDecBin->q_processMtx; + move16(); + q_mat = s_min( q_mat, hDiracDecBin->q_processMtxPrev ); + q_mat = s_min( q_mat, hDiracDecBin->q_processMtxDec ); + q_mat = s_min( q_mat, hDiracDecBin->q_processMtxDecPrev ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) + { + Scale_sig( hDiracDecBin->processMtxRe_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtx ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxIm_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtx ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxRePrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxPrev ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxImPrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxPrev ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecRe_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDec ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecIm_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDec ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecRePrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDecPrev ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecImPrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDecPrev ) ); // scaling to q_mat + } + FOR( slot = 0; slot < nchanSeparateChannels; slot++ ) + { + Scale_sig( hDiracDecBin->processMtxRe_fx[ch][slot + BINAURAL_CHANNELS], nBins, sub( q_mat, hDiracDecBin->q_processMtx ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxIm_fx[ch][slot + BINAURAL_CHANNELS], nBins, sub( q_mat, hDiracDecBin->q_processMtx ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxRePrev_fx[ch][slot + BINAURAL_CHANNELS], nBins, sub( q_mat, hDiracDecBin->q_processMtxPrev ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxImPrev_fx[ch][slot + BINAURAL_CHANNELS], nBins, sub( q_mat, hDiracDecBin->q_processMtxPrev ) ); // scaling to q_mat + } + } + hDiracDecBin->q_processMtx = q_mat; + move16(); + hDiracDecBin->q_processMtxPrev = q_mat; + move16(); + hDiracDecBin->q_processMtxDec = q_mat; + move16(); + hDiracDecBin->q_processMtxDecPrev = q_mat; + move16(); + + /* re-use reverb and decorr from main direction for the sides */ + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, + tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 0 ); + + /* copy from temporary buffer to the main split rendering buffer */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) + { + Copy32( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + Copy32( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + } + } + + hDiracDecBin->hDiffuseDist = NULL; + } + } + } + + /* update this counter only after the last rendering of split directions */ +#endif + + hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] ); + hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); + + move16(); + move16(); + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + scale_sig32( output_fx[ch], imult1616( nBins, hSpatParamRendCom->subframe_nbslots[subframe] ), sub( 11, q_out ) ); // Scaling to Q11 + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; + move16(); + } + + return; +} + + +static void ivas_dirac_dec_decorrelate_slot_fx( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + const Word16 num_freq_bands, + const Word16 slot, + Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ + Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ + Word16 q_inp, + Word32 decRe[][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ + Word32 decIm[][CLDFB_NO_CHANNELS_MAX] /*q_inp*/ ) +{ + Word16 offset, ch, bin; + Word32 onset_filter_fx[BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, 60 bins */ + Word32 decorrelatedFrameInterleaved_fx[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ + Word32 protoFrame_fx[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ + Word16 q_decorrelatedFrameInterleaved, q_protoFrame; + const Word16 protoIndexDir[BINAURAL_CHANNELS] = { 0, 1 }; + move16(); + q_protoFrame = q_inp; + move16(); + /* Decorrelation needs interleaved data. Copy left and right signals to proto_frame_f */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + offset = imult1616( imult1616( num_freq_bands, BINAURAL_CHANNELS ), ch ); + FOR( bin = 0; bin < num_freq_bands; bin++ ) + { + protoFrame_fx[add( imult1616( bin, BINAURAL_CHANNELS ), offset )] = inRe[ch][slot][bin]; // q_protoFrame + protoFrame_fx[add( imult1616( bin, BINAURAL_CHANNELS ), add( offset, 1 ) )] = inIm[ch][slot][bin]; // q_protoFrame + move32(); + move32(); + } + } + + /* Decorrelate proto signal to decorrelatedFrameInterleaved */ + ivas_dirac_dec_decorr_process_fx( num_freq_bands, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + BINAURAL_CHANNELS, + protoFrame_fx, + q_protoFrame, + BINAURAL_CHANNELS, + protoIndexDir, + decorrelatedFrameInterleaved_fx, + &q_decorrelatedFrameInterleaved, + onset_filter_fx, + hDiracDecBin->h_freq_domain_decorr_ap_params, + hDiracDecBin->h_freq_domain_decorr_ap_state ); + + /* De-interleave decorrelated signals*/ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + offset = imult1616( imult1616( num_freq_bands, BINAURAL_CHANNELS ), ch ); + FOR( bin = 0; bin < num_freq_bands; bin++ ) + { + decRe[ch][bin] = decorrelatedFrameInterleaved_fx[add( imult1616( bin, BINAURAL_CHANNELS ), offset )]; // q_inp + decIm[ch][bin] = decorrelatedFrameInterleaved_fx[add( imult1616( bin, BINAURAL_CHANNELS ), add( offset, 1 ) )]; // q_inp + move32(); + move32(); + } + } + // q_decorrelatedFrameInterleaved will be same as q_inp/q_protoFrame // + return; +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + PARAMBIN_REND_CONFIG_HANDLE hConfig, + Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q*/ + Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q*/ + const Word16 subframe, + Word32 *subFrameTotalEne_fx, + Word16 *subFrameTotalEne_e, + Word32 *IIReneLimiter_fx, + Word16 q ) +{ + Word16 ch, slot, bin; + Word16 nBins, shift; + Word32 IIReneLimiterFactor_fx; // Q26 + Word32 qualityBasedSmFactor_fx; + Word32 lowBitRateEQ_fx[CLDFB_NO_CHANNELS_MAX]; + UWord8 applyLowBitRateEQ; + PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; + IVAS_FORMAT ivas_format; + Word32 ivas_total_brate; + Word16 nchan_transport; + Word16 exp, exp1; + Word64 temp64; + Word32 temp; + + ivas_format = hConfig->ivas_format; + move32(); + ivas_total_brate = hConfig->ivas_total_brate; + move32(); + nchan_transport = hConfig->nchan_transport; + move16(); + qualityBasedSmFactor_fx = hConfig->qualityBasedSmFactor_fx; /*Q31*/ + move32(); + qualityBasedSmFactor_fx = Mpy_32_32( qualityBasedSmFactor_fx, qualityBasedSmFactor_fx ); /*Q31*/ + + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + move16(); + + + set32_fx( hDiracDecBin->ChCrossRe_fx, 0, nBins ); + set32_fx( hDiracDecBin->ChCrossIm_fx, 0, nBins ); + + + set16_fx( hDiracDecBin->ChCrossRe_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossIm_e, 0, nBins ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set32_fx( hDiracDecBin->ChEne_fx[ch], 0, nBins ); + + set16_fx( hDiracDecBin->ChEne_e[ch], 0, nBins ); + } + + set16_fx( subFrameTotalEne_e, 0, CLDFB_NO_CHANNELS_MAX ); + + /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ + applyLowBitRateEQ = 0; + move16(); + test(); + test(); + IF( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MC_FORMAT ) ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) + { + applyLowBitRateEQ = 1; + move16(); + IF( EQ_32( ivas_total_brate, IVAS_16k4 ) ) + { + FOR( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ_fx[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = L_add( L_shr( lowBitRateBinauralEQ_fx[bin], 1 ), ONE_IN_Q30 ); // Q31 + move32(); + } + } + ELSE + { + FOR( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ_fx[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ_fx[bin]; // Q31 + move32(); + } + } + } + + /* Formulate input and target covariance matrices for this subframe */ + set32_fx( subFrameTotalEne_fx, 0, CLDFB_NO_CHANNELS_MAX ); + + exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below + + /* Calculate input covariance matrix */ + FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + FOR( bin = 0; bin < nBins; bin++ ) + { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Word32 instEne_fx; + temp64 = W_mult0_32_32( inRe_fx[ch][slot][bin], inRe_fx[ch][slot][bin] ); // 2q + temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[ch][slot][bin], inIm_fx[ch][slot][bin] ) ); // 2q + exp1 = W_norm( temp64 ); + instEne_fx = W_extract_h( W_shl( temp64, exp1 ) ); // 2q - 32 + exp1 + /* exp of instEne_fx = 31 - (2q -32 + exp1) = 63 - 2q - exp1 = exp - exp1*/ + + hDiracDecBin->ChEne_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[ch][bin], hDiracDecBin->ChEne_e[ch][bin], instEne_fx, sub( exp, exp1 ), &hDiracDecBin->ChEne_e[ch][bin] ); + subFrameTotalEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameTotalEne_fx[bin], subFrameTotalEne_e[bin], instEne_fx, sub( exp, exp1 ), &subFrameTotalEne_e[bin] ); + move32(); + move32(); + } + temp64 = W_mult0_32_32( inRe_fx[0][slot][bin], inRe_fx[1][slot][bin] ); // 2q + temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ) ); // 2q + exp1 = W_norm( temp64 ); + temp = W_extract_h( W_shl( temp64, exp1 ) ); // // 2q - 32 + exp1 + hDiracDecBin->ChCrossRe_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossRe_e[bin], temp, sub( exp, exp1 ), &hDiracDecBin->ChCrossRe_e[bin] ); + move32(); + + temp64 = W_mult0_32_32( inRe_fx[0][slot][bin], inIm_fx[1][slot][bin] ); // 2q + temp64 = W_sub( temp64, W_mult0_32_32( inIm_fx[0][slot][bin], inRe_fx[1][slot][bin] ) ); // 2q + exp1 = W_norm( temp64 ); + temp = W_extract_h( W_shl( temp64, exp1 ) ); // // 2q - 32 + exp1 + hDiracDecBin->ChCrossIm_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossIm_fx[bin], hDiracDecBin->ChCrossIm_e[bin], temp, sub( exp, exp1 ), &hDiracDecBin->ChCrossIm_e[bin] ); + move32(); + } + } + + /* Apply EQ at low bit rates */ + IF( applyLowBitRateEQ != 0 ) + { + Word16 lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; + + FOR( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) + { + subFrameTotalEne_fx[bin] = Mpy_32_32( subFrameTotalEne_fx[bin], lowBitRateEQ_fx[bin] ); // exp = subFrameTotalEne_e[bin] + move32(); + } + FOR( ; bin < nBins; bin++ ) + { + subFrameTotalEne_fx[bin] = Mpy_32_32( subFrameTotalEne_fx[bin], lowBitRateEQ_fx[lastEqBin] ); // exp = subFrameTotalEne_e[bin] + move32(); + } + } + + test(); + test(); + IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( nchan_transport, 2 ) ) + { + Word32 tempRe, tempIm; + Word32 subFrameSumEne_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 subFrameSumEne_e[CLDFB_NO_CHANNELS_MAX]; + + set32_fx( subFrameSumEne_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set16_fx( subFrameSumEne_e, 0, CLDFB_NO_CHANNELS_MAX ); + FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + FOR( bin = 0; bin < nBins; bin++ ) + { + tempRe = L_add( inRe_fx[0][slot][bin], inRe_fx[1][slot][bin] ); // q + tempIm = L_add( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ); // q + temp64 = W_add( W_mult0_32_32( tempRe, tempRe ), W_mult0_32_32( tempIm, tempIm ) ); // 2q + exp1 = W_norm( temp64 ); + temp64 = W_shl( temp64, exp1 ); // 2q + exp1 + subFrameSumEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameSumEne_fx[bin], subFrameTotalEne_e[bin], W_extract_h( temp64 ), sub( exp /* 63 - 2q */, exp1 ) /*31 - (2q + exp1 - 32)*/, &subFrameTotalEne_e[bin] ); + move32(); + } + } + FOR( bin = 0; bin < nBins; bin++ ) + { + temp = L_shl_sat( subFrameTotalEne_fx[bin], sub( subFrameTotalEne_e[bin], subFrameSumEne_e[bin] ) ); // subFrameSumEne_e[bin] + IF( GT_32( subFrameSumEne_fx[bin], temp ) ) + { + subFrameTotalEne_fx[bin] = subFrameSumEne_fx[bin]; + move32(); + subFrameTotalEne_e[bin] = subFrameSumEne_e[bin]; + move16(); + } + } + } + + + test(); + /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ + IF( EQ_32( ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) + { + IIReneLimiterFactor_fx = L_add( L_shl( 16, Q26 ), L_sub( L_shl( 1, Q26 ), L_shr( qualityBasedSmFactor_fx, 5 ) ) ); // Q26 + } + ELSE + { + IIReneLimiterFactor_fx = L_add( L_shl( 8, Q26 ), L_sub( L_shl( 1, Q26 ), L_shr( qualityBasedSmFactor_fx, 5 ) ) ); // Q26 + } + + FOR( bin = 0; bin < nBins; bin++ ) + { + + /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that + * the energy history (IIR) must not be more than double of the current frame energy. This provides more + * robust performance at energy offsets when compared to typical IIR averaging. */ + Word16 num_e, den_e; + Word32 num, den; + num = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->ChEne_e[1][bin], &num_e ); + num = Mpy_32_32( num, IIReneLimiterFactor_fx ); /*Q = (31 - num_e + 26 - 31) = (26 - num_e)*/ + den_e = 0; + move16(); + den = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEnePrev_fx[0][bin], hDiracDecBin->ChEnePrev_e[0][bin], hDiracDecBin->ChEnePrev_fx[1][bin], hDiracDecBin->ChEnePrev_e[1][bin], &den_e ); + den = L_max( 1, den ); + IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp ); + exp = add( sub( num_e, den_e ), add( 5, exp ) ); + IF( L_shr_sat( IIReneLimiter_fx[bin], sub( 31, exp ) ) > 0 ) + { + IIReneLimiter_fx[bin] = ONE_IN_Q31; /*Q31*/ + move32(); + } + ELSE + { + IIReneLimiter_fx[bin] = L_shl( IIReneLimiter_fx[bin], exp ); /*Q31*/ + } + + hDiracDecBin->ChCrossRe_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossRe_fx[bin], qualityBasedSmFactor_fx ); + hDiracDecBin->ChCrossIm_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossIm_fx[bin], qualityBasedSmFactor_fx ); + + move32(); + move32(); + move32(); + move32(); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne_fx[ch][bin] = Mpy_32_32( hDiracDecBin->ChEne_fx[ch][bin], qualityBasedSmFactor_fx ); + move32(); + } + + hDiracDecBin->ChCrossRe_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossRe_e[bin], Mpy_32_32( hDiracDecBin->ChCrossRePrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossRePrev_e[bin], &hDiracDecBin->ChCrossRe_e[bin] ); + hDiracDecBin->ChCrossIm_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossIm_fx[bin], hDiracDecBin->ChCrossIm_e[bin], Mpy_32_32( hDiracDecBin->ChCrossImPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossImPrev_e[bin], &hDiracDecBin->ChCrossIm_e[bin] ); + move32(); + move32(); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[ch][bin], hDiracDecBin->ChEne_e[ch][bin], Mpy_32_32( hDiracDecBin->ChEnePrev_fx[ch][bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChEnePrev_e[ch][bin], &hDiracDecBin->ChEne_e[ch][bin] ); + move32(); + } + + /* Store energy values and coefficients for next round */ + hDiracDecBin->ChCrossRePrev_fx[bin] = hDiracDecBin->ChCrossRe_fx[bin]; + move32(); + hDiracDecBin->ChCrossImPrev_fx[bin] = hDiracDecBin->ChCrossIm_fx[bin]; + move32(); + hDiracDecBin->ChCrossRePrev_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; + move16(); + hDiracDecBin->ChCrossImPrev_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; + move16(); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEnePrev_fx[ch][bin] = hDiracDecBin->ChEne_fx[ch][bin]; + move32(); + hDiracDecBin->ChEnePrev_e[ch][bin] = hDiracDecBin->ChEne_e[ch][bin]; + move16(); + } + } + + return; +} + +static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + const PARAMBIN_REND_CONFIG_HANDLE hConfig, + Word32 Rmat_fx[3][3], + const int16_t subframe, + const int16_t isHeadtracked, + Word32 *subFrameTotalEne_fx, + Word16 *subFrameTotalEne_e, + Word32 *IIReneLimiter_fx, + const MASA_ISM_DATA_HANDLE hMasaIsmData ) +{ + Word16 ch, bin; + Word16 separateCenterChannelRendering; + Word16 nBins, idx, shift; + Word32 frameMeanDiffusenessEneWeight_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 qualityBasedSmFactor_fx; + Word16 dirac_read_idx; + PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; + IVAS_FORMAT ivas_format; + MC_MODE mc_mode; + Word16 gainCacheBaseIndex; + Word16 q_earlyPartEneCorrection; + Word16 exp, exp1; + Word32 temp; + + separateCenterChannelRendering = hConfig->separateCenterChannelRendering; + move16(); + ivas_format = hConfig->ivas_format; + move32(); + mc_mode = hConfig->mc_mode; + move32(); + qualityBasedSmFactor_fx = hConfig->qualityBasedSmFactor_fx; /*Q31*/ + move32(); + qualityBasedSmFactor_fx = Mpy_32_32( qualityBasedSmFactor_fx, qualityBasedSmFactor_fx ); /*Q31*/ + + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + move16(); + + q_earlyPartEneCorrection = s_min( Q31, add( getScaleFactor32( hDiracDecBin->earlyPartEneCorrection_fx, nBins ), hDiracDecBin->q_earlyPartEneCorrection ) ); + scale_sig32( hDiracDecBin->earlyPartEneCorrection_fx, nBins, sub( q_earlyPartEneCorrection, hDiracDecBin->q_earlyPartEneCorrection ) ); + hDiracDecBin->q_earlyPartEneCorrection = q_earlyPartEneCorrection; + move16(); + + set32_fx( hDiracDecBin->ChCrossReOut_fx, 0, nBins ); + set32_fx( hDiracDecBin->ChCrossImOut_fx, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossReOut_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossImOut_e, 0, nBins ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set32_fx( hDiracDecBin->ChEneOut_fx[ch], 0, nBins ); + set16_fx( hDiracDecBin->ChEneOut_e[ch], 0, nBins ); + } + set32_fx( hDiracDecBin->frameMeanDiffuseness_fx, 0, nBins ); + + set32_fx( frameMeanDiffusenessEneWeight_fx, 0, CLDFB_NO_CHANNELS_MAX ); + + FOR( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) + { + gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ + move16(); + } + + /* Determine target covariance matrix containing target binaural properties */ + FOR( bin = 0; bin < nBins; bin++ ) + { + Word32 diffuseness_fx = ONE_IN_Q30; /* ratio1 and ratio2 are subtracted from diffuseness further below */ + Word32 diffusenessValForDecorrelationReduction_fx = ONE_IN_Q30; + Word32 diffEneValForDecorrelationReduction_fx; + Word16 q_diffEneValForDecorrelationReduction; + Word16 surCoh_fx = 0, spreadCoh_fx = 0; /* Default values if spreadSurroundCoherenceApplied == false */ + Word32 diffEne_fx, dirEne_fx, meanEnePerCh_fx; + Word16 q_meanEnePerCh; + Word16 q_diffEne, q_dirEne; + Word16 dirIndex; + move16(); + move16(); + move32(); + move32(); + + /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. + * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the + * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match + * the early spectrum of the BRIR data, using the spectral correction data in + * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ + meanEnePerCh_fx = Mpy_32_32( hDiracDecBin->earlyPartEneCorrection_fx[bin], subFrameTotalEne_fx[bin] ); // Q( q_meanEnePerCh ) + q_meanEnePerCh = add( sub( q_earlyPartEneCorrection, subFrameTotalEne_e[bin] ), 1 ); // q_earlyPartEneCorrection + 31 - subFrameTotalEne_e[bin] - 31 + Q1(0.5f) + /* Determine direct part target covariance matrix (for 1 or 2 directions) */ + FOR( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ ) + { + Word16 aziDeg, eleDeg; + Word32 lRealp_fx, lImagp_fx, rRealp_fx, rImagp_fx; + Word32 lRealpTmp_fx, lImagpTmp_fx, rRealpTmp_fx, rImagpTmp_fx; + Word32 hrtfEne_fx[BINAURAL_CHANNELS], hrtfCrossRe_fx, hrtfCrossIm_fx, ratio_fx; + UWord8 isIsmDirection = 0; + move16(); + + test(); + test(); + IF( dirIndex == 0 ) /* For first of the two simultaneous directions */ + { + aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; + move16(); + eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; + move16(); + ratio_fx = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin]; + move32(); + spreadCoh_fx = hSpatParamRendCom->spreadCoherence_fx[dirac_read_idx][bin]; + move16(); + gainCacheBaseIndex = 0; + move16(); + } + ELSE IF( NE_32( ivas_format, MASA_ISM_FORMAT ) || ( EQ_32( ivas_format, MASA_ISM_FORMAT ) && LT_16( dirIndex, hSpatParamRendCom->numParametricDirections ) ) ) /* For second of the two simultaneous directions */ + { + IF( LT_32( ( ratio_fx = hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] ), 10737418 /* 0.01 in Q30 */ ) ) + { + /* This touches only MASA path where second direction always has smaller ratio and + * for non-2dir it is zero. As the whole direction contribution is multiplied with + * the ratio, a very small ratio does not contribute any energy to output. Thus, + * it is better to save complexity. */ + CONTINUE; + } + aziDeg = hSpatParamRendCom->azimuth2[dirac_read_idx][bin]; + move16(); + eleDeg = hSpatParamRendCom->elevation2[dirac_read_idx][bin]; + move16(); + spreadCoh_fx = hSpatParamRendCom->spreadCoherence2_fx[dirac_read_idx][bin]; + move16(); + gainCacheBaseIndex = 3; + move16(); + } + ELSE /* For object directions of MASA_ISM_FORMAT */ + { + isIsmDirection = 1; + move16(); + UWord16 ismDirIndex; + ismDirIndex = sub( dirIndex, hSpatParamRendCom->numParametricDirections ); + assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); + IF( hMasaIsmData->ism_is_edited[ismDirIndex] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; + move16(); + eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; + move16(); + } + ELSE + { + aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; + move16(); + eleDeg = hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx]; + move16(); + } + ratio_fx = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin]; + move32(); + spreadCoh_fx = 0; + move16(); + gainCacheBaseIndex = add( 6, ismDirIndex ); + } + + diffuseness_fx = L_sub( diffuseness_fx, ratio_fx ); /* diffuseness = 1 - ratio1 - ratio2 */ + + if ( diffuseness_fx < 0 ) + { + diffuseness_fx = 0; + move32(); + } + IF( isIsmDirection ) + { + /* Objects cause lesser decorrelation reduction, to avoid removing all decorrelation when only objects are present */ + diffusenessValForDecorrelationReduction_fx = L_sub( diffusenessValForDecorrelationReduction_fx, L_shr( ratio_fx, 1 ) ); /*Q30*/ + } + ELSE + { + diffusenessValForDecorrelationReduction_fx = L_sub( diffusenessValForDecorrelationReduction_fx, ratio_fx ); /*Q30*/ + } + + IF( separateCenterChannelRendering ) + { + /* In masa + mono rendering mode, the center directions originate from phantom sources, so the + * spread coherence is increased */ + Word16 azi_scaled, ele_scaled; + Word32 doaVectorX_fx, num, den; + Word16 e = 0, spatialAngleDeg_fx, altSpreadCoh_fx; + move16(); + + azi_scaled = i_mult( aziDeg, 91 ); + ele_scaled = i_mult( eleDeg, 91 ); + doaVectorX_fx = L_mult( getCosWord16R2( azi_scaled ), getCosWord16R2( ele_scaled ) ); /*Q31*/ + num = Sqrt32( L_sub( ONE_IN_Q31, Mpy_32_32( doaVectorX_fx, doaVectorX_fx ) ), &e ); + den = doaVectorX_fx; + move32(); + spatialAngleDeg_fx = BASOP_util_atan2( num, den, e ); // Q13 + Word16 numr, num_e = 0, denr, den_e; + move16(); + num_e = sub( norm_s( spatialAngleDeg_fx ), 1 ); + numr = shl( spatialAngleDeg_fx, num_e ); + denr = 17157; + move16(); + den_e = 4; + move16(); + altSpreadCoh_fx = sub( 32767, shl_sat( div_s( numr, denr ), sub( den_e, num_e ) ) ); // 4289 = pi/6 in Q13 + spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx ); + } + + getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked ); + + Word16 q_lr = Q28; + move16(); + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* Synthesizing spread coherence is not needed for stereo loudspeaker output, + * as directional sound is reproduced with two loudspeakers in any case */ + spreadCoh_fx = 0; + move32(); + } + + IF( spreadCoh_fx > 0 ) + { + Word32 centerMul_fx, sidesMul_fx; + Word32 hrtfEneCenter_fx, hrtfEneSides_fx, hrtfEneRealized_fx; + Word16 eneCorrectionFactor_fx, eneCorrectionFactor_e; + Word16 w1_fx, w2_fx, w3_fx, eq_fx; + + hrtfEneCenter_fx = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), // Q25 + L_add( Mpy_32_32( lImagp_fx, lImagp_fx ), // Q25 + L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), // Q25 + Mpy_32_32( rImagp_fx, rImagp_fx ) ) ) ); // Q25 + + /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. + * The following formulas determine the gains for these sources. + * spreadCoh = 0: Only panning + * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) + * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ + IF( LT_16( spreadCoh_fx, 16384 ) ) + { + /* 0.0f < spreadCoh < 0.5f */ + sidesMul_fx = L_mult0( spreadCoh_fx, 9459 ); /* 2*sqrt(1/3) in Q13 = 9459 */ // Q28 + centerMul_fx = L_add( L_sub( ONE_IN_Q28, L_shl( spreadCoh_fx, 14 ) ), sidesMul_fx ); // Q28 + } + ELSE + { + /* 0.5f <= spreadCoh < 1.0f */ + // centerMul = 2.0f - ( 2.0f * spreadCoh ); + centerMul_fx = L_shl( sub( 32767, spreadCoh_fx ), 14 ); // Q28 + sidesMul_fx = Isqrt( L_add( L_shr( centerMul_fx, 22 ), L_shl( 2, Q6 ) ) ); // Q28 + centerMul_fx = L_shl( Mpy_32_32( centerMul_fx, sidesMul_fx ), 3 ); // Q28 + } + + /* Apply the gain for the center source of the three coherent sources */ + lRealp_fx = Mpy_32_32( lRealp_fx, centerMul_fx ); // Q25 + lImagp_fx = Mpy_32_32( lImagp_fx, centerMul_fx ); // Q25 + rRealp_fx = Mpy_32_32( rRealp_fx, centerMul_fx ); // Q25 + rImagp_fx = Mpy_32_32( rImagp_fx, centerMul_fx ); // Q25 + + /* Apply the gain for the left source of the three coherent sources */ + getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked ); + + hrtfEneSides_fx = L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 + L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ), // Q25 + L_add( Mpy_32_32( rRealpTmp_fx, rRealpTmp_fx ), // Q25 + Mpy_32_32( rImagpTmp_fx, rImagpTmp_fx ) ) ) ); // Q25 + lRealp_fx = L_add( lRealp_fx, Mpy_32_32( sidesMul_fx, lRealpTmp_fx ) ); // Q25 + lImagp_fx = L_add( lImagp_fx, Mpy_32_32( sidesMul_fx, lImagpTmp_fx ) ); // Q25 + rRealp_fx = L_add( rRealp_fx, Mpy_32_32( sidesMul_fx, rRealpTmp_fx ) ); // Q25 + rImagp_fx = L_add( rImagp_fx, Mpy_32_32( sidesMul_fx, rImagpTmp_fx ) ); // Q25 + + /* Apply the gain for the right source of the three coherent sources. + * -30 degrees to 330 wrapping due to internal functions. */ + + getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); + + hrtfEneSides_fx = L_add( hrtfEneSides_fx, + L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 + L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ), // Q25 + L_add( Mpy_32_32( rRealpTmp_fx, rRealpTmp_fx ), // Q25 + Mpy_32_32( rImagpTmp_fx, rImagpTmp_fx ) ) ) ) ); // Q25 + lRealp_fx = L_add( lRealp_fx, Mpy_32_32( sidesMul_fx, lRealpTmp_fx ) ); // Q25 + lImagp_fx = L_add( lImagp_fx, Mpy_32_32( sidesMul_fx, lImagpTmp_fx ) ); // Q25 + rRealp_fx = L_add( rRealp_fx, Mpy_32_32( sidesMul_fx, rRealpTmp_fx ) ); // Q25 + rImagp_fx = L_add( rImagp_fx, Mpy_32_32( sidesMul_fx, rImagpTmp_fx ) ); // Q25 + + /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ + hrtfEneRealized_fx = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), // Q19 + L_add( Mpy_32_32( lImagp_fx, lImagp_fx ), // Q19 + L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), // Q19 + Mpy_32_32( rImagp_fx, rImagp_fx ) ) ) ); // Q19 + + eneCorrectionFactor_fx = BASOP_Util_Divide3232_Scale( L_add( Mpy_32_32( hrtfEneSides_fx, Mpy_32_32( sidesMul_fx, sidesMul_fx ) ), + Mpy_32_32( hrtfEneCenter_fx, Mpy_32_32( centerMul_fx, centerMul_fx ) ) ), + L_max( 1, hrtfEneRealized_fx ), &eneCorrectionFactor_e ); + + /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ + IF( LT_16( spreadCoh_fx, 16384 ) ) + { + w1_fx = sub( 32767, shl( spreadCoh_fx, 1 ) ); /*Q15*/ + w2_fx = shl( spreadCoh_fx, 1 ); /*Q15*/ + w3_fx = 0; + move16(); + } + ELSE + { + w1_fx = 0; + move16(); + w2_fx = shl( sub( 32767, spreadCoh_fx ), 1 ); /*Q15*/ + w3_fx = shl( sub( spreadCoh_fx, 16384 ), 1 ); /*Q15*/ + } + + test(); + IF( ( EQ_32( ivas_format, MC_FORMAT ) && EQ_32( mc_mode, MC_MODE_MCMASA ) ) ) + { + idx = s_min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + + /* Apply the target spectrum to the eneCorrectionFactor */ + IF( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ + { + eneCorrectionFactor_fx = mult_r( eneCorrectionFactor_fx, add( mult_r( w1_fx, 8192 ), shr( mult_r( add( w2_fx, w3_fx ), spreadCohEne1_fx[idx] ), 1 ) ) ); + eneCorrectionFactor_e = add( eneCorrectionFactor_e, 2 ); + } + ELSE + { + eneCorrectionFactor_fx = mult_r( eneCorrectionFactor_fx, add( mult_r( w1_fx, 4096 ), add( shr( mult_r( w2_fx, spreadCohEne05_fx[idx] ), 1 ), shr( mult_r( w3_fx, spreadCohEne1_fx[idx] ), 2 ) ) ) ); + eneCorrectionFactor_e = add( eneCorrectionFactor_e, 3 ); + } + } + + /* Equalize the spread coherent combined HRTFs */ + Word16 tmp, tmp_e; + tmp_e = eneCorrectionFactor_e; + move16(); + tmp = Sqrt16( eneCorrectionFactor_fx, &tmp_e ); + IF( GE_16( shr( tmp, sub( 15, tmp_e ) ), 4 ) ) + { + eq_fx = 32767; // Q13 + move16(); + } + ELSE + { + eq_fx = shl( tmp, sub( tmp_e, 2 ) ); // Q13 + } + + lRealp_fx = Mpy_32_16_1( lRealp_fx, eq_fx ); // Q23 + lImagp_fx = Mpy_32_16_1( lImagp_fx, eq_fx ); // Q23 + rRealp_fx = Mpy_32_16_1( rRealp_fx, eq_fx ); // Q23 + rImagp_fx = Mpy_32_16_1( rImagp_fx, eq_fx ); // Q23 + q_lr = Q23; + move16(); + } + + hrtfEne_fx[0] = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), Mpy_32_32( lImagp_fx, lImagp_fx ) ); // Q( 2*q_lr - 31 ) + hrtfEne_fx[1] = L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), Mpy_32_32( rImagp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) + move32(); + move32(); + hrtfCrossRe_fx = L_add( Mpy_32_32( lRealp_fx, rRealp_fx ), Mpy_32_32( lImagp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) + hrtfCrossIm_fx = L_add( Mpy_32_32( -lImagp_fx, rRealp_fx ), Mpy_32_32( lRealp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) + + /* Add direct part (1 or 2) covariance matrix */ + dirEne_fx = Mpy_32_32( ratio_fx, meanEnePerCh_fx ); // Q(q_meanEnePerCh - 1) + shift = norm_l( dirEne_fx ); + dirEne_fx = L_shl( dirEne_fx, shift ); + q_dirEne = add( sub( q_meanEnePerCh, 1 ), shift ); + + hDiracDecBin->ChEneOut_fx[0][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[0][bin], hDiracDecBin->ChEneOut_e[0][bin], Mpy_32_32( dirEne_fx, hrtfEne_fx[0] ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChEneOut_e[0][bin] ); /* Dir ene part*/ + hDiracDecBin->ChEneOut_fx[1][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[1][bin], hDiracDecBin->ChEneOut_e[1][bin], Mpy_32_32( dirEne_fx, hrtfEne_fx[1] ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChEneOut_e[1][bin] ); + hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( dirEne_fx, hrtfCrossRe_fx ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChCrossReOut_e[bin] ); /* Dir cross re */ + hDiracDecBin->ChCrossImOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossImOut_fx[bin], hDiracDecBin->ChCrossImOut_e[bin], Mpy_32_32( dirEne_fx, hrtfCrossIm_fx ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChCrossImOut_e[bin] ); /* Dir cross im */ + move32(); + move32(); + move32(); + move32(); + } + + /* Add diffuse / ambient part covariance matrix */ + diffuseness_fx = L_max( 0, diffuseness_fx ); // Q30 + diffEne_fx = Mpy_32_32( diffuseness_fx, meanEnePerCh_fx ); // Q(2q - 32) + shift = norm_l( diffEne_fx ); + diffEne_fx = L_shl( diffEne_fx, shift ); + q_diffEne = add( shift, sub( q_meanEnePerCh, 1 ) ); + + surCoh_fx = hSpatParamRendCom->surroundingCoherence_fx[dirac_read_idx][bin]; // Q15 + move16(); + + diffusenessValForDecorrelationReduction_fx = L_max( 0, diffusenessValForDecorrelationReduction_fx ); // Q30 + diffEneValForDecorrelationReduction_fx = Mpy_32_32( diffusenessValForDecorrelationReduction_fx, meanEnePerCh_fx ); // resulting Q = q_meanEnePerCh - 1 + q_diffEneValForDecorrelationReduction = sub( q_meanEnePerCh, 1 ); + + test(); + IF( ( EQ_32( ivas_format, MC_FORMAT ) && EQ_32( mc_mode, MC_MODE_MCMASA ) ) ) + { + IF( !hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + Word32 spectrumModVal; + + idx = s_min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ + spectrumModVal = L_add( L_sub( ONE_IN_Q29, L_shl( surCoh_fx, 14 ) ), L_mult( surCoh_fx, surCohEne_fx[idx] ) ); // Q29 + diffEne_fx = Mpy_32_32( diffEne_fx, spectrumModVal ); // Q-2 + q_diffEne = sub( q_diffEne, 2 ); + /* Modify also the value for decorrelation reduction */ + diffEneValForDecorrelationReduction_fx = Mpy_32_32( diffEneValForDecorrelationReduction_fx, spectrumModVal ); // Q-2 + q_diffEneValForDecorrelationReduction = sub( q_diffEneValForDecorrelationReduction, 2 ); + } + } + hDiracDecBin->ChEneOut_fx[0][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[0][bin], hDiracDecBin->ChEneOut_e[0][bin], diffEne_fx, sub( 31, q_diffEne ), &hDiracDecBin->ChEneOut_e[0][bin] ); /* Diff ene part*/ + hDiracDecBin->ChEneOut_fx[1][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[1][bin], hDiracDecBin->ChEneOut_e[1][bin], diffEne_fx, sub( 31, q_diffEne ), &hDiracDecBin->ChEneOut_e[1][bin] ); - hDiracDecBin->hDiffuseDist = NULL; + move32(); + move32(); + IF( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ + hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_16_1( diffEne_fx, surCoh_fx ), sub( 31, q_diffEne ), &hDiracDecBin->ChCrossReOut_e[bin] ); + move32(); + } + ELSE /* When rendering binaural, ambience has frequency dependent ICC. */ + { + test(); + test(); + IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && LT_16( bin, BINAURAL_COHERENCE_DIFFERENCE_BINS ) ) + { + Word32 diffuseFieldCoherence_fx; + Word16 tmp_exp; + temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hDiracDecBin->hDiffuseDist->diffuseRatioX_fx[bin], hDiracDecBin->diffuseFieldCoherenceX_fx[bin] ), 0, Mpy_32_32( hDiracDecBin->hDiffuseDist->diffuseRatioY_fx[bin], hDiracDecBin->diffuseFieldCoherenceY_fx[bin] ), 0, &tmp_exp ); + diffuseFieldCoherence_fx = BASOP_Util_Add_Mant32Exp( temp, tmp_exp, Mpy_32_32( hDiracDecBin->hDiffuseDist->diffuseRatioZ_fx[bin], hDiracDecBin->diffuseFieldCoherenceZ_fx[bin] ), 0, &tmp_exp ); + temp = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( diffuseFieldCoherence_fx, sub( 32767, surCoh_fx ) ), tmp_exp, L_shl( surCoh_fx, 16 ), 0, &tmp_exp ); + hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( temp, diffEne_fx ), add( tmp_exp, sub( 31, q_diffEne ) ), &hDiracDecBin->ChCrossReOut_e[bin] ); + } + ELSE + { + hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( L_add( Mpy_32_16_1( hDiracDecBin->diffuseFieldCoherence_fx[bin], sub( 32767, surCoh_fx ) ), L_shl( surCoh_fx, 16 ) ), diffEne_fx ), sub( 31, q_diffEne ), &hDiracDecBin->ChCrossReOut_e[bin] ); + } + move32(); + } - hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] ); - hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); + /* Store parameters for formulating average diffuseness over frame */ + Word32 frameMeanDiffuseness = BASOP_Util_Add_Mant32Exp( hDiracDecBin->frameMeanDiffuseness_fx[bin], 2 /*Q29*/, diffEneValForDecorrelationReduction_fx, sub( 31, q_diffEneValForDecorrelationReduction ), &exp1 ); // exp = exp1 + frameMeanDiffusenessEneWeight_fx[bin] = L_add( frameMeanDiffusenessEneWeight_fx[bin], meanEnePerCh_fx ); + move32(); - move16(); - move16(); - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - scale_sig32( output_fx[ch], imult1616( nBins, hSpatParamRendCom->subframe_nbslots[subframe] ), sub( 11, q_out ) ); // Scaling to Q11 - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; - move16(); + /* Formulate average diffuseness over frame */ + frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_cadence( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1 + exp = sub( exp, sub( sub( 31, q_meanEnePerCh ), exp1 ) ); + hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29 + move32(); } - return; -} - - -static void ivas_dirac_dec_decorrelate_slot_fx( - DIRAC_DEC_BIN_HANDLE hDiracDecBin, - const Word16 num_freq_bands, - const Word16 slot, - Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ - Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ - Word16 q_inp, - Word32 decRe[][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ - Word32 decIm[][CLDFB_NO_CHANNELS_MAX] /*q_inp*/ ) -{ - Word16 offset, ch, bin; - Word32 onset_filter_fx[BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, 60 bins */ - Word32 decorrelatedFrameInterleaved_fx[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ - Word32 protoFrame_fx[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ - Word16 q_decorrelatedFrameInterleaved, q_protoFrame; - const Word16 protoIndexDir[BINAURAL_CHANNELS] = { 0, 1 }; - move16(); - q_protoFrame = q_inp; - move16(); - /* Decorrelation needs interleaved data. Copy left and right signals to proto_frame_f */ - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( bin = 0; bin < nBins; bin++ ) { - offset = imult1616( imult1616( num_freq_bands, BINAURAL_CHANNELS ), ch ); - FOR( bin = 0; bin < num_freq_bands; bin++ ) + hDiracDecBin->ChCrossReOut_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossReOut_fx[bin], qualityBasedSmFactor_fx ); + hDiracDecBin->ChCrossImOut_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossImOut_fx[bin], qualityBasedSmFactor_fx ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - protoFrame_fx[add( imult1616( bin, BINAURAL_CHANNELS ), offset )] = inRe[ch][slot][bin]; // q_protoFrame - protoFrame_fx[add( imult1616( bin, BINAURAL_CHANNELS ), add( offset, 1 ) )] = inIm[ch][slot][bin]; // q_protoFrame + hDiracDecBin->ChEneOut_fx[ch][bin] = Mpy_32_32( hDiracDecBin->ChEneOut_fx[ch][bin], qualityBasedSmFactor_fx ); move32(); + } + hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossReOutPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossReOutPrev_e[bin], &hDiracDecBin->ChCrossReOut_e[bin] ); + hDiracDecBin->ChCrossImOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossImOut_fx[bin], hDiracDecBin->ChCrossImOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossImOutPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossImOutPrev_e[bin], &hDiracDecBin->ChCrossImOut_e[bin] ); + move32(); + move32(); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEneOut_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[ch][bin], hDiracDecBin->ChEneOut_e[ch][bin], Mpy_32_32( hDiracDecBin->ChEneOutPrev_fx[ch][bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChEneOutPrev_e[ch][bin], &hDiracDecBin->ChEneOut_e[ch][bin] ); move32(); } - } - /* Decorrelate proto signal to decorrelatedFrameInterleaved */ - ivas_dirac_dec_decorr_process_fx( num_freq_bands, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - BINAURAL_CHANNELS, - protoFrame_fx, - q_protoFrame, - BINAURAL_CHANNELS, - protoIndexDir, - decorrelatedFrameInterleaved_fx, - &q_decorrelatedFrameInterleaved, - onset_filter_fx, - hDiracDecBin->h_freq_domain_decorr_ap_params, - hDiracDecBin->h_freq_domain_decorr_ap_state ); - /* De-interleave decorrelated signals*/ - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - offset = imult1616( imult1616( num_freq_bands, BINAURAL_CHANNELS ), ch ); - FOR( bin = 0; bin < num_freq_bands; bin++ ) + hDiracDecBin->ChCrossReOutPrev_fx[bin] = hDiracDecBin->ChCrossReOut_fx[bin]; + move32(); + hDiracDecBin->ChCrossImOutPrev_fx[bin] = hDiracDecBin->ChCrossImOut_fx[bin]; + move32(); + hDiracDecBin->ChCrossReOutPrev_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; + move16(); + hDiracDecBin->ChCrossImOutPrev_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; + move16(); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - decRe[ch][bin] = decorrelatedFrameInterleaved_fx[add( imult1616( bin, BINAURAL_CHANNELS ), offset )]; // q_inp - decIm[ch][bin] = decorrelatedFrameInterleaved_fx[add( imult1616( bin, BINAURAL_CHANNELS ), add( offset, 1 ) )]; // q_inp + hDiracDecBin->ChEnePrev_fx[ch][bin] = hDiracDecBin->ChEne_fx[ch][bin]; move32(); + hDiracDecBin->ChEnePrev_e[ch][bin] = hDiracDecBin->ChEne_e[ch][bin]; + move16(); + hDiracDecBin->ChEneOutPrev_fx[ch][bin] = hDiracDecBin->ChEneOut_fx[ch][bin]; move32(); + hDiracDecBin->ChEneOutPrev_e[ch][bin] = hDiracDecBin->ChEneOut_e[ch][bin]; + move16(); } } - // q_decorrelatedFrameInterleaved will be same as q_inp/q_protoFrame // + return; } + +#else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -1773,6 +2780,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric return; } +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, @@ -2381,7 +3389,18 @@ static void ivas_dirac_dec_binaural_process_output_fx( const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, - const Word16 q_mat ) + const Word16 q_mat +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + Word32 outRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word32 outIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word32 reverbRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word32 reverbIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word32 decorrRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word32 decorrIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const UWord8 recompute +#endif +) { Word16 slot, bin, chA, chB; Word16 nBins; @@ -2397,8 +3416,10 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 decSlotRe_fx[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], decSlotIm_fx[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 outSlotRe_fx[CLDFB_NO_CHANNELS_MAX], outSlotIm_fx[CLDFB_NO_CHANNELS_MAX]; +#ifndef SPLIT_REND_WITH_HEAD_ROT Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#endif Word16 q_inp[6][CLDFB_SLOTS_PER_SUBFRAME]; Word16 interpVal_fx; Word32 *decSlotRePointer_fx; @@ -2409,8 +3430,15 @@ static void ivas_dirac_dec_binaural_process_output_fx( IF( processReverb ) { - /* Process second / room effect part of binaural output when needed */ - ivas_binaural_reverb_processSubframe_fx( hDiracDecBin->hReverb, numInChannels, nSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( recompute == 1 ) + { +#endif + /* Process second / room effect part of binaural output when needed */ + ivas_binaural_reverb_processSubframe_fx( hDiracDecBin->hReverb, numInChannels, nSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } // scaling input and reverb to same q// @@ -2425,7 +3453,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], nBins ), L_norm_arr( inIm_fx[i][j], nBins ) ); move16(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) +#else IF( ( processReverb ) && LT_16( i, 2 ) ) +#endif { q_reverb = s_min( L_norm_arr( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); q_inp[i][j] = s_min( q_reverb, q_inp[i][j] ); @@ -2453,7 +3485,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( scale_sig32( inRe_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ scale_sig32( inIm_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ test(); - IF( processReverb && LT_16( i, 2 ) ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) +#else + IF( ( processReverb ) && LT_16( i, 2 ) ) +#endif { scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ @@ -2493,7 +3529,27 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( !hDiracDecBin->useTdDecorr && ( max_band_decorr > 0 ) ) { - ivas_dirac_dec_decorrelate_slot_fx( hDiracDecBin, nBins, slot, inRe_fx, inIm_fx, q_inp_mix, decSlotRe_fx, decSlotIm_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( recompute == 1 ) + { +#endif + ivas_dirac_dec_decorrelate_slot_fx( hDiracDecBin, nBins, slot, inRe_fx, inIm_fx, q_inp_mix, decSlotRe_fx, decSlotIm_fx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + Copy32( decSlotRe_fx[chA], decorrRe_fx[chA][slot], CLDFB_NO_CHANNELS_MAX ); + Copy32( decSlotIm_fx[chA], decorrIm_fx[chA][slot], CLDFB_NO_CHANNELS_MAX ); + } + } + else + { + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + Copy32( decorrRe_fx[chA][slot], decSlotRe_fx[chA], CLDFB_NO_CHANNELS_MAX ); + Copy32( decorrIm_fx[chA][slot], decSlotIm_fx[chA], CLDFB_NO_CHANNELS_MAX ); + } + } +#endif } FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -2583,13 +3639,40 @@ static void ivas_dirac_dec_binaural_process_output_fx( outSlotRePr_fx = &( outSlotRe_fx[0] ); outSlotImPr_fx = &( outSlotIm_fx[0] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( outRe_fx != NULL && outIm_fx != NULL ) + { + /* provide the data outside in CLDFB domain => mainly for split rendering */ + Copy32( outSlotRePr_fx, outRe_fx[chA][slot], CLDFB_NO_CHANNELS_MAX ); + Copy32( outSlotImPr_fx, outIm_fx[chA][slot], CLDFB_NO_CHANNELS_MAX ); + Scale_sig32( outRe_fx[chA][slot], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_result ) ); // Q6 + Scale_sig32( outIm_fx[chA][slot], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_result ) ); // Q6 + } + if ( recompute == 1 ) + { + /* Inverse filter bank */ + cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); + cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); + move16(); + } +#else cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); +#endif } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( recompute == 1 ) + { + *q_out = sub( q_result, 1 ); + move16(); + } +#else *q_out = sub( q_result, 1 ); move16(); +#endif + return; } @@ -5394,9 +6477,16 @@ static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[], /* Q11*/ - const Word16 subframe ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 subframe, + const SPLIT_REND_WRAPPER *hSplitRendWrapper, + Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] +#else + const Word16 subframe +#endif +) { - DIRAC_DEC_BIN_HANDLE hDiracDecBin; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; PARAMBIN_REND_CONFIG config_data; @@ -5406,7 +6496,25 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Word16 i, j; Word16 nchan_transport; Word16 q_mat; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + Word32 tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + + /* these allow re-using the reverb and freq-domain decorrelator signals from ivas_dirac_dec_binaural_process_output() in split rendering for the side renderings */ + Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 decorrRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 decorrIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX]; + Word32 IIReneLimiter_fx[CLDFB_NO_CHANNELS_MAX]; + + hDiracDecBin = hMasaExtRend->hDiracDecBin[0]; +#else hDiracDecBin = hMasaExtRend->hDiracDecBin; +#endif hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -5526,18 +6634,30 @@ static void ivas_masa_ext_rend_parambin_internal_fx( IF( EQ_16( nchan_transport, 2 ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ +#endif adaptTransportSignalsHeadtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); } } test(); +#ifndef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, NULL, q_inp ); - +#endif /* Always using CLDFB decorrelation in MASA EXT renderer */ max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, subframe, + subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, q_inp ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_fx, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, NULL ); +#endif + ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, 0, NULL ); @@ -5587,11 +6707,139 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); move16(); - ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + pMultiBinPoseData = NULL; + if ( hSplitRendWrapper != NULL ) + { + pMultiBinPoseData = &( hSplitRendWrapper->multiBinPoseData ); + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + Copy32( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + Copy32( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + } + } + } + else + { + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + } +#else + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); +#endif hDiracDecBin->hDiffuseDist = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + { + /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ + IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; + Word32 Rmat_local[3][3]; + + + if ( hCombinedOrientationData ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Copy_Quat_fx( Quaternions_ref, &Quaternions_abs ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, Q22 ); + Quaternions_rot.w_fx = L_negate( 12582912 ); /* signal to use Euler */ + Quat2EulerDegree_fx( Quaternions_abs, &Quaternions_abs.z_fx, &Quaternions_abs.y_fx, &Quaternions_abs.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + Quaternions_abs.w_fx = L_negate( 12582912 ); /* signal to use Euler */ + + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + Quaternions_rot.x_fx = L_add( Quaternions_abs.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_rot.y_fx = L_add( Quaternions_abs.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_rot.z_fx = L_add( Quaternions_abs.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + move32(); + move32(); + move32(); + modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact ); + QuatToRotMat_fx( Quaternions_rot, Rmat_local ); + + hDiracDecBin = hMasaExtRend->hDiracDecBin[pos_idx]; + assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); + + /* re-use input covariance for the side renderings */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + mvr2r( hMasaExtRend->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands ); + } + Copy32( hMasaExtRend->hDiracDecBin[0]->ChCrossRe_fx, hDiracDecBin->ChCrossRe_fx, hSpatParamRendCom->num_freq_bands ); + Copy32( hMasaExtRend->hDiracDecBin[0]->ChCrossIm_fx, hDiracDecBin->ChCrossIm_fx, hSpatParamRendCom->num_freq_bands ); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, NULL ); + + ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + 0, NULL ); + + + q_mat = hDiracDecBin->q_processMtx; + move16(); + q_mat = s_min( q_mat, hDiracDecBin->q_processMtxPrev ); + q_mat = s_min( q_mat, hDiracDecBin->q_processMtxDec ); + q_mat = s_min( q_mat, hDiracDecBin->q_processMtxDecPrev ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) + { + Scale_sig( hDiracDecBin->processMtxDecRe_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDec ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecIm_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDec ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecRePrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDecPrev ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxDecImPrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxDecPrev ) ); // scaling to q_mat + } + } + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < numInChannels; slot++ ) + { + Scale_sig( hDiracDecBin->processMtxRe_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtx ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxIm_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtx ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxRePrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxPrev ) ); // scaling to q_mat + Scale_sig( hDiracDecBin->processMtxImPrev_fx[ch][slot], nBins, sub( q_mat, hDiracDecBin->q_processMtxPrev ) ); // scaling to q_mat + } + } + hDiracDecBin->q_processMtx = q_mat; + hDiracDecBin->q_processMtxPrev = q_mat; + hDiracDecBin->q_processMtxDec = q_mat; + hDiracDecBin->q_processMtxDecPrev = q_mat; + move16(); + move16(); + move16(); + move16(); + /* re-use reverb and decorr from main direction for the sides */ + ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 0 ); + + /* copy from temporary buffer to the main split rendering buffer */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + Copy32( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + Copy32( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + } + } + + hDiracDecBin->hDiffuseDist = NULL; + } + } + } + + /* update this counter only after the last rendering of split directions */ +#endif + hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] ); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); move16(); @@ -5611,7 +6859,15 @@ void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ - const Word16 num_subframes ) /* i : number of subframes to render */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 num_subframes, /* i : number of subframes to render */ + const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ + Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ + Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ +#else + const Word16 num_subframes /* i : number of subframes to render */ +#endif +) { Word16 subframe; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -5633,8 +6889,11 @@ void ivas_masa_ext_rend_parambin_render_fx( hSpatParamRendCom->slots_rendered = 0; move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx, hSplitRendWrapper, Cldfb_Out_Real, Cldfb_Out_Imag ); +#else ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx ); - +#endif FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_output[ch] += n_samples_sf; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4a62de19f..269806ccf 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -215,7 +215,15 @@ void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ - const Word16 num_subframes ); /* i : number of subframes to render */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 num_subframes, /* i : number of subframes to render */ + const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ + Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ + Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ +#else + const Word16 num_subframes /* i : number of subframes to render */ +#endif +); ivas_error ivas_dirac_dec_init_binaural_data_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ @@ -1215,11 +1223,21 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word32 output_Fs, + const Word16 num_poses +#else const Word32 output_Fs +#endif ); void ivas_rend_closeCrend( +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend , + const Word16 num_poses +#else CREND_WRAPPER_HANDLE *pCrend +#endif ); ivas_error ivas_hrtf_init( @@ -1227,7 +1245,12 @@ ivas_error ivas_hrtf_init( ); ivas_error ivas_rend_initCrendWrapper( +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend, + const Word16 num_poses +#else CREND_WRAPPER_HANDLE *pCrend +#endif ); ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, @@ -1239,7 +1262,12 @@ ivas_error ivas_rend_crendProcess( EFAP_HANDLE hEFAPdata, Word32 *output[], /* i/o: input/output audio channels */ const Word32 output_Fs, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const Word16 num_subframes, /* i : number of subframes to render */ + const Word16 pos_idx /* i : pose index */ +#else const Word16 num_subframes /* i : number of subframes to render */ +#endif ); ivas_error ivas_rend_crendProcessSubframe( const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ @@ -1254,6 +1282,10 @@ ivas_error ivas_rend_crendProcessSubframe( Word32 *output[], /* i/o: input/output audio channels */ const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word32 output_Fs /* i : output sampling rate */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const Word16 pos_idx +#endif ); @@ -1586,6 +1618,14 @@ void QuatToRotMat( float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); +#endif void rotateAziEle( float azi_in, /* i : output elevation */ @@ -1951,6 +1991,85 @@ void masaPrerendClose_fx( MASA_PREREND_HANDLE *hMasaPrerendPtr /* i/o: prerenderer handle to be closed */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word32 *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t nSamplesRendered /* i : number of samples to render */ +); + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + Word32 *input_f[], /* i : transport channels */ + Word32 *output[], /* i/o: input/output audio channels */ + const Word16 n_samples_to_render, /* i : output frame length per channel */ + const Word32 output_Fs /* i : output sampling rate */ +); + +ivas_error ivas_rend_crendProcessSplitBin( + const CREND_WRAPPER *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, + EFAP_HANDLE hEFAPdata, + Word32 *output[], + const Word32 output_Fs +); + +ivas_error ivas_rend_openMultiBinCrend( + CREND_WRAPPER_HANDLE *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs +); + +void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes +); + +ivas_error ivas_rend_openCldfb( + HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS], + const AUDIO_CONFIG inConfig, + const Word32 output_Fs +); + +ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs +); + +void ivas_rend_closeCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend +); + +#endif /* clang-format on */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 14139c534..76e5633fc 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -39,7 +39,7 @@ #include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved #include "stat_com.h" /* Note: Currently needed for CLDFB. */ #include "common_api_types.h" - +#include "isar_stat.h" /*----------------------------------------------------------------------------------* * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) @@ -769,6 +769,9 @@ typedef struct IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_VECTOR3 Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 crossfade_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q31 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif ivas_orient_trk_state_t *hOrientationTracker; } IVAS_REND_HeadRotData; @@ -790,6 +793,9 @@ typedef struct ivas_binaural_head_track_struct Word16 shd_rot_max_order; ivas_orient_trk_state_t *OrientationTracker; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif } HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE; /*----------------------------------------------------------------------------------* @@ -822,14 +828,22 @@ typedef struct ivas_combined_orientation_struct IVAS_QUATERNION Quaternion_prev_extOrientation; IVAS_QUATERNION Quaternions_ext_interpolation_start; IVAS_QUATERNION Quaternions_ext_interpolation_target; - Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; /* Q30 */ - Word32 Rmat_prev_fx[3][3]; /* Q30 */ + Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; /* Q30 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Rmat_prev_fx[MAX_HEAD_ROT_POSES][3][3]; +#else + Word32 Rmat_prev_fx[3][3]; +#endif /* Q30 */ Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ Word16 q_chEneIIR; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */ Word16 q_procChEneIIR; Word16 shd_rot_max_order; IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; + Word16 sr_low_res_flag; +#endif IVAS_QUATERNION Quaternion_frozen_ext; IVAS_QUATERNION Quaternion_frozen_head; Word8 isExtOrientationFrozen; @@ -1327,7 +1341,11 @@ typedef struct ivas_crend_state_t typedef struct ivas_binaural_crend_wrapper_struct { Word32 binaural_latency_ns; +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_HANDLE hCrend[MAX_HEAD_ROT_POSES]; +#else CREND_HANDLE hCrend; +#endif HRTFS_HANDLE hHrtfCrend; Word16 *p_io_qfactor; Word16 io_qfactor; @@ -1342,12 +1360,12 @@ typedef struct ivas_binaural_rendering_struct IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ EFAP_HANDLE hEFAPdata; /* EFAP structure*/ Word32 *hoa_dec_mtx; /* pointer to HOA decoder mtx */ /*Q29*/ - int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ - int16_t max_band; /* band upto which rendering is performed */ - int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ - int16_t timeSlots; /* number of time slots of binaural renderer */ - int16_t nInChannels; /* number input channels */ - int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + Word8 rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + Word16 max_band; /* band upto which rendering is performed */ + Word16 conv_band; /* band upto which convolution in cldfb domain is performed */ + Word16 timeSlots; /* number of time slots of binaural renderer */ + Word16 nInChannels; /* number input channels */ + Word8 render_lfe; /* Flag to render LFE in binaural rendering*/ IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ /* Convolution module structure */ @@ -1428,6 +1446,21 @@ typedef struct ivas_hrtfs_parambin_struct } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT + +/*----------------------------------------------------------------------------------* + * CLDFB renderer wrapper + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + int32_t binaural_latency_ns; + BINAURAL_RENDERER_HANDLE hCldfbRend; + HRTFS_FASTCONV_HANDLE hHrtfFastConv; + +} CLDFB_REND_WRAPPER; + +#endif /*----------------------------------------------------------------------------------* * Limiter structure @@ -1461,6 +1494,7 @@ typedef struct ivas_LS_setupconversion_struct } LSSETUP_CONVERSION_STRUCT, *LSSETUP_CONVERSION_HANDLE; + typedef struct ivas_LS_setupconversion_matrix_fx { Word16 index; @@ -1520,7 +1554,11 @@ typedef struct ivas_masa_external_rendering_struct RENDERER_TYPE renderer_type; DIRAC_REND_HANDLE hDirACRend; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef SPLIT_REND_WITH_HEAD_ROT + DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; +#else DIRAC_DEC_BIN_HANDLE hDiracDecBin; +#endif REVERB_STRUCT_HANDLE hReverb; HRTFS_PARAMBIN_HANDLE hHrtfParambin; -- GitLab From d9575b5e78594cc6147889de70ebdd76cfccb1ed Mon Sep 17 00:00:00 2001 From: norvell Date: Thu, 30 Jan 2025 09:09:38 +0000 Subject: [PATCH 018/329] Set BASOP_CI_BRANCH_PC_REPO: "ci/bring-back-per-channel-odg" for testing of both PEAQ measurements in parallel --- .gitlab-ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a9e1efb5..ebf6a3e91 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ variables: REF_DECODER_PATH: "./IVAS_dec_ref" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + BASOP_CI_BRANCH_PC_REPO: "ci/bring-back-per-channel-odg" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -32,6 +32,7 @@ variables: INSTR_DIR: "scripts/c-code_instrument" BUILD_WITH_DEBUG_MODE_INFO: "" ENCODER_TEST: "" + DELTA_ODG: "" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -314,9 +315,13 @@ stages: - *build-and-create-reference-outputs - comp_args="--mld --ssnr --odg" + - summary_args="MLD DIFF SSNR ODG" - if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi + - if [ "$DELTA_ODG" = "true" ]; then comp_args="${comp_args} --odg_bin"; summary_args="${summary_args} DELTA_ODG";fi - echo "$comp_args" + + ### run pytest - exit_code=0 - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml $comp_args -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? @@ -324,7 +329,7 @@ stages: - python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME - mkdir $IMAGES_ARTIFACT_NAME - - for MEASURE in MLD DIFF SSNR ODG;do python3 scripts/create_histogram_summary.py $CSV_ARTIFACT_NAME $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".csv $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".png --measure $MEASURE; done + - for MEASURE in $summary_args;do python3 scripts/create_histogram_summary.py $CSV_ARTIFACT_NAME $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".csv $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".png --measure $MEASURE; done - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME - if [ $USE_LTV -eq 1 ] && [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then @@ -1185,6 +1190,7 @@ peaq-enc-passthrough: - USE_LTV=0 - DUT_DECODER_PATH=./$REF_DECODER_PATH - TEST_SUITE="tests/test_enc_passthrough.py" + - DELTA_ODG="true" - LEVEL_SCALING=1.0 <<: *ivas-pytest-anchor -- GitLab From bd35dc1b3f7602aec02ac9577a04d2cbd8c1fc70 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Jan 2025 12:40:22 +0100 Subject: [PATCH 019/329] Fix for parse_xml_report.py call --- .gitlab-ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ebf6a3e91..3c912285e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -316,18 +316,17 @@ stages: - comp_args="--mld --ssnr --odg" - summary_args="MLD DIFF SSNR ODG" + - ="" - if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi - - if [ "$DELTA_ODG" = "true" ]; then comp_args="${comp_args} --odg_bin"; summary_args="${summary_args} DELTA_ODG";fi + - if [ "$DELTA_ODG" = "true" ]; then comp_args="${comp_args} --odg_bin"; summary_args="${summary_args} DELTA_ODG"; REPORT_ARG="--delta_odg"; fi - echo "$comp_args" - - ### run pytest - exit_code=0 - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml $comp_args -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - - python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME + - python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME $REPORT_ARG - mkdir $IMAGES_ARTIFACT_NAME - for MEASURE in $summary_args;do python3 scripts/create_histogram_summary.py $CSV_ARTIFACT_NAME $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".csv $IMAGES_ARTIFACT_NAME/summary_"$MEASURE".png --measure $MEASURE; done - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME -- GitLab From f10b357e0b4c0bd06d7eb5d70863708e968ecb9d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Jan 2025 12:54:23 +0100 Subject: [PATCH 020/329] Fix syntax error --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c912285e..d5f6294f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -316,7 +316,7 @@ stages: - comp_args="--mld --ssnr --odg" - summary_args="MLD DIFF SSNR ODG" - - ="" + - REPORT_ARG="" - if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi - if [ "$DELTA_ODG" = "true" ]; then comp_args="${comp_args} --odg_bin"; summary_args="${summary_args} DELTA_ODG"; REPORT_ARG="--delta_odg"; fi - echo "$comp_args" -- GitLab From 06f8a2cd5f208feffe98ce79b876af5b84cbc3b9 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Jan 2025 15:51:35 +0100 Subject: [PATCH 021/329] Reset BASOP_CI_BRANCH_PC_REPO: basop-ci-branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5f6294f8..3d41cc11d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ variables: REF_DECODER_PATH: "./IVAS_dec_ref" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "ci/bring-back-per-channel-odg" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 -- GitLab From a7252203c2b626722f1926c2cb65bb507f1cb180 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 31 Jan 2025 10:56:09 +1100 Subject: [PATCH 022/329] few more updates to split rendering BASOP --- lib_com/cnst.h | 1 + lib_rend/ivas_output_init.c | 21 +- lib_rend/ivas_render_config.c | 27 ++ lib_rend/ivas_rotation.c | 191 +++++++--- lib_rend/ivas_shoebox.c | 1 + lib_rend/lib_rend.c | 684 +++++++++++++++++++++++++++++++--- lib_rend/lib_rend.h | 95 ++++- 7 files changed, 916 insertions(+), 104 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index cb141912c..e86b51472 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -788,6 +788,7 @@ enum #define CLDFB_NO_CHANNELS_MAX 60 /* CLDFB resampling - max number of CLDFB channels, == IVAS_CLDFB_NO_CHANNELS_MAX */ #define CLDFB_NO_CHANNELS_MAX_FX 30720 /*Q9*/ #define CLDFB_NO_COL_MAX 16 /* CLDFB resampling - max number of CLDFB col., == IVAS_CLDFB_NO_COL_MAX */ +#define ONE_BY_CLDFB_NO_COL_MAX_Q31 134217728 #define CLDFB_NO_COL_MAX_SWITCH 6 /* CLDFB resampling - max number of CLDFB col. for switching */ #define CLDFB_NO_COL_MAX_SWITCH_BFI 10 /* CLDFB resampling - max number of CLDFB col. for switching, BFI */ #define CLDFB_OVRLP_MIN_SLOTS 3 /* CLDFB resampling - minimize processing to minimum required for transition frame ACELP->TCX/HQ */ diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 359bea7e6..f20cab785 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -100,6 +100,10 @@ Word16 audioCfg2channels( move16(); BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: nchan_out = 2; @@ -266,6 +270,10 @@ void ivas_output_init( move16(); BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_ISM1: @@ -370,7 +378,12 @@ Word16 ivas_get_nchan_buffers_dec( { nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { nchan_out_buff = shl( CPE_CHANNELS, 1 ); } @@ -451,6 +464,12 @@ Word16 ivas_get_nchan_buffers_dec( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); + } +#endif return nchan_out_buff; } diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index d35a6c005..780e1bdd2 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -138,5 +138,32 @@ ivas_error ivas_render_config_init_from_rom_fx( move16(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + move32(); + ( *hRenderConfig )->split_rend_config.dof = 3; + move16(); + ( *hRenderConfig )->split_rend_config.hq_mode = 0; + move16(); + ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; + move16(); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20; + move16(); +#endif + ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ + move16(); + ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + move32(); + ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + move32(); + ( *hRenderConfig )->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; + move32(); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; + move16(); +#endif +#endif + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 8b938a7e0..8651de7f7 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -88,6 +88,9 @@ Word16 square_root30_q12[31] = { static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ +#endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); static void external_target_interpolation_fx( @@ -141,6 +144,10 @@ ivas_error ivas_headTrack_open_fx( move32(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *hHeadTrackData )->sr_pose_pred_axis = DEFAULT_AXIS; + move32(); +#endif set32_fx( ( *hHeadTrackData )->chEneIIR_fx[0], 0, MASA_FREQUENCY_BANDS ); set32_fx( ( *hHeadTrackData )->chEneIIR_fx[1], 0, MASA_FREQUENCY_BANDS ); @@ -189,52 +196,66 @@ void QuatToRotMat_fx( Word32 Rmat[3][3] /* o : real-space rotation matrix for this rotation 2*Qx-32 */ ) { - Word32 w = quat.w_fx; // Qx - move32(); - Word32 x = quat.x_fx; - move32(); - Word32 y = quat.y_fx; - move32(); - Word32 z = quat.z_fx; - move32(); - // Adding a guard bit to squared terms since 2*x is not being done in those - // statements (R[0][0], R[1][1], R[2][2]). This is done to avoid L_shl. - Word32 ww = L_shr( Mpy_32_32( w, w ), 1 ); // 2 * Qx - 31 - 1 = 2*Qx-32 - Word32 xx = L_shr( Mpy_32_32( x, x ), 1 ); - Word32 yy = L_shr( Mpy_32_32( y, y ), 1 ); - Word32 zz = L_shr( Mpy_32_32( z, z ), 1 ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( quat.w_fx, L_negate( 12582912 ) ) ) + { + assert( 0 ); + // IVAS_QUATERNION quat_local; + // Euler2Quat_fx( deg2rad( quat.x_fx ), deg2rad( quat.y_fx ), deg2rad( quat.z_fx ), &quat_local ); + // QuatToRotMat_fx( quat_local, Rmat ); + } + else + { +#endif + Word32 w = quat.w_fx; // Qx + move32(); + Word32 x = quat.x_fx; + move32(); + Word32 y = quat.y_fx; + move32(); + Word32 z = quat.z_fx; + move32(); - Word32 wx = Mpy_32_32( w, x ); // 2 * Qx - 31 - Word32 wz = Mpy_32_32( w, z ); - Word32 wy = Mpy_32_32( w, y ); + // Adding a guard bit to squared terms since 2*x is not being done in those + // statements (R[0][0], R[1][1], R[2][2]). This is done to avoid L_shl. + Word32 ww = L_shr( Mpy_32_32( w, w ), 1 ); // 2 * Qx - 31 - 1 = 2*Qx-32 + Word32 xx = L_shr( Mpy_32_32( x, x ), 1 ); + Word32 yy = L_shr( Mpy_32_32( y, y ), 1 ); + Word32 zz = L_shr( Mpy_32_32( z, z ), 1 ); - Word32 xy = Mpy_32_32( x, y ); - Word32 xz = Mpy_32_32( x, z ); + Word32 wx = Mpy_32_32( w, x ); // 2 * Qx - 31 + Word32 wz = Mpy_32_32( w, z ); + Word32 wy = Mpy_32_32( w, y ); - Word32 yz = Mpy_32_32( y, z ); + Word32 xy = Mpy_32_32( x, y ); + Word32 xz = Mpy_32_32( x, z ); - Rmat[0][0] = L_sub( L_sub( L_add( ww, xx ), yy ), zz ); // 2 * Qx - 31 - 1 = 2*Qx-32 - move32(); - Rmat[0][1] = L_sub( xy, wz ); - move32(); - Rmat[0][2] = L_add( xz, wy ); - move32(); + Word32 yz = Mpy_32_32( y, z ); - Rmat[1][0] = L_add( xy, wz ); // 2 * Qx - 32 - move32(); - Rmat[1][1] = L_sub( L_add( L_sub( ww, xx ), yy ), zz ); - move32(); - Rmat[1][2] = L_sub( yz, wx ); - move32(); + Rmat[0][0] = L_sub( L_sub( L_add( ww, xx ), yy ), zz ); // 2 * Qx - 31 - 1 = 2*Qx-32 + move32(); + Rmat[0][1] = L_sub( xy, wz ); + move32(); + Rmat[0][2] = L_add( xz, wy ); + move32(); - Rmat[2][0] = L_sub( xz, wy ); // 2 * Qx - 32 - move32(); - Rmat[2][1] = L_add( yz, wx ); - move32(); - Rmat[2][2] = L_add( L_sub( L_sub( ww, xx ), yy ), zz ); - move32(); + Rmat[1][0] = L_add( xy, wz ); // 2 * Qx - 32 + move32(); + Rmat[1][1] = L_sub( L_add( L_sub( ww, xx ), yy ), zz ); + move32(); + Rmat[1][2] = L_sub( yz, wx ); + move32(); + Rmat[2][0] = L_sub( xz, wy ); // 2 * Qx - 32 + move32(); + Rmat[2][1] = L_add( yz, wx ); + move32(); + Rmat[2][2] = L_add( L_sub( L_sub( ww, xx ), yy ), zz ); + move32(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif return; } @@ -711,8 +732,11 @@ void rotateFrame_shd( } /* calculate ambisonics rotation matrices for the previous and current frames */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + SHrotmatgen( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx[0], shd_rot_max_order ); +#else SHrotmatgen_fx( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx, shd_rot_max_order ); - +#endif SHrotmatgen_fx( SHrotmat /*Q14*/, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); FOR( i = 0; i < subframe_len; i++ ) @@ -773,7 +797,11 @@ void rotateFrame_shd( { MVR2R_WORD32( hCombinedOrientationData->Rmat_fx[subframe_idx][i], +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCombinedOrientationData->Rmat_prev_fx[0][i], +#else hCombinedOrientationData->Rmat_prev_fx[i], +#endif 3 ); // Q14 } @@ -872,8 +900,11 @@ void rotateFrame_sd( } /* gains for previous subframe rotation */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotateAziEle_fx( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx[0], hTransSetup.is_planar_setup ); +#else rotateAziEle_fx( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx, hTransSetup.is_planar_setup ); - +#endif test(); test(); IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), elevation ) ) ) @@ -967,7 +998,11 @@ void rotateFrame_sd( { MVR2R_WORD32( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx][i], // Q30 +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCombinedOrientationData->Rmat_prev_fx[0][i], +#else hCombinedOrientationData->Rmat_prev_fx[i], +#endif 3 ); } /* copy to output */ @@ -1311,6 +1346,9 @@ ivas_error ivas_combined_orientation_open( Word16 j; IVAS_QUATERNION identity; IVAS_VECTOR3 origo; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif identity.w_fx = ONE_IN_Q31; move32(); identity.x_fx = 0; @@ -1380,13 +1418,31 @@ ivas_error ivas_combined_orientation_open( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + FOR( j = 0; j < 3; j++ ) + { + set32_fx( ( *hCombinedOrientationData )->Rmat_prev_fx[pos_idx][j], 0, 3 ); + ( *hCombinedOrientationData )->Rmat_prev_fx[pos_idx][j][j] = ONE_IN_Q30; + move32(); + } + } + ( *hCombinedOrientationData )->sr_pose_pred_axis = DEFAULT_AXIS; + ( *hCombinedOrientationData )->sr_low_res_flag = 0; + move32(); + move16(); +#else FOR( j = 0; j < 3; j++ ) { set32_fx( ( *hCombinedOrientationData )->Rmat_prev_fx[j], 0, 3 ); ( *hCombinedOrientationData )->Rmat_prev_fx[j][j] = ONE_IN_Q30; move32(); } - ( *hCombinedOrientationData )->Quaternion_prev_extOrientation = identity; +#endif + + ( *hCombinedOrientationData ) + ->Quaternion_prev_extOrientation = identity; ( *hCombinedOrientationData )->Quaternion_frozen_ext = identity; ( *hCombinedOrientationData )->Quaternion_frozen_head = identity; set_zero_fx( ( *hCombinedOrientationData )->chEneIIR_fx[0], MASA_FREQUENCY_BANDS ); @@ -1447,6 +1503,9 @@ ivas_error combine_external_and_head_orientations_dec( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif IVAS_QUATERNION *pHeadRotQuaternion = NULL; IVAS_VECTOR3 *listenerPos = NULL; @@ -1454,8 +1513,20 @@ ivas_error combine_external_and_head_orientations_dec( { pHeadRotQuaternion = hHeadTrackData->Quaternions; listenerPos = hHeadTrackData->Pos; +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis; +#endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ELSE + { + sr_pose_pred_axis = DEFAULT_AXIS; + } +#endif return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis, +#endif hExtOrientationData, hCombinedOrientationData ); } @@ -1472,10 +1543,17 @@ ivas_error combine_external_and_head_orientations_rend( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif IVAS_QUATERNION *headRotQuaternions = NULL; IVAS_VECTOR3 *listenerPos = NULL; Word16 i; +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis = DEFAULT_AXIS; +#endif + IF( hHeadTrackData != NULL ) { IF( hHeadTrackData->headRotEnabled ) @@ -1483,6 +1561,9 @@ ivas_error combine_external_and_head_orientations_rend( headRotQuaternions = hHeadTrackData->headPositions; listenerPos = hHeadTrackData->Pos; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis; +#endif } ELSE IF( hExtOrientationData != NULL ) { @@ -1498,6 +1579,9 @@ ivas_error combine_external_and_head_orientations_rend( } return combine_external_and_head_orientations( headRotQuaternions, listenerPos, +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis, +#endif hExtOrientationData, hCombinedOrientationData ); } @@ -1509,8 +1593,11 @@ ivas_error combine_external_and_head_orientations_rend( * NOTE that the external orientations are inversed. *------------------------------------------------------------------------*/ ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ - IVAS_VECTOR3 *listenerPos, /* i : listener position */ + IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ + IVAS_VECTOR3 *listenerPos, /* i : listener position */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ +#endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) @@ -1858,6 +1945,10 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternions[i].q_fact = add( hCombinedOrientationData->Quaternions[i].q_fact, l_shift ); move16(); } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; +#endif return IVAS_ERR_OK; } @@ -2166,7 +2257,11 @@ static Word32 SHrot_w_fx( IF( m == 0 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + assert( 0 && "ERROR should not be called\n" ); +#else printf( "ERROR should not be called\n" ); +#endif return 0; } ELSE @@ -2366,7 +2461,11 @@ void ivas_combined_orientation_update_index( Word16 exp, div_result; IF( hCombinedOrientationData != NULL ) { - IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) ) + IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + || hCombinedOrientationData->sr_low_res_flag +#endif + ) { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; @@ -2423,7 +2522,11 @@ void ivas_combined_orientation_update_start_index( { IF( hCombinedOrientationData != NULL ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) || hCombinedOrientationData->sr_low_res_flag ) +#else IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) ) +#endif { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c index 6e27da202..2afaea63e 100644 --- a/lib_rend/ivas_shoebox.c +++ b/lib_rend/ivas_shoebox.c @@ -35,6 +35,7 @@ #include #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" +#include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "prot.h" #include "prot_fx.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f230cca25..796b6e0e0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -36,6 +36,9 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" +#include "isar_prot.h" +#include "isar_stat.h" +#include "lib_isar_pre_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" @@ -57,16 +60,8 @@ /* Maximum buffer length (per channel) in samples. * Keep this separate from L_FRAME48k in case we want to support different size later */ -#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k ) - -/* Maximum buffer length (total) in samples. */ -/* Maximum buffer length (total) in samples. */ -#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) - -#define MAX_BIN_DELAY_SAMPLES 50 /* Maximum supported rendering latency for binaural IRs */ - -/* Frame size required when rendering to binaural */ -#define BINAURAL_RENDERING_FRAME_SIZE_MS 5 +#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) +#define MAX_BIN_DELAY_SAMPLES 150 /* Maximum supported rendering latency for binaural IRs */ /*-------------------------------------------------------------------* @@ -105,6 +100,11 @@ typedef struct const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; const EFAP_WRAPPER *pEfapOutWrapper; IVAS_REND_HeadRotData *pHeadRotData; // for now removing the const qualifier TODO: will modify later +#ifdef SPLIT_REND_WITH_HEAD_ROT + const RENDER_CONFIG_HANDLE *hhRendererConfig; + const Word16 *pSplitRendBFI; + const SPLIT_REND_WRAPPER *pSplitRendWrapper; +#endif const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; } rendering_context; /* Common base for input structs */ @@ -130,6 +130,9 @@ typedef struct rotation_matrix_fx rot_mat_prev_fx; pan_vector prev_pan_gains; Word8 firstFrameRendered; +#ifdef SPLIT_REND_WITH_HEAD_ROT + TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ +#endif Word32 *bufferData_fx; Word16 nonDiegeticPan; Word32 nonDiegeticPanGain_fx; /* Q31 */ @@ -162,8 +165,15 @@ typedef struct EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; +#ifdef SPLIT_REND_WITH_HEAD_ROT + TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ +#endif REVERB_HANDLE hReverb; +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotation_gains_Word32 rot_gains_prev_fx[MAX_HEAD_ROT_POSES]; +#else rotation_gains_Word32 rot_gains_prev_fx; +#endif Word16 nonDiegeticPan; Word32 nonDiegeticPanGain_fx; lfe_routing lfeRouting; @@ -177,8 +187,15 @@ typedef struct input_base base; // pan_matrix hoaDecMtx; pan_matrix_fx hoaDecMtx_fx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + CLDFB_REND_WRAPPER cldfbRendWrapper; +#endif CREND_WRAPPER_HANDLE crendWrapper; +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotation_gains_fx rot_gains_prev_fx[MAX_HEAD_ROT_POSES]; +#else rotation_gains_fx rot_gains_prev_fx; +#endif Word32 *bufferData_fx; DIRAC_ANA_HANDLE hDirAC; } input_sba; @@ -208,7 +225,14 @@ struct IVAS_REND EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; +#ifdef SPLIT_REND_WITH_HEAD_ROT + SPLIT_REND_WRAPPER splitRendWrapper; + IVAS_REND_AudioBuffer splitRendEncBuffer; +#endif IVAS_REND_HeadRotData headRotData; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 splitRendBFI; +#endif EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; @@ -228,6 +252,21 @@ static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ Word16 to_fix ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderSbaToMultiBinauralCldfb( + input_sba *sbaInput, + Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes ); + +static ivas_error renderSbaToMultiBinaural( + input_sba *sbaInput, + const AUDIO_CONFIG outConfig, + Word32 out[][L_FRAME48k] ); +#endif + /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ @@ -306,6 +345,103 @@ static Word32 *getSmplPtr_fx( { return buffer.data_fx + chnlIdx * buffer.config.numSamplesPerChannel + smplIdx; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void convertBitsBufferToInternalBitsBuff( + const IVAS_REND_BitstreamBuffer outBits, + ISAR_SPLIT_REND_BITS_HANDLE hBits ) +{ + hBits->bits_buf = outBits.bits; + hBits->bits_read = outBits.config.bitsRead; + hBits->bits_written = outBits.config.bitsWritten; + hBits->buf_len = outBits.config.bufLenInBytes; + hBits->codec = outBits.config.codec; + hBits->pose_correction = outBits.config.poseCorrection; + hBits->codec_frame_size_ms = outBits.config.codec_frame_size_ms; + + return; +} + +static void convertInternalBitsBuffToBitsBuffer( + IVAS_REND_BitstreamBuffer *hOutBits, + const ISAR_SPLIT_REND_BITS_DATA bits ) +{ + hOutBits->bits = bits.bits_buf; + hOutBits->config.bitsRead = bits.bits_read; + hOutBits->config.bitsWritten = bits.bits_written; + hOutBits->config.bufLenInBytes = bits.buf_len; + hOutBits->config.codec = bits.codec; + hOutBits->config.poseCorrection = bits.pose_correction; + hOutBits->config.codec_frame_size_ms = bits.codec_frame_size_ms; + + return; +} + +static void copyBufferToCLDFBarray( + const IVAS_REND_AudioBuffer buffer, + Word32 re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) +{ + UWord32 smplIdx, slotIdx; + UWord32 numCldfbSamples, num_bands; + UWord32 chnlIdx; + const Word32 *readPtr; + + assert( ( buffer.config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); + readPtr = buffer.data_fx; + numCldfbSamples = (UWord32) shl( buffer.config.numSamplesPerChannel, 1 ); + num_bands = (UWord32) Mpy_32_32( numCldfbSamples, ONE_BY_CLDFB_NO_COL_MAX_Q31 ); + FOR( chnlIdx = 0; chnlIdx < (UWord32) buffer.config.numChannels; ++chnlIdx ) + { + FOR( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; ++slotIdx ) + { + FOR( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + re[chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + FOR( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + im[chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + } + } + + return; +} + +static void accumulateCLDFBArrayToBuffer( + Word32 re[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 im[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + IVAS_REND_AudioBuffer *buffer ) +{ + UWord32 smplIdx, slotIdx; + UWord32 numCldfbSamples, num_bands; + UWord32 chnlIdx; + Word32 *writePtr; + + assert( ( buffer->config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); + writePtr = buffer->data_fx; + numCldfbSamples = (UWord32) shl( buffer->config.numSamplesPerChannel, 1 ); + num_bands = (UWord32) Mpy_32_32( numCldfbSamples, ONE_BY_CLDFB_NO_COL_MAX_Q31 ); + FOR( chnlIdx = 0; chnlIdx < (uint32_t) buffer->config.numChannels; ++chnlIdx ) + { + FOR( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; ++slotIdx ) + { + FOR( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + *writePtr++ += re[chnlIdx][slotIdx][smplIdx]; + } + FOR( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + *writePtr++ += im[chnlIdx][slotIdx][smplIdx]; + } + } + } + + return; +} +#endif + static void copyBufferTo2dArray_fx( const IVAS_REND_AudioBuffer buffer, Word32 array[][L_FRAME48k] ) @@ -314,6 +450,10 @@ static void copyBufferTo2dArray_fx( UWord32 chnlIdx; const Word32 *readPtr; +#ifdef SPLIT_REND_WITH_HEAD_ROT + assert( ( buffer.config.is_cldfb == 0 ) && "for CLDFB input call copyBufferToCLDFBarray()" ); +#endif + readPtr = buffer.data_fx; FOR( chnlIdx = 0; chnlIdx < (UWord32) buffer.config.numChannels; ++chnlIdx ) @@ -329,7 +469,7 @@ static void copyBufferTo2dArray_fx( } static void accumulate2dArrayToBuffer_fx( Word32 array[][L_FRAME48k], - IVAS_REND_AudioBuffer *buffer ) + const IVAS_REND_AudioBuffer *buffer ) { Word16 smplIdx, chnlIdx; Word32 *writePtr; @@ -420,6 +560,10 @@ static ivas_error validateOutputAudioConfig( case IVAS_AUDIO_CONFIG_HOA2: case IVAS_AUDIO_CONFIG_HOA3: case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_MASA1: @@ -496,13 +640,20 @@ IVAS_REND_AudioConfigType getAudioConfigType( static ivas_error validateOutputSampleRate( const Word32 sampleRate, - const AUDIO_CONFIG outConfig ) -{ - IF( NE_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) - { + const AUDIO_CONFIG outConfig ){ + + IF( NE_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ){ /* If no binaural rendering, any sampling rate is supported */ return IVAS_ERR_OK; - } +} +#ifdef SPLIT_REND_WITH_HEAD_ROT +ELSE IF( ( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( sampleRate, 48000 ) ) +{ + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); +} +ELSE +{ +#endif /* Otherwise rendering to binaural, support the same set as IVAS decoder */ SWITCH( sampleRate ) @@ -515,6 +666,9 @@ static ivas_error validateOutputSampleRate( } return IVAS_ERR_INVALID_SAMPLING_RATE; +#ifdef SPLIT_REND_WITH_HEAD_ROT +} +#endif } /*-------------------------------------------------------------------* * getAudioConfigNumChannels() @@ -536,6 +690,10 @@ ivas_error getAudioConfigNumChannels( BREAK; case IVAS_AUDIO_CONFIG_STEREO: case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_MASA2: @@ -1045,6 +1203,10 @@ static ivas_error initHeadRotation_fx( hIvasRend->headRotData.headPositions[i] = quaternionInit_fx(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasRend->headRotData.sr_pose_pred_axis = DEFAULT_AXIS; + move32(); +#endif IF( ( hIvasRend->headRotData.hOrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { @@ -1196,6 +1358,11 @@ static rendering_context getRendCtx( ctx.pCustomLsOut = &hIvasRend->customLsOut; ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper; ctx.pHeadRotData = &hIvasRend->headRotData; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ctx.hhRendererConfig = &hIvasRend->hRendererConfig; + ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; + ctx.pSplitRendWrapper = &hIvasRend->splitRendWrapper; +#endif ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; return ctx; @@ -1244,8 +1411,11 @@ static ivas_error initIsmMasaRendering( inputIsm->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputIsm->crendWrapper ); - +#endif ivas_reverb_close( &inputIsm->hReverb ); IF( NE_32( ( error = ivas_omasa_ana_open( &inputIsm->hOMasa, inSampleRate, inputIsm->total_num_objects ) ), IVAS_ERR_OK ) ) @@ -1267,7 +1437,9 @@ static ivas_error setRendInputActiveIsm( rendering_context rendCtx; AUDIO_CONFIG outConfig; input_ism *inputIsm; - +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 i; +#endif inputIsm = (input_ism *) input; rendCtx = inputIsm->base.ctx; outConfig = *rendCtx.pOutConfig; @@ -1296,57 +1468,97 @@ static ivas_error setRendInputActiveIsm( set_zero_fx( inputIsm->prev_pan_gains_fx, MAX_OUTPUT_CHANNELS ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + inputIsm->splitTdRendWrappers[i] = defaultTdRendWrapper(); + } +#endif + inputIsm->hOMasa = NULL; error = IVAS_ERR_OK; move32(); test(); - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) - { - IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { + IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ){ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ){ return error; - } +} +#else + IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ){ + return error; +} +#endif +} +ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) +{ + IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) + { + return error; } - ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) +} +ELSE +{ + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + Word16 ivas_format; + IF( EQ_32( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { - IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; - } + ivas_format = MC_FORMAT; } ELSE { - Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; - Word16 num_src; - Word16 ivas_format; - IF( EQ_32( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) - { - ivas_format = MC_FORMAT; - } - ELSE + ivas_format = ISM_FORMAT; + } + + move16(); + IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) + { + return error; + } + + + Word16 nchan_rend = num_src; + move16(); + + test(); + IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ + } + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) { - ivas_format = ISM_FORMAT; + IF( Src_p->SrcSpatial_p != NULL ) + { + Src_p->SrcSpatial_p->q_Pos_p = Q31; + move16(); + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + SrcSpatial_p->q_Pos_p = Q31; + move16(); } + } - move16(); - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* Open TD renderer wrappers */ + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK ) { return error; } - Word16 nchan_rend = num_src; - move16(); + /* Assert same delay as main TD renderer */ + assert( inputIsm->splitTdRendWrappers[i].binaural_latency_ns == inputIsm->tdRendWrapper.binaural_latency_ns ); - test(); - IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ - } FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) { - TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + TDREND_SRC_t *Src_p = inputIsm->splitTdRendWrappers[i].hBinRendererTd->Sources[SrcInd[nS]]; IF( Src_p != NULL ) { IF( Src_p->SrcSpatial_p != NULL ) @@ -1354,28 +1566,34 @@ static ivas_error setRendInputActiveIsm( Src_p->SrcSpatial_p->q_Pos_p = Q31; move16(); } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->splitTdRendWrappers[i].hBinRendererTd->Sources[nS]->SrcSpatial_p; SrcSpatial_p->q_Pos_p = Q31; move16(); } } + } - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif + + IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) { - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } } +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } static void clearInputIsm( input_ism *inputIsm ) { rendering_context rendCtx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif rendCtx = inputIsm->base.ctx; @@ -1384,7 +1602,11 @@ static void clearInputIsm( initRendInputBase_fx( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputIsm->crendWrapper ); +#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -1394,6 +1616,13 @@ static void clearInputIsm( inputIsm->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + ivas_td_binaural_close( &inputIsm->splitTdRendWrappers[i].hBinRendererTd ); + inputIsm->splitTdRendWrappers[i].hHrtfTD = NULL; + } +#endif ivas_omasa_ana_close( &( inputIsm->hOMasa ) ); @@ -2123,6 +2352,10 @@ static ivas_error updateMcPanGains( SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif BREAK; /* Do nothing */ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: @@ -2172,6 +2405,9 @@ static ivas_error initMcBinauralRendering( Word32 binauralDelayNs; Word32 outSampleRate; Word8 useTDRend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation) or planar MC layouts with headrotation, CREND for the rest */ @@ -2203,11 +2439,28 @@ static ivas_error initMcBinauralRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( !reconfigureFlag || !useTDRend ) + { + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + IF( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL ) + { + ivas_td_binaural_close_fx( &inputMc->splitTdRendWrappers[i].hBinRendererTd ); + inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; + } + } + } +#endif /* if we need to use TD renderer and CREND was open, close it */ IF( useTDRend ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputMc->crendWrapper ); +#endif } test(); @@ -2266,6 +2519,44 @@ static ivas_error initMcBinauralRendering( } } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + /* Open TD renderer wrappers */ + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + IF( ( error = ivas_td_binaural_open_ext_fx( &inputMc->splitTdRendWrappers[i], inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Assert same delay as main TD renderer */ + assert( inputMc->splitTdRendWrappers[i].binaural_latency_ns == inputMc->tdRendWrapper.binaural_latency_ns ); + + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = inputMc->splitTdRendWrappers[i].hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) + { + IF( Src_p->SrcSpatial_p != NULL ) + { + Src_p->SrcSpatial_p->q_Pos_p = 31; + move16(); + } + IF( inputMc->splitTdRendWrappers[i].hBinRendererTd->Sources[nS] != NULL ) + { + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputMc->splitTdRendWrappers[i].hBinRendererTd->Sources[nS]->SrcSpatial_p; + SrcSpatial_p->q_Pos_p = 31; + move16(); + } + } + } + } + } + +#endif + test(); IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && inputMc->hReverb == NULL ) { @@ -2278,7 +2569,11 @@ static ivas_error initMcBinauralRendering( ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -2337,7 +2632,11 @@ static ivas_error initMcMasaRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputMc->crendWrapper ); +#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2423,10 +2722,16 @@ static ivas_error setRendInputActiveMc( const IVAS_REND_InputId id, RENDER_CONFIG_DATA *hRendCfg ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 i; +#endif ivas_error error; rendering_context rendCtx; AUDIO_CONFIG outConfig; input_mc *inputMc; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 pos_idx; +#endif inputMc = (input_mc *) input; rendCtx = inputMc->base.ctx; @@ -2455,7 +2760,14 @@ static ivas_error setRendInputActiveMc( inputMc->hReverb = NULL; inputMc->hMcMasa = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + initRotGainsWord32_fx( inputMc->rot_gains_prev_fx[pos_idx] ); + } +#else initRotGainsWord32_fx( inputMc->rot_gains_prev_fx ); +#endif inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); set32_fx( inputMc->lfeDelayBuffer_fx, 0, MAX_BIN_DELAY_SAMPLES ); inputMc->binauralDelaySmp = 0; @@ -2463,7 +2775,16 @@ static ivas_error setRendInputActiveMc( test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + inputMc->splitTdRendWrappers[i] = defaultTdRendWrapper(); + } + + IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) +#else IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ), IVAS_ERR_OK ) ) { @@ -2491,6 +2812,9 @@ static void clearInputMc( input_mc *inputMc ) { rendering_context rendCtx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 i; +#endif rendCtx = inputMc->base.ctx; freeMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx ); @@ -2503,7 +2827,11 @@ static void clearInputMc( efap_free_data_fx( &inputMc->efapInWrapper.hEfap ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputMc->crendWrapper ); +#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2513,6 +2841,16 @@ static void clearInputMc( inputMc->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + IF( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &inputMc->splitTdRendWrappers[i].hBinRendererTd ); + inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; + } + } +#endif ivas_mcmasa_ana_close( &( inputMc->hMcMasa ) ); @@ -2634,12 +2972,58 @@ static ivas_error updateSbaPanGains( case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: SWITCH( outConfig ) { - case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: { - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) + IF( EQ_32( hRendCfg->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) { - return error; + assert( inConfig == IVAS_AUDIO_CONFIG_HOA3 && ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural fast conv mode is currently supported with HOA3 input and 48k sampling rate only" ); + if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + assert( ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural crend mode is currently supported with 48k sampling rate only" ); + if ( ( error = ivas_rend_openMultiBinCrend( &inputSba->crendWrapper, inConfig, outConfig, + &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + break; + } +#endif + case IVAS_AUDIO_CONFIG_BINAURAL: + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, + &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else +#endif + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) + + { + return error; + } +#else + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) + + { + return error; + } +#endif } } BREAK; @@ -2649,11 +3033,17 @@ static ivas_error updateSbaPanGains( { return error; } - +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) { return error; } +#endif BREAK; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; @@ -2682,7 +3072,11 @@ static ivas_error initSbaMasaRendering( { ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputSba->crendWrapper ); +#endif IF( NE_32( ( error = ivas_dirac_ana_open_fx( &inputSba->hDirAC, inSampleRate ) ), IVAS_ERR_OK ) ) { @@ -2702,6 +3096,9 @@ static ivas_error setRendInputActiveSba( rendering_context rendCtx; AUDIO_CONFIG outConfig; input_sba *inputSba; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif inputSba = (input_sba *) input; rendCtx = inputSba->base.ctx; @@ -2713,17 +3110,36 @@ static ivas_error setRendInputActiveSba( return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = allocateInputBaseBufferData_fx( &inputSba->bufferData_fx, MAX_CLDFB_BUFFER_LENGTH ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = allocateInputBaseBufferData_fx( &inputSba->bufferData_fx, MAX_BUFFER_LENGTH ) ), IVAS_ERR_OK ) ) { return error; } +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + initRendInputBase_fx( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData_fx, MAX_CLDFB_BUFFER_LENGTH ); +#else initRendInputBase_fx( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData_fx, MAX_BUFFER_LENGTH ); +#endif setZeroPanMatrix_fx( inputSba->hoaDecMtx_fx ); inputSba->crendWrapper = NULL; inputSba->hDirAC = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + initRotGains_fx( inputSba->rot_gains_prev_fx[pos_idx] ); + } +#else initRotGains_fx( inputSba->rot_gains_prev_fx ); +#endif test(); IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) @@ -2752,8 +3168,17 @@ static void clearInputSba( initRendInputBase_fx( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputSba->crendWrapper, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ); + + IF( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) + { + ivas_rend_closeCldfbRend( &inputSba->cldfbRendWrapper ); + } +#else /* Free input's internal handles */ ivas_rend_closeCrend( &inputSba->crendWrapper ); +#endif ivas_dirac_ana_close_fx( &( inputSba->hDirAC ) ); @@ -2860,6 +3285,9 @@ ivas_error IVAS_REND_Open( const Word16 num_subframes ) { Word16 i; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 j; +#endif IVAS_REND_HANDLE hIvasRend; ivas_error error; Word16 numOutChannels; @@ -2929,6 +3357,10 @@ ivas_error IVAS_REND_Open( } /* Initialize inputs */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + isar_init_split_rend_handles( &hIvasRend->splitRendWrapper ); + hIvasRend->splitRendEncBuffer.data_fx = NULL; +#endif FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { @@ -2936,6 +3368,13 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsIsm[i].crendWrapper = NULL; hIvasRend->inputsIsm[i].hReverb = NULL; hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( j = 0; j < MAX_HEAD_ROT_POSES - 1; ++j ) + { + hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hBinRendererTd = NULL; + hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hHrtfTD = NULL; + } +#endif hIvasRend->inputsIsm[i].nonDiegeticPan = nonDiegeticPan; move16(); hIvasRend->inputsIsm[i].nonDiegeticPanGain_fx = nonDiegeticPanGain; @@ -2959,6 +3398,13 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsMc[i].nonDiegeticPanGain_fx = nonDiegeticPanGain; move32(); hIvasRend->inputsMc[i].hMcMasa = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + FOR( j = 0; j < MAX_HEAD_ROT_POSES - 1; ++j ) + { + hIvasRend->inputsMc[i].splitTdRendWrappers[j].hBinRendererTd = NULL; + hIvasRend->inputsMc[i].splitTdRendWrappers[j].hHrtfTD = NULL; + } +#endif } FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) @@ -2966,6 +3412,10 @@ ivas_error IVAS_REND_Open( initRendInputBase_fx( &hIvasRend->inputsSba[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsSba[i].crendWrapper = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend = NULL; + hIvasRend->inputsSba[i].cldfbRendWrapper.hHrtfFastConv = NULL; +#endif hIvasRend->inputsSba[i].bufferData_fx = NULL; hIvasRend->inputsSba[i].hDirAC = NULL; } @@ -3361,6 +3811,124 @@ static ivas_error findFreeInputSlot_fx( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static Word16 getCldfbRendFlag( + IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + const IVAS_REND_AudioConfigType new_configType ) +{ + Word16 i; + Word16 numMasaInputs = 0, numSbaInputs = 0, numIsmInputs = 0, numMcInputs = 0; + Word16 isCldfbRend; + + move16(); + move16(); + move16(); + move16(); + + isCldfbRend = 0; + move16(); + + IF( hIvasRend->hRendererConfig != NULL ) + { + FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) + { + numMasaInputs = add( numMasaInputs, ( hIvasRend->inputsMasa[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ? 0 : 1 ); + move16(); + } + FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) + { + numSbaInputs = add( numSbaInputs, ( hIvasRend->inputsSba[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ? 0 : 1 ); + move16(); + } + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) + { + numIsmInputs = add( numIsmInputs, ( hIvasRend->inputsIsm[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ? 0 : 1 ); + move16(); + } + FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) + { + numMcInputs = add( numMcInputs, ( hIvasRend->inputsMc[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? 0 : 1 ); + move16(); + } + + IF( GT_16( numIsmInputs, 0 ) || GT_16( numMcInputs, 0 ) ) + { + isCldfbRend = 0; + move16(); + } + ELSE IF( GT_16( numMasaInputs, 0 ) || ( GT_16( numSbaInputs, 0 ) && EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) ) + { + isCldfbRend = 1; + move16(); + } + } + + return isCldfbRend; +} + +/*------------------------------------------------------------------------- + * Function ivas_pre_rend_init() + * + * + *------------------------------------------------------------------------*/ + +static ivas_error ivas_pre_rend_init( + SPLIT_REND_WRAPPER *pSplitRendWrapper, + IVAS_REND_AudioBuffer *pSplitRendEncBuffer, + ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + IVAS_REND_HeadRotData headRotData, + const Word32 outputSampleRate, + const AUDIO_CONFIG outConfig, + const Word16 cldfb_in_flag, + const Word16 num_subframes ) +{ + ivas_error error; + IVAS_REND_AudioBufferConfig bufConfig; + + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + ISAR_PRE_REND_GetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis ); + } + else if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); + } + + if ( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /*allocate for CLDFB in and change to TD during process if needed*/ + bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; + bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses; + bufConfig.is_cldfb = 1; + pSplitRendEncBuffer->config = bufConfig; + + if ( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + } + else + { + IVAS_REND_AudioBufferConfig bufConfig2; + + bufConfig2.numSamplesPerChannel = 0; + bufConfig2.numChannels = 0; + bufConfig2.is_cldfb = 0; + pSplitRendEncBuffer->config = bufConfig2; + pSplitRendEncBuffer->data_fx = NULL; + } + + return IVAS_ERR_OK; +} + +#endif + + /*-------------------------------------------------------------------* * IVAS_REND_AddInput() * diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 5af21427f..60d217bad 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -34,6 +34,7 @@ #define LIB_REND_H #include "common_api_types.h" +#include "ivas_stat_rend.h" #include "basop_util.h" #include @@ -55,6 +56,26 @@ typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; typedef Word32 IVAS_REND_LfePanMtx_fx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT +typedef struct +{ + Word32 bufLenInBytes; + Word32 bitsWritten; + Word32 bitsRead; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; + Word16 codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 isar_frame_size_ms; + Word16 lc3plus_highres; +#endif +} IVAS_REND_BitstreamBufferConfig; +typedef struct +{ + IVAS_REND_BitstreamBufferConfig config; + UWord8 *bits; +} IVAS_REND_BitstreamBuffer; +#endif typedef struct { @@ -212,11 +233,45 @@ Word16 IVAS_REND_FeedRenderConfig( const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error IVAS_REND_FeedSplitBinauralBitstream( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ +); + +ivas_error IVAS_REND_GetSplitBinauralSamples( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + bool* needNewFrame +); + +ivas_error IVAS_REND_GetSplitBinauralBitstream( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ +); + +ivas_error IVAS_REND_GetSplitRendBitstreamHeader( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + Word16 *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ +#endif +); +#endif + ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ - const Word16 sf_idx /* i : subframe index */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering*/ +#endif + const Word16 sf_idx /* i : subframe index */ ); /* Head rotation becomes enabled by calling IVAS_REND_SetHeadRotation. Use this to disable. */ @@ -250,6 +305,11 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error IVAS_REND_SetSplitRendBFI( + IVAS_REND_HANDLE hIvasRend, + const Word16 bfi); +#endif ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ @@ -309,6 +369,39 @@ void IVAS_REND_Close( IVAS_REND_HANDLE* phIvasRend /* i/o: Pointer to renderer handle */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Split binaural rendering functions */ + +ivas_error IVAS_REND_openCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], + const Word16 num_in_chs, + const Word16 num_out_chs, + const Word32 output_Fs +); + +void IVAS_REND_closeCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] +); + +void IVAS_REND_cldfbAnalysis_ts_wrapper( + const Word32 *timeIn, /* i : time buffer */ + Word32 realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ +); + +void IVAS_REND_cldfbSynthesis_wrapper( + Word32 **realBuffer, /* i : real values */ + Word32 **imagBuffer, /* i : imag values */ + Word32 *timeOut, /* o : output time domain samples */ + const Word16 samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ +); +#endif + #ifdef FIX_DISCLAIMER /* Disclaimer and info printing */ -- GitLab From e4e3f76f6e08e4341f3a4aaa9f3f75d38646ebe2 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 31 Jan 2025 21:56:12 +1100 Subject: [PATCH 023/329] temp changes in lib rend --- Workspace_msvc/Workspace_msvc.sln | 12 + lib_rend/lib_rend.c | 1708 +++++++++++++++++++++++++---- 2 files changed, 1491 insertions(+), 229 deletions(-) diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index 5449368aa..ac2e76b52 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -99,6 +99,18 @@ Global {95030B82-70CD-4C6B-84D4-61096035BEA2}.Release|Win32.ActiveCfg = Release|Win32 {95030B82-70CD-4C6B-84D4-61096035BEA2}.Release|Win32.Build.0 = Release|Win32 {95030B82-70CD-4C6B-84D4-61096035BEA2}.Release|x64.ActiveCfg = Release|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Debug|Win32.ActiveCfg = Debug|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Debug|Win32.Build.0 = Debug|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Debug|x64.ActiveCfg = Debug|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Release|Win32.ActiveCfg = Release|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Release|Win32.Build.0 = Release|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Release|x64.ActiveCfg = Release|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Debug|Win32.ActiveCfg = Debug|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Debug|Win32.Build.0 = Debug|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Debug|x64.ActiveCfg = Debug|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Release|Win32.ActiveCfg = Release|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Release|Win32.Build.0 = Release|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 796b6e0e0..c5156c2a5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3885,34 +3885,38 @@ static ivas_error ivas_pre_rend_init( ivas_error error; IVAS_REND_AudioBufferConfig bufConfig; - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) { ISAR_PRE_REND_GetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis ); } - else if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + ELSE IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); } - if ( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) + IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) { return error; } /*allocate for CLDFB in and change to TD during process if needed*/ bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; - bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses; + bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); bufConfig.is_cldfb = 1; pSplitRendEncBuffer->config = bufConfig; + move16(); + move16(); + move16(); + move32(); - if ( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) + IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } } - else + ELSE { IVAS_REND_AudioBufferConfig bufConfig2; @@ -3921,6 +3925,11 @@ static ivas_error ivas_pre_rend_init( bufConfig2.is_cldfb = 0; pSplitRendEncBuffer->config = bufConfig2; pSplitRendEncBuffer->data_fx = NULL; + move16(); + move16(); + move16(); + move32(); + move32(); } return IVAS_ERR_OK; @@ -3954,6 +3963,19 @@ ivas_error IVAS_REND_AddInput_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && hIvasRend->splitRendEncBuffer.data_fx == NULL && hIvasRend->hRendererConfig != NULL ) + { + Word16 cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); + + IF( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + SWITCH( getAudioConfigType( inConfig ) ) { @@ -4062,7 +4084,11 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( test(); test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) +#else IF( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, FALSE ) ), IVAS_ERR_OK ) ) { @@ -4404,6 +4430,27 @@ ivas_error IVAS_REND_GetDelay_fx( { IF( NE_32( hIvasRend->inputsSba[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hIvasRend->splitRendWrapper.hBinHrSplitPreRend != NULL ) + { + if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; + } + else + { + latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; + } + max_latency_ns = max( max_latency_ns, latency_ns ); + } + else if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) + { + latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; + latency_ns += IVAS_FB_DEC_DELAY_NS; + max_latency_ns = max( max_latency_ns, latency_ns ); + } + else +#endif { IF( hIvasRend->inputsSba[i].crendWrapper != NULL ) { @@ -4454,6 +4501,9 @@ ivas_error IVAS_REND_FeedInputAudio_fx( ivas_error error; input_base *inputBase; Word16 numInputChannels; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 cldfb2tdSampleFact; +#endif /* Validate function arguments */ test(); @@ -4463,7 +4513,14 @@ ivas_error IVAS_REND_FeedInputAudio_fx( } test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; + + if ( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) +#else IF( inputAudio.config.numSamplesPerChannel <= 0 || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, inputAudio.config.numSamplesPerChannel ) ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -4476,8 +4533,15 @@ ivas_error IVAS_REND_FeedInputAudio_fx( test(); move32(); // move added for typecasting +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) +#else IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( L_mult0( inputAudio.config.numSamplesPerChannel, 1000 ), (Word32) W_mult0_32_32( L_mult0( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -4508,7 +4572,11 @@ ivas_error IVAS_REND_FeedInputAudio_fx( MVR2R_WORD32( inputAudio.data_fx, inputBase->inputBuffer.data_fx, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel / cldfb2tdSampleFact; +#else inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel; +#endif move32(); return IVAS_ERR_OK; @@ -4704,6 +4772,23 @@ Word16 IVAS_REND_GetRenderConfig( Copy32( hRCin->roomAcoustics.pAcoustic_rt60_fx, hRCout->roomAcoustics.pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); Copy32( hRCin->roomAcoustics.pAcoustic_dsr_fx, hRCout->roomAcoustics.pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.dof = 3; + hRCout->split_rend_config.hq_mode = 0; + hRCout->split_rend_config.codec_delay_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.isar_frame_size_ms = 20; +#endif + hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ + hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.lc3plus_highres = 0; +#endif +#endif + hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -4726,6 +4811,9 @@ Word16 IVAS_REND_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_error error; +#endif test(); IF( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) @@ -4761,6 +4849,35 @@ Word16 IVAS_REND_FeedRenderConfig( Copy32( renderConfig.roomAcoustics.AbsCoeff_fx, hRenderConfig->roomAcoustics.AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRenderConfig->split_rend_config = renderConfig.split_rend_config; + /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ + if ( hRenderConfig->split_rend_config.dof == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + + hRenderConfig->split_rend_config.codec = renderConfig.split_rend_config.codec; + + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Must re-initialize split rendering config in case renderer config is updated after adding renderer inputs */ + /* if its not initialized yet then no need to re-initialize, initialization will happen while adding inputs*/ + if ( hIvasRend->splitRendEncBuffer.data_fx != NULL && hIvasRend->hRendererConfig != NULL ) + { + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); + + if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif return IVAS_ERR_OK; } @@ -4774,7 +4891,10 @@ ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ - const Word16 sf_idx /* i : subframe index */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ +#endif + const Word16 sf_idx /* i : subframe index */ ) { Word16 i; @@ -4859,6 +4979,10 @@ ivas_error IVAS_REND_SetHeadRotation( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasRend->headRotData.sr_pose_pred_axis = rot_axis; +#endif + hIvasRend->headRotData.Pos[sf_idx] = Pos; return IVAS_ERR_OK; @@ -4904,6 +5028,25 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_SetSplitRendBFI() + * + * + *-------------------------------------------------------------------*/ + +ivas_error +IVAS_REND_SetSplitRendBFI( + IVAS_REND_HANDLE hIvasRend, + const int16_t bfi ) +{ + hIvasRend->splitRendBFI = bfi; + + return IVAS_ERR_OK; +} +#endif + + /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() * @@ -5581,9 +5724,20 @@ static Word16 getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const Word32 sampleRate ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdShift; + + cldfb2tdShift = buffer->config.is_cldfb ? 1 : 0; + + Word16 scale, temp = extract_l( Mpy_32_32( sampleRate, 10737418 /* 1 / FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); + temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &scale ); + temp = shr( temp, sub( 15, scale ) ); /* Q0 */ + temp = shr( temp, cldfb2tdShift ); +#else Word16 scale, temp = extract_l( Mpy_32_32( sampleRate, 10737418 /* 1 / FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &scale ); temp = shr( temp, sub( 15, scale ) ); /* Q0 */ +#endif return temp; } @@ -5776,12 +5930,19 @@ static ivas_error renderIsmToBinauralRoom( move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* render 7_1_4 with BRIRs */ + IF( NE_32( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, + NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ), 0 ) ), + IVAS_ERR_OK ) ) +#else /* render 7_1_4 with BRIRs */ IF( NE_32( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) - +#endif { return error; } @@ -6069,6 +6230,109 @@ static ivas_error renderIsmToSba( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderIsmToSplitBinaural( + input_ism *ismInput, + const IVAS_REND_AudioBuffer outAudio ) +{ + ivas_error error; + float tmpProcessing[MAX_NUM_OBJECTS][L_FRAME48k]; + int16_t pos_idx; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + const SPLIT_REND_WRAPPER *pSplitRendWrapper; + IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t i; + float tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + int16_t output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; + int16_t ism_md_subframe_update_ext; + + push_wmops( "renderIsmToSplitBinaural" ); + + pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; + pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; + + /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ + ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms_fx / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + + pCombinedOrientationData = *ismInput->base.ctx.pCombinedOrientationData; + + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( i = 1; i < pCombinedOrientationData->num_subframes; ++i ) + { + pCombinedOrientationData->Quaternions[i] = pCombinedOrientationData->Quaternions[0]; + } + } + + /* Save current head positions */ + for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + { + originalHeadRot[i] = pCombinedOrientationData->Quaternions[i]; + } + + /* Copy input audio to a processing buffer. */ + copyBufferTo2dArray( ismInput->base.inputBuffer, tmpProcessing ); + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + if ( pos_idx != 0 ) + { + for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + { + if ( originalHeadRot[i].w == -3.0f ) + { + pCombinedOrientationData->Quaternions[i].w = -3.0f; + pCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + pCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + pCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + else + { + pCombinedOrientationData->Quaternions[i].w = -3.0f; + Quat2EulerDegree( originalHeadRot[i], + &pCombinedOrientationData->Quaternions[i].z, + &pCombinedOrientationData->Quaternions[i].y, + &pCombinedOrientationData->Quaternions[i].x ); + pCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + pCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + pCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + } + } + + /* Render */ + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, + NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Copy rendered audio to tmp storage buffer. Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + mvr2r( tmpProcessing[0], tmpBinaural[2 * pos_idx], output_frame ); + mvr2r( tmpProcessing[1], tmpBinaural[2 * pos_idx + 1], output_frame ); + + /* Overwrite processing buffer with original input audio again */ + copyBufferTo2dArray( ismInput->base.inputBuffer, tmpProcessing ); + } + + /* Restore original head rotation */ + for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + { + pCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + } + + accumulate2dArrayToBuffer( tmpBinaural, &outAudio ); + pop_wmops(); + + /* Encoding to split rendering bitstream done at a higher level */ + return IVAS_ERR_OK; +} +#endif + + static void renderIsmToMasa( input_ism *ismInput, IVAS_REND_AudioBuffer outAudio, @@ -6180,6 +6444,12 @@ static ivas_error renderInputIsm( case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: error = renderIsmToBinauralRoom( ismInput, outAudio, &exp ); BREAK; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderIsmToSplitBinaural( ismInput, outAudio ); + break; +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: error = renderIsmToBinauralReverb( ismInput, outAudio ); BREAK; @@ -6249,11 +6519,17 @@ static ivas_error renderActiveInputsIsm( } static ivas_error renderLfeToBinaural_fx( const input_mc *mcInput, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const AUDIO_CONFIG outConfig, +#endif IVAS_REND_AudioBuffer outAudio, Word16 in_q, Word16 out_q ) { Word16 lfe_idx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pose_idx, num_poses; +#endif Word32 gain_fx; Word16 ear_idx, i, r_shift; Word32 tmpLfeBuffer[MAX_BUFFER_LENGTH_PER_CHANNEL]; @@ -6261,7 +6537,11 @@ static ivas_error renderLfeToBinaural_fx( const Word32 *lfeInput; Word32 *writePtr; +#ifdef SPLIT_REND_WITH_HEAD_ROT + assert( ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && "Must be binaural output" ); +#else assert( ( outAudio.config.numChannels == 2 ) && "Must be binaural output" ); +#endif push_wmops( "renderLfeToBinaural" ); gain_fx = GAIN_LFE_WORD32; /* 1.88364911f in Q30 */ @@ -6312,6 +6592,27 @@ static ivas_error renderLfeToBinaural_fx( move32(); } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* Copy LFE to left and right binaural channels for all poses */ + if ( mcInput->base.ctx.pSplitRendWrapper != NULL ) + { + num_poses = mcInput->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; + } + else + { + num_poses = 1; + } + + for ( pose_idx = 0; pose_idx < num_poses; ++pose_idx ) + { + for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) + { + writePtr = getSmplPtr_fx( outAudio, pose_idx * BINAURAL_CHANNELS + ear_idx, 0 ); + v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */ + } + } +#else /* SPLIT_REND_WITH_HEAD_ROT */ /* Copy LFE to left and right ears */ FOR( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) { @@ -6319,6 +6620,7 @@ static ivas_error renderLfeToBinaural_fx( move32(); v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */ } +#endif pop_wmops(); @@ -6395,7 +6697,11 @@ static ivas_error renderMcToBinaural( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); set32_fx( tmpRotBuffer.data_fx, 0, imult1616( tmpRotBuffer.config.numSamplesPerChannel, tmpRotBuffer.config.numChannels ) ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6415,9 +6721,15 @@ static ivas_error renderMcToBinaural( hCrend = mcInput->crendWrapper->hCrend; /* call CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6515,7 +6827,11 @@ static ivas_error renderMcToBinauralRoom( set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev_fx[0], +#else mcInput->rot_gains_prev_fx, +#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) { @@ -6536,9 +6852,15 @@ static ivas_error renderMcToBinauralRoom( hCrend = mcInput->crendWrapper->hCrend; /* call CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6550,7 +6872,11 @@ static ivas_error renderMcToBinauralRoom( accumulate2dArrayToBuffer_fx( tmpRendBuffer, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6609,7 +6935,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev_fx[0], +#else mcInput->rot_gains_prev_fx, +#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) { @@ -6648,9 +6978,15 @@ static ivas_error renderMcCustomLsToBinauralRoom( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend; /* call CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, + p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6661,7 +6997,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( accumulate2dArrayToBuffer_fx( tmpCrendBuffer, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6726,55 +7066,222 @@ static void renderMcToMasa( return; } -static ivas_error renderInputMc( +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderMcToSplitBinaural( input_mc *mcInput, const AUDIO_CONFIG outConfig, IVAS_REND_AudioBuffer outAudio ) { + int16_t i, j, pos_idx; + int16_t sf; + int16_t output_frame; ivas_error error; - IVAS_REND_AudioBuffer inAudio; - error = IVAS_ERR_OK; - move32(); + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + const SPLIT_REND_WRAPPER *pSplitRendWrapper; + float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + float tmpSplitBinauralBuffer[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + AUDIO_CONFIG inConfig; + IVAS_REND_AudioBuffer tmpRotBuffer; + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; - inAudio = mcInput->base.inputBuffer; + push_wmops( "renderMcToSplitBinaural" ); + inConfig = mcInput->base.inConfig; + output_frame = mcInput->base.inputBuffer.config.numSamplesPerChannel; - IF( NE_32( mcInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) + pSplitRendWrapper = mcInput->base.ctx.pSplitRendWrapper; + pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { - return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); + p_tmpRendBuffer[i] = tmpRendBuffer[i]; } - mcInput->base.numNewSamplesPerChannel = 0; - move32(); - v_multc_fixed( inAudio.data_fx, mcInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); - *outAudio.pq_fact = sub( *outAudio.pq_fact, Q1 ); // reducing the Q by 1 compensating for the v_mult_fixed done - move16(); - /* set combined orientation subframe info to start info */ - ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); - SWITCH( getAudioConfigType( outConfig ) ) + /* save current head positions */ + pCombinedOrientationDataLocal = *mcInput->base.ctx.pCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: - renderMcToMc( mcInput, outAudio ); - BREAK; - case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: - renderMcToSba( mcInput, outAudio ); - BREAK; - case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: - SWITCH( outConfig ) + for ( sf = 1; sf < combinedOrientationDataLocal.num_subframes; ++sf ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) { - case IVAS_AUDIO_CONFIG_BINAURAL: - error = renderMcToBinaural( mcInput, outConfig, outAudio ); - BREAK; - case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: - case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: - IF( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - error = renderMcCustomLsToBinauralRoom( mcInput, outConfig, outAudio ); - } - ELSE - { - error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); - } - BREAK; + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + /* temporary buffer for rotation in source format for CREND */ + tmpRotBuffer = mcInput->base.inputBuffer; + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_AUDIO_CONFIG_5_1 && inConfig != IVAS_AUDIO_CONFIG_7_1 ) + { + tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + } + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + if ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM || inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1 ) + { + /* tdrend processing overview: + * 1. copy from inputBuffer to tmpRendBuffer + * 2. td_binaural_renderer_ext: inplace processing in tmpRendBuffer + * 3. copy from tmpRendBuffer to tmpSplitBinBuffer + * 4. LFE mixing + * 5. tmpSplitBinBuffer accumulated to outBuffer */ + + /* copy input to tdrend input/output buffer */ + copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); + + /* perform rotation in source format to tmpRotBuffer */ + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + + /* Render */ + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Copy rendered audio to tmp storage buffer. Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); + mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); + } + else + { + /* crend processing overview: + * 1. rotateFrameMc: inputBuffer to tmpRotBuffer + * 2. crend_process: tmpRotBuffer to tmpRendBuffer + * 3. copy from tmpRendBuffer to tmpSplitBinBuffer + * 4. LFE mixing + * 5. tmpSplitBinBuffer accumulated to outBuffer */ + + + /* copy input for in-place rotation */ + set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); + + /* perform rotation in source format to tmpRotBuffer */ + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, mcInput->rot_gains_prev[pos_idx], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); + + /* call CREND (rotation already performed) */ + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Copy rendererd audio to tmp storage buffer, Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); + mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); + } + + /* restore original headrotation data */ + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + } + + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_AUDIO_CONFIG_5_1 && inConfig != IVAS_AUDIO_CONFIG_7_1 ) + { + /* free temporary buffer for rotation in source format for CREND */ + free( tmpRotBuffer.data ); + } + + accumulate2dArrayToBuffer( tmpSplitBinauralBuffer, &outAudio ); + + if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + + pop_wmops(); + return IVAS_ERR_OK; +} +#endif + + +static ivas_error renderInputMc( + input_mc *mcInput, + const AUDIO_CONFIG outConfig, + IVAS_REND_AudioBuffer outAudio ) +{ + ivas_error error; + IVAS_REND_AudioBuffer inAudio; + error = IVAS_ERR_OK; + move32(); + + inAudio = mcInput->base.inputBuffer; + + IF( NE_32( mcInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); + } + mcInput->base.numNewSamplesPerChannel = 0; + move32(); + v_multc_fixed( inAudio.data_fx, mcInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + *outAudio.pq_fact = sub( *outAudio.pq_fact, Q1 ); // reducing the Q by 1 compensating for the v_mult_fixed done + move16(); + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); + + SWITCH( getAudioConfigType( outConfig ) ) + { + case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: + renderMcToMc( mcInput, outAudio ); + BREAK; + case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: + renderMcToSba( mcInput, outAudio ); + BREAK; + case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: + SWITCH( outConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + error = renderMcToBinaural( mcInput, outConfig, outAudio ); + BREAK; + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: + IF( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + error = renderMcCustomLsToBinauralRoom( mcInput, outConfig, outAudio ); + } + ELSE + { + error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); + } + BREAK; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderMcToSplitBinaural( mcInput, outConfig, outAudio ); + break; +#endif default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } @@ -6850,6 +7357,170 @@ static void renderSbaToSba( pop_wmops(); return; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +static ivas_error renderSbaToMultiBinaural( + input_sba *sbaInput, + const AUDIO_CONFIG outConfig, + float out[][L_FRAME48k] ) +{ + float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; + int16_t sf; + int16_t i, j, pos_idx; + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + ivas_error error; + IVAS_REND_AudioBuffer tmpRotBuffer; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + p_tmpCrendBuffer[i] = tmpCrendBuffer[i]; + } + push_wmops( "renderSbaToMultiBinaural" ); + pMultiBinPoseData = &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData; + + pCombinedOrientationDataLocal = *sbaInput->base.ctx.pCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < combinedOrientationDataLocal.num_subframes; sf++ ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + tmpRotBuffer = sbaInput->base.inputBuffer; + tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + + /* copy input for in-place rotation */ + mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); + + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, sbaInput->rot_gains_prev[pos_idx], tmpRotBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + copyBufferTo2dArray( tmpRotBuffer, tmpCrendBuffer ); + + assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); + + /* call CREND */ + if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + + + /* move to output */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + mvr2r( tmpCrendBuffer[i], out[pos_idx * BINAURAL_CHANNELS + i], tmpRotBuffer.config.numSamplesPerChannel ); + } + } + + free( tmpRotBuffer.data ); + + pop_wmops(); + return IVAS_ERR_OK; +} + + +static ivas_error renderSbaToMultiBinauralCldfb( + input_sba *sbaInput, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes ) +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + + copyBufferToCLDFBarray( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + + ivas_rend_CldfbMultiBinRendProcess( sbaInput->cldfbRendWrapper.hCldfbRend, sbaInput->base.ctx.pCombinedOrientationData, &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, + Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes ); + + return IVAS_ERR_OK; +} + + +static ivas_error renderSbaToSplitBinaural( + input_sba *sbaInput, + const AUDIO_CONFIG outConfig, + IVAS_REND_AudioBuffer outAudio ) +{ + float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + ivas_error error; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t low_res_pre_rend_rot; + + low_res_pre_rend_rot = 1; + + push_wmops( "renderSbaToSplitBinaural" ); + error = IVAS_ERR_OK; + + if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + if ( ( renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + } + else + { + if ( ( renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); + } + + pop_wmops(); + return error; +} +#endif + static ivas_error renderSbaToBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -6865,6 +7536,23 @@ static ivas_error renderSbaToBinaural( Word32 *output_fx[MAX_OUTPUT_CHANNELS]; push_wmops( "renderSbaToBinaural" ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + + if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + } + else +#endif { FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) @@ -6897,12 +7585,22 @@ static ivas_error renderSbaToBinaural( Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, i_mult( tmpRotBuffer.config.numChannels, tmpRotBuffer.config.numSamplesPerChannel ) ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_16( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), + IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_16( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx, tmpRotBuffer ) ), IVAS_ERR_OK ) ) { return error; } +#endif copyBufferTo2dArray_fx( tmpRotBuffer, output_buffer_fx ); free( tmpRotBuffer.data_fx ); @@ -6916,9 +7614,15 @@ static ivas_error renderSbaToBinaural( hCrend = sbaInput->crendWrapper->hCrend; /* call CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, output_fx, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, output_fx, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6994,7 +7698,11 @@ static ivas_error renderSbaToBinauralRoom( IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, +#ifdef SPLIT_REND_WITH_HEAD_ROT + sbaInput->rot_gains_prev_fx[0], +#else sbaInput->rot_gains_prev_fx, +#endif tmpRotBuffer ) ), IVAS_ERR_OK ) ) { @@ -7031,10 +7739,17 @@ static ivas_error renderSbaToBinauralRoom( // Porting Crend_process function /* call CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, + NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -7076,11 +7791,20 @@ static ivas_error renderInputSba( { ivas_error error; IVAS_REND_AudioBuffer inAudio; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; +#endif error = IVAS_ERR_OK; move32(); inAudio = sbaInput->base.inputBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = outAudio.config.is_cldfb ? 2 : 1; + if ( ( sbaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && + ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else IF( NE_32( sbaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -7098,6 +7822,12 @@ static ivas_error renderInputSba( SWITCH( getAudioConfigType( outConfig ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderSbaToSplitBinaural( sbaInput, outConfig, outAudio ); + break; +#endif case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: renderSbaToMc( sbaInput, outAudio ); BREAK; @@ -7436,6 +8166,11 @@ static ivas_error renderInputMasa( Word16 maxBin; Word32 *tmpBuffer_fx[MAX_OUTPUT_CHANNELS]; Word32 tmpBuffer_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif IF( !masaInput->metadataHasBeenFed ) { @@ -7443,7 +8178,14 @@ static ivas_error renderInputMasa( } inAudio = masaInput->base.inputBuffer; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = outAudio.config.is_cldfb ? 2 : 1; + if ( ( masaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && + ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else IF( NE_32( masaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -7480,58 +8222,94 @@ static ivas_error renderInputMasa( num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( masaInput->base.inputBuffer.config.numSamplesPerChannel, IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), *masaInput->base.ctx.pOutSampleRate, &exp ); num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ - SWITCH( masaInput->hMasaExtRend->renderer_type ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - case RENDERER_DIRAC: - - copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); - intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 1 ); - FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) - { - masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; - move16(); - } - FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + /* split rendering. use the combined of the first subframe in all subframes */ + int16_t sf, i, j; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; + pCombinedOrientationData = *masaInput->base.ctx.pCombinedOrientationData; + for ( sf = 1; sf < pCombinedOrientationData->num_subframes; sf++ ) + { + pCombinedOrientationData->Quaternions[sf] = pCombinedOrientationData->Quaternions[0]; + for ( i = 0; i < 3; i++ ) { - Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + for ( j = 0; j < 3; j++ ) + { + pCombinedOrientationData->Rmat[sf][i][j] = pCombinedOrientationData->Rmat[0][i][j]; + } } + } - scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); - ivas_masa_ext_dirac_render_fx( masaInput->hMasaExtRend, tmpBuffer_fx, num_subframes ); + ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); - *outAudio.pq_fact = Q11; - move16(); + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + } + else + { + /* non-split path */ +#endif + SWITCH( masaInput->hMasaExtRend->renderer_type ) + { + case RENDERER_DIRAC: - FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) - { - scale_sig32( masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, masaInput->hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state ) ); /* Q11 */ - masaInput->hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 1 ); + FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) + { + masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; + move16(); + } + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + } + + scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + + ivas_masa_ext_dirac_render_fx( masaInput->hMasaExtRend, tmpBuffer_fx, num_subframes ); + + *outAudio.pq_fact = Q11; move16(); - } - intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 0 ); - BREAK; - case RENDERER_STEREO_PARAMETRIC: - case RENDERER_BINAURAL_PARAMETRIC: - case RENDERER_BINAURAL_PARAMETRIC_ROOM: + FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) + { + scale_sig32( masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, masaInput->hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state ) ); /* Q11 */ + masaInput->hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; + move16(); + } - copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 0 ); + BREAK; + case RENDERER_STEREO_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: - Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); - scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); + Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, NULL, NULL, NULL ); +#else ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes ); - *outAudio.pq_fact = Q11; - move16(); - BREAK; - case RENDERER_DISABLE: - BREAK; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ - default: - return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); +#endif + *outAudio.pq_fact = Q11; + move16(); + BREAK; + case RENDERER_DISABLE: + BREAK; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ + default: + return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif accumulate2dArrayToBuffer_fx( tmpBuffer_buff_fx, &outAudio ); } @@ -7763,12 +8541,21 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( *-------------------------------------------------------------------*/ static ivas_error getSamplesInternal( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */, + IVAS_REND_BitstreamBuffer *hBits /*i/o: buffer for input/output bitstream. Needed in split rendering mode*/ +#else IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +#endif ) { ivas_error error; Word16 numOutChannels; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; + IVAS_REND_AudioBuffer outAudioOrig; +#endif /* Validate function arguments */ test(); IF( hIvasRend == NULL || outAudio.data_fx == NULL ) @@ -7777,7 +8564,14 @@ static ivas_error getSamplesInternal( } test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; + + if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) +#else IF( outAudio.config.numSamplesPerChannel <= 0 || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, outAudio.config.numSamplesPerChannel ) ) +#endif { return IVAS_ERR_INVALID_BUFFER_SIZE; } @@ -7789,8 +8583,15 @@ static ivas_error getSamplesInternal( } test(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + ( outAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) +#else IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( L_mult0( outAudio.config.numSamplesPerChannel, 1000 ), imult3216( hIvasRend->sampleRateOut, i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ) ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -7864,41 +8665,256 @@ static ivas_error getSamplesInternal( } } - IF( NE_32( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) + { + return error; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( numOutChannels != outAudio.config.numChannels && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + IF( NE_16( numOutChannels, outAudio.config.numChannels ) ) +#endif + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + /* Clear original output buffer */ + set32_fx( outAudio.data_fx, 0, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + outAudioOrig = outAudio; + /* Use internal buffer if outputting split rendering bitstream */ + if ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + int16_t num_poses_orig; + num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; + outAudio = hIvasRend->splitRendEncBuffer; + Word16 i, q_factor = Q22; + + ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); + + FOR( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses[i][0] = fixedToFloat( hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses_fx[i][0], q_factor ); + hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses[i][1] = fixedToFloat( hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses_fx[i][1], q_factor ); + hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses[i][2] = fixedToFloat( hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses_fx[i][2], q_factor ); + } + assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" ); + + /* Clear output buffer for split rendering bitstream */ + set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); + } +#endif + + IF( NE_32( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) + { + return error; + } + IF( NE_32( ( error = renderActiveInputsMc( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) + { + return error; + } + IF( NE_32( ( error = renderActiveInputsSba( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) + { + return error; + } + IF( NE_32( ( error = renderActiveInputsMasa( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) + { + return error; + } + + test(); + test(); + +#ifndef SPLIT_REND_WITH_HEAD_ROT + + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + ISAR_SPLIT_REND_BITS_DATA bits; + int16_t cldfb_in_flag; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + for ( int i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + { + for ( int j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + for ( int k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural[i][j][k] = 0; + Cldfb_ImagBuffer_Binaural[i][j][k] = 0; + } + } + } + int16_t ch; + int16_t i, ro_md_flag; + float *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBinaural[ch] = tmpBinaural_buff[ch]; + } + + if ( outAudio.config.is_cldfb == 1 ) + { + cldfb_in_flag = 1; + copyBufferToCLDFBarray( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); + } + else + { + cldfb_in_flag = 0; + copyBufferTo2dArray( outAudio, tmpBinaural_buff ); + } + + /* Encode split rendering bitstream */ + convertBitsBufferToInternalBitsBuff( *hBits, &bits ); + + ro_md_flag = 0; + for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) + { + if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + ro_md_flag = 1; + break; + } + } + Word16 j; + Word16 q, q1 = 31, q2 = 31, Q_buff; + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word32 *pOutput_fx[CLDFB_NO_COL_MAX]; + Word32 output_fx[CLDFB_NO_COL_MAX][L_FRAME48k]; + Word16 Q_out[CLDFB_NO_COL_MAX]; + Q_out[0] = 31; + for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + pOutput_fx[i] = &( output_fx[i][0] ); + } + Word16 num_poses = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; + for ( i = 0; i < 16; i++ ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + q = Q_factor_arrL( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ); + q1 = s_min( q1, q ); + q = Q_factor_arrL( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ); + q2 = s_min( q2, q ); + } + } + Q_buff = s_min( q1, q2 ); + for ( i = 0; i < 16; i++ ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + floatToFixed_arrL( Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural_fx[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural_fx[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + } + } + IF( EQ_16( cldfb_in_flag, 0 ) ) + { + /*TD input*/ + /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ + /* local float2fix, to be removed */ + num_poses = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; + if ( hIvasRend->splitRendWrapper.hLc3plusEnc != NULL ) + { + Word16 frame_size_lc3 = (Word16) ( ( hIvasRend->splitRendWrapper.hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ) + hIvasRend->splitRendWrapper.lc3plusDelaySamples ); + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + Q_out[0] = s_min( Q_out[0], Q_factor_arrL( hIvasRend->splitRendWrapper.lc3plusDelayBuffers[i], frame_size_lc3 ) ); + } + } + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + Q_out[0] = s_min( Q_out[0], Q_factor_arrL( tmpBinaural[i], L_FRAME48k ) ); + } + // printf("%d\n", Q_sig); + if ( hIvasRend->splitRendWrapper.hLc3plusEnc != NULL ) + { + Word16 frame_size_lc3 = (Word16) ( ( hIvasRend->splitRendWrapper.hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ) + hIvasRend->splitRendWrapper.lc3plusDelaySamples ); + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + floatToFixed_arrL( hIvasRend->splitRendWrapper.lc3plusDelayBuffers[i], hIvasRend->splitRendWrapper.lc3plusDelayBuffers_fx[i], Q_out[0], frame_size_lc3 ); + } + } + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + floatToFixed_arrL( tmpBinaural[i], pOutput_fx[i], Q_out[0], L_FRAME48k ); + } + } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, +#endif + hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, + &bits, Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, pOutput_fx, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + IF( EQ_16( cldfb_in_flag, 0 ) ) + { + if ( hIvasRend->splitRendWrapper.hLc3plusEnc != NULL ) + { + Word16 frame_size_lc3 = (Word16) ( ( hIvasRend->splitRendWrapper.hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ) + hIvasRend->splitRendWrapper.lc3plusDelaySamples ); + +#ifdef DUMP_LC3_DELAY_OUT + FILE *fp = fopen( "ref_lc3delay.txt", "ab" ); +#endif + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + fixedToFloat_arrL( hIvasRend->splitRendWrapper.lc3plusDelayBuffers_fx[i], hIvasRend->splitRendWrapper.lc3plusDelayBuffers[i], Q_out[0], frame_size_lc3 ); +#ifdef DUMP_LC3_DELAY_OUT + for ( Word16 j = 0; j < frame_size_lc3; j++ ) + { + fprintf( fp, "%f\n", hSplitBin->lc3plusDelayBuffers[i][j] ); + } +#endif + } +#ifdef DUMP_LC3_DELAY_OUT + fclose( fp ); +#endif + } + } + + Word16 pcm_out_flag = ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + IF( NE_16( pcm_out_flag, 0 ) && ( NE_16( cldfb_in_flag, 0 ) ) ) + { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + fixedToFloat_arrL( pOutput_fx[ch], tmpBinaural[ch], Q_out[ch], hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX ); + + fixedToFloat_arrL( hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->cldfb_state, hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->Q_split, hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->p_filter_length ); + } + } + - IF( NE_16( numOutChannels, outAudio.config.numChannels ) ) - { - return IVAS_ERR_WRONG_NUM_CHANNELS; - } + convertInternalBitsBuffToBitsBuffer( hBits, bits ); - /* Clear original output buffer */ - set32_fx( outAudio.data_fx, 0, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); + /* reset to outAudioOrig in case of PCM output */ + outAudio = outAudioOrig; - IF( NE_32( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) - { - return error; - } - IF( NE_32( ( error = renderActiveInputsMc( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) - { - return error; - } - IF( NE_32( ( error = renderActiveInputsSba( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) - { - return error; + if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); + } } - IF( NE_32( ( error = renderActiveInputsMasa( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outAudio.config.is_cldfb == 0 ) { - return error; + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); } - - test(); - test(); - - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); +#endif /* update global cominbed orientation start index */ ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); @@ -7918,9 +8934,71 @@ ivas_error IVAS_REND_GetSamples( ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + return getSamplesInternal( hIvasRend, outAudio, NULL ); +#else return getSamplesInternal( hIvasRend, outAudio ); +#endif +} + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitBinauralBitstream() + * + * + *-------------------------------------------------------------------*/ + +ivas_error +IVAS_REND_GetSplitBinauralBitstream( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ +) +{ + int16_t cldfb_in_flag; + + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in_flag; + if ( hIvasRend->hRendererConfig->split_rend_config.dof == 0 || hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = outAudio.config.numSamplesPerChannel; + } + else + { + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = (int16_t) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); + } + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; + + /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output + outAudio used for BINAURAL_SPLIT_PCM output */ + return getSamplesInternal( hIvasRend, outAudio, hBits ); +} + +ivas_error IVAS_REND_GetSplitRendBitstreamHeader( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ +#endif +) +{ + if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + *pCodec = hIvasRend->hRendererConfig->split_rend_config.codec; + *pCodec_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + *pIsar_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms; +#endif + *poseCorrection = hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode; + return IVAS_ERR_OK; } +#endif /*-------------------------------------------------------------------* * IVAS_REND_Close() @@ -7972,6 +9050,11 @@ void IVAS_REND_Close( ivas_limiter_close_fx( &hIvasRend->hLimiter ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* Split binaural rendering */ + ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); +#endif + closeHeadRotation( hIvasRend ); @@ -7984,6 +9067,126 @@ void IVAS_REND_Close( return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_openCldfb() + * + * + *-------------------------------------------------------------------*/ + +ivas_error +IVAS_REND_openCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], + const int16_t num_in_chs, + const int16_t num_out_chs, + const int32_t output_Fs ) +{ + int16_t n; + ivas_error error; + + for ( n = 0; n < num_in_chs; n++ ) + { + if ( ( error = openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + cldfbAna[n] = NULL; + } + + for ( n = 0; n < num_out_chs; n++ ) + { + if ( ( error = openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + for ( ; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) + { + cldfbSyn[n] = NULL; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * IVAS_REND_closeCldfb() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_closeCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] ) +{ + int16_t n; + + for ( n = 0; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + if ( cldfbAna[n] != NULL ) + { + deleteCldfb( &( cldfbAna[n] ) ); + cldfbAna[n] = NULL; + } + } + + for ( n = 0; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) + { + if ( cldfbSyn[n] != NULL ) + { + deleteCldfb( &( cldfbSyn[n] ) ); + cldfbSyn[n] = NULL; + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_cldfbSynthesis_wrapper() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_cldfbAnalysis_ts_wrapper( + const float *timeIn, /* i : time buffer */ + float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const int16_t samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ +) +{ + cldfbAnalysis_ts( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb ); + + return; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_cldfbSynthesis_wrapper() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_cldfbSynthesis_wrapper( + float **realBuffer, /* i : real values */ + float **imagBuffer, /* i : imag values */ + float *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ +) +{ + cldfbSynthesis( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); + + return; +} +#endif + + static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) { @@ -8426,6 +9629,10 @@ static ivas_error ivas_masa_ext_rend_parambin_init( Word16 tmpFloat_fx; ivas_error error; Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif + Word16 tmp; Word16 tmp_e; Word16 tmp2; @@ -8443,144 +9650,165 @@ static ivas_error ivas_masa_ext_rend_parambin_init( renderer_type = inputMasa->hMasaExtRend->renderer_type; move32(); - hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin; - - /* Init assumes that no reconfiguration is required in external renderer. Instead, free and rebuild whole rendering. */ - IF( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < inputMasa->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; pos_idx++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); - } - - hDiracDecBin->hTdDecorr = NULL; - hDiracDecBin->hReverb = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; - hDiracDecBin->hDiffuseDist = NULL; /* Not used in external renderer */ - hDiracDecBin->useTdDecorr = 0; /* Always use frequency domain decorrelator in external renderer */ - move16(); + hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin[pos_idx]; +#else + hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin; +#endif - FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + /* Init assumes that no reconfiguration is required in external renderer. Instead, free and rebuild whole rendering. */ + IF( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) { - set16_fx( hDiracDecBin->processMtxRe_fx[j][k], 0, nBins ); - set16_fx( hDiracDecBin->processMtxIm_fx[j][k], 0, nBins ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); } - FOR( k = 0; k < BINAURAL_CHANNELS; k++ ) - { - set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k], 0, nBins ); - set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k], 0, nBins ); - } - hDiracDecBin->q_processMtx = Q15; - hDiracDecBin->q_processMtxSCCR = Q15; - hDiracDecBin->q_processMtxPrev = Q15; - hDiracDecBin->q_processMtxPrevSCCR = Q15; - hDiracDecBin->q_processMtxDec = Q15; - hDiracDecBin->q_processMtxDecPrev = Q15; - move16(); - move16(); - move16(); - move16(); - move16(); + hDiracDecBin->hTdDecorr = NULL; + hDiracDecBin->hReverb = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; + hDiracDecBin->hDiffuseDist = NULL; /* Not used in external renderer */ + hDiracDecBin->useTdDecorr = 0; /* Always use frequency domain decorrelator in external renderer */ move16(); - set_zero_fx( hDiracDecBin->ChEnePrev_fx[j], nBins ); - set_zero_fx( hDiracDecBin->ChEneOutPrev_fx[j], nBins ); - set16_fx( hDiracDecBin->ChEnePrev_e[j], 0, nBins ); - set16_fx( hDiracDecBin->ChEneOutPrev_e[j], 0, nBins ); - } - set_zero_fx( hDiracDecBin->ChCrossRePrev_fx, nBins ); - set_zero_fx( hDiracDecBin->ChCrossImPrev_fx, nBins ); - set_zero_fx( hDiracDecBin->ChCrossReOutPrev_fx, nBins ); - set_zero_fx( hDiracDecBin->ChCrossImOutPrev_fx, nBins ); - set16_fx( hDiracDecBin->ChCrossRePrev_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossImPrev_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossReOutPrev_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossImOutPrev_e, 0, nBins ); - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - move16(); - FOR( bin = 0; bin < nBins; bin++ ) - { - binCenterFreq_fx = L_mult0( extract_l( L_shr( output_Fs, 1 ) ), div_s( add( shl( bin, 1 ), 1 ), shl( nBins, 1 ) ) ) /*( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f )*/; /*Q15*/ - /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ - tmp = BASOP_Util_Divide3232_Scale( binCenterFreq_fx, L_shl( 2700, Q15 ), &tmp_e ); - IF( tmp_e < 0 ) + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { - tmp = shl( tmp, tmp_e ); /*q15*/ - tmp_e = 0; + FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + { + set16_fx( hDiracDecBin->processMtxRe_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxIm_fx[j][k], 0, nBins ); + } + + FOR( k = 0; k < BINAURAL_CHANNELS; k++ ) + { + set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k], 0, nBins ); + set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k], 0, nBins ); + } + hDiracDecBin->q_processMtx = Q15; + hDiracDecBin->q_processMtxSCCR = Q15; + hDiracDecBin->q_processMtxPrev = Q15; + hDiracDecBin->q_processMtxPrevSCCR = Q15; + hDiracDecBin->q_processMtxDec = Q15; + hDiracDecBin->q_processMtxDecPrev = Q15; + move16(); + move16(); + move16(); move16(); + move16(); + move16(); + set_zero_fx( hDiracDecBin->ChEnePrev_fx[j], nBins ); + set_zero_fx( hDiracDecBin->ChEneOutPrev_fx[j], nBins ); + set16_fx( hDiracDecBin->ChEnePrev_e[j], 0, nBins ); + set16_fx( hDiracDecBin->ChEneOutPrev_e[j], 0, nBins ); + } + set_zero_fx( hDiracDecBin->ChCrossRePrev_fx, nBins ); + set_zero_fx( hDiracDecBin->ChCrossImPrev_fx, nBins ); + set_zero_fx( hDiracDecBin->ChCrossReOutPrev_fx, nBins ); + set_zero_fx( hDiracDecBin->ChCrossImOutPrev_fx, nBins ); + set16_fx( hDiracDecBin->ChCrossRePrev_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossImPrev_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossReOutPrev_e, 0, nBins ); + set16_fx( hDiracDecBin->ChCrossImOutPrev_e, 0, nBins ); + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; + move16(); + + FOR( bin = 0; bin < nBins; bin++ ) + { + binCenterFreq_fx = L_mult0( extract_l( L_shr( output_Fs, 1 ) ), div_s( add( shl( bin, 1 ), 1 ), shl( nBins, 1 ) ) ) /*( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f )*/; /*Q15*/ + /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ + tmp = BASOP_Util_Divide3232_Scale( binCenterFreq_fx, L_shl( 2700, Q15 ), &tmp_e ); + IF( tmp_e < 0 ) + { + tmp = shl( tmp, tmp_e ); /*q15*/ + tmp_e = 0; + move16(); + } + tmpFloat_fx = s_max( 0, sub( shl_sat( 1, sub( 15, tmp_e ) ), tmp ) ) /*max( 0.0f, 1.0f - binCenterFreq / 2700.0f )*/; /*Q30*/ + tmp2 = extract_l( Mult_32_32( binCenterFreq_fx, 1952258 /*=2^31*180/(550)/360*/ ) % 32767 ); //*binCenterFreq_fx * EVS_PI / 550.0f*/ + hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( L_mult0( divide3232( tmpFloat_fx, Mult_32_16( binCenterFreq_fx, 187 /*2^15*pi/550*/ ) ), getSineWord16R2( tmp2 ) ), tmp_e ); /*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/ + hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( hDiracDecBin->diffuseFieldCoherence_fx[bin], 1 ); /* Q31 */ + move32(); + move32(); } - tmpFloat_fx = s_max( 0, sub( shl_sat( 1, sub( 15, tmp_e ) ), tmp ) ) /*max( 0.0f, 1.0f - binCenterFreq / 2700.0f )*/; /*Q30*/ - tmp2 = extract_l( Mult_32_32( binCenterFreq_fx, 1952258 /*=2^31*180/(550)/360*/ ) % 32767 ); //*binCenterFreq_fx * EVS_PI / 550.0f*/ - hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( L_mult0( divide3232( tmpFloat_fx, Mult_32_16( binCenterFreq_fx, 187 /*2^15*pi/550*/ ) ), getSineWord16R2( tmp2 ) ), tmp_e ); /*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/ - hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( hDiracDecBin->diffuseFieldCoherence_fx[bin], 1 ); /* Q31 */ - move32(); - move32(); - } - /* No SPAR in external renderer so set directive diffuse field coherence tables to zero */ - set_zero_fx( hDiracDecBin->diffuseFieldCoherenceX_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - set_zero_fx( hDiracDecBin->diffuseFieldCoherenceY_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - set_zero_fx( hDiracDecBin->diffuseFieldCoherenceZ_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); + /* No SPAR in external renderer so set directive diffuse field coherence tables to zero */ + set_zero_fx( hDiracDecBin->diffuseFieldCoherenceX_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); + set_zero_fx( hDiracDecBin->diffuseFieldCoherenceY_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); + set_zero_fx( hDiracDecBin->diffuseFieldCoherenceZ_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) /* Indication of binaural rendering without room effect */ - { - set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->q_earlyPartEneCorrection = Q28; - move16(); - hDiracDecBin->hReverb = NULL; - } - ELSE IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ - { - Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); - hDiracDecBin->q_earlyPartEneCorrection = Q28; - move16(); + IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) /* Indication of binaural rendering without room effect */ + { + set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->q_earlyPartEneCorrection = Q28; + move16(); + hDiracDecBin->hReverb = NULL; + } + ELSE IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ + { + Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); + hDiracDecBin->q_earlyPartEneCorrection = Q28; + move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ +#else IF( hDiracDecBin->hReverb == NULL ) +#endif + { + /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ + IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + } + ELSE IF( EQ_16( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + { + set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->q_earlyPartEneCorrection = Q28; + move16(); + hDiracDecBin->hReverb = NULL; + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; + move16(); + } + ELSE /* Not valid renderer type for this renderer */ + { + assert( false ); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) +#endif + /* Always open frequency domain decorrelator */ + ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); + + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis_fx, + BINAURAL_CHANNELS, + output_Fs ) ), + IVAS_ERR_OK ) ) { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT } - } - ELSE IF( EQ_16( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->q_earlyPartEneCorrection = Q28; - move16(); - hDiracDecBin->hReverb = NULL; - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; +#endif + /* External renderer uses constant regularization factor */ + hDiracDecBin->reqularizationFactor_fx = 6554; /* 0.4f in Q14 */ move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + inputMasa->hMasaExtRend->hDiracDecBin[pos_idx] = hDiracDecBin; } - ELSE /* Not valid renderer type for this renderer */ - { - assert( false ); - } - - /* Always open frequency domain decorrelator */ - ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); - - IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis_fx, - BINAURAL_CHANNELS, - output_Fs ) ), - IVAS_ERR_OK ) ) - { - return error; - } - /* External renderer uses constant regularization factor */ - hDiracDecBin->reqularizationFactor_fx = 6554; /* 0.4f in Q14 */ - move16(); - +#else inputMasa->hMasaExtRend->hDiracDecBin = hDiracDecBin; +#endif return error; } @@ -8608,7 +9836,14 @@ static ivas_error initMasaExtRenderer( move32(); hMasaExtRend->hDirACRend = NULL; hMasaExtRend->hSpatParamRendCom = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + hMasaExtRend->hDiracDecBin[i] = NULL; + } +#else hMasaExtRend->hDiracDecBin = NULL; +#endif hMasaExtRend->hReverb = NULL; hMasaExtRend->hHrtfParambin = NULL; hMasaExtRend->hVBAPdata = NULL; @@ -8659,6 +9894,10 @@ static ivas_error initMasaExtRenderer( BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: +#endif hMasaExtRend->renderer_type = RENDERER_BINAURAL_PARAMETRIC; move32(); BREAK; @@ -8776,10 +10015,21 @@ static void freeMasaExtRenderer( ivas_spat_hSpatParamRendCom_close_fx( &hMasaExtRend->hSpatParamRendCom ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + if ( hMasaExtRend->hDiracDecBin[i] != NULL ) + { + ivas_dirac_dec_close_binaural_data( &hMasaExtRend->hDiracDecBin[i] ); + } + } + +#else IF( hMasaExtRend->hDiracDecBin != NULL ) { ivas_dirac_dec_close_binaural_data( &hMasaExtRend->hDiracDecBin ); } +#endif IF( hMasaExtRend->hReverb != NULL ) { -- GitLab From ca4f1e55553b023a9a1d85a4a7ec61b16086ae5d Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 3 Feb 2025 22:49:19 +1100 Subject: [PATCH 024/329] lib rend changes --- lib_com/cnst.h | 1 + lib_com/ivas_rotation_com.c | 13 +- lib_dec/ivas_binRenderer_internal.c | 21 +- lib_dec/ivas_objectRenderer_internal.c | 44 +- lib_rend/ivas_prot_rend.h | 3 +- lib_rend/lib_rend.c | 673 ++++++++++++++----------- 6 files changed, 415 insertions(+), 340 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index e86b51472..35dc4f02a 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -596,6 +596,7 @@ enum #define FRAMES_PER_SEC 50 #define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC 200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) +#define ONE_BY_SUBFRAME_LEN_MS_Q31 (429496730) #define ONE_BY_FRAMES_PER_SEC_Q31 ( 42949673 ) #define FRAMES_PER_SEC_BY_2 (FRAMES_PER_SEC >> 1) #define INV_FRAME_PER_SEC_Q15 656 diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 9e5d1a594..fc390dfb2 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -53,7 +53,7 @@ void Euler2Quat_fx( const Word32 yaw, /* i : yaw (x) Q22 */ const Word32 pitch, /* i : pitch (y) Q22 */ const Word32 roll, /* i : roll (z) Q22 */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation Q19 */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation Q22*/ ) { Word16 cr = getCosWord16( extract_l( L_shr_r( roll, 10 ) ) ); // Q14 @@ -62,15 +62,18 @@ void Euler2Quat_fx( Word16 sp = getSinWord16( extract_l( L_shr_r( pitch, 10 ) ) ); Word16 cy = getCosWord16( extract_l( L_shr_r( yaw, 10 ) ) ); Word16 sy = getSinWord16( extract_l( L_shr_r( yaw, 10 ) ) ); - quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); // Q19 + quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); // Q22 move32(); - quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); // Q19 + quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); // Q22 move32(); - quat->y_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( sr, cp ), sy ), Mpy_32_16_1( L_mult0( cr, sp ), cy ) ), 5 ); // Q19 + quat->y_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( sr, cp ), sy ), Mpy_32_16_1( L_mult0( cr, sp ), cy ) ), 5 ); // Q22 move32(); - quat->z_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( cr, cp ), sy ), Mpy_32_16_1( L_mult0( sr, sp ), cy ) ), 5 ); // Q19 + quat->z_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( cr, cp ), sy ), Mpy_32_16_1( L_mult0( sr, sp ), cy ) ), 5 ); // Q22 move32(); + quat->q_fact = Q22; + move16(); + return; } void Euler2Quat( diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 040d9bf9d..ce4dfa9c9 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -2108,6 +2108,8 @@ void ivas_rend_CldfbMultiBinRendProcess( Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_in_orig = *Q_in; + move16(); FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { @@ -2121,20 +2123,23 @@ void ivas_rend_CldfbMultiBinRendProcess( } } - if ( ( *pCombinedOrientationData ) != NULL ) + IF( ( *pCombinedOrientationData ) != NULL ) { - if ( ( low_res_pre_rend_rot ) && ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) { - ( *pCombinedOrientationData )->Quaternions[sf_idx] = ( *pCombinedOrientationData )->Quaternions[0]; - for ( i = 0; i < 3; i++ ) + Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); + + FOR( i = 0; i < 3; i++ ) { - for ( j = 0; j < 3; j++ ) + FOR( j = 0; j < 3; j++ ) { ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; + move32(); } } } ( *pCombinedOrientationData )->shd_rot_max_order = -1; + move16(); } ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, Q_in ); @@ -2148,12 +2153,12 @@ void ivas_rend_CldfbMultiBinRendProcess( { Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q6, *Q_in ) ); // Q6 - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q6, *Q_in ) ); // Q6 + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in_orig, *Q_in ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in_orig, *Q_in ) ); // Q_in_orig } } } - *Q_in = Q6; + *Q_in = Q_in_orig; } return; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 12ed81e07..4e568b5ab 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -413,31 +413,27 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( /* Update head positions */ IF( NE_16( pos_idx, 0 ) ) { + COMBINED_ORIENTATION_HANDLE pCombinedOrientationData = st_ivas->hCombinedOrientationData; + Word16 q_fact_orig; FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) { - IF( EQ_32( originalHeadRot[i].w_fx, -1610612736 /* -3.0f in Q29 */ ) ) - { - assert( 0 ); - } - else - { - st_ivas->hCombinedOrientationData->Quaternions[i].w = -12582912; // Q22 - move32(); - - Quat2EulerDegree( originalHeadRot[i], /* TODO tmu : fix bug with ordering*/ - &st_ivas->hCombinedOrientationData->Quaternions[i].z_fx, - &st_ivas->hCombinedOrientationData->Quaternions[i].y_fx, - &st_ivas->hCombinedOrientationData->Quaternions[i].x_fx ); - - st_ivas->hCombinedOrientationData->Quaternions[i].x_fx = L_add( st_ivas->hCombinedOrientationData->Quaternions[i].x_fx, pMultiBinPoseData->relative_head_poses[pos_idx][0] ); - st_ivas->hCombinedOrientationData->Quaternions[i].y_fx = L_add( st_ivas->hCombinedOrientationData->Quaternions[i].y_fx, pMultiBinPoseData->relative_head_poses[pos_idx][1] ); - st_ivas->hCombinedOrientationData->Quaternions[i].z_fx = L_add( st_ivas->hCombinedOrientationData->Quaternions[i].z_fx, pMultiBinPoseData->relative_head_poses[pos_idx][2] ); - move32(); - move32(); - move32(); - - Euler2Quat_fx( deg2rad_fx( st_ivas->hCombinedOrientationData->Quaternions[i].x_fx ), deg2rad_fx( st_ivas->hCombinedOrientationData->Quaternions[i].y_fx ), deg2rad_fx( st_ivas->hCombinedOrientationData->Quaternions[i].z_fx ), &st_ivas->hCombinedOrientationData->Quaternions[i] ); - } + pCombinedOrientationData->Quaternions[i].w_fx = L_negate( 12582912 ); // Q22 + q_fact_orig = originalHeadRot[i].q_fact; + modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 ); + /*euler*/ + Quat2EulerDegree_fx( originalHeadRot[i], + &pCombinedOrientationData->Quaternions[i].z_fx, + &pCombinedOrientationData->Quaternions[i].y_fx, + &pCombinedOrientationData->Quaternions[i].x_fx ); + pCombinedOrientationData->Quaternions[i].x_fx = L_add( pCombinedOrientationData->Quaternions[i].x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + pCombinedOrientationData->Quaternions[i].y_fx = L_add( pCombinedOrientationData->Quaternions[i].y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + pCombinedOrientationData->Quaternions[i].z_fx = L_add( pCombinedOrientationData->Quaternions[i].z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + + Euler2Quat_fx( deg2rad_fx( pCombinedOrientationData->Quaternions[i].x_fx ), + deg2rad_fx( pCombinedOrientationData->Quaternions[i].y_fx ), + deg2rad_fx( pCombinedOrientationData->Quaternions[i].z_fx ), &pCombinedOrientationData->Quaternions[i] ); + + modify_Quat_q_fx( &pCombinedOrientationData->Quaternions[i], &pCombinedOrientationData->Quaternions[i], q_fact_orig ); } } @@ -472,7 +468,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( Word32 *p_tc[MAX_TRANSPORT_CHANNELS]; FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { - p_tc[i] = st_ivas->hTcBuffer->tc[i] + st_ivas->hTcBuffer->n_samples_rendered; + p_tc[i] = st_ivas->hTcBuffer->tc_fx[i] + st_ivas->hTcBuffer->n_samples_rendered; } ivas_binaural_add_LFE_fx( st_ivas, nSamplesRendered, p_tc, p_bin_output ); } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 269806ccf..51fca0ec8 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -2048,7 +2048,8 @@ void ivas_rend_CldfbMultiBinRendProcess( Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 low_res_pre_rend_rot, - const Word16 num_subframes + const Word16 num_subframes, + Word16 *Q_in ); ivas_error ivas_rend_openCldfb( diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c5156c2a5..604596496 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -259,7 +259,8 @@ static ivas_error renderSbaToMultiBinauralCldfb( Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 low_res_pre_rend_rot, - const Word16 num_subframes ); + const Word16 num_subframes, + const Word16 Q_in ); static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, @@ -359,6 +360,14 @@ static void convertBitsBufferToInternalBitsBuff( hBits->pose_correction = outBits.config.poseCorrection; hBits->codec_frame_size_ms = outBits.config.codec_frame_size_ms; + move16(); + move32(); + move32(); + move32(); + move32(); + move32(); + move32(); + return; } @@ -377,7 +386,7 @@ static void convertInternalBitsBuffToBitsBuffer( return; } -static void copyBufferToCLDFBarray( +static void copyBufferToCLDFBarray_fx( const IVAS_REND_AudioBuffer buffer, Word32 re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) @@ -409,7 +418,7 @@ static void copyBufferToCLDFBarray( return; } -static void accumulateCLDFBArrayToBuffer( +static void accumulateCLDFBArrayToBuffer_fx( Word32 re[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 im[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], IVAS_REND_AudioBuffer *buffer ) @@ -4502,7 +4511,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( input_base *inputBase; Word16 numInputChannels; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 cldfb2tdSampleFact; + Word16 cldfb2tdShift; #endif /* Validate function arguments */ @@ -4514,10 +4523,10 @@ ivas_error IVAS_REND_FeedInputAudio_fx( test(); #ifdef SPLIT_REND_WITH_HEAD_ROT - cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; + cldfb2tdShift = ( inputAudio.config.is_cldfb ) ? 1 : 0; - if ( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || - ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) + IF( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( shl( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdShift ) ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) #else IF( inputAudio.config.numSamplesPerChannel <= 0 || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, inputAudio.config.numSamplesPerChannel ) ) #endif @@ -4534,10 +4543,10 @@ ivas_error IVAS_REND_FeedInputAudio_fx( test(); move32(); // move added for typecasting #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && - hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && - hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) + IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && + NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && + shr( i_mult( inputAudio.config.numSamplesPerChannel, 1000 ), cldfb2tdShift ) != i_mult( i_mult( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) #else IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( L_mult0( inputAudio.config.numSamplesPerChannel, 1000 ), (Word32) W_mult0_32_32( L_mult0( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) ) @@ -4573,7 +4582,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( MVR2R_WORD32( inputAudio.data_fx, inputBase->inputBuffer.data_fx, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); #ifdef SPLIT_REND_WITH_HEAD_ROT - inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel / cldfb2tdSampleFact; + inputBase->numNewSamplesPerChannel = shr( inputAudio.config.numSamplesPerChannel, cldfb2tdShift ); #else inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel; #endif @@ -4852,27 +4861,27 @@ Word16 IVAS_REND_FeedRenderConfig( #ifdef SPLIT_REND_WITH_HEAD_ROT hRenderConfig->split_rend_config = renderConfig.split_rend_config; /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ - if ( hRenderConfig->split_rend_config.dof == 0 ) + IF( EQ_16( hRenderConfig->split_rend_config.dof, 0 ) ) { hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; } hRenderConfig->split_rend_config.codec = renderConfig.split_rend_config.codec; - if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + IF( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } /* Must re-initialize split rendering config in case renderer config is updated after adding renderer inputs */ /* if its not initialized yet then no need to re-initialize, initialization will happen while adding inputs*/ - if ( hIvasRend->splitRendEncBuffer.data_fx != NULL && hIvasRend->hRendererConfig != NULL ) + IF( hIvasRend->splitRendEncBuffer.data_fx != NULL && hIvasRend->hRendererConfig != NULL ) { int16_t cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); - if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) { return error; } @@ -5725,7 +5734,7 @@ static Word16 getNumSubframesInBuffer( const Word32 sampleRate ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t cldfb2tdShift; + Word16 cldfb2tdShift; cldfb2tdShift = buffer->config.is_cldfb ? 1 : 0; @@ -5914,7 +5923,11 @@ static ivas_error renderIsmToBinauralRoom( } // Crend_process porting CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = ismInput->crendWrapper->hCrend[0]; +#else hCrend = ismInput->crendWrapper->hCrend; +#endif IF( hCrend->reflections != NULL ) { test(); @@ -6236,16 +6249,16 @@ static ivas_error renderIsmToSplitBinaural( const IVAS_REND_AudioBuffer outAudio ) { ivas_error error; - float tmpProcessing[MAX_NUM_OBJECTS][L_FRAME48k]; - int16_t pos_idx; + Word32 tmpProcessing[MAX_NUM_OBJECTS][L_FRAME48k]; + Word16 pos_idx; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; const SPLIT_REND_WRAPPER *pSplitRendWrapper; IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t i; - float tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; - int16_t output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; + Word16 i; + Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + Word16 output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; - int16_t ism_md_subframe_update_ext; + Word16 ism_md_subframe_update_ext; push_wmops( "renderIsmToSplitBinaural" ); @@ -6253,78 +6266,78 @@ static ivas_error renderIsmToSplitBinaural( pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ - ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms_fx / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + ism_md_subframe_update_ext = (Word16) Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ); pCombinedOrientationData = *ismInput->base.ctx.pCombinedOrientationData; - if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + IF( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) { - for ( i = 1; i < pCombinedOrientationData->num_subframes; ++i ) + FOR( i = 1; i < pCombinedOrientationData->num_subframes; ++i ) { - pCombinedOrientationData->Quaternions[i] = pCombinedOrientationData->Quaternions[0]; + Copy_Quat_fx( &pCombinedOrientationData->Quaternions[0], &pCombinedOrientationData->Quaternions[i] ); } } /* Save current head positions */ - for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + FOR( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) { - originalHeadRot[i] = pCombinedOrientationData->Quaternions[i]; + Copy_Quat_fx( &pCombinedOrientationData->Quaternions[i], &originalHeadRot[i] ); } /* Copy input audio to a processing buffer. */ - copyBufferTo2dArray( ismInput->base.inputBuffer, tmpProcessing ); + copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpProcessing ); - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { /* Update head positions */ - if ( pos_idx != 0 ) + IF( NE_16( pos_idx, 0 ) ) { - for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + Word16 q_fact_orig; + FOR( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) { - if ( originalHeadRot[i].w == -3.0f ) - { - pCombinedOrientationData->Quaternions[i].w = -3.0f; - pCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; - pCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; - pCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; - } - else - { - pCombinedOrientationData->Quaternions[i].w = -3.0f; - Quat2EulerDegree( originalHeadRot[i], - &pCombinedOrientationData->Quaternions[i].z, - &pCombinedOrientationData->Quaternions[i].y, - &pCombinedOrientationData->Quaternions[i].x ); - pCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; - pCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; - pCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; - } + pCombinedOrientationData->Quaternions[i].w_fx = L_negate( 12582912 ); // Q22 + q_fact_orig = originalHeadRot[i].q_fact; + modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 ); + /*euler*/ + Quat2EulerDegree_fx( originalHeadRot[i], + &pCombinedOrientationData->Quaternions[i].z_fx, + &pCombinedOrientationData->Quaternions[i].y_fx, + &pCombinedOrientationData->Quaternions[i].x_fx ); + pCombinedOrientationData->Quaternions[i].x_fx = L_add( pCombinedOrientationData->Quaternions[i].x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + pCombinedOrientationData->Quaternions[i].y_fx = L_add( pCombinedOrientationData->Quaternions[i].y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + pCombinedOrientationData->Quaternions[i].z_fx = L_add( pCombinedOrientationData->Quaternions[i].z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + + Euler2Quat_fx( deg2rad_fx( pCombinedOrientationData->Quaternions[i].x_fx ), + deg2rad_fx( pCombinedOrientationData->Quaternions[i].y_fx ), + deg2rad_fx( pCombinedOrientationData->Quaternions[i].z_fx ), &pCombinedOrientationData->Quaternions[i] ); + + modify_Quat_q_fx( &pCombinedOrientationData->Quaternions[i], &pCombinedOrientationData->Quaternions[i], q_fact_orig ); } } /* Render */ - if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, - NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[sub( pos_idx, 1 )], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, + NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) { return error; } /* Copy rendered audio to tmp storage buffer. Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ - mvr2r( tmpProcessing[0], tmpBinaural[2 * pos_idx], output_frame ); - mvr2r( tmpProcessing[1], tmpBinaural[2 * pos_idx + 1], output_frame ); + Copy32( tmpProcessing[0], tmpBinaural[i_mult( 2, pos_idx )], output_frame ); + Copy32( tmpProcessing[1], tmpBinaural[add( i_mult( 2, pos_idx ), 1 )], output_frame ); /* Overwrite processing buffer with original input audio again */ - copyBufferTo2dArray( ismInput->base.inputBuffer, tmpProcessing ); + copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpProcessing ); } /* Restore original head rotation */ - for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + FOR( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) { - pCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + Copy_Quat_fx( &originalHeadRot[i], &pCombinedOrientationData->Quaternions[i] ); } - accumulate2dArrayToBuffer( tmpBinaural, &outAudio ); + accumulate2dArrayToBuffer_fx( tmpBinaural, &outAudio ); pop_wmops(); /* Encoding to split rendering bitstream done at a higher level */ @@ -6517,6 +6530,7 @@ static ivas_error renderActiveInputsIsm( } return IVAS_ERR_OK; } + static ivas_error renderLfeToBinaural_fx( const input_mc *mcInput, #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -6528,7 +6542,7 @@ static ivas_error renderLfeToBinaural_fx( { Word16 lfe_idx; #ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t pose_idx, num_poses; + Word16 pose_idx, num_poses; #endif Word32 gain_fx; Word16 ear_idx, i, r_shift; @@ -6595,20 +6609,22 @@ static ivas_error renderLfeToBinaural_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT /* Copy LFE to left and right binaural channels for all poses */ - if ( mcInput->base.ctx.pSplitRendWrapper != NULL ) + IF( mcInput->base.ctx.pSplitRendWrapper != NULL ) { num_poses = mcInput->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; + Move16(); } - else + ELSE { num_poses = 1; + move16(); } - for ( pose_idx = 0; pose_idx < num_poses; ++pose_idx ) + FOR( pose_idx = 0; pose_idx < num_poses; ++pose_idx ) { - for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) + FOR( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) { - writePtr = getSmplPtr_fx( outAudio, pose_idx * BINAURAL_CHANNELS + ear_idx, 0 ); + writePtr = getSmplPtr_fx( outAudio, add( i_mult( pose_idx, BINAURAL_CHANNELS ), ear_idx ), 0 ); v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */ } } @@ -6718,7 +6734,11 @@ static ivas_error renderMcToBinaural( } // Porting Crend_process function CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = mcInput->crendWrapper->hCrend[0]; +#else hCrend = mcInput->crendWrapper->hCrend; +#endif /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -6741,11 +6761,19 @@ static ivas_error renderMcToBinaural( accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) + + { + return error; + } +#else IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) { return error; } +#endif *outAudio.pq_fact = exp; move16(); pop_wmops(); @@ -6849,7 +6877,11 @@ static ivas_error renderMcToBinauralRoom( } // Porting Crend_process function CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = mcInput->crendWrapper->hCrend[0]; +#else hCrend = mcInput->crendWrapper->hCrend; +#endif /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -6976,7 +7008,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray_fx( tmpMcBuffer, tmpCrendBuffer ); CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = mcInput->crendWrapper->hCrend[0]; +#else hCrend = mcInput->crendWrapper->hCrend; +#endif /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, @@ -7072,45 +7108,61 @@ static ivas_error renderMcToSplitBinaural( const AUDIO_CONFIG outConfig, IVAS_REND_AudioBuffer outAudio ) { - int16_t i, j, pos_idx; - int16_t sf; - int16_t output_frame; + Word16 i, j, pos_idx; + Word16 sf; + Word16 output_frame; ivas_error error; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; const SPLIT_REND_WRAPPER *pSplitRendWrapper; - float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; - float tmpSplitBinauralBuffer[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + Word32 tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + Word32 tmpSplitBinauralBuffer[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; AUDIO_CONFIG inConfig; IVAS_REND_AudioBuffer tmpRotBuffer; COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + Word16 exp = *outAudio.pq_fact; + move16(); + CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = mcInput->crendWrapper->hCrend[0]; +#else + hCrend = mcInput->crendWrapper->hCrend; +#endif push_wmops( "renderMcToSplitBinaural" ); inConfig = mcInput->base.inConfig; + move32(); output_frame = mcInput->base.inputBuffer.config.numSamplesPerChannel; + move16(); pSplitRendWrapper = mcInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; + move32(); + move32(); - for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; + move32(); } /* save current head positions */ pCombinedOrientationDataLocal = *mcInput->base.ctx.pCombinedOrientationData; + move32(); combinedOrientationDataLocal = *pCombinedOrientationDataLocal; - if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + move32(); + IF( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) { - for ( sf = 1; sf < combinedOrientationDataLocal.num_subframes; ++sf ) + FOR( sf = 1; sf < combinedOrientationDataLocal.num_subframes; ++sf ) { - combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; - for ( i = 0; i < 3; i++ ) + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[0], &combinedOrientationDataLocal.Quaternions[sf] ); + FOR( i = 0; i < 3; i++ ) { - for ( j = 0; j < 3; j++ ) + FOR( j = 0; j < 3; j++ ) { - combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + combinedOrientationDataLocal.Rmat_fx[sf][i][j] = combinedOrientationDataLocal.Rmat_fx[0][i][j]; + move32(); } } } @@ -7118,29 +7170,44 @@ static ivas_error renderMcToSplitBinaural( /* temporary buffer for rotation in source format for CREND */ tmpRotBuffer = mcInput->base.inputBuffer; - if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_AUDIO_CONFIG_5_1 && inConfig != IVAS_AUDIO_CONFIG_7_1 ) + move32(); + IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_7_1 ) ) { - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); } - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { /* Update head positions */ IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; - for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + Word16 q_fact_orig; + FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) { - Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; - Quaternions_abs.w = -3.0f; - Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[i], &Quaternions_orig[i] ); - Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; - Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; - Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; - combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; - QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + q_fact_orig = combinedOrientationDataLocal.Quaternions[i].q_fact; + modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Q22 ); + /*euler*/ + Quat2EulerDegree_fx( combinedOrientationDataLocal.Quaternions[i], + &Quaternions_abs.z_fx, + &Quaternions_abs.y_fx, + &Quaternions_abs.x_fx ); + Quaternions_abs.x_fx = L_add( Quaternions_abs.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_abs.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), + deg2rad_fx( Quaternions_abs.y_fx ), + deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); + + Copy_Quat_fx( &Quaternions_abs, &combinedOrientationDataLocal.Quaternions[i] ); + QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); } - if ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM || inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1 ) + IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_7_1 ) ) { /* tdrend processing overview: * 1. copy from inputBuffer to tmpRendBuffer @@ -7150,23 +7217,23 @@ static ivas_error renderMcToSplitBinaural( * 5. tmpSplitBinBuffer accumulated to outBuffer */ /* copy input to tdrend input/output buffer */ - copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); + copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer ); /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; /* Render */ - if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } /* Copy rendered audio to tmp storage buffer. Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ - mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); - mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); + Copy32( tmpRendBuffer[0], tmpSplitBinauralBuffer[i_mult( 2, pos_idx )], output_frame ); + Copy32( tmpRendBuffer[1], tmpSplitBinauralBuffer[add( i_mult( 2, pos_idx ), 1 )], output_frame ); } - else + ELSE { /* crend processing overview: * 1. rotateFrameMc: inputBuffer to tmpRotBuffer @@ -7177,49 +7244,60 @@ static ivas_error renderMcToSplitBinaural( /* copy input for in-place rotation */ - set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); + set32_fx( tmpRotBuffer.data_fx, 0, i_mult( tmpRotBuffer.config.numSamplesPerChannel, tmpRotBuffer.config.numChannels ) ); /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, mcInput->rot_gains_prev[pos_idx], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, mcInput->rot_gains_prev_fx[pos_idx], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } + IF( EQ_16( pos_idx, 0 ) ) + { + exp = sub( *outAudio.pq_fact, 1 ); + } - copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); + copyBufferTo2dArray_fx( tmpRotBuffer, tmpRendBuffer ); /* call CREND (rotation already performed) */ - if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, - NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, pos_idx ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, + p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &tmpRotBuffer, *mcInput->base.ctx.pOutSampleRate ), pos_idx ) ), + IVAS_ERR_OK ) ) + + IF( EQ_16( pos_idx, 0 ) ) { - return error; + IF( hCrend->hReverb != NULL ) + { + exp = sub( exp, 2 ); + } } /* Copy rendererd audio to tmp storage buffer, Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ - mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); - mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); + Copy32( tmpRendBuffer[0], tmpSplitBinauralBuffer[i_mult( 2, pos_idx )], output_frame ); + Copy32( tmpRendBuffer[1], tmpSplitBinauralBuffer[add( i_mult( 2, pos_idx ), 1 )], output_frame ); } /* restore original headrotation data */ - for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) { - combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + Copy_Quat_fx( &Quaternions_orig[i], &combinedOrientationDataLocal.Quaternions[i] ); } } - if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_AUDIO_CONFIG_5_1 && inConfig != IVAS_AUDIO_CONFIG_7_1 ) + IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_7_1 ) ) { /* free temporary buffer for rotation in source format for CREND */ - free( tmpRotBuffer.data ); + free( tmpRotBuffer.data_fx ); } - accumulate2dArrayToBuffer( tmpSplitBinauralBuffer, &outAudio ); + accumulate2dArrayToBuffer_fx( tmpSplitBinauralBuffer, &outAudio ); - if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) + IF( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ) != IVAS_ERR_OK ) { return error; } + *outAudio.pq_fact = exp; pop_wmops(); return IVAS_ERR_OK; @@ -7364,97 +7442,113 @@ static void renderSbaToSba( static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, - float out[][L_FRAME48k] ) + Word32 out[][L_FRAME48k] ) { - float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; - int16_t sf; - int16_t i, j, pos_idx; + Word32 tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; + Word16 sf; + Word16 i, j, pos_idx; COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpCrendBuffer[i] = tmpCrendBuffer[i]; + move32(); } push_wmops( "renderSbaToMultiBinaural" ); pMultiBinPoseData = &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData; + move32(); pCombinedOrientationDataLocal = *sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationDataLocal = *pCombinedOrientationDataLocal; - if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + move32(); + move32(); + + IF( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) { - for ( sf = 1; sf < combinedOrientationDataLocal.num_subframes; sf++ ) + FOR( sf = 1; sf < combinedOrientationDataLocal.num_subframes; ++sf ) { - combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; - for ( i = 0; i < 3; i++ ) + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[0], &combinedOrientationDataLocal.Quaternions[sf] ); + FOR( i = 0; i < 3; i++ ) { - for ( j = 0; j < 3; j++ ) + FOR( j = 0; j < 3; j++ ) { - combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + combinedOrientationDataLocal.Rmat_fx[sf][i][j] = combinedOrientationDataLocal.Rmat_fx[0][i][j]; + move32(); } } } } tmpRotBuffer = sbaInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; - for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + Word16 q_fact_orig; + FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) { - Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; - Quaternions_abs.w = -3.0f; - Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[i], &Quaternions_orig[i] ); - Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; - Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; - Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; - combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; - QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); - } + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + q_fact_orig = combinedOrientationDataLocal.Quaternions[i].q_fact; + modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Q22 ); + /*euler*/ + Quat2EulerDegree_fx( combinedOrientationDataLocal.Quaternions[i], + &Quaternions_abs.z_fx, + &Quaternions_abs.y_fx, + &Quaternions_abs.x_fx ); + Quaternions_abs.x_fx = L_add( Quaternions_abs.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_abs.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), + deg2rad_fx( Quaternions_abs.y_fx ), + deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); + + Copy_Quat_fx( &Quaternions_abs, &combinedOrientationDataLocal.Quaternions[i] ); + QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + } /* copy input for in-place rotation */ - mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); + Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, sbaInput->rot_gains_prev[pos_idx], tmpRotBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, sbaInput->rot_gains_prev_fx[pos_idx], tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } - copyBufferTo2dArray( tmpRotBuffer, tmpCrendBuffer ); + copyBufferTo2dArray_fx( tmpRotBuffer, tmpCrendBuffer ); assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); /* call CREND */ - if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, - NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, pos_idx ) ) != IVAS_ERR_OK ) - { - return error; - } + IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &tmpRotBuffer, *sbaInput->base.ctx.pOutSampleRate ), pos_idx ) ), + IVAS_ERR_OK ) ) - for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) { - combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + Copy_Quat_fx( &Quaternions_orig[i], &combinedOrientationDataLocal.Quaternions[i] ); } - /* move to output */ - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - mvr2r( tmpCrendBuffer[i], out[pos_idx * BINAURAL_CHANNELS + i], tmpRotBuffer.config.numSamplesPerChannel ); + Copy32( tmpCrendBuffer[i], out[pos_idx * BINAURAL_CHANNELS + i], tmpRotBuffer.config.numSamplesPerChannel ); } } - free( tmpRotBuffer.data ); + free( tmpRotBuffer.data_fx ); pop_wmops(); return IVAS_ERR_OK; @@ -7463,18 +7557,19 @@ static ivas_error renderSbaToMultiBinaural( static ivas_error renderSbaToMultiBinauralCldfb( input_sba *sbaInput, - float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const int16_t low_res_pre_rend_rot, - const int16_t num_subframes ) + Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes, + const Word16 Q_in ) { - float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - copyBufferToCLDFBarray( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + copyBufferToCLDFBarray_fx( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); ivas_rend_CldfbMultiBinRendProcess( sbaInput->cldfbRendWrapper.hCldfbRend, sbaInput->base.ctx.pCombinedOrientationData, &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, - Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes ); + Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes, &Q_in ); return IVAS_ERR_OK; } @@ -7485,26 +7580,27 @@ static ivas_error renderSbaToSplitBinaural( const AUDIO_CONFIG outConfig, IVAS_REND_AudioBuffer outAudio ) { - float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; ivas_error error; - float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - int16_t low_res_pre_rend_rot; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 low_res_pre_rend_rot; low_res_pre_rend_rot = 1; push_wmops( "renderSbaToSplitBinaural" ); error = IVAS_ERR_OK; + move32(); - if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) { if ( ( renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), *outAudio.pq_fact ) ) != IVAS_ERR_OK ) { return error; } - accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else { @@ -7512,8 +7608,13 @@ static ivas_error renderSbaToSplitBinaural( { return error; } + IF( sbaInput->crendWrapper->hCrend[0]->hReverb != NULL ) + { + *outAudio.pq_fact = sub( *outAudio.pq_fact, Q2 ); + move16(); + } - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); + accumulate2dArrayToBuffer_fx( tmpCrendBuffer, &outAudio ); } pop_wmops(); @@ -7538,26 +7639,27 @@ static ivas_error renderSbaToBinaural( push_wmops( "renderSbaToBinaural" ); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) { - float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + IF( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), *outAudio.pq_fact ) ) != IVAS_ERR_OK ) { return error; } - accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } - else + ELSE #endif { FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { output_fx[i] = output_buffer_fx[i]; + move32(); } hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; @@ -7611,7 +7713,11 @@ static ivas_error renderSbaToBinaural( } // Porting Crend_process function CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = sbaInput->crendWrapper->hCrend[0]; +#else hCrend = sbaInput->crendWrapper->hCrend; +#endif /* call CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -7658,8 +7764,11 @@ static ivas_error renderSbaToBinauralRoom( push_wmops( "renderSbaToBinauralRoom" ); Word16 nchan_out; CREND_HANDLE hCrend; - +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = sbaInput->crendWrapper->hCrend[0]; +#else hCrend = sbaInput->crendWrapper->hCrend; +#endif IF( NE_32( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ), IVAS_ERR_OK ) ) { @@ -7792,16 +7901,16 @@ static ivas_error renderInputSba( ivas_error error; IVAS_REND_AudioBuffer inAudio; #ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t cldfb2tdSampleFact; + int16_t cldfb2tdShift; #endif error = IVAS_ERR_OK; move32(); inAudio = sbaInput->base.inputBuffer; #ifdef SPLIT_REND_WITH_HEAD_ROT - cldfb2tdSampleFact = outAudio.config.is_cldfb ? 2 : 1; - if ( ( sbaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && - ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; + IF( NE_16( shl( sbaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) && + NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else IF( NE_32( sbaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) #endif @@ -8167,9 +8276,9 @@ static ivas_error renderInputMasa( Word32 *tmpBuffer_fx[MAX_OUTPUT_CHANNELS]; Word32 tmpBuffer_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; #ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t cldfb2tdSampleFact; - float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t cldfb2tdShift; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; #endif IF( !masaInput->metadataHasBeenFed ) @@ -8180,9 +8289,9 @@ static ivas_error renderInputMasa( inAudio = masaInput->base.inputBuffer; #ifdef SPLIT_REND_WITH_HEAD_ROT - cldfb2tdSampleFact = outAudio.config.is_cldfb ? 2 : 1; - if ( ( masaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && - ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; + IF( ( NE_16( shl( masaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) ) && + NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else IF( NE_32( masaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) #endif @@ -8223,31 +8332,41 @@ static ivas_error renderInputMasa( num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { /* split rendering. use the combined of the first subframe in all subframes */ - int16_t sf, i, j; + Word16 sf, i, j; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; pCombinedOrientationData = *masaInput->base.ctx.pCombinedOrientationData; - for ( sf = 1; sf < pCombinedOrientationData->num_subframes; sf++ ) + FOR( sf = 1; sf < pCombinedOrientationData->num_subframes; sf++ ) { - pCombinedOrientationData->Quaternions[sf] = pCombinedOrientationData->Quaternions[0]; - for ( i = 0; i < 3; i++ ) + Copy_Quat_fx( &pCombinedOrientationData->Quaternions[0], &pCombinedOrientationData->Quaternions[sf] ); + FOR( i = 0; i < 3; i++ ) { - for ( j = 0; j < 3; j++ ) + FOR( j = 0; j < 3; j++ ) { - pCombinedOrientationData->Rmat[sf][i][j] = pCombinedOrientationData->Rmat[0][i][j]; + pCombinedOrientationData->Rmat_fx[sf][i][j] = pCombinedOrientationData->Rmat_fx[0][i][j]; + move32(); } } } - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ + + // scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); + - ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); + ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); - accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + + + *outAudio.pq_fact = Q6; + move16(); } - else + ELSE { /* non-split path */ #endif @@ -8307,11 +8426,10 @@ static ivas_error renderInputMasa( default: return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); } + accumulate2dArrayToBuffer_fx( tmpBuffer_buff_fx, &outAudio ); #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif - - accumulate2dArrayToBuffer_fx( tmpBuffer_buff_fx, &outAudio ); } return IVAS_ERR_OK; @@ -8553,7 +8671,7 @@ static ivas_error getSamplesInternal( ivas_error error; Word16 numOutChannels; #ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t cldfb2tdSampleFact; + int16_t cldfb2tdSampleShift; IVAS_REND_AudioBuffer outAudioOrig; #endif /* Validate function arguments */ @@ -8565,10 +8683,10 @@ static ivas_error getSamplesInternal( test(); #ifdef SPLIT_REND_WITH_HEAD_ROT - cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; + cldfb2tdSampleShift = ( outAudio.config.is_cldfb ) ? 1 : 0; - if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || - ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) + IF( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( shl( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdSampleShift ) ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) #else IF( outAudio.config.numSamplesPerChannel <= 0 || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, outAudio.config.numSamplesPerChannel ) ) #endif @@ -8577,17 +8695,18 @@ static ivas_error getSamplesInternal( } test(); - IF( outAudio.config.numChannels <= 0 || LT_16( MAX_OUTPUT_CHANNELS, outAudio.config.numChannels ) ) + IF( LE_16( outAudio.config.numChannels, 0 ) || LT_16( MAX_OUTPUT_CHANNELS, outAudio.config.numChannels ) ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } test(); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && - hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && - hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - ( outAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) + IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && + NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && + NE_32( L_shr( L_mult0( outAudio.config.numSamplesPerChannel, 1000 ), cldfb2tdSampleShift ), + imult3216( hIvasRend->sampleRateOut, i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ) ) #else IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( L_mult0( outAudio.config.numSamplesPerChannel, 1000 ), imult3216( hIvasRend->sampleRateOut, i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ) ) @@ -8671,7 +8790,7 @@ static ivas_error getSamplesInternal( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( numOutChannels != outAudio.config.numChannels && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( NE_16( numOutChannels, outAudio.config.numChannels ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else IF( NE_16( numOutChannels, outAudio.config.numChannels ) ) #endif @@ -8685,26 +8804,20 @@ static ivas_error getSamplesInternal( #ifdef SPLIT_REND_WITH_HEAD_ROT outAudioOrig = outAudio; /* Use internal buffer if outputting split rendering bitstream */ - if ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - int16_t num_poses_orig; + Word16 num_poses_orig; num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; + move16(); outAudio = hIvasRend->splitRendEncBuffer; - Word16 i, q_factor = Q22; ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); - FOR( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) - { - hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses[i][0] = fixedToFloat( hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses_fx[i][0], q_factor ); - hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses[i][1] = fixedToFloat( hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses_fx[i][1], q_factor ); - hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses[i][2] = fixedToFloat( hIvasRend->splitRendWrapper.multiBinPoseData.relative_head_poses_fx[i][2], q_factor ); - } assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" ); /* Clear output buffer for split rendering bitstream */ - set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); + set32_fx( outAudio.data_fx, 0, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); } #endif @@ -8735,76 +8848,73 @@ static ivas_error getSamplesInternal( #endif #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { ISAR_SPLIT_REND_BITS_DATA bits; - int16_t cldfb_in_flag; - float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - for ( int i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + Word16 cldfb_in_flag, i, j, k, ch, ro_md_flag; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) { - for ( int j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { - for ( int k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { Cldfb_RealBuffer_Binaural[i][j][k] = 0; Cldfb_ImagBuffer_Binaural[i][j][k] = 0; + move32(); + move32(); } } } - int16_t ch; - int16_t i, ro_md_flag; - float *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { tmpBinaural[ch] = tmpBinaural_buff[ch]; + move32(); } - if ( outAudio.config.is_cldfb == 1 ) + IF( EQ_16( outAudio.config.is_cldfb, 1 ) ) { cldfb_in_flag = 1; - copyBufferToCLDFBarray( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); + move16(); + copyBufferToCLDFBarray_fx( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); } - else + ELSE { cldfb_in_flag = 0; - copyBufferTo2dArray( outAudio, tmpBinaural_buff ); + move16(); + copyBufferTo2dArray_fx( outAudio, tmpBinaural_buff ); } /* Encode split rendering bitstream */ convertBitsBufferToInternalBitsBuff( *hBits, &bits ); ro_md_flag = 0; - for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) + move16(); + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { - if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + IF( NE_32( hIvasRend->inputsIsm[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { ro_md_flag = 1; + move16(); break; } } - Word16 j; - Word16 q, q1 = 31, q2 = 31, Q_buff; - Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; - Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; - Word32 *pOutput_fx[CLDFB_NO_COL_MAX]; - Word32 output_fx[CLDFB_NO_COL_MAX][L_FRAME48k]; + + Word16 q1 = 31, q2 = 31, Q_buff; Word16 Q_out[CLDFB_NO_COL_MAX]; Q_out[0] = 31; - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - pOutput_fx[i] = &( output_fx[i][0] ); - } Word16 num_poses = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; + for ( i = 0; i < 16; i++ ) { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { - q = Q_factor_arrL( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ); - q1 = s_min( q1, q ); - q = Q_factor_arrL( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ); - q2 = s_min( q2, q ); + q1 = s_min( q1, L_norm_arr( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + q2 = s_min( q2, L_norm_arr( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); } } Q_buff = s_min( q1, q2 ); @@ -8812,96 +8922,55 @@ static ivas_error getSamplesInternal( { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { - floatToFixed_arrL( Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural_fx[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); - floatToFixed_arrL( Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural_fx[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + scale_sig32( Cldfb_RealBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); } } + Q_buff = Q_buff + Q6; + IF( EQ_16( cldfb_in_flag, 0 ) ) { /*TD input*/ - /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - /* local float2fix, to be removed */ num_poses = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; - if ( hIvasRend->splitRendWrapper.hLc3plusEnc != NULL ) - { - Word16 frame_size_lc3 = (Word16) ( ( hIvasRend->splitRendWrapper.hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ) + hIvasRend->splitRendWrapper.lc3plusDelaySamples ); - FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) - { - Q_out[0] = s_min( Q_out[0], Q_factor_arrL( hIvasRend->splitRendWrapper.lc3plusDelayBuffers[i], frame_size_lc3 ) ); - } - } FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { - Q_out[0] = s_min( Q_out[0], Q_factor_arrL( tmpBinaural[i], L_FRAME48k ) ); + Q_out[0] = s_min( Q_out[0], L_norm_arr( tmpBinaural_buff[i], L_FRAME48k ) ); } - // printf("%d\n", Q_sig); - if ( hIvasRend->splitRendWrapper.hLc3plusEnc != NULL ) - { - Word16 frame_size_lc3 = (Word16) ( ( hIvasRend->splitRendWrapper.hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ) + hIvasRend->splitRendWrapper.lc3plusDelaySamples ); - FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) - { - floatToFixed_arrL( hIvasRend->splitRendWrapper.lc3plusDelayBuffers[i], hIvasRend->splitRendWrapper.lc3plusDelayBuffers_fx[i], Q_out[0], frame_size_lc3 ); - } - } FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { - floatToFixed_arrL( tmpBinaural[i], pOutput_fx[i], Q_out[0], L_FRAME48k ); + scale_sig32( tmpBinaural_buff[i], Q_out[0], L_FRAME48k ); } + + Q_out[0] = Q_out[0] + *outAudio.pq_fact; } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, #endif hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, pOutput_fx, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } - IF( EQ_16( cldfb_in_flag, 0 ) ) - { - if ( hIvasRend->splitRendWrapper.hLc3plusEnc != NULL ) - { - Word16 frame_size_lc3 = (Word16) ( ( hIvasRend->splitRendWrapper.hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ) + hIvasRend->splitRendWrapper.lc3plusDelaySamples ); - -#ifdef DUMP_LC3_DELAY_OUT - FILE *fp = fopen( "ref_lc3delay.txt", "ab" ); -#endif - FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) - { - fixedToFloat_arrL( hIvasRend->splitRendWrapper.lc3plusDelayBuffers_fx[i], hIvasRend->splitRendWrapper.lc3plusDelayBuffers[i], Q_out[0], frame_size_lc3 ); -#ifdef DUMP_LC3_DELAY_OUT - for ( Word16 j = 0; j < frame_size_lc3; j++ ) - { - fprintf( fp, "%f\n", hSplitBin->lc3plusDelayBuffers[i][j] ); - } -#endif - } -#ifdef DUMP_LC3_DELAY_OUT - fclose( fp ); -#endif - } - } Word16 pcm_out_flag = ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - IF( NE_16( pcm_out_flag, 0 ) && ( NE_16( cldfb_in_flag, 0 ) ) ) + IF( NE_16( pcm_out_flag, 0 ) ) { - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { - fixedToFloat_arrL( pOutput_fx[ch], tmpBinaural[ch], Q_out[ch], hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX ); - - fixedToFloat_arrL( hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->cldfb_state, hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->Q_split, hIvasRend->splitRendWrapper.hCldfbHandles->cldfbSyn[ch]->p_filter_length ); + scale_sig32( tmpBinaural_buff[j], L_FRAME48k, sub( *outAudio.pq_fact, Q_out[j] ) ); // *outAudio.pq_fact } } - convertInternalBitsBuffToBitsBuffer( hBits, bits ); /* reset to outAudioOrig in case of PCM output */ outAudio = outAudioOrig; - if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( NE_16( pcm_out_flag, 0 ) ) { accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); } -- GitLab From 86f8098b35ca91141446616aff0d1226a2be7ce5 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 4 Feb 2025 12:20:46 +1100 Subject: [PATCH 025/329] q factor fixes in renderer --- apps/isar_post_rend.c | 12 +- apps/renderer.c | 391 ++++++++++++++--------------- lib_isar/isar_splitRend_lcld_dec.c | 1 + lib_isar/isar_splitRendererPLC.c | 5 +- lib_isar/isar_splitRendererPost.c | 2 +- lib_isar/isar_splitRendererPre.c | 19 +- lib_isar/lib_isar_pre_rend.c | 10 +- lib_rend/lib_rend.c | 33 ++- lib_rend/lib_rend.h | 26 +- 9 files changed, 237 insertions(+), 262 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 9a8d7c3ba..c28a5b811 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -952,12 +952,12 @@ int main( inBuffer.config.is_cldfb = 0; inBuffer.config.numChannels = (int16_t) totalNumInChannels; inBuffer.data_fx = inFloatBuffer_fx; - inBuffer.q_data_fx = malloc( sizeof( Word16 ) ); + inBuffer.pq_fact = malloc( sizeof( Word16 ) ); outBuffer.config.is_cldfb = 0; outBuffer.config.numChannels = (int16_t) numOutChannels; outBuffer.data_fx = outFloatBuffer_fx; - outBuffer.q_data_fx = malloc( sizeof( Word16 ) ); + outBuffer.pq_fact = malloc( sizeof( Word16 ) ); memset( outBuffer.data_fx, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( Word32 ) ); @@ -1035,7 +1035,7 @@ int main( /* Convert from int to float and from interleaved to packed */ convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer_fx ); - *inBuffer.q_data_fx = 0; + *inBuffer.pq_fact = 0; int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; @@ -1121,7 +1121,7 @@ int main( /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ - convertOutputBuffer( outFloatBuffer_fx, *outBuffer.q_data_fx, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); + convertOutputBuffer( outFloatBuffer_fx, *outBuffer.pq_fact, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); if ( delayNumSamples == -1 ) { @@ -1225,10 +1225,10 @@ int main( /* === Close === */ free( inpInt16Buffer ); free( inFloatBuffer_fx ); - free( inBuffer.q_data_fx ); + free( inBuffer.pq_fact ); free( outInt16Buffer ); free( outFloatBuffer_fx ); - free( outBuffer.q_data_fx ); + free( outBuffer.pq_fact ); if ( bitsBufferData != NULL ) { diff --git a/apps/renderer.c b/apps/renderer.c index 9b64aff93..1979a7f1f 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -439,8 +439,36 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); -static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, Word16 *intBuffer, Word16 q_factor, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); -static void convertInputBuffer_fx( const Word16 *intBuffer, const Word16 numIntSamplesPerChannel, const Word16 numFloatSamplesPerChannel, const Word16 numChannels, Word32 *Int32Buffer, Word16 in_q_factor, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); +static void convertOutputBuffer_fx( + const Word32 *Word32Buffer, + const Word16 numSamplesPerChannel, + const Word16 numChannels, +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word16 *intBuffer, + const Word16 cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn, + Word16 out_q +#else + Word16 *intBuffer, + Word16 out_q +#endif +); +static void convertInputBuffer_fx( + const Word16 *intBuffer, + const Word16 numIntSamplesPerChannel, + const Word16 numFloatSamplesPerChannel, + const Word16 numChannels, +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 *Word32Buffer, + Word16 in_q_factor, + const int16_t cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna, + Word16 *out_q_factor +#else + Word32 *Word32Buffer, + Word16 in_q_factor +#endif +); #else static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer ); @@ -1413,11 +1441,11 @@ int main( } #endif - if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); - exit( -1 ); - } + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); + exit( -1 ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -1430,28 +1458,41 @@ int main( if ( cldfb_in_flag == 0 ) { inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); - inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); + outInt32Buffer = malloc( outBufferSize * sizeof( Word32 ) ); + inInt32Buffer = malloc( inBufferSize * sizeof( Word32 ) ); outFloatBuffer = malloc( outBufferSize * sizeof( float ) ); + + inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + inBuffer.config.numChannels = (int16_t) totalNumInChannels; + outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + outBuffer.config.numChannels = (int16_t) numOutChannels; + outBuffer.data_fx = outInt32Buffer; + inBuffer.data_fx = inInt32Buffer; } else { inFloatBuffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( float ) ); - inBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); + outInt32Buffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( Word32 ) ); + inInt32Buffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( Word32 ) ); outFloatBuffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( float ) ); + + inBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + inBuffer.config.numChannels = (int16_t) totalNumInChannels; + outBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + outBuffer.config.numChannels = (int16_t) numOutChannels; + outBuffer.data_fx = outInt32Buffer; + inBuffer.data_fx = inInt32Buffer; } - outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); inBuffer.config.is_cldfb = cldfb_in_flag; - inBuffer.config.numChannels = (int16_t) totalNumInChannels; - inBuffer.data = inFloatBuffer; - outBuffer.config.is_cldfb = cldfb_in_flag; - outBuffer.config.numChannels = (int16_t) numOutChannels; - outBuffer.data = outFloatBuffer; - memset( outBuffer.data, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( float ) ); + + memset( outBuffer.data_fx, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( Word32 ) ); if ( is_split_pre_rend_mode( &args ) ) { @@ -1533,12 +1574,15 @@ int main( /* Convert from int to float and from interleaved to packed */ #ifdef SPLIT_REND_WITH_HEAD_ROT - convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); + Word16 Q_out; + *outBuffer.pq_fact = 16 - ( gd_bits ); + convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, inBuffer.config.is_cldfb, cldfbAna, *outBuffer.pq_fact, &Q_out ); + *outBuffer.pq_fact = Q_out; #else - convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer ); -#endif *outBuffer.pq_fact = 16 - ( gd_bits ); convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact ); +#endif + int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; @@ -1764,15 +1808,15 @@ int main( else { #endif - if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) - { + if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); #else fprintf( stderr, "Error in getting samples\n" ); #endif - exit( -1 ); - } + exit( -1 ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -1782,18 +1826,12 @@ int main( /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ - if ( *outBuffer.pq_fact == 0 ) - { - #ifdef SPLIT_REND_WITH_HEAD_ROT - convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + convertOutputBuffer_fx( outInt32Buffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn, *outBuffer.pq_fact ); #else - convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); + convertOutputBuffer_fx( outInt32Buffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, *outBuffer.pq_fact ); #endif - } - else - { - convertOutputBuffer_fx( outInt32Buffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, *outBuffer.pq_fact ); - } + if ( delayNumSamples == -1 ) { if ( args.delayCompensationEnabled ) @@ -1828,19 +1866,19 @@ int main( if ( audioWriter != NULL ) { #endif - if ( delayNumSamples * num_out_channels < outBufferSize ) - { - if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) + if ( delayNumSamples * num_out_channels < outBufferSize ) { - fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); - exit( -1 ); + if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); + exit( -1 ); + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); } - delayNumSamples = 0; - } - else - { - delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); - } #ifdef SPLIT_REND_WITH_HEAD_ROT } @@ -1957,23 +1995,23 @@ int main( if ( audioWriter != NULL ) { #endif - for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) - { - memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) + for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) + { + memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + exit( -1 ); + } + } + + memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); exit( -1 ); } - } - - memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nOutput audio file writer error\n" ); - exit( -1 ); - } - zeroPadToWrite = 0; + zeroPadToWrite = 0; #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -3760,82 +3798,86 @@ static ivas_error parseLfePanMtxFile( * accepted by the renderer (float, packed) *--------------------------------------------------------------------------*/ -static void convertInputBuffer( - const int16_t *intBuffer, - const int16_t numIntSamplesPerChannel, - const int16_t numFloatSamplesPerChannel, - const int16_t numChannels, +static void convertInputBuffer_fx( + const Word16 *intBuffer, + const Word16 numIntSamplesPerChannel, + const Word16 numFloatSamplesPerChannel, + const Word16 numChannels, #ifdef SPLIT_REND_WITH_HEAD_ROT - float *floatBuffer, + Word32 *Word32Buffer, + Word16 in_q_factor, const int16_t cldfb_in_flag, - IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna, + Word16 *out_q_factor #else - float *floatBuffer + Word32 *Word32Buffer, + Word16 in_q_factor #endif ) { - int16_t chnl, smpl, i; + Word16 chnl, smpl, i; i = 0; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in_flag ) + IF( cldfb_in_flag ) { - int16_t slotIdx, numCldfbBands, numFloatPcmSamples; - float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + Word16 slotIdx, numCldfbBands, numFloatPcmSamples; + Word32 fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; numFloatPcmSamples = numFloatSamplesPerChannel >> 1; numCldfbBands = numFloatPcmSamples / IVAS_CLDFB_NO_COL_MAX; /* CLDFB Analysis*/ assert( numIntSamplesPerChannel <= IVAS_MAX_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE ); - for ( smpl = 0; smpl < numFloatPcmSamples; ++smpl ) - { - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( smpl = 0; smpl < numFloatPcmSamples; ++smpl ) { - if ( i < numIntSamplesPerChannel ) - { - fIn[chnl][smpl] = (float) intBuffer[i]; - } - else + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - fIn[chnl][smpl] = 0.f; - } + IF( i < numIntSamplesPerChannel ) + { + fIn[chnl][smpl] = L_shl( (Word32) intBuffer[i], Q11 ); + } + ELSE + { + fIn[chnl][smpl] = 0; + } - ++i; + ++i; + } } - } - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) + FOR( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx], - &floatBuffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], - &floatBuffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], - numCldfbBands, cldfbAna[chnl] ); + &Word32Buffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + &Word32Buffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + numCldfbBands, cldfbAna[chnl], in_q_factor, *out_q_factor ); } } } - else + ELSE { #endif - for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) + FOR( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) { - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - if ( i < numIntSamplesPerChannel ) + IF( i < numIntSamplesPerChannel ) { - floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; + Word32Buffer[chnl * numFloatSamplesPerChannel + smpl] = L_shl( (Word32) intBuffer[i], in_q_factor ); } - else + ELSE { - floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; + Word32Buffer[chnl * numFloatSamplesPerChannel + smpl] = 0; } ++i; } } + *out_q_factor = in_q_factor; #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -3843,174 +3885,105 @@ static void convertInputBuffer( return; } -/*--------------------------------------------------------------------------* - * convertInputBuffer() - * - * Convert input buffer from WAV/PCM file (int16_t, interleaved) to a format - * accepted by the renderer (float, packed) - *--------------------------------------------------------------------------*/ - -static void convertInputBuffer_fx( - const Word16 *intBuffer, - const Word16 numIntSamplesPerChannel, - const Word16 numFloatSamplesPerChannel, - const Word16 numChannels, - Word32 *Word32Buffer, - Word16 in_q_factor ) -{ - Word16 chnl, smpl, i; - - i = 0; - - FOR( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) - { - FOR( chnl = 0; chnl < numChannels; ++chnl ) - { - IF( i < numIntSamplesPerChannel ) - { - Word32Buffer[chnl * numFloatSamplesPerChannel + smpl] = L_shl( (Word32) intBuffer[i], in_q_factor ); - } - ELSE - { - Word32Buffer[chnl * numFloatSamplesPerChannel + smpl] = 0; - } - - ++i; - } - } - return; -} /*--------------------------------------------------------------------------* - * convertOutputBuffer() + * convertOutputBuffer_fx() * - * Convert output buffer from the renderer (Word32, packed) to a format ready - * for writing to a WAV/PCM file (Word16, interleaved) + * Convert output buffer from the renderer (float, packed) to a format ready + * for writing to a WAV/PCM file (int16_t, interleaved) *--------------------------------------------------------------------------*/ + static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, - Word16 *intBuffer, - Word16 out_q ) -{ - Word16 chnl, smpl, i; - Word32 temp_fx; - Word32 temp_fx1; - i = 0; - - FOR( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) - { - FOR( chnl = 0; chnl < numChannels; ++chnl ) - { - temp_fx = L_add( Word32Buffer[chnl * numSamplesPerChannel + smpl], lshl( 1, ( out_q - 1 ) ) ); - temp_fx1 = L_shr( temp_fx, out_q ); - IF( GT_32( temp_fx1, IVAS_MAX16B_FX ) ) - { - temp_fx1 = IVAS_MAX16B_FX; - } - ELSE IF( LT_32( temp_fx1, IVAS_MIN16B_FX ) ) - { - temp_fx1 = IVAS_MIN16B_FX; - } - intBuffer[i] = (Word16) temp_fx1; - - ++i; - } - } - - return; -} -/*--------------------------------------------------------------------------* - * convertOutputBuffer() - * - * Convert output buffer from the renderer (float, packed) to a format ready - * for writing to a WAV/PCM file (int16_t, interleaved) - *--------------------------------------------------------------------------*/ - -static void convertOutputBuffer( - const float *floatBuffer, - const int16_t numSamplesPerChannel, - const int16_t numChannels, #ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t *intBuffer, - const int16_t cldfb_in_flag, - IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn + Word16 *intBuffer, + const Word16 cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn, + Word16 out_q #else - int16_t *intBuffer + Word16 *intBuffer, + Word16 out_q #endif ) { - int16_t chnl, smpl, i; - float temp; - + Word16 chnl, smpl, i; + Word32 temp_fx; + Word32 temp_fx1; i = 0; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in_flag ) + IF( cldfb_in_flag ) { - int16_t slotIdx, numCldfbBands, numPcmSamples, b; - float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; - float re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; - float im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + Word16 slotIdx, numCldfbBands, numPcmSamples, b, temp_out_q; + Word32 fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + Word32 re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + Word32 im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; numPcmSamples = numSamplesPerChannel >> 1; numCldfbBands = numPcmSamples / IVAS_CLDFB_NO_COL_MAX; /* CLDFB Synthesis*/ - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) + FOR( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - for ( b = 0; b < numCldfbBands; b++ ) + FOR( b = 0; b < numCldfbBands; b++ ) { - re[chnl][slotIdx][b] = floatBuffer[( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; - im[chnl][slotIdx][b] = floatBuffer[numCldfbBands + ( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + re[chnl][slotIdx][b] = Word32Buffer[( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + im[chnl][slotIdx][b] = Word32Buffer[numCldfbBands + ( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + move32(); + move32(); } } } /* Implement CLDFB synthesis */ - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - float *RealBuffer[IVAS_CLDFB_NO_COL_MAX]; - float *ImagBuffer[IVAS_CLDFB_NO_COL_MAX]; + Word32 *RealBuffer[IVAS_CLDFB_NO_COL_MAX]; + Word32 *ImagBuffer[IVAS_CLDFB_NO_COL_MAX]; - for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) + FOR( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { RealBuffer[slotIdx] = re[chnl][slotIdx]; ImagBuffer[slotIdx] = im[chnl][slotIdx]; + move32(); + move32(); } - IVAS_REND_cldfbSynthesis_wrapper( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * IVAS_CLDFB_NO_COL_MAX, cldfbSyn[chnl] ); + IVAS_REND_cldfbSynthesis_wrapper( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * IVAS_CLDFB_NO_COL_MAX, cldfbSyn[chnl], out_q, &temp_out_q ); } - for ( smpl = 0; smpl < numPcmSamples; ++smpl ) + + FOR( smpl = 0; smpl < numPcmSamples; ++smpl ) { - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - intBuffer[i] = (int16_t) roundf( fIn[chnl][smpl] ); + intBuffer[i] = (Word16) L_shl( fIn[chnl][smpl], sub( out_q, temp_out_q ) ); ++i; } } } - else + ELSE { #endif - for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) + + FOR( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) { - for ( chnl = 0; chnl < numChannels; ++chnl ) + FOR( chnl = 0; chnl < numChannels; ++chnl ) { - temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; - temp = (float) floor( temp + 0.5f ); - if ( temp > IVAS_MAX16B_FLT ) + temp_fx = L_add( Word32Buffer[chnl * numSamplesPerChannel + smpl], lshl( 1, ( out_q - 1 ) ) ); + temp_fx1 = L_shr( temp_fx, out_q ); + IF( GT_32( temp_fx1, IVAS_MAX16B_FX ) ) { - temp = IVAS_MAX16B_FLT; + temp_fx1 = IVAS_MAX16B_FX; } - else if ( temp < IVAS_MIN16B_FLT ) + ELSE IF( LT_32( temp_fx1, IVAS_MIN16B_FX ) ) { - temp = IVAS_MIN16B_FLT; + temp_fx1 = IVAS_MIN16B_FX; } - intBuffer[i] = (int16_t) temp; + intBuffer[i] = (Word16) temp_fx1; ++i; } diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 7e5c3e2bb..0d5ccae2f 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -36,6 +36,7 @@ #include "isar_prot.h" #include "ivas_prot.h" #include "prot.h" +#include "prot_fx.h" #include "control.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 152fe52f3..5d2f02af6 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -43,9 +43,8 @@ #include "debug.h" #endif #include "wmc_auto.h" -#include "prot_fx2.h" +#include "prot_fx.h" #include "basop_util.h" -#include "basop_mpy.h" #include "enh64.h" /*------------------------------------------------------------------------- @@ -1034,7 +1033,7 @@ ivas_error isar_splitBinRendPLCOpen( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC; error = IVAS_ERR_OK; - IF( ( hSplitRendPLC = (ISAR_SPLIT_REND_PLC_HANDLE) malloc( sizeof( SPLIT_REND_PLC_STRUCT ) ) ) == NULL ) + IF( ( hSplitRendPLC = (ISAR_SPLIT_REND_PLC_HANDLE) malloc( sizeof( ISAR_SPLIT_REND_PLC_STRUCT ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split renderer PLC Module \n" ) ); } diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 1bbff0b5c..840b102d0 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -44,7 +44,7 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "prot_fx2.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "basop_util.h" #define Q31_BY_360 ( 5965232 ) // Q31 diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 2e2e19ac4..12e684767 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -49,7 +49,7 @@ #ifdef DBG_WAV_WRITER #include "string.h" #endif -#include "prot_fx2.h" +#include "prot_fx.h" #include "basop_util.h" /*---------------------------------------------------------------------* @@ -2909,7 +2909,6 @@ void isar_init_split_rend_handles( FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { - hSplitRendWrapper->lc3plusDelayBuffers[i] = NULL; hSplitRendWrapper->lc3plusDelayBuffers_fx[i] = NULL; } hSplitRendWrapper->lc3plusDelaySamples = 0; @@ -2990,15 +2989,9 @@ ivas_error split_renderer_open_lc3plus( /* Alocate buffers for delay compensation */ IF( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - delayBufferLength = (Word16) ( OutSampleRate / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); + delayBufferLength = (Word16) ( OutSampleRate / (int32_t) FRAMES_PER_SEC + hSplitRendWrapper->lc3plusDelaySamples ); FOR( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) { - IF( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); - } - - set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength ); IF( ( hSplitRendWrapper->lc3plusDelayBuffers_fx[i] = malloc( delayBufferLength * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); @@ -3017,12 +3010,6 @@ ivas_error split_renderer_open_lc3plus( delayBufferLength = 2 /* Columns */ * 2 /* real and imag */ * CLDFB_NO_CHANNELS_MAX; FOR( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) { - IF( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); - } - - set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength ); IF( ( hSplitRendWrapper->lc3plusDelayBuffers_fx[i] = malloc( delayBufferLength * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); @@ -3165,7 +3152,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( /*this should always have the time resolution of pose correction MD. Note that this does not change frame size of LC3plus*/ // Word16 frame_size = (Word16) ( hSplitBin->hLc3plusEnc->config.samplerate / (Word32) FRAMES_PER_SECOND ); tmp_e = 0; - tmp = BASOP_Util_Divide3232_Scale( hSplitBin->hLc3plusEnc->config.samplerate, FRAMES_PER_SECOND_FX, &tmp_e ); + tmp = BASOP_Util_Divide3232_Scale( hSplitBin->hLc3plusEnc->config.samplerate, FRAMES_PER_SEC, &tmp_e ); Word16 frame_size = shr( tmp, sub( 15, tmp_e ) ); // Q0 FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 447fed0ba..44fe32f4a 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -36,6 +36,7 @@ #include #include "ivas_prot.h" #include "prot.h" +#include "prot_fx.h" #include "isar_cnst.h" #include "isar_rom_post_rend.h" #include "lib_isar_pre_rend.h" @@ -504,13 +505,12 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); - Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split ) ); + Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 Q_out[ch] = sub( Q_cldfb, 1 ); move16(); - hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split = Q_out[ch]; + hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; move16(); - fixedToFloat_arrL( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state, hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length ); } #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS @@ -561,11 +561,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); - Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split ) ); + Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 Q_out[ch] = sub( Q_cldfb, 1 ); move16(); - hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_split = Q_out[ch]; + hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; move16(); } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 604596496..b33ce2942 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -9226,11 +9226,17 @@ void IVAS_REND_cldfbAnalysis_ts_wrapper( float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ const int16_t samplesToProcess, /* i : samples to process */ - IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ -) + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filterbank state */ + Word16 Q_in, + Word16 *Q_out ) { cldfbAnalysis_ts( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb ); + Word16 Q_cldfb = Q_in; + cldfbAnalysis_ts_fx_fixed_q( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb, + &Q_cldfb ); + *Q_out = sub( Q_in, 5 ); + return; } @@ -9242,14 +9248,21 @@ void IVAS_REND_cldfbAnalysis_ts_wrapper( *-------------------------------------------------------------------*/ void IVAS_REND_cldfbSynthesis_wrapper( - float **realBuffer, /* i : real values */ - float **imagBuffer, /* i : imag values */ - float *timeOut, /* o : output time domain samples */ - const int16_t samplesToProcess, /* i : number of processed samples */ - IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ -) -{ - cldfbSynthesis( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); + Word32 **realBuffer, /* i : real values */ + Word32 **imagBuffer, /* i : imag values */ + Word32 *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filter bank state */ + Word16 Q_cldfb, + Word16 Q_out ) +{ + + Scale_sig32( h_cldfb->cldfb_state_fx, h_cldfb->p_filter_length, sub( sub( Q_cldfb, 1 ), h_cldfb->Q_cldfb_state ) ); + cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); // Q_cldfb - 1 + Q_out = sub( Q_cldfb, 1 ); + move16(); + h_cldfb->Q_cldfb_state = Q_out; + move16(); return; } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 60d217bad..59f0ea4dd 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -386,20 +386,22 @@ void IVAS_REND_closeCldfb( ); void IVAS_REND_cldfbAnalysis_ts_wrapper( - const Word32 *timeIn, /* i : time buffer */ - Word32 realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - Word32 imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const Word16 samplesToProcess, /* i : samples to process */ - IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ -); + const float *timeIn, /* i : time buffer */ + float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const int16_t samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filterbank state */ + Word16 Q_in, + Word16 *Q_out ); void IVAS_REND_cldfbSynthesis_wrapper( - Word32 **realBuffer, /* i : real values */ - Word32 **imagBuffer, /* i : imag values */ - Word32 *timeOut, /* o : output time domain samples */ - const Word16 samplesToProcess, /* i : number of processed samples */ - IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ -); + Word32 **realBuffer, /* i : real values */ + Word32 **imagBuffer, /* i : imag values */ + Word32 *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filter bank state */ + Word16 Q_cldfb, + Word16 Q_out ); #endif -- GitLab From 1c0f36f0aa732ca19ae34a0a0db2cd1bd35c8a5e Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 4 Feb 2025 10:30:01 +0100 Subject: [PATCH 026/329] refactor the usage of f_forceModeDir in the API --- apps/encoder.c | 115 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 36 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 36ba0bcd7..56991959f 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -201,9 +201,6 @@ int main( int16_t *pcmBuf = NULL; #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; -#ifdef DEBUG_FORCE_DIR - bool f_forceModeDir = false; -#endif #endif #ifdef WMOPS @@ -541,42 +538,15 @@ int main( #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode; int32_t force_profile_cnt = 0; -#ifdef DEBUG_FORCE_DIR - struct stat path_stat; -#endif if ( arg.forcedModeFile ) { -#ifdef DEBUG_FORCE_DIR - if ( stat( arg.forcedModeFile, &path_stat ) != 0 ) - { - fprintf( stderr, "\nError: The profile file/dir could not be opened: %s\n\n", arg.forcedModeFile ); - usage_enc(); - goto cleanup; - } - - /* check if it is a directory */ - if ( S_ISDIR( path_stat.st_mode ) ) - { - f_forceModeDir = true; - } - else - { - if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) - { - fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); - usage_enc(); - goto cleanup; - } - } -#else if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) { fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); usage_enc(); goto cleanup; } -#endif } #endif @@ -724,16 +694,12 @@ int main( } /* Force mode not set when configuring, set in first frame even if not reading from file */ - if ( f_forcedModeProfile || -#ifdef DEBUG_FORCE_DIR - f_forceModeDir || -#endif - frame == 0 ) + if ( f_forcedModeProfile || frame == 0 ) { if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode #ifdef DEBUG_FORCE_DIR , - arg.forcedModeFile + arg.forcedModeDir #endif ) ) != IVAS_ERR_OK ) { @@ -906,6 +872,9 @@ static void initArgStruct( EncArguments *arg ) #ifdef DEBUGGING arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; arg->forcedModeFile = NULL; +#ifdef DEBUG_FORCE_DIR + arg->forcedModeDir = NULL; +#endif #endif arg->pca = false; @@ -1046,6 +1015,28 @@ static bool parseCmdlIVAS_enc( arg->forcedMode = parseForcedMode( stmp ); +#ifdef DEBUG_FORCE_DIR + if ( arg->forcedMode < IVAS_ENC_FORCE_FILE ) + { + fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_FILE ) + { + arg->forcedModeFile = argv[i + 1]; + fprintf( stdout, "Force switching file: %s\n", argv[i + 1] ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_DIR ) + { + arg->forcedModeDir = argv[i + 1]; + fprintf( stdout, "Forcing switching directory: %s\n", argv[i + 1] ); + } + else + { + fprintf( stderr, "\nError: The force switching profile file/dir %s does not exist or could not be opened!\n\n", argv[i + 1] ); + usage_enc(); + return false; + } +#else if ( arg->forcedMode == IVAS_ENC_FORCE_UNDEFINED ) { arg->forcedModeFile = argv[i + 1]; @@ -1055,6 +1046,7 @@ static bool parseCmdlIVAS_enc( { fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); } +#endif i += 2; } @@ -1958,8 +1950,58 @@ static bool readBitrate( static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ) { +#ifdef DEBUG_FORCE_DIR + struct stat path_stat; +#endif + to_upper( forcedModeChar ); +#ifdef DEBUG_FORCE_DIR + if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || + ( strcmp( forcedModeChar, "0" ) == 0 ) ) + { + return IVAS_ENC_FORCE_SPEECH; + } + else if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) ) + { + return IVAS_ENC_FORCE_MUSIC; + } + else if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_ACELP; + } + else if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_GSC; + } + else if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX; + } + else if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_HQ; + } + else + { + if ( stat( forcedModeChar, &path_stat ) != 0 ) + { + return IVAS_ENC_FORCE_UNDEFINED; + } + + /* check if the argument represents an existing file or directory */ + if ( S_ISDIR( path_stat.st_mode ) ) + { + /* it's a directory */ + return IVAS_ENC_FORCE_DIR; + } + else + { + /* it's a file */ + return IVAS_ENC_FORCE_FILE; + } + } +#else if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || ( strcmp( forcedModeChar, "0" ) == 0 ) ) { @@ -1987,6 +2029,7 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( } return IVAS_ENC_FORCE_UNDEFINED; +#endif } -- GitLab From 8926070a3e56e05d2f6724ef71f19517edb796bd Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 4 Feb 2025 13:19:07 +0100 Subject: [PATCH 027/329] fix force_dir initialization to empty string --- lib_enc/lib_enc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 26fc04a5e..631f7bf38 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1888,10 +1888,9 @@ ivas_error IVAS_ENC_SetForcedMode( } #ifdef DEBUG_FORCE_DIR + hIvasEnc->st_ivas->hEncoderConfig->force_dir[0] = '\0'; if ( forcedMode < IVAS_ENC_FORCE_FILE ) { - hIvasEnc->st_ivas->hEncoderConfig->force_dir[0] = '\0'; - if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 0fbfb763563067e4268166f85e8e2ca7fe2fb32c Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 4 Feb 2025 13:19:39 +0100 Subject: [PATCH 028/329] fix element_mode read/write location --- lib_enc/ivas_stereo_classifier.c | 65 ++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 96754c97d..bf8f74b14 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -217,17 +217,6 @@ Word16 select_stereo_mode( } } -#ifdef DEBUG_FORCE_DIR - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); - } -#endif - /* switch from LRTD to DFT when xtalk_decision goes from 0->1 (note: this special case is not handled in the xtalk classifier) */ test(); test(); @@ -252,6 +241,17 @@ Word16 select_stereo_mode( } } +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); + } +#endif + IF( NE_16( hCPE->last_element_mode, element_mode ) ) { test(); @@ -914,6 +914,16 @@ void unclr_classifier_td_fx( move16(); } +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_unclr_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/force_unclr_decision.enf" ); + } +#endif return; } @@ -1021,6 +1031,16 @@ void unclr_classifier_dft_fx( move16(); } +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_unclr_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/force_unclr_decision.enf" ); + } +#endif return; } @@ -1169,6 +1189,17 @@ void xtalk_classifier_td_fx( move16(); } +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_xtalk_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/force_xtalk_decision.enf" ); + } +#endif + return; } @@ -1389,7 +1420,6 @@ void xtalk_classifier_dft_fx( move16(); } - /* updates */ hItd->prev_m1_fx = m1; move32(); @@ -1400,6 +1430,17 @@ void xtalk_classifier_dft_fx( hItd->prev_itd2 = itd2; move16(); +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_xtalk_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/force_xtalk_decision.enf" ); + } +#endif + return; } -- GitLab From eabcb20b922ac7307c644ef6baf39f9c42077f2c Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 01:41:31 +1100 Subject: [PATCH 029/329] co[pilation fixes on windows --- Workspace_msvc/lib_isar.vcxproj | 32 ++----- Workspace_msvc/lib_lc3plus.vcxproj | 4 +- apps/decoder.c | 47 ++++------ apps/renderer.c | 2 +- lib_com/cnst.h | 5 ++ lib_com/delay_comp.c | 2 +- lib_com/enh1632.c | 21 +++++ lib_com/enh1632.h | 1 + lib_com/ivas_prot_fx.h | 12 --- lib_com/ivas_rotation_com.c | 70 +-------------- lib_com/prot_fx.h | 2 +- lib_com/tools_fx.c | 20 ----- lib_com/typedef.h | 2 + lib_dec/ivas_binRenderer_internal.c | 33 ++++--- lib_dec/ivas_dirac_dec.c | 16 ++-- lib_dec/ivas_init_dec.c | 16 ++-- lib_dec/ivas_init_dec_fx.c | 4 + lib_dec/ivas_ism_dec.c | 12 +-- lib_dec/ivas_ism_param_dec.c | 21 ++--- lib_dec/ivas_jbm_dec.c | 21 +++-- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_mc_param_dec.c | 16 +++- lib_dec/ivas_mc_paramupmix_dec.c | 25 ++++-- lib_dec/ivas_mct_dec.c | 6 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 15 ++-- lib_dec/ivas_output_config.c | 43 +++++---- lib_dec/ivas_sba_dec.c | 18 ++-- lib_dec/ivas_spar_decoder.c | 9 +- lib_dec/lib_dec_fx.c | 10 ++- lib_isar/isar_PredDecoder.c | 1 - lib_isar/isar_PredEncoder.c | 2 +- lib_isar/isar_RMSEnvGrouping.c | 2 +- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 3 +- lib_isar/isar_prot.h | 15 ++-- lib_isar/isar_splitRendererPLC.c | 18 ---- lib_isar/isar_splitRendererPost.c | 9 +- lib_isar/isar_splitRendererPre.c | 7 +- lib_isar/isar_splitRenderer_utils.c | 67 +------------- lib_isar/lib_isar_post_rend.c | 18 ++-- lib_isar/lib_isar_pre_rend.c | 8 +- lib_lc3plus/apply_global_gain_fx.c | 2 +- lib_lc3plus/ari_codec.c | 16 ++-- lib_lc3plus/basop_util_lc3plus.c | 2 +- lib_lc3plus/basop_util_lc3plus.h | 2 +- lib_lc3plus/cutoff_bandwidth.c | 2 +- lib_lc3plus/dct4_fx.c | 2 +- lib_lc3plus/dec_entropy.c | 2 +- lib_lc3plus/ltpf_coder_fx.c | 4 +- lib_lc3plus/olpa_fx.c | 4 +- lib_lc3plus/plc_xcorr_fx.c | 2 +- lib_rend/ivas_crend.c | 12 +-- lib_rend/ivas_dirac_dec_binaural_functions.c | 22 +++-- lib_rend/ivas_orient_trk.c | 10 +++ lib_rend/ivas_output_init.c | 6 +- lib_rend/ivas_prot_rend.h | 10 +-- lib_rend/ivas_reflections.c | 16 +++- lib_rend/ivas_rotation.c | 14 +-- lib_rend/lib_rend.c | 93 +++++++++++++++----- lib_rend/lib_rend.h | 10 +-- lib_util/rotation_file_reader.c | 25 +++++- 62 files changed, 416 insertions(+), 481 deletions(-) diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index c663ef5e7..23d803730 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -13,16 +13,16 @@ lib_isar {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} - evs_dec + isar 10.0.17763.0 + StaticLibrary v141 false MultiByte - StaticLibrary v141 @@ -47,33 +47,24 @@ .\Debug_$(ProjectName)\ .\Debug_$(ProjectName)\ - false - false - libivasrend + libisar .\Release_$(ProjectName)\ .\Release_$(ProjectName)\ - false - false - libivasrend + libisar - - .\Debug\$(ProjectName).tlb - - Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions); EnableFastChecks MultiThreadedDebug - false $(IntDir)$(ProjectName).pdb @@ -82,7 +73,6 @@ OldStyle Default %(DisableSpecificWarnings) - false _DEBUG;%(PreprocessorDefinitions) @@ -98,10 +88,6 @@ - - $(IntDir)$(ProjectName).tlb - - MaxSpeed AnySuitable @@ -109,14 +95,13 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true Default MultiThreaded true - false $(IntDir)$(ProjectName).pdb @@ -125,7 +110,6 @@ Default %(DisableSpecificWarnings) - false NDEBUG;%(PreprocessorDefinitions) @@ -138,7 +122,6 @@ - @@ -163,7 +146,6 @@ - diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 294677fff..b22697021 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -65,7 +65,7 @@ Level3 - ..\lib_com;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) Disabled MultiThreadedDebug WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) @@ -84,7 +84,7 @@ Level3 - ..\lib_com;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) MaxSpeed MultiThreaded true diff --git a/apps/decoder.c b/apps/decoder.c index 77126067e..6ad1ebd6a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1942,13 +1942,15 @@ static ivas_error decodeG192( { for ( i = 0; i < num_subframes; i++ ) { - Quaternions[i].w = -3.0f; - Quaternions[i].x = 0.0f; - Quaternions[i].y = 0.0f; - Quaternions[i].z = 0.0f; - Pos[i].x = 0.0f; - Pos[i].y = 0.0f; - Pos[i].z = 0.0f; + Quaternions[i].w_fx = -12582912; + Quaternions[i].x_fx = 0; + Quaternions[i].y_fx = 0; + Quaternions[i].z_fx = 0; + Quaternions[i].q_fact = 22; + Pos[i].x_fx = 0; + Pos[i].y_fx = 0; + Pos[i].z_fx = 0; + Pos[i].q_fact = 25; } } else @@ -2046,13 +2048,7 @@ static ivas_error decodeG192( else { #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) - -#else - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) - -#endif + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2264,11 +2260,7 @@ static ivas_error decodeG192( } /* decode and get samples */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) -#else if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2655,13 +2647,15 @@ static ivas_error decodeVoIP( { for ( i = 0; i < num_subframes; i++ ) { - Quaternions[i].w = -3.0f; - Quaternions[i].x = 0.0f; - Quaternions[i].y = 0.0f; - Quaternions[i].z = 0.0f; + Quaternions[i].w_fx = -12582912; + Quaternions[i].x_fx = 0; + Quaternions[i].y_fx = 0; + Quaternions[i].z_fx = 0; + Quaternions[i].q_fact = 22; Pos[i].x = 0.0f; Pos[i].y = 0.0f; Pos[i].z = 0.0f; + Pos[i].q_fact = 25; } } else @@ -2774,19 +2768,10 @@ static ivas_error decodeVoIP( /* decode and get samples */ - -#ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif -#else #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/apps/renderer.c b/apps/renderer.c index 1979a7f1f..09b1425ce 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -3854,7 +3854,7 @@ static void convertInputBuffer_fx( IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx], &Word32Buffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], &Word32Buffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], - numCldfbBands, cldfbAna[chnl], in_q_factor, *out_q_factor ); + numCldfbBands, cldfbAna[chnl], Q11, *out_q_factor ); } } } diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 35dc4f02a..e7c601ca3 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -3069,8 +3069,13 @@ enum #define SYNC_BAD_FRAME (UWord16) 0x6B20 /* synchronization word of a "bad" frame */ #define G192_BIN0 (UWord16) 0x007F /* binary "0" according to ITU-T G.192 */ #define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +#define DEGREE_180 (Word32)(180.0 *ONE_IN_Q22) +#define DEGREE_360 (Word32)(360.0 *ONE_IN_Q22) +#else #define DEGREE_180 (Word32)(180.0 *ONE_IN_Q23) #define DEGREE_360 (Word32)(360.0 *ONE_IN_Q23) +#endif extern const Word16 Idx2Freq_Tbl[]; #define chk_fs(fs) diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 38a077f9e..581db32bd 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -110,7 +110,7 @@ Word32 get_delay_fx( /* o : delay value in ms #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_16( output_config, AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { #endif if ( hCldfb != NULL ) diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index bac18231e..f397c3432 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -616,6 +616,27 @@ Word32 L_rotr( Word32 L_var1, Word16 var2, Word16 *var3 ) } +int16_t norm_ul( uint32_t UL_var1 ) +{ + int16_t var_out; + + if ( UL_var1 == 0 ) + { + var_out = 0; + } + else + { + for ( var_out = 0; UL_var1 < (uint32_t) 0x80000000U; var_out++ ) + { + UL_var1 <<= 1; + } + } + BASOP_CHECK(); + + return ( var_out ); +} + + /***************************************************************************** * * Function Name : L_rotl diff --git a/lib_com/enh1632.h b/lib_com/enh1632.h index 10c10866a..f91494fb1 100644 --- a/lib_com/enh1632.h +++ b/lib_com/enh1632.h @@ -55,6 +55,7 @@ Word16 rotl( Word16 var1, Word16 var2, Word16 *var3 ); Word32 L_rotr( Word32 var1, Word16 var2, Word16 *var3 ); Word32 L_rotl( Word32 var1, Word16 var2, Word16 *var3 ); +Word16 norm_ul( UWord32 UL_var1 ); /***************************************************************************** * diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0fd85daae..9429640ba 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5907,12 +5907,6 @@ void reset_metadata_spatial_fx( const Word16 nb_bits_metadata /* i : number of meatdata bits */ ); -void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -); void Euler2Quat_fx( const Word32 yaw, /* i : yaw (x) Q22 */ const Word32 pitch, /* i : pitch (y) Q22 */ @@ -5926,12 +5920,6 @@ Word32 deg2rad_fx( Word32 degrees ); #ifdef SPLIT_REND_WITH_HEAD_ROT -void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ -); void Quat2EulerDegree_fx( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ Word32 *yaw_fx, /* o : yaw */ diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index fc390dfb2..8aae50841 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -76,26 +76,6 @@ void Euler2Quat_fx( return; } -void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -) -{ - float cr = cosf( roll * 0.5f ); - float sr = sinf( roll * 0.5f ); - float cp = cosf( pitch * 0.5f ); - float sp = sinf( pitch * 0.5f ); - float cy = cosf( yaw * 0.5f ); - float sy = sinf( yaw * 0.5f ); - quat->w = cr * cp * cy + sr * sp * sy; - quat->x = sr * cp * cy - cr * sp * sy; - quat->y = sr * cp * sy + cr * sp * cy; - quat->z = cr * cp * sy - sr * sp * cy; - - return; -} #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -258,61 +238,15 @@ void Quat2EulerDegree_fx( return; } -void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ -) -{ - if ( quat.w != -3.0 ) - { - float p; - - *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); - - p = 2 * ( quat.w * quat.y - quat.z * quat.x ); - p = max( -1.0f, min( 1.0f, p ) ); - *pitch = asinf( p ); - - *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); - - *yaw *= _180_OVER_PI; - *pitch *= _180_OVER_PI; - *roll *= _180_OVER_PI; - } - else - { - /* Euler angles in R_X(roll)*R_Y(pitch)*R_Z(yaw) convention - * - * yaw: rotate scene counter-clockwise in the horizontal plane - * pitch: rotate scene in the median plane, increase elevation with positive values - * roll: rotate scene from the right ear to the top - */ - *yaw = quat.z; - *pitch = quat.y; - *roll = quat.x; - } - - return; -} #endif -/*------------------------------------------------------------------------- - * deg2rad() - * - * Converts degrees to normalized radians - *------------------------------------------------------------------------*/ -#define DEGREE_180 ( Word32 )( 180.0 * ONE_IN_Q22 ) -#define DEGREE_360 ( Word32 )( 360.0 * ONE_IN_Q22 ) -#define PI_OVER_180_FX ( Word32 )( ( EVS_PI / 180.0f ) * ONE_IN_Q31 ) /*------------------------------------------------------------------------- * deg2rad() * * Converts degrees to normalized radians *------------------------------------------------------------------------*/ Word32 deg2rad_fx( - Word32 degrees // Q23 + Word32 degrees // Q22 ) { WHILE( GE_32( degrees, DEGREE_180 ) ) @@ -324,7 +258,7 @@ Word32 deg2rad_fx( degrees = L_add( degrees, DEGREE_360 ); } - return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q23 + return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q22 } float deg2rad( diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2aa3311b8..3de9a7f3b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -128,7 +128,7 @@ Word32 sum_l_fx( const Word32 *vec, /* i : input vector */ const Word16 lvec /* i : length of input vector */ ); -Word16 norm_ul( UWord32 UL_var1 ); + Word32 Mult_32_16( Word32 a, diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 74a47dde8..6f40a49a5 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -242,26 +242,6 @@ void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo ) #undef WMC_TOOL_SKIP -int16_t norm_ul( uint32_t UL_var1 ) -{ - int16_t var_out; - - if ( UL_var1 == 0 ) - { - var_out = 0; - } - else - { - for ( var_out = 0; UL_var1 < (uint32_t) 0x80000000U; var_out++ ) - { - UL_var1 <<= 1; - } - } - BASOP_CHECK(); - - return ( var_out ); -} - /*-------------------------------------------------------------------* * usdequant_fx() * diff --git a/lib_com/typedef.h b/lib_com/typedef.h index 3d86229dd..36ff2e091 100644 --- a/lib_com/typedef.h +++ b/lib_com/typedef.h @@ -134,6 +134,8 @@ typedef float Float32; typedef unsigned short int UNS_Word16; /* 16 bit "register" (sw*) */ +typedef int Counter; + #ifndef TYPEDEF_INITIALIZED #error types in typedef.h not initialized #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index ce4dfa9c9..60bdda941 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1839,8 +1839,8 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } @@ -1848,8 +1848,8 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { - mvr2r( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - mvr2r( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } } #else @@ -1935,7 +1935,7 @@ void ivas_binRenderer_fx( IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { IVAS_QUATERNION Quaternions_rel, Quaternions_abs, *Quaternions_ref; - Word32 Rmat_local[3][3]; + Word32 Rmat_local[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; Word16 q_fact_orig; IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) @@ -1981,25 +1981,25 @@ void ivas_binRenderer_fx( modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); - QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + QuatToRotMat_fx( Quaternions_abs, Rmat_local[0] ); - modify_Rmat_q_fx( Rmat_local, Rmat_local, MAX_PARAM_SPATIAL_SUBFRAMES, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, 1, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) { - rotateFrame_sd_cldfb( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_sd_cldfb_fixed( Rmat_local[0], RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } else { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local[0], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { FOR( k = 0; k < numTimeSlots; k++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); @@ -2099,7 +2099,7 @@ void ivas_rend_CldfbMultiBinRendProcess( Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 low_res_pre_rend_rot, const Word16 num_subframes, - Word16 *Q_in /* i : LS signals exp */ + const Word16 Q_in /* i : LS signals exp */ ) { int16_t slot_idx, ch_idx, idx, pose_idx, i, j; @@ -2108,7 +2108,7 @@ void ivas_rend_CldfbMultiBinRendProcess( Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word16 Q_in_orig = *Q_in; + Word16 Q_in_orig = Q_in; move16(); FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) @@ -2142,7 +2142,7 @@ void ivas_rend_CldfbMultiBinRendProcess( move16(); } - ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, Q_in ); + ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { @@ -2153,12 +2153,11 @@ void ivas_rend_CldfbMultiBinRendProcess( { Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in_orig, *Q_in ) ); // Q_in_orig - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in_orig, *Q_in ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig } } } - *Q_in = Q_in_orig; } return; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 46cb389bf..a8b2da904 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3806,22 +3806,28 @@ void ivas_dirac_dec_render_sf_fx( hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); - +#ifndef SPLIT_REND_WITH_HEAD_ROT Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 - +#else + Word16 pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + Scale_sig32( &Cldfb_RealBuffer_Binaural_fx[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 + Scale_sig32( &Cldfb_ImagBuffer_Binaural_fx[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 + } +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - Word16 pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { - Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[( add( i_mult( pos_idx, BINAURAL_CHANNELS ) ), ch )][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); // Q6 - Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[( add( i_mult( pos_idx, BINAURAL_CHANNELS ) ), ch )][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); // Q6 + Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); // Q6 + Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); // Q6 } } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8fe884c3f..29aacd01a 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1186,12 +1186,12 @@ ivas_error ivas_init_decoder_front( *--------------------------------------------------------------------*/ test(); test(); - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || - ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) +#else + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) { @@ -3500,7 +3500,7 @@ static ivas_error doSanityChecks_IVAS( } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_16( output_Fs, 48000 ) ) + IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); } @@ -3510,11 +3510,11 @@ static ivas_error doSanityChecks_IVAS( { test(); test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #endif - ) ) { return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" ); } diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index b0dbe97b4..47b17aa96 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -60,7 +60,11 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx( move16(); } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else IF( st_ivas->hDiracDecBin->useTdDecorr ) +#endif { *numCldfbAnalyses = add( *numCldfbAnalyses, 2 ); move16(); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 6f1ae3de8..a234caaba 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -198,11 +198,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); test(); - IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { /* close the parametric binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -277,11 +277,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } test(); - IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { /* open the parametric binaural renderer */ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 50d1811f6..31d28961d 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -556,11 +556,11 @@ static ivas_error ivas_param_ism_rendering_init_fx( test(); test(); test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #endif - ) ) { /* computation of proto matrix */ ivas_ism_get_proto_matrix_fx( hOutSetup, nchan_transport, hParamIsmRendering->proto_matrix_fx ); @@ -737,12 +737,13 @@ ivas_error ivas_param_ism_dec_open_fx( test(); test(); test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else + IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) #endif - ) ) { /* Initialize efap handle */ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) @@ -765,11 +766,11 @@ ivas_error ivas_param_ism_dec_open_fx( test(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 0f762462c..865a2d85e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1687,20 +1687,23 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( test(); test(); /* delay the objects here for all renderers where it is needed */ - IF( #ifdef SPLIT_REND_WITH_HEAD_ROT + IF( ( -#endif EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || - EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) -#ifdef SPLIT_REND_WITH_HEAD_ROT - ) && - ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) && + ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else + IF( + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || + EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) #endif - ) { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -2081,7 +2084,7 @@ ivas_error ivas_jbm_dec_render_fx( { IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural_fx( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } @@ -2415,7 +2418,7 @@ ivas_error ivas_jbm_dec_render_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index e87d5da00..c547c4687 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1790,7 +1790,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( st_ivas->hDiracDecBin[pos_idx] != NULL ) { /* regularization factor is bitrate-dependent */ - st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); move16(); } } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 7e96c0717..078268dc4 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -2227,6 +2227,20 @@ void ivas_param_mc_dec_render_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + { + FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) + { + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 + } + } + } +#else FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) @@ -2235,11 +2249,11 @@ void ivas_param_mc_dec_render_fx( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 } } +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - int16_t pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++ ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index f998b0d1b..08606c8f1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -866,8 +866,8 @@ static void ivas_mc_paramupmix_dec_sf( { FOR( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) { - Copy32( Cldfb_RealBuffer_subfr[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][add( slot_index_start, slot_idx )], maxBand ); - Copy32( Cldfb_ImagBuffer_subfr[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][add( slot_index_start, slot_idx )], maxBand ); + Copy32( Cldfb_RealBuffer_subfr_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_index_start, slot_idx )], maxBand ); + Copy32( Cldfb_ImagBuffer_subfr_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_index_start, slot_idx )], maxBand ); } } @@ -888,7 +888,20 @@ static void ivas_mc_paramupmix_dec_sf( Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); - +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + { + FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) + { + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 + } + } + } +#else FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) @@ -897,19 +910,19 @@ static void ivas_mc_paramupmix_dec_sf( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 } } +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - int16_t pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) { FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { - Copy32( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); - Copy32( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); + Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); + Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); } } } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 8e34d6642..ec9cc8b12 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1455,11 +1455,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); test(); test(); - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { /* remove unneeded binaural renderers */ test(); diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index b4f757025..0079ae4de 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -813,7 +813,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); n++ ) { - p_rend_obj[n] = &output_f[n][0]; + p_rend_obj[n] = &output_fx[n][0]; move32(); } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index b71b73a6a..1c008caa0 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -176,7 +176,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( move16(); st_ivas->nchan_transport = st_ivas->nchan_ism; move16(); - IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } @@ -188,18 +188,19 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( { FOR( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) { - cldfbAnalysis_ts_fx_fixed_q( &( output_f[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n], &q_cldfb ); + cldfbAnalysis_ts_fx_fixed_q( &( output_fx[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n], &q_cldfb ); + Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); FOR( b = 0; b < num_cldfb_bands; b++ ) { - st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] = - L_add( L_shr( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][add( slot_idx_start, slot_idx )][b], 1 ), + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx][b] = + L_add( L_shr( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][add( slot_idx_start, slot_idx )][b], 1 ), L_shr( Cldfb_RealBuffer[b], 1 ) ); move32(); - st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] = - L_add( L_shr( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][add(slot_idx_start, slot_idx)][b], 1 ), - L_shrCldfb_ImagBuffer[b], 1) ); + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx][b] = + L_add( L_shr( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][add( slot_idx_start, slot_idx )][b], 1 ), + L_shr( Cldfb_ImagBuffer[b], 1 ) ); move32(); } } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index d2aad8218..a3f361e1e 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -81,11 +81,11 @@ void ivas_renderer_select( test(); test(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { test(); test(); @@ -96,11 +96,11 @@ void ivas_renderer_select( { IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) #endif - ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -114,11 +114,11 @@ void ivas_renderer_select( ELSE /* ISM_MODE_DISC */ { test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move16(); @@ -138,12 +138,11 @@ void ivas_renderer_select( { *internal_config = output_config; move16(); - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) #endif - ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -160,11 +159,11 @@ void ivas_renderer_select( move16(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; move16(); @@ -219,11 +218,11 @@ void ivas_renderer_select( *internal_config = output_config; move16(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) #endif - ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -239,11 +238,11 @@ void ivas_renderer_select( *internal_config = transport_config; move16(); test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { test(); test(); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index f1ac7fa76..daf624a78 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -185,11 +185,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); test(); test(); - IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #endif - ) ) { RENDERER_TYPE renderer_type_new; Word16 sba_order_internal; @@ -200,11 +200,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ IF( LE_16( ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_order_internal ), 2 ) ) { - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) #endif - ) { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -218,11 +218,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( ELSE { test(); - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif - ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; move16(); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 760d12a36..ebccb336f 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -2002,12 +2002,13 @@ void ivas_spar_dec_upmixer_sf_fx( test(); test(); test(); - IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif - ) ) && + IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) && + !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) +#else + IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) && !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) +#endif { Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, -6 ); /*st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state-6*/ st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8e1edc657..2e6085494 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2268,11 +2268,19 @@ ivas_error IVAS_DEC_FeedHeadTrackData( /* Move head-tracking data to the decoder handle */ /* check for Euler angle signaling */ - // TODO change euler angle to Q22 format +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* check for Euler angle signaling */ + IF( EQ_32( orientation.w_fx, L_negate( 12582912 ) ) && EQ_16( orientation.q_fact, Q22 ) ) + { + Euler2Quat_fx( deg2rad_fx( orientation.x_fx ), deg2rad_fx( orientation.y_fx ), deg2rad_fx( orientation.z_fx ), &orientation ); + modify_Quat_q_fx( &orientation, &orientation, Q29 ); + } +#else IF( EQ_32( orientation.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) { Euler2Quat_fx( deg2rad_fx( orientation.x_fx ), deg2rad_fx( orientation.y_fx ), deg2rad_fx( orientation.z_fx ), &orientation ); } +#endif Word32 updateRate_fx = 1677721600; // value is 200 in Q23 move32(); diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 3fa9ec877..eab82fe12 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -39,7 +39,6 @@ #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" #include "wmc_auto.h" -#include "basop_mpy.h" /*-------------------------------------------------------------------* * Function CreatePredictionDecoder() diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 0ca4d7add..d2b6e0f5c 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -39,7 +39,7 @@ #include "prot.h" #include "isar_prot.h" #include "wmc_auto.h" -#include "prot_fx2.h" +#include "prot_fx.h" #include "basop_util.h" #include "enh64.h" #include "basop32.h" diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 0c24040be..450356d02 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -40,7 +40,7 @@ #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" #include "wmc_auto.h" -#include "prot_fx2.h" +#include "prot_fx.h" #include "basop_util.h" #include "enh64.h" Word32 Inv_grp_length[17] = { diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index c067ad064..2695b397d 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -40,7 +40,7 @@ #include "isar_prot.h" #include "wmc_auto.h" #include "basop_util.h" -#include "prot_fx2.h" +#include "prot_fx.h" // #define DEBUG_WRITE #include "debug.h" #include "enh64.h" diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index aa9332c26..784f6f92e 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -38,13 +38,12 @@ #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" #include "prot.h" -#include "prot_fx2.h" +#include "prot_fx.h" #include "isar_prot.h" #include "wmc_auto.h" #include "basop_util.h" #include "enh64.h" #include "basop32.h" -#include "basop_mpy.h" #define LOG10_2_FX ( 646456993 ) /*------------------------------------------------------------------------------------------* diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 24f93b283..331eaadf3 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -136,9 +136,6 @@ void isar_splitBinLCLDDecProcess( void set_fix_rotation_mat_fx( Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); -void set_fix_rotation_mat( - float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); void isar_splitBinLCLDEncClose( ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); @@ -153,9 +150,6 @@ void isar_splitBinLCLDEncProcess( void set_pose_types_fx( ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); -void set_pose_types( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); void isar_split_rend_init_huff_cfg( ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ); @@ -275,8 +269,6 @@ void isar_init_multi_bin_pose_data_fx( /* Copy for encoder, to be removed */ void isar_init_multi_bin_pose_data_fx_enc( MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); -void isar_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); void isar_rend_CldfbSplitPreRendProcess( const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, @@ -460,6 +452,13 @@ void set32_fx( Word16 ceil_log_2( UWord64 val ); + +void ivas_cmult_fix( Word32 in1_re_fx, Word16 exp_re1, Word32 in1_im_fx, Word16 exp_im1, Word32 in2_re_fx, Word16 exp_re2, Word32 in2_im_fx, Word16 exp_im2, Word32 *out1_re_fx, Word32 *out1_im_fx, Word16 *exp_out1_re, Word16 *exp_out1_im ); + +void ivas_calculate_abs_fx( Word32 re_fx, Word16 exp_re, Word32 im_fx, Word16 exp_im, Word32 *out_fx, Word16 *exp_out ); + +void ivas_calculate_rabs_fx( Word32 re_fx, Word16 exp_re, Word32 *out_fx, Word16 *exp_out ); + /* clang-format on */ #endif /* IVAS_PROT_REND_H */ diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 5d2f02af6..5266cfd6b 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -64,24 +64,6 @@ #define PLC_FADE_CNST SR_PLC_FADE_START *CLDFB_NO_COL_MAX #define PLC_MUTE_CNST SR_PLC_MUTE *CLDFB_NO_COL_MAX Word32 xf_alp_tab[CLDFB_PLC_XF] = { 1431655680, 715827840 }; -static Word16 find_guarded_bits_fx( Word32 n ) -{ - return n <= 1 ? 0 : n <= 2 ? 1 - : n <= 4 ? 2 - : n <= 8 ? 3 - : n <= 16 ? 4 - : n <= 32 ? 5 - : n <= 64 ? 6 - : n <= 128 ? 7 - : n <= 256 ? 8 - : n <= 512 ? 9 - : n <= 1024 ? 10 - : n <= 2048 ? 11 - : n <= 4096 ? 12 - : n <= 8192 ? 13 - : n <= 16384 ? 14 - : 15; -} /*------------------------------------------------------------------------- * Function adaptive_polar_ext_plc() diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 840b102d0..c313e9ca4 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -38,6 +38,7 @@ #include #endif #include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "prot.h" #include "isar_rom_post_rend.h" #include "isar_prot.h" @@ -86,11 +87,11 @@ ivas_error isar_splitBinPostRendOpen( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - IF( ( error = openCldfb_splitRend( &( hBinRend->cldfbSyn[ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hBinRend->cldfbSyn[ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } - IF( ( error = openCldfb_splitRend( &( hBinRend->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hBinRend->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -134,12 +135,12 @@ void isar_splitBinPostRendClose( { IF( ( *hBinHrSplitPostRend )->cldfbSyn[ch] != NULL ) { - deleteCldfb_splitRend( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) ); + deleteCldfb_ivas_fx( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) ); ( *hBinHrSplitPostRend )->cldfbSyn[ch] = NULL; } IF( ( *hBinHrSplitPostRend )->cldfbAna[ch] != NULL ) { - deleteCldfb_splitRend( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) ); + deleteCldfb_ivas_fx( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) ); ( *hBinHrSplitPostRend )->cldfbAna[ch] = NULL; } } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 12e684767..092358962 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -38,6 +38,7 @@ #include #endif #include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "prot.h" #include "lib_isar_pre_rend.h" #include "isar_rom_post_rend.h" @@ -2375,12 +2376,6 @@ static void isar_SplitRenderer_quant_code( * *------------------------------------------------------------------------*/ -static Word16 imult1616( Word16 x, Word16 y ) -{ - assert( (int) x * (int) y < 32768 && (int) x * (int) y >= -32768 ); - return extract_l( L_mult0( x, y ) ); -} - static void isar_SplitRenderer_GetRotMd_fx( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index b290ca12a..3e2dd1f41 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -49,7 +49,7 @@ #endif #include "wmc_auto.h" #include "basop_settings.h" -#include "prot_fx2.h" +#include "prot_fx.h" #include "basop_util.h" @@ -439,29 +439,6 @@ void set_fix_rotation_mat_fx( return; } -void set_fix_rotation_mat( - float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) -{ - float yaw_a, cos_yaw, sin_yaw; - int16_t pos_idx; - yaw_a = 0.0f; - - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) - { - yaw_a = pMultiBinPoseData->relative_head_poses[pos_idx + 1][0]; - cos_yaw = cosf( EVS_PI * yaw_a / 180.0f ); - sin_yaw = sinf( EVS_PI * yaw_a / 180.0f ); - sin_yaw = 0.0f; - fix_pos_rot_mat[pos_idx][0][0] = cos_yaw; - fix_pos_rot_mat[pos_idx][1][1] = cos_yaw; - fix_pos_rot_mat[pos_idx][0][1] = sin_yaw; - fix_pos_rot_mat[pos_idx][1][0] = -1.0f * sin_yaw; - } - - return; -} - /*------------------------------------------------------------------------- * Function set_pose_types() @@ -496,30 +473,6 @@ void set_pose_types_fx( return; } -void set_pose_types( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) -{ - int16_t pos_idx; - - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) - { - if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] ) > EPSILON ) - { - pose_type[pos_idx] = ANY_YAW; - } - else if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][2] ) > EPSILON ) - { - pose_type[pos_idx] = ANY_ROLL; - } - else - { - pose_type[pos_idx] = PITCH_ONLY; - } - } - - return; -} /*------------------------------------------------------------------------- @@ -1512,24 +1465,6 @@ void isar_init_multi_bin_pose_data_fx_enc( return; } -void isar_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) -{ - int16_t pos_idx; - - for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) - { - pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f; - pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f; - pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f; - } - pMultiBinPoseData->num_poses = 1; - pMultiBinPoseData->dof = 3; - pMultiBinPoseData->hq_mode = 0; - pMultiBinPoseData->rot_axis = DEFAULT_AXIS; - - return; -} #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error isar_framesize_to_ms( diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 178718a60..128675281 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -37,7 +37,8 @@ #include "isar_prot.h" #include "prot.h" #include "ivas_prot.h" -#include "prot_fx2.h" +#include "ivas_prot_fx.h" +#include "prot_fx.h" #ifndef SPLIT_REND_WITH_HEAD_ROT int32_t ISAR_POST_REND_void_func( void ) @@ -51,7 +52,7 @@ int32_t ISAR_POST_REND_void_func( void ) #include #include #include "wmc_auto.h" -#include "prot_fx2.h" +#include "prot_fx.h" /*-------------------------------------------------------------------* @@ -170,6 +171,7 @@ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ + static ivas_error allocateInputBaseBufferData_fx( Word32 **data, const Word16 data_size ) @@ -387,10 +389,10 @@ static ivas_error initLimiter( /* Support re-init: close if already allocated */ IF( *phLimiter != NULL ) { - ivas_limiter_close_splitRend( phLimiter ); + ivas_limiter_close_fx( phLimiter ); } - IF( ( error = ivas_limiter_open_splitRend( phLimiter, numChannels, sampleRate ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_limiter_open_fx( phLimiter, numChannels, sampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -1666,7 +1668,7 @@ static ivas_error renderSplitBinauralWithPostRot( } Q_max = s_min( Q_max, Q13 ); accumulate2dArrayToBuffer_fx( tmpCrendBuffer_fx, Q_out, Q_max, &outAudio, num_subframes, outBufNumSamplesPerChannel ); - *outAudio.q_data_fx = Q_max; + *outAudio.pq_fact = Q_max; pop_wmops(); return error; @@ -1793,8 +1795,8 @@ ivas_error ISAR_POST_REND_getSamples( #ifdef DEBUGGING hIvasRend->numClipping += #endif - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.q_data_fx ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.q_data_fx ); + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); #endif return IVAS_ERR_OK; @@ -1847,7 +1849,7 @@ void ISAR_POST_REND_Close( clearInputSplitRend( &hIvasRend->inputsSplitPost[i] ); } - ivas_limiter_close_splitRend( &hIvasRend->hLimiter ); + ivas_limiter_close_fx( &hIvasRend->hLimiter ); free( hIvasRend ); *phIvasRend = NULL; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 44fe32f4a..bafb68a15 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -157,9 +157,9 @@ ivas_error ISAR_PRE_REND_open( FOR( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), - CLDFB_ANALYSIS, - OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), + CLDFB_ANALYSIS, + OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -167,7 +167,7 @@ ivas_error ISAR_PRE_REND_open( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - IF( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_lc3plus/apply_global_gain_fx.c b/lib_lc3plus/apply_global_gain_fx.c index 7c5220f10..a3299d863 100644 --- a/lib_lc3plus/apply_global_gain_fx.c +++ b/lib_lc3plus/apply_global_gain_fx.c @@ -11,7 +11,7 @@ void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 global_gain_idx, Word16 global_gain_off) { - Counter i; + Word32 i; #ifdef ENABLE_HR_MODE Word32 global_gain; #else diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c index 8092aa28e..46ad0a532 100644 --- a/lib_lc3plus/ari_codec.c +++ b/lib_lc3plus/ari_codec.c @@ -99,7 +99,7 @@ Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side_in, Word16 mask_side_i Dyn_Mem_Deluxe_In(Encoder_State_fx st; Word16 bp, bp_side, mask_side, extra_bits; Word32 a1, b1, a1_i, b1_i, a1_msb, b1_msb; Word16 lev1; Word16 nbits_side; Word16 tmp; - Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Counter i, n, k, lev;); + Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Word32 i, n, k, lev;); lsb = (Word16 *)scratchAlign(scratchBuffer, 0); /* size = 2 * lastnz */ @@ -777,8 +777,8 @@ void processAriDecoder_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Wor Word16 lsb_ind_c; Word16 * lsb_ind; Word16 tmp; - Counter n, k, lev; - Counter i; + Word32 n, k, lev; + Word32 i; Word16 max_lev = 14; #ifdef DYNMEM_COUNT @@ -1711,7 +1711,7 @@ void processAriDecoderScaling_fx( # endif Word16 dataLen, Word32 *data32, Word16 *data_e) { - Counter i; + Word32 i; # ifdef ENABLE_HR_MODE Dyn_Mem_Deluxe_In(Word16 shift; Word32 tmp, x_min, x_max;); @@ -1802,7 +1802,7 @@ Word16 find_last_nz_pair(const Word32 x[], Word16 length) Word16 find_last_nz_pair(const Word16 x[], Word16 length) #endif { - Dyn_Mem_Deluxe_In(Word16 last_nz, lobs[4]; Counter stage, i;); + Dyn_Mem_Deluxe_In(Word16 last_nz, lobs[4]; Word32 stage, i;); lobs[0] = 4; move16(); @@ -1866,7 +1866,7 @@ void write_bit_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 bit) void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, Word16 numbits) { - Dyn_Mem_Deluxe_In(Counter k; Word16 bit;); + Dyn_Mem_Deluxe_In(Word32 k; Word16 bit;); FOR (k = 0; k < numbits; k++) { @@ -1881,7 +1881,7 @@ void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, static __forceinline void write_indice_forward(UWord8 *ptr, Word16 bp, Word16 indice, Word16 numbits) { - Dyn_Mem_Deluxe_In(Counter k; Word16 bit, mask, tmp;); + Dyn_Mem_Deluxe_In(Word32 k; Word16 bit, mask, tmp;); tmp = (Word16)ptr[bp]; move16(); @@ -2093,7 +2093,7 @@ __forceinline Word16 read_bit(UWord8 *ptr, Word16 *bp, Word16 *mask) static __forceinline void ac_dec_init_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_side, Word16 *mask_side, Decoder_State_fx *st_fx) /* i/o: Decoder State */ { - Dyn_Mem_Deluxe_In(Counter i;); + Dyn_Mem_Deluxe_In(Word32 i;); st_fx->ac_low_fx = L_deposit_l(0); diff --git a/lib_lc3plus/basop_util_lc3plus.c b/lib_lc3plus/basop_util_lc3plus.c index 55a9b9eb1..e3ab30f70 100644 --- a/lib_lc3plus/basop_util_lc3plus.c +++ b/lib_lc3plus/basop_util_lc3plus.c @@ -856,7 +856,7 @@ Word16 BASOP_Util_Cmp_Mant32Exp_lc3plus /*!< o: flag: result of comparison */ * mantissa (Q31) * *----------------------------------------------------------------------------------*/ -Word32 Isqrt(Word32 x, /* mantissa */ +Word32 Isqrt_lc3plus(Word32 x, /* mantissa */ Word16 *x_e /* pointer to exponent */ ) { diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h index 99bc211a9..5f4f5c56b 100644 --- a/lib_lc3plus/basop_util_lc3plus.h +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -299,7 +299,7 @@ void Copy_Scale_sig_32(const Word32 x[], /* i : signal to scale input ); #endif -Word32 Isqrt(Word32 x, /* (i) Q31: normalized value (1.0 > x >= 0.5) */ +Word32 Isqrt_lc3plus(Word32 x, /* (i) Q31: normalized value (1.0 > x >= 0.5) */ Word16 *x_e /* (i/o) Q0 : pointer to exponent */ ); diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c index 05f7cce49..8ab047c81 100644 --- a/lib_lc3plus/cutoff_bandwidth.c +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -11,7 +11,7 @@ void process_cutoff_bandwidth(Word32 d_fx[], Word16 len, Word16 bw_bin) { - Counter i = 0; + Word32 i = 0; if (len > bw_bin){ /* roll off */ for (i = -1; i < 3; i++) { diff --git a/lib_lc3plus/dct4_fx.c b/lib_lc3plus/dct4_fx.c index af98a395d..9f12894f4 100644 --- a/lib_lc3plus/dct4_fx.c +++ b/lib_lc3plus/dct4_fx.c @@ -35,7 +35,7 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ Word32 accu3; Word32 accu4; - Counter i; + Word32 i; #ifdef ENABLE_HR_MODE const PWord32 *twiddle; diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c index 48512f9fe..572438615 100644 --- a/lib_lc3plus/dec_entropy.c +++ b/lib_lc3plus/dec_entropy.c @@ -26,7 +26,7 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 L, submodeLSB; Word32 tmp32, tmp32lim; Word16 gain_e, gain, submodeMSB, BER_detect; - Counter n; + Word32 n; UWord8 *ptr; ); diff --git a/lib_lc3plus/ltpf_coder_fx.c b/lib_lc3plus/ltpf_coder_fx.c index 212788d73..d17daa1b9 100644 --- a/lib_lc3plus/ltpf_coder_fx.c +++ b/lib_lc3plus/ltpf_coder_fx.c @@ -139,7 +139,7 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo shift = norm_l(prod); prod = L_shl_pos(prod, shift); prod_exp = sub(62, add(add(scale1, scale2), shift)); - inv = Isqrt(prod, &prod_exp); + inv = Isqrt_lc3plus(prod, &prod_exp); scale0 = norm_l(sum0); sum0 = L_shl_pos(sum0, scale0); prod = Mpy_32_32_lc3plus(sum0, inv); @@ -257,7 +257,7 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo shift = norm_l(prod); prod = L_shl_pos(prod, shift); prod_exp = sub(62, add(add(scale1, scale2), shift)); - inv = Isqrt(prod, &prod_exp); + inv = Isqrt_lc3plus(prod, &prod_exp); scale0 = norm_l(sum0); sum0 = L_shl_pos(sum0, scale0); prod = Mpy_32_32_lc3plus(sum0, inv); diff --git a/lib_lc3plus/olpa_fx.c b/lib_lc3plus/olpa_fx.c index a72d8b61c..a93a0ba25 100644 --- a/lib_lc3plus/olpa_fx.c +++ b/lib_lc3plus/olpa_fx.c @@ -176,7 +176,7 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] shift = norm_l(prod); prod = L_shl_pos(prod, shift); prod_exp = sub(62, add(add(scale1, scale2), shift)); - inv = Isqrt(prod, &prod_exp); + inv = Isqrt_lc3plus(prod, &prod_exp); scale0 = norm_l(sum0); sum0 = L_shl_pos(sum0, scale0); prod = Mpy_32_32_lc3plus(sum0, inv); @@ -225,7 +225,7 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] shift = norm_l(prod); prod = L_shl_pos(prod, shift); prod_exp = sub(62, add(add(scale1, scale2), shift)); - inv = Isqrt(prod, &prod_exp); + inv = Isqrt_lc3plus(prod, &prod_exp); scale0 = norm_l(sum0); sum0 = L_shl_pos(sum0, scale0); prod = Mpy_32_32_lc3plus(sum0, inv); diff --git a/lib_lc3plus/plc_xcorr_fx.c b/lib_lc3plus/plc_xcorr_fx.c index 720015295..1a4782c32 100644 --- a/lib_lc3plus/plc_xcorr_fx.c +++ b/lib_lc3plus/plc_xcorr_fx.c @@ -145,7 +145,7 @@ Word16 plc_norm_corr_blocks_fx( /* o: norm_corr range [-1 shift = norm_l(L_prod); L_prod = L_shl_pos(L_prod, shift); prod_exp = sub(62, add(add(scale1, scale2), shift)); - L_inv = Isqrt(L_prod, &prod_exp); + L_inv = Isqrt_lc3plus(L_prod, &prod_exp); L_tmp0 = L_shl_pos(L_tmp0, scale0); L_prod = Mpy_32_32_lc3plus(L_tmp0, L_inv); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 4a4cce092..faf696393 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -193,9 +193,9 @@ static ivas_error ivas_rend_initCrend_fx( test(); test(); - IF( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif ) { @@ -1835,9 +1835,9 @@ void ivas_rend_closeCldfbRend( pCldfbRend->hCldfbRend->hInputSetup = NULL; } - ivas_binRenderer_close( &pCldfbRend->hCldfbRend ); + ivas_binRenderer_close_fx( &pCldfbRend->hCldfbRend ); ivas_binaural_hrtf_close( &pCldfbRend->hHrtfFastConv ); - ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv ); + ivas_HRTF_fastconv_binary_close_fx( &pCldfbRend->hHrtfFastConv ); return; } @@ -2440,7 +2440,7 @@ ivas_error ivas_rend_crendProcessSplitBin( Word16 sf; Word16 pos_idx, output_frame; ivas_error error; - Word32 gain_lfe; + Word16 gain_lfe; Word32 tmpLfeBuffer[L_FRAME48k]; Word32 tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word32 *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; @@ -2601,7 +2601,7 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( Word16 sf; Word16 pos_idx; ivas_error error; - Word32 gain_lfe; + Word16 gain_lfe; Word32 tmpLfeBuffer[L_FRAME48k]; Word16 original_subframes_rendered, original_slots_rendered; Word32 tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 8ec066dc9..f430f073d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -113,7 +113,7 @@ static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBIN static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const Word16 num_freq_bands, const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME] /*q_inp*/[CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 decIm[] /*q_inp*/[CLDFB_NO_CHANNELS_MAX] ); #ifdef SPLIT_REND_WITH_HEAD_ROT -static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, Word16 q ); +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, Word16 q ); static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 Rmat[3][3], const Word16 subframe, const Word16 isHeadtracked, const Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, const Word32 *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData ); #else @@ -1343,12 +1343,11 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( Word16 q ) { Word16 ch, slot, bin; - Word16 nBins, shift; + Word16 nBins; Word32 IIReneLimiterFactor_fx; // Q26 Word32 qualityBasedSmFactor_fx; Word32 lowBitRateEQ_fx[CLDFB_NO_CHANNELS_MAX]; UWord8 applyLowBitRateEQ; - PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; IVAS_FORMAT ivas_format; Word32 ivas_total_brate; Word16 nchan_transport; @@ -1598,9 +1597,9 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( Word32 Rmat_fx[3][3], const int16_t subframe, const int16_t isHeadtracked, - Word32 *subFrameTotalEne_fx, + const Word32 *subFrameTotalEne_fx, Word16 *subFrameTotalEne_e, - Word32 *IIReneLimiter_fx, + const Word32 *IIReneLimiter_fx, const MASA_ISM_DATA_HANDLE hMasaIsmData ) { Word16 ch, bin; @@ -1655,6 +1654,8 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( move16(); } + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + /* Determine target covariance matrix containing target binaural properties */ FOR( bin = 0; bin < nBins; bin++ ) { @@ -3398,7 +3399,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 reverbIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const UWord8 recompute + const Word8 recompute #endif ) { @@ -6529,8 +6530,11 @@ static void ivas_masa_ext_rend_parambin_internal_fx( } } Word32 Rmat_fx[3][3]; - +#ifdef SPLIT_REND_WITH_HEAD_ROT + hDiracDecBin = hMasaExtRend->hDiracDecBin[0]; +#else hDiracDecBin = hMasaExtRend->hDiracDecBin; +#endif assert( hDiracDecBin ); hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; @@ -6768,9 +6772,9 @@ static void ivas_masa_ext_rend_parambin_internal_fx( assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); /* re-use input covariance for the side renderings */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - mvr2r( hMasaExtRend->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands ); + Copy32( hMasaExtRend->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands ); } Copy32( hMasaExtRend->hDiracDecBin[0]->ChCrossRe_fx, hDiracDecBin->ChCrossRe_fx, hSpatParamRendCom->num_freq_bands ); Copy32( hMasaExtRend->hDiracDecBin[0]->ChCrossIm_fx, hDiracDecBin->ChCrossIm_fx, hSpatParamRendCom->num_freq_bands ); diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index a3e833455..acd1621d6 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -34,6 +34,7 @@ #include #include "options.h" #include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include @@ -696,11 +697,20 @@ ivas_error ivas_orient_trk_SetReferenceRotation_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* check for Euler angle signaling */ + IF( EQ_32( refRot.w_fx, L_negate( 12582912 ) ) && EQ_16( refRot.q_fact, Q22 ) ) + { + Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot ); + modify_Quat_q_fx( &pOTR->refRot, &pOTR->refRot, Q29 ); + } +#else /* check for Euler angle signaling */ IF( EQ_32( refRot.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) { Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot ); } +#endif pOTR->refRot = refRot; return IVAS_ERR_OK; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index f20cab785..b27c0cd15 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -378,10 +378,10 @@ Word16 ivas_get_nchan_buffers_dec( { nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + else if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 51fca0ec8..9a4a1a279 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1618,14 +1618,6 @@ void QuatToRotMat( float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT -void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ -); -#endif void rotateAziEle( float azi_in, /* i : output elevation */ @@ -2049,7 +2041,7 @@ void ivas_rend_CldfbMultiBinRendProcess( Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 low_res_pre_rend_rot, const Word16 num_subframes, - Word16 *Q_in + const Word16 Q_in ); ivas_error ivas_rend_openCldfb( diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index c5d118858..c7d9c74e5 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -40,6 +40,7 @@ #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "prot_fx.h" @@ -340,10 +341,17 @@ ivas_error ivas_er_encoder_init( p_y_fx = reflections->shoebox_data.az_angle.data_fx[i]; // Q23 move32(); move32(); - - rad_el_angle = deg2rad_fx( p_x_fx ); // Q23 - rad_az_angle = deg2rad_fx( p_y_fx ); // Q23 - +#ifdef SPLIT_REND_WITH_HEAD_ROT + p_x_fx = L_shr( p_x_fx, 1 ); // Q22 + p_y_fx = L_shr( p_y_fx, 1 ); // Q22 +#endif + rad_el_angle = deg2rad_fx( p_x_fx ); // Q22 + rad_az_angle = deg2rad_fx( p_y_fx ); // Q22 + +#ifdef SPLIT_REND_WITH_HEAD_ROT + rad_el_angle = L_shl( rad_el_angle, 1 ); // Q23 + rad_az_angle = L_shl( rad_az_angle, 1 ); // Q23 +#endif rad_el_angle = L_shr( rad_el_angle, 10 ); // Q13 rad_az_angle = L_shr( rad_az_angle, 10 ); // Q13 diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 8651de7f7..f307e29f5 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -733,7 +733,7 @@ void rotateFrame_shd( /* calculate ambisonics rotation matrices for the previous and current frames */ #ifdef SPLIT_REND_WITH_HEAD_ROT - SHrotmatgen( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx[0], shd_rot_max_order ); + SHrotmatgen_fx( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx[0], shd_rot_max_order ); #else SHrotmatgen_fx( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx, shd_rot_max_order ); #endif @@ -795,7 +795,7 @@ void rotateFrame_shd( /* move Rmat to Rmat_prev */ FOR( i = 0; i < 3; i++ ) { - MVR2R_WORD32( + Copy32( hCombinedOrientationData->Rmat_fx[subframe_idx][i], #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev_fx[0][i], @@ -996,7 +996,7 @@ void rotateFrame_sd( /* move Rmat to Rmat_prev */ FOR( i = 0; i < 3; i++ ) { - MVR2R_WORD32( + Copy32( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx][i], // Q30 #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev_fx[0][i], @@ -1008,7 +1008,7 @@ void rotateFrame_sd( /* copy to output */ FOR( ch_out = 0; ch_out < nchan; ch_out++ ) { - MVR2R_WORD32( &output_tmp_fx[ch_out][offset], &output[ch_out][offset], subframe_len ); // Q11 + Copy32( &output_tmp_fx[ch_out][offset], &output[ch_out][offset], subframe_len ); // Q11 } pop_wmops(); @@ -2461,11 +2461,11 @@ void ivas_combined_orientation_update_index( Word16 exp, div_result; IF( hCombinedOrientationData != NULL ) { - IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) #ifdef SPLIT_REND_WITH_HEAD_ROT - || hCombinedOrientationData->sr_low_res_flag + IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) || hCombinedOrientationData->sr_low_res_flag ) +#else + IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) ) #endif - ) { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index b33ce2942..448375dfd 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4546,7 +4546,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && - shr( i_mult( inputAudio.config.numSamplesPerChannel, 1000 ), cldfb2tdShift ) != i_mult( i_mult( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) + NE_32( L_shr( L_mult0( inputAudio.config.numSamplesPerChannel, 1000 ), cldfb2tdShift ), (Word32) W_mult0_32_32( L_mult0( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) ) #else IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( L_mult0( inputAudio.config.numSamplesPerChannel, 1000 ), (Word32) W_mult0_32_32( L_mult0( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) ) @@ -6250,6 +6250,7 @@ static ivas_error renderIsmToSplitBinaural( { ivas_error error; Word32 tmpProcessing[MAX_NUM_OBJECTS][L_FRAME48k]; + Word32 *pTmpProcessing[MAX_NUM_OBJECTS]; Word16 pos_idx; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; const SPLIT_REND_WRAPPER *pSplitRendWrapper; @@ -6258,13 +6259,14 @@ static ivas_error renderIsmToSplitBinaural( Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; Word16 output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; - Word16 ism_md_subframe_update_ext; + Word16 ism_md_subframe_update_ext, exp; push_wmops( "renderIsmToSplitBinaural" ); pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; + exp = *outAudio.pq_fact; /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ ism_md_subframe_update_ext = (Word16) Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ); @@ -6287,6 +6289,12 @@ static ivas_error renderIsmToSplitBinaural( /* Copy input audio to a processing buffer. */ copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpProcessing ); + FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) + { + pTmpProcessing[i] = tmpProcessing[i]; + } + + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { /* Update head positions */ @@ -6315,13 +6323,33 @@ static ivas_error renderIsmToSplitBinaural( } } + + FOR( i = 0; i < MAX_NUM_OBJECTS; ++i ) + { + Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ + } /* Render */ - IF( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[sub( pos_idx, 1 )], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, - NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[sub( pos_idx, 1 )], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, + NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing, &exp ) ) != IVAS_ERR_OK ) { return error; } + FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ + } + IF( ismInput->hReverb != NULL ) + { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel; j++ ) + { + tmpProcessing[i][j] = L_shl( tmpProcessing[i][j], Q2 ); /* Q(exp + 2) */ + move32(); + } + } + } /* Copy rendered audio to tmp storage buffer. Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ Copy32( tmpProcessing[0], tmpBinaural[i_mult( 2, pos_idx )], output_frame ); @@ -6612,7 +6640,7 @@ static ivas_error renderLfeToBinaural_fx( IF( mcInput->base.ctx.pSplitRendWrapper != NULL ) { num_poses = mcInput->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; - Move16(); + move16(); } ELSE { @@ -6854,14 +6882,17 @@ static ivas_error renderMcToBinauralRoom( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), + IVAS_ERR_OK ) ) #else + IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx, -#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -6966,14 +6997,17 @@ static ivas_error renderMcCustomLsToBinauralRoom( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), + IVAS_ERR_OK ) ) #else + IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx, -#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -7222,11 +7256,19 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ + } /* Render */ - IF( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK ) { return error; } + FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ + } /* Copy rendered audio to tmp storage buffer. Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ @@ -7569,7 +7611,7 @@ static ivas_error renderSbaToMultiBinauralCldfb( copyBufferToCLDFBarray_fx( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); ivas_rend_CldfbMultiBinRendProcess( sbaInput->cldfbRendWrapper.hCldfbRend, sbaInput->base.ctx.pCombinedOrientationData, &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, - Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes, &Q_in ); + Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes, Q_in ); return IVAS_ERR_OK; } @@ -7805,15 +7847,19 @@ static ivas_error renderSbaToBinauralRoom( /* copy input for in-place rotation */ Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, i_mult( tmpRotBuffer.config.numChannels, tmpRotBuffer.config.numSamplesPerChannel ) ); +#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, -#ifdef SPLIT_REND_WITH_HEAD_ROT sbaInput->rot_gains_prev_fx[0], + tmpRotBuffer ) ), + IVAS_ERR_OK ) ) #else + IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx, -#endif tmpRotBuffer ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -7909,7 +7955,7 @@ static ivas_error renderInputSba( #ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; - IF( NE_16( shl( sbaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) && + IF( NE_32( L_shl( sbaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else IF( NE_32( sbaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) @@ -8290,7 +8336,7 @@ static ivas_error renderInputMasa( #ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; - IF( ( NE_16( shl( masaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) ) && + IF( ( NE_32( L_shl( masaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else IF( NE_32( masaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) @@ -8972,7 +9018,7 @@ static ivas_error getSamplesInternal( IF( NE_16( pcm_out_flag, 0 ) ) { - accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); + accumulate2dArrayToBuffer_fx( tmpBinaural_buff, &outAudio ); } } #endif @@ -9156,7 +9202,7 @@ IVAS_REND_openCldfb( for ( n = 0; n < num_in_chs; n++ ) { - if ( ( error = openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb_ivas_fx( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -9168,7 +9214,7 @@ IVAS_REND_openCldfb( for ( n = 0; n < num_out_chs; n++ ) { - if ( ( error = openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb_ivas_fx( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -9222,15 +9268,14 @@ void IVAS_REND_closeCldfb( *-------------------------------------------------------------------*/ void IVAS_REND_cldfbAnalysis_ts_wrapper( - const float *timeIn, /* i : time buffer */ - float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const int16_t samplesToProcess, /* i : samples to process */ - IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filterbank state */ + const Word32 *timeIn, /* i : time buffer */ + Word32 realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filterbank state */ Word16 Q_in, Word16 *Q_out ) { - cldfbAnalysis_ts( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb ); Word16 Q_cldfb = Q_in; cldfbAnalysis_ts_fx_fixed_q( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb, diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 59f0ea4dd..6d7ce0bdf 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -386,11 +386,11 @@ void IVAS_REND_closeCldfb( ); void IVAS_REND_cldfbAnalysis_ts_wrapper( - const float *timeIn, /* i : time buffer */ - float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const int16_t samplesToProcess, /* i : samples to process */ - IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filterbank state */ + const Word32 *timeIn, /* i : time buffer */ + Word32 realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filterbank state */ Word16 Q_in, Word16 *Q_out ); diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 987d40c85..b13d99045 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -121,15 +121,32 @@ ivas_error HeadRotationFileReading( ( headRotReader->frameCounter )++; - pQuaternion->w = w; - pQuaternion->x = x; - pQuaternion->y = y; - pQuaternion->z = z; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( w == -3.0f ) + { + pQuaternion->w_fx = floatToFixed_32( w, Q22 ); + pQuaternion->x_fx = floatToFixed_32( x, Q22 ); + pQuaternion->y_fx = floatToFixed_32( y, Q22 ); + pQuaternion->z_fx = floatToFixed_32( z, Q22 ); + pQuaternion->q_fact = Q22; + } + else + { + pQuaternion->w_fx = floatToFixed_32( w, Q31 ); + pQuaternion->x_fx = floatToFixed_32( x, Q31 ); + pQuaternion->y_fx = floatToFixed_32( y, Q31 ); + pQuaternion->z_fx = floatToFixed_32( z, Q31 ); + pQuaternion->q_fact = Q31; + } +#else pQuaternion->w_fx = floatToFixed_32( w, Q31 ); pQuaternion->x_fx = floatToFixed_32( x, Q31 ); pQuaternion->y_fx = floatToFixed_32( y, Q31 ); pQuaternion->z_fx = floatToFixed_32( z, Q31 ); pQuaternion->q_fact = Q31; +#endif + if ( pPos != NULL ) { pPos->x = posx; -- GitLab From cb925aad93a92bd6fa2edc45b8820b3afa8bef14 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 12:37:25 +1100 Subject: [PATCH 030/329] windows compilation fixes, temp fix in wmc_auto.h --- apps/isar_post_rend.c | 2 +- apps/renderer.c | 22 +- lib_com/ivas_limiter.c | 1 + lib_com/ivas_prot.h | 16 +- lib_com/ivas_rom_com.c | 819 +++++++++++++++++++ lib_com/ivas_rom_com.h | 3 + lib_com/lsf_tools_fx.c | 4 +- lib_debug/wmc_auto.h | 56 +- lib_dec/ivas_init_dec.c | 2 +- lib_isar/isar_prot.h | 14 - lib_isar/isar_splitRenderer_utils.c | 111 --- lib_lc3plus/defines.h | 26 + lib_rend/ivas_dirac_dec_binaural_functions.c | 4 +- lib_rend/ivas_rom_rend.c | 817 ------------------ lib_rend/ivas_rom_rend.h | 2 - lib_rend/lib_rend.c | 10 +- lib_rend/lib_rend.h | 2 +- 17 files changed, 914 insertions(+), 997 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index c28a5b811..278503690 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1047,7 +1047,7 @@ int main( IVAS_QUATERNION headRot; IVAS_VECTOR3 Pos; - IF( ( error = HeadRotationFileReading_fx( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) + IF( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); exit( -1 ); diff --git a/apps/renderer.c b/apps/renderer.c index 09b1425ce..a41b633e2 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1373,7 +1373,7 @@ int main( #endif ); - if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); exit( -1 ); @@ -1414,7 +1414,7 @@ int main( #endif ); - if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); exit( -1 ); @@ -1576,7 +1576,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT Word16 Q_out; *outBuffer.pq_fact = 16 - ( gd_bits ); - convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, inBuffer.config.is_cldfb, cldfbAna, *outBuffer.pq_fact, &Q_out ); + convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact, inBuffer.config.is_cldfb, cldfbAna, &Q_out ); *outBuffer.pq_fact = Q_out; #else *outBuffer.pq_fact = 16 - ( gd_bits ); @@ -3854,7 +3854,7 @@ static void convertInputBuffer_fx( IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx], &Word32Buffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], &Word32Buffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], - numCldfbBands, cldfbAna[chnl], Q11, *out_q_factor ); + numCldfbBands, cldfbAna[chnl], Q11, out_q_factor ); } } } @@ -3916,7 +3916,7 @@ static void convertOutputBuffer_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT IF( cldfb_in_flag ) { - Word16 slotIdx, numCldfbBands, numPcmSamples, b, temp_out_q; + Word16 slotIdx, numCldfbBands, numPcmSamples, b, temp_out_q = 0; Word32 fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; Word32 re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; Word32 im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; @@ -3960,7 +3960,17 @@ static void convertOutputBuffer_fx( { FOR( chnl = 0; chnl < numChannels; ++chnl ) { - intBuffer[i] = (Word16) L_shl( fIn[chnl][smpl], sub( out_q, temp_out_q ) ); + temp_fx = L_add( fIn[chnl][smpl], lshl( 1, ( temp_out_q - 1 ) ) ); + temp_fx1 = L_shr( temp_fx, temp_out_q ); + IF( GT_32( temp_fx1, IVAS_MAX16B_FX ) ) + { + temp_fx1 = IVAS_MAX16B_FX; + } + ELSE IF( LT_32( temp_fx1, IVAS_MIN16B_FX ) ) + { + temp_fx1 = IVAS_MIN16B_FX; + } + intBuffer[i] = (Word16) temp_fx1; ++i; } } diff --git a/lib_com/ivas_limiter.c b/lib_com/ivas_limiter.c index 17211d1c6..e0ec108a5 100644 --- a/lib_com/ivas_limiter.c +++ b/lib_com/ivas_limiter.c @@ -36,6 +36,7 @@ #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" +#include "ivas_rom_com.h" #include "wmc_auto.h" #include #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e7827023b..d99f58db1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3296,26 +3296,26 @@ void ivas_td_decorr_get_ducking_gains( ); #define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ - out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); MAC(1); MULT(1); \ - out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); MAC(1); MULT(1); + out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ + out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); #define IVAS_CALCULATE_ABS( re, im, out ) \ - out = sqrtf( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); SQRT(1); + out = sqrtf( ( re * re ) + ( im * im ) ); #define IVAS_CALCULATE_RABS( re, out ) \ - out = sqrtf( re * re ); MULT(1); SQRT(1); + out = sqrtf( re * re ); #define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ - out = (float) ( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); + out = (float) ( ( re * re ) + ( im * im ) ); #define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); DMULT(1); \ + out1_re = ( in1_re * in2_re ); \ #define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ - out = (float) ( re * re ); MULT(1); + out = (float) ( re * re ); #define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); MULT(1); + out1_re = ( in1_re * in2_re ); /* PCA */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 5a864835c..6023812c8 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2901,3 +2901,822 @@ const Word16 ivas_param_upmx_mx_qmap[33] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + + +const Word32 release_cnst_table[4][201] = // Q31 + { + { + 1913946752, + 1919716352, + 1925351680, + 1930855552, + 1936230784, + 1941479808, + 1946605312, + 1951609728, + 1956495744, + 1961265792, + 1965922304, + 1970467584, + 1974904320, + 1979234560, + 1983460736, + 1987585024, + 1991609856, + 1995537280, + 1999369344, + 2003108480, + 2006756480, + 2010315520, + 2013787520, + 2017174528, + 2020478464, + 2023701248, + 2026844672, + 2029910656, + 2032900992, + 2035817344, + 2038661376, + 2041435008, + 2044139648, + 2046777088, + 2049348864, + 2051856384, + 2054301440, + 2056685312, + 2059009536, + 2061275520, + 2063484672, + 2065638272, + 2067737856, + 2069784448, + 2071779584, + 2073724416, + 2075620096, + 2077467904, + 2079268992, + 2081024512, + 2082735488, + 2084403200, + 2086028416, + 2087612544, + 2089156352, + 2090660864, + 2092127104, + 2093555968, + 2094948480, + 2096305408, + 2097627776, + 2098916352, + 2100172032, + 2101395584, + 2102587776, + 2103749504, + 2104881408, + 2105984384, + 2107059072, + 2108106112, + 2109126400, + 2110120448, + 2111088896, + 2112032512, + 2112951808, + 2113847552, + 2114720128, + 2115570304, + 2116398592, + 2117205504, + 2117991552, + 2118757504, + 2119503616, + 2120230400, + 2120938496, + 2121628288, + 2122300288, + 2122954880, + 2123592576, + 2124213760, + 2124818944, + 2125408384, + 2125982592, + 2126541952, + 2127086848, + 2127617664, + 2128134656, + 2128638336, + 2129128832, + 2129606784, + 2130072192, + 2130525568, + 2130967296, + 2131397376, + 2131816448, + 2132224640, + 2132622080, + 2133009408, + 2133386496, + 2133753856, + 2134111744, + 2134460288, + 2134799744, + 2135130368, + 2135452416, + 2135766144, + 2136071680, + 2136369152, + 2136659072, + 2136941312, + 2137216256, + 2137484160, + 2137744896, + 2137998976, + 2138246400, + 2138487424, + 2138722176, + 2138950656, + 2139173376, + 2139390208, + 2139601408, + 2139807104, + 2140007424, + 2140202624, + 2140392576, + 2140577664, + 2140758016, + 2140933504, + 2141104512, + 2141271040, + 2141433216, + 2141591168, + 2141745024, + 2141894912, + 2142040832, + 2142182912, + 2142321408, + 2142456192, + 2142587392, + 2142715264, + 2142839808, + 2142961152, + 2143079296, + 2143194240, + 2143306240, + 2143415424, + 2143521664, + 2143625216, + 2143725952, + 2143824128, + 2143919744, + 2144012800, + 2144103424, + 2144191744, + 2144277760, + 2144361472, + 2144443136, + 2144522496, + 2144599936, + 2144675200, + 2144748544, + 2144820096, + 2144889600, + 2144957440, + 2145023488, + 2145087744, + 2145150336, + 2145211264, + 2145270656, + 2145328512, + 2145384832, + 2145439616, + 2145493120, + 2145545088, + 2145595776, + 2145645056, + 2145693184, + 2145739904, + 2145785472, + 2145829888, + 2145873152, + 2145915136, + 2145956224, + 2145996032, + 2146034944, + 2146072832, + 2146109696, + 2146145664, + 2146180608, + 2146214656, + 2146247808, + }, + { + 2027355264, + 2030408704, + 2033386624, + 2036290944, + 2039123328, + 2041885440, + 2044578944, + 2047205376, + 2049766528, + 2052263680, + 2054698496, + 2057072384, + 2059387008, + 2061643520, + 2063843328, + 2065987968, + 2068078720, + 2070116864, + 2072103552, + 2074040192, + 2075927936, + 2077767936, + 2079561472, + 2081309568, + 2083013376, + 2084673920, + 2086292352, + 2087869696, + 2089406976, + 2090905216, + 2092365184, + 2093788032, + 2095174528, + 2096525824, + 2097842432, + 2099125632, + 2100375808, + 2101594240, + 2102781312, + 2103938048, + 2105065216, + 2106163456, + 2107233536, + 2108276096, + 2109292032, + 2110281728, + 2111246080, + 2112185728, + 2113101056, + 2113992960, + 2114861824, + 2115708288, + 2116532992, + 2117336448, + 2118119168, + 2118881792, + 2119624704, + 2120348416, + 2121053440, + 2121740288, + 2122409344, + 2123061120, + 2123696128, + 2124314624, + 2124917120, + 2125504128, + 2126075776, + 2126632832, + 2127175296, + 2127703808, + 2128218624, + 2128720000, + 2129208448, + 2129684352, + 2130147712, + 2130599168, + 2131038976, + 2131467264, + 2131884416, + 2132290816, + 2132686592, + 2133072256, + 2133447680, + 2133813504, + 2134169856, + 2134516864, + 2134854784, + 2135184000, + 2135504640, + 2135816960, + 2136121216, + 2136417536, + 2136706048, + 2136987136, + 2137260928, + 2137527552, + 2137787264, + 2138040192, + 2138286592, + 2138526464, + 2138760192, + 2138987776, + 2139209472, + 2139425408, + 2139635712, + 2139840512, + 2140039936, + 2140234240, + 2140423424, + 2140607744, + 2140787200, + 2140962048, + 2141132288, + 2141298048, + 2141459584, + 2141616896, + 2141769984, + 2141919232, + 2142064512, + 2142205952, + 2142343808, + 2142478080, + 2142608768, + 2142736128, + 2142860032, + 2142980864, + 2143098368, + 2143212928, + 2143324544, + 2143433088, + 2143538944, + 2143641984, + 2143742336, + 2143840000, + 2143935232, + 2144027904, + 2144118144, + 2144206080, + 2144291712, + 2144375168, + 2144456320, + 2144535424, + 2144612480, + 2144687488, + 2144760448, + 2144831616, + 2144900992, + 2144968448, + 2145034112, + 2145098112, + 2145160448, + 2145221248, + 2145280256, + 2145337856, + 2145393920, + 2145448576, + 2145501696, + 2145553536, + 2145603968, + 2145653120, + 2145700992, + 2145747456, + 2145792896, + 2145837056, + 2145880064, + 2145922048, + 2145962880, + 2146002560, + 2146041344, + 2146078976, + 2146115712, + 2146151424, + 2146186240, + 2146220160, + 2146253184, + 2146285312, + 2146316672, + 2146347136, + 2146376832, + 2146405760, + 2146433920, + 2146461440, + 2146488192, + 2146514176, + 2146539520, + 2146564224, + 2146588160, + 2146611584, + 2146634368, + 2146656640, + 2146678272, + 2146699264, + 2146719744, + 2146739712, + 2146759168, + 2146778112, + 2146796544, + 2146814464, + 2146832000, + 2146849024, + 2146865664, + }, + { + 2086555136, + 2088125824, + 2089656576, + 2091148416, + 2092602240, + 2094018944, + 2095399680, + 2096745088, + 2098056192, + 2099333888, + 2100578816, + 2101792000, + 2102974080, + 2104125824, + 2105248128, + 2106341760, + 2107407232, + 2108445440, + 2109456896, + 2110442496, + 2111402624, + 2112338176, + 2113249664, + 2114137728, + 2115002880, + 2115845760, + 2116666880, + 2117466880, + 2118246272, + 2119005568, + 2119745280, + 2120465920, + 2121167872, + 2121851776, + 2122517888, + 2123166976, + 2123799168, + 2124414976, + 2125014912, + 2125599360, + 2126168704, + 2126723200, + 2127263360, + 2127789568, + 2128302208, + 2128801408, + 2129287808, + 2129761536, + 2130222976, + 2130672512, + 2131110272, + 2131536768, + 2131952128, + 2132356736, + 2132750848, + 2133134720, + 2133508736, + 2133872896, + 2134227584, + 2134573184, + 2134909696, + 2135237504, + 2135556736, + 2135867648, + 2136170624, + 2136465536, + 2136752896, + 2137032832, + 2137305344, + 2137570816, + 2137829376, + 2138081280, + 2138326528, + 2138565504, + 2138798080, + 2139024768, + 2139245440, + 2139460480, + 2139669888, + 2139873792, + 2140072320, + 2140265856, + 2140454144, + 2140637696, + 2140816384, + 2140990464, + 2141159936, + 2141325056, + 2141485824, + 2141642368, + 2141794944, + 2141943424, + 2142088064, + 2142228992, + 2142366208, + 2142499840, + 2142630016, + 2142756736, + 2142880128, + 2143000448, + 2143117440, + 2143231488, + 2143342592, + 2143450752, + 2143556096, + 2143658624, + 2143758592, + 2143855872, + 2143950592, + 2144043008, + 2144132864, + 2144220416, + 2144305664, + 2144388608, + 2144469504, + 2144548224, + 2144624896, + 2144699648, + 2144772352, + 2144843264, + 2144912256, + 2144979328, + 2145044864, + 2145108480, + 2145170560, + 2145231104, + 2145289856, + 2145347200, + 2145403008, + 2145457408, + 2145510400, + 2145561984, + 2145612160, + 2145661056, + 2145708672, + 2145755136, + 2145800192, + 2145844224, + 2145887104, + 2145928832, + 2145969408, + 2146008960, + 2146047616, + 2146085120, + 2146121600, + 2146157184, + 2146191872, + 2146225664, + 2146258560, + 2146290560, + 2146321792, + 2146352128, + 2146381696, + 2146410496, + 2146438528, + 2146465920, + 2146492416, + 2146518400, + 2146543616, + 2146568192, + 2146592128, + 2146615424, + 2146638080, + 2146660224, + 2146681728, + 2146702720, + 2146723072, + 2146743040, + 2146762368, + 2146781184, + 2146799616, + 2146817408, + 2146834816, + 2146851840, + 2146868352, + 2146884352, + 2146900096, + 2146915328, + 2146930176, + 2146944640, + 2146958720, + 2146972416, + 2146985856, + 2146998784, + 2147011456, + 2147023872, + 2147035904, + 2147047552, + 2147058944, + 2147070080, + 2147080832, + 2147091456, + 2147101696, + 2147111680, + 2147121408, + 2147130880, + 2147140096, + 2147149056, + 2147157760, + 2147166336, + 2147174656, + }, + { + 2106670080, + 2107727232, + 2108757120, + 2109760640, + 2110738432, + 2111691008, + 2112619136, + 2113523328, + 2114404352, + 2115262592, + 2116098816, + 2116913408, + 2117707136, + 2118480256, + 2119233536, + 2119967360, + 2120682240, + 2121378688, + 2122057088, + 2122717952, + 2123361792, + 2123988992, + 2124599936, + 2125195136, + 2125774848, + 2126339584, + 2126889728, + 2127425536, + 2127947520, + 2128456064, + 2128951296, + 2129433856, + 2129903744, + 2130361600, + 2130807424, + 2131241728, + 2131664768, + 2132076928, + 2132478208, + 2132869248, + 2133250048, + 2133620992, + 2133982208, + 2134334080, + 2134676864, + 2135010688, + 2135335936, + 2135652608, + 2135961088, + 2136261504, + 2136554112, + 2136839168, + 2137116800, + 2137387136, + 2137650560, + 2137907072, + 2138156928, + 2138400256, + 2138637184, + 2138867968, + 2139092864, + 2139311744, + 2139524992, + 2139732736, + 2139934976, + 2140131968, + 2140323840, + 2140510720, + 2140692736, + 2140870016, + 2141042688, + 2141210752, + 2141374592, + 2141534080, + 2141689344, + 2141840640, + 2141987968, + 2142131456, + 2142271232, + 2142407424, + 2142539904, + 2142669056, + 2142794752, + 2142917248, + 2143036544, + 2143152640, + 2143265792, + 2143375872, + 2143483264, + 2143587712, + 2143689472, + 2143788544, + 2143885056, + 2143979136, + 2144070656, + 2144159872, + 2144246656, + 2144331264, + 2144413568, + 2144493824, + 2144571904, + 2144647936, + 2144722048, + 2144794240, + 2144864512, + 2144932864, + 2144999552, + 2145064448, + 2145127680, + 2145189248, + 2145249152, + 2145307520, + 2145364480, + 2145419776, + 2145473792, + 2145526272, + 2145577472, + 2145627264, + 2145675776, + 2145723008, + 2145768960, + 2145813760, + 2145857408, + 2145899904, + 2145941376, + 2145981696, + 2146020864, + 2146059136, + 2146096384, + 2146132608, + 2146167936, + 2146202368, + 2146235776, + 2146268416, + 2146300160, + 2146331136, + 2146361216, + 2146390528, + 2146419200, + 2146446976, + 2146474112, + 2146500480, + 2146526208, + 2146551168, + 2146575488, + 2146599296, + 2146622464, + 2146644864, + 2146666880, + 2146688128, + 2146708992, + 2146729216, + 2146748928, + 2146768128, + 2146786816, + 2146805120, + 2146822784, + 2146840064, + 2146856960, + 2146873344, + 2146889216, + 2146904832, + 2146919936, + 2146934656, + 2146948992, + 2146962944, + 2146976640, + 2146989824, + 2147002752, + 2147015296, + 2147027584, + 2147039488, + 2147051136, + 2147062400, + 2147073408, + 2147084160, + 2147094528, + 2147104768, + 2147114624, + 2147124352, + 2147133696, + 2147142912, + 2147151744, + 2147160448, + 2147168896, + 2147177088, + 2147185152, + 2147192960, + 2147200512, + 2147207936, + 2147215104, + 2147222144, + 2147229056, + 2147235712, + 2147242112, + 2147248384, + 2147254656, + 2147260544, + 2147266432, + 2147272064, + 2147277568, + }, + + + }; \ No newline at end of file diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index b58e183eb..1cde96510 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -326,5 +326,8 @@ extern const Word16 sns_1st_means_32k[2][16]; extern const Word16 ivas_param_upmx_mx_qmap[33]; + +extern const Word32 release_cnst_table[4][201]; // Q31 + /* IVAS_ROM_COM_H */ #endif diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index b99fc4753..c2ec76aa5 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -4286,7 +4286,7 @@ void dctT2_N_apply_matrix_fx( *pt_y = L_add( *pt_y, Mpy_32_32( ( *pt_x++ ), ( *pt_A ) ) ); move32(); pt_A += mat_step_col; /* step +maxtrunc or +1 */ /* ptr indexing*/ - MAC( 1 ); + MAC_C( 1 ); #undef WMC_TOOL_SKIP } pt_y++; @@ -4338,7 +4338,7 @@ void extend_dctN_input_fx( ext_sig[i] = L_add( ext_sig[i], Mpy_32_32( dct_input[j], ptr[i_rev][j] ) ); /* sum up scaled and extended basis vector */ // Q31 + Q - Q31 -> Q move32(); - MAC( 1 ); + MAC_C( 1 ); #undef WMC_TOOL_SKIP } } diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 59bbc5bbf..64e2c751a 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -34,7 +34,7 @@ #define ENH_64_BIT_OPERATOR #define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR -#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ #define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */ #ifdef WMOPS @@ -123,7 +123,7 @@ void update_mem( void ); ops_cnt += ( _MULT_C * ( x ) ); \ inst_cnt[_MULT] += ( x ); \ } -#define MAC( x ) \ +#define MAC_C( x ) \ { \ ops_cnt += ( _MAC_C * ( x ) ); \ inst_cnt[_MAC] += ( x ); \ @@ -258,7 +258,7 @@ void update_mem( void ); { \ ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ inst_cnt[_TRANS] += ( x ); \ - } + } #else @@ -273,7 +273,7 @@ extern int cntr_push_pop; #define ADD( x ) #define ABS( x ) #define MULT( x ) -#define MAC( x ) +#define MAC_C( x ) #define MOVE( x ) #define STORE( x ) #define LOGIC( x ) @@ -335,29 +335,29 @@ extern int cntr_push_pop; #endif /* Define all Macros without '{' & '}' (None of these should be called externally!) */ -#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) -#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) -#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) -#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) -#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) -#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) -#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) -#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) -#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) -#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) -#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) -#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) #define POWER_( x ) TRANS_( x ) #define LOG_( x ) TRANS_( x ) -#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) -#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) -#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) #ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION -#define FUNC_( x ) ( x ) +#define FUNC_( x ) ( x ) #else -#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) #endif -#define MISC_( x ) ABS_( x ) +#define MISC_( x ) ABS_( x ) /* Math Operations */ #define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) @@ -401,8 +401,8 @@ extern int cntr_push_pop; #define frexp_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexp ) #define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf ) -/* the macros below are instrumented versions of user-defined macros that might be used in the source code - representing some well-known and recognized mathematical operations (that are not defined in math.h) +/* the macros below are instrumented versions of user-defined macros that might be used in the source code + representing some well-known and recognized mathematical operations (that are not defined in math.h) Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */ #define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) @@ -928,7 +928,7 @@ typedef struct unsigned int Madd_32_32_r; /* Complexity Weight of 1 */ unsigned int Msub_32_32; /* Complexity Weight of 1 */ unsigned int Msub_32_32_r; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR unsigned int UL_addNs; /* Complexity Weight of 1 */ @@ -938,7 +938,7 @@ typedef struct unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */ unsigned int norm_ul_float; /* Complexity Weight of 1 */ unsigned int UL_deposit_l; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS unsigned int LT_16; /* Complexity Weight of 1 */ @@ -1095,7 +1095,9 @@ void incrIf( const char *func_name ); #ifndef WMOPS #define ELSE else #else /* ifndef WMOPS */ -#define ELSE else if ( incrElse( __func__ ), 0 ); else +#define ELSE \ + else if ( incrElse( __func__ ), 0 ); \ + else void incrElse( const char *func_name ); #endif /* ifndef WMOPS */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 29aacd01a..9c951badf 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -203,7 +203,7 @@ static ivas_error ivas_dec_reconfig_split_rend( { st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; move32(); - ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] ); } } } diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 331eaadf3..1f2009b66 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -438,20 +438,6 @@ void lc3plusTimeAlignCldfbPoseCorr( SPLIT_REND_WRAPPER *hSplitBin, Word16 *Q_in ); #endif -void set16_fx( - Word16 y[], /* i/o: Vector to set */ - const Word16 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -); - -void set32_fx( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -); - -Word16 ceil_log_2( - UWord64 val ); void ivas_cmult_fix( Word32 in1_re_fx, Word16 exp_re1, Word32 in1_im_fx, Word16 exp_im1, Word32 in2_re_fx, Word16 exp_re2, Word32 in2_im_fx, Word16 exp_im2, Word32 *out1_re_fx, Word32 *out1_im_fx, Word16 *exp_out1_re, Word16 *exp_out1_im ); diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 3e2dd1f41..44b3822a7 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -1561,116 +1561,5 @@ Word32 get_bit( return L_and( state, ( L_shl( 1, (Word16) bit_id ) ) ); } -void set16_fx( - Word16 y[], /* i/o: Vector to set */ - const Word16 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -) -{ - Word16 i; - - for ( i = 0; i < N; i++ ) - { - y[i] = a; - } - - return; -} - -void set32_fx( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Length of the vector */ -) -{ - Word16 i; - - FOR( i = 0; i < N; i++ ) - { - y[i] = a; - move32(); - } - - return; -} -/*-------------------------------------------------------------------* - * ceil_log_2() - * - * calculates ceil(log2(val)) - *-------------------------------------------------------------------*/ - -Word16 ceil_log_2( - UWord64 val ) -{ - - IF( val <= 0 ) - { - assert( 0 ); - } - return val <= 1 ? 0 : val <= 2 ? 1 - : val <= 4 ? 2 - : val <= 8 ? 3 - : val <= 16 ? 4 - : val <= 32 ? 5 - : val <= 64 ? 6 - : val <= 128 ? 7 - : val <= 256 ? 8 - : val <= 512 ? 9 - : val <= 1024 ? 10 - : val <= 2048 ? 11 - : val <= 4096 ? 12 - : val <= 8192 ? 13 - : val <= 16384 ? 14 - : val <= 32768 ? 15 - : val <= 65536 ? 16 - : val <= 131072 ? 17 - : val <= 262144 ? 18 - : val <= 524288 ? 19 - : val <= 1048576 ? 20 - : val <= 2097152 ? 21 - : val <= 4194304 ? 22 - : val <= 8388608 ? 23 - : val <= 16777216 ? 24 - : val <= 33554432 ? 25 - : val <= 67108864 ? 26 - : val <= 134217728 ? 27 - : val <= 268435456 ? 28 - : val <= 536870912 ? 29 - : val <= 1073741824 ? 30 - : val <= 2147483648 ? 31 - : val <= 4294967296 ? 32 - : val <= 8589934592 ? 33 - : val <= 17179869184 ? 34 - : val <= 34359738368 ? 35 - : val <= 68719476736 ? 36 - : val <= 137438953472 ? 37 - : val <= 274877906944 ? 38 - : val <= 549755813888 ? 39 - : val <= 1099511627776 ? 40 - : val <= 2199023255552 ? 41 - : val <= 4398046511104 ? 42 - : val <= 8796093022208 ? 43 - : val <= 17592186044416 ? 44 - : val <= 35184372088832 ? 45 - : val <= 70368744177664 ? 46 - : val <= 140737488355328 ? 47 - : val <= 281474976710656 ? 48 - : val <= 562949953421312 ? 49 - : val <= 1125899906842624 ? 50 - : val <= 2251799813685248 ? 51 - : val <= 4503599627370496 ? 52 - : val <= 9007199254740992 ? 53 - : val <= 18014398509481984 ? 54 - : val <= 36028797018963968 ? 55 - : val <= 72057594037927936 ? 56 - : val <= 144115188075855872 ? 57 - : val <= 288230376151711744 ? 58 - : val <= 576460752303423488 ? 59 - : val <= 1152921504606846976 ? 60 - : val <= 2305843009213693952 ? 61 - : val <= 4611686018427387904 ? 62 - : val <= 9223372036854775807 ? 63 - : 64; -} #endif diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index c9909ddf2..f468568a9 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -731,4 +731,30 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger /* some configurations leave empty translation units. */ extern int fix_empty_translation_unit_warning; +#define FIX_IVAS_LC3PLUS_DUPLICATES +#ifdef FIX_IVAS_LC3PLUS_DUPLICATES +#define Tab_esc_nb Tab_esc_nb_lc3plus +#define POW_ATT_TABLE0 POW_ATT_TABLE0_lc3plus +#define POW_ATT_TABLE1 POW_ATT_TABLE1_lc3plus +#define InvIntTable InvIntTable_lc3plus +#define SineTable320 SineTable320_lc3plus +#define RotVector_320 RotVector_320_lc3plus +#define RotVector_480 RotVector_480_lc3plus +#define SineWindow20 SineWindow20_lc3plus +#define SineWindow40 SineWindow40_lc3plus +#define SineWindow60 SineWindow60_lc3plus +#define SineWindow80 SineWindow80_lc3plus +#define SineWindow120 SineWindow120_lc3plus +#define SineWindow160 SineWindow160_lc3plus +#define SineWindow180 SineWindow180_lc3plus +#define SineWindow320 SineWindow320_lc3plus +#define BASOP_getTables BASOP_getTables_lc3plus +#define ISqrt16 ISqrt16_lc3plus +#define getScaleFactor16 getScaleFactor16_lc3plus +#define Norm32Norm Norm32Norm_lc3plus +#define Scale_sig Scale_sig_lc3plus +#define Copy_Scale_sig Copy_Scale_sig_lc3plus +#define get_size_mpvq_calc_offset_fx get_size_mpvq_calc_offset_fx_lc3plus +#endif + #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index f430f073d..3e5bb8b86 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -445,14 +445,14 @@ void ivas_dirac_dec_close_binaural_data( { IF( hBinaural[pos_idx]->hReverb != NULL ) { - ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); + ivas_binaural_reverb_close_fx( &( hBinaural[pos_idx]->hReverb ) ); } ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) { - ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); + ivas_dirac_dec_decorr_close_fx( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); } free( hBinaural[pos_idx] ); diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index d99a4ad76..2492bc64a 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -598,823 +598,6 @@ const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] = 6.2001e-08f, 2.8483e-08f, 2.6267e-08f }; -const Word32 release_cnst_table[4][201] = // Q31 - { - { - 1913946752, - 1919716352, - 1925351680, - 1930855552, - 1936230784, - 1941479808, - 1946605312, - 1951609728, - 1956495744, - 1961265792, - 1965922304, - 1970467584, - 1974904320, - 1979234560, - 1983460736, - 1987585024, - 1991609856, - 1995537280, - 1999369344, - 2003108480, - 2006756480, - 2010315520, - 2013787520, - 2017174528, - 2020478464, - 2023701248, - 2026844672, - 2029910656, - 2032900992, - 2035817344, - 2038661376, - 2041435008, - 2044139648, - 2046777088, - 2049348864, - 2051856384, - 2054301440, - 2056685312, - 2059009536, - 2061275520, - 2063484672, - 2065638272, - 2067737856, - 2069784448, - 2071779584, - 2073724416, - 2075620096, - 2077467904, - 2079268992, - 2081024512, - 2082735488, - 2084403200, - 2086028416, - 2087612544, - 2089156352, - 2090660864, - 2092127104, - 2093555968, - 2094948480, - 2096305408, - 2097627776, - 2098916352, - 2100172032, - 2101395584, - 2102587776, - 2103749504, - 2104881408, - 2105984384, - 2107059072, - 2108106112, - 2109126400, - 2110120448, - 2111088896, - 2112032512, - 2112951808, - 2113847552, - 2114720128, - 2115570304, - 2116398592, - 2117205504, - 2117991552, - 2118757504, - 2119503616, - 2120230400, - 2120938496, - 2121628288, - 2122300288, - 2122954880, - 2123592576, - 2124213760, - 2124818944, - 2125408384, - 2125982592, - 2126541952, - 2127086848, - 2127617664, - 2128134656, - 2128638336, - 2129128832, - 2129606784, - 2130072192, - 2130525568, - 2130967296, - 2131397376, - 2131816448, - 2132224640, - 2132622080, - 2133009408, - 2133386496, - 2133753856, - 2134111744, - 2134460288, - 2134799744, - 2135130368, - 2135452416, - 2135766144, - 2136071680, - 2136369152, - 2136659072, - 2136941312, - 2137216256, - 2137484160, - 2137744896, - 2137998976, - 2138246400, - 2138487424, - 2138722176, - 2138950656, - 2139173376, - 2139390208, - 2139601408, - 2139807104, - 2140007424, - 2140202624, - 2140392576, - 2140577664, - 2140758016, - 2140933504, - 2141104512, - 2141271040, - 2141433216, - 2141591168, - 2141745024, - 2141894912, - 2142040832, - 2142182912, - 2142321408, - 2142456192, - 2142587392, - 2142715264, - 2142839808, - 2142961152, - 2143079296, - 2143194240, - 2143306240, - 2143415424, - 2143521664, - 2143625216, - 2143725952, - 2143824128, - 2143919744, - 2144012800, - 2144103424, - 2144191744, - 2144277760, - 2144361472, - 2144443136, - 2144522496, - 2144599936, - 2144675200, - 2144748544, - 2144820096, - 2144889600, - 2144957440, - 2145023488, - 2145087744, - 2145150336, - 2145211264, - 2145270656, - 2145328512, - 2145384832, - 2145439616, - 2145493120, - 2145545088, - 2145595776, - 2145645056, - 2145693184, - 2145739904, - 2145785472, - 2145829888, - 2145873152, - 2145915136, - 2145956224, - 2145996032, - 2146034944, - 2146072832, - 2146109696, - 2146145664, - 2146180608, - 2146214656, - 2146247808, - }, - { - 2027355264, - 2030408704, - 2033386624, - 2036290944, - 2039123328, - 2041885440, - 2044578944, - 2047205376, - 2049766528, - 2052263680, - 2054698496, - 2057072384, - 2059387008, - 2061643520, - 2063843328, - 2065987968, - 2068078720, - 2070116864, - 2072103552, - 2074040192, - 2075927936, - 2077767936, - 2079561472, - 2081309568, - 2083013376, - 2084673920, - 2086292352, - 2087869696, - 2089406976, - 2090905216, - 2092365184, - 2093788032, - 2095174528, - 2096525824, - 2097842432, - 2099125632, - 2100375808, - 2101594240, - 2102781312, - 2103938048, - 2105065216, - 2106163456, - 2107233536, - 2108276096, - 2109292032, - 2110281728, - 2111246080, - 2112185728, - 2113101056, - 2113992960, - 2114861824, - 2115708288, - 2116532992, - 2117336448, - 2118119168, - 2118881792, - 2119624704, - 2120348416, - 2121053440, - 2121740288, - 2122409344, - 2123061120, - 2123696128, - 2124314624, - 2124917120, - 2125504128, - 2126075776, - 2126632832, - 2127175296, - 2127703808, - 2128218624, - 2128720000, - 2129208448, - 2129684352, - 2130147712, - 2130599168, - 2131038976, - 2131467264, - 2131884416, - 2132290816, - 2132686592, - 2133072256, - 2133447680, - 2133813504, - 2134169856, - 2134516864, - 2134854784, - 2135184000, - 2135504640, - 2135816960, - 2136121216, - 2136417536, - 2136706048, - 2136987136, - 2137260928, - 2137527552, - 2137787264, - 2138040192, - 2138286592, - 2138526464, - 2138760192, - 2138987776, - 2139209472, - 2139425408, - 2139635712, - 2139840512, - 2140039936, - 2140234240, - 2140423424, - 2140607744, - 2140787200, - 2140962048, - 2141132288, - 2141298048, - 2141459584, - 2141616896, - 2141769984, - 2141919232, - 2142064512, - 2142205952, - 2142343808, - 2142478080, - 2142608768, - 2142736128, - 2142860032, - 2142980864, - 2143098368, - 2143212928, - 2143324544, - 2143433088, - 2143538944, - 2143641984, - 2143742336, - 2143840000, - 2143935232, - 2144027904, - 2144118144, - 2144206080, - 2144291712, - 2144375168, - 2144456320, - 2144535424, - 2144612480, - 2144687488, - 2144760448, - 2144831616, - 2144900992, - 2144968448, - 2145034112, - 2145098112, - 2145160448, - 2145221248, - 2145280256, - 2145337856, - 2145393920, - 2145448576, - 2145501696, - 2145553536, - 2145603968, - 2145653120, - 2145700992, - 2145747456, - 2145792896, - 2145837056, - 2145880064, - 2145922048, - 2145962880, - 2146002560, - 2146041344, - 2146078976, - 2146115712, - 2146151424, - 2146186240, - 2146220160, - 2146253184, - 2146285312, - 2146316672, - 2146347136, - 2146376832, - 2146405760, - 2146433920, - 2146461440, - 2146488192, - 2146514176, - 2146539520, - 2146564224, - 2146588160, - 2146611584, - 2146634368, - 2146656640, - 2146678272, - 2146699264, - 2146719744, - 2146739712, - 2146759168, - 2146778112, - 2146796544, - 2146814464, - 2146832000, - 2146849024, - 2146865664, - }, - { - 2086555136, - 2088125824, - 2089656576, - 2091148416, - 2092602240, - 2094018944, - 2095399680, - 2096745088, - 2098056192, - 2099333888, - 2100578816, - 2101792000, - 2102974080, - 2104125824, - 2105248128, - 2106341760, - 2107407232, - 2108445440, - 2109456896, - 2110442496, - 2111402624, - 2112338176, - 2113249664, - 2114137728, - 2115002880, - 2115845760, - 2116666880, - 2117466880, - 2118246272, - 2119005568, - 2119745280, - 2120465920, - 2121167872, - 2121851776, - 2122517888, - 2123166976, - 2123799168, - 2124414976, - 2125014912, - 2125599360, - 2126168704, - 2126723200, - 2127263360, - 2127789568, - 2128302208, - 2128801408, - 2129287808, - 2129761536, - 2130222976, - 2130672512, - 2131110272, - 2131536768, - 2131952128, - 2132356736, - 2132750848, - 2133134720, - 2133508736, - 2133872896, - 2134227584, - 2134573184, - 2134909696, - 2135237504, - 2135556736, - 2135867648, - 2136170624, - 2136465536, - 2136752896, - 2137032832, - 2137305344, - 2137570816, - 2137829376, - 2138081280, - 2138326528, - 2138565504, - 2138798080, - 2139024768, - 2139245440, - 2139460480, - 2139669888, - 2139873792, - 2140072320, - 2140265856, - 2140454144, - 2140637696, - 2140816384, - 2140990464, - 2141159936, - 2141325056, - 2141485824, - 2141642368, - 2141794944, - 2141943424, - 2142088064, - 2142228992, - 2142366208, - 2142499840, - 2142630016, - 2142756736, - 2142880128, - 2143000448, - 2143117440, - 2143231488, - 2143342592, - 2143450752, - 2143556096, - 2143658624, - 2143758592, - 2143855872, - 2143950592, - 2144043008, - 2144132864, - 2144220416, - 2144305664, - 2144388608, - 2144469504, - 2144548224, - 2144624896, - 2144699648, - 2144772352, - 2144843264, - 2144912256, - 2144979328, - 2145044864, - 2145108480, - 2145170560, - 2145231104, - 2145289856, - 2145347200, - 2145403008, - 2145457408, - 2145510400, - 2145561984, - 2145612160, - 2145661056, - 2145708672, - 2145755136, - 2145800192, - 2145844224, - 2145887104, - 2145928832, - 2145969408, - 2146008960, - 2146047616, - 2146085120, - 2146121600, - 2146157184, - 2146191872, - 2146225664, - 2146258560, - 2146290560, - 2146321792, - 2146352128, - 2146381696, - 2146410496, - 2146438528, - 2146465920, - 2146492416, - 2146518400, - 2146543616, - 2146568192, - 2146592128, - 2146615424, - 2146638080, - 2146660224, - 2146681728, - 2146702720, - 2146723072, - 2146743040, - 2146762368, - 2146781184, - 2146799616, - 2146817408, - 2146834816, - 2146851840, - 2146868352, - 2146884352, - 2146900096, - 2146915328, - 2146930176, - 2146944640, - 2146958720, - 2146972416, - 2146985856, - 2146998784, - 2147011456, - 2147023872, - 2147035904, - 2147047552, - 2147058944, - 2147070080, - 2147080832, - 2147091456, - 2147101696, - 2147111680, - 2147121408, - 2147130880, - 2147140096, - 2147149056, - 2147157760, - 2147166336, - 2147174656, - }, - { - 2106670080, - 2107727232, - 2108757120, - 2109760640, - 2110738432, - 2111691008, - 2112619136, - 2113523328, - 2114404352, - 2115262592, - 2116098816, - 2116913408, - 2117707136, - 2118480256, - 2119233536, - 2119967360, - 2120682240, - 2121378688, - 2122057088, - 2122717952, - 2123361792, - 2123988992, - 2124599936, - 2125195136, - 2125774848, - 2126339584, - 2126889728, - 2127425536, - 2127947520, - 2128456064, - 2128951296, - 2129433856, - 2129903744, - 2130361600, - 2130807424, - 2131241728, - 2131664768, - 2132076928, - 2132478208, - 2132869248, - 2133250048, - 2133620992, - 2133982208, - 2134334080, - 2134676864, - 2135010688, - 2135335936, - 2135652608, - 2135961088, - 2136261504, - 2136554112, - 2136839168, - 2137116800, - 2137387136, - 2137650560, - 2137907072, - 2138156928, - 2138400256, - 2138637184, - 2138867968, - 2139092864, - 2139311744, - 2139524992, - 2139732736, - 2139934976, - 2140131968, - 2140323840, - 2140510720, - 2140692736, - 2140870016, - 2141042688, - 2141210752, - 2141374592, - 2141534080, - 2141689344, - 2141840640, - 2141987968, - 2142131456, - 2142271232, - 2142407424, - 2142539904, - 2142669056, - 2142794752, - 2142917248, - 2143036544, - 2143152640, - 2143265792, - 2143375872, - 2143483264, - 2143587712, - 2143689472, - 2143788544, - 2143885056, - 2143979136, - 2144070656, - 2144159872, - 2144246656, - 2144331264, - 2144413568, - 2144493824, - 2144571904, - 2144647936, - 2144722048, - 2144794240, - 2144864512, - 2144932864, - 2144999552, - 2145064448, - 2145127680, - 2145189248, - 2145249152, - 2145307520, - 2145364480, - 2145419776, - 2145473792, - 2145526272, - 2145577472, - 2145627264, - 2145675776, - 2145723008, - 2145768960, - 2145813760, - 2145857408, - 2145899904, - 2145941376, - 2145981696, - 2146020864, - 2146059136, - 2146096384, - 2146132608, - 2146167936, - 2146202368, - 2146235776, - 2146268416, - 2146300160, - 2146331136, - 2146361216, - 2146390528, - 2146419200, - 2146446976, - 2146474112, - 2146500480, - 2146526208, - 2146551168, - 2146575488, - 2146599296, - 2146622464, - 2146644864, - 2146666880, - 2146688128, - 2146708992, - 2146729216, - 2146748928, - 2146768128, - 2146786816, - 2146805120, - 2146822784, - 2146840064, - 2146856960, - 2146873344, - 2146889216, - 2146904832, - 2146919936, - 2146934656, - 2146948992, - 2146962944, - 2146976640, - 2146989824, - 2147002752, - 2147015296, - 2147027584, - 2147039488, - 2147051136, - 2147062400, - 2147073408, - 2147084160, - 2147094528, - 2147104768, - 2147114624, - 2147124352, - 2147133696, - 2147142912, - 2147151744, - 2147160448, - 2147168896, - 2147177088, - 2147185152, - 2147192960, - 2147200512, - 2147207936, - 2147215104, - 2147222144, - 2147229056, - 2147235712, - 2147242112, - 2147248384, - 2147254656, - 2147260544, - 2147266432, - 2147272064, - 2147277568, - }, - - - }; /*----------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index c80fab8ce..7d7df163c 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -125,8 +125,6 @@ extern const float ivas_reverb_default_fc[]; extern const float ivas_reverb_default_RT60[]; extern const float ivas_reverb_default_DSR[]; -extern const Word32 release_cnst_table[4][201]; // Q31 - /*----------------------------------------------------------------------------------* * Renderer SBA & MC enc/dec matrices *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 448375dfd..9b96ac146 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1628,7 +1628,7 @@ static void clearInputIsm( #ifdef SPLIT_REND_WITH_HEAD_ROT FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { - ivas_td_binaural_close( &inputIsm->splitTdRendWrappers[i].hBinRendererTd ); + ivas_td_binaural_close_fx( &inputIsm->splitTdRendWrappers[i].hBinRendererTd ); inputIsm->splitTdRendWrappers[i].hHrtfTD = NULL; } #endif @@ -2855,7 +2855,7 @@ static void clearInputMc( { IF( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL ) { - ivas_td_binaural_close( &inputMc->splitTdRendWrappers[i].hBinRendererTd ); + ivas_td_binaural_close_fx( &inputMc->splitTdRendWrappers[i].hBinRendererTd ); inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; } } @@ -9299,14 +9299,14 @@ void IVAS_REND_cldfbSynthesis_wrapper( const int16_t samplesToProcess, /* i : number of processed samples */ IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filter bank state */ Word16 Q_cldfb, - Word16 Q_out ) + Word16 *Q_out ) { Scale_sig32( h_cldfb->cldfb_state_fx, h_cldfb->p_filter_length, sub( sub( Q_cldfb, 1 ), h_cldfb->Q_cldfb_state ) ); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); // Q_cldfb - 1 - Q_out = sub( Q_cldfb, 1 ); + *Q_out = sub( Q_cldfb, 1 ); move16(); - h_cldfb->Q_cldfb_state = Q_out; + h_cldfb->Q_cldfb_state = *Q_out; move16(); return; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 6d7ce0bdf..1ac3c9fea 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -401,7 +401,7 @@ void IVAS_REND_cldfbSynthesis_wrapper( const int16_t samplesToProcess, /* i : number of processed samples */ IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filter bank state */ Word16 Q_cldfb, - Word16 Q_out ); + Word16 *Q_out ); #endif -- GitLab From 9e5259ceb1a8ddc45b5294c8d3a40bc3256b77ad Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 13:06:56 +1100 Subject: [PATCH 031/329] clang format fix --- lib_com/ivas_rom_com.c | 7094 ++++++++++++++------------- lib_dec/ivas_binRenderer_internal.c | 26 +- 2 files changed, 3562 insertions(+), 3558 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 6023812c8..5df975cf8 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -52,3671 +52,3673 @@ const Word32 ivas_brate_tbl[SIZE_IVAS_BRATE_TBL] = IVAS_192k, IVAS_256k, IVAS_384k, IVAS_512k }; - -/*------------------------------------------------------------------------- - * DFT Stereo ROM tables - *------------------------------------------------------------------------*/ - -/*4xERB scale: max of 14 bands*/ -const Word16 dft_band_limits_erb4[STEREO_DFT_ERB4_BANDS] = -{ - 1, 3, 5, 10, 18, 26, 41, 56, 84, 132, 214, 342, 470, 601 -}; - -/*8xERB scale: max of 8 bands*/ -const Word16 dft_band_limits_erb8[STEREO_DFT_ERB8_BANDS] = -{ - 1, 5, 18, 41, 84, 214, 470, 601 -}; - - -const Word16 dft_band_ipd[3][4] = -{ - {0,8,10,13}, - {0,5,6,8}, - {0,2,3,4} -}; - -const Word16 dft_band_res_cod[3][4] = -{ - {0,8,10,11}, - {0,5,6,7}, - {0,5,6,7} -}; - -// Q31 -const Word32 dft_res_gains_q_Q31[][2] = -{ - /* quantization points for joint quantization of prediction gain and residual energy */ - - /* column 1 (|ILD| = 0): */ - {0, 0 }, - {0, 251216928 }, - {0, 487459456 }, - {0, 731632640 }, - {0, 997611392 }, - {0, 1299397248 }, - {0, 1666984192 }, - {0, 2147483647 }, - - /* column 2 (|ILD| = 2): */ - {246151024, 0 }, - {249475328, 247871152 }, - {258660112, 480729248 }, - {274304544, 720918848 }, - {298427200, 981720000 }, - {334663840, 1276185088 }, - {391374592, 1632160640 }, - {485919712, 2091786496 }, - - /* column 3 (|ILD| = 4): */ - {485919712, 0 }, - {492224736, 238188144 }, - {509610752, 461283776 }, - {539117184, 690072384 }, - {584326016, 936189056 }, - {651608832, 1210182144 }, - {755411712, 1534299776 }, - {924504576, 1938292992 }, - - /* column 4 (|ILD| = 6): */ - {713563712, 0 }, - {722237376, 223142880 }, - {746085184, 431184640 }, - {786311872, 642617280 }, - {847364864, 866812416 }, - {936938496, 1111020032 }, - {1072199936, 1390431232 }, - {1285225984, 1720430720 }, - - /* column 5 (|ILD| = 8): */ - {924504576, 0 }, - {934784576, 204139792 }, - {962942400, 393358880 }, - {1010083968, 583482048 }, - {1080789888, 781462848 }, - {1182728704, 991308544 }, - {1332741248, 1221608960 }, - {1559902080, 1475937536 }, - - /* column 6 (|ILD| = 10): */ - {1115604864, 0 }, - {1126709504, 182744416 }, - {1156997632, 351025536 }, - {1207276672, 517958016 }, - {1281710592, 688294272 }, - {1387005952, 863412992 }, - {1537761536, 1046870336 }, - {1757032448, 1234717184 }, - - /* column 7 (|ILD| = 13): */ - {1361843968, 0 }, - {1372924928, 149366080 }, - {1402942464, 285507936 }, - {1452130560, 417893888 }, - {1523515136, 548787328 }, - {1621670144, 677135936 }, - {1756740352, 802203264 }, - {1942499840, 915633344 }, - - /* column 8 (|ILD| = 16): */ - {1559902080, 0 }, - {1569913600, 117815248 }, - {1596862336, 224162928 }, - {1640492800, 325650848 }, - {1702660352, 423060736 }, - {1785997696, 514412544 }, - {1896788608, 597466432 }, - {2042241920, 664027712 }, - - /* column 9 (|ILD| = 19): */ - {1714196608, 0 }, - {1722634112, 90359672 }, - {1745223424, 171238192 }, - {1781415040, 247171072 }, - {1832190080, 318199104 }, - {1898830848, 382271424 }, - {1984989952, 437025792 }, - {2094086528, 475912448 }, - - /* column 10 (|ILD| = 22): */ - {1831427712, 0 }, - {1838194432, 67828272 }, - {1856228992, 128123168 }, - {1884882944, 183977072 }, - {1924581248, 235132272 }, - {1975822336, 279821408 }, - {2040659200, 316058048 }, - {2120554240, 339023232 }, - - /* column 11 (|ILD| = 25): */ - {1918819584, 0 }, - {1924055168, 50102940 }, - {1937964416, 94399088 }, - {1959916032, 135003712 }, - {1990038784, 171579648 }, - {2028424960, 202728896 }, - {2076217216, 226931040 }, - {2133943808, 240762976 }, - - /* column 12 (|ILD| = 30): */ - {2015827840, 0 }, - {2019068416, 29502130 }, - {2027636864, 55420112 }, - {2041056512, 78889960 }, - {2059271424, 99626064 }, - {2082150784, 116769424 }, - {2110128128, 129415952 }, - {2143192960, 135682304 }, - - /* column 13 (|ILD| = 35): */ - {2072441984, 0 }, - {2074364032, 17033840 }, - {2079438464, 31939524 }, - {2087347712, 45337676 }, - {2098012032, 57039312 }, - {2111296384, 66537632 }, - {2127368192, 73321536 }, - {2146126464, 76351632 }, - - /* column 14 (|ILD| = 40): */ - {2104959232, 0 }, - {2106073728, 9723806 }, - {2109011456, 18212808 }, - {2113579136, 25810606 }, - {2119712384, 32401234 }, - {2127314432, 37692632 }, - {2136458496, 41399188 }, - {2147054208, 42945376 }, - - /* column 15 (|ILD| = 45): */ - {2123466240, 0 }, - {2124103936, 5514738 }, - {2125783296, 10322954 }, - {2128390400, 14615774 }, - {2131882240, 18322330 }, - {2136200832, 21283710 }, - {2141376256, 23332410 }, - {2147348352, 24150602 }, - - /* column 16 (|ILD| = 50): */ - {2133943808, 0 }, - {2134306688, 3115998 }, - {2135260160, 5830418 }, - {2136737664, 8250632 }, - {2138715520, 10335839 }, - {2141157120, 11995844 }, - {2144077696, 13136157 }, - {2147440640, 13580687 } -}; - - -/* tables for adaptive Golomb-Rice coding of DFT stereo parameters */ -const Word16 dft_code_itd[] = -{ - 0, 3, 4, 13, 8, 9, 12, 5, 10, 44, 23, 60, 45, 31, 235, 59, 28, 61, 234, 116 -}; - -const Word16 dft_len_itd[] = -{ - 2, 3, 4, 4, 4, 4, 4, 4, 4, 6, 5, 6, 6, 5, 8, 6, 5, 6, 8, 7 -}; - -const Word16 dft_maps_rpg[] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, - 2, 0, 1, 3, 4, 5, 6, 7, - 6, 2, 0, 1, 3, 4, 5, 7, - 7, 5, 2, 0, 1, 3, 4, 6, - 7, 6, 4, 3, 1, 0, 2, 5, - 7, 6, 5, 3, 2, 1, 0, 4, - 7, 6, 5, 4, 3, 2, 0, 1, - 7, 6, 5, 4, 3, 2, 0, 1, - 6, 5, 4, 3, 1, 0, 2, 7, -}; - -const Word16 dft_maps_sg[NO_SYMB_GR_SIDE_G * NO_SYMB_GR_SIDE_G] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 15, 4, 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 12, 9, 4, 1, 0, 2, 3, 5, 6, 7, 8, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 16, 14, 8, 4, 2, 0, 1, 3, 5, 6, 7, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 18, 16, 14, 10, 5, 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 15, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 21, 19, 17, 15, 8, 4, 2, 0, 1, 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 21, 19, 17, 15, 12, 8, 4, 0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 21, 19, 17, 15, 13, 11, 9, 3, 0, 1, 2, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 24, 22, 20, 18, 16, 14, 12, 9, 6, 0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 26, 27, 28, 29, 30, - 25, 23, 21, 19, 17, 15, 13, 11, 9, 6, 0, 1, 2, 3, 4, 5, 7, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 28, 29, 30, - 27, 25, 23, 21, 19, 17, 15, 13, 11, 8, 5, 0, 1, 2, 3, 4, 6, 7, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, - 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 28, 29, 30, - 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30, - 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, - 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, - 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, - 30, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, - 30, 29, 28, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, - 30, 29, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 9, 7, 6, 4, 3, 2, 1, 0, 5, 8, 11, 13, 15, 17, 19, 21, 23, 25, 27, - 30, 29, 28, 27, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 7, 5, 4, 3, 2, 1, 0, 6, 9, 11, 13, 15, 17, 19, 21, 23, 25, - 30, 29, 28, 27, 26, 25, 23, 21, 19, 17, 15, 13, 11, 10, 8, 7, 5, 4, 3, 2, 1, 0, 6, 9, 12, 14, 16, 18, 20, 22, 24, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 18, 16, 14, 12, 10, 8, 7, 6, 5, 4, 2, 1, 0, 3, 9, 11, 13, 15, 17, 19, 21, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 18, 16, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 0, 4, 8, 12, 15, 17, 19, 21, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 18, 16, 14, 13, 12, 11, 10, 9, 7, 6, 5, 3, 1, 0, 2, 4, 8, 15, 17, 19, 21, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 17, 15, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1, 0, 5, 10, 14, 16, 18, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 15, 13, 12, 11, 10, 9, 7, 6, 5, 3, 1, 0, 2, 4, 8, 14, 16, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 11, 10, 8, 7, 6, 5, 3, 2, 0, 1, 4, 9, 12, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 3, 2, 1, 0, 4, 15, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 1, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 -}; - - -/*------------------------------------------------------------------------- - * Range Coder ROM tables - *------------------------------------------------------------------------*/ - -/* Create separate tables for cumulative frequency and symbol frequency */ -const UWord16 cum_freq_ari_pk_s17_LC_ext[RANGE_N_CONTEXT][1 + RANGE_N_SYMBOLS] = -{ - { 0,16,47,153,241,269,325,468,591,674,798,912,1017,1082,1183,1277,1364,16384 }, - { 0,7401,7844,7886,7899,12065,12718,12790,12805,14099,14476,14533,14549,15058,15264,15299,15310,16384 }, - { 0,4362,6345,6864,7038,9037,11049,11736,12002,12569,13301,13656,13822,14021,14334,14515,14607,16384 }, - { 0,2955,5183,5822,6013,8153,10671,11614,11943,12586,13540,14025,14232,14437,14770,14978,15080,16384 }, - { 0,3155,4981,5615,5855,7969,9953,10739,11073,11936,12837,13208,13383,13767,14203,14400,14498,16384 }, - { 0,1216,2630,3264,3558,4831,6679,7661,8157,8709,9622,10204,10542,10799,11243,11568,11777,16384 }, - { 0,1759,3641,4350,4612,6325,8678,9732,10161,10790,11790,12361,12642,12883,13295,13566,13720,16384 }, - { 0,1109,2705,3433,3732,5226,7532,8732,9263,9978,11142,11842,12188,12490,12986,13321,13520,16384 }, - { 0,11524,13046,13170,13191,14956,15708,15813,15837,16028,16162,16195,16204,16245,16282,16295,16300,16384 }, - { 0,8027,10586,10909,10974,13291,14861,15157,15232,15535,15824,15914,15943,16014,16090,16123,16136,16384 }, - { 0,834,2034,2674,2997,4087,5843,6891,7455,8030,9013,9688,10085,10376,10893,11277,11528,16384 }, - { 0,6038,9086,9451,9519,12332,14521,14913,15003,15329,15711,15848,15893,15955,16045,16091,16111,16384 }, - { 0,4732,7685,8354,8545,10717,12924,13618,13852,14291,14842,15083,15181,15314,15491,15582,15625,16384 }, - { 0,745,1783,2347,2655,3537,4963,5864,6406,6863,7664,8248,8634,8891,9351,9708,9958,16384 }, - { 0,3957,6794,7669,7998,9743,11676,12498,12869,13313,13894,14186,14332,14498,14714,14835,14906,16384 }, - { 0,2779,5388,6021,6201,8582,11352,12260,12544,13117,13981,14408,14580,14751,15039,15213,15298,16384 }, - { 0,448,1160,1625,1920,2576,3706,4518,5053,5474,6234,6835,7262,7531,8032,8446,8758,16384 }, - { 0,1,2,1555,2246,2247,2248,3489,4112,5449,6596,7302,7710,8311,8876,9266,9517,16384 }, - { 0,2496,4910,5544,5722,8049,10799,11689,11973,12583,13467,13878,14047,14234,14537,14712,14803,16384 }, - { 0,921,2222,2880,3188,4407,6321,7406,7955,8573,9616,10296,10679,10978,11502,11880,12118,16384 }, - { 0,2620,4443,5017,5233,7072,9213,10083,10441,11049,11954,12442,12676,12918,13310,13565,13705,16384 }, - { 0,11205,13084,13178,13187,15164,16010,16081,16091,16213,16303,16321,16325,16340,16355,16360,16362,16384 }, - { 0,358,916,1288,1542,2055,2937,3594,4062,4399,5017,5524,5907,6136,6573,6941,7236,16384 }, - { 0,3575,5093,5536,5735,7408,9185,9878,10188,10727,11497,11933,12165,12410,12794,13019,13166,16384 }, - { 0,1,2,640,1036,1037,1038,1670,2096,2696,3287,3732,4056,4417,4800,5106,5339,16384 }, - { 0,969,1397,1518,1578,2633,3338,3566,3675,4197,4664,4857,4957,5288,5625,5783,5874,16384 }, - { 0,10458,12104,12294,12331,14246,15264,15437,15481,15752,15971,16031,16050,16120,16186,16210,16218,16384 }, - { 0,7178,9744,10039,10093,12701,14612,14961,15042,15360,15732,15869,15917,15978,16070,16117,16139,16384 }, - { 0,1298,2418,2879,3113,4146,5509,6227,6621,7053,7755,8229,8539,8776,9186,9492,9714,16384 }, - { 0,4957,7785,8252,8357,10978,13372,13955,14114,14561,15140,15378,15464,15570,15730,15820,15860,16384 }, - { 0,4823,8164,8570,8647,11604,14169,14653,14763,15105,15554,15727,15785,15852,15960,16018,16045,16384 }, - { 0,4735,7010,7517,7660,9986,12230,12914,13131,13666,14374,14689,14814,14972,15212,15342,15404,16384 }, - { 0,3363,5881,6658,6941,8864,11113,12015,12368,12889,13643,14019,14203,14394,14665,14823,14906,16384 }, - { 0,2569,4996,5779,6068,7917,10251,11209,11602,12129,12918,13321,13520,13696,13976,14155,14259,16384 }, - { 0,209,577,848,1046,1378,1982,2465,2835,3072,3513,3893,4202,4374,4703,4994,5241,16384 }, - { 0,2074,4337,5048,5274,7319,10003,11066,11446,12105,13112,13652,13885,14100,14464,14691,14810,16384 }, - { 0,1619,3560,4288,4550,6381,8955,10102,10543,11239,12362,12982,13261,13516,13958,14234,14381,16384 }, - { 0,89,257,441,582,734,1024,1325,1568,1716,1983,2222,2430,2545,2750,2941,3109,16384 }, - { 0,2202,3563,4044,4264,5686,7344,8100,8476,9006,9835,10331,10612,10864,11304,11599,11787,16384 }, - { 0,1220,2801,3492,3784,5223,7387,8496,8998,9640,10711,11369,11711,11993,12486,12829,13035,16384 }, - { 0,12626,13813,13903,13917,15396,15906,15972,15987,16139,16230,16251,16257,16289,16315,16323,16326,16384 }, - { 0,1579,3191,3831,4099,5678,7788,8761,9206,9842,10821,11388,11681,11958,12417,12722,12902,16384 }, - { 0,597,1514,2064,2379,3237,4679,5637,6213,6733,7649,8316,8755,9052,9599,10023,10323,16384 }, - { 0,9273,11762,12080,12151,14038,15210,15446,15514,15725,15929,15995,16019,16068,16124,16148,16158,16384 }, - { 0,9238,11681,11852,11872,14306,15644,15801,15828,16013,16183,16231,16243,16266,16297,16312,16318,16384 }, - { 0,6791,9200,9531,9594,12240,14178,14552,14639,15064,15506,15643,15687,15785,15908,15960,15983,16384 }, - { 0,7175,10415,10905,11033,13038,14621,15002,15123,15367,15651,15762,15806,15864,15938,15974,15992,16384 }, - { 0,5060,7703,8132,8225,10934,13270,13778,13911,14397,14972,15173,15242,15367,15537,15619,15654,16384 }, - { 0,3721,6311,6857,6992,9557,12180,12895,13098,13671,14418,14718,14830,14984,15212,15333,15390,16384 }, - { 0,5971,9288,10044,10269,11991,13680,14228,14437,14750,15130,15293,15374,15459,15579,15642,15677,16384 }, - { 0,3047,5311,5907,6078,8339,10850,11679,11946,12580,13442,13854,14024,14220,14534,14716,14810,16384 }, - { 0,2061,4280,4993,5228,7201,9735,10735,11097,11708,12606,13082,13295,13498,13836,14043,14161,16384 }, - { 0,4738,7949,8880,9234,10781,12502,13214,13531,13897,14355,14593,14718,14835,14998,15096,15153,16384 }, - { 0,3237,5045,5632,5860,7609,9702,10608,10986,11571,12476,12978,13230,13451,13830,14074,14208,16384 }, - { 0,1833,3889,4677,5028,6422,8379,9378,9884,10350,11086,11545,11809,12003,12327,12559,12711,16384 }, - { 0,3989,6858,7352,7459,10254,12936,13571,13735,14240,14895,15153,15242,15364,15548,15646,15690,16384 }, - { 0,1463,3197,3909,4220,5626,7609,8632,9127,9657,10520,11078,11380,11607,11991,12265,12442,16384 }, - { 0,14233,15083,15108,15110,16069,16300,16314,16316,16352,16370,16373,16374,16377,16380,16381,16382,16384 }, - { 0,1,2,2610,3293,3294,3295,5097,5671,8467,10332,11119,11437,12223,12850,13185,13345,16384 }, - { 0,2010,4053,4696,4910,6879,9391,10386,10750,11393,12376,12886,13119,13348,13726,13967,14099,16384 }, - { 0,7586,10517,10758,10791,13543,15346,15577,15619,15846,16082,16150,16169,16202,16245,16265,16273,16384 }, - { 0,3059,5772,6369,6524,9041,11801,12582,12813,13361,14115,14439,14567,14714,14944,15075,15141,16384 }, - { 0,8643,10594,10813,10856,13274,14686,14920,14975,15350,15680,15771,15799,15897,16003,16042,16057,16384 }, - { 0,6720,8878,9325,9467,11564,13248,13744,13929,14384,14880,15087,15167,15311,15488,15569,15607,16384 }, -}; - -const UWord16 sym_freq_ari_pk_s17_LC_ext[RANGE_N_CONTEXT][RANGE_N_SYMBOLS] = -{ - { 16,31,106,88,28,56,143,123,83,124,114,105,65,101,94,87,15020 }, - { 7401,443,42,13,4166,653,72,15,1294,377,57,16,509,206,35,11,1074 }, - { 4362,1983,519,174,1999,2012,687,266,567,732,355,166,199,313,181,92,1777 }, - { 2955,2228,639,191,2140,2518,943,329,643,954,485,207,205,333,208,102,1304 }, - { 3155,1826,634,240,2114,1984,786,334,863,901,371,175,384,436,197,98,1886 }, - { 1216,1414,634,294,1273,1848,982,496,552,913,582,338,257,444,325,209,4607 }, - { 1759,1882,709,262,1713,2353,1054,429,629,1000,571,281,241,412,271,154,2664 }, - { 1109,1596,728,299,1494,2306,1200,531,715,1164,700,346,302,496,335,199,2864 }, - { 11524,1522,124,21,1765,752,105,24,191,134,33,9,41,37,13,5,84 }, - { 8027,2559,323,65,2317,1570,296,75,303,289,90,29,71,76,33,13,248 }, - { 834,1200,640,323,1090,1756,1048,564,575,983,675,397,291,517,384,251,4856 }, - { 6038,3048,365,68,2813,2189,392,90,326,382,137,45,62,90,46,20,273 }, - { 4732,2953,669,191,2172,2207,694,234,439,551,241,98,133,177,91,43,759 }, - { 745,1038,564,308,882,1426,901,542,457,801,584,386,257,460,357,250,6426 }, - { 3957,2837,875,329,1745,1933,822,371,444,581,292,146,166,216,121,71,1478 }, - { 2779,2609,633,180,2381,2770,908,284,573,864,427,172,171,288,174,85,1086 }, - { 448,712,465,295,656,1130,812,535,421,760,601,427,269,501,414,312,7626 }, - { 1,1,1553,691,1,1,1241,623,1337,1147,706,408,601,565,390,251,6867 }, - { 2496,2414,634,178,2327,2750,890,284,610,884,411,169,187,303,175,91,1581 }, - { 921,1301,658,308,1219,1914,1085,549,618,1043,680,383,299,524,378,238,4266 }, - { 2620,1823,574,216,1839,2141,870,358,608,905,488,234,242,392,255,140,2679 }, - { 11205,1879,94,9,1977,846,71,10,122,90,18,4,15,15,5,2,22 }, - { 358,558,372,254,513,882,657,468,337,618,507,383,229,437,368,295,9148 }, - { 3575,1518,443,199,1673,1777,693,310,539,770,436,232,245,384,225,147,3218 }, - { 1,1,638,396,1,1,632,426,600,591,445,324,361,383,306,233,11045 }, - { 969,428,121,60,1055,705,228,109,522,467,193,100,331,337,158,91,10510 }, - { 10458,1646,190,37,1915,1018,173,44,271,219,60,19,70,66,24,8,166 }, - { 7178,2566,295,54,2608,1911,349,81,318,372,137,48,61,92,47,22,245 }, - { 1298,1120,461,234,1033,1363,718,394,432,702,474,310,237,410,306,222,6670 }, - { 4957,2828,467,105,2621,2394,583,159,447,579,238,86,106,160,90,40,524 }, - { 4823,3341,406,77,2957,2565,484,110,342,449,173,58,67,108,58,27,339 }, - { 4735,2275,507,143,2326,2244,684,217,535,708,315,125,158,240,130,62,980 }, - { 3363,2518,777,283,1923,2249,902,353,521,754,376,184,191,271,158,83,1478 }, - { 2569,2427,783,289,1849,2334,958,393,527,789,403,199,176,280,179,104,2125 }, - { 209,368,271,198,332,604,483,370,237,441,380,309,172,329,291,247,11143 }, - { 2074,2263,711,226,2045,2684,1063,380,659,1007,540,233,215,364,227,119,1574 }, - { 1619,1941,728,262,1831,2574,1147,441,696,1123,620,279,255,442,276,147,2003 }, - { 89,168,184,141,152,290,301,243,148,267,239,208,115,205,191,168,13275 }, - { 2202,1361,481,220,1422,1658,756,376,530,829,496,281,252,440,295,188,4597 }, - { 1220,1581,691,292,1439,2164,1109,502,642,1071,658,342,282,493,343,206,3349 }, - { 12626,1187,90,14,1479,510,66,15,152,91,21,6,32,26,8,3,58 }, - { 1579,1612,640,268,1579,2110,973,445,636,979,567,293,277,459,305,180,3482 }, - { 597,917,550,315,858,1442,958,576,520,916,667,439,297,547,424,300,6061 }, - { 9273,2489,318,71,1887,1172,236,68,211,204,66,24,49,56,24,10,226 }, - { 9238,2443,171,20,2434,1338,157,27,185,170,48,12,23,31,15,6,66 }, - { 6791,2409,331,63,2646,1938,374,87,425,442,137,44,98,123,52,23,401 }, - { 7175,3240,490,128,2005,1583,381,121,244,284,111,44,58,74,36,18,392 }, - { 5060,2643,429,93,2709,2336,508,133,486,575,201,69,125,170,82,35,730 }, - { 3721,2590,546,135,2565,2623,715,203,573,747,300,112,154,228,121,57,994 }, - { 5971,3317,756,225,1722,1689,548,209,313,380,163,81,85,120,63,35,707 }, - { 3047,2264,596,171,2261,2511,829,267,634,862,412,170,196,314,182,94,1574 }, - { 2061,2219,713,235,1973,2534,1000,362,611,898,476,213,203,338,207,118,2223 }, - { 4738,3211,931,354,1547,1721,712,317,366,458,238,125,117,163,98,57,1231 }, - { 3237,1808,587,228,1749,2093,906,378,585,905,502,252,221,379,244,134,2176 }, - { 1833,2056,788,351,1394,1957,999,506,466,736,459,264,194,324,232,152,3673 }, - { 3989,2869,494,107,2795,2682,635,164,505,655,258,89,122,184,98,44,694 }, - { 1463,1734,712,311,1406,1983,1023,495,530,863,558,302,227,384,274,177,3942 }, - { 14233,850,25,2,959,231,14,2,36,18,3,1,3,3,1,1,2 }, - { 1,1,2608,683,1,1,1802,574,2796,1865,787,318,786,627,335,160,3039 }, - { 2010,2043,643,214,1969,2512,995,364,643,983,510,233,229,378,241,132,2285 }, - { 7586,2931,241,33,2752,1803,231,42,227,236,68,19,33,43,20,8,111 }, - { 3059,2713,597,155,2517,2760,781,231,548,754,324,128,147,230,131,66,1243 }, - { 8643,1951,219,43,2418,1412,234,55,375,330,91,28,98,106,39,15,327 }, - { 6720,2158,447,142,2097,1684,496,185,455,496,207,80,144,177,81,38,777 }, -}; - - -/*------------------------------------------------------------------------- - * ECLVQ Stereo ROM tables - *------------------------------------------------------------------------*/ - -/* table with round(ECSQ_PROB_TOTAL / index) for entropy coding, with i in {1, .., ECSQ_SEGMENT_SIZE} */ -const UWord16 ECSQ_tab_inverse[1 + ECSQ_SEGMENT_SIZE] = -{ - 0, 16384, 8192, 5461, 4096, 3277, 2731, 2341, 2048 -}; - - -const Word16 tdm_bit_allc_tbl[5][6] = -{ - /* IC -- UC -- GC -- TM --AC */ - { 1650, 3500, 0, 4400, 0, 5000 }, /* IVAS_13k2 */ - { 1650, 3500, 0, 5000, 0, 5000 }, /* IVAS_16k4 */ - { 1650, 3500, 0, 6000, 0, 5000 }, /* IVAS_24k4 */ - { 1650, 6050, 0, 10000, 0, 10000 }, /* IVAS_32k */ - { 1650, 6050, 0, 13000, 0, 14000 } /* IVAS_48k */ -}; - - -const Word16 fast_FCB_bits_2sfr[] = {8, 14, 18, 20, 24, 128/*stop value*/}; - -const Word16 fast_FCB_rates_2sfr[] = {/*16*50,*/ (8+14)*50, 28*50, 32*50, 34*50, 36*50, 38*50, 40*50, 42*50, 44*50, 48*50}; - - -/*----------------------------------------------------------------------------------* - * MDCT Stereo ROM tables - *----------------------------------------------------------------------------------*/ - - /* PsychLPC */ - -const SpectrumWarping sw32000Hz[] = -{{ - { - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, - 6, 8, 8, 8, 8, 8, 10, 10, 10, 10, 12, 12, 12, 12, 14, 14, - 14, 16, 18, 18, 18, 20, 22, 22, 22, 24, 26, 26, 26, 28, 30, 32 - }, - { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, - 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10 - }, -}}; - -const SpectrumWarping sw25600Hz[] = -{{ - { - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, - 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 12, 12, 12, 12, - 12, 12, 14, 14, 14, 14, 14, 16, 16, 18, 18, 18, 18, 18, 20, 20 - }, - { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 - }, -}}; - -const SpectrumWarping sw16000Hz[] = -{{ - { - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 - }, - { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 - }, -}}; - -const MDCTStereoBands_config mdctStereoBands_32000_640[] = -{{ - /*TCX 20*/ - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, - 12, 20, 20, 20, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 42, - 64, 64, 96, 160}, - {44, 41,38, 29},/*number of bands for frame lengths 960, 640, 512, 320 respectively*/ - - /*TCX 10*/ - { - 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 20, 32, 32, - 32, 48, 80 - }, - {33, 29, 26, 18}/*number of bands for frame lengths 480, 320, 256, 160 respectively*/ -}}; - - -const Word16 dft_cng_coh_u2i[9] = { 4, 5, 3, 6, 2, 7, 1, 8, 0 }; /* Coherence unary codeword -> residual codeword conversion table */ - -const Word16 dft_cng_coh_i2u[9] = { 8, 6, 4, 2, 0, 1, 3, 5, 7 }; /* Coherence residual codeword -> unary codeword conversion table */ - -const Word16 dft_cng_coh_alpha_start[STEREO_DFT_N_COH_ALPHA_STEPS - 1] = { 15, 16, 17, 18 }; - - -const Word16 DirAC_band_grouping_12[12 + 1] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 11, 17, 25, 40, 60 -}; - - -const Word16 DirAC_band_grouping_6[6 + 1] = -{ - 0, 1, 4, 8, 20, 30, 60 -}; - -const Word16 DirAC_band_grouping_5[5 + 1] = -{ - 0, 1, 3, 7, 15, 60 -}; - -const Word16 DirAC_block_grouping[MAX_PARAM_SPATIAL_SUBFRAMES + 1] = -{ - 0, 4, 8, 12, 16 -}; - -const Word16 DirAC_block_grouping_5ms_MDFT[MAX_PARAM_SPATIAL_SUBFRAMES + 1] = -{ - 0, 1, 2, 3, 4 -}; - -const Word32 c_weights_fx[DIRAC_NO_FB_BANDS_MAX] /* Q30 */ = { 106970960, 1033798336, 1065867776, 1071704704, 1073381888, 1073741824, 1073494016, 1072883072, 1072012032, 1070930560, 1069665600, 1068232640, 1066641792, 1064899968, 1063012224, 1060982464, 1058814144, 1056510016, 1054072832, 1051505280, 1048809664, 1045988480, 1043044160, 1039979072, 1036795776, 1033496576, 1030084096, 1026560960, 1022929600, 1019192512, 1015352576, 1011412416, 1007374720, 1003242112, 999017472, 994703488, 990302976, 985818688, 981253568, 976610304, 971891712, 967100672, 962240064, 957312576, 952321088, 947268224, 942156992, 936990080, 931770048, 926499840, 921182016, 915819200, 910414208, 904969344, 899487488, 893970944, 888422272, 882843840, 877238144, 871607552, 865954432, 860280896, 854589184, 848881728, 843160384, 837427328, 831684672, 825934208, 820178240, 814418240, 808656320, 802894208, 797133568, 791376192, 785623744, 779877568, 774139520, 768410880, 762693184, 756987904, 751296064, 745619328, 739958784, 734315584, 728691008, 723086208, 717502016, 711939712, 706400064, 700884096, 695392768, 689926912, 684487232, 679074688, 673689856, 668333504, 663006464, 657709056, 652442176, 647206144, 642001600, 636828992, 631688896, 626581696, 621507776, 616467520, 611461184, 606489344, 601552064, 596649792, 591782528, 586950784, 582154560, 577394112, 572669696, 567981312, 563329088, 558713152, 554133568, 549590464, 545083840, 540613760, 536180160, 531783104, 527422528, 523098464, 518810784, 514559520, 510344672, 506165856, 502023360, 497916832, 493846304, 489811488, 485812448, 481848832, 477920672, 474027808, 470169952, 466347008, 462558848, 458805152, 455085920, 451400736, 447749600, 444132160, 440548320, 436997792, 433480416, 429995904, 426544032, 423124608, 419737376, 416382144, 413058720, 409766720, 406505984, 403276288, 400077280, 396908768, 393770656, 390662496, 387584064, 384535200, 381515616, 378525024, 375563200, 372629952, 369724864, 366847872, 363998592, 361176672, 358382176, 355614592, 352873760, 350159456, 347471328, 344809216, 342172864, 339562048, 336976384, 334415808, 331879840, 329368576, 326881472, 324418432, 321979104, 319563392, 317170976, 314801664, 312455232, 310131328, 307829856, 305550528, 303293088, 301057440, 298843168, 296650176, 294478304, 292327168, 290196672, 288086432, 285996512, 283926432, 281876224, 279845472, 277834016, 275841792, 273868480, 271913856, 269977792, 268059968, 266160304, 264278672, 262414768, 260568368, 258739360, 256927520, 255132768, 253354752, 251593392, 249848448, 248119936, 246407424, 244710816, 243030080, 241364928, 239715120, 238080672, 236461248, 234856752, 233267088, 231692016, 230131440, 228585136, 227053024, 225534848, 224030544, 222539872, 221062832 }; - -/*----------------------------------------------------------------------* -* SPAR ROM tables -*-----------------------------------------------------------------------*/ - -const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = -{ -/* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel - so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - - { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - - { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 16400, 14850, 24350 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - - { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 24000, 20450, 31950 } }, - { { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 }, - - { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, - { { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 }, - - { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 }, - - { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, - { { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 0, 0 }, - - { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, - { { 21, 9, 9, 1 },{ 21, 7, 5, 1 },{ 21, 7, 5, 1 } }, 1, 0, 0 }, - - { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, - { { 21, 11, 9, 1 },{ 21, 9, 7, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - - { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, - { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - - { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, - { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - - { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, - { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, - { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, - { { 31, 11, 11, 1 },{ 1, 1, 1, 1 }, { 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, - { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, - { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, - { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, - { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124000, 124000, 128000 },{ 124000, 124000, 128000 },{ 125200, 118450, 128000 },{ 76300, 73000, 128000 } }, - { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - - { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 118000, 118000, 128000 },{ 118000, 118000, 128000 },{ 117200, 109250, 128000 },{ 72300, 69000, 128000 } }, - { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, -}; - -const ivas_spar_br_table_t ivas_spar_br_table_consts_fx[IVAS_SPAR_BR_TABLE_LEN] = /*ceilf(log2f)*/ -{ - /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel - so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, - { { 4, 0, 3, 0 },{ 4, 0, 2, 0 },{ 3, 0, 2, 0 } }, 0, 0, 0 }, - - { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, - { { 4, 0, 3, 0 },{ 4, 0, 2, 0 },{ 3, 0, 2, 0 } }, 0, 0, 0 }, - - { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 16400, 14850, 24350 } }, - { { 4, 0, 3, 0 },{ 4, 0, 2, 0 },{ 3, 0, 2, 0 } }, 0, 0, 0 }, - - { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 24000, 20450, 31950 } }, - { { 5, 0, 3, 0 },{ 4, 0, 3, 0 },{ 4, 0, 2, 0 } }, 0, 0, 0 }, - - { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, - { { 4, 3, 3, 0 },{ 4, 3, 2, 0 },{ 3, 3, 2, 0 } }, 1, 0, 0 }, - - { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 5, 3, 3, 0 },{ 4, 3, 3, 0 },{ 4, 3, 2, 0 } }, 1, 1, 0 }, - - { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, - { { 5, 3, 3, 0 },{ 4, 3, 3, 0 },{ 4, 3, 2, 0 } }, 1, 0, 0 }, - - { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, - { { 5, 4, 4, 0 },{ 5, 3, 3, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, - - { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, - { { 5, 4, 4, 0 },{ 5, 4, 3, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, - - { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, - { { 5, 4, 4, 0 },{ 5, 4, 4, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, - - { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, - { { 5, 4, 4, 0 },{ 5, 4, 4, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, - - { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, - { { 5, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, - { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, - { { 5, 4, 4, 0 },{ 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, - { { 5, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, - { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, - { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, - { { 5, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124000, 124000, 128000 },{ 124000, 124000, 128000 },{ 125200, 118450, 128000 },{ 76300, 73000, 128000 } }, - { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, - - { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 118000, 118000, 128000 },{ 118000, 118000, 128000 },{ 117200, 109250, 128000 },{ 72300, 69000, 128000 } }, - { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, -}; -const ivas_freq_models_t ivas_arith_pred_r_consts[TOTAL_PRED_QUANT_STRATS_ARITH] = -{ - /* entry for 1 quantization points */ - { - /* pred_R real */ - { - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - }, - /* pred_R real differential */ - { - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - }, - /* pred_R real : values for general and differential */ - { 0 },{ 0 }, - /* pred_R real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 7 quantization points for br_table_idx >= 2 */ - { - /* pred_R real */ - { - { 0,546,1092,2184,8740,2184,1092,546, }, - { 0,1779,2116,2516,3562,2516,2116,1779, }, - { 0,1848,2614,5229,2614,1848,1307,924, }, - { 0,924,1307,1848,2614,5229,2614,1848, }, - }, - /* pred_R real differential */ - { - { 0,125,399,1269,12798,1269,399,125, }, - { 0,744,1327,2365,7512,2365,1327,744, }, - { 0,1354,2413,7664,2413,1354,760,426, }, - { 0,426,760,1354,2413,7664,2413,1354, }, - }, - /* pred_R real : values for general and differential */ - { -3,-2,-1,0,1,2,3 },{ -3,-2,-1,0,1,2,3 }, - /* pred_R real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 15 quantization points for br_table_idx >= 2 */ - { - /* pred_R real */ - { - { 0,32,64,128,257,514,1028,2056,8226,2056,1028,514,257,128,64,32, }, - { 0,565,672,799,950,1130,1344,1598,2268,1598,1344,1130,950,799,672,565, }, - { 0,353,500,707,1000,1414,2000,4010,2000,1414,1000,707,500,353,250,176, }, - { 0,176,250,353,500,707,1000,1414,2000,4010,2000,1414,1000,707,500,353, }, - }, - /* pred_R real differential */ - { - { 0,1,3,12,39,125,397,1260,12710,1260,397,125,39,12,3,1, }, - { 0,66,119,212,378,674,1201,2140,6804,2140,1201,674,378,212,119,66, }, - { 0,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119,67,37, }, - { 0,37,67,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119, }, - }, - /* pred_R real : values for general and differential */ - { -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 }, - { -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 }, - /* pred_R real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 21 quantization points for br_table_idx >= 2 */ - { - /* pred_R real */ - { - { 0,4,8,16,32,64,128,256,512,1024,2049,8198,2049,1024,512,256,128,64,32,16,8,4, }, - { 0,292,348,414,492,585,696,828,984,1171,1392,1980,1392,1171,984,828,696,585,492,414,348,292, }, - { 0,119,168,238,336,476,673,952,1346,1904,3817,1904,1346,952,673,476,336,238,168,119,84,59, }, - { 0,59,84,119,168,238,336,476,673,952,1346,1904,3817,1904,1346,952,673,476,336,238,168,119, }, - }, - /* pred_R real differential */ - { - { 0,1,1,1,1,3,12,39,125,397,1260,12704,1260,397,125,39,12,3,1,1,1,1, }, - { 0,11,20,37,66,118,210,375,668,1191,2122,6748,2122,1191,668,375,210,118,66,37,20,11, }, - { 0,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20,11,6, }, - { 0,6,11,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20, }, - }, - /* pred_R real : values for general and differential */ - { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, - { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, - /* pred_R real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 31 quantization points */ - { - /* pred real */ - { - { 0,1,1,1,1,2,4,8,16,32,64,128,256,512,1024,2048,8188,2048,1024,512,256,128,64,32,16,8,4,2,1,1,1,1, }, - { 0,110,131,156,186,221,263,313,373,443,527,627,746,887,1055,1255,1798,1255,1055,887,746,627,527,443,373,313,263,221,186,156,131,110, }, - { 0,20,29,41,58,82,116,164,233,329,466,659,932,1318,1864,3738,1864,1318,932,659,466,329,233,164,116,82,58,41,29,20,14,10, }, - { 0,10,14,20,29,41,58,82,116,164,233,329,466,659,932,1318,1864,3738,1864,1318,932,659,466,329,233,164,116,82,58,41,29,20, } - }, - /* pred real differential */ - { - { 0,1,1,1,1,1,1,1,1,1,3,12,39,125,397,1260,12694,1260,397,125,39,12,3,1,1,1,1,1,1,1,1,1, }, - { 0,1,1,2,3,6,11,20,37,66,117,210,374,667,1189,2118,6740,2118,1189,667,374,210,117,66,37,20,11,6,3,2,1,1, }, - { 0,1,2,3,6,11,20,37,66,117,210,374,667,1189,2118,6740,2118,1189,667,374,210,117,66,37,20,11,6,3,2,1,1,1, }, - { 0,1,1,1,2,3,6,11,20,37,66,117,210,374,667,1189,2118,6740,2118,1189,667,374,210,117,66,37,20,11,6,3,2,1, } - }, - /* pred real : values for general and differential */ - { -15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, - { -15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, - /* pred real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 7 quantization points for br_table_idx < 2 */ - { - /* pred_R real */ - { - { 0,327,778,1851,10472,1851,778,327, }, - { 0,1057,1630,2514,5982,2514,1630,1057, }, - { 0,1668,2572,6122,2572,1668,1081,701, }, - { 0,701,1081,1668,2572,6122,2572,1668, }, - }, - /* pred_R real differential */ - { - { 0,125,399,1269,12798,1269,399,125, }, - { 0,744,1327,2365,7512,2365,1327,744, }, - { 0,1354,2413,7664,2413,1354,760,426, }, - { 0,426,760,1354,2413,7664,2413,1354, }, - }, - /* pred_R real : values for general and differential */ - { -3,-2,-1,0,1,2,3 },{ -3,-2,-1,0,1,2,3 }, - /* pred_R real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 15 quantization points for br_table_idx < 2 */ - { - /* pred real */ - { - { 0,9,23,56,133,318,757,1800,10192,1800,757,318,133,56,23,9, }, - { 0,156,240,371,573,883,1363,2102,5008,2102,1363,883,573,371,240,156, }, - { 0,241,372,575,886,1367,2109,5027,2109,1367,886,575,372,241,156,101, }, - { 0,101,156,241,372,575,886,1367,2109,5027,2109,1367,886,575,372,241, } - }, - /* pred real differential */ - { - { 0,1,3,12,39,125,397,1260,12710,1260,397,125,39,12,3,1, }, - { 0,66,119,212,378,674,1201,2140,6804,2140,1201,674,378,212,119,66, }, - { 0,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119,67,37, }, - { 0,37,67,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119, } - }, - /* pred real : values for general and differential */ - {-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7}, - { -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 }, - /* pred real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 21 quantization points for br_table_idx < 2 */ - { - /* pred_R real */ - { - { 0,1,1,4,9,23,56,133,318,756,1799,10184,1799,756,318,133,56,23,9,4,1,1, }, - { 0,41,64,98,152,234,362,558,861,1329,2049,4888,2049,1329,861,558,362,234,152,98,64,41, }, - { 0,64,98,152,235,362,559,862,1330,2051,4891,2051,1330,862,559,362,235,152,98,64,41,26, }, - { 0,26,41,64,98,152,235,362,559,862,1330,2051,4891,2051,1330,862,559,362,235,152,98,64, }, - }, - /* pred_R real differential */ - { - { 0,1,1,1,1,3,12,39,125,397,1260,12704,1260,397,125,39,12,3,1,1,1,1, }, - { 0,11,20,37,66,118,210,375,668,1191,2122,6748,2122,1191,668,375,210,118,66,37,20,11, }, - { 0,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20,11,6, }, - { 0,6,11,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20, }, - }, - /* pred_R real : values for general and differential */ - { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, - { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, - /* pred_R real : num dyn models for general and differential */ - 4, 4 - } -}; - -const ivas_freq_models_t ivas_arith_drct_r_consts[TOTAL_DRCT_QUANT_STRATS] = -{ - /* entry for 1 quantization points */ - { - /* drct real */ - { - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - }, - /* drct real differential */ - { - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - }, - /* drct real : values for general and differential */ - {0},{ 0 }, - /* drct real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 7 quantization points */ - { /* drct real */ - { - { 0,125,399,1269,12798,1269,399,125, }, - { 0,744,1327,2365,7512,2365,1327,744, }, - { 0,988,1244,1568,1976,2489,3136,4983, }, - { 0,2111,2262,2425,2788,2425,2262,2111, }, - }, - /* drct real differential */ - { - { 0,125,399,1269,12798,1269,399,125, }, - { 0,744,1327,2365,7512,2365,1327,744, }, - { 0,1354,2413,7664,2413,1354,760,426, }, - { 0,426,760,1354,2413,7664,2413,1354, }, - }, - /* drct real : values for general and differential */ - { -3,-2,-1,0,1,2,3 },{ -3,-2,-1,0,1,2,3 }, - /* drct real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 9 quantization points */ - { - /* drct real */ - { - { 0,39,125,397,1263,12736,1263,397,125,39, }, - { 0,397,708,1262,2250,7150,2250,1262,708,397, }, - { 0,573,722,909,1146,1444,1819,2292,2888,4591, }, - { 0,1587,1701,1824,1955,2250,1955,1824,1701,1587, }, - }, - /* drct real differential */ - { - { 0,39,125,397,1263,12736,1263,397,125,39, }, - { 0,397,708,1262,2250,7150,2250,1262,708,397, }, - { 0,716,1276,2274,7225,2274,1276,716,402,225, }, - { 0,225,402,716,1276,2274,7225,2274,1276,716, } - }, - /* drct real : values for general and differential */ - { -4,-3,-2,-1,0,1,2,3,4 },{ -4,-3,-2,-1,0,1,2,3,4 }, - /* drct real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 11 quantization points */ - { - /* drct real */ - { - { 0,12,39,125,397,1261,12716,1261,397,125,39,12, }, - { 0,217,387,689,1229,2190,6960,2190,1229,689,387,217, }, - { 0,343,433,546,687,866,1092,1375,1733,2184,2751,4374, }, - { 0,1254,1344,1441,1544,1655,1908,1655,1544,1441,1344,1254, }, - }, - /* drct real differential */ - { - { 0,12,39,125,397,1261,12716,1261,397,125,39,12, }, - { 0,217,387,689,1229,2190,6960,2190,1229,689,387,217, }, - { 0,389,694,1236,2203,7000,2203,1236,694,389,218,122, }, - { 0,122,218,389,694,1236,2203,7000,2203,1236,694,389, }, - }, - /* drct real : values for general and differential */ - { -5,-4,-3,-2,-1,0,1,2,3,4,5 },{ -5,-4,-3,-2,-1,0,1,2,3,4,5 }, - /* drct real : num dyn models for general and differential */ - 4, 4 - } -}; - -const ivas_freq_models_t ivas_arith_decd_r_consts[TOTAL_DECD_QUANT_STRATS] = -{ - /* entry for 1 quantization points */ - { - /* decd real */ - { - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - }, - /* decd real differential */ - { - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - { 0,16384, }, - }, - /* decd real : values for general and differential */ - { 0 },{ 0 }, - /* decd real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 3 quantization points */ - { - /* decd real */ - { - { 0,11917,2978,1489, }, - { 0,8840,4419,3125, }, - { 0,4567,7250,4567, }, - { 0,5203,5978,5203, }, - }, - /* decd real differential */ - { - { 0,1356,13672,1356, }, - { 0,3166,10052,3166, }, - { 0,10984,3459,1941, }, - { 0,1941,3459,10984, }, - }, - /* decd real : values for general and differential */ - { 0,1,2 },{-1,0,1}, - /* decd real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 5 quantization points */ - { - /* decd real */ - { - { 0,11157,2788,1394,697,348, }, - { 0,7186,3592,2540,1796,1270, }, - { 0,2512,3166,5028,3166,2512, }, - { 0,3048,3267,3754,3267,3048, }, - }, - /* decd real differential */ - { - { 0,406,1289,12994,1289,406, }, - { 0,1460,2601,8262,2601,1460, }, - { 0,2707,8599,2707,1519,852, }, - { 0,852,1519,2707,8599,2707, }, - }, - /* decd real : values for general and differential */ - { 0,1,2,3,4 },{ -2,-1,0,1,2 }, - /* decd real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 7 quantization points */ - { - /* decd real */ - { - { 0,10983,2744,1372,686,343,171,85, }, - { 0,6573,3285,2322,1642,1161,821,580, }, - { 0,1603,2020,2546,4046,2546,2020,1603, }, - { 0,2111,2262,2425,2788,2425,2262,2111, }, - }, - /* decd real differential */ - { - { 0,125,399,1269,12798,1269,399,125, }, - { 0,744,1327,2365,7512,2365,1327,744, }, - { 0,1354,2413,7664,2413,1354,760,426, }, - { 0,426,760,1354,2413,7664,2413,1354, } - }, - /* decd real : values for general and differential */ - { 0,1,2,3,4,5,6 },{ -3,-2,-1,0,1,2,3 }, - /* decd real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 9 quantization points */ - { /* decd real */ - { - { 0,10941,2734,1367,683,341,170,85,42,21, }, - { 0,6305,3150,2227,1575,1113,787,556,393,278, }, - { 0,1101,1388,1749,2203,3502,2203,1749,1388,1101, }, - { 0,1587,1701,1824,1955,2250,1955,1824,1701,1587, }, - }, - /* decd real differential */ - { - { 0,39,125,397,1263,12736,1263,397,125,39, }, - { 0,397,708,1262,2250,7150,2250,1262,708,397, }, - { 0,716,1276,2274,7225,2274,1276,716,402,225, }, - { 0,225,402,716,1276,2274,7225,2274,1276,716, } - }, - /* decd real : values for general and differential */ - { 0,1,2,3,4,5,6,7,8 },{ -4,-3,-2,-1,0,1,2,3,4 }, - /* decd real : num dyn models for general and differential */ - 4, 4 - }, - /* entry for 11 quantization points */ - { - /* decd real */ - { - { 0,10932,2731,1365,682,341,170,85,42,21,10,5, }, - { 0,6181,3086,2182,1543,1091,771,545,385,272,192,136, }, - { 0,790,995,1254,1580,1991,3164,1991,1580,1254,995,790, }, - { 0,1254,1344,1441,1544,1655,1908,1655,1544,1441,1344,1254, }, - }, - /* decd real differential */ - { - { 0,12,39,125,397,1261,12716,1261,397,125,39,12, }, - { 0,217,387,689,1229,2190,6960,2190,1229,689,387,217, }, - { 0,389,694,1236,2203,7000,2203,1236,694,389,218,122, }, - { 0,122,218,389,694,1236,2203,7000,2203,1236,694,389, }, - }, - /* decd real : values for general and differential */ - { 0,1,2,3,4,5,6,7,8,9,10 },{ -5,-4,-3,-2,-1,0,1,2,3,4,5 }, - /* decd real : num dyn models for general and differential */ - 4, 4 - } -}; - -const ivas_huff_models_t ivas_huff_pred_r_consts[TOTAL_PRED_QUANT_STRATS_HUFF] = -{ - /* entry for 1 quantization points for br_table_idx */ - {{{ 0 }}, {{ 0 }}}, - /* entry for 7 quantization points for br_table_idx */ - { - /* pred_R codebook */ - { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 }, }, - /* pred_R differential codebook */ - { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 }, }, - }, - /* entry for 15 quantization points for br_table_idx */ - { - /* pred_r codebook */ - { { -7,4,2 },{ -6,4,3 },{ -5, 4, 4 },{ -4, 4, 5 },{ -3,4,6 },{ -2,4,7 },{ -1,4,8 }, - { 0,3,0 },{ 1,4,9 },{ 2,4,10 },{ 3,4,11 },{ 4,4,12 },{ 5,4,13 },{ 6,4,14 },{ 7,4,15 } }, - /* pred_r differential codebook */ - { { -7,4,2 },{ -6,4,3 },{ -5, 4, 4 },{ -4, 4, 5 },{ -3,4,6 },{ -2,4,7 },{ -1,4,8 }, - { 0,3,0 },{ 1,4,9 },{ 2,4,10 },{ 3,4,11 },{ 4,4,12 },{ 5,4,13 },{ 6,4,14 },{ 7,4,15 } }, - }, - /* entry for 21 quantization points for br_table_idx=0 */ - { - /* pred_r codebook */ - { {-10,5,22},{-9,5,23},{-8,5,24},{-7,5,25},{-6,5,26}, { -5, 4, 0 },{ -4, 4, 1 },{ -3,4,2 },{ -2,4,3 },{ -1,4,4 }, - { 0,4,5 },{ 1,4,6 },{ 2,4,7 },{ 3,4,8 },{ 4,4,9 },{ 5,4,10 },{6,5,27},{7,5,28},{8,5,29},{9,5,30},{10,5,31} }, - /* pred_r differential codebook */ - { { -10,5,22 },{ -9,5,23 },{ -8,5,24 },{ -7,5,25 },{ -6,5,26 },{ -5, 4, 0 },{ -4, 4, 1 },{ -3,4,2 },{ -2,4,3 },{ -1,4,4 }, - { 0,4,5 },{ 1,4,6 },{ 2,4,7 },{ 3,4,8 },{ 4,4,9 },{ 5,4,10 },{ 6,5,27 },{ 7,5,28 },{ 8,5,29 },{ 9,5,30 },{ 10,5,31 } }, - }, - - /* entry for 31 quantization points for br_table_idx>0 */ - { - /* pred_r codebook */ - { {-15,5,2},{-14,5,3},{-13,5,4},{-12,5,5},{-11,5,6}, { -10,5,7 },{ -9,5,8 },{ -8,5,9 }, - { -7,5,10 },{ -6,5,11 },{ -5, 5, 12 },{ -4, 5, 13 },{ -3,5,14 },{ -2,5,15 },{ -1,5,16 }, - { 0,4,0 },{ 1,5,17 },{ 2,5,18 },{ 3,5,19 },{ 4,5,20 },{ 5,5,21 },{ 6,5,22 },{ 7,5,23 }, - { 8,5,24 },{ 9,5,25 },{ 10,5,26 },{11,5,27},{12,5,28},{13,5,29},{14,5,30},{15,5,31} }, - /* pred_r differential codebook */ - { { -15,5,2 },{ -14,5,3 },{ -13,5,4 },{ -12,5,5 },{ -11,5,6 },{ -10,5,7 },{ -9,5,8 },{ -8,5,9 }, - { -7,5,10 },{ -6,5,11 },{ -5, 5, 12 },{ -4, 5, 13 },{ -3,5,14 },{ -2,5,15 },{ -1,5,16 }, - { 0,4,0 },{ 1,5,17 },{ 2,5,18 },{ 3,5,19 },{ 4,5,20 },{ 5,5,21 },{ 6,5,22 },{ 7,5,23 }, - { 8,5,24 },{ 9,5,25 },{ 10,5,26 },{ 11,5,27 },{ 12,5,28 },{ 13,5,29 },{ 14,5,30 },{ 15,5,31 } }, - }, - }; - - const ivas_huff_models_t ivas_huff_drct_r_consts[TOTAL_DRCT_QUANT_STRATS] = -{ - /* entry for 1 quantization points */ - {{{ 0 }}, {{ 0 }}}, - /* entry for 7 quantization points */ - { - /* drct_r codebook */ - { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 } }, - /* drct_r differential codebook */ - { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 } }, - }, - /* entry for 9 quantization points */ - { - /* drct_r codebook */ - { { -4, 4, 14 },{ -3,3,0 },{ -2,3,1 },{ -1,3,2 },{ 0,3,3 },{ 1,3,4 },{ 2,3,5 },{ 3,3,6 },{ 4,4,15 } }, - /* drct_r differential codebook */ - { { -4, 4, 14 },{ -3,3,0 },{ -2,3,1 },{ -1,3,2 },{ 0,3,3 },{ 1,3,4 },{ 2,3,5 },{ 3,3,6 },{ 4,4,15 } }, - }, - /* entry for 11 quantization points */ - { - /* drct_r codebook */ - { { -5, 4, 10 },{ -4, 4, 11 },{ -3,4,12 },{ -2,3,0 },{ -1,3,1 },{ 0,3,2 },{ 1,3,3 },{ 2,3,4 },{ 3,4,13 },{ 4,4,14 },{ 5,4,15 } }, - /* drct_r differential codebook */ - { { -5, 4, 10 },{ -4, 4, 11 },{ -3,4,12 },{ -2,3,0 },{ -1,3,1 },{ 0,3,2 },{ 1,3,3 },{ 2,3,4 },{ 3,4,13 },{ 4,4,14 },{ 5,4,15 } }, - }, -}; - -const ivas_huff_models_t ivas_huff_decd_r_consts[TOTAL_DECD_QUANT_STRATS] = -{ - /* entry for 1 quantization points */ - {{{ 0 }}, {{ 0 }}}, - /* entry for 3 quantization points */ - { - /* decd_r codebook */ - { { 0, 2, 2 },{ 1, 1, 0 },{ 2,2,3 } }, - /* decd_r differential codebook */ - { { -1, 2, 2 },{ 0, 1, 0 },{ 1,2,3 } }, - }, - /* entry for 5 quantization points */ - { - /* decd_r codebook */ - { { 0,3,6 },{ 1,2,0 },{ 2,2,1 },{ 3,2,2 },{ 4,3,7 } }, - /* decd_r differential codebook */ - { { -2,3,6 },{ -1,2,0 },{ 0,2,1 },{ 1,2,2 },{ 2,3,7 } }, - }, - /* entry for 7 quantization points */ - { - /* decd_r */ - { { 0, 3, 2 },{ 1, 3, 3 },{ 2,3,4 },{ 3,3,0 },{ 4,3,5 },{ 5,3,6 },{ 6,3,7 } }, - /* decd_r codebook differential codebook */ - { { -3, 3, 2 },{ -2, 3, 3 },{ -1,3,4 },{ 0,3,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 } }, - }, - /* entry for 9 quantization points */ - { - /* decd_r codebook */ - { { 0, 4, 14 },{ 1,3,0 },{ 2,3,1 },{ 3,3,2 },{ 4,3,3 },{ 5,3,4 },{ 6,3,5 },{ 7,3,6 },{ 8,4,15 } }, - /* decd_r differential codebook */ - { { -4, 4, 14 },{ -3,3,0 },{ -2,3,1 },{ -1,3,2 },{ 0,3,3 },{ 1,3,4 },{ 2,3,5 },{ 3,3,6 },{ 4,4,15 } }, - }, - /* entry for 11 quantization points */ - { - /* decd_r codebook */ - { { 0, 4, 10 },{ 1, 4, 11 },{ 2,4,12 },{ 3,3,0 },{ 4,3,1 },{ 5,3,2 },{ 6,3,3 },{ 7,3,4 },{ 8,4,13 },{ 9,4,14 },{ 10,4,15 } }, - /* decd_r differential codebook */ - { { -5, 4, 10 },{ -4, 4, 11 },{ -3,4,12 },{ -2,3,0 },{ -1,3,1 },{ 0,3,2 },{ 1,3,3 },{ 2,3,4 },{ 3,4,13 },{ 4,4,14 },{ 5,4,15 } }, - }, -}; - -/* DTX quantization and bitstream constants */ - -const Word16 dtx_pd_real_q_levels[3][3] = { { 7,7,7 },{ 7,7,0 },{ 3,0,0 } }; -const Word16 dtx_pr_real_q_levels[3][3] = { { 9,9,9 },{ 9,7,9 },{ 9,5,7 } }; -const Word16 pr_pr_idx_pairs[3][3][2] = { { { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 1, 3 },{ 0, 0 } } }; -const Word16 pr_pd_idx_pairs[3][3][2] = { { { 1, 1 },{ 2, 2 },{ 3, 3 } },{ { 1, 1 },{ 3, 2 },{ 2, 0 } },{ { 2, 1 },{ 0, 0 },{ 0, 0 } } }; - -const Word16 remix_order_set[1][DIRAC_MAX_ANA_CHANS] = { /* WYZX --> WYXZ... */ - { 0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10 } -}; - -const Word16 HOA_keep_ind[IVAS_SPAR_MAX_FB_IN_CHAN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15}; -const Word16 HOA_keep_ind_spar[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 8, 9, 10, 10, 10, 10}; -const Word16 HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - - -/*----------------------------------------------------------------------* -* PCA ROM tables -*-----------------------------------------------------------------------*/ - -const Word32 ivas_pca_offset_index1[IVAS_PCA_N1 + 1] = -{ - 0, 1, 9, 61, 163, 359, 685, 1125, 1747, - 2519, 3521, 4713, 6183, 7883, 9809, 12093, 14633, 17575, - 20807, 24343, 28181, 32487, 37121, 42097, 47405, 53057, 59061, - 65421, 72137, 79205, 86625, 94415, 102345, 110629, 119263, 128017, - 137097, 146515, 156043, 165637, 175551, 185515, 195535, 205837, 216183, - 226545, 236911, 247273, 257619, 267921, 277941, 287905, 297819, 307413, - 316941, 326359, 335439, 344193, 352827, 361111, 369041, 376831, 384251, - 391319, 398035, 404395, 410399, 416051, 421359, 426335, 430969, 435275, - 439113, 442649, 445881, 448823, 451363, 453647, 455573, 457273, 458743, - 459935, 460937, 461709, 462331, 462771, 463097, 463293, 463395, 463447, - 463455, 463456 -}; - -const Word16 ivas_pca_offset_index2[2692] = -{ - 0, 1, 0, 1, 7, 8, 0, 1, 7, 19, - 33, 45, 51, 52, 0, 1, 9, 23, 41, 61, - 79, 93, 101, 102, 0, 1, 7, 21, 39, 61, - 85, 111, 135, 157, 175, 189, 195, 196, 0, 1, - 7, 19, 37, 59, 85, 115, 147, 179, 211, 241, - 267, 289, 307, 319, 325, 326, 0, 1, 7, 21, - 41, 65, 95, 127, 163, 201, 239, 277, 313, 345, - 375, 399, 419, 433, 439, 440, 0, 1, 7, 19, - 37, 61, 91, 125, 163, 203, 245, 289, 333, 377, - 419, 459, 497, 531, 561, 585, 603, 615, 621, 622, - 0, 1, 7, 21, 41, 67, 97, 133, 173, 217, - 263, 311, 361, 411, 461, 509, 555, 599, 639, 675, - 705, 731, 751, 765, 771, 772, 0, 1, 7, 19, - 37, 61, 91, 127, 167, 211, 259, 309, 363, 417, - 473, 529, 585, 639, 693, 743, 791, 835, 875, 911, - 941, 965, 983, 995, 1001, 1002, 0, 1, 7, 21, - 41, 67, 99, 135, 177, 223, 273, 327, 383, 443, - 503, 565, 627, 689, 749, 809, 865, 919, 969, 1015, - 1057, 1093, 1125, 1151, 1171, 1185, 1191, 1192, 0, 1, - 7, 19, 37, 61, 91, 127, 169, 215, 265, 319, - 377, 437, 501, 567, 633, 701, 769, 837, 903, 969, - 1033, 1093, 1151, 1205, 1255, 1301, 1343, 1379, 1409, 1433, - 1451, 1463, 1469, 1470, 0, 1, 7, 21, 41, 67, - 99, 137, 179, 227, 279, 335, 395, 459, 525, 595, - 667, 739, 813, 887, 961, 1033, 1105, 1175, 1241, 1305, - 1365, 1421, 1473, 1521, 1563, 1601, 1633, 1659, 1679, 1693, - 1699, 1700, 0, 1, 9, 23, 43, 69, 101, 139, - 183, 231, 285, 343, 405, 471, 541, 613, 689, 765, - 843, 923, 1003, 1083, 1161, 1237, 1313, 1385, 1455, 1521, - 1583, 1641, 1695, 1743, 1787, 1825, 1857, 1883, 1903, 1917, - 1925, 1926, 0, 1, 7, 21, 41, 67, 99, 137, - 179, 227, 281, 339, 401, 467, 537, 611, 687, 767, - 849, 931, 1015, 1099, 1185, 1269, 1353, 1435, 1517, 1597, - 1673, 1747, 1817, 1883, 1945, 2003, 2057, 2105, 2147, 2185, - 2217, 2243, 2263, 2277, 2283, 2284, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 285, 345, 409, 477, - 549, 625, 705, 787, 871, 957, 1045, 1135, 1225, 1315, - 1405, 1495, 1583, 1669, 1753, 1835, 1915, 1991, 2063, 2131, - 2195, 2255, 2309, 2359, 2403, 2441, 2473, 2499, 2519, 2533, - 2539, 2540, 0, 1, 7, 19, 39, 65, 97, 135, - 177, 225, 279, 337, 401, 469, 541, 617, 697, 781, - 867, 955, 1045, 1137, 1231, 1327, 1423, 1519, 1615, 1711, - 1805, 1897, 1987, 2075, 2161, 2245, 2325, 2401, 2473, 2541, - 2605, 2663, 2717, 2765, 2807, 2845, 2877, 2903, 2923, 2935, - 2941, 2942, 0, 1, 7, 21, 41, 67, 99, 137, - 181, 229, 283, 343, 407, 477, 551, 629, 711, 797, - 885, 977, 1071, 1167, 1265, 1365, 1465, 1565, 1667, 1767, - 1867, 1967, 2065, 2161, 2255, 2347, 2435, 2521, 2603, 2681, - 2755, 2825, 2889, 2949, 3003, 3051, 3095, 3133, 3165, 3191, - 3211, 3225, 3231, 3232, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 347, 413, 483, 559, 639, - 723, 811, 903, 997, 1093, 1193, 1295, 1399, 1503, 1609, - 1715, 1821, 1927, 2033, 2137, 2241, 2343, 2443, 2539, 2633, - 2725, 2813, 2897, 2977, 3053, 3123, 3189, 3249, 3305, 3355, - 3399, 3437, 3469, 3495, 3515, 3529, 3535, 3536, 0, 1, - 7, 21, 41, 67, 99, 137, 181, 231, 287, 349, - 415, 487, 563, 645, 731, 821, 915, 1011, 1111, 1213, - 1317, 1423, 1531, 1641, 1751, 1863, 1975, 2087, 2197, 2307, - 2415, 2521, 2625, 2727, 2827, 2923, 3017, 3107, 3193, 3275, - 3351, 3423, 3489, 3551, 3607, 3657, 3701, 3739, 3771, 3797, - 3817, 3831, 3837, 3838, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 285, 345, 411, 481, 557, 637, - 721, 809, 901, 997, 1097, 1199, 1305, 1413, 1523, 1635, - 1749, 1863, 1979, 2095, 2211, 2327, 2443, 2557, 2671, 2783, - 2893, 3001, 3107, 3209, 3309, 3405, 3497, 3585, 3669, 3749, - 3825, 3895, 3961, 4021, 4075, 4125, 4169, 4207, 4239, 4265, - 4285, 4299, 4305, 4306, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 347, 413, 485, 561, 643, - 729, 819, 913, 1011, 1113, 1217, 1325, 1435, 1547, 1663, - 1779, 1897, 2017, 2137, 2257, 2377, 2497, 2617, 2737, 2855, - 2971, 3087, 3199, 3309, 3417, 3521, 3623, 3721, 3815, 3905, - 3991, 4073, 4149, 4221, 4287, 4347, 4403, 4453, 4497, 4535, - 4567, 4593, 4613, 4627, 4633, 4634, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 415, 487, - 565, 647, 733, 825, 921, 1021, 1125, 1231, 1341, 1453, - 1569, 1687, 1807, 1929, 2051, 2175, 2299, 2425, 2551, 2677, - 2801, 2925, 3047, 3169, 3289, 3407, 3523, 3635, 3745, 3851, - 3955, 4055, 4151, 4243, 4329, 4411, 4489, 4561, 4627, 4689, - 4745, 4795, 4839, 4877, 4909, 4935, 4955, 4969, 4975, 4976, - 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, - 287, 349, 417, 489, 567, 649, 737, 829, 925, 1025, - 1129, 1237, 1349, 1463, 1581, 1701, 1823, 1947, 2073, 2201, - 2329, 2459, 2589, 2719, 2849, 2979, 3107, 3235, 3361, 3485, - 3607, 3727, 3845, 3959, 4071, 4179, 4283, 4383, 4479, 4571, - 4659, 4741, 4819, 4891, 4959, 5021, 5077, 5127, 5171, 5209, - 5241, 5267, 5287, 5301, 5307, 5308, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 417, 489, - 567, 651, 739, 831, 929, 1031, 1137, 1247, 1361, 1477, - 1597, 1719, 1843, 1969, 2097, 2227, 2359, 2491, 2625, 2759, - 2893, 3027, 3161, 3293, 3425, 3555, 3683, 3809, 3933, 4055, - 4175, 4291, 4405, 4515, 4621, 4723, 4821, 4913, 5001, 5085, - 5163, 5235, 5303, 5365, 5421, 5471, 5515, 5553, 5585, 5611, - 5631, 5645, 5651, 5652, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 569, 653, - 741, 835, 933, 1035, 1141, 1251, 1365, 1483, 1603, 1727, - 1853, 1983, 2115, 2249, 2383, 2519, 2657, 2795, 2933, 3071, - 3209, 3347, 3485, 3621, 3755, 3889, 4021, 4151, 4277, 4401, - 4521, 4639, 4753, 4863, 4969, 5071, 5169, 5263, 5351, 5435, - 5513, 5587, 5655, 5717, 5773, 5823, 5867, 5905, 5937, 5963, - 5983, 5997, 6003, 6004, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 569, 653, - 741, 835, 933, 1037, 1145, 1257, 1373, 1491, 1613, 1739, - 1867, 1997, 2131, 2267, 2405, 2543, 2683, 2825, 2967, 3109, - 3251, 3393, 3535, 3677, 3817, 3955, 4093, 4229, 4363, 4493, - 4621, 4747, 4869, 4987, 5103, 5215, 5323, 5427, 5525, 5619, - 5707, 5791, 5869, 5943, 6011, 6073, 6129, 6179, 6223, 6261, - 6293, 6319, 6339, 6353, 6359, 6360, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, - 569, 653, 743, 837, 935, 1039, 1147, 1259, 1375, 1495, - 1619, 1745, 1875, 2007, 2143, 2281, 2421, 2563, 2705, 2849, - 2993, 3139, 3285, 3431, 3577, 3723, 3867, 4011, 4153, 4295, - 4435, 4573, 4709, 4841, 4971, 5097, 5221, 5341, 5457, 5569, - 5677, 5781, 5879, 5973, 6063, 6147, 6225, 6299, 6367, 6429, - 6485, 6535, 6579, 6617, 6649, 6675, 6695, 6709, 6715, 6716, - 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, - 287, 349, 417, 491, 569, 653, 743, 837, 937, 1041, - 1149, 1261, 1377, 1497, 1621, 1749, 1879, 2013, 2149, 2287, - 2429, 2573, 2717, 2863, 3011, 3159, 3309, 3459, 3609, 3759, - 3909, 4057, 4205, 4351, 4495, 4639, 4781, 4919, 5055, 5189, - 5319, 5447, 5571, 5691, 5807, 5919, 6027, 6131, 6231, 6325, - 6415, 6499, 6577, 6651, 6719, 6781, 6837, 6887, 6931, 6969, - 7001, 7027, 7047, 7061, 7067, 7068, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, - 569, 653, 743, 837, 937, 1041, 1149, 1261, 1377, 1497, - 1621, 1749, 1881, 2015, 2153, 2293, 2435, 2579, 2725, 2873, - 3023, 3175, 3327, 3479, 3633, 3787, 3941, 4093, 4245, 4397, - 4547, 4695, 4841, 4985, 5127, 5267, 5405, 5539, 5671, 5799, - 5923, 6043, 6159, 6271, 6379, 6483, 6583, 6677, 6767, 6851, - 6929, 7003, 7071, 7133, 7189, 7239, 7283, 7321, 7353, 7379, - 7399, 7413, 7419, 7420, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 489, 567, 651, - 741, 835, 935, 1039, 1147, 1259, 1377, 1499, 1625, 1753, - 1885, 2021, 2159, 2301, 2445, 2591, 2739, 2889, 3041, 3195, - 3349, 3505, 3661, 3817, 3973, 4129, 4285, 4441, 4595, 4749, - 4901, 5051, 5199, 5345, 5489, 5631, 5769, 5905, 6037, 6165, - 6291, 6413, 6531, 6643, 6751, 6855, 6955, 7049, 7139, 7223, - 7301, 7373, 7441, 7503, 7559, 7609, 7653, 7691, 7723, 7749, - 7769, 7783, 7789, 7790, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, - 747, 843, 945, 1051, 1161, 1277, 1397, 1521, 1649, 1781, - 1915, 2053, 2195, 2339, 2485, 2635, 2787, 2941, 3095, 3251, - 3409, 3567, 3725, 3885, 4045, 4205, 4363, 4521, 4679, 4835, - 4989, 5143, 5295, 5445, 5591, 5735, 5877, 6015, 6149, 6281, - 6409, 6533, 6653, 6769, 6879, 6985, 7087, 7183, 7273, 7359, - 7439, 7513, 7581, 7643, 7699, 7749, 7793, 7831, 7863, 7889, - 7909, 7923, 7929, 7930, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, - 747, 843, 943, 1049, 1159, 1273, 1393, 1517, 1645, 1777, - 1913, 2051, 2193, 2337, 2485, 2635, 2787, 2941, 3097, 3255, - 3415, 3575, 3737, 3899, 4061, 4223, 4385, 4547, 4709, 4869, - 5029, 5187, 5343, 5497, 5649, 5799, 5947, 6091, 6233, 6371, - 6507, 6639, 6767, 6891, 7011, 7125, 7235, 7341, 7441, 7537, - 7627, 7713, 7793, 7867, 7935, 7997, 8053, 8103, 8147, 8185, - 8217, 8243, 8263, 8277, 8283, 8284, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, - 571, 655, 745, 841, 941, 1047, 1157, 1271, 1389, 1513, - 1641, 1773, 1907, 2045, 2187, 2331, 2479, 2629, 2783, 2939, - 3097, 3257, 3417, 3579, 3743, 3907, 4071, 4235, 4399, 4563, - 4727, 4891, 5055, 5217, 5377, 5537, 5695, 5851, 6005, 6155, - 6303, 6447, 6589, 6727, 6861, 6993, 7121, 7245, 7363, 7477, - 7587, 7693, 7793, 7889, 7979, 8063, 8143, 8217, 8285, 8347, - 8403, 8453, 8497, 8535, 8567, 8593, 8613, 8627, 8633, 8634, - 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, - 287, 349, 417, 491, 571, 657, 749, 845, 947, 1053, - 1165, 1281, 1401, 1527, 1657, 1791, 1929, 2069, 2213, 2361, - 2511, 2663, 2819, 2977, 3137, 3299, 3463, 3627, 3793, 3959, - 4125, 4293, 4461, 4629, 4795, 4961, 5127, 5291, 5455, 5617, - 5777, 5935, 6091, 6243, 6393, 6541, 6685, 6825, 6963, 7097, - 7227, 7353, 7473, 7589, 7701, 7807, 7909, 8005, 8097, 8183, - 8263, 8337, 8405, 8467, 8523, 8573, 8617, 8655, 8687, 8713, - 8733, 8747, 8753, 8754, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, - 747, 843, 943, 1049, 1159, 1275, 1395, 1519, 1647, 1779, - 1915, 2055, 2199, 2345, 2495, 2647, 2803, 2961, 3121, 3283, - 3447, 3613, 3779, 3947, 4115, 4285, 4455, 4625, 4795, 4965, - 5133, 5301, 5467, 5633, 5797, 5959, 6119, 6277, 6433, 6585, - 6735, 6881, 7025, 7165, 7301, 7433, 7561, 7685, 7805, 7921, - 8031, 8137, 8237, 8333, 8423, 8509, 8589, 8663, 8731, 8793, - 8849, 8899, 8943, 8981, 9013, 9039, 9059, 9073, 9079, 9080, - 0, 1, 7, 19, 39, 65, 97, 135, 179, 229, - 285, 347, 415, 489, 567, 651, 741, 835, 935, 1041, - 1151, 1265, 1385, 1509, 1637, 1769, 1905, 2045, 2189, 2335, - 2485, 2637, 2793, 2951, 3111, 3273, 3437, 3603, 3771, 3939, - 4109, 4279, 4451, 4623, 4795, 4967, 5139, 5309, 5479, 5647, - 5815, 5981, 6145, 6307, 6467, 6625, 6781, 6933, 7083, 7229, - 7373, 7513, 7649, 7781, 7909, 8033, 8153, 8267, 8377, 8483, - 8583, 8677, 8767, 8851, 8929, 9003, 9071, 9133, 9189, 9239, - 9283, 9321, 9353, 9379, 9399, 9411, 9417, 9418, 0, 1, - 7, 21, 41, 67, 99, 137, 181, 231, 287, 349, - 417, 491, 571, 657, 747, 843, 945, 1051, 1163, 1279, - 1399, 1525, 1655, 1789, 1927, 2069, 2213, 2361, 2513, 2667, - 2825, 2985, 3147, 3311, 3477, 3645, 3815, 3985, 4157, 4329, - 4503, 4677, 4851, 5025, 5199, 5371, 5543, 5713, 5883, 6051, - 6217, 6381, 6543, 6703, 6861, 7015, 7167, 7315, 7459, 7601, - 7739, 7873, 8003, 8129, 8249, 8365, 8477, 8583, 8685, 8781, - 8871, 8957, 9037, 9111, 9179, 9241, 9297, 9347, 9391, 9429, - 9461, 9487, 9507, 9521, 9527, 9528, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, - 571, 657, 749, 845, 947, 1055, 1167, 1285, 1407, 1533, - 1663, 1797, 1935, 2077, 2223, 2373, 2525, 2681, 2839, 3001, - 3165, 3331, 3499, 3669, 3839, 4011, 4185, 4359, 4533, 4709, - 4885, 5061, 5235, 5409, 5583, 5755, 5925, 6095, 6263, 6429, - 6593, 6755, 6913, 7069, 7221, 7371, 7517, 7659, 7797, 7931, - 8061, 8187, 8309, 8427, 8539, 8647, 8749, 8845, 8937, 9023, - 9103, 9177, 9245, 9307, 9363, 9413, 9457, 9495, 9527, 9553, - 9573, 9587, 9593, 9594, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 571, 655, - 745, 841, 941, 1047, 1157, 1273, 1393, 1517, 1647, 1781, - 1919, 2061, 2207, 2355, 2507, 2663, 2821, 2981, 3145, 3311, - 3479, 3649, 3821, 3993, 4167, 4341, 4517, 4693, 4869, 5045, - 5221, 5397, 5573, 5747, 5921, 6093, 6265, 6435, 6603, 6769, - 6933, 7093, 7251, 7407, 7559, 7707, 7853, 7995, 8133, 8267, - 8397, 8521, 8641, 8757, 8867, 8973, 9073, 9169, 9259, 9343, - 9423, 9497, 9565, 9627, 9683, 9733, 9777, 9815, 9847, 9873, - 9893, 9907, 9913, 9914, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, - 747, 843, 945, 1051, 1163, 1279, 1401, 1527, 1657, 1791, - 1929, 2071, 2217, 2367, 2519, 2675, 2835, 2997, 3161, 3327, - 3495, 3665, 3837, 4011, 4185, 4361, 4537, 4715, 4893, 5071, - 5249, 5427, 5603, 5779, 5953, 6127, 6299, 6469, 6637, 6803, - 6967, 7129, 7289, 7445, 7597, 7747, 7893, 8035, 8173, 8307, - 8437, 8563, 8685, 8801, 8913, 9019, 9121, 9217, 9307, 9393, - 9473, 9547, 9615, 9677, 9733, 9783, 9827, 9865, 9897, 9923, - 9943, 9957, 9963, 9964, 0, 1, 7, 21, 41, 67, - 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, - 749, 845, 947, 1055, 1167, 1285, 1407, 1533, 1663, 1799, - 1939, 2083, 2229, 2379, 2533, 2689, 2849, 3011, 3177, 3345, - 3515, 3687, 3861, 4035, 4211, 4387, 4565, 4743, 4921, 5099, - 5277, 5455, 5633, 5809, 5985, 6159, 6333, 6505, 6675, 6843, - 7009, 7171, 7331, 7487, 7641, 7791, 7937, 8081, 8221, 8357, - 8487, 8613, 8735, 8853, 8965, 9073, 9175, 9271, 9363, 9449, - 9529, 9603, 9671, 9733, 9789, 9839, 9883, 9921, 9953, 9979, - 9999, 10013, 10019, 10020, 0, 1, 7, 19, 39, 65, - 97, 135, 179, 229, 285, 347, 415, 489, 567, 651, - 741, 837, 937, 1043, 1153, 1269, 1389, 1513, 1643, 1777, - 1915, 2057, 2203, 2351, 2503, 2659, 2817, 2979, 3143, 3309, - 3477, 3647, 3819, 3993, 4169, 4345, 4523, 4701, 4881, 5061, - 5241, 5421, 5601, 5779, 5957, 6133, 6309, 6483, 6655, 6825, - 6993, 7159, 7323, 7485, 7643, 7799, 7951, 8099, 8245, 8387, - 8525, 8659, 8789, 8913, 9033, 9149, 9259, 9365, 9465, 9561, - 9651, 9735, 9813, 9887, 9955, 10017, 10073, 10123, 10167, 10205, - 10237, 10263, 10283, 10295, 10301, 10302, 0, 1, 7, 21, - 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, - 571, 655, 745, 841, 941, 1047, 1159, 1275, 1395, 1521, - 1651, 1785, 1923, 2065, 2211, 2361, 2513, 2669, 2829, 2991, - 3155, 3321, 3491, 3663, 3837, 4011, 4187, 4365, 4543, 4723, - 4903, 5083, 5263, 5443, 5623, 5803, 5981, 6159, 6335, 6509, - 6683, 6855, 7025, 7191, 7355, 7517, 7677, 7833, 7985, 8135, - 8281, 8423, 8561, 8695, 8825, 8951, 9071, 9187, 9299, 9405, - 9505, 9601, 9691, 9775, 9855, 9929, 9997, 10059, 10115, 10165, - 10209, 10247, 10279, 10305, 10325, 10339, 10345, 10346, 0, 1, - 7, 21, 41, 67, 99, 137, 181, 231, 287, 349, - 417, 491, 571, 655, 745, 841, 943, 1049, 1161, 1277, - 1397, 1523, 1653, 1787, 1925, 2067, 2213, 2363, 2517, 2673, - 2833, 2995, 3159, 3327, 3497, 3669, 3843, 4019, 4195, 4373, - 4551, 4731, 4911, 5091, 5271, 5451, 5631, 5811, 5989, 6167, - 6343, 6519, 6693, 6865, 7035, 7203, 7367, 7529, 7689, 7845, - 7999, 8149, 8295, 8437, 8575, 8709, 8839, 8965, 9085, 9201, - 9313, 9419, 9521, 9617, 9707, 9791, 9871, 9945, 10013, 10075, - 10131, 10181, 10225, 10263, 10295, 10321, 10341, 10355, 10361, 10362, - 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, - 287, 349, 417, 491, 571, 657, 747, 843, 945, 1051, - 1163, 1279, 1399, 1525, 1655, 1789, 1927, 2069, 2215, 2365, - 2519, 2675, 2835, 2997, 3161, 3329, 3499, 3671, 3845, 4021, - 4197, 4375, 4553, 4733, 4913, 5093, 5273, 5453, 5633, 5813, - 5991, 6169, 6345, 6521, 6695, 6867, 7037, 7205, 7369, 7531, - 7691, 7847, 8001, 8151, 8297, 8439, 8577, 8711, 8841, 8967, - 9087, 9203, 9315, 9421, 9523, 9619, 9709, 9795, 9875, 9949, - 10017, 10079, 10135, 10185, 10229, 10267, 10299, 10325, 10345, 10359, - 10365, 10366 -}; - -const Word16 ivas_pca_offset_n2[IVAS_PCA_N1] = -{ - 0, 2, 6, 14, 24, 38, 56, 76, 100, 126, 156, 188, - 224, 262, 302, 346, 392, 442, 494, 548, 604, 664, 726, 790, - 856, 924, 994, 1066, 1140, 1216, 1294, 1374, 1454, 1536, 1620, 1704, - 1790, 1878, 1966, 2054, 2144, 2234, 2324, 2416, 2508, 2600, 2692, 2784, - 2876, 2968, 3058, 3148, 3238, 3326, 3414, 3502, 3588, 3672, 3756, 3838, - 3918, 3998, 4076, 4152, 4226, 4298, 4368, 4436, 4502, 4566, 4628, 4688, - 4744, 4798, 4850, 4900, 4946, 4990, 5030, 5068, 5104, 5136, 5166, 5192, - 5216, 5236, 5254, 5268, 5278, 5286, 5290 -}; - -const Word16 ph1_q_n2_tbl[IVAS_PCA_N1][2] = { /* ph1_q : Q13, n2 : Q0 */ - { 0, 1 }, - { 286, 3 }, - { 572, 7 }, - { 858, 9 }, - { 1144, 13 }, - { 1430, 17 }, - { 1716, 19 }, - { 2002, 23 }, - { 2288, 25 }, - { 2574, 29 }, - { 2860, 31 }, - { 3146, 35 }, - { 3431, 37 }, - { 3717, 39 }, - { 4003, 43 }, - { 4289, 45 }, - { 4575, 49 }, - { 4861, 51 }, - { 5147, 53 }, - { 5433, 55 }, - { 5719, 59 }, - { 6005, 61 }, - { 6291, 63 }, - { 6577, 65 }, - { 6863, 67 }, - { 7149, 69 }, - { 7435, 71 }, - { 7721, 73 }, - { 8007, 75 }, - { 8293, 77 }, - { 8579, 79 }, - { 8865, 79 }, - { 9151, 81 }, - { 9437, 83 }, - { 9722, 83 }, - { 10008, 85 }, - { 10294, 87 }, - { 10580, 87 }, - { 10866, 87 }, - { 11152, 89 }, - { 11438, 89 }, - { 11724, 89 }, - { 12010, 91 }, - { 12296, 91 }, - { 12582, 91 }, - { 12868, 91 }, - { 13154, 91 }, - { 13440, 91 }, - { 13726, 91 }, - { 14012, 89 }, - { 14298, 89 }, - { 14584, 89 }, - { 14870, 87 }, - { 15156, 87 }, - { 15442, 87 }, - { 15728, 85 }, - { 16013, 83 }, - { 16299, 83 }, - { 16585, 81 }, - { 16871, 79 }, - { 17157, 79 }, - { 17443, 77 }, - { 17729, 75 }, - { 18015, 73 }, - { 18301, 71 }, - { 18587, 69 }, - { 18873, 67 }, - { 19159, 65 }, - { 19445, 63 }, - { 19731, 61 }, - { 20017, 59 }, - { 20303, 55 }, - { 20589, 53 }, - { 20875, 51 }, - { 21161, 49 }, - { 21447, 45 }, - { 21733, 43 }, - { 22019, 39 }, - { 22304, 37 }, - { 22590, 35 }, - { 22876, 31 }, - { 23162, 29 }, - { 23448, 25 }, - { 23734, 23 }, - { 24020, 19 }, - { 24306, 17 }, - { 24592, 13 }, - { 24878, 9 }, - { 25164, 7 }, - { 25450, 3 }, - { 25736, 1 } -}; - - -/*----------------------------------------------------------------------------------* - * Parametric MC ROM tables - *----------------------------------------------------------------------------------*/ - -const Word16 param_mc_band_grouping_20[20 + 1] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 17, 20, 23, 27, 33, 40, 52, 60 -}; - -const Word16 param_mc_coding_band_mapping_20[20] = -{ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -const Word16 param_mc_bands_coded_20[4] = -{ - 10, 14, 18, 20 -}; - -const Word16 param_mc_band_grouping_14[14 + 1] = -{ - 0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 28, 40, 60 -}; - -const Word16 param_mc_coding_band_mapping_14[14] = -{ - 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 -}; - -const Word16 param_mc_bands_coded_14[4] = -{ - 8, 11, 13, 14 -}; - -const Word16 param_mc_band_grouping_10[10 + 1] = -{ - 0, 1, 2, 3, 5, 7, 10, 14, 20, 40, 60 -}; - - -const Word16 param_mc_bands_coded_10[4] = -{ - 6, 8, 9, 10 -}; - -const Word16 param_mc_coding_band_mapping_10[10] = -{ - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 -}; - -const Word16 Param_MC_index[MAX_CICP_CHANNELS] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 -}; - - -const Word32 ivas_param_mc_dmx_fac_CICP6_2tc_fx[12] = -{ - 2147483647,0,1518500224,1518500224,2147483647,0, /*Lt*/ - 0,2147483647,1518500224,1518500224,0,2147483647 /*Rt*/ -}; - -const Word32 ivas_param_mc_dmx_fac_CICP12_2tc_fx[16] = -{ - 2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0, /*Lt*/ - 0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647 /*Rt*/ -}; - -const Word32 ivas_param_mc_dmx_fac_CICP12_3tc_fx[24] = -{ - 2147483647,0,0,0,2147483647,0,2147483647,0, /*Lt*/ - 0,2147483647,0,0,0,2147483647,0,2147483647, /*Rt*/ - 0,0,2147483647,2147483647,0,0,0,0 /*Ct*/ -}; - -const Word32 ivas_param_mc_dmx_fac_CICP14_2tc_fx[16] = -{ - 2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0, /*Lt*/ - 0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647 /*Rt*/ -}; -const Word32 ivas_param_mc_dmx_fac_CICP14_3tc_fx[24] = -{ - 2147483647,0,0,0,2147483647,0,2147483647,0, /*Lt*/ - 0,2147483647,0,0,0,2147483647,0,2147483647, /*Rt*/ - 0,0,2147483647,2147483647,0,0,0,0 /*Ct*/ -}; - -const Word32 ivas_param_mc_dmx_fac_CICP16_3tc_fx[30] = -{ - 2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0, /*Lt*/ - 0,2147483647,0,0,0,2147483647,0,2147483647,0,2147483647, /*Rt*/ - 0,0,2147483647,2147483647,0,0,0,0,0,0 /*Ct*/ -}; - -const Word32 ivas_param_mc_dmx_fac_CICP19_3tc_fx[36] = -{ - 2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0,2147483647,0, /*Lt*/ - 0,2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0,2147483647, /*Rt*/ - 0,0,2147483647,2147483647,0,0,0,0,0,0,0,0 /*Ct*/ -}; - -const Word32 ivas_param_mc_dmx_fac_CICP19_4tc_fx[48] = -{ - 2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0,0,0,0,0, /*Lht*/ - 0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647,0,0,0,0, /*Rht*/ - 0,0,0,0,0,0,0,0,2147483647,0,2147483647,0, /*Lut*/ - 0,0,0,0,0,0,0,0,0,2147483647,0,2147483647 /*Rut*/ -}; - - -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP6_2tc_fx[6] = -{ - 12832, - 12832, - 6820, - 10607, - 10607, - 6820 -}; - -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP12_2tc_fx[8] = -{ - 11965, - 11965, - 6816, - 6877, - 6877, - 5619, - 5619, - 6816 -}; - -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP12_3tc_fx[8] = -{ - 16384, - 16384, - 9502, - 9502, - 6553, - 6553, - 32767, - 8192 -}; -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP14_2tc_fx[8] = -{ - 11936, - 11936, - 5993, - 6945, - 6945, - 8049, - 8049, - 6816 -}; - -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP14_3tc_fx[8] = -{ - 16291, - 16291, - 8257, - 8257, - 9666, - 9666, - 32767, - 8192 -}; - -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP16_3tc_fx[10] = -{ - 11141, - 11141, - 7209, - 7209, - 6553, - 6553, - 5898, - 5898, - 32767, - 8192 -}; - -//Q15 -const Word16 ivas_param_mc_ild_fac_CICP19_3tc_fx[12] = -{ - 9830, - 9830, - 5570, - 5570, - 3932, - 3932, - 6226, - 6226, - 6226, - 6226, - 32767, - 16384 -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP6_2tc = -{ - 5, - 6, - {0,1,2,4,5,3}, - {1,1,2,1,1,2}, - {{0},{1},{0,1},{0},{1},{0,1}} -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP12_2tc = -{ - 7, - 8, - {0,1,2,4,5,6,7,3}, - {1,1,2,1,1,1,1,2}, - {{0},{1},{0,1},{0},{1},{0},{1},{0,1}} -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP12_3tc = -{ - 6, - 8, - {0,1,4,5,6,7,2,3}, - {1,1,1,1,1,1,1,1}, - {{0},{1},{0},{1},{0},{1},{2},{2}} -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP14_2tc = -{ - 7, - 8, - {0,1,2,4,5,6,7,3}, - {1,1,2,1,1,1,1,2}, - {{0},{1},{0,1},{0},{1},{0},{1},{0,1}} -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP14_3tc = -{ - 6, - 8, - {0,1,4,5,6,7,2,3}, - {1,1,1,1,1,1,1,1}, - {{0},{1},{0},{1},{0},{1},{2},{2}} -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP16_3tc = -{ - 8, - 10, - {0,1,4,5,6,7,8,9,2,3}, - {1,1,1,1,1,1,1,1,1,1}, - {{0},{1},{0},{1},{0},{1},{0},{1},{2},{2}} -}; - -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP19_3tc = -{ - 10, - 12, - {0,1,4,5,6,7,8,9,10,11,2,3}, - {1,1,1,1,1,1,1,1,1,1,1,1}, - {{0},{1},{0},{1},{0},{1},{0},{1},{0},{1},{2},{2}} -}; - -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP6_2tc = -{ - 4, - 5, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 2, 3 }} /* C/LFE */ -}; - -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP12_2tc = -{ - 6, - 7, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 2, 6 }, /* C/BLS */ - { 2, 7 }, /* C/BRS */ - { 2, 3 } /* C/LFE */ - } -}; - -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP12_3tc = -{ - 6, - 7, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 0, 6 }, /* L/BLS */ - { 1, 7 }, /* R/BRS */ - { 2, 3 } /* C/LFE */ - } -}; - -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP14_2tc = -{ - 6, - 7, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 2, 6 }, /* C/UFL */ - { 2, 7 }, /* C/UFR */ - { 2, 3 } /* C/LFE */ - } -}; -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP14_3tc = -{ - 6, - 7, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 0, 6 }, /* L/UFL */ - { 1, 7 }, /* R/UFR */ - { 2, 3 } /* C/LFE */ - } -}; - -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP16_3tc = -{ - 8, - 9, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 0, 6 }, /* L/UFL */ - { 1, 7 }, /* R/UFR */ - { 4, 8 }, /* LS/UBL */ - { 5, 9 }, /* RS/UBR */ - { 2, 3 } /* C/LFE */ - } -}; - -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP19_3tc = -{ - 10, - 11, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 0, 6 }, /* L/LBS */ - { 1, 7 }, /* R/RBS */ - { 0, 8 }, /* L/UFL */ - { 1, 9 }, /* R/UFR */ - { 6, 10 }, /* LBS/UBL */ - { 7, 11 }, /* RBS/UBR */ - { 2, 3 } /* C/LFE */ - } -}; - -const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = -{ - /* CICP6 48000 */ - { - MC_LS_SETUP_5_1, - 6, - 2, - IVAS_48k, - &ivas_param_mc_ild_mapping_CICP6_2tc, - &ivas_param_mc_icc_mapping_CICP6_2tc, - &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] - }, - /* CICP6 64000 */ - { - MC_LS_SETUP_5_1, - 6, - 2, - IVAS_64k, - &ivas_param_mc_ild_mapping_CICP6_2tc, - &ivas_param_mc_icc_mapping_CICP6_2tc, - &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], - & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] - }, - /* CICP6 80000 */ - { - MC_LS_SETUP_5_1, - 6, - 2, - IVAS_80k, - &ivas_param_mc_ild_mapping_CICP6_2tc, - &ivas_param_mc_icc_mapping_CICP6_2tc, - &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], - & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] - }, - /* CICP12 48000 */ - { - MC_LS_SETUP_7_1, - 8, - 2, - IVAS_48k, - &ivas_param_mc_ild_mapping_CICP12_2tc, - &ivas_param_mc_icc_mapping_CICP12_2tc, - &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0] - }, - /* CICP12 64000 */ - { - MC_LS_SETUP_7_1, - 8, - 2, - IVAS_64k, - &ivas_param_mc_ild_mapping_CICP12_2tc, - &ivas_param_mc_icc_mapping_CICP12_2tc, - &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0] - }, - /* CICP12 80000 */ - { - MC_LS_SETUP_7_1, - 8, - 2, - IVAS_80k, - &ivas_param_mc_ild_mapping_CICP12_2tc, - &ivas_param_mc_icc_mapping_CICP12_2tc, - &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0], - }, - /* CICP12 96000 */ - { - MC_LS_SETUP_7_1, - 8, - 3, - IVAS_96k, - &ivas_param_mc_ild_mapping_CICP12_3tc, - &ivas_param_mc_icc_mapping_CICP12_3tc, - &ivas_param_mc_ild_fac_CICP12_3tc_fx[0], - &ivas_param_mc_dmx_fac_CICP12_3tc_fx[0] - }, - /* CICP14 48000 */ - { - MC_LS_SETUP_5_1_2, - 8, - 2, - IVAS_48k, - &ivas_param_mc_ild_mapping_CICP14_2tc, - &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] - }, - /* CICP14 64000 */ - { - MC_LS_SETUP_5_1_2, - 8, - 2, - IVAS_64k, - &ivas_param_mc_ild_mapping_CICP14_2tc, - &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] - }, - /* CICP14 80000 */ - { - MC_LS_SETUP_5_1_2, - 8, - 2, - IVAS_80k, - &ivas_param_mc_ild_mapping_CICP14_2tc, - &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], - &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] - }, - /* CICP14 96000 */ - { - MC_LS_SETUP_5_1_2, - 8, - 3, - IVAS_96k, - &ivas_param_mc_ild_mapping_CICP14_3tc, - &ivas_param_mc_icc_mapping_CICP14_3tc, - &ivas_param_mc_ild_fac_CICP14_3tc_fx[0], - &ivas_param_mc_dmx_fac_CICP14_3tc_fx[0] - }, - /* CICP16 96000 */ - { - MC_LS_SETUP_5_1_4, - 10, - 3, - IVAS_96k, - &ivas_param_mc_ild_mapping_CICP16_3tc, - &ivas_param_mc_icc_mapping_CICP16_3tc, - &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], - &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] - }, - /* CICP16 128000 */ - { - MC_LS_SETUP_5_1_4, - 10, - 3, - IVAS_128k, - &ivas_param_mc_ild_mapping_CICP16_3tc, - &ivas_param_mc_icc_mapping_CICP16_3tc, - &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], - &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] - }, - /* CICP19 128000 */ +/*----------------------------------------------------------------------------------* + * IVAS limiter table + *----------------------------------------------------------------------------------*/ +const Word32 release_cnst_table[4][201] = // Q31 { - MC_LS_SETUP_7_1_4, - 12, - 3, - IVAS_128k, - &ivas_param_mc_ild_mapping_CICP19_3tc, - &ivas_param_mc_icc_mapping_CICP19_3tc, - &ivas_param_mc_ild_fac_CICP19_3tc_fx[0], - &ivas_param_mc_dmx_fac_CICP19_3tc_fx[0] - } -}; - - -/* Alphabet for delta coding for the ICCs in Parametric MC processing */ -const UWord16 ivas_param_mc_cum_freq_icc_cicp6_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = -{ - 0, 24, 224, 20873, 42384, 51699, 57122, 60572, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_cicp6_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 24, 200, 20649, 21511, 9315, 5423, 3450, 4963 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 0, 4, 9, 124, 447, 1311, 4453, 18116, 48636, 60573, 63692, 64746, 65327, 65531, 65534, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1] = -{ - 4, 5, 115, 323, 864, 3142, 13663, 30520, 11937, 3119, 1054, 581, 204, 3, 1 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_cicp12_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = -{ - 0, 30, 848, 26611, 47846, 57358, 61679, 63237, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_cicp12_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 30, 818, 25763, 21235, 9512, 4321, 1558, 2298 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 0, 2, 7, 53, 243, 979, 3994, 16732, 49642, 61343, 64331, 65158, 65438, 65532, 65534, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1] = -{ - 2, 5, 46, 190, 736, 3015, 12738, 32910, 11701, 2988, 827, 280, 94, 2, 1 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_cicp14_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = -{ - 0, 46, 826, 27798, 49552, 58447, 62046, 63284, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_cicp14_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER ]={ - 46, 780, 26972, 21754, 8895, 3599, 1238, 2251 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_delta_cicp14_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 0, 3, 8, 36, 172, 763, 3436, 15845, 50168, 62005, 64676, 65298, 65481, 65533, 65534, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_delta_cicp14_48_16bits[2* PARAM_MC_SZ_ICC_QUANTIZER - 1] = -{ - 3, 5, 28, 136, 591, 2673, 12409, 34323, 11837, 2671, 622, 183, 52, 1, 1 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_combined_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = -{ - 0, 34, 552, 24717, 45819, 54772, 59054, 61166, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_combined_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 34, 518, 24165, 21102, 8953, 4282, 2112, 4369 -}; - -const UWord16 ivas_param_mc_cum_freq_icc_delta_combined_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = -{ - 0, 3, 7, 74, 304, 1009, 3870, 16502, 49834, 61384, 64217, 65020, 65369, 65531, 65534, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1] = -{ - 3, 4, 67, 230, 705, 2861, 12632, 33332, 11550, 2833, 803, 349, 162, 3, 1 -}; - -const UWord16 ivas_param_mc_cum_freq_ild_cicp6_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1] = -{ - 0, 1092, 5574, 8315, 10652, 13875, 19656, 27664, 36284, 47058, 56251, 62579, 65118, 65462, 65513, 65532, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_ild_cicp6_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = -{ - 1092, 4482, 2741, 2337, 3223, 5781, 8008, 8620, 10774, 9193, 6328, 2539, 344, 51, 19, 3 -}; - -const UWord16 ivas_param_mc_cum_freq_ild_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = -{ - 0, 1, 2, 3, 5, 38, 146, 352, 638, 997, 1559, 2323, 3570, 5859, 10556, 21075, 44682, 55617, 60408, 62739, 63833, 64443, 64809, 65074, 65279, 65400, 65484, 65531, 65532, 65533, 65534, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_ild_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = -{ - 1, 1, 1, 2, 33, 108, 206, 286, 359, 562, 764, 1247, 2289, 4697, 10519, 23607, 10935, 4791, 2331, 1094, 610, 366, 265, 205, 121, 84, 47, 1, 1, 1, 1 -}; - -const UWord16 ivas_param_mc_cum_freq_ild_cicp12_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1] = -{ - 0, 967, 6335, 9941, 12837, 16652, 22416, 29814, 38807, 48497, 57184, 62661, 64916, 65466, 65514, 65530, 65535 -}; - -const UWord16 ivas_param_mc_sym_freq_ild_cicp12_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = -{ - 967, 5368, 3606, 2896, 3815, 5764, 7398, 8993, 9690, 8687, 5477, 2255, 550, 48, 16, 5 -}; + { + 1913946752, + 1919716352, + 1925351680, + 1930855552, + 1936230784, + 1941479808, + 1946605312, + 1951609728, + 1956495744, + 1961265792, + 1965922304, + 1970467584, + 1974904320, + 1979234560, + 1983460736, + 1987585024, + 1991609856, + 1995537280, + 1999369344, + 2003108480, + 2006756480, + 2010315520, + 2013787520, + 2017174528, + 2020478464, + 2023701248, + 2026844672, + 2029910656, + 2032900992, + 2035817344, + 2038661376, + 2041435008, + 2044139648, + 2046777088, + 2049348864, + 2051856384, + 2054301440, + 2056685312, + 2059009536, + 2061275520, + 2063484672, + 2065638272, + 2067737856, + 2069784448, + 2071779584, + 2073724416, + 2075620096, + 2077467904, + 2079268992, + 2081024512, + 2082735488, + 2084403200, + 2086028416, + 2087612544, + 2089156352, + 2090660864, + 2092127104, + 2093555968, + 2094948480, + 2096305408, + 2097627776, + 2098916352, + 2100172032, + 2101395584, + 2102587776, + 2103749504, + 2104881408, + 2105984384, + 2107059072, + 2108106112, + 2109126400, + 2110120448, + 2111088896, + 2112032512, + 2112951808, + 2113847552, + 2114720128, + 2115570304, + 2116398592, + 2117205504, + 2117991552, + 2118757504, + 2119503616, + 2120230400, + 2120938496, + 2121628288, + 2122300288, + 2122954880, + 2123592576, + 2124213760, + 2124818944, + 2125408384, + 2125982592, + 2126541952, + 2127086848, + 2127617664, + 2128134656, + 2128638336, + 2129128832, + 2129606784, + 2130072192, + 2130525568, + 2130967296, + 2131397376, + 2131816448, + 2132224640, + 2132622080, + 2133009408, + 2133386496, + 2133753856, + 2134111744, + 2134460288, + 2134799744, + 2135130368, + 2135452416, + 2135766144, + 2136071680, + 2136369152, + 2136659072, + 2136941312, + 2137216256, + 2137484160, + 2137744896, + 2137998976, + 2138246400, + 2138487424, + 2138722176, + 2138950656, + 2139173376, + 2139390208, + 2139601408, + 2139807104, + 2140007424, + 2140202624, + 2140392576, + 2140577664, + 2140758016, + 2140933504, + 2141104512, + 2141271040, + 2141433216, + 2141591168, + 2141745024, + 2141894912, + 2142040832, + 2142182912, + 2142321408, + 2142456192, + 2142587392, + 2142715264, + 2142839808, + 2142961152, + 2143079296, + 2143194240, + 2143306240, + 2143415424, + 2143521664, + 2143625216, + 2143725952, + 2143824128, + 2143919744, + 2144012800, + 2144103424, + 2144191744, + 2144277760, + 2144361472, + 2144443136, + 2144522496, + 2144599936, + 2144675200, + 2144748544, + 2144820096, + 2144889600, + 2144957440, + 2145023488, + 2145087744, + 2145150336, + 2145211264, + 2145270656, + 2145328512, + 2145384832, + 2145439616, + 2145493120, + 2145545088, + 2145595776, + 2145645056, + 2145693184, + 2145739904, + 2145785472, + 2145829888, + 2145873152, + 2145915136, + 2145956224, + 2145996032, + 2146034944, + 2146072832, + 2146109696, + 2146145664, + 2146180608, + 2146214656, + 2146247808, + }, + { + 2027355264, + 2030408704, + 2033386624, + 2036290944, + 2039123328, + 2041885440, + 2044578944, + 2047205376, + 2049766528, + 2052263680, + 2054698496, + 2057072384, + 2059387008, + 2061643520, + 2063843328, + 2065987968, + 2068078720, + 2070116864, + 2072103552, + 2074040192, + 2075927936, + 2077767936, + 2079561472, + 2081309568, + 2083013376, + 2084673920, + 2086292352, + 2087869696, + 2089406976, + 2090905216, + 2092365184, + 2093788032, + 2095174528, + 2096525824, + 2097842432, + 2099125632, + 2100375808, + 2101594240, + 2102781312, + 2103938048, + 2105065216, + 2106163456, + 2107233536, + 2108276096, + 2109292032, + 2110281728, + 2111246080, + 2112185728, + 2113101056, + 2113992960, + 2114861824, + 2115708288, + 2116532992, + 2117336448, + 2118119168, + 2118881792, + 2119624704, + 2120348416, + 2121053440, + 2121740288, + 2122409344, + 2123061120, + 2123696128, + 2124314624, + 2124917120, + 2125504128, + 2126075776, + 2126632832, + 2127175296, + 2127703808, + 2128218624, + 2128720000, + 2129208448, + 2129684352, + 2130147712, + 2130599168, + 2131038976, + 2131467264, + 2131884416, + 2132290816, + 2132686592, + 2133072256, + 2133447680, + 2133813504, + 2134169856, + 2134516864, + 2134854784, + 2135184000, + 2135504640, + 2135816960, + 2136121216, + 2136417536, + 2136706048, + 2136987136, + 2137260928, + 2137527552, + 2137787264, + 2138040192, + 2138286592, + 2138526464, + 2138760192, + 2138987776, + 2139209472, + 2139425408, + 2139635712, + 2139840512, + 2140039936, + 2140234240, + 2140423424, + 2140607744, + 2140787200, + 2140962048, + 2141132288, + 2141298048, + 2141459584, + 2141616896, + 2141769984, + 2141919232, + 2142064512, + 2142205952, + 2142343808, + 2142478080, + 2142608768, + 2142736128, + 2142860032, + 2142980864, + 2143098368, + 2143212928, + 2143324544, + 2143433088, + 2143538944, + 2143641984, + 2143742336, + 2143840000, + 2143935232, + 2144027904, + 2144118144, + 2144206080, + 2144291712, + 2144375168, + 2144456320, + 2144535424, + 2144612480, + 2144687488, + 2144760448, + 2144831616, + 2144900992, + 2144968448, + 2145034112, + 2145098112, + 2145160448, + 2145221248, + 2145280256, + 2145337856, + 2145393920, + 2145448576, + 2145501696, + 2145553536, + 2145603968, + 2145653120, + 2145700992, + 2145747456, + 2145792896, + 2145837056, + 2145880064, + 2145922048, + 2145962880, + 2146002560, + 2146041344, + 2146078976, + 2146115712, + 2146151424, + 2146186240, + 2146220160, + 2146253184, + 2146285312, + 2146316672, + 2146347136, + 2146376832, + 2146405760, + 2146433920, + 2146461440, + 2146488192, + 2146514176, + 2146539520, + 2146564224, + 2146588160, + 2146611584, + 2146634368, + 2146656640, + 2146678272, + 2146699264, + 2146719744, + 2146739712, + 2146759168, + 2146778112, + 2146796544, + 2146814464, + 2146832000, + 2146849024, + 2146865664, + }, + { + 2086555136, + 2088125824, + 2089656576, + 2091148416, + 2092602240, + 2094018944, + 2095399680, + 2096745088, + 2098056192, + 2099333888, + 2100578816, + 2101792000, + 2102974080, + 2104125824, + 2105248128, + 2106341760, + 2107407232, + 2108445440, + 2109456896, + 2110442496, + 2111402624, + 2112338176, + 2113249664, + 2114137728, + 2115002880, + 2115845760, + 2116666880, + 2117466880, + 2118246272, + 2119005568, + 2119745280, + 2120465920, + 2121167872, + 2121851776, + 2122517888, + 2123166976, + 2123799168, + 2124414976, + 2125014912, + 2125599360, + 2126168704, + 2126723200, + 2127263360, + 2127789568, + 2128302208, + 2128801408, + 2129287808, + 2129761536, + 2130222976, + 2130672512, + 2131110272, + 2131536768, + 2131952128, + 2132356736, + 2132750848, + 2133134720, + 2133508736, + 2133872896, + 2134227584, + 2134573184, + 2134909696, + 2135237504, + 2135556736, + 2135867648, + 2136170624, + 2136465536, + 2136752896, + 2137032832, + 2137305344, + 2137570816, + 2137829376, + 2138081280, + 2138326528, + 2138565504, + 2138798080, + 2139024768, + 2139245440, + 2139460480, + 2139669888, + 2139873792, + 2140072320, + 2140265856, + 2140454144, + 2140637696, + 2140816384, + 2140990464, + 2141159936, + 2141325056, + 2141485824, + 2141642368, + 2141794944, + 2141943424, + 2142088064, + 2142228992, + 2142366208, + 2142499840, + 2142630016, + 2142756736, + 2142880128, + 2143000448, + 2143117440, + 2143231488, + 2143342592, + 2143450752, + 2143556096, + 2143658624, + 2143758592, + 2143855872, + 2143950592, + 2144043008, + 2144132864, + 2144220416, + 2144305664, + 2144388608, + 2144469504, + 2144548224, + 2144624896, + 2144699648, + 2144772352, + 2144843264, + 2144912256, + 2144979328, + 2145044864, + 2145108480, + 2145170560, + 2145231104, + 2145289856, + 2145347200, + 2145403008, + 2145457408, + 2145510400, + 2145561984, + 2145612160, + 2145661056, + 2145708672, + 2145755136, + 2145800192, + 2145844224, + 2145887104, + 2145928832, + 2145969408, + 2146008960, + 2146047616, + 2146085120, + 2146121600, + 2146157184, + 2146191872, + 2146225664, + 2146258560, + 2146290560, + 2146321792, + 2146352128, + 2146381696, + 2146410496, + 2146438528, + 2146465920, + 2146492416, + 2146518400, + 2146543616, + 2146568192, + 2146592128, + 2146615424, + 2146638080, + 2146660224, + 2146681728, + 2146702720, + 2146723072, + 2146743040, + 2146762368, + 2146781184, + 2146799616, + 2146817408, + 2146834816, + 2146851840, + 2146868352, + 2146884352, + 2146900096, + 2146915328, + 2146930176, + 2146944640, + 2146958720, + 2146972416, + 2146985856, + 2146998784, + 2147011456, + 2147023872, + 2147035904, + 2147047552, + 2147058944, + 2147070080, + 2147080832, + 2147091456, + 2147101696, + 2147111680, + 2147121408, + 2147130880, + 2147140096, + 2147149056, + 2147157760, + 2147166336, + 2147174656, + }, + { + 2106670080, + 2107727232, + 2108757120, + 2109760640, + 2110738432, + 2111691008, + 2112619136, + 2113523328, + 2114404352, + 2115262592, + 2116098816, + 2116913408, + 2117707136, + 2118480256, + 2119233536, + 2119967360, + 2120682240, + 2121378688, + 2122057088, + 2122717952, + 2123361792, + 2123988992, + 2124599936, + 2125195136, + 2125774848, + 2126339584, + 2126889728, + 2127425536, + 2127947520, + 2128456064, + 2128951296, + 2129433856, + 2129903744, + 2130361600, + 2130807424, + 2131241728, + 2131664768, + 2132076928, + 2132478208, + 2132869248, + 2133250048, + 2133620992, + 2133982208, + 2134334080, + 2134676864, + 2135010688, + 2135335936, + 2135652608, + 2135961088, + 2136261504, + 2136554112, + 2136839168, + 2137116800, + 2137387136, + 2137650560, + 2137907072, + 2138156928, + 2138400256, + 2138637184, + 2138867968, + 2139092864, + 2139311744, + 2139524992, + 2139732736, + 2139934976, + 2140131968, + 2140323840, + 2140510720, + 2140692736, + 2140870016, + 2141042688, + 2141210752, + 2141374592, + 2141534080, + 2141689344, + 2141840640, + 2141987968, + 2142131456, + 2142271232, + 2142407424, + 2142539904, + 2142669056, + 2142794752, + 2142917248, + 2143036544, + 2143152640, + 2143265792, + 2143375872, + 2143483264, + 2143587712, + 2143689472, + 2143788544, + 2143885056, + 2143979136, + 2144070656, + 2144159872, + 2144246656, + 2144331264, + 2144413568, + 2144493824, + 2144571904, + 2144647936, + 2144722048, + 2144794240, + 2144864512, + 2144932864, + 2144999552, + 2145064448, + 2145127680, + 2145189248, + 2145249152, + 2145307520, + 2145364480, + 2145419776, + 2145473792, + 2145526272, + 2145577472, + 2145627264, + 2145675776, + 2145723008, + 2145768960, + 2145813760, + 2145857408, + 2145899904, + 2145941376, + 2145981696, + 2146020864, + 2146059136, + 2146096384, + 2146132608, + 2146167936, + 2146202368, + 2146235776, + 2146268416, + 2146300160, + 2146331136, + 2146361216, + 2146390528, + 2146419200, + 2146446976, + 2146474112, + 2146500480, + 2146526208, + 2146551168, + 2146575488, + 2146599296, + 2146622464, + 2146644864, + 2146666880, + 2146688128, + 2146708992, + 2146729216, + 2146748928, + 2146768128, + 2146786816, + 2146805120, + 2146822784, + 2146840064, + 2146856960, + 2146873344, + 2146889216, + 2146904832, + 2146919936, + 2146934656, + 2146948992, + 2146962944, + 2146976640, + 2146989824, + 2147002752, + 2147015296, + 2147027584, + 2147039488, + 2147051136, + 2147062400, + 2147073408, + 2147084160, + 2147094528, + 2147104768, + 2147114624, + 2147124352, + 2147133696, + 2147142912, + 2147151744, + 2147160448, + 2147168896, + 2147177088, + 2147185152, + 2147192960, + 2147200512, + 2147207936, + 2147215104, + 2147222144, + 2147229056, + 2147235712, + 2147242112, + 2147248384, + 2147254656, + 2147260544, + 2147266432, + 2147272064, + 2147277568, + }, -const UWord16 ivas_param_mc_cum_freq_ild_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = -{ - 0, 1, 2, 3, 5, 18, 61, 149, 320, 592, 1083, 1793, 2974, 5257, 10133, 21274, 44342, 55891, 60895, 63174, 64244, 64793, 65100, 65287, 65406, 65477, 65517, 65531, 65532, 65533, 65534, 65535 -}; -const UWord16 ivas_param_mc_sym_freq_ild_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = -{ - 1, 1, 1, 2, 13, 43, 88, 171, 272, 491, 710, 1181, 2283, 4876, 11141, 23068, 11549, 5004, 2279, 1070, 549, 307, 187, 119, 71, 40, 14, 1, 1, 1, 1 -}; + }; -const UWord16 ivas_param_mc_cum_freq_ild_cicp14_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1] = -{ - 0, 229, 7068, 10910, 13856, 17467, 22629, 29174, 36906, 46558, 55579, 61802, 65222, 65505, 65527, 65534, 65535 -}; +/*------------------------------------------------------------------------- + * DFT Stereo ROM tables + *------------------------------------------------------------------------*/ -const UWord16 ivas_param_mc_sym_freq_ild_cicp14_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +/*4xERB scale: max of 14 bands*/ +const Word16 dft_band_limits_erb4[STEREO_DFT_ERB4_BANDS] = { - 229, 6839, 3842, 2946, 3611, 5162, 6545, 7732, 9652, 9021, 6223, 3420, 283, 22, 7, 1 + 1, 3, 5, 10, 18, 26, 41, 56, 84, 132, 214, 342, 470, 601 }; -const UWord16 ivas_param_mc_cum_freq_ild_delta_cicp14_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +/*8xERB scale: max of 8 bands*/ +const Word16 dft_band_limits_erb8[STEREO_DFT_ERB8_BANDS] = { - 0, 1, 2, 3, 4, 12, 56, 153, 278, 475, 856, 1430, 2489, 4723, 9580, 20685, 45423, 56274, 60948, 63097, 64128, 64679, 65002, 65208, 65348, 65445, 65517, 65531, 65532, 65533, 65534, 65535 + 1, 5, 18, 41, 84, 214, 470, 601 }; -const UWord16 ivas_param_mc_sym_freq_ild_delta_cicp14_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = -{ - 1, 1, 1, 1, 8, 44, 97, 125, 197, 381, 574, 1059, 2234, 4857, 11105, 24738, 10851, 4674, 2149, 1031, 551, 323, 206, 140, 97, 72, 14, 1, 1, 1, 1 -}; -const UWord16 ivas_param_mc_cum_freq_ild_combined_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS+1] = +const Word16 dft_band_ipd[3][4] = { - 0, 1453, 8326, 12221, 15164, 18764, 24177, 31297, 39520, 49154, 57135, 62460, 64821, 65468, 65514, 65530, 65535 + {0,8,10,13}, + {0,5,6,8}, + {0,2,3,4} }; -const UWord16 ivas_param_mc_sym_freq_ild_combined_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +const Word16 dft_band_res_cod[3][4] = { - 1453, 6873, 3895, 2943, 3600, 5413, 7120, 8223, 9634, 7981, 5325, 2361, 647, 46, 16, 5 + {0,8,10,11}, + {0,5,6,7}, + {0,5,6,7} }; -const UWord16 ivas_param_mc_cum_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +// Q31 +const Word32 dft_res_gains_q_Q31[][2] = { - 0, 1, 2, 3, 5, 29, 98, 220, 414, 699, 1186, 1876, 3049, 5304, 10013, 20612, 45247, 56109, 60818, 63022, 64081, 64647, 64977, 65198, 65348, 65443, 65502, 65530, 65532, 65533, 65534, 65535 -}; + /* quantization points for joint quantization of prediction gain and residual energy */ -const UWord16 ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = -{ - 1, 1, 1, 2, 24, 69, 122, 194, 285, 487, 690, 1173, 2255, 4709, 10599, 24635, 10862, 4709, 2204, 1059, 566, 330, 221, 150, 95, 59, 28, 2, 1, 1, 1 -}; + /* column 1 (|ILD| = 0): */ + {0, 0 }, + {0, 251216928 }, + {0, 487459456 }, + {0, 731632640 }, + {0, 997611392 }, + {0, 1299397248 }, + {0, 1666984192 }, + {0, 2147483647 }, + /* column 2 (|ILD| = 2): */ + {246151024, 0 }, + {249475328, 247871152 }, + {258660112, 480729248 }, + {274304544, 720918848 }, + {298427200, 981720000 }, + {334663840, 1276185088 }, + {391374592, 1632160640 }, + {485919712, 2091786496 }, -/*----------------------------------------------------------------------------------* - * MASA ROM tables - *----------------------------------------------------------------------------------*/ + /* column 3 (|ILD| = 4): */ + {485919712, 0 }, + {492224736, 238188144 }, + {509610752, 461283776 }, + {539117184, 690072384 }, + {584326016, 936189056 }, + {651608832, 1210182144 }, + {755411712, 1534299776 }, + {924504576, 1938292992 }, -const Word64 diffuseness_reconstructions_hr_fx[HR_MASA_ER_LEVELS] = { /* Q62 */ - 0, - 65865144550293504, - 138485688541642752, - 239816680157478912, - 355502895585558528, - 485544334825881600, - 667940119734386688, - 902690250311073792, - 1225260573621485568, - 1635651089665622016, - 2011983133527769088, - 2354256705207926784, - 2741003323208368128, - 3172222987529093120, - 3693796119373938688, - 4305722718742904832, -}; + /* column 4 (|ILD| = 6): */ + {713563712, 0 }, + {722237376, 223142880 }, + {746085184, 431184640 }, + {786311872, 642617280 }, + {847364864, 866812416 }, + {936938496, 1111020032 }, + {1072199936, 1390431232 }, + {1285225984, 1720430720 }, -const Word32 diffuseness_thresholds_hr_fx[HR_MASA_ER_LEVELS + 1] = { /* Q30 */ - 0, - 10223616, - 20447232, - 44040192, - 67633152, - 97910784, - 128188416, - 182845440, - 237502464, - 333053952, - 428605440, - 508297216, - 587988992, - 688390144, - 788791296, - 931266560, - MAX_32 /* out-of-range large value to make searching easier */ -}; + /* column 5 (|ILD| = 8): */ + {924504576, 0 }, + {934784576, 204139792 }, + {962942400, 393358880 }, + {1010083968, 583482048 }, + {1080789888, 781462848 }, + {1182728704, 991308544 }, + {1332741248, 1221608960 }, + {1559902080, 1475937536 }, -const Word16 bits_direction_masa[DIRAC_DIFFUSE_LEVELS] = -{ - 11, - 11, - 10, - 9, - 7, - 6, - 5, - 3 -}; + /* column 6 (|ILD| = 10): */ + {1115604864, 0 }, + {1126709504, 182744416 }, + {1156997632, 351025536 }, + {1207276672, 517958016 }, + {1281710592, 688294272 }, + {1387005952, 863412992 }, + {1537761536, 1046870336 }, + {1757032448, 1234717184 }, + /* column 7 (|ILD| = 13): */ + {1361843968, 0 }, + {1372924928, 149366080 }, + {1402942464, 285507936 }, + {1452130560, 417893888 }, + {1523515136, 548787328 }, + {1621670144, 677135936 }, + {1756740352, 802203264 }, + {1942499840, 915633344 }, -const Word16 len_cb_dct0_masa[DIRAC_DIFFUSE_LEVELS] = { 7, 6, 5, 4, 4, 4, 3, 2 }; + /* column 8 (|ILD| = 16): */ + {1559902080, 0 }, + {1569913600, 117815248 }, + {1596862336, 224162928 }, + {1640492800, 325650848 }, + {1702660352, 423060736 }, + {1785997696, 514412544 }, + {1896788608, 597466432 }, + {2042241920, 664027712 }, -const UWord8 sur_coherence_cb_masa[MASA_MAX_NO_CV_SUR_COH*MASA_NO_CB_SUR_COH] = -{ - 16, 99, 0, 0, 0, 0, 0, 0, - 12, 64, 167, 0, 0, 0, 0, 0, - 10, 45, 100, 218, 0, 0, 0, 0, - 8, 34, 70, 124, 235, 0, 0, 0, - 7, 27, 55, 90, 141, 242, 0, 0, - 7, 23, 45, 71, 105, 153, 247, 0, - 6, 20, 38, 60, 86, 119, 165, 249 -}; + /* column 9 (|ILD| = 19): */ + {1714196608, 0 }, + {1722634112, 90359672 }, + {1745223424, 171238192 }, + {1781415040, 247171072 }, + {1832190080, 318199104 }, + {1898830848, 382271424 }, + {1984989952, 437025792 }, + {2094086528, 475912448 }, -const Word16 idx_cb_sur_coh_masa[MASA_MAX_NO_CV_SUR_COH] = { 0, 1, 2, 3, 4, 5, 5, 6 }; + /* column 10 (|ILD| = 22): */ + {1831427712, 0 }, + {1838194432, 67828272 }, + {1856228992, 128123168 }, + {1884882944, 183977072 }, + {1924581248, 235132272 }, + {1975822336, 279821408 }, + {2040659200, 316058048 }, + {2120554240, 339023232 }, -const Word16 len_huf_masa[MASA_NO_CV_COH1] = { 4, 2, 1, 3, 4 }; + /* column 11 (|ILD| = 25): */ + {1918819584, 0 }, + {1924055168, 50102940 }, + {1937964416, 94399088 }, + {1959916032, 135003712 }, + {1990038784, 171579648 }, + {2028424960, 202728896 }, + {2076217216, 226931040 }, + {2133943808, 240762976 }, -const Word16 huff_code_av_masa[MASA_NO_CV_COH1] = { 15, 2, 0, 6, 14 }; + /* column 12 (|ILD| = 30): */ + {2015827840, 0 }, + {2019068416, 29502130 }, + {2027636864, 55420112 }, + {2041056512, 78889960 }, + {2059271424, 99626064 }, + {2082150784, 116769424 }, + {2110128128, 129415952 }, + {2143192960, 135682304 }, -const Word16 no_theta_masa[NO_SPHERICAL_GRIDS-2] = /* from 1 to 11 bits */ -{ /*1, 1,*/ 2 ,2 , 4, 5, 6, 7, 10, 14, 19 - /*0, 2, 8, 6, 7, 12, 14, 16*/ -}; + /* column 13 (|ILD| = 35): */ + {2072441984, 0 }, + {2074364032, 17033840 }, + {2079438464, 31939524 }, + {2087347712, 45337676 }, + {2098012032, 57039312 }, + {2111296384, 66537632 }, + {2127368192, 73321536 }, + {2146126464, 76351632 }, -const Word16 no_phi_masa[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = /* from 1 to 11 bits*/ -{ - { 2 }, - { 4 }, - { 4, 2 }, - { 8, 4 }, /* 8, 4*/ - { 12, 7, 2, 1 }, /* 12, */ - { 14, 13, 9, 2, 1 }, - { 22, 21, 17, 11, 3, 1 }, - { 33, 32, 29, 23, 17, 9, 1 }, - { 48, 47, 45, 41, 35, 28, 20, 12, 2, 1 }, - { 60, 60, 58, 56, 54, 50, 46, 41, 36, 30, 23, 17, 10, 1 }, - { 89, 89, 88, 86, 84, 81, 77, 73, 68, 63, 57, 51, 44, 38, 30, 23, 15, 8, 1 } -}; + /* column 14 (|ILD| = 40): */ + {2104959232, 0 }, + {2106073728, 9723806 }, + {2109011456, 18212808 }, + {2113579136, 25810606 }, + {2119712384, 32401234 }, + {2127314432, 37692632 }, + {2136458496, 41399188 }, + {2147054208, 42945376 }, -const Word16 MASA_band_grouping_24[24 + 1] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30, 40, 60 -}; + /* column 15 (|ILD| = 45): */ + {2123466240, 0 }, + {2124103936, 5514738 }, + {2125783296, 10322954 }, + {2128390400, 14615774 }, + {2131882240, 18322330 }, + {2136200832, 21283710 }, + {2141376256, 23332410 }, + {2147348352, 24150602 }, -const Word16 MASA_band_mapping_24_to_18[18 + 1] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 17, 20, 21, 22, 23, 24 + /* column 16 (|ILD| = 50): */ + {2133943808, 0 }, + {2134306688, 3115998 }, + {2135260160, 5830418 }, + {2136737664, 8250632 }, + {2138715520, 10335839 }, + {2141157120, 11995844 }, + {2144077696, 13136157 }, + {2147440640, 13580687 } }; -const Word16 MASA_band_mapping_24_to_12[12 + 1] = -{ - 0, 1, 2, 3, 4, 5, 7, 9, 12, 15, 20, 22, 24 -}; -const Word16 MASA_band_mapping_24_to_8[8 + 1] = +/* tables for adaptive Golomb-Rice coding of DFT stereo parameters */ +const Word16 dft_code_itd[] = { - 0, 1, 2, 3, 5, 8, 12, 20, 24 + 0, 3, 4, 13, 8, 9, 12, 5, 10, 44, 23, 60, 45, 31, 235, 59, 28, 61, 234, 116 }; -const Word16 MASA_band_mapping_24_to_5[5 + 1] = +const Word16 dft_len_itd[] = { - 0, 1, 3, 7, 15, 24 + 2, 3, 4, 4, 4, 4, 4, 4, 4, 6, 5, 6, 6, 5, 8, 6, 5, 6, 8, 7 }; -const Word16 MASA_grouping_8_to_5[8] = +const Word16 dft_maps_rpg[] = { - 0, 1, 1, 2, 3, 3, 4, 4 + 0, 1, 2, 3, 4, 5, 6, 7, + 2, 0, 1, 3, 4, 5, 6, 7, + 6, 2, 0, 1, 3, 4, 5, 7, + 7, 5, 2, 0, 1, 3, 4, 6, + 7, 6, 4, 3, 1, 0, 2, 5, + 7, 6, 5, 3, 2, 1, 0, 4, + 7, 6, 5, 4, 3, 2, 0, 1, + 7, 6, 5, 4, 3, 2, 0, 1, + 6, 5, 4, 3, 1, 0, 2, 7, }; -const Word16 MASA_grouping_12_to_5[12] = +const Word16 dft_maps_sg[NO_SYMB_GR_SIDE_G * NO_SYMB_GR_SIDE_G] = { - 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 15, 4, 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 12, 9, 4, 1, 0, 2, 3, 5, 6, 7, 8, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 16, 14, 8, 4, 2, 0, 1, 3, 5, 6, 7, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 18, 16, 14, 10, 5, 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 15, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 21, 19, 17, 15, 8, 4, 2, 0, 1, 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 21, 19, 17, 15, 12, 8, 4, 0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 21, 19, 17, 15, 13, 11, 9, 3, 0, 1, 2, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 24, 22, 20, 18, 16, 14, 12, 9, 6, 0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 26, 27, 28, 29, 30, + 25, 23, 21, 19, 17, 15, 13, 11, 9, 6, 0, 1, 2, 3, 4, 5, 7, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 28, 29, 30, + 27, 25, 23, 21, 19, 17, 15, 13, 11, 8, 5, 0, 1, 2, 3, 4, 6, 7, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, + 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 28, 29, 30, + 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30, + 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, + 30, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, + 30, 29, 28, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, + 30, 29, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 9, 7, 6, 4, 3, 2, 1, 0, 5, 8, 11, 13, 15, 17, 19, 21, 23, 25, 27, + 30, 29, 28, 27, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 7, 5, 4, 3, 2, 1, 0, 6, 9, 11, 13, 15, 17, 19, 21, 23, 25, + 30, 29, 28, 27, 26, 25, 23, 21, 19, 17, 15, 13, 11, 10, 8, 7, 5, 4, 3, 2, 1, 0, 6, 9, 12, 14, 16, 18, 20, 22, 24, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 18, 16, 14, 12, 10, 8, 7, 6, 5, 4, 2, 1, 0, 3, 9, 11, 13, 15, 17, 19, 21, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 18, 16, 14, 13, 11, 10, 9, 7, 6, 5, 3, 2, 1, 0, 4, 8, 12, 15, 17, 19, 21, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 18, 16, 14, 13, 12, 11, 10, 9, 7, 6, 5, 3, 1, 0, 2, 4, 8, 15, 17, 19, 21, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 17, 15, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1, 0, 5, 10, 14, 16, 18, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 15, 13, 12, 11, 10, 9, 7, 6, 5, 3, 1, 0, 2, 4, 8, 14, 16, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 11, 10, 8, 7, 6, 5, 3, 2, 0, 1, 4, 9, 12, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 3, 2, 1, 0, 4, 15, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 1, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; -const Word16 MASA_grouping_18_to_5[18] = -{ - 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 -}; -const Word16 MASA_grouping_24_to_5[24] = -{ - 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4 -}; +/*------------------------------------------------------------------------- + * Range Coder ROM tables + *------------------------------------------------------------------------*/ -/* IVAS_13k2, IVAS_16k4, IVAS_24k4, IVAS_32k, IVAS_48k, IVAS_64k, IVAS_80k, IVAS_96k, IVAS_128k, IVAS_160k, IVAS_192k, IVAS_256k, IVAS_384k, IVAS_512k */ -const Word16 masa_bits[IVAS_NUM_ACTIVE_BRATES] = +/* Create separate tables for cumulative frequency and symbol frequency */ +const UWord16 cum_freq_ari_pk_s17_LC_ext[RANGE_N_CONTEXT][1 + RANGE_N_SYMBOLS] = { - 50, 60, 70, 85, 140, 180, 220, 256, 350, 432, 528, 832, 1024, MASA_MAX_BITS + { 0,16,47,153,241,269,325,468,591,674,798,912,1017,1082,1183,1277,1364,16384 }, + { 0,7401,7844,7886,7899,12065,12718,12790,12805,14099,14476,14533,14549,15058,15264,15299,15310,16384 }, + { 0,4362,6345,6864,7038,9037,11049,11736,12002,12569,13301,13656,13822,14021,14334,14515,14607,16384 }, + { 0,2955,5183,5822,6013,8153,10671,11614,11943,12586,13540,14025,14232,14437,14770,14978,15080,16384 }, + { 0,3155,4981,5615,5855,7969,9953,10739,11073,11936,12837,13208,13383,13767,14203,14400,14498,16384 }, + { 0,1216,2630,3264,3558,4831,6679,7661,8157,8709,9622,10204,10542,10799,11243,11568,11777,16384 }, + { 0,1759,3641,4350,4612,6325,8678,9732,10161,10790,11790,12361,12642,12883,13295,13566,13720,16384 }, + { 0,1109,2705,3433,3732,5226,7532,8732,9263,9978,11142,11842,12188,12490,12986,13321,13520,16384 }, + { 0,11524,13046,13170,13191,14956,15708,15813,15837,16028,16162,16195,16204,16245,16282,16295,16300,16384 }, + { 0,8027,10586,10909,10974,13291,14861,15157,15232,15535,15824,15914,15943,16014,16090,16123,16136,16384 }, + { 0,834,2034,2674,2997,4087,5843,6891,7455,8030,9013,9688,10085,10376,10893,11277,11528,16384 }, + { 0,6038,9086,9451,9519,12332,14521,14913,15003,15329,15711,15848,15893,15955,16045,16091,16111,16384 }, + { 0,4732,7685,8354,8545,10717,12924,13618,13852,14291,14842,15083,15181,15314,15491,15582,15625,16384 }, + { 0,745,1783,2347,2655,3537,4963,5864,6406,6863,7664,8248,8634,8891,9351,9708,9958,16384 }, + { 0,3957,6794,7669,7998,9743,11676,12498,12869,13313,13894,14186,14332,14498,14714,14835,14906,16384 }, + { 0,2779,5388,6021,6201,8582,11352,12260,12544,13117,13981,14408,14580,14751,15039,15213,15298,16384 }, + { 0,448,1160,1625,1920,2576,3706,4518,5053,5474,6234,6835,7262,7531,8032,8446,8758,16384 }, + { 0,1,2,1555,2246,2247,2248,3489,4112,5449,6596,7302,7710,8311,8876,9266,9517,16384 }, + { 0,2496,4910,5544,5722,8049,10799,11689,11973,12583,13467,13878,14047,14234,14537,14712,14803,16384 }, + { 0,921,2222,2880,3188,4407,6321,7406,7955,8573,9616,10296,10679,10978,11502,11880,12118,16384 }, + { 0,2620,4443,5017,5233,7072,9213,10083,10441,11049,11954,12442,12676,12918,13310,13565,13705,16384 }, + { 0,11205,13084,13178,13187,15164,16010,16081,16091,16213,16303,16321,16325,16340,16355,16360,16362,16384 }, + { 0,358,916,1288,1542,2055,2937,3594,4062,4399,5017,5524,5907,6136,6573,6941,7236,16384 }, + { 0,3575,5093,5536,5735,7408,9185,9878,10188,10727,11497,11933,12165,12410,12794,13019,13166,16384 }, + { 0,1,2,640,1036,1037,1038,1670,2096,2696,3287,3732,4056,4417,4800,5106,5339,16384 }, + { 0,969,1397,1518,1578,2633,3338,3566,3675,4197,4664,4857,4957,5288,5625,5783,5874,16384 }, + { 0,10458,12104,12294,12331,14246,15264,15437,15481,15752,15971,16031,16050,16120,16186,16210,16218,16384 }, + { 0,7178,9744,10039,10093,12701,14612,14961,15042,15360,15732,15869,15917,15978,16070,16117,16139,16384 }, + { 0,1298,2418,2879,3113,4146,5509,6227,6621,7053,7755,8229,8539,8776,9186,9492,9714,16384 }, + { 0,4957,7785,8252,8357,10978,13372,13955,14114,14561,15140,15378,15464,15570,15730,15820,15860,16384 }, + { 0,4823,8164,8570,8647,11604,14169,14653,14763,15105,15554,15727,15785,15852,15960,16018,16045,16384 }, + { 0,4735,7010,7517,7660,9986,12230,12914,13131,13666,14374,14689,14814,14972,15212,15342,15404,16384 }, + { 0,3363,5881,6658,6941,8864,11113,12015,12368,12889,13643,14019,14203,14394,14665,14823,14906,16384 }, + { 0,2569,4996,5779,6068,7917,10251,11209,11602,12129,12918,13321,13520,13696,13976,14155,14259,16384 }, + { 0,209,577,848,1046,1378,1982,2465,2835,3072,3513,3893,4202,4374,4703,4994,5241,16384 }, + { 0,2074,4337,5048,5274,7319,10003,11066,11446,12105,13112,13652,13885,14100,14464,14691,14810,16384 }, + { 0,1619,3560,4288,4550,6381,8955,10102,10543,11239,12362,12982,13261,13516,13958,14234,14381,16384 }, + { 0,89,257,441,582,734,1024,1325,1568,1716,1983,2222,2430,2545,2750,2941,3109,16384 }, + { 0,2202,3563,4044,4264,5686,7344,8100,8476,9006,9835,10331,10612,10864,11304,11599,11787,16384 }, + { 0,1220,2801,3492,3784,5223,7387,8496,8998,9640,10711,11369,11711,11993,12486,12829,13035,16384 }, + { 0,12626,13813,13903,13917,15396,15906,15972,15987,16139,16230,16251,16257,16289,16315,16323,16326,16384 }, + { 0,1579,3191,3831,4099,5678,7788,8761,9206,9842,10821,11388,11681,11958,12417,12722,12902,16384 }, + { 0,597,1514,2064,2379,3237,4679,5637,6213,6733,7649,8316,8755,9052,9599,10023,10323,16384 }, + { 0,9273,11762,12080,12151,14038,15210,15446,15514,15725,15929,15995,16019,16068,16124,16148,16158,16384 }, + { 0,9238,11681,11852,11872,14306,15644,15801,15828,16013,16183,16231,16243,16266,16297,16312,16318,16384 }, + { 0,6791,9200,9531,9594,12240,14178,14552,14639,15064,15506,15643,15687,15785,15908,15960,15983,16384 }, + { 0,7175,10415,10905,11033,13038,14621,15002,15123,15367,15651,15762,15806,15864,15938,15974,15992,16384 }, + { 0,5060,7703,8132,8225,10934,13270,13778,13911,14397,14972,15173,15242,15367,15537,15619,15654,16384 }, + { 0,3721,6311,6857,6992,9557,12180,12895,13098,13671,14418,14718,14830,14984,15212,15333,15390,16384 }, + { 0,5971,9288,10044,10269,11991,13680,14228,14437,14750,15130,15293,15374,15459,15579,15642,15677,16384 }, + { 0,3047,5311,5907,6078,8339,10850,11679,11946,12580,13442,13854,14024,14220,14534,14716,14810,16384 }, + { 0,2061,4280,4993,5228,7201,9735,10735,11097,11708,12606,13082,13295,13498,13836,14043,14161,16384 }, + { 0,4738,7949,8880,9234,10781,12502,13214,13531,13897,14355,14593,14718,14835,14998,15096,15153,16384 }, + { 0,3237,5045,5632,5860,7609,9702,10608,10986,11571,12476,12978,13230,13451,13830,14074,14208,16384 }, + { 0,1833,3889,4677,5028,6422,8379,9378,9884,10350,11086,11545,11809,12003,12327,12559,12711,16384 }, + { 0,3989,6858,7352,7459,10254,12936,13571,13735,14240,14895,15153,15242,15364,15548,15646,15690,16384 }, + { 0,1463,3197,3909,4220,5626,7609,8632,9127,9657,10520,11078,11380,11607,11991,12265,12442,16384 }, + { 0,14233,15083,15108,15110,16069,16300,16314,16316,16352,16370,16373,16374,16377,16380,16381,16382,16384 }, + { 0,1,2,2610,3293,3294,3295,5097,5671,8467,10332,11119,11437,12223,12850,13185,13345,16384 }, + { 0,2010,4053,4696,4910,6879,9391,10386,10750,11393,12376,12886,13119,13348,13726,13967,14099,16384 }, + { 0,7586,10517,10758,10791,13543,15346,15577,15619,15846,16082,16150,16169,16202,16245,16265,16273,16384 }, + { 0,3059,5772,6369,6524,9041,11801,12582,12813,13361,14115,14439,14567,14714,14944,15075,15141,16384 }, + { 0,8643,10594,10813,10856,13274,14686,14920,14975,15350,15680,15771,15799,15897,16003,16042,16057,16384 }, + { 0,6720,8878,9325,9467,11564,13248,13744,13929,14384,14880,15087,15167,15311,15488,15569,15607,16384 }, }; -const Word16 masa_bits_LR_stereo[4] = +const UWord16 sym_freq_ari_pk_s17_LC_ext[RANGE_N_CONTEXT][RANGE_N_SYMBOLS] = { - 50, 50, 60, 70 + { 16,31,106,88,28,56,143,123,83,124,114,105,65,101,94,87,15020 }, + { 7401,443,42,13,4166,653,72,15,1294,377,57,16,509,206,35,11,1074 }, + { 4362,1983,519,174,1999,2012,687,266,567,732,355,166,199,313,181,92,1777 }, + { 2955,2228,639,191,2140,2518,943,329,643,954,485,207,205,333,208,102,1304 }, + { 3155,1826,634,240,2114,1984,786,334,863,901,371,175,384,436,197,98,1886 }, + { 1216,1414,634,294,1273,1848,982,496,552,913,582,338,257,444,325,209,4607 }, + { 1759,1882,709,262,1713,2353,1054,429,629,1000,571,281,241,412,271,154,2664 }, + { 1109,1596,728,299,1494,2306,1200,531,715,1164,700,346,302,496,335,199,2864 }, + { 11524,1522,124,21,1765,752,105,24,191,134,33,9,41,37,13,5,84 }, + { 8027,2559,323,65,2317,1570,296,75,303,289,90,29,71,76,33,13,248 }, + { 834,1200,640,323,1090,1756,1048,564,575,983,675,397,291,517,384,251,4856 }, + { 6038,3048,365,68,2813,2189,392,90,326,382,137,45,62,90,46,20,273 }, + { 4732,2953,669,191,2172,2207,694,234,439,551,241,98,133,177,91,43,759 }, + { 745,1038,564,308,882,1426,901,542,457,801,584,386,257,460,357,250,6426 }, + { 3957,2837,875,329,1745,1933,822,371,444,581,292,146,166,216,121,71,1478 }, + { 2779,2609,633,180,2381,2770,908,284,573,864,427,172,171,288,174,85,1086 }, + { 448,712,465,295,656,1130,812,535,421,760,601,427,269,501,414,312,7626 }, + { 1,1,1553,691,1,1,1241,623,1337,1147,706,408,601,565,390,251,6867 }, + { 2496,2414,634,178,2327,2750,890,284,610,884,411,169,187,303,175,91,1581 }, + { 921,1301,658,308,1219,1914,1085,549,618,1043,680,383,299,524,378,238,4266 }, + { 2620,1823,574,216,1839,2141,870,358,608,905,488,234,242,392,255,140,2679 }, + { 11205,1879,94,9,1977,846,71,10,122,90,18,4,15,15,5,2,22 }, + { 358,558,372,254,513,882,657,468,337,618,507,383,229,437,368,295,9148 }, + { 3575,1518,443,199,1673,1777,693,310,539,770,436,232,245,384,225,147,3218 }, + { 1,1,638,396,1,1,632,426,600,591,445,324,361,383,306,233,11045 }, + { 969,428,121,60,1055,705,228,109,522,467,193,100,331,337,158,91,10510 }, + { 10458,1646,190,37,1915,1018,173,44,271,219,60,19,70,66,24,8,166 }, + { 7178,2566,295,54,2608,1911,349,81,318,372,137,48,61,92,47,22,245 }, + { 1298,1120,461,234,1033,1363,718,394,432,702,474,310,237,410,306,222,6670 }, + { 4957,2828,467,105,2621,2394,583,159,447,579,238,86,106,160,90,40,524 }, + { 4823,3341,406,77,2957,2565,484,110,342,449,173,58,67,108,58,27,339 }, + { 4735,2275,507,143,2326,2244,684,217,535,708,315,125,158,240,130,62,980 }, + { 3363,2518,777,283,1923,2249,902,353,521,754,376,184,191,271,158,83,1478 }, + { 2569,2427,783,289,1849,2334,958,393,527,789,403,199,176,280,179,104,2125 }, + { 209,368,271,198,332,604,483,370,237,441,380,309,172,329,291,247,11143 }, + { 2074,2263,711,226,2045,2684,1063,380,659,1007,540,233,215,364,227,119,1574 }, + { 1619,1941,728,262,1831,2574,1147,441,696,1123,620,279,255,442,276,147,2003 }, + { 89,168,184,141,152,290,301,243,148,267,239,208,115,205,191,168,13275 }, + { 2202,1361,481,220,1422,1658,756,376,530,829,496,281,252,440,295,188,4597 }, + { 1220,1581,691,292,1439,2164,1109,502,642,1071,658,342,282,493,343,206,3349 }, + { 12626,1187,90,14,1479,510,66,15,152,91,21,6,32,26,8,3,58 }, + { 1579,1612,640,268,1579,2110,973,445,636,979,567,293,277,459,305,180,3482 }, + { 597,917,550,315,858,1442,958,576,520,916,667,439,297,547,424,300,6061 }, + { 9273,2489,318,71,1887,1172,236,68,211,204,66,24,49,56,24,10,226 }, + { 9238,2443,171,20,2434,1338,157,27,185,170,48,12,23,31,15,6,66 }, + { 6791,2409,331,63,2646,1938,374,87,425,442,137,44,98,123,52,23,401 }, + { 7175,3240,490,128,2005,1583,381,121,244,284,111,44,58,74,36,18,392 }, + { 5060,2643,429,93,2709,2336,508,133,486,575,201,69,125,170,82,35,730 }, + { 3721,2590,546,135,2565,2623,715,203,573,747,300,112,154,228,121,57,994 }, + { 5971,3317,756,225,1722,1689,548,209,313,380,163,81,85,120,63,35,707 }, + { 3047,2264,596,171,2261,2511,829,267,634,862,412,170,196,314,182,94,1574 }, + { 2061,2219,713,235,1973,2534,1000,362,611,898,476,213,203,338,207,118,2223 }, + { 4738,3211,931,354,1547,1721,712,317,366,458,238,125,117,163,98,57,1231 }, + { 3237,1808,587,228,1749,2093,906,378,585,905,502,252,221,379,244,134,2176 }, + { 1833,2056,788,351,1394,1957,999,506,466,736,459,264,194,324,232,152,3673 }, + { 3989,2869,494,107,2795,2682,635,164,505,655,258,89,122,184,98,44,694 }, + { 1463,1734,712,311,1406,1983,1023,495,530,863,558,302,227,384,274,177,3942 }, + { 14233,850,25,2,959,231,14,2,36,18,3,1,3,3,1,1,2 }, + { 1,1,2608,683,1,1,1802,574,2796,1865,787,318,786,627,335,160,3039 }, + { 2010,2043,643,214,1969,2512,995,364,643,983,510,233,229,378,241,132,2285 }, + { 7586,2931,241,33,2752,1803,231,42,227,236,68,19,33,43,20,8,111 }, + { 3059,2713,597,155,2517,2760,781,231,548,754,324,128,147,230,131,66,1243 }, + { 8643,1951,219,43,2418,1412,234,55,375,330,91,28,98,106,39,15,327 }, + { 6720,2158,447,142,2097,1684,496,185,455,496,207,80,144,177,81,38,777 }, }; -const Word16 mcmasa_bits[IVAS_NUM_ACTIVE_BRATES] = -{ - 50, 70, 80, 120, 140, 160, 220, 256, 288, 432, 528, 832, 1024, MASA_MAX_BITS -}; -const UWord8 masa_nbands[IVAS_NUM_ACTIVE_BRATES] = -{ - 5, 5, 5, 5, 5, 5, 5, 5, 8, 12, 18, 24, 24, 24 -}; +/*------------------------------------------------------------------------- + * ECLVQ Stereo ROM tables + *------------------------------------------------------------------------*/ -const UWord8 masa_joined_nbands[IVAS_NUM_ACTIVE_BRATES] = +/* table with round(ECSQ_PROB_TOTAL / index) for entropy coding, with i in {1, .., ECSQ_SEGMENT_SIZE} */ +const UWord16 ECSQ_tab_inverse[1 + ECSQ_SEGMENT_SIZE] = { - 5, 5, 5, 8, 12, 12, 12, 18, 18, 18, 18, 24, 24, 24 + 0, 16384, 8192, 5461, 4096, 3277, 2731, 2341, 2048 }; -const UWord8 masa_twodir_bands[IVAS_NUM_ACTIVE_BRATES] = -{ - 0, 0, 0, 0, 0, 1, 1, 1, 3, 4, 6, 6, 9, 24 -}; -const UWord8 masa_twodir_bands_joined[IVAS_NUM_ACTIVE_BRATES] = +const Word16 tdm_bit_allc_tbl[5][6] = { - 0, 0, 0, 0, 0, 2, 2, 3, 4, 6, 8, 9, 12, MASA_MAXIMUM_TWO_DIR_BANDS + /* IC -- UC -- GC -- TM --AC */ + { 1650, 3500, 0, 4400, 0, 5000 }, /* IVAS_13k2 */ + { 1650, 3500, 0, 5000, 0, 5000 }, /* IVAS_16k4 */ + { 1650, 3500, 0, 6000, 0, 5000 }, /* IVAS_24k4 */ + { 1650, 6050, 0, 10000, 0, 10000 }, /* IVAS_32k */ + { 1650, 6050, 0, 13000, 0, 14000 } /* IVAS_48k */ }; -/*----------------------------------------------------------------------------------* - * OMASA ROM tables - *----------------------------------------------------------------------------------*/ - -const Word32 sep_object_brate[][MAX_NUM_OBJECTS] = -{ - {0, 0, 0, 0}, /* 13k2 */ - {0, 0, 0, 0}, /* 16k4 */ - {9600, 0, 0, 0}, /* 24k4 */ - {IVAS_13k2, 0, 0, 0}, /* 32k */ - {16000, 11000, 0, 0}, /* 48k */ - {16000, 11700, 0, 0}, /* 64k */ - {20000, 16000, 0, 0}, /* 80k */ - {IVAS_32k, 20000, 20000, 0}, /* 96k */ - {IVAS_32k, IVAS_24k4, 24000, 24000}, /* 128k */ - {IVAS_48k, IVAS_32k, IVAS_24k4, 24000}, /* 160k */ - {IVAS_64k, IVAS_48k, IVAS_32k, IVAS_24k4}, /* 192k */ - {IVAS_96k, IVAS_64k, IVAS_48k, IVAS_32k}, /* 256k */ - {IVAS_128k, IVAS_80k, IVAS_64k, IVAS_48k}, /* 384k */ - {IVAS_128k, IVAS_96k, IVAS_80k, IVAS_64k} /* 512k */ -}; +const Word16 fast_FCB_bits_2sfr[] = {8, 14, 18, 20, 24, 128/*stop value*/}; -/* column wise DCT matrices for 4 5, and 8 dim */ -/*----------------------------------------------------------------------------------* - * Param ISM ROM tables - *----------------------------------------------------------------------------------*/ +const Word16 fast_FCB_rates_2sfr[] = {/*16*50,*/ (8+14)*50, 28*50, 32*50, 34*50, 36*50, 38*50, 40*50, 42*50, 44*50, 48*50}; -const Word16 Param_ISM_band_grouping[MAX_PARAM_ISM_NBANDS + 1] = -{ - 0, 1, 2, 3, 4, 6, 8, 11, 15, 21, 31, 60 -}; /*----------------------------------------------------------------------------------* - * LFE coding ROM tables + * MDCT Stereo ROM tables *----------------------------------------------------------------------------------*/ -const ivas_lfe_freq_models ivas_str_lfe_freq_models = -{ - { 16384, 14924, 13463, 12003, 10542, 9082, 7622, 6161, - 4701, 4336, 3970, 3605, 3240, 2875, 2510, 2145, - 1780, 1689, 1597, 1506, 1415, 1323, 1232, 1141, - 1050, 1004, 958, 913, 867, 821, 776, 730, - 685, 639, 593, 548, 502, 456, 411, 365, - 319, 297, 274, 251, 228, 205, 183, 160, - 137, 126, 114, 103, 91, 80, 68, 57, - 46, 40, 34, 29, 23, 17, 11, 6, 0 }, - - { 16384, 13463, 10542, 7622, 4701, 3970, 3240, 2510, - 1780, 1597, 1415, 1232, 1050, 958, 867, 776, - 685, 593, 502, 411, 319, 274, 228, 183, - 137, 114, 91, 68, 46, 34, 23, 11, 0 }, - - { 16384, 4701, 1780, 1050, 685, 319, 137, 46, - 0, }, - - { 16384, 3277, 0 }, - - { 16384, 13463, 10542, 7622, 4701, 3970, 3240, 2510, - 1780, 1597, 1415, 1232, 1050, 958, 867, 776, - 685, 593, 502, 411, 319, 274, 228, 183, - 137, 114, 91, 68, 46, 34, 23, 11, - 0 }, - - { 16384, 10542, 4701, 3240, 1780, 1415, 1050, 867, - 685, 502, 319, 228, 137, 91, 46, 23, - 0 }, - - { 16384, 4468, 1489, 745, 0 }, 0, -}; - -const Word16 ivas_lfe_num_ele_in_coder_models[2][4] = -{ - { 63, 31, 7, 1 },{ 31, 15, 3, 0 } -}; - -const Word16 ivas_lfe_log2_num_ele_in_coder_models_fx[2][4] = -{ - { 6, 5, 3, 1 },{ 5, 4, 2, 0 } -}; + /* PsychLPC */ -const Word16 ivas_lfe_num_dct_pass_bins_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 8, 6 }; +const SpectrumWarping sw32000Hz[] = +{{ + { + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, + 6, 8, 8, 8, 8, 8, 10, 10, 10, 10, 12, 12, 12, 12, 14, 14, + 14, 16, 18, 18, 18, 20, 22, 22, 22, 24, 26, 26, 26, 28, 30, 32 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, + 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10 + }, +}}; -const Word16 ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; +const SpectrumWarping sw25600Hz[] = +{{ + { + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, + 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 12, 12, 12, 12, + 12, 12, 14, 14, 14, 14, 14, 16, 16, 18, 18, 18, 18, 18, 20, 20 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 + }, +}}; -const Word16 ivas_lfe_lpf_delay_Q15[2] = { 57, 114 }; +const SpectrumWarping sw16000Hz[] = +{{ + { + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 + }, +}}; -const Word16 dirac_gains_P_idx[16] = -{ - -1, 1, 0, 1, 4, 3, 2, 3, 4, 8, 7, 6, 5, 6, 7, 8 -}; +const MDCTStereoBands_config mdctStereoBands_32000_640[] = +{{ + /*TCX 20*/ + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, + 12, 20, 20, 20, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 42, + 64, 64, 96, 160}, + {44, 41,38, 29},/*number of bands for frame lengths 960, 640, 512, 320 respectively*/ -/*----------------------------------------------------------------------------------* - * FB ROM tables - *----------------------------------------------------------------------------------*/ + /*TCX 10*/ + { + 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 20, 32, 32, + 32, 48, 80 + }, + {33, 29, 26, 18}/*number of bands for frame lengths 480, 320, 256, 160 respectively*/ +}}; -const Word32 ivas_fb_fcs_12band_1ms_fx[IVAS_FB_BANDS_12] = -{ - 17895696, 53687092, 89478488, 125269880, - 161061280, 196852672, 232644064, 304226848, - 465288128, 715827904, 1091637520, 1735882615 -};/*Q31*/ -const Word16 ivas_fb_abs_bins_per_band_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = -{ - { 24, 30, 30, 30, 30, 30, 42, 76, 124, 182, 291, 367 }, - { 24, 30, 30, 30, 30, 30, 42, 76, 124, 182, 260, 47 }, - { 24, 30, 30, 30, 30, 30, 42, 75, 122, 73, 0, 0 } -}; +const Word16 dft_cng_coh_u2i[9] = { 4, 5, 3, 6, 2, 7, 1, 8, 0 }; /* Coherence unary codeword -> residual codeword conversion table */ -const Word16 ivas_fb_abs_bins_start_offset_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = -{ - {0, 9, 25, 41, 57, 73, 88, 110, 158, 246, 380, 593 }, - {0, 9, 25, 41, 57, 73, 88, 110, 158, 246, 380, 593 }, - {0, 9, 25, 41, 57, 73, 88, 110, 159, 247, 0, 0 } -}; +const Word16 dft_cng_coh_i2u[9] = { 8, 6, 4, 2, 0, 1, 3, 5, 7 }; /* Coherence residual codeword -> unary codeword conversion table */ -const Word16 ivas_fb_bins_per_band_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = -{ - { - IVAS_FB_12_1MS_48K_END_BINS_BAND_0 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_0, - IVAS_FB_12_1MS_48K_END_BINS_BAND_1 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_1, - IVAS_FB_12_1MS_48K_END_BINS_BAND_2 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_2, - IVAS_FB_12_1MS_48K_END_BINS_BAND_3 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_3, - IVAS_FB_12_1MS_48K_END_BINS_BAND_4 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_4, - IVAS_FB_12_1MS_48K_END_BINS_BAND_5 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_5, - IVAS_FB_12_1MS_48K_END_BINS_BAND_6 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_6, - IVAS_FB_12_1MS_48K_END_BINS_BAND_7 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_7, - IVAS_FB_12_1MS_48K_END_BINS_BAND_8 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_8, - IVAS_FB_12_1MS_48K_END_BINS_BAND_9 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_9, - IVAS_FB_12_1MS_48K_END_BINS_BAND_10 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_10, - IVAS_FB_12_1MS_48K_END_BINS_BAND_11 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_11 - }, - { - IVAS_FB_12_1MS_32K_END_BINS_BAND_0 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_0, - IVAS_FB_12_1MS_32K_END_BINS_BAND_1 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_1, - IVAS_FB_12_1MS_32K_END_BINS_BAND_2 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_2, - IVAS_FB_12_1MS_32K_END_BINS_BAND_3 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_3, - IVAS_FB_12_1MS_32K_END_BINS_BAND_4 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_4, - IVAS_FB_12_1MS_32K_END_BINS_BAND_5 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_5, - IVAS_FB_12_1MS_32K_END_BINS_BAND_6 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_6, - IVAS_FB_12_1MS_32K_END_BINS_BAND_7 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_7, - IVAS_FB_12_1MS_32K_END_BINS_BAND_8 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_8, - IVAS_FB_12_1MS_32K_END_BINS_BAND_9 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_9, - IVAS_FB_12_1MS_32K_END_BINS_BAND_10 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_10, - IVAS_FB_12_1MS_32K_END_BINS_BAND_11 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_11 - }, - { - IVAS_FB_12_1MS_16K_END_BINS_BAND_0 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_0, - IVAS_FB_12_1MS_16K_END_BINS_BAND_1 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_1, - IVAS_FB_12_1MS_16K_END_BINS_BAND_2 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_2, - IVAS_FB_12_1MS_16K_END_BINS_BAND_3 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_3, - IVAS_FB_12_1MS_16K_END_BINS_BAND_4 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_4, - IVAS_FB_12_1MS_16K_END_BINS_BAND_5 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_5, - IVAS_FB_12_1MS_16K_END_BINS_BAND_6 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_6, - IVAS_FB_12_1MS_16K_END_BINS_BAND_7 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_7, - IVAS_FB_12_1MS_16K_END_BINS_BAND_8 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_8, - IVAS_FB_12_1MS_16K_END_BINS_BAND_9 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_9, - IVAS_FB_12_1MS_16K_END_BINS_BAND_10 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_10, - IVAS_FB_12_1MS_16K_END_BINS_BAND_11 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_11 - }, +const Word16 dft_cng_coh_alpha_start[STEREO_DFT_N_COH_ALPHA_STEPS - 1] = { 15, 16, 17, 18 }; + + +const Word16 DirAC_band_grouping_12[12 + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 11, 17, 25, 40, 60 }; -const Word16 ivas_fb_bins_start_offset_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = + +const Word16 DirAC_band_grouping_6[6 + 1] = { - { - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_0, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_1, - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_2, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_3, - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_4, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_5, - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_6, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_7, - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_8, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_9, - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_10, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_11 - }, - { - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_0, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_1, - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_2, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_3, - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_4, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_5, - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_6, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_7, - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_8, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_9, - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_10, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_11 - }, - { - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_0, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_1, - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_2, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_3, - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_4, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_5, - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_6, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_7, - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_8, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_9, - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_10, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_11 - }, + 0, 1, 4, 8, 20, 30, 60 }; +const Word16 DirAC_band_grouping_5[5 + 1] = +{ + 0, 1, 3, 7, 15, 60 +}; -const Word16 ivas_num_active_bands[FB - WB + 1] = +const Word16 DirAC_block_grouping[MAX_PARAM_SPATIAL_SUBFRAMES + 1] = { - IVAS_16K_12BANDS_ACTIVE_BANDS, IVAS_FB_BANDS_12, IVAS_FB_BANDS_12 + 0, 4, 8, 12, 16 }; -/*------------------------------------------------------------------------------------------* - * SNS MSVQ codebooks and means - *------------------------------------------------------------------------------------------*/ +const Word16 DirAC_block_grouping_5ms_MDFT[MAX_PARAM_SPATIAL_SUBFRAMES + 1] = +{ + 0, 1, 2, 3, 4 +}; -const Word16 ivas_sns_cdbks_tcx20_levels[SNS_MSVQ_NSTAGES_TCX20] = { 128, 64, 32, 32 }; +const Word32 c_weights_fx[DIRAC_NO_FB_BANDS_MAX] /* Q30 */ = { 106970960, 1033798336, 1065867776, 1071704704, 1073381888, 1073741824, 1073494016, 1072883072, 1072012032, 1070930560, 1069665600, 1068232640, 1066641792, 1064899968, 1063012224, 1060982464, 1058814144, 1056510016, 1054072832, 1051505280, 1048809664, 1045988480, 1043044160, 1039979072, 1036795776, 1033496576, 1030084096, 1026560960, 1022929600, 1019192512, 1015352576, 1011412416, 1007374720, 1003242112, 999017472, 994703488, 990302976, 985818688, 981253568, 976610304, 971891712, 967100672, 962240064, 957312576, 952321088, 947268224, 942156992, 936990080, 931770048, 926499840, 921182016, 915819200, 910414208, 904969344, 899487488, 893970944, 888422272, 882843840, 877238144, 871607552, 865954432, 860280896, 854589184, 848881728, 843160384, 837427328, 831684672, 825934208, 820178240, 814418240, 808656320, 802894208, 797133568, 791376192, 785623744, 779877568, 774139520, 768410880, 762693184, 756987904, 751296064, 745619328, 739958784, 734315584, 728691008, 723086208, 717502016, 711939712, 706400064, 700884096, 695392768, 689926912, 684487232, 679074688, 673689856, 668333504, 663006464, 657709056, 652442176, 647206144, 642001600, 636828992, 631688896, 626581696, 621507776, 616467520, 611461184, 606489344, 601552064, 596649792, 591782528, 586950784, 582154560, 577394112, 572669696, 567981312, 563329088, 558713152, 554133568, 549590464, 545083840, 540613760, 536180160, 531783104, 527422528, 523098464, 518810784, 514559520, 510344672, 506165856, 502023360, 497916832, 493846304, 489811488, 485812448, 481848832, 477920672, 474027808, 470169952, 466347008, 462558848, 458805152, 455085920, 451400736, 447749600, 444132160, 440548320, 436997792, 433480416, 429995904, 426544032, 423124608, 419737376, 416382144, 413058720, 409766720, 406505984, 403276288, 400077280, 396908768, 393770656, 390662496, 387584064, 384535200, 381515616, 378525024, 375563200, 372629952, 369724864, 366847872, 363998592, 361176672, 358382176, 355614592, 352873760, 350159456, 347471328, 344809216, 342172864, 339562048, 336976384, 334415808, 331879840, 329368576, 326881472, 324418432, 321979104, 319563392, 317170976, 314801664, 312455232, 310131328, 307829856, 305550528, 303293088, 301057440, 298843168, 296650176, 294478304, 292327168, 290196672, 288086432, 285996512, 283926432, 281876224, 279845472, 277834016, 275841792, 273868480, 271913856, 269977792, 268059968, 266160304, 264278672, 262414768, 260568368, 258739360, 256927520, 255132768, 253354752, 251593392, 249848448, 248119936, 246407424, 244710816, 243030080, 241364928, 239715120, 238080672, 236461248, 234856752, 233267088, 231692016, 230131440, 228585136, 227053024, 225534848, 224030544, 222539872, 221062832 }; -const Word16 ivas_sns_cdbks_tcx20_bits[SNS_MSVQ_NSTAGES_TCX20] = { 7, 6, 5, 5 }; +/*----------------------------------------------------------------------* +* SPAR ROM tables +*-----------------------------------------------------------------------*/ -/* pre-rounded codebook vectors for singed Q4.12 represantation */ +const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = +{ +/* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel + so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, -const Word16 ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 }; + { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, -const Word16 ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 }; + { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 16400, 14850, 24350 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, + { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 24000, 20450, 31950 } }, + { { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 }, -const Word16 ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 }; -const Word16 ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 }; -const Word16 ivas_sns_cdbks_side_tcx10_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 8 }; -const Word16 ivas_sns_cdbks_side_tcx10_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 3 }; + { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, + { { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 }, + { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 }, -const Word16 sns_1st_cdbk[2][2][8 * 32] = -{ - { /* split 1 */ - { /* TCX 20 */ - -10900, -11064, -10637, -10471, -9051, -6381, -4688, -2438, - -2119, -5087, -6702, -8118, -7586, -6343, -4828, -3406, - 2004, -3443, -4289, -3757, -3234, -2952, -2313, -1781, - 1749, 5598, 3916, 732, -1472, -2964, -3275, -2332, - -11978, -14369, -5600, -545, 981, -929, -57, 1903, - 1745, 391, 202, 115, 256, -291, -862, -1637, - -4052, 2059, 4709, 6768, 5595, 1975, -1723, -1218, - 2093, 7263, 8679, 7576, 3701, -2438, -4389, -2686, - -7120, -6279, -5715, -5520, -4752, -3125, -1856, -438, - 8131, -2543, -6285, -6723, -5588, -4321, -3264, -2164, - -653, -1301, -660, 608, 1598, 1805, 1698, 760, - 4882, 9309, 6333, 1734, 284, 364, 560, 1015, - -7686, -5737, -3443, -1642, 245, 1531, 1827, 1769, - -1468, 3782, 144, -5130, -6883, -5165, -1497, 2072, - -12937, -8429, -2619, 2894, 5004, 4710, 4627, 3740, - 3198, 3928, 4358, 4554, 3887, 2844, 1299, 129, - -13828, -12296, -9364, -7918, -5571, -1909, 307, 2047, - -4314, -1211, -559, -1061, -1928, -2228, -2359, -1902, - -309, -3224, -3404, -1895, -743, -59, 757, 908, - 10914, 5865, 1599, -386, -1392, -2285, -2236, -2042, - -11825, -16241, -11402, -3627, 6556, 8953, 6421, 1546, - 6102, 777, -301, 536, 902, 541, 210, -429, - -3052, 3997, 5389, 1842, -344, 1556, 2667, 2428, - 11788, 10894, 7448, 5423, 2372, -677, -2385, -3839, - -45, -7602, -8923, -7179, -3273, 65, 4500, 6726, - 5895, 626, -1610, -2598, -3240, -3540, -2930, -2156, - -971, 461, 1494, 4907, 5859, 5199, 3678, 2502, - 10766, 5297, 1844, 1236, 2498, 3503, 2846, 838, - -7816, -1212, 891, 2387, 1317, 2225, 1859, 1602, - 2376, 5357, 2088, -2719, -3419, -420, 2431, 2943, - -8383, -795, 4351, 7026, 7460, 7191, 5262, 3796, - 1522, 6283, 8714, 8222, 7434, 5768, 3586, 1499, - }, - { /* TCX 10 */ - -15596, -16321, -10264, -1002, 5955, 5543, -29, -1688, - 17, -3794, -6207, -7356, -6998, -6081, -4453, -2448, - -12543, -11530, -10186, -8817, -7083, -4440, -1946, 892, - 5198, 2751, -274, -2574, -4561, -6087, -5944, -4600, - -683, -2640, -2753, -1195, -239, -217, -286, 90, - -1400, -1146, -1853, -2845, -3456, -3788, -3171, -1969, - -1835, 392, 1725, 1209, -392, -1640, -2001, -1608, - 5770, 7707, 5210, 2112, -382, -2088, -2634, -3007, - -10766, -8101, -5137, -3754, -1881, 331, 2339, 3679, - -2637, -4640, -5811, -5651, -3790, -1359, 913, 1893, - -7793, -4768, -1762, -545, -717, -837, -441, -75, - 4030, 1770, 467, 379, 10, -1330, -2398, -2290, - -9395, -6952, -2494, 2022, 4753, 5614, 4443, 2642, - -1486, 1748, 859, -2586, -3368, -638, 2761, 3269, - -2408, 306, 3633, 6567, 5950, 2474, -621, -1421, - 5478, 7986, 9498, 8165, 5477, 1244, -523, -1586, - -13564, -14673, -10597, -5504, 1575, 8248, 7662, 4025, - 4978, -682, -3586, -4305, -3703, -3001, -2227, -1278, - -8002, -6831, -5558, -4868, -4243, -3393, -2486, -1110, - 11485, 5472, 1645, -533, -1792, -2814, -3169, -2706, - 1617, 421, 232, 1382, 2162, 2017, 1318, 744, - 3677, 5212, 1990, -1514, -2894, -2441, -451, 592, - 731, 4295, 5860, 3756, 1991, 1437, 869, 127, - 12736, 11722, 7768, 4682, 1574, -744, -1989, -3131, - -3490, -4269, -3681, -1531, 1111, 3327, 4138, 3815, - 7344, 1400, -1302, -1502, -1015, 57, 1212, 1498, - -4836, -1881, 1071, 2055, 2114, 2465, 2093, 1458, - 8569, 5879, 3654, 2879, 2530, 1703, 781, -233, - -3709, -990, 2338, 6227, 7083, 7102, 5657, 3401, - 3389, 6392, 5267, 1011, 275, 3519, 5236, 4339, - 599, 3752, 6943, 9211, 8152, 5568, 3337, 1838, - 9885, 9591, 7905, 8068, 7929, 7421, 4234, 757, - } - }, - { /* split 2 */ - { /* TCX 20 */ - -178, -3476, -5982, -7081, -7548, -7440, -6859, -5798, - -3596, -3670, -1501, 770, 812, -286, -2001, -3377, - -3998, -5191, -4988, -4421, -3889, -3571, -2738, -1969, - -2981, -2687, -1501, -83, 1136, 2377, 3248, 4105, - 1842, -41, -1972, -4282, -6779, -8405, -8674, -7835, - -259, 571, 2124, 3344, 2959, 1407, -750, -2523, - -524, -1956, -2855, -3202, -3939, -4666, -4907, -4782, - -5110, -4768, -3017, -663, 4188, 9210, 16602, 21081, - 4373, 4846, -603, -6495, -7289, -5540, -4749, -5527, - -1448, -1043, -619, -105, 356, 362, 542, 857, - 1373, -752, -5334, -6244, -3001, -932, -1040, -3125, - -2403, -1397, 612, 2449, 3920, 5231, 6819, 8581, - 2183, 1211, -111, -1084, -2836, -4977, -6701, -7284, - -751, 1255, 3408, 6474, 7503, 7026, 5413, 4464, - 935, 850, 589, 353, 160, -434, -939, -931, - 268, 2284, 3884, 5423, 6680, 7996, 9244, 9472, - 1075, 113, -1289, -4457, -7512, -5930, -1799, -571, - -3689, -4254, -3755, -2995, -1581, -135, 1049, 1589, - -1166, -1752, -1790, -1897, -1927, -1831, -1359, -805, - -1494, -735, 635, 1993, 2909, 3546, 4226, 4956, - 4435, 4299, 4269, 1328, -3731, -7621, -9319, -9170, - 1358, 2227, 3873, 4469, 4692, 4057, 2601, 1608, - 813, 398, -499, -666, -1286, -2271, -3316, -4025, - -3300, -1255, 2181, 6431, 10002, 12760, 13549, 12584, - 3714, 4180, 484, -2905, -2864, -1359, -1256, -2477, - 308, 868, 1373, 1629, 1793, 1834, 1814, 1746, - 1472, 798, -282, -1935, -1818, 320, 2221, 2914, - 2281, 3240, 2988, 1400, 2383, 4072, 5667, 6675, - 2672, 2678, 2874, 2096, -226, -2301, -3861, -4534, - 4988, 7231, 7641, 7731, 7061, 6447, 5411, 3513, - 3978, 4156, 4126, 2896, 1469, 759, 368, -68, - -264, 4210, 8534, 11008, 11606, 11888, 11072, 8949, - }, - { /* TCX 10 */ - -2852, -6158, -7231, -7830, -8012, -7922, -7556, -6706, - -3911, -5340, -5053, -4741, -4805, -4484, -3727, -3037, - -966, -1461, -1694, -2427, -3081, -3037, -2547, -2230, - -3455, -3315, -2451, -836, 1383, 3196, 3720, 3379, - 3052, 281, -3351, -6866, -9051, -9586, -8983, -8236, - -748, -4465, -4314, -2251, 29, -40, -3963, -6195, - 200, 1293, 2535, 2803, 1603, -186, -1397, -1697, - -1707, -265, 2196, 5295, 5894, 4216, 3440, 3826, - -237, -2133, -2279, -3149, -4377, -5638, -6520, -6764, - -2407, -2049, -1246, -664, -521, -430, -349, -211, - 3874, 1335, -1501, -2055, -1268, -990, -1852, -2871, - -1883, -1845, -1681, -484, 384, 2035, 5839, 9597, - 275, 380, 1048, 424, -1146, -3012, -4431, -5104, - -1699, -484, 756, 1261, 1279, 1377, 1975, 2590, - 2139, 4502, 3645, 4975, 6491, 5972, 5012, 4346, - -3821, -2581, -433, 2667, 6436, 10038, 11311, 8783, - 2359, -2689, -6604, -7039, -5992, -4268, -3711, -4840, - -2776, -4251, -4539, -3672, -2494, -1055, 280, 695, - 491, 866, 822, -44, -1009, -1165, -831, -538, - -1024, 91, 786, 1295, 2433, 3910, 4975, 5403, - 3117, 2590, 2337, -667, -4580, -8147, -9400, -9523, - -103, -630, -831, 669, 3062, 3398, 549, -1690, - 2113, 3467, 4279, 5047, 5344, 3361, 127, -2313, - -1199, 1153, 2914, 3688, 4260, 5421, 7471, 8831, - 2815, 2184, 316, -3058, -5596, -5564, -4343, -3793, - 922, 126, -1414, -1731, -1007, 359, 2029, 3088, - 4889, 4619, 2537, 1114, 950, 946, 799, 419, - -4271, -3750, -3359, -484, 1448, 4106, 10487, 20479, - 3818, 4687, 4064, 2212, -172, -2287, -3535, -4041, - 884, 2456, 3394, 2925, 2182, 2323, 2583, 2507, - 4767, 8057, 8263, 6461, 5003, 4055, 2923, 1845, - 19, 3813, 6926, 8432, 10141, 10850, 9692, 8383, - } - } -}; + { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, + { { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 0, 0 }, + + { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, + { { 21, 9, 9, 1 },{ 21, 7, 5, 1 },{ 21, 7, 5, 1 } }, 1, 0, 0 }, + + { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, + { { 21, 11, 9, 1 },{ 21, 9, 7, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, + + { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, + { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, + + { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, + { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, + + { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, + { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, + { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, + { { 31, 11, 11, 1 },{ 1, 1, 1, 1 }, { 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, + { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, + { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, + { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, + { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, + + { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124000, 124000, 128000 },{ 124000, 124000, 128000 },{ 125200, 118450, 128000 },{ 76300, 73000, 128000 } }, + { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, -const Word16 sns_1st_means_16k[2][16] = -{ - { /* TCX 20 */ - 14210, 19017, 14362, 9309, 5385, 2674, 1055, -211, -1407, -3059, -4393, -8597, -11180, -11756, -12131, -13281, - }, - { /* TCX 10*/ - 12018, 15915, 11089, 6015, 847, -705, -539, -1548, -893, -2163, -1806, -4189, -7017, -8670, -8874, -9480, - } + { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 118000, 118000, 128000 },{ 118000, 118000, 128000 },{ 117200, 109250, 128000 },{ 72300, 69000, 128000 } }, + { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, }; -const Word16 sns_1st_means_25k6[2][16] = +const ivas_spar_br_table_t ivas_spar_br_table_consts_fx[IVAS_SPAR_BR_TABLE_LEN] = /*ceilf(log2f)*/ { - { /* TCX 20 */ - 14973, 20323, 16461, 9554, 4017, 3103, 1602, 1694, -221, -1401, -6817, -10071, -11503, -11805, -13158, -16749, - }, - { /* TCX 10 */ - 15560, 19489, 14623, 5595, 2084, 1699, 775, -1312, -2195, -6101, -9078, -9465, -7825, -6603, -7281, -9960, - } -}; + /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel + so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, + { { 4, 0, 3, 0 },{ 4, 0, 2, 0 },{ 3, 0, 2, 0 } }, 0, 0, 0 }, -const Word16 sns_1st_means_32k[2][16] = + { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, + { { 4, 0, 3, 0 },{ 4, 0, 2, 0 },{ 3, 0, 2, 0 } }, 0, 0, 0 }, + + { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 16400, 14850, 24350 } }, + { { 4, 0, 3, 0 },{ 4, 0, 2, 0 },{ 3, 0, 2, 0 } }, 0, 0, 0 }, + + { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 24000, 20450, 31950 } }, + { { 5, 0, 3, 0 },{ 4, 0, 3, 0 },{ 4, 0, 2, 0 } }, 0, 0, 0 }, + + { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, + { { 4, 3, 3, 0 },{ 4, 3, 2, 0 },{ 3, 3, 2, 0 } }, 1, 0, 0 }, + + { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 5, 3, 3, 0 },{ 4, 3, 3, 0 },{ 4, 3, 2, 0 } }, 1, 1, 0 }, + + { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0, { { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, + { { 5, 3, 3, 0 },{ 4, 3, 3, 0 },{ 4, 3, 2, 0 } }, 1, 0, 0 }, + + { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, + { { 5, 4, 4, 0 },{ 5, 3, 3, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, + + { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, + { { 5, 4, 4, 0 },{ 5, 4, 3, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, + + { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, + { { 5, 4, 4, 0 },{ 5, 4, 4, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, + + { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0, { { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, + { { 5, 4, 4, 0 },{ 5, 4, 4, 0 },{ 5, 3, 3, 0 } }, 1, 0, 0 }, + + { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, + { { 5, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, + { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, + { { 5, 4, 4, 0 },{ 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, + { { 5, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, + { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, + { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, + { { 5, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124000, 124000, 128000 },{ 124000, 124000, 128000 },{ 125200, 118450, 128000 },{ 76300, 73000, 128000 } }, + { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, + + { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0, { { 118000, 118000, 128000 },{ 118000, 118000, 128000 },{ 117200, 109250, 128000 },{ 72300, 69000, 128000 } }, + { { 5, 4, 4, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 } }, 1, 2, 0 }, +}; +const ivas_freq_models_t ivas_arith_pred_r_consts[TOTAL_PRED_QUANT_STRATS_ARITH] = { - { /* TCX 20 */ - 15041, 20603, 16969, 10289, 4973, 4283, 3003, 3316, 1684, -259, -6614, -9535, -10363, -11834, -16625, -24930, + /* entry for 1 quantization points */ + { + /* pred_R real */ + { + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + }, + /* pred_R real differential */ + { + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + }, + /* pred_R real : values for general and differential */ + { 0 },{ 0 }, + /* pred_R real : num dyn models for general and differential */ + 4, 4 }, - { /* TCX 10 */ - 16510, 20660, 16025, 7224, 3921, 3868, 2623, 742, -1316, -6269, -8284, -7288, -6380, -8410, -13351, -20277, + /* entry for 7 quantization points for br_table_idx >= 2 */ + { + /* pred_R real */ + { + { 0,546,1092,2184,8740,2184,1092,546, }, + { 0,1779,2116,2516,3562,2516,2116,1779, }, + { 0,1848,2614,5229,2614,1848,1307,924, }, + { 0,924,1307,1848,2614,5229,2614,1848, }, + }, + /* pred_R real differential */ + { + { 0,125,399,1269,12798,1269,399,125, }, + { 0,744,1327,2365,7512,2365,1327,744, }, + { 0,1354,2413,7664,2413,1354,760,426, }, + { 0,426,760,1354,2413,7664,2413,1354, }, + }, + /* pred_R real : values for general and differential */ + { -3,-2,-1,0,1,2,3 },{ -3,-2,-1,0,1,2,3 }, + /* pred_R real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 15 quantization points for br_table_idx >= 2 */ + { + /* pred_R real */ + { + { 0,32,64,128,257,514,1028,2056,8226,2056,1028,514,257,128,64,32, }, + { 0,565,672,799,950,1130,1344,1598,2268,1598,1344,1130,950,799,672,565, }, + { 0,353,500,707,1000,1414,2000,4010,2000,1414,1000,707,500,353,250,176, }, + { 0,176,250,353,500,707,1000,1414,2000,4010,2000,1414,1000,707,500,353, }, + }, + /* pred_R real differential */ + { + { 0,1,3,12,39,125,397,1260,12710,1260,397,125,39,12,3,1, }, + { 0,66,119,212,378,674,1201,2140,6804,2140,1201,674,378,212,119,66, }, + { 0,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119,67,37, }, + { 0,37,67,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119, }, + }, + /* pred_R real : values for general and differential */ + { -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 }, + { -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 }, + /* pred_R real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 21 quantization points for br_table_idx >= 2 */ + { + /* pred_R real */ + { + { 0,4,8,16,32,64,128,256,512,1024,2049,8198,2049,1024,512,256,128,64,32,16,8,4, }, + { 0,292,348,414,492,585,696,828,984,1171,1392,1980,1392,1171,984,828,696,585,492,414,348,292, }, + { 0,119,168,238,336,476,673,952,1346,1904,3817,1904,1346,952,673,476,336,238,168,119,84,59, }, + { 0,59,84,119,168,238,336,476,673,952,1346,1904,3817,1904,1346,952,673,476,336,238,168,119, }, + }, + /* pred_R real differential */ + { + { 0,1,1,1,1,3,12,39,125,397,1260,12704,1260,397,125,39,12,3,1,1,1,1, }, + { 0,11,20,37,66,118,210,375,668,1191,2122,6748,2122,1191,668,375,210,118,66,37,20,11, }, + { 0,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20,11,6, }, + { 0,6,11,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20, }, + }, + /* pred_R real : values for general and differential */ + { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, + { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, + /* pred_R real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 31 quantization points */ + { + /* pred real */ + { + { 0,1,1,1,1,2,4,8,16,32,64,128,256,512,1024,2048,8188,2048,1024,512,256,128,64,32,16,8,4,2,1,1,1,1, }, + { 0,110,131,156,186,221,263,313,373,443,527,627,746,887,1055,1255,1798,1255,1055,887,746,627,527,443,373,313,263,221,186,156,131,110, }, + { 0,20,29,41,58,82,116,164,233,329,466,659,932,1318,1864,3738,1864,1318,932,659,466,329,233,164,116,82,58,41,29,20,14,10, }, + { 0,10,14,20,29,41,58,82,116,164,233,329,466,659,932,1318,1864,3738,1864,1318,932,659,466,329,233,164,116,82,58,41,29,20, } + }, + /* pred real differential */ + { + { 0,1,1,1,1,1,1,1,1,1,3,12,39,125,397,1260,12694,1260,397,125,39,12,3,1,1,1,1,1,1,1,1,1, }, + { 0,1,1,2,3,6,11,20,37,66,117,210,374,667,1189,2118,6740,2118,1189,667,374,210,117,66,37,20,11,6,3,2,1,1, }, + { 0,1,2,3,6,11,20,37,66,117,210,374,667,1189,2118,6740,2118,1189,667,374,210,117,66,37,20,11,6,3,2,1,1,1, }, + { 0,1,1,1,2,3,6,11,20,37,66,117,210,374,667,1189,2118,6740,2118,1189,667,374,210,117,66,37,20,11,6,3,2,1, } + }, + /* pred real : values for general and differential */ + { -15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + { -15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + /* pred real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 7 quantization points for br_table_idx < 2 */ + { + /* pred_R real */ + { + { 0,327,778,1851,10472,1851,778,327, }, + { 0,1057,1630,2514,5982,2514,1630,1057, }, + { 0,1668,2572,6122,2572,1668,1081,701, }, + { 0,701,1081,1668,2572,6122,2572,1668, }, + }, + /* pred_R real differential */ + { + { 0,125,399,1269,12798,1269,399,125, }, + { 0,744,1327,2365,7512,2365,1327,744, }, + { 0,1354,2413,7664,2413,1354,760,426, }, + { 0,426,760,1354,2413,7664,2413,1354, }, + }, + /* pred_R real : values for general and differential */ + { -3,-2,-1,0,1,2,3 },{ -3,-2,-1,0,1,2,3 }, + /* pred_R real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 15 quantization points for br_table_idx < 2 */ + { + /* pred real */ + { + { 0,9,23,56,133,318,757,1800,10192,1800,757,318,133,56,23,9, }, + { 0,156,240,371,573,883,1363,2102,5008,2102,1363,883,573,371,240,156, }, + { 0,241,372,575,886,1367,2109,5027,2109,1367,886,575,372,241,156,101, }, + { 0,101,156,241,372,575,886,1367,2109,5027,2109,1367,886,575,372,241, } + }, + /* pred real differential */ + { + { 0,1,3,12,39,125,397,1260,12710,1260,397,125,39,12,3,1, }, + { 0,66,119,212,378,674,1201,2140,6804,2140,1201,674,378,212,119,66, }, + { 0,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119,67,37, }, + { 0,37,67,119,212,379,675,1203,2144,6816,2144,1203,675,379,212,119, } + }, + /* pred real : values for general and differential */ + {-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7}, + { -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 }, + /* pred real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 21 quantization points for br_table_idx < 2 */ + { + /* pred_R real */ + { + { 0,1,1,4,9,23,56,133,318,756,1799,10184,1799,756,318,133,56,23,9,4,1,1, }, + { 0,41,64,98,152,234,362,558,861,1329,2049,4888,2049,1329,861,558,362,234,152,98,64,41, }, + { 0,64,98,152,235,362,559,862,1330,2051,4891,2051,1330,862,559,362,235,152,98,64,41,26, }, + { 0,26,41,64,98,152,235,362,559,862,1330,2051,4891,2051,1330,862,559,362,235,152,98,64, }, + }, + /* pred_R real differential */ + { + { 0,1,1,1,1,3,12,39,125,397,1260,12704,1260,397,125,39,12,3,1,1,1,1, }, + { 0,11,20,37,66,118,210,375,668,1191,2122,6748,2122,1191,668,375,210,118,66,37,20,11, }, + { 0,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20,11,6, }, + { 0,6,11,20,37,66,118,210,375,668,1191,2123,6751,2123,1191,668,375,210,118,66,37,20, }, + }, + /* pred_R real : values for general and differential */ + { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, + { -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 }, + /* pred_R real : num dyn models for general and differential */ + 4, 4 } }; - -/*----------------------------------------------------------------------* - * MC ParamUpmix ROM tables - *-----------------------------------------------------------------------*/ - -const Word16 ivas_param_upmx_mx_qmap[33] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 -}; - - -const Word32 release_cnst_table[4][201] = // Q31 +const ivas_freq_models_t ivas_arith_drct_r_consts[TOTAL_DRCT_QUANT_STRATS] = +{ + /* entry for 1 quantization points */ { + /* drct real */ { - 1913946752, - 1919716352, - 1925351680, - 1930855552, - 1936230784, - 1941479808, - 1946605312, - 1951609728, - 1956495744, - 1961265792, - 1965922304, - 1970467584, - 1974904320, - 1979234560, - 1983460736, - 1987585024, - 1991609856, - 1995537280, - 1999369344, - 2003108480, - 2006756480, - 2010315520, - 2013787520, - 2017174528, - 2020478464, - 2023701248, - 2026844672, - 2029910656, - 2032900992, - 2035817344, - 2038661376, - 2041435008, - 2044139648, - 2046777088, - 2049348864, - 2051856384, - 2054301440, - 2056685312, - 2059009536, - 2061275520, - 2063484672, - 2065638272, - 2067737856, - 2069784448, - 2071779584, - 2073724416, - 2075620096, - 2077467904, - 2079268992, - 2081024512, - 2082735488, - 2084403200, - 2086028416, - 2087612544, - 2089156352, - 2090660864, - 2092127104, - 2093555968, - 2094948480, - 2096305408, - 2097627776, - 2098916352, - 2100172032, - 2101395584, - 2102587776, - 2103749504, - 2104881408, - 2105984384, - 2107059072, - 2108106112, - 2109126400, - 2110120448, - 2111088896, - 2112032512, - 2112951808, - 2113847552, - 2114720128, - 2115570304, - 2116398592, - 2117205504, - 2117991552, - 2118757504, - 2119503616, - 2120230400, - 2120938496, - 2121628288, - 2122300288, - 2122954880, - 2123592576, - 2124213760, - 2124818944, - 2125408384, - 2125982592, - 2126541952, - 2127086848, - 2127617664, - 2128134656, - 2128638336, - 2129128832, - 2129606784, - 2130072192, - 2130525568, - 2130967296, - 2131397376, - 2131816448, - 2132224640, - 2132622080, - 2133009408, - 2133386496, - 2133753856, - 2134111744, - 2134460288, - 2134799744, - 2135130368, - 2135452416, - 2135766144, - 2136071680, - 2136369152, - 2136659072, - 2136941312, - 2137216256, - 2137484160, - 2137744896, - 2137998976, - 2138246400, - 2138487424, - 2138722176, - 2138950656, - 2139173376, - 2139390208, - 2139601408, - 2139807104, - 2140007424, - 2140202624, - 2140392576, - 2140577664, - 2140758016, - 2140933504, - 2141104512, - 2141271040, - 2141433216, - 2141591168, - 2141745024, - 2141894912, - 2142040832, - 2142182912, - 2142321408, - 2142456192, - 2142587392, - 2142715264, - 2142839808, - 2142961152, - 2143079296, - 2143194240, - 2143306240, - 2143415424, - 2143521664, - 2143625216, - 2143725952, - 2143824128, - 2143919744, - 2144012800, - 2144103424, - 2144191744, - 2144277760, - 2144361472, - 2144443136, - 2144522496, - 2144599936, - 2144675200, - 2144748544, - 2144820096, - 2144889600, - 2144957440, - 2145023488, - 2145087744, - 2145150336, - 2145211264, - 2145270656, - 2145328512, - 2145384832, - 2145439616, - 2145493120, - 2145545088, - 2145595776, - 2145645056, - 2145693184, - 2145739904, - 2145785472, - 2145829888, - 2145873152, - 2145915136, - 2145956224, - 2145996032, - 2146034944, - 2146072832, - 2146109696, - 2146145664, - 2146180608, - 2146214656, - 2146247808, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + }, + /* drct real differential */ + { + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + }, + /* drct real : values for general and differential */ + {0},{ 0 }, + /* drct real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 7 quantization points */ + { /* drct real */ + { + { 0,125,399,1269,12798,1269,399,125, }, + { 0,744,1327,2365,7512,2365,1327,744, }, + { 0,988,1244,1568,1976,2489,3136,4983, }, + { 0,2111,2262,2425,2788,2425,2262,2111, }, + }, + /* drct real differential */ + { + { 0,125,399,1269,12798,1269,399,125, }, + { 0,744,1327,2365,7512,2365,1327,744, }, + { 0,1354,2413,7664,2413,1354,760,426, }, + { 0,426,760,1354,2413,7664,2413,1354, }, + }, + /* drct real : values for general and differential */ + { -3,-2,-1,0,1,2,3 },{ -3,-2,-1,0,1,2,3 }, + /* drct real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 9 quantization points */ + { + /* drct real */ + { + { 0,39,125,397,1263,12736,1263,397,125,39, }, + { 0,397,708,1262,2250,7150,2250,1262,708,397, }, + { 0,573,722,909,1146,1444,1819,2292,2888,4591, }, + { 0,1587,1701,1824,1955,2250,1955,1824,1701,1587, }, }, + /* drct real differential */ { - 2027355264, - 2030408704, - 2033386624, - 2036290944, - 2039123328, - 2041885440, - 2044578944, - 2047205376, - 2049766528, - 2052263680, - 2054698496, - 2057072384, - 2059387008, - 2061643520, - 2063843328, - 2065987968, - 2068078720, - 2070116864, - 2072103552, - 2074040192, - 2075927936, - 2077767936, - 2079561472, - 2081309568, - 2083013376, - 2084673920, - 2086292352, - 2087869696, - 2089406976, - 2090905216, - 2092365184, - 2093788032, - 2095174528, - 2096525824, - 2097842432, - 2099125632, - 2100375808, - 2101594240, - 2102781312, - 2103938048, - 2105065216, - 2106163456, - 2107233536, - 2108276096, - 2109292032, - 2110281728, - 2111246080, - 2112185728, - 2113101056, - 2113992960, - 2114861824, - 2115708288, - 2116532992, - 2117336448, - 2118119168, - 2118881792, - 2119624704, - 2120348416, - 2121053440, - 2121740288, - 2122409344, - 2123061120, - 2123696128, - 2124314624, - 2124917120, - 2125504128, - 2126075776, - 2126632832, - 2127175296, - 2127703808, - 2128218624, - 2128720000, - 2129208448, - 2129684352, - 2130147712, - 2130599168, - 2131038976, - 2131467264, - 2131884416, - 2132290816, - 2132686592, - 2133072256, - 2133447680, - 2133813504, - 2134169856, - 2134516864, - 2134854784, - 2135184000, - 2135504640, - 2135816960, - 2136121216, - 2136417536, - 2136706048, - 2136987136, - 2137260928, - 2137527552, - 2137787264, - 2138040192, - 2138286592, - 2138526464, - 2138760192, - 2138987776, - 2139209472, - 2139425408, - 2139635712, - 2139840512, - 2140039936, - 2140234240, - 2140423424, - 2140607744, - 2140787200, - 2140962048, - 2141132288, - 2141298048, - 2141459584, - 2141616896, - 2141769984, - 2141919232, - 2142064512, - 2142205952, - 2142343808, - 2142478080, - 2142608768, - 2142736128, - 2142860032, - 2142980864, - 2143098368, - 2143212928, - 2143324544, - 2143433088, - 2143538944, - 2143641984, - 2143742336, - 2143840000, - 2143935232, - 2144027904, - 2144118144, - 2144206080, - 2144291712, - 2144375168, - 2144456320, - 2144535424, - 2144612480, - 2144687488, - 2144760448, - 2144831616, - 2144900992, - 2144968448, - 2145034112, - 2145098112, - 2145160448, - 2145221248, - 2145280256, - 2145337856, - 2145393920, - 2145448576, - 2145501696, - 2145553536, - 2145603968, - 2145653120, - 2145700992, - 2145747456, - 2145792896, - 2145837056, - 2145880064, - 2145922048, - 2145962880, - 2146002560, - 2146041344, - 2146078976, - 2146115712, - 2146151424, - 2146186240, - 2146220160, - 2146253184, - 2146285312, - 2146316672, - 2146347136, - 2146376832, - 2146405760, - 2146433920, - 2146461440, - 2146488192, - 2146514176, - 2146539520, - 2146564224, - 2146588160, - 2146611584, - 2146634368, - 2146656640, - 2146678272, - 2146699264, - 2146719744, - 2146739712, - 2146759168, - 2146778112, - 2146796544, - 2146814464, - 2146832000, - 2146849024, - 2146865664, + { 0,39,125,397,1263,12736,1263,397,125,39, }, + { 0,397,708,1262,2250,7150,2250,1262,708,397, }, + { 0,716,1276,2274,7225,2274,1276,716,402,225, }, + { 0,225,402,716,1276,2274,7225,2274,1276,716, } + }, + /* drct real : values for general and differential */ + { -4,-3,-2,-1,0,1,2,3,4 },{ -4,-3,-2,-1,0,1,2,3,4 }, + /* drct real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 11 quantization points */ + { + /* drct real */ + { + { 0,12,39,125,397,1261,12716,1261,397,125,39,12, }, + { 0,217,387,689,1229,2190,6960,2190,1229,689,387,217, }, + { 0,343,433,546,687,866,1092,1375,1733,2184,2751,4374, }, + { 0,1254,1344,1441,1544,1655,1908,1655,1544,1441,1344,1254, }, + }, + /* drct real differential */ + { + { 0,12,39,125,397,1261,12716,1261,397,125,39,12, }, + { 0,217,387,689,1229,2190,6960,2190,1229,689,387,217, }, + { 0,389,694,1236,2203,7000,2203,1236,694,389,218,122, }, + { 0,122,218,389,694,1236,2203,7000,2203,1236,694,389, }, + }, + /* drct real : values for general and differential */ + { -5,-4,-3,-2,-1,0,1,2,3,4,5 },{ -5,-4,-3,-2,-1,0,1,2,3,4,5 }, + /* drct real : num dyn models for general and differential */ + 4, 4 + } +}; + +const ivas_freq_models_t ivas_arith_decd_r_consts[TOTAL_DECD_QUANT_STRATS] = +{ + /* entry for 1 quantization points */ + { + /* decd real */ + { + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + }, + /* decd real differential */ + { + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, + { 0,16384, }, }, + /* decd real : values for general and differential */ + { 0 },{ 0 }, + /* decd real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 3 quantization points */ + { + /* decd real */ { - 2086555136, - 2088125824, - 2089656576, - 2091148416, - 2092602240, - 2094018944, - 2095399680, - 2096745088, - 2098056192, - 2099333888, - 2100578816, - 2101792000, - 2102974080, - 2104125824, - 2105248128, - 2106341760, - 2107407232, - 2108445440, - 2109456896, - 2110442496, - 2111402624, - 2112338176, - 2113249664, - 2114137728, - 2115002880, - 2115845760, - 2116666880, - 2117466880, - 2118246272, - 2119005568, - 2119745280, - 2120465920, - 2121167872, - 2121851776, - 2122517888, - 2123166976, - 2123799168, - 2124414976, - 2125014912, - 2125599360, - 2126168704, - 2126723200, - 2127263360, - 2127789568, - 2128302208, - 2128801408, - 2129287808, - 2129761536, - 2130222976, - 2130672512, - 2131110272, - 2131536768, - 2131952128, - 2132356736, - 2132750848, - 2133134720, - 2133508736, - 2133872896, - 2134227584, - 2134573184, - 2134909696, - 2135237504, - 2135556736, - 2135867648, - 2136170624, - 2136465536, - 2136752896, - 2137032832, - 2137305344, - 2137570816, - 2137829376, - 2138081280, - 2138326528, - 2138565504, - 2138798080, - 2139024768, - 2139245440, - 2139460480, - 2139669888, - 2139873792, - 2140072320, - 2140265856, - 2140454144, - 2140637696, - 2140816384, - 2140990464, - 2141159936, - 2141325056, - 2141485824, - 2141642368, - 2141794944, - 2141943424, - 2142088064, - 2142228992, - 2142366208, - 2142499840, - 2142630016, - 2142756736, - 2142880128, - 2143000448, - 2143117440, - 2143231488, - 2143342592, - 2143450752, - 2143556096, - 2143658624, - 2143758592, - 2143855872, - 2143950592, - 2144043008, - 2144132864, - 2144220416, - 2144305664, - 2144388608, - 2144469504, - 2144548224, - 2144624896, - 2144699648, - 2144772352, - 2144843264, - 2144912256, - 2144979328, - 2145044864, - 2145108480, - 2145170560, - 2145231104, - 2145289856, - 2145347200, - 2145403008, - 2145457408, - 2145510400, - 2145561984, - 2145612160, - 2145661056, - 2145708672, - 2145755136, - 2145800192, - 2145844224, - 2145887104, - 2145928832, - 2145969408, - 2146008960, - 2146047616, - 2146085120, - 2146121600, - 2146157184, - 2146191872, - 2146225664, - 2146258560, - 2146290560, - 2146321792, - 2146352128, - 2146381696, - 2146410496, - 2146438528, - 2146465920, - 2146492416, - 2146518400, - 2146543616, - 2146568192, - 2146592128, - 2146615424, - 2146638080, - 2146660224, - 2146681728, - 2146702720, - 2146723072, - 2146743040, - 2146762368, - 2146781184, - 2146799616, - 2146817408, - 2146834816, - 2146851840, - 2146868352, - 2146884352, - 2146900096, - 2146915328, - 2146930176, - 2146944640, - 2146958720, - 2146972416, - 2146985856, - 2146998784, - 2147011456, - 2147023872, - 2147035904, - 2147047552, - 2147058944, - 2147070080, - 2147080832, - 2147091456, - 2147101696, - 2147111680, - 2147121408, - 2147130880, - 2147140096, - 2147149056, - 2147157760, - 2147166336, - 2147174656, + { 0,11917,2978,1489, }, + { 0,8840,4419,3125, }, + { 0,4567,7250,4567, }, + { 0,5203,5978,5203, }, + }, + /* decd real differential */ + { + { 0,1356,13672,1356, }, + { 0,3166,10052,3166, }, + { 0,10984,3459,1941, }, + { 0,1941,3459,10984, }, + }, + /* decd real : values for general and differential */ + { 0,1,2 },{-1,0,1}, + /* decd real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 5 quantization points */ + { + /* decd real */ + { + { 0,11157,2788,1394,697,348, }, + { 0,7186,3592,2540,1796,1270, }, + { 0,2512,3166,5028,3166,2512, }, + { 0,3048,3267,3754,3267,3048, }, + }, + /* decd real differential */ + { + { 0,406,1289,12994,1289,406, }, + { 0,1460,2601,8262,2601,1460, }, + { 0,2707,8599,2707,1519,852, }, + { 0,852,1519,2707,8599,2707, }, + }, + /* decd real : values for general and differential */ + { 0,1,2,3,4 },{ -2,-1,0,1,2 }, + /* decd real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 7 quantization points */ + { + /* decd real */ + { + { 0,10983,2744,1372,686,343,171,85, }, + { 0,6573,3285,2322,1642,1161,821,580, }, + { 0,1603,2020,2546,4046,2546,2020,1603, }, + { 0,2111,2262,2425,2788,2425,2262,2111, }, }, + /* decd real differential */ { - 2106670080, - 2107727232, - 2108757120, - 2109760640, - 2110738432, - 2111691008, - 2112619136, - 2113523328, - 2114404352, - 2115262592, - 2116098816, - 2116913408, - 2117707136, - 2118480256, - 2119233536, - 2119967360, - 2120682240, - 2121378688, - 2122057088, - 2122717952, - 2123361792, - 2123988992, - 2124599936, - 2125195136, - 2125774848, - 2126339584, - 2126889728, - 2127425536, - 2127947520, - 2128456064, - 2128951296, - 2129433856, - 2129903744, - 2130361600, - 2130807424, - 2131241728, - 2131664768, - 2132076928, - 2132478208, - 2132869248, - 2133250048, - 2133620992, - 2133982208, - 2134334080, - 2134676864, - 2135010688, - 2135335936, - 2135652608, - 2135961088, - 2136261504, - 2136554112, - 2136839168, - 2137116800, - 2137387136, - 2137650560, - 2137907072, - 2138156928, - 2138400256, - 2138637184, - 2138867968, - 2139092864, - 2139311744, - 2139524992, - 2139732736, - 2139934976, - 2140131968, - 2140323840, - 2140510720, - 2140692736, - 2140870016, - 2141042688, - 2141210752, - 2141374592, - 2141534080, - 2141689344, - 2141840640, - 2141987968, - 2142131456, - 2142271232, - 2142407424, - 2142539904, - 2142669056, - 2142794752, - 2142917248, - 2143036544, - 2143152640, - 2143265792, - 2143375872, - 2143483264, - 2143587712, - 2143689472, - 2143788544, - 2143885056, - 2143979136, - 2144070656, - 2144159872, - 2144246656, - 2144331264, - 2144413568, - 2144493824, - 2144571904, - 2144647936, - 2144722048, - 2144794240, - 2144864512, - 2144932864, - 2144999552, - 2145064448, - 2145127680, - 2145189248, - 2145249152, - 2145307520, - 2145364480, - 2145419776, - 2145473792, - 2145526272, - 2145577472, - 2145627264, - 2145675776, - 2145723008, - 2145768960, - 2145813760, - 2145857408, - 2145899904, - 2145941376, - 2145981696, - 2146020864, - 2146059136, - 2146096384, - 2146132608, - 2146167936, - 2146202368, - 2146235776, - 2146268416, - 2146300160, - 2146331136, - 2146361216, - 2146390528, - 2146419200, - 2146446976, - 2146474112, - 2146500480, - 2146526208, - 2146551168, - 2146575488, - 2146599296, - 2146622464, - 2146644864, - 2146666880, - 2146688128, - 2146708992, - 2146729216, - 2146748928, - 2146768128, - 2146786816, - 2146805120, - 2146822784, - 2146840064, - 2146856960, - 2146873344, - 2146889216, - 2146904832, - 2146919936, - 2146934656, - 2146948992, - 2146962944, - 2146976640, - 2146989824, - 2147002752, - 2147015296, - 2147027584, - 2147039488, - 2147051136, - 2147062400, - 2147073408, - 2147084160, - 2147094528, - 2147104768, - 2147114624, - 2147124352, - 2147133696, - 2147142912, - 2147151744, - 2147160448, - 2147168896, - 2147177088, - 2147185152, - 2147192960, - 2147200512, - 2147207936, - 2147215104, - 2147222144, - 2147229056, - 2147235712, - 2147242112, - 2147248384, - 2147254656, - 2147260544, - 2147266432, - 2147272064, - 2147277568, + { 0,125,399,1269,12798,1269,399,125, }, + { 0,744,1327,2365,7512,2365,1327,744, }, + { 0,1354,2413,7664,2413,1354,760,426, }, + { 0,426,760,1354,2413,7664,2413,1354, } + }, + /* decd real : values for general and differential */ + { 0,1,2,3,4,5,6 },{ -3,-2,-1,0,1,2,3 }, + /* decd real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 9 quantization points */ + { /* decd real */ + { + { 0,10941,2734,1367,683,341,170,85,42,21, }, + { 0,6305,3150,2227,1575,1113,787,556,393,278, }, + { 0,1101,1388,1749,2203,3502,2203,1749,1388,1101, }, + { 0,1587,1701,1824,1955,2250,1955,1824,1701,1587, }, + }, + /* decd real differential */ + { + { 0,39,125,397,1263,12736,1263,397,125,39, }, + { 0,397,708,1262,2250,7150,2250,1262,708,397, }, + { 0,716,1276,2274,7225,2274,1276,716,402,225, }, + { 0,225,402,716,1276,2274,7225,2274,1276,716, } + }, + /* decd real : values for general and differential */ + { 0,1,2,3,4,5,6,7,8 },{ -4,-3,-2,-1,0,1,2,3,4 }, + /* decd real : num dyn models for general and differential */ + 4, 4 + }, + /* entry for 11 quantization points */ + { + /* decd real */ + { + { 0,10932,2731,1365,682,341,170,85,42,21,10,5, }, + { 0,6181,3086,2182,1543,1091,771,545,385,272,192,136, }, + { 0,790,995,1254,1580,1991,3164,1991,1580,1254,995,790, }, + { 0,1254,1344,1441,1544,1655,1908,1655,1544,1441,1344,1254, }, + }, + /* decd real differential */ + { + { 0,12,39,125,397,1261,12716,1261,397,125,39,12, }, + { 0,217,387,689,1229,2190,6960,2190,1229,689,387,217, }, + { 0,389,694,1236,2203,7000,2203,1236,694,389,218,122, }, + { 0,122,218,389,694,1236,2203,7000,2203,1236,694,389, }, + }, + /* decd real : values for general and differential */ + { 0,1,2,3,4,5,6,7,8,9,10 },{ -5,-4,-3,-2,-1,0,1,2,3,4,5 }, + /* decd real : num dyn models for general and differential */ + 4, 4 + } +}; + +const ivas_huff_models_t ivas_huff_pred_r_consts[TOTAL_PRED_QUANT_STRATS_HUFF] = +{ + /* entry for 1 quantization points for br_table_idx */ + {{{ 0 }}, {{ 0 }}}, + /* entry for 7 quantization points for br_table_idx */ + { + /* pred_R codebook */ + { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 }, }, + /* pred_R differential codebook */ + { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 }, }, + }, + /* entry for 15 quantization points for br_table_idx */ + { + /* pred_r codebook */ + { { -7,4,2 },{ -6,4,3 },{ -5, 4, 4 },{ -4, 4, 5 },{ -3,4,6 },{ -2,4,7 },{ -1,4,8 }, + { 0,3,0 },{ 1,4,9 },{ 2,4,10 },{ 3,4,11 },{ 4,4,12 },{ 5,4,13 },{ 6,4,14 },{ 7,4,15 } }, + /* pred_r differential codebook */ + { { -7,4,2 },{ -6,4,3 },{ -5, 4, 4 },{ -4, 4, 5 },{ -3,4,6 },{ -2,4,7 },{ -1,4,8 }, + { 0,3,0 },{ 1,4,9 },{ 2,4,10 },{ 3,4,11 },{ 4,4,12 },{ 5,4,13 },{ 6,4,14 },{ 7,4,15 } }, + }, + /* entry for 21 quantization points for br_table_idx=0 */ + { + /* pred_r codebook */ + { {-10,5,22},{-9,5,23},{-8,5,24},{-7,5,25},{-6,5,26}, { -5, 4, 0 },{ -4, 4, 1 },{ -3,4,2 },{ -2,4,3 },{ -1,4,4 }, + { 0,4,5 },{ 1,4,6 },{ 2,4,7 },{ 3,4,8 },{ 4,4,9 },{ 5,4,10 },{6,5,27},{7,5,28},{8,5,29},{9,5,30},{10,5,31} }, + /* pred_r differential codebook */ + { { -10,5,22 },{ -9,5,23 },{ -8,5,24 },{ -7,5,25 },{ -6,5,26 },{ -5, 4, 0 },{ -4, 4, 1 },{ -3,4,2 },{ -2,4,3 },{ -1,4,4 }, + { 0,4,5 },{ 1,4,6 },{ 2,4,7 },{ 3,4,8 },{ 4,4,9 },{ 5,4,10 },{ 6,5,27 },{ 7,5,28 },{ 8,5,29 },{ 9,5,30 },{ 10,5,31 } }, + }, + + /* entry for 31 quantization points for br_table_idx>0 */ + { + /* pred_r codebook */ + { {-15,5,2},{-14,5,3},{-13,5,4},{-12,5,5},{-11,5,6}, { -10,5,7 },{ -9,5,8 },{ -8,5,9 }, + { -7,5,10 },{ -6,5,11 },{ -5, 5, 12 },{ -4, 5, 13 },{ -3,5,14 },{ -2,5,15 },{ -1,5,16 }, + { 0,4,0 },{ 1,5,17 },{ 2,5,18 },{ 3,5,19 },{ 4,5,20 },{ 5,5,21 },{ 6,5,22 },{ 7,5,23 }, + { 8,5,24 },{ 9,5,25 },{ 10,5,26 },{11,5,27},{12,5,28},{13,5,29},{14,5,30},{15,5,31} }, + /* pred_r differential codebook */ + { { -15,5,2 },{ -14,5,3 },{ -13,5,4 },{ -12,5,5 },{ -11,5,6 },{ -10,5,7 },{ -9,5,8 },{ -8,5,9 }, + { -7,5,10 },{ -6,5,11 },{ -5, 5, 12 },{ -4, 5, 13 },{ -3,5,14 },{ -2,5,15 },{ -1,5,16 }, + { 0,4,0 },{ 1,5,17 },{ 2,5,18 },{ 3,5,19 },{ 4,5,20 },{ 5,5,21 },{ 6,5,22 },{ 7,5,23 }, + { 8,5,24 },{ 9,5,25 },{ 10,5,26 },{ 11,5,27 },{ 12,5,28 },{ 13,5,29 },{ 14,5,30 },{ 15,5,31 } }, + }, + }; + + const ivas_huff_models_t ivas_huff_drct_r_consts[TOTAL_DRCT_QUANT_STRATS] = +{ + /* entry for 1 quantization points */ + {{{ 0 }}, {{ 0 }}}, + /* entry for 7 quantization points */ + { + /* drct_r codebook */ + { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 } }, + /* drct_r differential codebook */ + { { -3,3,2 },{ -2,3,3 },{ -1,3,4 },{ 0,2,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 } }, + }, + /* entry for 9 quantization points */ + { + /* drct_r codebook */ + { { -4, 4, 14 },{ -3,3,0 },{ -2,3,1 },{ -1,3,2 },{ 0,3,3 },{ 1,3,4 },{ 2,3,5 },{ 3,3,6 },{ 4,4,15 } }, + /* drct_r differential codebook */ + { { -4, 4, 14 },{ -3,3,0 },{ -2,3,1 },{ -1,3,2 },{ 0,3,3 },{ 1,3,4 },{ 2,3,5 },{ 3,3,6 },{ 4,4,15 } }, + }, + /* entry for 11 quantization points */ + { + /* drct_r codebook */ + { { -5, 4, 10 },{ -4, 4, 11 },{ -3,4,12 },{ -2,3,0 },{ -1,3,1 },{ 0,3,2 },{ 1,3,3 },{ 2,3,4 },{ 3,4,13 },{ 4,4,14 },{ 5,4,15 } }, + /* drct_r differential codebook */ + { { -5, 4, 10 },{ -4, 4, 11 },{ -3,4,12 },{ -2,3,0 },{ -1,3,1 },{ 0,3,2 },{ 1,3,3 },{ 2,3,4 },{ 3,4,13 },{ 4,4,14 },{ 5,4,15 } }, + }, +}; + +const ivas_huff_models_t ivas_huff_decd_r_consts[TOTAL_DECD_QUANT_STRATS] = +{ + /* entry for 1 quantization points */ + {{{ 0 }}, {{ 0 }}}, + /* entry for 3 quantization points */ + { + /* decd_r codebook */ + { { 0, 2, 2 },{ 1, 1, 0 },{ 2,2,3 } }, + /* decd_r differential codebook */ + { { -1, 2, 2 },{ 0, 1, 0 },{ 1,2,3 } }, + }, + /* entry for 5 quantization points */ + { + /* decd_r codebook */ + { { 0,3,6 },{ 1,2,0 },{ 2,2,1 },{ 3,2,2 },{ 4,3,7 } }, + /* decd_r differential codebook */ + { { -2,3,6 },{ -1,2,0 },{ 0,2,1 },{ 1,2,2 },{ 2,3,7 } }, + }, + /* entry for 7 quantization points */ + { + /* decd_r */ + { { 0, 3, 2 },{ 1, 3, 3 },{ 2,3,4 },{ 3,3,0 },{ 4,3,5 },{ 5,3,6 },{ 6,3,7 } }, + /* decd_r codebook differential codebook */ + { { -3, 3, 2 },{ -2, 3, 3 },{ -1,3,4 },{ 0,3,0 },{ 1,3,5 },{ 2,3,6 },{ 3,3,7 } }, + }, + /* entry for 9 quantization points */ + { + /* decd_r codebook */ + { { 0, 4, 14 },{ 1,3,0 },{ 2,3,1 },{ 3,3,2 },{ 4,3,3 },{ 5,3,4 },{ 6,3,5 },{ 7,3,6 },{ 8,4,15 } }, + /* decd_r differential codebook */ + { { -4, 4, 14 },{ -3,3,0 },{ -2,3,1 },{ -1,3,2 },{ 0,3,3 },{ 1,3,4 },{ 2,3,5 },{ 3,3,6 },{ 4,4,15 } }, + }, + /* entry for 11 quantization points */ + { + /* decd_r codebook */ + { { 0, 4, 10 },{ 1, 4, 11 },{ 2,4,12 },{ 3,3,0 },{ 4,3,1 },{ 5,3,2 },{ 6,3,3 },{ 7,3,4 },{ 8,4,13 },{ 9,4,14 },{ 10,4,15 } }, + /* decd_r differential codebook */ + { { -5, 4, 10 },{ -4, 4, 11 },{ -3,4,12 },{ -2,3,0 },{ -1,3,1 },{ 0,3,2 },{ 1,3,3 },{ 2,3,4 },{ 3,4,13 },{ 4,4,14 },{ 5,4,15 } }, + }, +}; + +/* DTX quantization and bitstream constants */ + +const Word16 dtx_pd_real_q_levels[3][3] = { { 7,7,7 },{ 7,7,0 },{ 3,0,0 } }; +const Word16 dtx_pr_real_q_levels[3][3] = { { 9,9,9 },{ 9,7,9 },{ 9,5,7 } }; +const Word16 pr_pr_idx_pairs[3][3][2] = { { { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 1, 3 },{ 0, 0 } } }; +const Word16 pr_pd_idx_pairs[3][3][2] = { { { 1, 1 },{ 2, 2 },{ 3, 3 } },{ { 1, 1 },{ 3, 2 },{ 2, 0 } },{ { 2, 1 },{ 0, 0 },{ 0, 0 } } }; + +const Word16 remix_order_set[1][DIRAC_MAX_ANA_CHANS] = { /* WYZX --> WYXZ... */ + { 0, 1, 3, 2, 4, 5, 6, 7, 8, 9, 10 } +}; + +const Word16 HOA_keep_ind[IVAS_SPAR_MAX_FB_IN_CHAN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15}; +const Word16 HOA_keep_ind_spar[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 8, 9, 10, 10, 10, 10}; +const Word16 HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + + +/*----------------------------------------------------------------------* +* PCA ROM tables +*-----------------------------------------------------------------------*/ + +const Word32 ivas_pca_offset_index1[IVAS_PCA_N1 + 1] = +{ + 0, 1, 9, 61, 163, 359, 685, 1125, 1747, + 2519, 3521, 4713, 6183, 7883, 9809, 12093, 14633, 17575, + 20807, 24343, 28181, 32487, 37121, 42097, 47405, 53057, 59061, + 65421, 72137, 79205, 86625, 94415, 102345, 110629, 119263, 128017, + 137097, 146515, 156043, 165637, 175551, 185515, 195535, 205837, 216183, + 226545, 236911, 247273, 257619, 267921, 277941, 287905, 297819, 307413, + 316941, 326359, 335439, 344193, 352827, 361111, 369041, 376831, 384251, + 391319, 398035, 404395, 410399, 416051, 421359, 426335, 430969, 435275, + 439113, 442649, 445881, 448823, 451363, 453647, 455573, 457273, 458743, + 459935, 460937, 461709, 462331, 462771, 463097, 463293, 463395, 463447, + 463455, 463456 +}; + +const Word16 ivas_pca_offset_index2[2692] = +{ + 0, 1, 0, 1, 7, 8, 0, 1, 7, 19, + 33, 45, 51, 52, 0, 1, 9, 23, 41, 61, + 79, 93, 101, 102, 0, 1, 7, 21, 39, 61, + 85, 111, 135, 157, 175, 189, 195, 196, 0, 1, + 7, 19, 37, 59, 85, 115, 147, 179, 211, 241, + 267, 289, 307, 319, 325, 326, 0, 1, 7, 21, + 41, 65, 95, 127, 163, 201, 239, 277, 313, 345, + 375, 399, 419, 433, 439, 440, 0, 1, 7, 19, + 37, 61, 91, 125, 163, 203, 245, 289, 333, 377, + 419, 459, 497, 531, 561, 585, 603, 615, 621, 622, + 0, 1, 7, 21, 41, 67, 97, 133, 173, 217, + 263, 311, 361, 411, 461, 509, 555, 599, 639, 675, + 705, 731, 751, 765, 771, 772, 0, 1, 7, 19, + 37, 61, 91, 127, 167, 211, 259, 309, 363, 417, + 473, 529, 585, 639, 693, 743, 791, 835, 875, 911, + 941, 965, 983, 995, 1001, 1002, 0, 1, 7, 21, + 41, 67, 99, 135, 177, 223, 273, 327, 383, 443, + 503, 565, 627, 689, 749, 809, 865, 919, 969, 1015, + 1057, 1093, 1125, 1151, 1171, 1185, 1191, 1192, 0, 1, + 7, 19, 37, 61, 91, 127, 169, 215, 265, 319, + 377, 437, 501, 567, 633, 701, 769, 837, 903, 969, + 1033, 1093, 1151, 1205, 1255, 1301, 1343, 1379, 1409, 1433, + 1451, 1463, 1469, 1470, 0, 1, 7, 21, 41, 67, + 99, 137, 179, 227, 279, 335, 395, 459, 525, 595, + 667, 739, 813, 887, 961, 1033, 1105, 1175, 1241, 1305, + 1365, 1421, 1473, 1521, 1563, 1601, 1633, 1659, 1679, 1693, + 1699, 1700, 0, 1, 9, 23, 43, 69, 101, 139, + 183, 231, 285, 343, 405, 471, 541, 613, 689, 765, + 843, 923, 1003, 1083, 1161, 1237, 1313, 1385, 1455, 1521, + 1583, 1641, 1695, 1743, 1787, 1825, 1857, 1883, 1903, 1917, + 1925, 1926, 0, 1, 7, 21, 41, 67, 99, 137, + 179, 227, 281, 339, 401, 467, 537, 611, 687, 767, + 849, 931, 1015, 1099, 1185, 1269, 1353, 1435, 1517, 1597, + 1673, 1747, 1817, 1883, 1945, 2003, 2057, 2105, 2147, 2185, + 2217, 2243, 2263, 2277, 2283, 2284, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 285, 345, 409, 477, + 549, 625, 705, 787, 871, 957, 1045, 1135, 1225, 1315, + 1405, 1495, 1583, 1669, 1753, 1835, 1915, 1991, 2063, 2131, + 2195, 2255, 2309, 2359, 2403, 2441, 2473, 2499, 2519, 2533, + 2539, 2540, 0, 1, 7, 19, 39, 65, 97, 135, + 177, 225, 279, 337, 401, 469, 541, 617, 697, 781, + 867, 955, 1045, 1137, 1231, 1327, 1423, 1519, 1615, 1711, + 1805, 1897, 1987, 2075, 2161, 2245, 2325, 2401, 2473, 2541, + 2605, 2663, 2717, 2765, 2807, 2845, 2877, 2903, 2923, 2935, + 2941, 2942, 0, 1, 7, 21, 41, 67, 99, 137, + 181, 229, 283, 343, 407, 477, 551, 629, 711, 797, + 885, 977, 1071, 1167, 1265, 1365, 1465, 1565, 1667, 1767, + 1867, 1967, 2065, 2161, 2255, 2347, 2435, 2521, 2603, 2681, + 2755, 2825, 2889, 2949, 3003, 3051, 3095, 3133, 3165, 3191, + 3211, 3225, 3231, 3232, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 347, 413, 483, 559, 639, + 723, 811, 903, 997, 1093, 1193, 1295, 1399, 1503, 1609, + 1715, 1821, 1927, 2033, 2137, 2241, 2343, 2443, 2539, 2633, + 2725, 2813, 2897, 2977, 3053, 3123, 3189, 3249, 3305, 3355, + 3399, 3437, 3469, 3495, 3515, 3529, 3535, 3536, 0, 1, + 7, 21, 41, 67, 99, 137, 181, 231, 287, 349, + 415, 487, 563, 645, 731, 821, 915, 1011, 1111, 1213, + 1317, 1423, 1531, 1641, 1751, 1863, 1975, 2087, 2197, 2307, + 2415, 2521, 2625, 2727, 2827, 2923, 3017, 3107, 3193, 3275, + 3351, 3423, 3489, 3551, 3607, 3657, 3701, 3739, 3771, 3797, + 3817, 3831, 3837, 3838, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 285, 345, 411, 481, 557, 637, + 721, 809, 901, 997, 1097, 1199, 1305, 1413, 1523, 1635, + 1749, 1863, 1979, 2095, 2211, 2327, 2443, 2557, 2671, 2783, + 2893, 3001, 3107, 3209, 3309, 3405, 3497, 3585, 3669, 3749, + 3825, 3895, 3961, 4021, 4075, 4125, 4169, 4207, 4239, 4265, + 4285, 4299, 4305, 4306, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 347, 413, 485, 561, 643, + 729, 819, 913, 1011, 1113, 1217, 1325, 1435, 1547, 1663, + 1779, 1897, 2017, 2137, 2257, 2377, 2497, 2617, 2737, 2855, + 2971, 3087, 3199, 3309, 3417, 3521, 3623, 3721, 3815, 3905, + 3991, 4073, 4149, 4221, 4287, 4347, 4403, 4453, 4497, 4535, + 4567, 4593, 4613, 4627, 4633, 4634, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 415, 487, + 565, 647, 733, 825, 921, 1021, 1125, 1231, 1341, 1453, + 1569, 1687, 1807, 1929, 2051, 2175, 2299, 2425, 2551, 2677, + 2801, 2925, 3047, 3169, 3289, 3407, 3523, 3635, 3745, 3851, + 3955, 4055, 4151, 4243, 4329, 4411, 4489, 4561, 4627, 4689, + 4745, 4795, 4839, 4877, 4909, 4935, 4955, 4969, 4975, 4976, + 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, + 287, 349, 417, 489, 567, 649, 737, 829, 925, 1025, + 1129, 1237, 1349, 1463, 1581, 1701, 1823, 1947, 2073, 2201, + 2329, 2459, 2589, 2719, 2849, 2979, 3107, 3235, 3361, 3485, + 3607, 3727, 3845, 3959, 4071, 4179, 4283, 4383, 4479, 4571, + 4659, 4741, 4819, 4891, 4959, 5021, 5077, 5127, 5171, 5209, + 5241, 5267, 5287, 5301, 5307, 5308, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 417, 489, + 567, 651, 739, 831, 929, 1031, 1137, 1247, 1361, 1477, + 1597, 1719, 1843, 1969, 2097, 2227, 2359, 2491, 2625, 2759, + 2893, 3027, 3161, 3293, 3425, 3555, 3683, 3809, 3933, 4055, + 4175, 4291, 4405, 4515, 4621, 4723, 4821, 4913, 5001, 5085, + 5163, 5235, 5303, 5365, 5421, 5471, 5515, 5553, 5585, 5611, + 5631, 5645, 5651, 5652, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 569, 653, + 741, 835, 933, 1035, 1141, 1251, 1365, 1483, 1603, 1727, + 1853, 1983, 2115, 2249, 2383, 2519, 2657, 2795, 2933, 3071, + 3209, 3347, 3485, 3621, 3755, 3889, 4021, 4151, 4277, 4401, + 4521, 4639, 4753, 4863, 4969, 5071, 5169, 5263, 5351, 5435, + 5513, 5587, 5655, 5717, 5773, 5823, 5867, 5905, 5937, 5963, + 5983, 5997, 6003, 6004, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 569, 653, + 741, 835, 933, 1037, 1145, 1257, 1373, 1491, 1613, 1739, + 1867, 1997, 2131, 2267, 2405, 2543, 2683, 2825, 2967, 3109, + 3251, 3393, 3535, 3677, 3817, 3955, 4093, 4229, 4363, 4493, + 4621, 4747, 4869, 4987, 5103, 5215, 5323, 5427, 5525, 5619, + 5707, 5791, 5869, 5943, 6011, 6073, 6129, 6179, 6223, 6261, + 6293, 6319, 6339, 6353, 6359, 6360, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, + 569, 653, 743, 837, 935, 1039, 1147, 1259, 1375, 1495, + 1619, 1745, 1875, 2007, 2143, 2281, 2421, 2563, 2705, 2849, + 2993, 3139, 3285, 3431, 3577, 3723, 3867, 4011, 4153, 4295, + 4435, 4573, 4709, 4841, 4971, 5097, 5221, 5341, 5457, 5569, + 5677, 5781, 5879, 5973, 6063, 6147, 6225, 6299, 6367, 6429, + 6485, 6535, 6579, 6617, 6649, 6675, 6695, 6709, 6715, 6716, + 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, + 287, 349, 417, 491, 569, 653, 743, 837, 937, 1041, + 1149, 1261, 1377, 1497, 1621, 1749, 1879, 2013, 2149, 2287, + 2429, 2573, 2717, 2863, 3011, 3159, 3309, 3459, 3609, 3759, + 3909, 4057, 4205, 4351, 4495, 4639, 4781, 4919, 5055, 5189, + 5319, 5447, 5571, 5691, 5807, 5919, 6027, 6131, 6231, 6325, + 6415, 6499, 6577, 6651, 6719, 6781, 6837, 6887, 6931, 6969, + 7001, 7027, 7047, 7061, 7067, 7068, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, + 569, 653, 743, 837, 937, 1041, 1149, 1261, 1377, 1497, + 1621, 1749, 1881, 2015, 2153, 2293, 2435, 2579, 2725, 2873, + 3023, 3175, 3327, 3479, 3633, 3787, 3941, 4093, 4245, 4397, + 4547, 4695, 4841, 4985, 5127, 5267, 5405, 5539, 5671, 5799, + 5923, 6043, 6159, 6271, 6379, 6483, 6583, 6677, 6767, 6851, + 6929, 7003, 7071, 7133, 7189, 7239, 7283, 7321, 7353, 7379, + 7399, 7413, 7419, 7420, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 489, 567, 651, + 741, 835, 935, 1039, 1147, 1259, 1377, 1499, 1625, 1753, + 1885, 2021, 2159, 2301, 2445, 2591, 2739, 2889, 3041, 3195, + 3349, 3505, 3661, 3817, 3973, 4129, 4285, 4441, 4595, 4749, + 4901, 5051, 5199, 5345, 5489, 5631, 5769, 5905, 6037, 6165, + 6291, 6413, 6531, 6643, 6751, 6855, 6955, 7049, 7139, 7223, + 7301, 7373, 7441, 7503, 7559, 7609, 7653, 7691, 7723, 7749, + 7769, 7783, 7789, 7790, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, + 747, 843, 945, 1051, 1161, 1277, 1397, 1521, 1649, 1781, + 1915, 2053, 2195, 2339, 2485, 2635, 2787, 2941, 3095, 3251, + 3409, 3567, 3725, 3885, 4045, 4205, 4363, 4521, 4679, 4835, + 4989, 5143, 5295, 5445, 5591, 5735, 5877, 6015, 6149, 6281, + 6409, 6533, 6653, 6769, 6879, 6985, 7087, 7183, 7273, 7359, + 7439, 7513, 7581, 7643, 7699, 7749, 7793, 7831, 7863, 7889, + 7909, 7923, 7929, 7930, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, + 747, 843, 943, 1049, 1159, 1273, 1393, 1517, 1645, 1777, + 1913, 2051, 2193, 2337, 2485, 2635, 2787, 2941, 3097, 3255, + 3415, 3575, 3737, 3899, 4061, 4223, 4385, 4547, 4709, 4869, + 5029, 5187, 5343, 5497, 5649, 5799, 5947, 6091, 6233, 6371, + 6507, 6639, 6767, 6891, 7011, 7125, 7235, 7341, 7441, 7537, + 7627, 7713, 7793, 7867, 7935, 7997, 8053, 8103, 8147, 8185, + 8217, 8243, 8263, 8277, 8283, 8284, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, + 571, 655, 745, 841, 941, 1047, 1157, 1271, 1389, 1513, + 1641, 1773, 1907, 2045, 2187, 2331, 2479, 2629, 2783, 2939, + 3097, 3257, 3417, 3579, 3743, 3907, 4071, 4235, 4399, 4563, + 4727, 4891, 5055, 5217, 5377, 5537, 5695, 5851, 6005, 6155, + 6303, 6447, 6589, 6727, 6861, 6993, 7121, 7245, 7363, 7477, + 7587, 7693, 7793, 7889, 7979, 8063, 8143, 8217, 8285, 8347, + 8403, 8453, 8497, 8535, 8567, 8593, 8613, 8627, 8633, 8634, + 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, + 287, 349, 417, 491, 571, 657, 749, 845, 947, 1053, + 1165, 1281, 1401, 1527, 1657, 1791, 1929, 2069, 2213, 2361, + 2511, 2663, 2819, 2977, 3137, 3299, 3463, 3627, 3793, 3959, + 4125, 4293, 4461, 4629, 4795, 4961, 5127, 5291, 5455, 5617, + 5777, 5935, 6091, 6243, 6393, 6541, 6685, 6825, 6963, 7097, + 7227, 7353, 7473, 7589, 7701, 7807, 7909, 8005, 8097, 8183, + 8263, 8337, 8405, 8467, 8523, 8573, 8617, 8655, 8687, 8713, + 8733, 8747, 8753, 8754, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, + 747, 843, 943, 1049, 1159, 1275, 1395, 1519, 1647, 1779, + 1915, 2055, 2199, 2345, 2495, 2647, 2803, 2961, 3121, 3283, + 3447, 3613, 3779, 3947, 4115, 4285, 4455, 4625, 4795, 4965, + 5133, 5301, 5467, 5633, 5797, 5959, 6119, 6277, 6433, 6585, + 6735, 6881, 7025, 7165, 7301, 7433, 7561, 7685, 7805, 7921, + 8031, 8137, 8237, 8333, 8423, 8509, 8589, 8663, 8731, 8793, + 8849, 8899, 8943, 8981, 9013, 9039, 9059, 9073, 9079, 9080, + 0, 1, 7, 19, 39, 65, 97, 135, 179, 229, + 285, 347, 415, 489, 567, 651, 741, 835, 935, 1041, + 1151, 1265, 1385, 1509, 1637, 1769, 1905, 2045, 2189, 2335, + 2485, 2637, 2793, 2951, 3111, 3273, 3437, 3603, 3771, 3939, + 4109, 4279, 4451, 4623, 4795, 4967, 5139, 5309, 5479, 5647, + 5815, 5981, 6145, 6307, 6467, 6625, 6781, 6933, 7083, 7229, + 7373, 7513, 7649, 7781, 7909, 8033, 8153, 8267, 8377, 8483, + 8583, 8677, 8767, 8851, 8929, 9003, 9071, 9133, 9189, 9239, + 9283, 9321, 9353, 9379, 9399, 9411, 9417, 9418, 0, 1, + 7, 21, 41, 67, 99, 137, 181, 231, 287, 349, + 417, 491, 571, 657, 747, 843, 945, 1051, 1163, 1279, + 1399, 1525, 1655, 1789, 1927, 2069, 2213, 2361, 2513, 2667, + 2825, 2985, 3147, 3311, 3477, 3645, 3815, 3985, 4157, 4329, + 4503, 4677, 4851, 5025, 5199, 5371, 5543, 5713, 5883, 6051, + 6217, 6381, 6543, 6703, 6861, 7015, 7167, 7315, 7459, 7601, + 7739, 7873, 8003, 8129, 8249, 8365, 8477, 8583, 8685, 8781, + 8871, 8957, 9037, 9111, 9179, 9241, 9297, 9347, 9391, 9429, + 9461, 9487, 9507, 9521, 9527, 9528, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, + 571, 657, 749, 845, 947, 1055, 1167, 1285, 1407, 1533, + 1663, 1797, 1935, 2077, 2223, 2373, 2525, 2681, 2839, 3001, + 3165, 3331, 3499, 3669, 3839, 4011, 4185, 4359, 4533, 4709, + 4885, 5061, 5235, 5409, 5583, 5755, 5925, 6095, 6263, 6429, + 6593, 6755, 6913, 7069, 7221, 7371, 7517, 7659, 7797, 7931, + 8061, 8187, 8309, 8427, 8539, 8647, 8749, 8845, 8937, 9023, + 9103, 9177, 9245, 9307, 9363, 9413, 9457, 9495, 9527, 9553, + 9573, 9587, 9593, 9594, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 571, 655, + 745, 841, 941, 1047, 1157, 1273, 1393, 1517, 1647, 1781, + 1919, 2061, 2207, 2355, 2507, 2663, 2821, 2981, 3145, 3311, + 3479, 3649, 3821, 3993, 4167, 4341, 4517, 4693, 4869, 5045, + 5221, 5397, 5573, 5747, 5921, 6093, 6265, 6435, 6603, 6769, + 6933, 7093, 7251, 7407, 7559, 7707, 7853, 7995, 8133, 8267, + 8397, 8521, 8641, 8757, 8867, 8973, 9073, 9169, 9259, 9343, + 9423, 9497, 9565, 9627, 9683, 9733, 9777, 9815, 9847, 9873, + 9893, 9907, 9913, 9914, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, + 747, 843, 945, 1051, 1163, 1279, 1401, 1527, 1657, 1791, + 1929, 2071, 2217, 2367, 2519, 2675, 2835, 2997, 3161, 3327, + 3495, 3665, 3837, 4011, 4185, 4361, 4537, 4715, 4893, 5071, + 5249, 5427, 5603, 5779, 5953, 6127, 6299, 6469, 6637, 6803, + 6967, 7129, 7289, 7445, 7597, 7747, 7893, 8035, 8173, 8307, + 8437, 8563, 8685, 8801, 8913, 9019, 9121, 9217, 9307, 9393, + 9473, 9547, 9615, 9677, 9733, 9783, 9827, 9865, 9897, 9923, + 9943, 9957, 9963, 9964, 0, 1, 7, 21, 41, 67, + 99, 137, 181, 231, 287, 349, 417, 491, 571, 657, + 749, 845, 947, 1055, 1167, 1285, 1407, 1533, 1663, 1799, + 1939, 2083, 2229, 2379, 2533, 2689, 2849, 3011, 3177, 3345, + 3515, 3687, 3861, 4035, 4211, 4387, 4565, 4743, 4921, 5099, + 5277, 5455, 5633, 5809, 5985, 6159, 6333, 6505, 6675, 6843, + 7009, 7171, 7331, 7487, 7641, 7791, 7937, 8081, 8221, 8357, + 8487, 8613, 8735, 8853, 8965, 9073, 9175, 9271, 9363, 9449, + 9529, 9603, 9671, 9733, 9789, 9839, 9883, 9921, 9953, 9979, + 9999, 10013, 10019, 10020, 0, 1, 7, 19, 39, 65, + 97, 135, 179, 229, 285, 347, 415, 489, 567, 651, + 741, 837, 937, 1043, 1153, 1269, 1389, 1513, 1643, 1777, + 1915, 2057, 2203, 2351, 2503, 2659, 2817, 2979, 3143, 3309, + 3477, 3647, 3819, 3993, 4169, 4345, 4523, 4701, 4881, 5061, + 5241, 5421, 5601, 5779, 5957, 6133, 6309, 6483, 6655, 6825, + 6993, 7159, 7323, 7485, 7643, 7799, 7951, 8099, 8245, 8387, + 8525, 8659, 8789, 8913, 9033, 9149, 9259, 9365, 9465, 9561, + 9651, 9735, 9813, 9887, 9955, 10017, 10073, 10123, 10167, 10205, + 10237, 10263, 10283, 10295, 10301, 10302, 0, 1, 7, 21, + 41, 67, 99, 137, 181, 231, 287, 349, 417, 491, + 571, 655, 745, 841, 941, 1047, 1159, 1275, 1395, 1521, + 1651, 1785, 1923, 2065, 2211, 2361, 2513, 2669, 2829, 2991, + 3155, 3321, 3491, 3663, 3837, 4011, 4187, 4365, 4543, 4723, + 4903, 5083, 5263, 5443, 5623, 5803, 5981, 6159, 6335, 6509, + 6683, 6855, 7025, 7191, 7355, 7517, 7677, 7833, 7985, 8135, + 8281, 8423, 8561, 8695, 8825, 8951, 9071, 9187, 9299, 9405, + 9505, 9601, 9691, 9775, 9855, 9929, 9997, 10059, 10115, 10165, + 10209, 10247, 10279, 10305, 10325, 10339, 10345, 10346, 0, 1, + 7, 21, 41, 67, 99, 137, 181, 231, 287, 349, + 417, 491, 571, 655, 745, 841, 943, 1049, 1161, 1277, + 1397, 1523, 1653, 1787, 1925, 2067, 2213, 2363, 2517, 2673, + 2833, 2995, 3159, 3327, 3497, 3669, 3843, 4019, 4195, 4373, + 4551, 4731, 4911, 5091, 5271, 5451, 5631, 5811, 5989, 6167, + 6343, 6519, 6693, 6865, 7035, 7203, 7367, 7529, 7689, 7845, + 7999, 8149, 8295, 8437, 8575, 8709, 8839, 8965, 9085, 9201, + 9313, 9419, 9521, 9617, 9707, 9791, 9871, 9945, 10013, 10075, + 10131, 10181, 10225, 10263, 10295, 10321, 10341, 10355, 10361, 10362, + 0, 1, 7, 21, 41, 67, 99, 137, 181, 231, + 287, 349, 417, 491, 571, 657, 747, 843, 945, 1051, + 1163, 1279, 1399, 1525, 1655, 1789, 1927, 2069, 2215, 2365, + 2519, 2675, 2835, 2997, 3161, 3329, 3499, 3671, 3845, 4021, + 4197, 4375, 4553, 4733, 4913, 5093, 5273, 5453, 5633, 5813, + 5991, 6169, 6345, 6521, 6695, 6867, 7037, 7205, 7369, 7531, + 7691, 7847, 8001, 8151, 8297, 8439, 8577, 8711, 8841, 8967, + 9087, 9203, 9315, 9421, 9523, 9619, 9709, 9795, 9875, 9949, + 10017, 10079, 10135, 10185, 10229, 10267, 10299, 10325, 10345, 10359, + 10365, 10366 +}; + +const Word16 ivas_pca_offset_n2[IVAS_PCA_N1] = +{ + 0, 2, 6, 14, 24, 38, 56, 76, 100, 126, 156, 188, + 224, 262, 302, 346, 392, 442, 494, 548, 604, 664, 726, 790, + 856, 924, 994, 1066, 1140, 1216, 1294, 1374, 1454, 1536, 1620, 1704, + 1790, 1878, 1966, 2054, 2144, 2234, 2324, 2416, 2508, 2600, 2692, 2784, + 2876, 2968, 3058, 3148, 3238, 3326, 3414, 3502, 3588, 3672, 3756, 3838, + 3918, 3998, 4076, 4152, 4226, 4298, 4368, 4436, 4502, 4566, 4628, 4688, + 4744, 4798, 4850, 4900, 4946, 4990, 5030, 5068, 5104, 5136, 5166, 5192, + 5216, 5236, 5254, 5268, 5278, 5286, 5290 +}; + +const Word16 ph1_q_n2_tbl[IVAS_PCA_N1][2] = { /* ph1_q : Q13, n2 : Q0 */ + { 0, 1 }, + { 286, 3 }, + { 572, 7 }, + { 858, 9 }, + { 1144, 13 }, + { 1430, 17 }, + { 1716, 19 }, + { 2002, 23 }, + { 2288, 25 }, + { 2574, 29 }, + { 2860, 31 }, + { 3146, 35 }, + { 3431, 37 }, + { 3717, 39 }, + { 4003, 43 }, + { 4289, 45 }, + { 4575, 49 }, + { 4861, 51 }, + { 5147, 53 }, + { 5433, 55 }, + { 5719, 59 }, + { 6005, 61 }, + { 6291, 63 }, + { 6577, 65 }, + { 6863, 67 }, + { 7149, 69 }, + { 7435, 71 }, + { 7721, 73 }, + { 8007, 75 }, + { 8293, 77 }, + { 8579, 79 }, + { 8865, 79 }, + { 9151, 81 }, + { 9437, 83 }, + { 9722, 83 }, + { 10008, 85 }, + { 10294, 87 }, + { 10580, 87 }, + { 10866, 87 }, + { 11152, 89 }, + { 11438, 89 }, + { 11724, 89 }, + { 12010, 91 }, + { 12296, 91 }, + { 12582, 91 }, + { 12868, 91 }, + { 13154, 91 }, + { 13440, 91 }, + { 13726, 91 }, + { 14012, 89 }, + { 14298, 89 }, + { 14584, 89 }, + { 14870, 87 }, + { 15156, 87 }, + { 15442, 87 }, + { 15728, 85 }, + { 16013, 83 }, + { 16299, 83 }, + { 16585, 81 }, + { 16871, 79 }, + { 17157, 79 }, + { 17443, 77 }, + { 17729, 75 }, + { 18015, 73 }, + { 18301, 71 }, + { 18587, 69 }, + { 18873, 67 }, + { 19159, 65 }, + { 19445, 63 }, + { 19731, 61 }, + { 20017, 59 }, + { 20303, 55 }, + { 20589, 53 }, + { 20875, 51 }, + { 21161, 49 }, + { 21447, 45 }, + { 21733, 43 }, + { 22019, 39 }, + { 22304, 37 }, + { 22590, 35 }, + { 22876, 31 }, + { 23162, 29 }, + { 23448, 25 }, + { 23734, 23 }, + { 24020, 19 }, + { 24306, 17 }, + { 24592, 13 }, + { 24878, 9 }, + { 25164, 7 }, + { 25450, 3 }, + { 25736, 1 } +}; + + +/*----------------------------------------------------------------------------------* + * Parametric MC ROM tables + *----------------------------------------------------------------------------------*/ + +const Word16 param_mc_band_grouping_20[20 + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 17, 20, 23, 27, 33, 40, 52, 60 +}; + +const Word16 param_mc_coding_band_mapping_20[20] = +{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +const Word16 param_mc_bands_coded_20[4] = +{ + 10, 14, 18, 20 +}; + +const Word16 param_mc_band_grouping_14[14 + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 28, 40, 60 +}; + +const Word16 param_mc_coding_band_mapping_14[14] = +{ + 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 +}; + +const Word16 param_mc_bands_coded_14[4] = +{ + 8, 11, 13, 14 +}; + +const Word16 param_mc_band_grouping_10[10 + 1] = +{ + 0, 1, 2, 3, 5, 7, 10, 14, 20, 40, 60 +}; + + +const Word16 param_mc_bands_coded_10[4] = +{ + 6, 8, 9, 10 +}; + +const Word16 param_mc_coding_band_mapping_10[10] = +{ + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 +}; + +const Word16 Param_MC_index[MAX_CICP_CHANNELS] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 +}; + + +const Word32 ivas_param_mc_dmx_fac_CICP6_2tc_fx[12] = +{ + 2147483647,0,1518500224,1518500224,2147483647,0, /*Lt*/ + 0,2147483647,1518500224,1518500224,0,2147483647 /*Rt*/ +}; + +const Word32 ivas_param_mc_dmx_fac_CICP12_2tc_fx[16] = +{ + 2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0, /*Lt*/ + 0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647 /*Rt*/ +}; + +const Word32 ivas_param_mc_dmx_fac_CICP12_3tc_fx[24] = +{ + 2147483647,0,0,0,2147483647,0,2147483647,0, /*Lt*/ + 0,2147483647,0,0,0,2147483647,0,2147483647, /*Rt*/ + 0,0,2147483647,2147483647,0,0,0,0 /*Ct*/ +}; + +const Word32 ivas_param_mc_dmx_fac_CICP14_2tc_fx[16] = +{ + 2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0, /*Lt*/ + 0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647 /*Rt*/ +}; +const Word32 ivas_param_mc_dmx_fac_CICP14_3tc_fx[24] = +{ + 2147483647,0,0,0,2147483647,0,2147483647,0, /*Lt*/ + 0,2147483647,0,0,0,2147483647,0,2147483647, /*Rt*/ + 0,0,2147483647,2147483647,0,0,0,0 /*Ct*/ +}; + +const Word32 ivas_param_mc_dmx_fac_CICP16_3tc_fx[30] = +{ + 2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0, /*Lt*/ + 0,2147483647,0,0,0,2147483647,0,2147483647,0,2147483647, /*Rt*/ + 0,0,2147483647,2147483647,0,0,0,0,0,0 /*Ct*/ +}; + +const Word32 ivas_param_mc_dmx_fac_CICP19_3tc_fx[36] = +{ + 2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0,2147483647,0, /*Lt*/ + 0,2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0,2147483647, /*Rt*/ + 0,0,2147483647,2147483647,0,0,0,0,0,0,0,0 /*Ct*/ +}; + +const Word32 ivas_param_mc_dmx_fac_CICP19_4tc_fx[48] = +{ + 2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0,0,0,0,0, /*Lht*/ + 0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647,0,0,0,0, /*Rht*/ + 0,0,0,0,0,0,0,0,2147483647,0,2147483647,0, /*Lut*/ + 0,0,0,0,0,0,0,0,0,2147483647,0,2147483647 /*Rut*/ +}; + + +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP6_2tc_fx[6] = +{ + 12832, + 12832, + 6820, + 10607, + 10607, + 6820 +}; + +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP12_2tc_fx[8] = +{ + 11965, + 11965, + 6816, + 6877, + 6877, + 5619, + 5619, + 6816 +}; + +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP12_3tc_fx[8] = +{ + 16384, + 16384, + 9502, + 9502, + 6553, + 6553, + 32767, + 8192 +}; +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP14_2tc_fx[8] = +{ + 11936, + 11936, + 5993, + 6945, + 6945, + 8049, + 8049, + 6816 +}; + +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP14_3tc_fx[8] = +{ + 16291, + 16291, + 8257, + 8257, + 9666, + 9666, + 32767, + 8192 +}; + +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP16_3tc_fx[10] = +{ + 11141, + 11141, + 7209, + 7209, + 6553, + 6553, + 5898, + 5898, + 32767, + 8192 +}; + +//Q15 +const Word16 ivas_param_mc_ild_fac_CICP19_3tc_fx[12] = +{ + 9830, + 9830, + 5570, + 5570, + 3932, + 3932, + 6226, + 6226, + 6226, + 6226, + 32767, + 16384 +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP6_2tc = +{ + 5, + 6, + {0,1,2,4,5,3}, + {1,1,2,1,1,2}, + {{0},{1},{0,1},{0},{1},{0,1}} +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP12_2tc = +{ + 7, + 8, + {0,1,2,4,5,6,7,3}, + {1,1,2,1,1,1,1,2}, + {{0},{1},{0,1},{0},{1},{0},{1},{0,1}} +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP12_3tc = +{ + 6, + 8, + {0,1,4,5,6,7,2,3}, + {1,1,1,1,1,1,1,1}, + {{0},{1},{0},{1},{0},{1},{2},{2}} +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP14_2tc = +{ + 7, + 8, + {0,1,2,4,5,6,7,3}, + {1,1,2,1,1,1,1,2}, + {{0},{1},{0,1},{0},{1},{0},{1},{0,1}} +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP14_3tc = +{ + 6, + 8, + {0,1,4,5,6,7,2,3}, + {1,1,1,1,1,1,1,1}, + {{0},{1},{0},{1},{0},{1},{2},{2}} +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP16_3tc = +{ + 8, + 10, + {0,1,4,5,6,7,8,9,2,3}, + {1,1,1,1,1,1,1,1,1,1}, + {{0},{1},{0},{1},{0},{1},{0},{1},{2},{2}} +}; + +const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP19_3tc = +{ + 10, + 12, + {0,1,4,5,6,7,8,9,10,11,2,3}, + {1,1,1,1,1,1,1,1,1,1,1,1}, + {{0},{1},{0},{1},{0},{1},{0},{1},{0},{1},{2},{2}} +}; + +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP6_2tc = +{ + 4, + 5, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 2, 3 }} /* C/LFE */ +}; + +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP12_2tc = +{ + 6, + 7, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 2, 6 }, /* C/BLS */ + { 2, 7 }, /* C/BRS */ + { 2, 3 } /* C/LFE */ + } +}; + +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP12_3tc = +{ + 6, + 7, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 0, 6 }, /* L/BLS */ + { 1, 7 }, /* R/BRS */ + { 2, 3 } /* C/LFE */ + } +}; + +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP14_2tc = +{ + 6, + 7, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 2, 6 }, /* C/UFL */ + { 2, 7 }, /* C/UFR */ + { 2, 3 } /* C/LFE */ + } +}; +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP14_3tc = +{ + 6, + 7, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 0, 6 }, /* L/UFL */ + { 1, 7 }, /* R/UFR */ + { 2, 3 } /* C/LFE */ + } +}; + +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP16_3tc = +{ + 8, + 9, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 0, 6 }, /* L/UFL */ + { 1, 7 }, /* R/UFR */ + { 4, 8 }, /* LS/UBL */ + { 5, 9 }, /* RS/UBR */ + { 2, 3 } /* C/LFE */ + } +}; + +const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP19_3tc = +{ + 10, + 11, + { { 0, 4 }, /* L/LS */ + { 1, 5 }, /* R/RS */ + { 0, 2 }, /* L/C */ + { 1, 2 }, /* R/C */ + { 0, 6 }, /* L/LBS */ + { 1, 7 }, /* R/RBS */ + { 0, 8 }, /* L/UFL */ + { 1, 9 }, /* R/UFR */ + { 6, 10 }, /* LBS/UBL */ + { 7, 11 }, /* RBS/UBR */ + { 2, 3 } /* C/LFE */ + } +}; + +const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = +{ + /* CICP6 48000 */ + { + MC_LS_SETUP_5_1, + 6, + 2, + IVAS_48k, + &ivas_param_mc_ild_mapping_CICP6_2tc, + &ivas_param_mc_icc_mapping_CICP6_2tc, + &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] + }, + /* CICP6 64000 */ + { + MC_LS_SETUP_5_1, + 6, + 2, + IVAS_64k, + &ivas_param_mc_ild_mapping_CICP6_2tc, + &ivas_param_mc_icc_mapping_CICP6_2tc, + &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], + & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] + }, + /* CICP6 80000 */ + { + MC_LS_SETUP_5_1, + 6, + 2, + IVAS_80k, + &ivas_param_mc_ild_mapping_CICP6_2tc, + &ivas_param_mc_icc_mapping_CICP6_2tc, + &ivas_param_mc_ild_fac_CICP6_2tc_fx[0], + & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0] + }, + /* CICP12 48000 */ + { + MC_LS_SETUP_7_1, + 8, + 2, + IVAS_48k, + &ivas_param_mc_ild_mapping_CICP12_2tc, + &ivas_param_mc_icc_mapping_CICP12_2tc, + &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0] + }, + /* CICP12 64000 */ + { + MC_LS_SETUP_7_1, + 8, + 2, + IVAS_64k, + &ivas_param_mc_ild_mapping_CICP12_2tc, + &ivas_param_mc_icc_mapping_CICP12_2tc, + &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0] + }, + /* CICP12 80000 */ + { + MC_LS_SETUP_7_1, + 8, + 2, + IVAS_80k, + &ivas_param_mc_ild_mapping_CICP12_2tc, + &ivas_param_mc_icc_mapping_CICP12_2tc, + &ivas_param_mc_ild_fac_CICP12_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0], + }, + /* CICP12 96000 */ + { + MC_LS_SETUP_7_1, + 8, + 3, + IVAS_96k, + &ivas_param_mc_ild_mapping_CICP12_3tc, + &ivas_param_mc_icc_mapping_CICP12_3tc, + &ivas_param_mc_ild_fac_CICP12_3tc_fx[0], + &ivas_param_mc_dmx_fac_CICP12_3tc_fx[0] + }, + /* CICP14 48000 */ + { + MC_LS_SETUP_5_1_2, + 8, + 2, + IVAS_48k, + &ivas_param_mc_ild_mapping_CICP14_2tc, + &ivas_param_mc_icc_mapping_CICP14_2tc, + &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] + }, + /* CICP14 64000 */ + { + MC_LS_SETUP_5_1_2, + 8, + 2, + IVAS_64k, + &ivas_param_mc_ild_mapping_CICP14_2tc, + &ivas_param_mc_icc_mapping_CICP14_2tc, + &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] + }, + /* CICP14 80000 */ + { + MC_LS_SETUP_5_1_2, + 8, + 2, + IVAS_80k, + &ivas_param_mc_ild_mapping_CICP14_2tc, + &ivas_param_mc_icc_mapping_CICP14_2tc, + &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], + &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] + }, + /* CICP14 96000 */ + { + MC_LS_SETUP_5_1_2, + 8, + 3, + IVAS_96k, + &ivas_param_mc_ild_mapping_CICP14_3tc, + &ivas_param_mc_icc_mapping_CICP14_3tc, + &ivas_param_mc_ild_fac_CICP14_3tc_fx[0], + &ivas_param_mc_dmx_fac_CICP14_3tc_fx[0] + }, + /* CICP16 96000 */ + { + MC_LS_SETUP_5_1_4, + 10, + 3, + IVAS_96k, + &ivas_param_mc_ild_mapping_CICP16_3tc, + &ivas_param_mc_icc_mapping_CICP16_3tc, + &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], + &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] + }, + /* CICP16 128000 */ + { + MC_LS_SETUP_5_1_4, + 10, + 3, + IVAS_128k, + &ivas_param_mc_ild_mapping_CICP16_3tc, + &ivas_param_mc_icc_mapping_CICP16_3tc, + &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], + &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] + }, + /* CICP19 128000 */ + { + MC_LS_SETUP_7_1_4, + 12, + 3, + IVAS_128k, + &ivas_param_mc_ild_mapping_CICP19_3tc, + &ivas_param_mc_icc_mapping_CICP19_3tc, + &ivas_param_mc_ild_fac_CICP19_3tc_fx[0], + &ivas_param_mc_dmx_fac_CICP19_3tc_fx[0] + } +}; + + +/* Alphabet for delta coding for the ICCs in Parametric MC processing */ +const UWord16 ivas_param_mc_cum_freq_icc_cicp6_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = +{ + 0, 24, 224, 20873, 42384, 51699, 57122, 60572, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_cicp6_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 24, 200, 20649, 21511, 9315, 5423, 3450, 4963 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 0, 4, 9, 124, 447, 1311, 4453, 18116, 48636, 60573, 63692, 64746, 65327, 65531, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1] = +{ + 4, 5, 115, 323, 864, 3142, 13663, 30520, 11937, 3119, 1054, 581, 204, 3, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_cicp12_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = +{ + 0, 30, 848, 26611, 47846, 57358, 61679, 63237, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_cicp12_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 30, 818, 25763, 21235, 9512, 4321, 1558, 2298 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 0, 2, 7, 53, 243, 979, 3994, 16732, 49642, 61343, 64331, 65158, 65438, 65532, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1] = +{ + 2, 5, 46, 190, 736, 3015, 12738, 32910, 11701, 2988, 827, 280, 94, 2, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_cicp14_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = +{ + 0, 46, 826, 27798, 49552, 58447, 62046, 63284, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_cicp14_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER ]={ + 46, 780, 26972, 21754, 8895, 3599, 1238, 2251 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_delta_cicp14_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 0, 3, 8, 36, 172, 763, 3436, 15845, 50168, 62005, 64676, 65298, 65481, 65533, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_delta_cicp14_48_16bits[2* PARAM_MC_SZ_ICC_QUANTIZER - 1] = +{ + 3, 5, 28, 136, 591, 2673, 12409, 34323, 11837, 2671, 622, 183, 52, 1, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_combined_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] = +{ + 0, 34, 552, 24717, 45819, 54772, 59054, 61166, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_combined_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 34, 518, 24165, 21102, 8953, 4282, 2112, 4369 +}; + +const UWord16 ivas_param_mc_cum_freq_icc_delta_combined_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER] = +{ + 0, 3, 7, 74, 304, 1009, 3870, 16502, 49834, 61384, 64217, 65020, 65369, 65531, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1] = +{ + 3, 4, 67, 230, 705, 2861, 12632, 33332, 11550, 2833, 803, 349, 162, 3, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_cicp6_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1] = +{ + 0, 1092, 5574, 8315, 10652, 13875, 19656, 27664, 36284, 47058, 56251, 62579, 65118, 65462, 65513, 65532, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_cicp6_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 1092, 4482, 2741, 2337, 3223, 5781, 8008, 8620, 10774, 9193, 6328, 2539, 344, 51, 19, 3 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 0, 1, 2, 3, 5, 38, 146, 352, 638, 997, 1559, 2323, 3570, 5859, 10556, 21075, 44682, 55617, 60408, 62739, 63833, 64443, 64809, 65074, 65279, 65400, 65484, 65531, 65532, 65533, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = +{ + 1, 1, 1, 2, 33, 108, 206, 286, 359, 562, 764, 1247, 2289, 4697, 10519, 23607, 10935, 4791, 2331, 1094, 610, 366, 265, 205, 121, 84, 47, 1, 1, 1, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_cicp12_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1] = +{ + 0, 967, 6335, 9941, 12837, 16652, 22416, 29814, 38807, 48497, 57184, 62661, 64916, 65466, 65514, 65530, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_cicp12_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 967, 5368, 3606, 2896, 3815, 5764, 7398, 8993, 9690, 8687, 5477, 2255, 550, 48, 16, 5 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 0, 1, 2, 3, 5, 18, 61, 149, 320, 592, 1083, 1793, 2974, 5257, 10133, 21274, 44342, 55891, 60895, 63174, 64244, 64793, 65100, 65287, 65406, 65477, 65517, 65531, 65532, 65533, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_delta_cicp12_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = +{ + 1, 1, 1, 2, 13, 43, 88, 171, 272, 491, 710, 1181, 2283, 4876, 11141, 23068, 11549, 5004, 2279, 1070, 549, 307, 187, 119, 71, 40, 14, 1, 1, 1, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_cicp14_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1] = +{ + 0, 229, 7068, 10910, 13856, 17467, 22629, 29174, 36906, 46558, 55579, 61802, 65222, 65505, 65527, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_cicp14_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 229, 6839, 3842, 2946, 3611, 5162, 6545, 7732, 9652, 9021, 6223, 3420, 283, 22, 7, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_delta_cicp14_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 0, 1, 2, 3, 4, 12, 56, 153, 278, 475, 856, 1430, 2489, 4723, 9580, 20685, 45423, 56274, 60948, 63097, 64128, 64679, 65002, 65208, 65348, 65445, 65517, 65531, 65532, 65533, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_delta_cicp14_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = +{ + 1, 1, 1, 1, 8, 44, 97, 125, 197, 381, 574, 1059, 2234, 4857, 11105, 24738, 10851, 4674, 2149, 1031, 551, 323, 206, 140, 97, 72, 14, 1, 1, 1, 1 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_combined_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS+1] = +{ + 0, 1453, 8326, 12221, 15164, 18764, 24177, 31297, 39520, 49154, 57135, 62460, 64821, 65468, 65514, 65530, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_combined_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 1453, 6873, 3895, 2943, 3600, 5413, 7120, 8223, 9634, 7981, 5325, 2361, 647, 46, 16, 5 +}; + +const UWord16 ivas_param_mc_cum_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = +{ + 0, 1, 2, 3, 5, 29, 98, 220, 414, 699, 1186, 1876, 3049, 5304, 10013, 20612, 45247, 56109, 60818, 63022, 64081, 64647, 64977, 65198, 65348, 65443, 65502, 65530, 65532, 65533, 65534, 65535 +}; + +const UWord16 ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS - 1] = +{ + 1, 1, 1, 2, 24, 69, 122, 194, 285, 487, 690, 1173, 2255, 4709, 10599, 24635, 10862, 4709, 2204, 1059, 566, 330, 221, 150, 95, 59, 28, 2, 1, 1, 1 +}; + + +/*----------------------------------------------------------------------------------* + * MASA ROM tables + *----------------------------------------------------------------------------------*/ + +const Word64 diffuseness_reconstructions_hr_fx[HR_MASA_ER_LEVELS] = { /* Q62 */ + 0, + 65865144550293504, + 138485688541642752, + 239816680157478912, + 355502895585558528, + 485544334825881600, + 667940119734386688, + 902690250311073792, + 1225260573621485568, + 1635651089665622016, + 2011983133527769088, + 2354256705207926784, + 2741003323208368128, + 3172222987529093120, + 3693796119373938688, + 4305722718742904832, +}; + +const Word32 diffuseness_thresholds_hr_fx[HR_MASA_ER_LEVELS + 1] = { /* Q30 */ + 0, + 10223616, + 20447232, + 44040192, + 67633152, + 97910784, + 128188416, + 182845440, + 237502464, + 333053952, + 428605440, + 508297216, + 587988992, + 688390144, + 788791296, + 931266560, + MAX_32 /* out-of-range large value to make searching easier */ +}; + +const Word16 bits_direction_masa[DIRAC_DIFFUSE_LEVELS] = +{ + 11, + 11, + 10, + 9, + 7, + 6, + 5, + 3 +}; + + +const Word16 len_cb_dct0_masa[DIRAC_DIFFUSE_LEVELS] = { 7, 6, 5, 4, 4, 4, 3, 2 }; + +const UWord8 sur_coherence_cb_masa[MASA_MAX_NO_CV_SUR_COH*MASA_NO_CB_SUR_COH] = +{ + 16, 99, 0, 0, 0, 0, 0, 0, + 12, 64, 167, 0, 0, 0, 0, 0, + 10, 45, 100, 218, 0, 0, 0, 0, + 8, 34, 70, 124, 235, 0, 0, 0, + 7, 27, 55, 90, 141, 242, 0, 0, + 7, 23, 45, 71, 105, 153, 247, 0, + 6, 20, 38, 60, 86, 119, 165, 249 +}; + +const Word16 idx_cb_sur_coh_masa[MASA_MAX_NO_CV_SUR_COH] = { 0, 1, 2, 3, 4, 5, 5, 6 }; + +const Word16 len_huf_masa[MASA_NO_CV_COH1] = { 4, 2, 1, 3, 4 }; + +const Word16 huff_code_av_masa[MASA_NO_CV_COH1] = { 15, 2, 0, 6, 14 }; + +const Word16 no_theta_masa[NO_SPHERICAL_GRIDS-2] = /* from 1 to 11 bits */ +{ /*1, 1,*/ 2 ,2 , 4, 5, 6, 7, 10, 14, 19 + /*0, 2, 8, 6, 7, 12, 14, 16*/ +}; + +const Word16 no_phi_masa[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = /* from 1 to 11 bits*/ +{ + { 2 }, + { 4 }, + { 4, 2 }, + { 8, 4 }, /* 8, 4*/ + { 12, 7, 2, 1 }, /* 12, */ + { 14, 13, 9, 2, 1 }, + { 22, 21, 17, 11, 3, 1 }, + { 33, 32, 29, 23, 17, 9, 1 }, + { 48, 47, 45, 41, 35, 28, 20, 12, 2, 1 }, + { 60, 60, 58, 56, 54, 50, 46, 41, 36, 30, 23, 17, 10, 1 }, + { 89, 89, 88, 86, 84, 81, 77, 73, 68, 63, 57, 51, 44, 38, 30, 23, 15, 8, 1 } +}; + +const Word16 MASA_band_grouping_24[24 + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30, 40, 60 +}; + +const Word16 MASA_band_mapping_24_to_18[18 + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 17, 20, 21, 22, 23, 24 +}; + +const Word16 MASA_band_mapping_24_to_12[12 + 1] = +{ + 0, 1, 2, 3, 4, 5, 7, 9, 12, 15, 20, 22, 24 +}; + +const Word16 MASA_band_mapping_24_to_8[8 + 1] = +{ + 0, 1, 2, 3, 5, 8, 12, 20, 24 +}; + +const Word16 MASA_band_mapping_24_to_5[5 + 1] = +{ + 0, 1, 3, 7, 15, 24 +}; + +const Word16 MASA_grouping_8_to_5[8] = +{ + 0, 1, 1, 2, 3, 3, 4, 4 +}; + +const Word16 MASA_grouping_12_to_5[12] = +{ + 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4 +}; + +const Word16 MASA_grouping_18_to_5[18] = +{ + 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 +}; + +const Word16 MASA_grouping_24_to_5[24] = +{ + 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4 +}; + +/* IVAS_13k2, IVAS_16k4, IVAS_24k4, IVAS_32k, IVAS_48k, IVAS_64k, IVAS_80k, IVAS_96k, IVAS_128k, IVAS_160k, IVAS_192k, IVAS_256k, IVAS_384k, IVAS_512k */ +const Word16 masa_bits[IVAS_NUM_ACTIVE_BRATES] = +{ + 50, 60, 70, 85, 140, 180, 220, 256, 350, 432, 528, 832, 1024, MASA_MAX_BITS +}; + +const Word16 masa_bits_LR_stereo[4] = +{ + 50, 50, 60, 70 +}; + +const Word16 mcmasa_bits[IVAS_NUM_ACTIVE_BRATES] = +{ + 50, 70, 80, 120, 140, 160, 220, 256, 288, 432, 528, 832, 1024, MASA_MAX_BITS +}; + +const UWord8 masa_nbands[IVAS_NUM_ACTIVE_BRATES] = +{ + 5, 5, 5, 5, 5, 5, 5, 5, 8, 12, 18, 24, 24, 24 +}; + +const UWord8 masa_joined_nbands[IVAS_NUM_ACTIVE_BRATES] = +{ + 5, 5, 5, 8, 12, 12, 12, 18, 18, 18, 18, 24, 24, 24 +}; + +const UWord8 masa_twodir_bands[IVAS_NUM_ACTIVE_BRATES] = +{ + 0, 0, 0, 0, 0, 1, 1, 1, 3, 4, 6, 6, 9, 24 +}; + +const UWord8 masa_twodir_bands_joined[IVAS_NUM_ACTIVE_BRATES] = +{ + 0, 0, 0, 0, 0, 2, 2, 3, 4, 6, 8, 9, 12, MASA_MAXIMUM_TWO_DIR_BANDS +}; + + +/*----------------------------------------------------------------------------------* + * OMASA ROM tables + *----------------------------------------------------------------------------------*/ + +const Word32 sep_object_brate[][MAX_NUM_OBJECTS] = +{ + {0, 0, 0, 0}, /* 13k2 */ + {0, 0, 0, 0}, /* 16k4 */ + {9600, 0, 0, 0}, /* 24k4 */ + {IVAS_13k2, 0, 0, 0}, /* 32k */ + {16000, 11000, 0, 0}, /* 48k */ + {16000, 11700, 0, 0}, /* 64k */ + {20000, 16000, 0, 0}, /* 80k */ + {IVAS_32k, 20000, 20000, 0}, /* 96k */ + {IVAS_32k, IVAS_24k4, 24000, 24000}, /* 128k */ + {IVAS_48k, IVAS_32k, IVAS_24k4, 24000}, /* 160k */ + {IVAS_64k, IVAS_48k, IVAS_32k, IVAS_24k4}, /* 192k */ + {IVAS_96k, IVAS_64k, IVAS_48k, IVAS_32k}, /* 256k */ + {IVAS_128k, IVAS_80k, IVAS_64k, IVAS_48k}, /* 384k */ + {IVAS_128k, IVAS_96k, IVAS_80k, IVAS_64k} /* 512k */ +}; + +/* column wise DCT matrices for 4 5, and 8 dim */ +/*----------------------------------------------------------------------------------* + * Param ISM ROM tables + *----------------------------------------------------------------------------------*/ + +const Word16 Param_ISM_band_grouping[MAX_PARAM_ISM_NBANDS + 1] = +{ + 0, 1, 2, 3, 4, 6, 8, 11, 15, 21, 31, 60 +}; + +/*----------------------------------------------------------------------------------* + * LFE coding ROM tables + *----------------------------------------------------------------------------------*/ + +const ivas_lfe_freq_models ivas_str_lfe_freq_models = +{ + { 16384, 14924, 13463, 12003, 10542, 9082, 7622, 6161, + 4701, 4336, 3970, 3605, 3240, 2875, 2510, 2145, + 1780, 1689, 1597, 1506, 1415, 1323, 1232, 1141, + 1050, 1004, 958, 913, 867, 821, 776, 730, + 685, 639, 593, 548, 502, 456, 411, 365, + 319, 297, 274, 251, 228, 205, 183, 160, + 137, 126, 114, 103, 91, 80, 68, 57, + 46, 40, 34, 29, 23, 17, 11, 6, 0 }, + + { 16384, 13463, 10542, 7622, 4701, 3970, 3240, 2510, + 1780, 1597, 1415, 1232, 1050, 958, 867, 776, + 685, 593, 502, 411, 319, 274, 228, 183, + 137, 114, 91, 68, 46, 34, 23, 11, 0 }, + + { 16384, 4701, 1780, 1050, 685, 319, 137, 46, + 0, }, + + { 16384, 3277, 0 }, + + { 16384, 13463, 10542, 7622, 4701, 3970, 3240, 2510, + 1780, 1597, 1415, 1232, 1050, 958, 867, 776, + 685, 593, 502, 411, 319, 274, 228, 183, + 137, 114, 91, 68, 46, 34, 23, 11, + 0 }, + + { 16384, 10542, 4701, 3240, 1780, 1415, 1050, 867, + 685, 502, 319, 228, 137, 91, 46, 23, + 0 }, + + { 16384, 4468, 1489, 745, 0 }, 0, +}; + +const Word16 ivas_lfe_num_ele_in_coder_models[2][4] = +{ + { 63, 31, 7, 1 },{ 31, 15, 3, 0 } +}; + +const Word16 ivas_lfe_log2_num_ele_in_coder_models_fx[2][4] = +{ + { 6, 5, 3, 1 },{ 5, 4, 2, 0 } +}; + +const Word16 ivas_lfe_num_dct_pass_bins_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 8, 6 }; + +const Word16 ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; + +const Word16 ivas_lfe_lpf_delay_Q15[2] = { 57, 114 }; + +const Word16 dirac_gains_P_idx[16] = +{ + -1, 1, 0, 1, 4, 3, 2, 3, 4, 8, 7, 6, 5, 6, 7, 8 +}; + +/*----------------------------------------------------------------------------------* + * FB ROM tables + *----------------------------------------------------------------------------------*/ + +const Word32 ivas_fb_fcs_12band_1ms_fx[IVAS_FB_BANDS_12] = +{ + 17895696, 53687092, 89478488, 125269880, + 161061280, 196852672, 232644064, 304226848, + 465288128, 715827904, 1091637520, 1735882615 +};/*Q31*/ + +const Word16 ivas_fb_abs_bins_per_band_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = +{ + { 24, 30, 30, 30, 30, 30, 42, 76, 124, 182, 291, 367 }, + { 24, 30, 30, 30, 30, 30, 42, 76, 124, 182, 260, 47 }, + { 24, 30, 30, 30, 30, 30, 42, 75, 122, 73, 0, 0 } +}; + +const Word16 ivas_fb_abs_bins_start_offset_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = +{ + {0, 9, 25, 41, 57, 73, 88, 110, 158, 246, 380, 593 }, + {0, 9, 25, 41, 57, 73, 88, 110, 158, 246, 380, 593 }, + {0, 9, 25, 41, 57, 73, 88, 110, 159, 247, 0, 0 } +}; + +const Word16 ivas_fb_bins_per_band_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = +{ + { + IVAS_FB_12_1MS_48K_END_BINS_BAND_0 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_0, + IVAS_FB_12_1MS_48K_END_BINS_BAND_1 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_1, + IVAS_FB_12_1MS_48K_END_BINS_BAND_2 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_2, + IVAS_FB_12_1MS_48K_END_BINS_BAND_3 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_3, + IVAS_FB_12_1MS_48K_END_BINS_BAND_4 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_4, + IVAS_FB_12_1MS_48K_END_BINS_BAND_5 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_5, + IVAS_FB_12_1MS_48K_END_BINS_BAND_6 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_6, + IVAS_FB_12_1MS_48K_END_BINS_BAND_7 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_7, + IVAS_FB_12_1MS_48K_END_BINS_BAND_8 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_8, + IVAS_FB_12_1MS_48K_END_BINS_BAND_9 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_9, + IVAS_FB_12_1MS_48K_END_BINS_BAND_10 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_10, + IVAS_FB_12_1MS_48K_END_BINS_BAND_11 - IVAS_FB_12_1MS_48K_START_OFFSET_BAND_11 + }, + { + IVAS_FB_12_1MS_32K_END_BINS_BAND_0 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_0, + IVAS_FB_12_1MS_32K_END_BINS_BAND_1 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_1, + IVAS_FB_12_1MS_32K_END_BINS_BAND_2 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_2, + IVAS_FB_12_1MS_32K_END_BINS_BAND_3 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_3, + IVAS_FB_12_1MS_32K_END_BINS_BAND_4 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_4, + IVAS_FB_12_1MS_32K_END_BINS_BAND_5 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_5, + IVAS_FB_12_1MS_32K_END_BINS_BAND_6 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_6, + IVAS_FB_12_1MS_32K_END_BINS_BAND_7 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_7, + IVAS_FB_12_1MS_32K_END_BINS_BAND_8 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_8, + IVAS_FB_12_1MS_32K_END_BINS_BAND_9 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_9, + IVAS_FB_12_1MS_32K_END_BINS_BAND_10 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_10, + IVAS_FB_12_1MS_32K_END_BINS_BAND_11 - IVAS_FB_12_1MS_32K_START_OFFSET_BAND_11 + }, + { + IVAS_FB_12_1MS_16K_END_BINS_BAND_0 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_0, + IVAS_FB_12_1MS_16K_END_BINS_BAND_1 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_1, + IVAS_FB_12_1MS_16K_END_BINS_BAND_2 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_2, + IVAS_FB_12_1MS_16K_END_BINS_BAND_3 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_3, + IVAS_FB_12_1MS_16K_END_BINS_BAND_4 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_4, + IVAS_FB_12_1MS_16K_END_BINS_BAND_5 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_5, + IVAS_FB_12_1MS_16K_END_BINS_BAND_6 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_6, + IVAS_FB_12_1MS_16K_END_BINS_BAND_7 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_7, + IVAS_FB_12_1MS_16K_END_BINS_BAND_8 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_8, + IVAS_FB_12_1MS_16K_END_BINS_BAND_9 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_9, + IVAS_FB_12_1MS_16K_END_BINS_BAND_10 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_10, + IVAS_FB_12_1MS_16K_END_BINS_BAND_11 - IVAS_FB_12_1MS_16K_START_OFFSET_BAND_11 + }, +}; + +const Word16 ivas_fb_bins_start_offset_12band_1ms[IVAS_NUM_SUPPORTED_FS][IVAS_FB_BANDS_12] = +{ + { + IVAS_FB_12_1MS_48K_START_OFFSET_BAND_0, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_1, + IVAS_FB_12_1MS_48K_START_OFFSET_BAND_2, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_3, + IVAS_FB_12_1MS_48K_START_OFFSET_BAND_4, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_5, + IVAS_FB_12_1MS_48K_START_OFFSET_BAND_6, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_7, + IVAS_FB_12_1MS_48K_START_OFFSET_BAND_8, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_9, + IVAS_FB_12_1MS_48K_START_OFFSET_BAND_10, IVAS_FB_12_1MS_48K_START_OFFSET_BAND_11 + }, + { + IVAS_FB_12_1MS_32K_START_OFFSET_BAND_0, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_1, + IVAS_FB_12_1MS_32K_START_OFFSET_BAND_2, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_3, + IVAS_FB_12_1MS_32K_START_OFFSET_BAND_4, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_5, + IVAS_FB_12_1MS_32K_START_OFFSET_BAND_6, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_7, + IVAS_FB_12_1MS_32K_START_OFFSET_BAND_8, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_9, + IVAS_FB_12_1MS_32K_START_OFFSET_BAND_10, IVAS_FB_12_1MS_32K_START_OFFSET_BAND_11 + }, + { + IVAS_FB_12_1MS_16K_START_OFFSET_BAND_0, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_1, + IVAS_FB_12_1MS_16K_START_OFFSET_BAND_2, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_3, + IVAS_FB_12_1MS_16K_START_OFFSET_BAND_4, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_5, + IVAS_FB_12_1MS_16K_START_OFFSET_BAND_6, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_7, + IVAS_FB_12_1MS_16K_START_OFFSET_BAND_8, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_9, + IVAS_FB_12_1MS_16K_START_OFFSET_BAND_10, IVAS_FB_12_1MS_16K_START_OFFSET_BAND_11 + }, +}; + + +const Word16 ivas_num_active_bands[FB - WB + 1] = +{ + IVAS_16K_12BANDS_ACTIVE_BANDS, IVAS_FB_BANDS_12, IVAS_FB_BANDS_12 +}; + +/*------------------------------------------------------------------------------------------* + * SNS MSVQ codebooks and means + *------------------------------------------------------------------------------------------*/ + +const Word16 ivas_sns_cdbks_tcx20_levels[SNS_MSVQ_NSTAGES_TCX20] = { 128, 64, 32, 32 }; + +const Word16 ivas_sns_cdbks_tcx20_bits[SNS_MSVQ_NSTAGES_TCX20] = { 7, 6, 5, 5 }; + +/* pre-rounded codebook vectors for singed Q4.12 represantation */ + +const Word16 ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 }; + +const Word16 ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 }; + + +const Word16 ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 }; +const Word16 ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 }; +const Word16 ivas_sns_cdbks_side_tcx10_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 8 }; +const Word16 ivas_sns_cdbks_side_tcx10_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 3 }; + + +const Word16 sns_1st_cdbk[2][2][8 * 32] = +{ + { /* split 1 */ + { /* TCX 20 */ + -10900, -11064, -10637, -10471, -9051, -6381, -4688, -2438, + -2119, -5087, -6702, -8118, -7586, -6343, -4828, -3406, + 2004, -3443, -4289, -3757, -3234, -2952, -2313, -1781, + 1749, 5598, 3916, 732, -1472, -2964, -3275, -2332, + -11978, -14369, -5600, -545, 981, -929, -57, 1903, + 1745, 391, 202, 115, 256, -291, -862, -1637, + -4052, 2059, 4709, 6768, 5595, 1975, -1723, -1218, + 2093, 7263, 8679, 7576, 3701, -2438, -4389, -2686, + -7120, -6279, -5715, -5520, -4752, -3125, -1856, -438, + 8131, -2543, -6285, -6723, -5588, -4321, -3264, -2164, + -653, -1301, -660, 608, 1598, 1805, 1698, 760, + 4882, 9309, 6333, 1734, 284, 364, 560, 1015, + -7686, -5737, -3443, -1642, 245, 1531, 1827, 1769, + -1468, 3782, 144, -5130, -6883, -5165, -1497, 2072, + -12937, -8429, -2619, 2894, 5004, 4710, 4627, 3740, + 3198, 3928, 4358, 4554, 3887, 2844, 1299, 129, + -13828, -12296, -9364, -7918, -5571, -1909, 307, 2047, + -4314, -1211, -559, -1061, -1928, -2228, -2359, -1902, + -309, -3224, -3404, -1895, -743, -59, 757, 908, + 10914, 5865, 1599, -386, -1392, -2285, -2236, -2042, + -11825, -16241, -11402, -3627, 6556, 8953, 6421, 1546, + 6102, 777, -301, 536, 902, 541, 210, -429, + -3052, 3997, 5389, 1842, -344, 1556, 2667, 2428, + 11788, 10894, 7448, 5423, 2372, -677, -2385, -3839, + -45, -7602, -8923, -7179, -3273, 65, 4500, 6726, + 5895, 626, -1610, -2598, -3240, -3540, -2930, -2156, + -971, 461, 1494, 4907, 5859, 5199, 3678, 2502, + 10766, 5297, 1844, 1236, 2498, 3503, 2846, 838, + -7816, -1212, 891, 2387, 1317, 2225, 1859, 1602, + 2376, 5357, 2088, -2719, -3419, -420, 2431, 2943, + -8383, -795, 4351, 7026, 7460, 7191, 5262, 3796, + 1522, 6283, 8714, 8222, 7434, 5768, 3586, 1499, + }, + { /* TCX 10 */ + -15596, -16321, -10264, -1002, 5955, 5543, -29, -1688, + 17, -3794, -6207, -7356, -6998, -6081, -4453, -2448, + -12543, -11530, -10186, -8817, -7083, -4440, -1946, 892, + 5198, 2751, -274, -2574, -4561, -6087, -5944, -4600, + -683, -2640, -2753, -1195, -239, -217, -286, 90, + -1400, -1146, -1853, -2845, -3456, -3788, -3171, -1969, + -1835, 392, 1725, 1209, -392, -1640, -2001, -1608, + 5770, 7707, 5210, 2112, -382, -2088, -2634, -3007, + -10766, -8101, -5137, -3754, -1881, 331, 2339, 3679, + -2637, -4640, -5811, -5651, -3790, -1359, 913, 1893, + -7793, -4768, -1762, -545, -717, -837, -441, -75, + 4030, 1770, 467, 379, 10, -1330, -2398, -2290, + -9395, -6952, -2494, 2022, 4753, 5614, 4443, 2642, + -1486, 1748, 859, -2586, -3368, -638, 2761, 3269, + -2408, 306, 3633, 6567, 5950, 2474, -621, -1421, + 5478, 7986, 9498, 8165, 5477, 1244, -523, -1586, + -13564, -14673, -10597, -5504, 1575, 8248, 7662, 4025, + 4978, -682, -3586, -4305, -3703, -3001, -2227, -1278, + -8002, -6831, -5558, -4868, -4243, -3393, -2486, -1110, + 11485, 5472, 1645, -533, -1792, -2814, -3169, -2706, + 1617, 421, 232, 1382, 2162, 2017, 1318, 744, + 3677, 5212, 1990, -1514, -2894, -2441, -451, 592, + 731, 4295, 5860, 3756, 1991, 1437, 869, 127, + 12736, 11722, 7768, 4682, 1574, -744, -1989, -3131, + -3490, -4269, -3681, -1531, 1111, 3327, 4138, 3815, + 7344, 1400, -1302, -1502, -1015, 57, 1212, 1498, + -4836, -1881, 1071, 2055, 2114, 2465, 2093, 1458, + 8569, 5879, 3654, 2879, 2530, 1703, 781, -233, + -3709, -990, 2338, 6227, 7083, 7102, 5657, 3401, + 3389, 6392, 5267, 1011, 275, 3519, 5236, 4339, + 599, 3752, 6943, 9211, 8152, 5568, 3337, 1838, + 9885, 9591, 7905, 8068, 7929, 7421, 4234, 757, + } + }, + { /* split 2 */ + { /* TCX 20 */ + -178, -3476, -5982, -7081, -7548, -7440, -6859, -5798, + -3596, -3670, -1501, 770, 812, -286, -2001, -3377, + -3998, -5191, -4988, -4421, -3889, -3571, -2738, -1969, + -2981, -2687, -1501, -83, 1136, 2377, 3248, 4105, + 1842, -41, -1972, -4282, -6779, -8405, -8674, -7835, + -259, 571, 2124, 3344, 2959, 1407, -750, -2523, + -524, -1956, -2855, -3202, -3939, -4666, -4907, -4782, + -5110, -4768, -3017, -663, 4188, 9210, 16602, 21081, + 4373, 4846, -603, -6495, -7289, -5540, -4749, -5527, + -1448, -1043, -619, -105, 356, 362, 542, 857, + 1373, -752, -5334, -6244, -3001, -932, -1040, -3125, + -2403, -1397, 612, 2449, 3920, 5231, 6819, 8581, + 2183, 1211, -111, -1084, -2836, -4977, -6701, -7284, + -751, 1255, 3408, 6474, 7503, 7026, 5413, 4464, + 935, 850, 589, 353, 160, -434, -939, -931, + 268, 2284, 3884, 5423, 6680, 7996, 9244, 9472, + 1075, 113, -1289, -4457, -7512, -5930, -1799, -571, + -3689, -4254, -3755, -2995, -1581, -135, 1049, 1589, + -1166, -1752, -1790, -1897, -1927, -1831, -1359, -805, + -1494, -735, 635, 1993, 2909, 3546, 4226, 4956, + 4435, 4299, 4269, 1328, -3731, -7621, -9319, -9170, + 1358, 2227, 3873, 4469, 4692, 4057, 2601, 1608, + 813, 398, -499, -666, -1286, -2271, -3316, -4025, + -3300, -1255, 2181, 6431, 10002, 12760, 13549, 12584, + 3714, 4180, 484, -2905, -2864, -1359, -1256, -2477, + 308, 868, 1373, 1629, 1793, 1834, 1814, 1746, + 1472, 798, -282, -1935, -1818, 320, 2221, 2914, + 2281, 3240, 2988, 1400, 2383, 4072, 5667, 6675, + 2672, 2678, 2874, 2096, -226, -2301, -3861, -4534, + 4988, 7231, 7641, 7731, 7061, 6447, 5411, 3513, + 3978, 4156, 4126, 2896, 1469, 759, 368, -68, + -264, 4210, 8534, 11008, 11606, 11888, 11072, 8949, }, + { /* TCX 10 */ + -2852, -6158, -7231, -7830, -8012, -7922, -7556, -6706, + -3911, -5340, -5053, -4741, -4805, -4484, -3727, -3037, + -966, -1461, -1694, -2427, -3081, -3037, -2547, -2230, + -3455, -3315, -2451, -836, 1383, 3196, 3720, 3379, + 3052, 281, -3351, -6866, -9051, -9586, -8983, -8236, + -748, -4465, -4314, -2251, 29, -40, -3963, -6195, + 200, 1293, 2535, 2803, 1603, -186, -1397, -1697, + -1707, -265, 2196, 5295, 5894, 4216, 3440, 3826, + -237, -2133, -2279, -3149, -4377, -5638, -6520, -6764, + -2407, -2049, -1246, -664, -521, -430, -349, -211, + 3874, 1335, -1501, -2055, -1268, -990, -1852, -2871, + -1883, -1845, -1681, -484, 384, 2035, 5839, 9597, + 275, 380, 1048, 424, -1146, -3012, -4431, -5104, + -1699, -484, 756, 1261, 1279, 1377, 1975, 2590, + 2139, 4502, 3645, 4975, 6491, 5972, 5012, 4346, + -3821, -2581, -433, 2667, 6436, 10038, 11311, 8783, + 2359, -2689, -6604, -7039, -5992, -4268, -3711, -4840, + -2776, -4251, -4539, -3672, -2494, -1055, 280, 695, + 491, 866, 822, -44, -1009, -1165, -831, -538, + -1024, 91, 786, 1295, 2433, 3910, 4975, 5403, + 3117, 2590, 2337, -667, -4580, -8147, -9400, -9523, + -103, -630, -831, 669, 3062, 3398, 549, -1690, + 2113, 3467, 4279, 5047, 5344, 3361, 127, -2313, + -1199, 1153, 2914, 3688, 4260, 5421, 7471, 8831, + 2815, 2184, 316, -3058, -5596, -5564, -4343, -3793, + 922, 126, -1414, -1731, -1007, 359, 2029, 3088, + 4889, 4619, 2537, 1114, 950, 946, 799, 419, + -4271, -3750, -3359, -484, 1448, 4106, 10487, 20479, + 3818, 4687, 4064, 2212, -172, -2287, -3535, -4041, + 884, 2456, 3394, 2925, 2182, 2323, 2583, 2507, + 4767, 8057, 8263, 6461, 5003, 4055, 2923, 1845, + 19, 3813, 6926, 8432, 10141, 10850, 9692, 8383, + } + } +}; + +const Word16 sns_1st_means_16k[2][16] = +{ + { /* TCX 20 */ + 14210, 19017, 14362, 9309, 5385, 2674, 1055, -211, -1407, -3059, -4393, -8597, -11180, -11756, -12131, -13281, + }, + { /* TCX 10*/ + 12018, 15915, 11089, 6015, 847, -705, -539, -1548, -893, -2163, -1806, -4189, -7017, -8670, -8874, -9480, + } +}; + +const Word16 sns_1st_means_25k6[2][16] = +{ + { /* TCX 20 */ + 14973, 20323, 16461, 9554, 4017, 3103, 1602, 1694, -221, -1401, -6817, -10071, -11503, -11805, -13158, -16749, + }, + { /* TCX 10 */ + 15560, 19489, 14623, 5595, 2084, 1699, 775, -1312, -2195, -6101, -9078, -9465, -7825, -6603, -7281, -9960, + } +}; + +const Word16 sns_1st_means_32k[2][16] = +{ + { /* TCX 20 */ + 15041, 20603, 16969, 10289, 4973, 4283, 3003, 3316, 1684, -259, -6614, -9535, -10363, -11834, -16625, -24930, + }, + { /* TCX 10 */ + 16510, 20660, 16025, 7224, 3921, 3868, 2623, 742, -1316, -6269, -8284, -7288, -6380, -8410, -13351, -20277, + } +}; + +/*----------------------------------------------------------------------* + * MC ParamUpmix ROM tables + *-----------------------------------------------------------------------*/ + +const Word16 ivas_param_upmx_mx_qmap[33] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 +}; - }; \ No newline at end of file diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 60bdda941..94ad05426 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -654,25 +654,27 @@ static ivas_error ivas_alloc_pppMem_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - FOR( i = 0; i < dim1; i++ ){ - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ){ - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); -} -IF( allocate_init_flag == 0 ) -{ - FOR( j = 0; j < dim2; j++ ) + for ( i = 0; i < dim1; i++ ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } + IF( allocate_init_flag == 0 ) + { + FOR( j = 0; j < dim2; j++ ) + { + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } + } + } } -} -} -*pppMem = localMem; + *pppMem = localMem; -return IVAS_ERR_OK; + return IVAS_ERR_OK; } /*-------------------------------------------------------------------------* -- GitLab From dfc596d78345cbe2b391c3be4f3ca5eac1ac7e6f Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 13:18:35 +1100 Subject: [PATCH 032/329] linux compilation fix --- lib_com/ivas_rom_com.c | 5 +++-- lib_com/ivas_rotation_com.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 5df975cf8..9f2f244df 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -56,7 +56,7 @@ const Word32 ivas_brate_tbl[SIZE_IVAS_BRATE_TBL] = * IVAS limiter table *----------------------------------------------------------------------------------*/ const Word32 release_cnst_table[4][201] = // Q31 - { +{ { 1913946752, 1919716352, @@ -871,7 +871,7 @@ const Word32 release_cnst_table[4][201] = // Q31 }, - }; +}; /*------------------------------------------------------------------------- * DFT Stereo ROM tables @@ -3722,3 +3722,4 @@ const Word16 ivas_param_upmx_mx_qmap[33] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; +/* clang-format on */ diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 8aae50841..1ed1a7244 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -38,6 +38,7 @@ #include "cnst.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif -- GitLab From 1f3d8a7b0de3300616884d62e7e06b2081c32675 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 13:24:13 +1100 Subject: [PATCH 033/329] clang formatting fix --- lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 94ad05426..c31f0cbf7 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -2164,4 +2164,4 @@ void ivas_rend_CldfbMultiBinRendProcess( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 4e568b5ab..8a73539be 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -492,4 +492,4 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( return IVAS_ERR_OK; } -#endif \ No newline at end of file +#endif -- GitLab From 225019b3520b3bafce551e146dae1f0a410d131f Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 15:04:23 +1100 Subject: [PATCH 034/329] linux compilation fixes --- lib_com/ivas_prot_fx.h | 4 ++-- lib_com/ivas_rotation_com.c | 4 ++-- lib_dec/lib_dec.h | 2 +- lib_lc3plus/defines.h | 2 ++ lib_lc3plus/lc3.c | 2 ++ 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 8e0bfece9..88e8ed7ac 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5961,8 +5961,8 @@ void modify_Quat_q_fx( ); void modify_Rmat_q_fx( - const Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ - Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ + Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ Word16 num_subframes, Word16 q_cur, /* i : current q factor for rotation matrix */ Word16 q_new /* i : target q factor for rotation matrix */ diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 1ed1a7244..fccc5498b 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -130,8 +130,8 @@ void modify_Quat_q_fx( * Rotation matrix q factor modification *------------------------------------------------------------------------*/ void modify_Rmat_q_fx( - const Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ - Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ + Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ Word16 num_subframes, Word16 q_cur, /* i : current q factor for rotation matrix */ Word16 q_new /* i : target q factor for rotation matrix */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 0b20e64f9..dd2f14f09 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -147,7 +147,7 @@ ivas_error IVAS_DEC_GetSamples( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_DEC_GetSplitBinauralBitstream( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + Word16 *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ bool *needNewFrame /* o : indication that the decoder needs a new frame */ diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index f468568a9..ebf538b71 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -757,4 +757,6 @@ extern int fix_empty_translation_unit_warning; #define get_size_mpvq_calc_offset_fx get_size_mpvq_calc_offset_fx_lc3plus #endif +#define FIX_IVAS_LC3PLUS_WARNINGS + #endif diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c index 120dd0929..68dd8a0bb 100644 --- a/lib_lc3plus/lc3.c +++ b/lib_lc3plus/lc3.c @@ -17,6 +17,7 @@ if (cond) \ return (error) +#ifndef FIX_IVAS_LC3PLUS_WARNINGS #ifdef SUBSET_NB #pragma message("- SUBSET_NB") #endif @@ -35,6 +36,7 @@ #ifdef SUBSET_UB #pragma message("- SUBSET_UB") #endif +#endif /* ensure api header constants are up to date */ STATIC_ASSERT(LC3PLUS_MAX_SAMPLES >= MAX_LEN); -- GitLab From d38113cbedfff1f2773abf9294d21f2d8f60c970 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 15:37:10 +1100 Subject: [PATCH 035/329] linux warning fixes --- apps/renderer.c | 3 --- lib_isar/isar_splitRend_lcld_dec.c | 2 +- lib_rend/lib_rend.c | 18 ++++++------------ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index a41b633e2..6f55853d6 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -436,9 +436,6 @@ static void printSupportedAudioConfigs( void ); static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); #ifdef SPLIT_REND_WITH_HEAD_ROT -static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); - -static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 0d5ccae2f..98ca3d3ad 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -37,7 +37,7 @@ #include "ivas_prot.h" #include "prot.h" #include "prot_fx.h" -#include "control.h" +//#include "control.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 9b96ac146..bacdec5d1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -6250,7 +6250,6 @@ static ivas_error renderIsmToSplitBinaural( { ivas_error error; Word32 tmpProcessing[MAX_NUM_OBJECTS][L_FRAME48k]; - Word32 *pTmpProcessing[MAX_NUM_OBJECTS]; Word16 pos_idx; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; const SPLIT_REND_WRAPPER *pSplitRendWrapper; @@ -6289,11 +6288,6 @@ static ivas_error renderIsmToSplitBinaural( /* Copy input audio to a processing buffer. */ copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpProcessing ); - FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) - { - pTmpProcessing[i] = tmpProcessing[i]; - } - FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { @@ -7977,12 +7971,6 @@ static ivas_error renderInputSba( SWITCH( getAudioConfigType( outConfig ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: - case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: - error = renderSbaToSplitBinaural( sbaInput, outConfig, outAudio ); - break; -#endif case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: renderSbaToMc( sbaInput, outAudio ); BREAK; @@ -7992,6 +7980,12 @@ static ivas_error renderInputSba( case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: SWITCH( outConfig ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderSbaToSplitBinaural( sbaInput, outConfig, outAudio ); + break; +#endif case IVAS_AUDIO_CONFIG_BINAURAL: error = renderSbaToBinaural( sbaInput, outConfig, outAudio ); BREAK; -- GitLab From 344fd08b44401d56c67a3cd03b14590051b8b2f2 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Feb 2025 16:47:48 +1100 Subject: [PATCH 036/329] linux error fixes, compiles locally --- Makefile | 2 +- Workspace_msvc/lib_lc3plus.vcxproj | 4 +- lib_lc3plus/al_fec.c | 116 +++++++++--------- lib_lc3plus/basop_mpy_lc3plus.h | 6 +- lib_lc3plus/basop_util_lc3plus.c | 2 +- lib_lc3plus/dct4_fx.c | 10 +- lib_lc3plus/detect_cutoff_warped_fx.c | 2 +- lib_lc3plus/fft_lc3plus.c | 26 ++-- lib_lc3plus/per_band_energy_fx.c | 6 +- ..._basop_util.c => rom_basop_util_lc3plus.c} | 8 +- ..._basop_util.h => rom_basop_util_lc3plus.h} | 6 +- 11 files changed, 94 insertions(+), 94 deletions(-) rename lib_lc3plus/{rom_basop_util.c => rom_basop_util_lc3plus.c} (99%) rename lib_lc3plus/{rom_basop_util.h => rom_basop_util_lc3plus.h} (98%) diff --git a/Makefile b/Makefile index 92d3cd3f0..5003f2cb2 100644 --- a/Makefile +++ b/Makefile @@ -230,7 +230,7 @@ endif $(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBISAR) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) ifeq "$(INCLUDE_SPLIT)" "1" - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPPOSTREND) -L. -lisar -livasutil -livasdebug -llc3plus -livascom $(LDLIBS) -o $(CLI_APIPOSTREND) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPPOSTREND) -L. -lisar -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIPOSTREND) endif libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(LIB_LIBUTIL) diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index b22697021..22b5cddd3 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -164,7 +164,7 @@ - + @@ -183,7 +183,7 @@ - + diff --git a/lib_lc3plus/al_fec.c b/lib_lc3plus/al_fec.c index 7579a21b0..c659a90e0 100644 --- a/lib_lc3plus/al_fec.c +++ b/lib_lc3plus/al_fec.c @@ -11,7 +11,7 @@ #include "functions.h" -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" #include #include #include @@ -43,7 +43,7 @@ #define ERROR_REPORT_EP1_OK ((0x1000)>>1) #define ERROR_REPORT_EP2_OK ((0x2000)>>1) #define ERROR_REPORT_EP3_OK ((0x4000)>>1) -#define ERROR_REPORT_EP4_OK ((0x8000)>>1) +#define ERROR_REPORT_EP4_OK ((0x8000)>>1) #define ERROR_REPORT_ALL_OK (ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK) /* debugging switches */ @@ -781,7 +781,7 @@ int fec_decoder(UWord8 *iobuf, Word16 slot_bytes, int *data_bytes, Word16 *epmr, } } #endif - + IF (sub(*bfi, 1) == 0) { *data_bytes = 0; move16(); @@ -1060,7 +1060,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword n_mode_candidates = 0; move16(); risk_min_f.mantissa = SIMPLE_FLOAT_1_MANTISSA; move16(); risk_min_f.exponent = 0; move16(); - + IF (n_symb <= 80) { ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; move16(); @@ -1071,16 +1071,16 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; move16(); ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; move16(); } - + syndr_calc[0] = &rs16_calculate_two_syndromes; syndr_calc[1] = &rs16_calculate_four_syndromes; syndr_calc[2] = &rs16_calculate_six_syndromes; - + FOR (i = 0; i < FEC_N_MODES; i++) { t[i] = (Word8)shr(sub(hamming_distance[i], 1), 1); move16(); } - + syndromes = my_scratch; my_scratch += FEC_TOTAL_SYNDROME_SIZE; elp = my_scratch; @@ -1091,25 +1091,25 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword my_scratch += FEC_TOTAL_ERROR_SIZE; deg_elp = (Word8 *)my_scratch; my_scratch += FEC_TOTAL_DEG_ELP_SIZE; - + *error_report = 0; move16(); *bfi = 0; move32(); - + /* mode detection (stage 1) */ codeword_length = get_codeword_length(n_codewords, n_symb, 0); - + epmr_position = sub(codeword_length, 1); - + rs16_calculate_two_syndromes(syndromes + SYNDROME_IDX(0, 0), iobuf, sub(codeword_length, 1)); - + IF (s_or(syndromes[0 + SYNDROME_IDX(0, 0)], syndromes[1 + SYNDROME_IDX(0, 0)]) == 0) { - + /* data validation for fec mode 1 */ *epmr = cw0_get_epmr(iobuf, epmr_position); - + dw0_bitswap(iobuf + 2, 1, n_symb / 2); - + IF (!crc1(iobuf + 8, sub(n_symb, 8), *epmr, iobuf + 2, 3, 1)) { mode = 0; move16(); @@ -1121,27 +1121,27 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { /* reverse bit swap */ dw0_bitswap(iobuf + 2, 1, n_symb / 2); - + *epmr = add(*epmr, 4); move16(); } } - + blacklist[0] = 1; move16(); - + /* mode detection (stage 2) */ - + /* calculate syndromes of code words 0 to 5 and modes 1 to 3 */ cw_offset = 0; move16(); - + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - + rs16_calculate_six_syndromes(syndromes + SYNDROME_IDX(1, cw_counter), iobuf + cw_offset, sub(codeword_length, 1)); - + cw_offset = add(cw_offset, codeword_length); - + FOR (mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter--) { FOR (i = 0; i < sub(hamming_distance[mode_counter], 1); i++) @@ -1168,14 +1168,14 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword n_broken_cw = add(n_broken_cw, 1); } } - + IF (n_broken_cw == 0) { mode = mode_counter; move16(); cw_offset = 0; move16(); - + *epmr = cw0_get_epmr(iobuf, epmr_position); - + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); @@ -1187,7 +1187,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } } - + IF (mode < 0) /* mode hasn't been detected so far -> errors occurred in transmission */ { /* calculate error locator polynomials for code words 0 to 5 */ @@ -1205,13 +1205,13 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } } - + /* risk analysis for mode candidate selection */ FOR (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) { dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; move16(); dec_risk_f[mode_counter].exponent = 0; move16(); - + IF (blacklist[mode_counter] == 0) { FOR (cw_counter = 0; cw_counter < 6; cw_counter++) @@ -1220,12 +1220,12 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword dec_risk_f[mode_counter], risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)]]); move16(); } - + IF (simple_float_cmp(dec_risk_f[mode_counter], ep_risk_thresh) <= 0) { mode_candidates[n_mode_candidates++] = mode_counter; move16(); } - + IF (simple_float_cmp(dec_risk_f[mode_counter], risk_min_f) < 0) { risk_min_f = dec_risk_f[mode_counter]; move16(); @@ -1233,13 +1233,13 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3 - + /* sort mode candidates by risk */ FOR (i = 0; i < n_mode_candidates; i++) { idx_min = i; move16(); val_min_f = dec_risk_f[mode_candidates[i]]; move16(); - + FOR (j = i + 1; j < n_mode_candidates; j++) { IF (simple_float_cmp(dec_risk_f[mode_candidates[j]], val_min_f) < 0) @@ -1248,24 +1248,24 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword idx_min = j; move16(); } } - + IF (sub(idx_min, i) > 0) - { + { tmp = mode_candidates[i]; move16(); mode_candidates[i] = mode_candidates[idx_min]; move16(); mode_candidates[idx_min] = tmp; move16(); } } - + /* try out candidate modes */ FOR (i = 0; i < n_mode_candidates; i++) { mode = mode_candidates[i]; move16(); - + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - + IF (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) { IF (rs16_factorize_elp(err_pos + ERR_POS_IDX(mode, cw_counter), elp + ELP_IDX(mode, cw_counter), @@ -1283,34 +1283,34 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword BREAK; } } - + IF (mode < 0) { /* no decodable mode has been found */ *error_report = ERROR_REPORT_BEC_MASK; move16(); *bfi = 1; move32(); mode = -1; move16(); - + *epmr = fec_estimate_epmr_from_cw0(iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, n_symb); - + Dyn_Mem_Deluxe_Out(); return mode; } - + /* perform error correction */ cw_offset = 0; move16(); *error_report = 0; move16(); FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - + IF (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) { rs16_calculate_errors( err_symb + ERR_SYMB_IDX(mode, cw_counter), err_pos + ERR_POS_IDX(mode, cw_counter), syndromes + SYNDROME_IDX(mode, cw_counter), deg_elp[DEG_ELP_IDX(mode, cw_counter)], t[mode]); - + /* correct errors and sum up number of corrected bits */ FOR (i = 0; i < deg_elp[DEG_ELP_IDX(mode, cw_counter)]; i++) { @@ -1329,17 +1329,17 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } } - + FOR (i = 0; i <= EP_SIG_POLY_DEG; i++) { iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); } cw_offset = add(cw_offset, codeword_length); } - + /* set epmr according to risk value of cw0 */ epmr_dec_fail_increment = 8; - + IF (add(risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent, 8) <= 0) { epmr_dec_fail_increment = sub(epmr_dec_fail_increment, 4); @@ -1348,10 +1348,10 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { epmr_dec_fail_increment = sub(epmr_dec_fail_increment, 4); } - + *epmr = cw0_get_epmr(iobuf, epmr_position) + epmr_dec_fail_increment; } - + /* mode has been successfully detected -> now check and try to correct remaining code words*/ *n_pccw = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); IF (ccc_flag == 0) @@ -1363,15 +1363,15 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { n_pccw0 = 0; } - + FOR (cw_counter = 6; cw_counter < n_codewords; cw_counter++) { /* usual error correction scheme: syndromes -> elp's, errors, etc. */ codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); array_of_trust[n_codewords - 1 - cw_counter] = 1; move16(); - + syndr_calc[sub(t[mode], 1)](syndromes, iobuf + cw_offset, sub(codeword_length, 1)); - + deg_elp[0] = rs16_calculate_elp(elp, syndromes, t[mode]); move16(); FOR (i = 0; i < mode; i ++) @@ -1393,7 +1393,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword *error_report = ERROR_REPORT_BEC_MASK; move16(); mode = -1; move16(); *bfi = 1; move32(); - + BREAK; } ELSE @@ -1403,7 +1403,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword CONTINUE; } } - + IF (deg_elp[0]) { IF (rs16_factorize_elp(err_pos, elp, deg_elp[0], sub(codeword_length, 1))) @@ -1418,7 +1418,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword *error_report = ERROR_REPORT_BEC_MASK; move16(); mode = -1; move16(); *bfi = 1; move32(); - + BREAK; } ELSE @@ -1428,9 +1428,9 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword CONTINUE; } } - + rs16_calculate_errors(err_symb, err_pos, syndromes, deg_elp[0], t[mode]); - + /* correct errors and sum up number of corrected bits */ FOR (i = 0; i < deg_elp[0]; i++) { @@ -1459,7 +1459,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { return add(mode, 1); } - + return -1; } diff --git a/lib_lc3plus/basop_mpy_lc3plus.h b/lib_lc3plus/basop_mpy_lc3plus.h index 7c08755ee..72c7d91bb 100644 --- a/lib_lc3plus/basop_mpy_lc3plus.h +++ b/lib_lc3plus/basop_mpy_lc3plus.h @@ -9,8 +9,8 @@ #include "defines.h" -#ifndef __BASOP_MPY_H -#define __BASOP_MPY_H +#ifndef __BASOP_MPY_LC3PLUS_H +#define __BASOP_MPY_LC3PLUS_H #include "functions.h" @@ -91,4 +91,4 @@ void cplxMpy_32_16(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a void cplxMpy_32_32(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a_Im, const Word32 b_Re, const Word32 b_Im); -#endif /* __BASOP_SETTINGS_H */ +#endif /* __BASOP_MPY_LC3PLUS_H */ diff --git a/lib_lc3plus/basop_util_lc3plus.c b/lib_lc3plus/basop_util_lc3plus.c index e3ab30f70..9f2d6be79 100644 --- a/lib_lc3plus/basop_util_lc3plus.c +++ b/lib_lc3plus/basop_util_lc3plus.c @@ -9,7 +9,7 @@ #include "defines.h" #include "functions.h" -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" #include "basop_util_lc3plus.h" extern const Word32 SqrtTable_lc3plus[32]; diff --git a/lib_lc3plus/dct4_fx.c b/lib_lc3plus/dct4_fx.c index 9f12894f4..dca4e382c 100644 --- a/lib_lc3plus/dct4_fx.c +++ b/lib_lc3plus/dct4_fx.c @@ -8,7 +8,7 @@ ******************************************************************************/ #include "functions.h" -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ @@ -20,7 +20,7 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ # endif #endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ Word32 *workBuffer) /* : size of L */ - + { Word16 sin_step; Word16 idx; @@ -132,12 +132,12 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ #ifdef ENABLE_DCTIV_RESCALE # ifdef CR8_F_ADAPT_MDCT_DCT_PRECISION - if (hrmode) + if (hrmode) # endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ { - + scale = s_max(getScaleFactor32_lc3plus(pDat, L), 0); move16(); - + FOR (i = 0; i < L; i++) { pDat[i] = L_shl_pos(pDat[i], scale); move32(); diff --git a/lib_lc3plus/detect_cutoff_warped_fx.c b/lib_lc3plus/detect_cutoff_warped_fx.c index b6ef25472..adbf04afa 100644 --- a/lib_lc3plus/detect_cutoff_warped_fx.c +++ b/lib_lc3plus/detect_cutoff_warped_fx.c @@ -8,7 +8,7 @@ ******************************************************************************/ #include "functions.h" -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 frame_dms) { diff --git a/lib_lc3plus/fft_lc3plus.c b/lib_lc3plus/fft_lc3plus.c index a86286d04..6db6de7bb 100644 --- a/lib_lc3plus/fft_lc3plus.c +++ b/lib_lc3plus/fft_lc3plus.c @@ -6,9 +6,9 @@ * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + #include "functions.h" -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" #ifdef ENABLE_FFT_RESCALE #ifndef FFT_RESCALE_HR @@ -1085,7 +1085,7 @@ static void fft15(Word32 *re, Word32 *im, Word16 s) } #ifdef CR8_G_ADD_75MS - + #define STC(x) (x) const Word32 RotVectorReal12[] = { @@ -1104,7 +1104,7 @@ const Word32 RotVectorImag12[] = STC(0x7fffffff), STC(0x00000000), #endif }; - + static void fft12(Word32 *pInput) { Dyn_Mem_Deluxe_In(Word32 aDst[24]; Word32 * pSrc, *pDst; Counter i; Word32 r1, r2, s1, s2, pD; Word32 re, im; @@ -1141,7 +1141,7 @@ static void fft12(Word32 *pInput) pDst[5] = L_sub(s1, r2); pSrc += 2; pDst += 6; - + const Word32 *pVecRe = RotVectorReal12; const Word32 *pVecIm = RotVectorImag12; @@ -1176,7 +1176,7 @@ static void fft12(Word32 *pInput) vre = *pVecRe++; vim = *pVecIm++; cplxMpy_32_32(&pDst[3], &pDst[2], im, re, vre, vim); - + re = L_add(r1, s2); im = L_sub(s1, r2); @@ -3766,7 +3766,7 @@ static void fftN2(Word32 *re, Word32 *im, { fft15(&x[i * 2 * dim1], &x[i * 2 * dim1 + 1], 2); } - + BREAK; case 16: FOR (i = 0; i < dim2; i++) @@ -3808,7 +3808,7 @@ static void fftN2(Word32 *re, Word32 *im, #endif default: ASSERT(0); } - + #ifdef ENABLE_FFT_RESCALE IF (scale) { @@ -3878,7 +3878,7 @@ static void fftN2(Word32 *re, Word32 *im, im[sx * i + sx * 3 * dim1] = L_add(t03, t07); move32(); } - + BREAK; } @@ -3927,7 +3927,7 @@ static void fftN2(Word32 *re, Word32 *im, BREAK; } #endif - + case 8: { Word32 x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15; @@ -4084,7 +4084,7 @@ static void fftN2(Word32 *re, Word32 *im, } BREAK; } - + #if defined(ENABLE_HR_MODE) case 16: { @@ -4093,7 +4093,7 @@ static void fftN2(Word32 *re, Word32 *im, { cplxMpy4_16_1(y[2 * j], y[2 * j + 1], x[2 * 0 + 2 * j * dim1], x[2 * 0 + 2 * j * dim1 + 1]); } - + fft16(&y[0], &y[1], 2); FOR (j = 0; j < dim2; j++) { @@ -4333,7 +4333,7 @@ void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 length, Word16 s, Word16 #ifndef ENABLE_FFT_30X16 fftN2(re, im, RotVector_960, 60, 8, s, 2, 120, scratch); #else - fftN2(re, im, RotVector_30_16, 30, 16, s, 2, 60, scratch); + fftN2(re, im, RotVector_30_16, 30, 16, s, 2, 60, scratch); #endif *scale = add(*scale, SCALEFACTOR480); move16(); #else diff --git a/lib_lc3plus/per_band_energy_fx.c b/lib_lc3plus/per_band_energy_fx.c index 14e853212..3ba629a83 100644 --- a/lib_lc3plus/per_band_energy_fx.c +++ b/lib_lc3plus/per_band_energy_fx.c @@ -8,7 +8,7 @@ ******************************************************************************/ #include "functions.h" -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Word16 d_fx_exp, const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, Word16 frame_dms, @@ -78,7 +78,7 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor IF (sub(linear, 1) == 0) { - + #ifdef ENABLE_HR_MODE if (hrmode) { @@ -230,7 +230,7 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor /* specify headroom, it can be reduced by one due to use of L_mac0 */ s2 = sub(s1, bands_nrg_scale[nbands]); #endif - + /* calculate energy per band */ nrg = 0; move32(); diff --git a/lib_lc3plus/rom_basop_util.c b/lib_lc3plus/rom_basop_util_lc3plus.c similarity index 99% rename from lib_lc3plus/rom_basop_util.c rename to lib_lc3plus/rom_basop_util_lc3plus.c index e37b4bfad..45629965d 100644 --- a/lib_lc3plus/rom_basop_util.c +++ b/lib_lc3plus/rom_basop_util_lc3plus.c @@ -7,7 +7,7 @@ * estoppel or otherwise. * ******************************************************************************/ -#include "rom_basop_util.h" +#include "rom_basop_util_lc3plus.h" #include "basop_util_lc3plus.h" #include "functions.h" @@ -1197,7 +1197,7 @@ const PWord32 SineWindow720[360] = { WTCP(0x5b00814c, 0x5a03c172), WTCP(0x5ace2d0e, 0x5a36869f), WTCP(0x5a9bbc7c, 0x5a692fa7) }; #endif - + const PWord32 SineWindow960[480] = { WTCP(0x7ffffd30, 0x001aceea), WTCP(0x7fffe6bb, 0x00506cb9), WTCP(0x7fffb9d0, 0x00860a79), WTCP(0x7fff7670, 0x00bba822), WTCP(0x7fff1c9a, 0x00f145ab), WTCP(0x7ffeac4f, 0x0126e309), @@ -1361,7 +1361,7 @@ const PWord32 SineWindow960[480] = { WTCP(0x5ae10ff8, 0x5a237ff9), WTCP(0x5abb4628, 0x5a49894f), WTCP(0x5a956c6d, 0x5a6f82cd), }; # endif - + // fs 48 32 24 16 8 // ms +-------------------- // 10.0 | 480 320 240 160 80 @@ -2009,7 +2009,7 @@ const Word32 RotVector_720[2 * (720 - 30)] = { SHC(0x4654552e), SHC(0x465f4350), SHC(0x3078303d), SHC(0x40755c3d), SHC(0x00202477), SHC(0x56524553), SHC(0x454d414e), SHC(0x4c564c48), SHC(0x3d454d4f), SHC(0x732f7372), SHC(0x4e474f4c), SHC(0x6d676c73), SHC(0x59414c50), SHC(0x74617669), SHC(0x6f632f70), SHC(0x2e656c70), SHC(0x2e646863), SHC(0x53386438) - }; + }; #endif const Word32 RotVector_960[2 * (480 - 60)] = { SHC(0x7fffffff), SHC(0x00000000), SHC(0x7ffd3154), SHC(0xfe531484), SHC(0x7ff4c56f), SHC(0xfca63bd8), diff --git a/lib_lc3plus/rom_basop_util.h b/lib_lc3plus/rom_basop_util_lc3plus.h similarity index 98% rename from lib_lc3plus/rom_basop_util.h rename to lib_lc3plus/rom_basop_util_lc3plus.h index 6e757c339..11d90c77b 100644 --- a/lib_lc3plus/rom_basop_util.h +++ b/lib_lc3plus/rom_basop_util_lc3plus.h @@ -7,8 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ -#ifndef __BASOP_UTIL_ROM_H__ -#define __BASOP_UTIL_ROM_H__ +#ifndef __ROM_BASOP_UTIL_LC3PLUS_H__ +#define __ROM_BASOP_UTIL_LC3PLUS_H__ #include "basop_util_lc3plus.h" #include "functions.h" @@ -69,7 +69,7 @@ void BASOP_getTables( #else const PWord16 **ptwiddle, const PWord16 **sin_twiddle, -#endif +#endif Word16 *sin_step, Word16 length); -- GitLab From a7f9fcc5154eda4e05c5fdc5655da3f5144f70ae Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 5 Feb 2025 12:09:10 +0100 Subject: [PATCH 037/329] fix initialization of st->force_dir in ISM and SCE modes --- lib_enc/ivas_cpe_enc.c | 1 - lib_enc/ivas_init_enc.c | 3 +++ lib_enc/ivas_ism_enc.c | 3 +++ lib_enc/ivas_sce_enc.c | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 7b7ab41bf..4f8926eba 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -1198,7 +1198,6 @@ ivas_error ivas_cpe_enc_fx( } } - /*----------------------------------------------------------------* * Core Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index d6a3597bd..02219c4e3 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -370,6 +370,9 @@ void copy_encoder_config_fx( #ifdef DEBUGGING st_fx->force = st_ivas->hEncoderConfig->force; +#ifdef DEBUG_FORCE_DIR + st_fx->force_dir = st_ivas->hEncoderConfig->force_dir; +#endif #endif st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */ diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 6f8fb2b9f..2fef5a1cb 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -197,6 +197,9 @@ ivas_error ivas_ism_enc_fx( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; st->id_element = sce_id; +#ifdef DEBUG_FORCE_DIR + st->force_dir = st_ivas->hEncoderConfig->force_dir; +#endif #endif move16(); move16(); diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index d43ed7438..7d76b2fd5 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -161,6 +161,9 @@ ivas_error ivas_sce_enc_fx( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; st->id_element = sce_id; +#ifdef DEBUG_FORCE_DIR + st->force_dir = st_ivas->hEncoderConfig->force_dir; +#endif #endif move16(); move16(); -- GitLab From bf593d4ef4f67559a74472b3a1259a6c1ff30083 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 12:16:39 +0100 Subject: [PATCH 038/329] do not passs "BASOP" as project to prepare_instrumentation.sh this was added to skip missing split rendering/LC3Plus code parts which are now there --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cb080114..479a000a6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -901,7 +901,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR @@ -1655,7 +1655,7 @@ ivas-pytest-on-merge-request: stage: test variables: ret_val: 0 - GET_WMOPS_ARGS: "mem_only basop" + GET_WMOPS_ARGS: "mem_only" timeout: 3 hours 30 minutes before_script: - *print-common-info -- GitLab From 8b94edb889c5fefe9518eccf00ef3f458dd7b25b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 12:35:39 +0100 Subject: [PATCH 039/329] remove obsolete anchor + add clean step --- .gitlab-ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 479a000a6..3995083d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -132,10 +132,6 @@ stages: echo "Commit time was $CI_COMMIT_TIMESTAMP" ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression -.disable-debugging-macro: &disable-debugging-macro - # automatically disable #DEBUGGING macro in options.h using /**/-comment - - sed -i.bak -e "s/^[[:space:]]*\(#define[[:space:]]*DEBUGGING\)/\/\*\1\*\//g" lib_com/options.h - # From float CI .mr-fetch-target-branch: &mr-fetch-target-branch # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching @@ -151,7 +147,6 @@ stages: # From float CI .merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec ### build test binaries, initial clean for paranoia reasons - - *disable-debugging-macro - make clean - make -j - mv IVAS_cod IVAS_cod_test @@ -169,7 +164,7 @@ stages: - echo "Building reference codec at commit $target_commit" ### build reference binaries - - *disable-debugging-macro + - make clean - make -j - mv IVAS_cod IVAS_cod_ref - mv IVAS_dec IVAS_dec_ref -- GitLab From b93b23114f47c96272a1e31677917df6a6b9cb6a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 12:46:13 +0100 Subject: [PATCH 040/329] correct rule for build job with DEBUGGING active --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3995083d3..4fe5ec338 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -937,7 +937,7 @@ build-codec-linux-debugging-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_PIPELINE_SOURCE == 'schedule' - if: $CI_PIPELINE_SOURCE == 'push' when: never -- GitLab From d406d0e1fcaad3f5c3b26a30a72220325e6448d8 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 6 Feb 2025 10:00:10 +1100 Subject: [PATCH 041/329] debug compilation fix --- lib_isar/lib_isar_post_rend.c | 3 ++- lib_rend/ivas_stat_rend.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 128675281..768b23089 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1792,10 +1792,11 @@ ivas_error ISAR_POST_REND_getSamples( } #ifndef DISABLE_LIMITER + Word32 limiter_thresold; #ifdef DEBUGGING hIvasRend->numClipping += #endif - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limiter_thresold = L_shl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 76e5633fc..ea4d0015a 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1475,6 +1475,10 @@ typedef struct Word32 release_heuristic_fx; /* Q30 */ Word32 attack_constant_fx; /* Q31 */ Word16 strong_saturation_count; +#ifdef DEBUGGING + int32_t cnt_frames_limited; /* counter of frames in which the limiter is applied */ +#endif + } IVAS_LIMITER, *IVAS_LIMITER_HANDLE; -- GitLab From 199c69ea70ac103aacd7519cf411417ae0618e53 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 6 Feb 2025 10:46:25 +1100 Subject: [PATCH 042/329] temporary fix to disable WMOPS in lc3plus to pass instrumentation build --- lib_lc3plus/basop_util_lc3plus.h | 8 +- lib_lc3plus/dec_lc3.c | 94 ++++++++++---------- lib_lc3plus/enc_lc3.c | 112 ++++++++++++------------ lib_lc3plus/functions.h | 1 + lib_lc3plus/plc_classify_fx.c | 16 ++-- lib_lc3plus/plc_phecu_fec_hq_fx.c | 106 +++++++++++----------- lib_lc3plus/plc_phecu_peak_locator_fx.c | 4 +- lib_lc3plus/plc_phecu_setf0hz_fx.c | 4 +- lib_lc3plus/plc_phecu_tools_fx.c | 44 +++++----- lib_lc3plus/plc_update_aft_imdct_fx.c | 78 ++++++++--------- lib_lc3plus/plc_update_fx.c | 100 ++++++++++----------- lib_lc3plus/plc_xcorr_fx.c | 8 +- lib_lc3plus/pvq_enc_fx.c | 4 +- lib_lc3plus/pvq_index_fx.c | 8 +- lib_lc3plus/sns_quantize_scf_fx.c | 20 ++--- 15 files changed, 304 insertions(+), 303 deletions(-) diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h index 5f4f5c56b..f22d531cf 100644 --- a/lib_lc3plus/basop_util_lc3plus.h +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -316,14 +316,14 @@ void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word void BASOP_rfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); void BASOP_irfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); -#if WMOPS +#if WMOPS_LC3PLUS extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #endif static __inline void basop_memcpy(void *dst, const void *src, size_t n) { -#if WMOPS +#if WMOPS_LC3PLUS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif /* check for overlapping memory */ @@ -333,7 +333,7 @@ static __inline void basop_memcpy(void *dst, const void *src, size_t n) static __inline void basop_memmove(void *dst, const void *src, size_t n) { -#if WMOPS +#if WMOPS_LC3PLUS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif memmove(dst, src, n); @@ -341,7 +341,7 @@ static __inline void basop_memmove(void *dst, const void *src, size_t n) static __inline void basop_memset(void *dst, int val, size_t n) { -#if WMOPS +#if WMOPS_LC3PLUS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif memset(dst, val, n); diff --git a/lib_lc3plus/dec_lc3.c b/lib_lc3plus/dec_lc3.c index 40818106e..59a061862 100644 --- a/lib_lc3plus/dec_lc3.c +++ b/lib_lc3plus/dec_lc3.c @@ -148,7 +148,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s memset(q_d_fx, 0, decoder->frame_length * sizeof(*q_d_fx)); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Decoder"); #endif @@ -164,18 +164,18 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s if (bfi != 1) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("Dec(bfi=0)"); #endif } else { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("Dec(bfi=1)"); #endif } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Entropy dec"); #endif IF (sub(bfi, 1) != 0) @@ -186,11 +186,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s BW_cutoff_idx_nf = BW_cutoff_idx; move16(); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); /* Entropy dec */ #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Ari dec"); #endif IF (sub(bfi, 1) != 0) @@ -243,11 +243,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processAriDecoderScaling_fx(sqQdec, decoder->yLen, q_d_fx, &q_fx_exp); } } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); /* Ari dec */ #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("SnsQuantScfDec"); #endif IF (sub(bfi, 1) != 0) @@ -260,11 +260,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q, currentScratch); #endif } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("PLC::ComputeStabFac"); #endif if (h_DecSetup->plcAd) @@ -272,11 +272,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processPLCcomputeStabFac_main(scf_q, h_DecSetup->plcAd->old_scf_q, h_DecSetup->plcAd->old_old_scf_q, bfi, h_DecSetup->prev_bfi, h_DecSetup->prev_prev_bfi, &h_DecSetup->plcAd->stab_fac); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Partial Concealment"); #endif IF (sub(bfi, 1) != 0) @@ -295,13 +295,13 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s &h_DecSetup->prev_gg_e, &BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns_fx, &h_DecSetup->pc_nbLostFramesInRow); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif IF (sub(bfi, 1) != 0) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Residual dec"); #endif processResidualDecoding_fx(q_d_fx, q_fx_exp, decoder->yLen, resBitBuf, fill_bits @@ -309,11 +309,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Noisefill"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ @@ -326,19 +326,19 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("applyGlobalGain"); #endif processApplyGlobalGain_fx(q_d_fx, &q_fx_exp, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Tns_dec"); #endif /* currentScratch Size = 48 bytes */ @@ -348,45 +348,45 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif #ifdef ENABLE_HR_MODE -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("SnsInterpScfDec"); #endif processSnsInterpolateScf_fx(scf_q_ip, int_scf_fx_ip, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Mdct shaping_dec"); #endif processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); processMdctShaping_fx(q_d_fx, int_scf_fx_ip, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif #else -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("SnsInterpScfDec"); #endif /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Mdct shaping_dec"); #endif processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); processMdctShaping_fx(q_d_fx, int_scf_fx, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* end int_scf_fx */ @@ -406,7 +406,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("PLC::Main"); #endif /* currentScratch Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ @@ -432,7 +432,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->alpha_type_2_table #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif @@ -446,7 +446,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("PLC/PC::DampingScrambling"); #endif if (h_DecSetup->plcAd) @@ -462,11 +462,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Imdct"); #endif /* currentScratch Size = 4 * MAX_LEN */ @@ -499,11 +499,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("PLC::Update"); #endif @@ -514,11 +514,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("LtpfDec"); #endif /* currentScratch Size = 0.5 * MAX_LEN + 20 bytes */ @@ -533,7 +533,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms, #endif currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif @@ -547,7 +547,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Output scaling"); #endif { @@ -579,15 +579,15 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } } } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); /* Output scaling */ #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); /* Decoder */ #endif @@ -623,7 +623,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo { fec_num_bytes = num_bytes; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("fec_dec"); #endif @@ -632,7 +632,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec, scratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif @@ -668,7 +668,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo { fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("fec_dec"); #endif @@ -679,7 +679,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo &decoder->n_pccw, &channel_bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec, scratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif diff --git a/lib_lc3plus/enc_lc3.c b/lib_lc3plus/enc_lc3.c index 30ff9971b..ada4bf87e 100644 --- a/lib_lc3plus/enc_lc3.c +++ b/lib_lc3plus/enc_lc3.c @@ -61,7 +61,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ # endif #endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Encoder"); #endif @@ -134,7 +134,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* Scale 24-bit input data */ IF (sub(bits_per_sample, 24) == 0) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Scale_signal24"); #endif scale_signal24_fx(s_in, s_in_scaled, &h_EncSetup->x_exp, h_EncSetup->stEnc_mdct_mem, @@ -142,7 +142,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, encoder->r12k8_mem_out_len, h_EncSetup->mdct_mem32, encoder->frame_length, h_EncSetup->resamp_mem32, h_EncSetup->olpa_mem_s12k8, &h_EncSetup->resamp_exp); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif } @@ -161,7 +161,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Mdct"); #endif @@ -174,12 +174,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif encoder->W_fx, encoder->W_size, h_EncSetup->stEnc_mdct_mem, encoder->stEnc_mdct_mem_len, d_fx, &d_fx_exp, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* begin s_12k8 */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Resamp12k8"); #endif /* currentScratch Size = 2.25 * MAX_LEN bytes */ @@ -198,11 +198,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ , bits_per_sample ); #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Olpa"); #endif /* currentScratch Size = 392 bytes */ @@ -212,11 +212,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ &h_EncSetup->pitch_flag, #endif h_EncSetup->resamp_exp, encoder->frame_dms, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("LtpfEnc"); #endif /* currentScratch Size = 512 bytes */ @@ -229,12 +229,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ,encoder->hrmode #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* end s_12k8 */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("AttackDetector"); #endif /* currentScratch Size = ??? bytes */ @@ -243,12 +243,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #else attack_detector_fx(encoder, h_EncSetup, s_in_scaled, sub(h_EncSetup->x_exp, 15), currentScratch); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* begin ener_fx */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("PerBandEnergy"); #endif /* currentScratch Size = 160 bytes */ @@ -258,11 +258,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ , encoder->hrmode #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Near Nyquist Detector"); #endif /* Near Nyquist Detector */ @@ -283,10 +283,10 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->ltpf_mem_ltpf_on = 0; move16(); ltpf_idx[1] = 0; move16(); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("BW Cutoff-Detection"); #endif IF (h_EncSetup->lfe == 0) @@ -311,11 +311,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ { BW_cutoff_idx = 0; } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("SnsCompScf"); #endif @@ -324,39 +324,39 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processSnsComputeScf_fx(ener_fx, ener_fx_exp, encoder->fs_idx, encoder->bands_number, scf, h_EncSetup->attdec_detected, encoder->attdec_damping, currentScratch, encoder->sns_damping ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("SnsQuantScfEnc"); #endif /* currentScratch Size = 500 bytes */ processSnsQuantizeScfEncoder_fx(scf, L_scf_idx, scf_q, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("SnsInterpScfEnc"); #endif /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 1, encoder->bands_number, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Mdct shaping_enc"); #endif processMdctShaping_fx(d_fx, int_scf_fx, int_scf_fx_exp, encoder->bands_offset, encoder->bands_number); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* end int_scf_fx_exp */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("BandwidthControl_enc"); #endif if (encoder->bandwidth < L_shr_pos(encoder->fs, 1)) @@ -364,10 +364,10 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ process_cutoff_bandwidth(d_fx, encoder->yLen, encoder->bw_ctrl_cutoff_bin); BW_cutoff_idx = s_min(BW_cutoff_idx, encoder->bw_index); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Tns_enc"); #endif /* currentScratch Size = 2 * MAX_LEN + 220 */ @@ -392,11 +392,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->tns_bits = tns_numfilters; move16(); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Est. Global Gain"); #endif /* currentScratch Size = 4 * MAX_LEN bytes */ @@ -430,12 +430,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ , encoder->hrmode, h_EncSetup->regBits, encoder->frame_dms #endif ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* begin q_d_fx16 */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Quant. 1"); #endif #ifdef ENABLE_HR_MODE @@ -448,11 +448,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->targetBitsAri, &h_EncSetup->mem_specBits, &nBits, encoder->fs_idx, &lastnz, codingdata, &lsbMode, -1); #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Adj. Global Gain"); #endif #ifdef ENABLE_HR_MODE @@ -466,11 +466,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processAdjustGlobalGain_fx(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, &gain_e, h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx); #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Quant. 2"); #endif IF (sub(gainChange, 1) == 0) @@ -485,11 +485,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ 0); #endif /* ENABLE_HR_MODE */ } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Res. Cod."); #endif IF (lsbMode == 0) @@ -516,11 +516,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ numResBits = 0; move16(); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Noise fac"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ @@ -543,21 +543,21 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ fac_ns_idx = 7; move16(); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Entropy cod"); #endif processEncoderEntropy(bytes, &bp_side, &mask_side, h_EncSetup->targetBitsAri, h_EncSetup->targetBytes, encoder->yLen, encoder->BW_cutoff_bits, tns_numfilters, lsbMode, lastnz, tns_order, fac_ns_idx, quantizedGain, BW_cutoff_idx, ltpf_idx, L_scf_idx, bfi_ext, encoder->fs_idx); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Ari cod"); #endif processAriEncoder_fx(bytes, bp_side, mask_side, h_EncSetup->targetBitsAri, @@ -568,17 +568,17 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif tns_order, tns_numfilters, indexes, lastnz, codingdata, resBits, numResBits, lsbMode, h_EncSetup->enable_lpc_weighting, currentScratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Reorder Bitstream Enc"); #endif test(); IF (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("Reorder Ari dec"); #endif @@ -606,17 +606,17 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); /* Ari dec */ #endif processReorderBitstream_fx(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, currentScratch); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif /* end q_d_fx16 */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif @@ -638,14 +638,14 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 if (encoder->epmode && encoder->combined_channel_coding == 0) { output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("fec_enc"); #endif fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, encoder->channel_setup[ch]->n_pccw, scratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif @@ -663,14 +663,14 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 { input_size = output_size; output_size = (Word32)encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_start("fec_enc"); #endif fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw, scratch); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_end(); #endif } diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h index 90571c6cd..940c58da7 100644 --- a/lib_lc3plus/functions.h +++ b/lib_lc3plus/functions.h @@ -833,4 +833,5 @@ void *balloc(void *base, size_t *base_size, size_t size); Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, Word16 frame_dms); #endif + #endif diff --git a/lib_lc3plus/plc_classify_fx.c b/lib_lc3plus/plc_classify_fx.c index bbb01826a..d30b516a4 100644 --- a/lib_lc3plus/plc_classify_fx.c +++ b/lib_lc3plus/plc_classify_fx.c @@ -45,7 +45,7 @@ static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_ { Word32 current_byte = 0; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PLC::array_insert_and_shift"); #endif @@ -58,7 +58,7 @@ static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_ current_byte = change_bit_at_position(current_byte, *bit_position, value); array[*byte_position] = current_byte; move16(); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -73,7 +73,7 @@ static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Wor Word32 current_byte_tdc = 0, current_byte_ns = 0; Word16 counter_loc_tdc = 0, counter_loc_ns = 0, counter_tmp = 0; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PLC::array_calculate"); #endif @@ -104,7 +104,7 @@ static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Wor #ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER *counter_phecu = sub(sub(overall_counter, counter_loc_tdc), counter_loc_ns); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -130,7 +130,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost Word32 class; ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PLC::processPLCclassify_fx"); #endif @@ -246,7 +246,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost } Dyn_Mem_Deluxe_Out(); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -268,7 +268,7 @@ Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, W Word16 *old_scf_q_mod_exp; Word16 *band_offsets_local; ); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PLC::spectral_centroid_fx_lc"); #endif @@ -415,7 +415,7 @@ Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, W # endif Dyn_Mem_Deluxe_Out(); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return sc; diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c index ca2a345f4..aaf6a9bd0 100644 --- a/lib_lc3plus/plc_phecu_fec_hq_fx.c +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -127,12 +127,12 @@ static Word16 plc_phEcu_nonpure_tone_ana_fx(const Word16* plocs, const Word16 static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 sinFactor, Word16 *re_out_ptr, Word16 *im_out_ptr) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::rotate_W16_fx"); #endif *re_out_ptr = msu_r(L_mult(re_in, cosFactor), im_in, sinFactor); /* 2 ops no move when inlined */ *im_out_ptr = mac_r(L_mult(re_in, sinFactor), im_in, cosFactor); /* 2 ops no move when inlined */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return; @@ -141,7 +141,7 @@ static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 s static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFactor, Word16 cosFactor) { Word16 scale_fx; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::valley_magnitude_adj_fx"); #endif @@ -158,7 +158,7 @@ static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFa *re_ptr = mult_r(scale_fx, shl_sat(*re_ptr, 1)); /* no moves , should be inlined */ *im_ptr = mult_r(scale_fx, shl_sat(*im_ptr, 1)); /* no moves , should be inlined */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return; @@ -188,7 +188,7 @@ Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::rand_phase_fx"); #endif @@ -201,7 +201,7 @@ Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return seed2; @@ -354,13 +354,13 @@ void trans_burst_ana_fx( if (time_offs == 0) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(1st)"); #endif } else { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(N)"); #endif } @@ -699,7 +699,7 @@ void trans_burst_ana_fx( L_acc = L_sub((INT32_MAX >> 1) + 1, L_mult0(alpha[k], alpha[k])); { - /* use lower complex(WMOPS/ROM) 2nd-order sqrt approximation */ + /* use lower complex(WMOPS_LC3PLUS/ROM) 2nd-order sqrt approximation */ Word32 L_man, L_acc2 = L_acc; Word16 tmp, expo_in, expo2, man_in, man; /* updated code using the 2nd order approximation routine */ @@ -797,7 +797,7 @@ void trans_burst_ana_fx( #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -826,7 +826,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::imax_fx"); #endif @@ -913,7 +913,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return posi; @@ -959,7 +959,7 @@ static Word16 imax_fx( /* o: The location, relative to the Word16 P_in_plocs; Word16 n_real_interp_tail; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::spec_ana_fx(1st)"); #endif #ifdef DYNMEM_COUNT @@ -1008,7 +1008,7 @@ static Word16 imax_fx( /* o: The location, relative to the rectLength = sub(Lprot, shl_pos(hamm_len2, 1)); /* The length of the rectangular portion of the Hamming-Rectangular window. */ { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::WhrAnaWin+fft"); #endif @@ -1016,7 +1016,7 @@ static Word16 imax_fx( /* o: The location, relative to the windowing_L(xfp, L_xfp, sp_ana_win, rectLength, hamm_len2); BASOP_rfftN(L_xfp, Lprot, &fft_scale, buffer_fft); } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); /* anawin+fft */ #endif @@ -1035,7 +1035,7 @@ static Word16 imax_fx( /* o: The location, relative to the basop_memset(xfp + stop_band_start, 0, (stop_band_length) * sizeof(Word16)); } - peak_range_1 = s_min(Lprot2p1, MAX_LPROT_RED / 2 + 1); /* limit preliminary only active for 48k to save WMOPS */ + peak_range_1 = s_min(Lprot2p1, MAX_LPROT_RED / 2 + 1); /* limit preliminary only active for 48k to save WMOPS_LC3PLUS */ basop_memmove(X_sav, xfp, (Lprot) * sizeof(Word16)); @@ -1052,7 +1052,7 @@ static Word16 imax_fx( /* o: The location, relative to the plc_phEcu_peak_locator_fx(xfp, peak_range_1, plocs, num_plocs, sens, Xmax, Xmin, MAX_LPROT_RED, buffer_fft); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::Peaks_refine"); #endif @@ -1173,7 +1173,7 @@ static Word16 imax_fx( /* o: The location, relative to the } } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); /* peaks refine */ #endif @@ -1217,7 +1217,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -1307,13 +1307,13 @@ static Word16 imax_fx( /* o: The location, relative to the if (time_offs == 0) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::subst_spec_fx(1st)"); #endif } else { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::subst_spec_fx(N)"); #endif } @@ -1669,7 +1669,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -1700,7 +1700,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::my_wtda_fx"); #endif @@ -1760,7 +1760,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return; @@ -1807,7 +1807,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::rec_wtda_fx"); #endif @@ -1849,7 +1849,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif @@ -1893,7 +1893,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::rec_frame_fx"); #endif @@ -1912,11 +1912,11 @@ static Word16 imax_fx( /* o: The location, relative to the fft_scale = -1; move16(); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::IFFT_fx"); #endif BASOP_irfftN(L_x, Lprot, &fft_scale, buffer_fft); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif @@ -1955,7 +1955,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return; @@ -2036,13 +2036,13 @@ static Word16 imax_fx( /* o: The location, relative to the if (!prev_bfi) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(1st)"); #endif } else { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(N)"); #endif } @@ -2244,7 +2244,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -2256,7 +2256,7 @@ static Word16 imax_fx( /* o: The location, relative to the { Word32 acc; Word16 z; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::sqrt2ndOrder"); #endif @@ -2268,7 +2268,7 @@ static Word16 imax_fx( /* o: The location, relative to the z = mac_r(acc, z, x); /* in Q15 */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return z; @@ -2297,7 +2297,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::windowing_L"); #endif @@ -2335,7 +2335,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -2359,7 +2359,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::windowing_ola"); #endif @@ -2375,7 +2375,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -2460,7 +2460,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::sqrtMagnApprox_fx"); #endif @@ -2478,7 +2478,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return sum; @@ -2520,7 +2520,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::fft_spec2_sqrt_approx_fx"); #endif @@ -2547,7 +2547,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return; @@ -2584,7 +2584,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::imax2_jacobsen_mag_fx"); #endif @@ -2667,7 +2667,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif return posi; /* Q15. The position either left or right relative to the index of the middle of the 3 given @@ -2692,7 +2692,7 @@ static Word16 imax_fx( /* o: The location, relative to the #define FHG_FFT_UPSHIFT 2 -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::intlvW32_2_flippedW16"); #endif #ifdef DYNMEM_COUNT @@ -2750,7 +2750,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -2766,7 +2766,7 @@ static Word16 imax_fx( /* o: The location, relative to the Counter numPairsLocal; Word32 *pX_L; Word16 *pX_re, *pX_im; -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::flippedW16_2_intlvW32"); #endif #ifdef DYNMEM_COUNT @@ -2802,7 +2802,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -2818,7 +2818,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_In("get_sin_cosQ10", sizeof(struct { Word16 sign_val, idx, idx2, idx3; })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::get_sin_cosQ10opt"); #endif @@ -2871,7 +2871,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } @@ -2902,7 +2902,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhEcu::nonpure_tone_ana_fx"); #endif @@ -3144,7 +3144,7 @@ static Word16 imax_fx( /* o: The location, relative to the } /* bands available*/ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif diff --git a/lib_lc3plus/plc_phecu_peak_locator_fx.c b/lib_lc3plus/plc_phecu_peak_locator_fx.c index 531ee8f6f..78a6ec281 100644 --- a/lib_lc3plus/plc_phecu_peak_locator_fx.c +++ b/lib_lc3plus/plc_phecu_peak_locator_fx.c @@ -65,7 +65,7 @@ void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 Word16 *fsc_idx; })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::peak_locator_fx(1st)"); #endif sc_idx = (Word16 *)scratchAlign(scratchBuffer, 0); /* ByteSize = 2 * (1+ inp_len+1) */ @@ -378,7 +378,7 @@ void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif } diff --git a/lib_lc3plus/plc_phecu_setf0hz_fx.c b/lib_lc3plus/plc_phecu_setf0hz_fx.c index 6fffe632c..264aa19c3 100644 --- a/lib_lc3plus/plc_phecu_setf0hz_fx.c +++ b/lib_lc3plus/plc_phecu_setf0hz_fx.c @@ -32,7 +32,7 @@ plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::plc_phEcuSetF0Hz_fx"); #endif @@ -50,7 +50,7 @@ plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif diff --git a/lib_lc3plus/plc_phecu_tools_fx.c b/lib_lc3plus/plc_phecu_tools_fx.c index 13e90fa49..32eff68f2 100644 --- a/lib_lc3plus/plc_phecu_tools_fx.c +++ b/lib_lc3plus/plc_phecu_tools_fx.c @@ -91,7 +91,7 @@ Word16 plc_phEcu_find_ind_fx( /* o : output maximum in const Word16 *inp, /* i : vector */ const Word16 len, /* i : length */ const Word16 val /* i : value to find */ -) +) { Word16 val_ind; Counter pos; @@ -149,37 +149,37 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ const Word16 *win, /* i: left side Window coefficients */ const Word16 rectLength, /* i: Offset in between the 1st and 2nd symmetric halves of the Hamming window */ const Word16 halfLength, /* i: Half of the total length of a complete Hamming window. */ - Word16 *exp /* i/o : i exp of Word16 variable x , o:Lexp of output Word32 sum */ + Word16 *exp /* i/o : i exp of Word16 variable x , o:Lexp of output Word32 sum */ ) { Counter i; - Word32 L_tot; + Word32 L_tot; const Word16 *pX, *pW; Word16 tmp, tmp_RL; #ifdef DYNMEM_COUNT Dyn_Mem_In("PhEcu::GF::winEnCalc", sizeof(struct { Counter i; - Word32 L_tot; + Word32 L_tot; const Word16 *pX, *pW; Word16 tmp, tmp_RL; })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::winEnCalc"); #endif L_tot = INT32_MAX; move32(); /*acc is on negative side , but as all accumulation is positive, we make use of one extra bit */ pX = x; pW = win; - + assert( headroom_shift>=0 ); FOR (i = 0; i < halfLength; i++) /* 1st symmetric half of the Hamming window */ { - tmp = mult(*pX++, *pW++); + tmp = mult(*pX++, *pW++); tmp = shr_pos(tmp, headroom_shift); /* shr may/create bias on the negative side , costly options are shr_r or use msu_r */ L_tot = L_msu0(L_tot, tmp, tmp); /* acc on negative energy side */ } @@ -189,7 +189,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ ASSERT(rectLength != 0); FOR (i = 0; i < tmp_RL; i++) /* If rectLength is zero, it's a pure Hamming window; otherwise Hamming-Rectangular. */ - { + { tmp = shr_pos( *pX++, headroom_shift); L_tot = L_msu0(L_tot, tmp, tmp); /* acc on negative side */ } @@ -199,49 +199,49 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ FOR (i = 0; i < tmp_RL; i++) /* 2nd symmetric half of the Hamming window. */ { - tmp = mult(*pX++, *(--pW)); + tmp = mult(*pX++, *(--pW)); tmp = shr_pos(tmp, headroom_shift); L_tot = L_msu0(L_tot, tmp, tmp); } /* Lexp = 2*(incoming_exp + dnshift) + 1 , 2x for square + 1(for msu0 DSP dn shift)*/ - *exp = add(shl_pos(add(*exp, headroom_shift),1),1); + *exp = add(shl_pos(add(*exp, headroom_shift),1),1); /* handle wrap on zero point */ IF( L_tot >= 0 ) { /* L_tot positive --> less than 32 bits needed, */ L_tot = L_add(L_tot,(INT32_MIN+1)); if( L_tot == 0 ) - { + { *exp = LTOT_MIN_EXP; /* WC is actually (-(15+4)*2 + 1 +1 -31) */ ; move16(); - } + } L_tot = L_min(L_tot, -1); /* make sure there is energy for future ratio calculations */ - } - ELSE + } + ELSE { /* L_tot negative --> more than 31 bits needed for sum , scale 32 bit sum within 31 bits and adjust exp */ - + L_tot = L_shr_pos(L_add(L_tot,1),1); /* rnd by adding 1, then use 50% contribution from negative side */ - L_tot = L_add(L_tot, INT32_MIN>>1); /* add 50% contribution from positive side */ - - *exp = add(*exp, 1); move16(); - } + L_tot = L_add(L_tot, INT32_MIN>>1); /* add 50% contribution from positive side */ + + *exp = add(*exp, 1); move16(); + } L_tot = L_max( -(INT32_MAX), L_tot); /* guard against max accumulation on the negative side , should only occur for rectangle windows */ L_tot = L_negate(L_tot); /* no saturation here */ - /* activate when xfp_exp is not used any longer */ + /* activate when xfp_exp is not used any longer */ /* pre-maximize the mantissa for the following steps in burst_ana_dx */ tmp = norm_l(L_tot); L_tot = L_shl(L_tot,tmp); *exp = sub(*exp, tmp); move16(); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif - + return L_tot; } diff --git a/lib_lc3plus/plc_update_aft_imdct_fx.c b/lib_lc3plus/plc_update_aft_imdct_fx.c index 663f491c9..6be74bb61 100644 --- a/lib_lc3plus/plc_update_aft_imdct_fx.c +++ b/lib_lc3plus/plc_update_aft_imdct_fx.c @@ -36,12 +36,12 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea - -#ifdef WMOPS + +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("processPLCUpdateAfterIMDCT "); #endif - - + + if (plcAd) { /* for short NB frames(2.5 ms) TDC-filtering requires more PCM samples than the plc_xcorr function */ @@ -78,7 +78,7 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea marginOldFront = getScaleFactor16_0(&(plcAd->x_old_tot_fx[plcAd->max_len_pcm_plc - usedHistlen + pastLen]), frontLen); scale_fac_old = s_min(marginOldFront, marginOldPast); - + frontLen = 0; move16(); logic16(); logic16(); IF(bfi == 1 && *prev_bfi == 0 && sub(concealMethod, LC3_CON_TEC_PHASE_ECU) == 0) @@ -155,12 +155,12 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea plcAd->PhECU_short_flag_prev = 0; move16(); /* fullband transient not active */ } } - + /* values may be {0,1,2} */ *prev_prev_bfi = *prev_bfi; move16(); *prev_bfi = bfi; move16(); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif @@ -233,28 +233,28 @@ static void processPLCcomputeStabFac(Word16 scf_q[], Word16 old_scf_q[], Word16 #endif } -void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx, Word16 xfp_exp_fx, Word16 margin_xfp, +void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx, Word16 xfp_exp_fx, Word16 margin_xfp, Word16 fs_idx, - Word32 *L_oold_xfp_w_E_fx, Word16 *oold_xfp_w_E_exp_fx, + Word32 *L_oold_xfp_w_E_fx, Word16 *oold_xfp_w_E_exp_fx, Word32 *L_old_xfp_w_E_fx, Word16 *old_xfp_w_E_exp_fx, - - Word16 *oold_Ltot_exp_fx ,Word16 *old_Ltot_exp_fx ) + + Word16 *oold_Ltot_exp_fx ,Word16 *old_Ltot_exp_fx ) { - Word32 L_tot ; + Word32 L_tot ; Word16 dn_scale, exp_shift; Word16 used_xfp_exp_fx; - Word16 exp_out ; + Word16 exp_out ; #ifdef DYNMEM_COUNT - Dyn_Mem_In("PLCUpdateXFP_w_E_hist", sizeof(struct { + Dyn_Mem_In("PLCUpdateXFP_w_E_hist", sizeof(struct { Word32 L_tot; Word16 dn_scale, exp_shift; Word16 used_xfp_exp_fx; - Word16 exp_out; + Word16 exp_out; })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::UpdateXfp_w_E_hist_fx"); #endif @@ -263,16 +263,16 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx if (sub(prev_bfi,1) == 0) { - /* only a single historic frame available in the next frame + /* only a single historic frame available in the next frame , force artifical update of oold energy to be the same as old */ *old_xfp_w_E_exp_fx = LTOT_INIT_FLAG ; move16(); } - /* Time shift energy state and xfp exp */ - IF (sub_sat(*old_xfp_w_E_exp_fx, LTOT_INIT_FLAG ) == 0) + /* Time shift energy state and xfp exp */ + IF (sub_sat(*old_xfp_w_E_exp_fx, LTOT_INIT_FLAG ) == 0) { - *L_oold_xfp_w_E_fx = LTOT_MIN_MAN ; move32(); - *oold_xfp_w_E_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL ; move16(); + *L_oold_xfp_w_E_fx = LTOT_MIN_MAN ; move32(); + *oold_xfp_w_E_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL ; move16(); } ELSE { @@ -281,10 +281,10 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx } /* Time shift L_tot energy state and L_tot_exp */ - IF (sub_sat(*old_Ltot_exp_fx, LTOT_INIT_FLAG ) == 0) + IF (sub_sat(*old_Ltot_exp_fx, LTOT_INIT_FLAG ) == 0) { - *L_oold_xfp_w_E_fx = LTOT_MIN_MAN ; move32(); - *oold_Ltot_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL ; move16(); + *L_oold_xfp_w_E_fx = LTOT_MIN_MAN ; move32(); + *oold_Ltot_exp_fx = UNINIT_OR_UNSAFE_OOLD_SENTINEL ; move16(); } ELSE { @@ -292,46 +292,46 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx *oold_Ltot_exp_fx = *old_Ltot_exp_fx; move16(); } - + dn_scale = e_tot_headroom[fs_idx]; /* allowed minimum dn_scale for a max upshifted signal */ - used_xfp_exp_fx = xfp_exp_fx; - + used_xfp_exp_fx = xfp_exp_fx; + IF( margin_xfp > 0 ) /* xfp_fx was normalized on a larger area than 16ms part of pcmBuffer */ - { + { ASSERT(bfi !=1) ; /* if bfi was set the margin_xfp does not reflect the correct 16ms part of pcm_buf hist, prev_synth */ - dn_scale = s_max(0, sub(e_tot_headroom[fs_idx], margin_xfp)); + dn_scale = s_max(0, sub(e_tot_headroom[fs_idx], margin_xfp)); exp_shift = sub(e_tot_headroom[fs_idx], dn_scale); used_xfp_exp_fx = sub(xfp_exp_fx, exp_shift); /* the virtual change of the xfp_buffer due to reduced downscaling in L_tot calc */ } - + /* use semifixed dn_scale as adjusted by margin_xfp in 16 ms region */ exp_out = xfp_exp_fx; move16(); L_tot = winEnCalc(xfp_fx, dn_scale , PhECU_wins[fs_idx][0], rectLengthTab[fs_idx], hamm_len2Tab[fs_idx], &exp_out ); - + *L_old_xfp_w_E_fx = L_tot; move32(); - *old_xfp_w_E_exp_fx = used_xfp_exp_fx ; move16(); + *old_xfp_w_E_exp_fx = used_xfp_exp_fx ; move16(); /* this now needs to be in Q1 , used_fx_exp , (exp_out-1-2*e_tot_headroom[fs_idx])/2 */ - *old_Ltot_exp_fx = exp_out; /* new proper _Ltot value from winEnCalc function */ + *old_Ltot_exp_fx = exp_out; /* new proper _Ltot value from winEnCalc function */ + - /* use true Word32 exponent of L_tot */ - - /* restart oold and old from same state for init or prevBFI cases */ + + /* restart oold and old from same state for init or prevBFI cases */ logic16(); IF (sub_sat(*oold_xfp_w_E_exp_fx, UNINIT_OR_UNSAFE_OOLD_SENTINEL) <= 0 || /* old xfp_Exp */ sub_sat(*oold_Ltot_exp_fx, UNINIT_OR_UNSAFE_OOLD_SENTINEL) <= 0 ) /* new L_tot_exp */ { *L_oold_xfp_w_E_fx = L_tot; move32(); - *oold_xfp_w_E_exp_fx = used_xfp_exp_fx; move16(); - *oold_Ltot_exp_fx = *old_Ltot_exp_fx; /* use Ltot exp value */ + *oold_xfp_w_E_exp_fx = used_xfp_exp_fx; move16(); + *oold_Ltot_exp_fx = *old_Ltot_exp_fx; /* use Ltot exp value */ } } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT diff --git a/lib_lc3plus/plc_update_fx.c b/lib_lc3plus/plc_update_fx.c index fb05770d5..b219aa674 100644 --- a/lib_lc3plus/plc_update_fx.c +++ b/lib_lc3plus/plc_update_fx.c @@ -22,10 +22,10 @@ void processPLCupdate_fx(AplcSetup *plcAd, Word16 x_fx[], Word16 q_fx_exp, Word1 scf_q, ns_cum_alpha, plcAd); /* NB *prev_bfi updated here */ IF ( plcAd != 0 ) - { + { /* reuse/inplace the most recent 16 ms of x_old_tot without additional rescaling, keep exponent aligned with tdc pitch buffer to save WMOPS */ - + #ifdef ENABLE_HR_MODE if (hrmode == 0) #endif @@ -57,14 +57,14 @@ void processPLCupdateSpec_fx(Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q Dyn_Mem_Deluxe_Out(); } -void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], Word16 yLen, +void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], Word16 yLen, Word16 *stPhECU_oold_grp_shape_fx, Word16 *stPhECU_old_grp_shape_fx) -#define L_GRP_DC 4 +#define L_GRP_DC 4 { - Counter i,l; - Word16 *pX, tmp; + Counter i,l; + Word16 *pX, tmp; Word16 N_grp,l_grp; Word16 man, expo; Word32 L_acc; @@ -72,12 +72,12 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W Word32 L_grp_shape[MAX_LGW]; Word16 grp_shape[MAX_LGW]; /**/ Word16 fs_idx,local_prev_bfi; - + #ifdef DYNMEM_COUNT Dyn_Mem_In("process_plc_spec_2_shape_fx", sizeof(struct { Counter i,l; - Word16 *pX; + Word16 *pX; Word16 N_grp,l_grp; Word32 L_acc; Word32 L_tot; @@ -85,7 +85,7 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W Word16 fs_idx,local_prev_bfi; })); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("PhECU::GF::process_plc_spec_2_shape_fx"); #endif @@ -95,77 +95,77 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W N_grp = xavg_N_grp_fx[fs_idx]; move16(); local_prev_bfi = prev_bfi; move16(); - if (sub(local_prev_bfi, 2)==0) + if (sub(local_prev_bfi, 2)==0) { local_prev_bfi = 0; move16(); } - if( stPhECU_oold_grp_shape_fx[0] < 0 ) + if( stPhECU_oold_grp_shape_fx[0] < 0 ) { - local_prev_bfi = 1 ; move16(); /* handle startup in the case 2nd frame is a BFI frame */ + local_prev_bfi = 1 ; move16(); /* handle startup in the case 2nd frame is a BFI frame */ } /* Copy old to oold grp shape */ - FOR( i=0; i < MAX_LGW ; i++) + FOR( i=0; i < MAX_LGW ; i++) { stPhECU_oold_grp_shape_fx[i] = stPhECU_old_grp_shape_fx[i]; move16(); - } - - + } + + /* Accumulate DC bin(s) to total */ - pX = q_old_d_fx; /* ptr setup */ + pX = q_old_d_fx; /* ptr setup */ L_tot = L_deposit_h(0); /* acc on negative side */ - + FOR( i= 0; i < L_GRP_DC; i++) { tmp = shr_pos(*pX++ ,spec_shape_headroom[fs_idx]); /* scale down upscaled MDCT to create some headroom */ - L_tot = L_msu0(L_tot, tmp, tmp); - + L_tot = L_msu0(L_tot, tmp, tmp); + } - + /* Accumulate middle subbands and add to total */ FOR( i=0; i < sub(N_grp,1) ; i++) { - + L_acc = L_deposit_h(0); /* acc on negative side */ l_grp = sub(mdct_grp_bins_fx[i+1], mdct_grp_bins_fx[i]); move16(); - + FOR(l=0;l= 0 && idx < R); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT @@ -183,7 +183,7 @@ static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, Word16 *st1_idx0Ptr, Word16 *st1_idx1Ptr) { -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("processQuantize_stage1ScfEncStage1_fx"); #endif @@ -201,7 +201,7 @@ static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, *st1_idx1Ptr, st1_vector); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif @@ -306,7 +306,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( shape_far = (Word16 *)scratchAlign(pulses_far, sizeof(*pulses_far) * M); /* Size = 2 * M */ #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("pvq_enc_find_best_submode_pre_post_fx"); #endif @@ -414,7 +414,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( *sub_mode_ptr = extract_l(L_section); move16(); /* 0,1,2,3 */ -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT @@ -505,7 +505,7 @@ static void processQuantize_stage2ScfEncStage2_fx( proc_target_lp = (Word16 *)buffer_pvq_enc_find_best_submode_pre_post_fx; /* size = 2*M */ #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("processQuantize_stage2ScfEncStage2_fx"); #endif @@ -631,7 +631,7 @@ static void processQuantize_stage2ScfEncStage2_fx( L_prm_idx[2] = L_deposit_l(enc_PVQ_OA.lead_sign_ind); /* LS shape single bit */ } -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT @@ -676,7 +676,7 @@ static Word16 scfdec_stage2_fx( /* o: ber flag */ ); #endif -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_start("scfdec_stage2_fx"); #endif @@ -740,7 +740,7 @@ static Word16 scfdec_stage2_fx( /* o: ber flag */ /* scaling aligend with encoder search */ pvq_dec_scale_vec_fx(dec_adj_glob_vec, gValQ13, st2_vector); -#ifdef WMOPS +#ifdef WMOPS_LC3PLUS BASOP_sub_sub_end(); #endif Dyn_Mem_Deluxe_Out(); -- GitLab From 480eae02f1a8c25a2d2c4a5fb5a61051b98f9b2a Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 6 Feb 2025 13:45:17 +1100 Subject: [PATCH 043/329] another attempt to resolve lc3plus intrumentation erros, fix for SBA pytests --- lib_dec/ivas_binRenderer_internal.c | 33 +++++++++++++++++++++++------ lib_lc3plus/defines.h | 1 - lib_lc3plus/setup_dec_lc3.h | 18 ++++++++-------- lib_lc3plus/setup_enc_lc3.h | 20 ++++++++--------- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index c31f0cbf7..70f8219f9 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -554,16 +554,35 @@ static ivas_error ivas_binRenderer_convModuleOpen( } #ifdef SPLIT_REND_WITH_HEAD_ROT - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + } + } + } + } + ELSE + { + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + } } } } diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index ebf538b71..2d280620f 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -725,7 +725,6 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #endif #define scratchAlign(ptr, offset) (void *)(((uintptr_t)(ptr) + (offset) + 0x3) & ~0x3) -#define ALIGN_BUFFER_STRUCT /* some configurations leave empty translation units. */ diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h index 5c36163d3..3145cd21c 100644 --- a/lib_lc3plus/setup_dec_lc3.h +++ b/lib_lc3plus/setup_dec_lc3.h @@ -28,9 +28,9 @@ typedef struct Word16 tdc_preemph_fac; Word16 tdc_lpc_order; Word16 cum_fflcAtten; - Word16 harmonicBuf_fx[MAX_PITCH] ALIGN_BUFFER_STRUCT; + Word16 harmonicBuf_fx[MAX_PITCH]; Word16 harmonicBuf_Q; - Word16 synthHist_fx[M] ALIGN_BUFFER_STRUCT; + Word16 synthHist_fx[M]; Word16 cum_fading_slow; Word16 cum_fading_fast; Word16 PhECU_LprotOrg_fx; /* needed to change the Prot size adaptively */ @@ -63,17 +63,17 @@ typedef struct Word32 PhECU_L_old_xfp_w_E_fx; Word16 PhECU_oold_xfp_w_E_exp_fx; /* input Word16 xfp exponnet */ Word16 PhECU_old_xfp_w_E_exp_fx; - Word16 PhECU_oold_grp_shape_fx[MAX_LGW] ALIGN_BUFFER_STRUCT; - Word16 PhECU_old_grp_shape_fx[MAX_LGW] ALIGN_BUFFER_STRUCT; + Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; + Word16 PhECU_old_grp_shape_fx[MAX_LGW]; Word16 PhECU_margin_xfp; #ifdef CR8_A_PLC_FADEOUT_TUNING Word16 PhECU_nonpure_tone_flag; /* non-pure single tone indicator state */ #endif - Word16 PhECU_mag_chg_1st[MAX_LGW] ALIGN_BUFFER_STRUCT; - Word16 PhECU_Xavg[MAX_LGW] ALIGN_BUFFER_STRUCT; - Word16 old_scf_q[M] ALIGN_BUFFER_STRUCT; - Word16 old_old_scf_q[M] ALIGN_BUFFER_STRUCT; - Word16 tdc_A[M + 1] ALIGN_BUFFER_STRUCT; + Word16 PhECU_mag_chg_1st[MAX_LGW]; + Word16 PhECU_Xavg[MAX_LGW]; + Word16 old_scf_q[M]; + Word16 old_old_scf_q[M]; + Word16 tdc_A[M + 1]; /* for now 20 ms saved Q14 or ptr to a combined ifft win and MDCT preTDA synthesis window 16 ms */ #ifdef CR8_A_PLC_FADEOUT_TUNING diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h index 5e89829da..34e26a59d 100644 --- a/lib_lc3plus/setup_enc_lc3.h +++ b/lib_lc3plus/setup_enc_lc3.h @@ -53,24 +53,24 @@ typedef struct Word16 attdec_scaling; #ifdef ENABLE_HR_MODE Word16 regBits; - Word32 resamp_mem32[120] ALIGN_BUFFER_STRUCT; + Word32 resamp_mem32[120]; #else - Word32 resamp_mem32[60] ALIGN_BUFFER_STRUCT; + Word32 resamp_mem32[60]; #endif #ifdef ENABLE_HR_MODE - Word16 r12k8_mem_in[120] ALIGN_BUFFER_STRUCT; + Word16 r12k8_mem_in[120]; #else - Word16 r12k8_mem_in[60] ALIGN_BUFFER_STRUCT; + Word16 r12k8_mem_in[60]; #endif - Word32 r12k8_mem_50[2] ALIGN_BUFFER_STRUCT; + Word32 r12k8_mem_50[2]; #ifdef CR8_G_ADD_75MS - Word16 r12k8_mem_out[44] ALIGN_BUFFER_STRUCT; + Word16 r12k8_mem_out[44]; #else - Word16 r12k8_mem_out[24] ALIGN_BUFFER_STRUCT; + Word16 r12k8_mem_out[24]; #endif - Word16 olpa_mem_s12k8[3] ALIGN_BUFFER_STRUCT; - Word16 olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16] ALIGN_BUFFER_STRUCT; - Word16 ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1] ALIGN_BUFFER_STRUCT; + Word16 olpa_mem_s12k8[3]; + Word16 olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16]; + Word16 ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1]; Word16 n_pccw; Word16 n_pc; -- GitLab From c3fe889e83d2b0eb82f43be5f7951644c8643bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Mon, 13 Jan 2025 12:14:40 +0100 Subject: [PATCH 044/329] Port CI jobs relevant for split rendering --- .gitlab-ci.yml | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4fe5ec338..c8df11fcb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -190,6 +190,17 @@ stages: - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h - fi +.mr-get-target-commit: &mr-get-target-commit # compare to last target branch commit before pipeline was created + - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H) + +.get-commits-behind-count: &get-commits-behind-count + - echo $CI_COMMIT_SHA + - echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - commits_behind_count=$(git rev-list --count $CI_COMMIT_SHA..origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) + +.check-commits-behind-count-in-compare-jobs: &check-commits-behind-count-in-compare-jobs + - if [ $commits_behind_count -ne 0 ]; then echo "Your branch is not up-to-date with main -> Compare tests will not run as they can contain false negatives this way.\nMain might have changed during your pipeline run. Run 'git merge origin/main' to update."; exit 1; fi + .build-reference-binaries: &build-reference-binaries - current_commit_sha=$(git rev-parse HEAD) ### build reference binaries @@ -244,6 +255,13 @@ stages: - echo "Applying level scaling in scripts/testv using scale=$LEVEL_SCALING" - tests/scale_pcm.py ./scripts/testv/ $LEVEL_SCALING +.merge-request-comparison-check: &merge-request-comparison-check + - echo "--------------- Running merge-request-comparison-check anchor ---------------" + - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi + - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "Non-bitexact cases without non-BE tag encountered!"; exit $EXIT_CODE_FAIL; fi + - if [ $exit_code -eq 1 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi + - exit 0 + .update-ltv-repo: &update-ltv-repo - cd $LTV_DIR - git pull @@ -951,6 +969,93 @@ build-codec-linux-debugging-make: - *activate-debug-mode-info-if-set - make -j +# --------------------------------------------------------------- +# Test jobs for merge requests +# --------------------------------------------------------------- + +lc3-wrapper-unit-test: + extends: + - .test-job-linux + - .rules-merge-request + needs: ["build-codec-linux-cmake"] + stage: test + script: + - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j + - scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test + +# compare split-rendering bitexactness between target and source branch +split-rendering-pytest-on-merge-request: + extends: + - .test-job-linux-needs-testv-dir + - .rules-merge-request + needs: ["build-codec-linux-make"] + # TODO: set reasonable timeout, will most likely take less + timeout: "30 minutes" + stage: compare + script: + - *print-common-info + - *get-commits-behind-count + - *check-commits-behind-count-in-compare-jobs + + # some helper variables - "|| true" to prevent failures from grep not finding anything + # write to temporary file as workaround for failures observed with piping echo + - echo $CI_MERGE_REQUEST_TITLE > tmp.txt + - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true + - ref_using_main=$(grep -c --ignore-case "\[ref[ -]*using[ -]*main\]" tmp.txt) || true + + # store the current commit hash + - source_branch_commit_sha=$(git rev-parse HEAD) + + - *mr-fetch-target-branch + - *mr-get-target-commit + - git checkout $target_commit + - echo "Building reference codec at commit $target_commit" + + # build reference binaries + - make -j + - mv IVAS_cod IVAS_cod_ref + - mv IVAS_dec IVAS_dec_ref + - mv IVAS_rend IVAS_rend_ref + + ### If ref_using_main is not set, checkout the source branch to use scripts and input from there + - if [ $ref_using_main == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts + - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi + - exit_code=0 + - testcase_timeout=60 + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? + + # back to source branch + - git restore lib_com/options.h # Revert changes back before checking out another branch to avoid conflicts + - git checkout $source_branch_commit_sha + - make clean + - make -j + + ### Run test using scripts and input from main + - if [ $ref_using_main == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts + - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi + + # run test + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? + - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true + + - *merge-request-comparison-check + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 2 week + when: always + paths: + - report-junit.xml + - report.html + expose_as: "pytest split rendering results" + reports: + junit: + - report-junit.xml + # --------------------------------------------------------------- # Short test jobs that run in merge request pipelines # --------------------------------------------------------------- -- GitLab From 00636b34a9113f33bc80e7d3870f6a46f1be969e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Mon, 13 Jan 2025 12:17:10 +0100 Subject: [PATCH 045/329] fixup! Port CI jobs relevant for split rendering --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8df11fcb..2b2a1ea0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -292,6 +292,44 @@ stages: - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } +# --------------------------------------------------------------- +# Job templates +# --------------------------------------------------------------- + +# When designing templates, try not to use too much inheritance and +# if multiple templates and extended on, remember that on conflict, +# latest overwrites the parameter. + +# templates for rules +.rules-basis: + rules: + - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined) + when: never + - if: $CI_PIPELINE_SOURCE == 'schedule' # Don't run in any scheduled pipelines by default (use schedule templates below to enable again for certain conditions) + when: never + - if: $CI_PIPELINE_SOURCE == 'trigger' # Don't run triggered pipeline by default + when: never + - if: $MANUAL_PIPELINE_TYPE == 'test-be-release' # Skip all the normal jobs when testing manually against release codec + when: never + - if: $MANUAL_PIPELINE_TYPE == 'test-long-self-test' # Skip all the normal jobs when testing manually against release codec + when: never + - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance-linux' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'check-clipping' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'test-branch-vs-input-passthrough' + when: never + - when: on_success + +.rules-merge-request: + extends: .rules-basis + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + .rules-pytest-to-ref-short: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" -- GitLab From 3e5671a33bcf228367ee91768dac60def6d135c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Mon, 13 Jan 2025 12:18:40 +0100 Subject: [PATCH 046/329] fixup! fixup! Port CI jobs relevant for split rendering --- .gitlab-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b2a1ea0a..1c5981540 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1015,11 +1015,10 @@ lc3-wrapper-unit-test: extends: - .test-job-linux - .rules-merge-request - needs: ["build-codec-linux-cmake"] + needs: ["build-codec-linux-make"] stage: test script: - - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - - cmake --build cmake-build -- -j + - make -j - scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test # compare split-rendering bitexactness between target and source branch -- GitLab From 5d8c9e1e2cdce9017a370415d3f8c4c44521389c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Thu, 16 Jan 2025 13:12:41 +0100 Subject: [PATCH 047/329] Change ref_using_main to ref_using_target --- .gitlab-ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c5981540..8099d6e68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1039,7 +1039,9 @@ split-rendering-pytest-on-merge-request: # write to temporary file as workaround for failures observed with piping echo - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true - - ref_using_main=$(grep -c --ignore-case "\[ref[ -]*using[ -]*main\]" tmp.txt) || true + - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now + - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true + - ref_using_target=0 # store the current commit hash - source_branch_commit_sha=$(git rev-parse HEAD) @@ -1055,9 +1057,9 @@ split-rendering-pytest-on-merge-request: - mv IVAS_dec IVAS_dec_ref - mv IVAS_rend IVAS_rend_ref - ### If ref_using_main is not set, checkout the source branch to use scripts and input from there - - if [ $ref_using_main == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi + ### If ref_using_target is not set, checkout the source branch to use scripts and input from there + - if [ $ref_using_target == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts + - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi - exit_code=0 - testcase_timeout=60 - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? @@ -1069,8 +1071,8 @@ split-rendering-pytest-on-merge-request: - make -j ### Run test using scripts and input from main - - if [ $ref_using_main == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi + - if [ $ref_using_target == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts + - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi # run test - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? -- GitLab From 4e95e04085b8c7d386f13c6683a204db40e827b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Thu, 16 Jan 2025 13:21:17 +0100 Subject: [PATCH 048/329] fixup! Change ref_using_main to ref_using_target --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8099d6e68..e00469dd7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1039,8 +1039,8 @@ split-rendering-pytest-on-merge-request: # write to temporary file as workaround for failures observed with piping echo - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true - - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true + # TODO: ref_using_target comes from float repo, but does not apply here - disable for now + # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - ref_using_target=0 # store the current commit hash -- GitLab From c4eaca8a9e0a539c60478d4612477703f5e1cbe1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 08:21:07 +0100 Subject: [PATCH 049/329] disable no-commits-for-draft-MRs rule --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e00469dd7..bde6d4017 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,6 +60,9 @@ workflow: # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" when: never + # do not spawn pipelines for Draft MRs, see https://docs.gitlab.com/ee/ci/yaml/workflow.html#skip-pipelines-for-draft-merge-requests + # - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + # when: never - if: $CI_PIPELINE_SOURCE == 'merge_request_event' variables: IVAS_PIPELINE_NAME: 'MR pipeline: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME' -- GitLab From 719d24315bbebbf81cb78e5fbd0db4869460bcee Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 08:23:35 +0100 Subject: [PATCH 050/329] add split rendering smoke test --- .gitlab-ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bde6d4017..4dea76c7e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1014,6 +1014,27 @@ build-codec-linux-debugging-make: # Test jobs for merge requests # --------------------------------------------------------------- +split-rendering-smoke-test: + extends: + - .test-job-linux + - .rules-merge-request + needs: ["build-codec-linux-make"] + stage: test + script: + - make -j + - testcase_timeout=10 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "split rendering smoke results" + reports: + junit: + - report-junit.xml + lc3-wrapper-unit-test: extends: - .test-job-linux -- GitLab From cfcc9d4161bd3401fd85199f6b31b2fb8cee215f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 08:25:06 +0100 Subject: [PATCH 051/329] use cmake for building the lc3 unit test --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4dea76c7e..a151f781b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1042,7 +1042,8 @@ lc3-wrapper-unit-test: needs: ["build-codec-linux-make"] stage: test script: - - make -j + - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j - scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test # compare split-rendering bitexactness between target and source branch -- GitLab From e2119544aa151f2e8a2ee837c774c3ee2703eed9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 5 Feb 2025 08:28:46 +0100 Subject: [PATCH 052/329] add needed script anchors --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a151f781b..c2e74f6f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1021,6 +1021,9 @@ split-rendering-smoke-test: needs: ["build-codec-linux-make"] stage: test script: + - *print-common-info + - *update-scripts-repo + - make -j - testcase_timeout=10 - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout @@ -1042,6 +1045,9 @@ lc3-wrapper-unit-test: needs: ["build-codec-linux-make"] stage: test script: + - *print-common-info + - *update-scripts-repo + - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - cmake --build cmake-build -- -j - scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test @@ -1057,6 +1063,7 @@ split-rendering-pytest-on-merge-request: stage: compare script: - *print-common-info + - *update-scripts-repo - *get-commits-behind-count - *check-commits-behind-count-in-compare-jobs -- GitLab From efe6375a9d6a5d50e2d671de4515515777ad3ac2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 6 Feb 2025 09:57:18 +0100 Subject: [PATCH 053/329] add CMakeLists file --- CMakeLists.txt | 221 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..17799f0db --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,221 @@ +# CMake file for IVAS +# +# Usage with Unix Makefiles (Linux, OS/X): +# # create build directory +# mkdir build ; cd build +# # call CMake to generate build system, e.g. one of the following: +# cmake -D CMAKE_BUILD_TYPE=Debug ../ +# cmake -D CMAKE_BUILD_TYPE=Release ../ +# cmake -D CMAKE_BUILD_TYPE=Debug -D TARGET_PLATFORM=x86_64 ../ +# # build project +# make -j8 +# +# Usage with Visual Studio +# 1) download CMake from https://cmake.org/download/, don't use the Cygwin version! +# 2.1) build project using IDE +# In CMake GUI select the source dir (root of stereo-evs) and a new binary directory +# and press "Configure" and "Generate". Then open the Visual Studio solution file generated +# in the build directory. +# 2.2) build project using command line +# # create build directory +# mkdir build ; cd build +# # call CMake to generate build system, e.g. one of the following: +# cmake ../ +# cmake -G "Visual Studio 12 2013" ../ +# cmake -G "Visual Studio 12 2013 Win64" ../ +# # open the Visual Studio solution file generated in the build directory +# # or build on command line, e.g.: +# cmake --build . --config Debug +# cmake --build . --config Release + + +cmake_minimum_required(VERSION 3.1) + +set(CMAKE_C_STANDARD 99) + +# configuration options for UNIX +if(UNIX) + set(TARGET_PLATFORM "" CACHE STRING "i686 / x86_64") + set(CLANG "" CACHE STRING "1=msan / 2=asan / 3=usan") + set(GCOV OFF CACHE BOOL "enable GCOV") + set(STRIP OFF CACHE BOOL "enable STRIP") + + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") + endif() + # TARGET_PLATFORM + if("${TARGET_PLATFORM}" MATCHES "i386" OR + "${TARGET_PLATFORM}" MATCHES "i586" OR + "${TARGET_PLATFORM}" MATCHES "i686" + ) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + elseif("${TARGET_PLATFORM}" MATCHES "x86_64") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64") + endif() + # C compiler flags + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-contract=off") # disable floating point operation contraction + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + # to be uncommented in CI + # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + + # CLANG + if(CLANG) + find_program(clangBin NAMES /home/amm-archiv/soft/Linux/clang/current/bin/clang clang REQUIRED) + set(CMAKE_C_COMPILER "${clangBin}" CACHE STRING "") + if("${CLANG}" MATCHES "1" OR "${CLANG}" MATCHES "msan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory") + elseif("${CLANG}" MATCHES "2" OR "${CLANG}" MATCHES "asan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + elseif("${CLANG}" MATCHES "3" OR "${CLANG}" MATCHES "usan") + # NOTE: keep in sync with list in Makefile + set(USAN_CHECKS_ENABLE + undefined # Default checks + # Extra checks + float-divide-by-zero + implicit-conversion + local-bounds + ) + list(JOIN USAN_CHECKS_ENABLE "," USAN_CHECKS_ENABLE) + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${USAN_CHECKS_ENABLE} -fsanitize-recover=${USAN_CHECKS_ENABLE}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${USAN_CHECKS_ENABLE} -fsanitize-recover=${USAN_CHECKS_ENABLE}") + else() + message(FATAL_ERROR "Unknown CLANG setting: ${CLANG}") + endif() + endif() + # GCOV + if(GCOV) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") + endif() + # STRIP + if(STRIP) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-gc-sections -static") + endif() + + message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") + message("CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") + # write settings in CMake cache + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g3" CACHE STRING "") + set(CMAKE_C_FLAGS_RELEASE "-O2 -DRELEASE" CACHE STRING "") # TODO should contain -DNDEBUG to disable assert() +elseif(WIN32) + # MSVC compiler flags + add_definitions( + -D_CRT_SECURE_NO_WARNINGS + /MP + ) +endif() + +# configuration options for all platforms +set(WMOPS OFF CACHE BOOL "enable WMOPS") +if(WMOPS) + add_definitions("-DWMOPS=1") +endif() + +project(stereo-evs) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) # make Visual Studio projects look nicer +include(CTest) + +file(GLOB libComSrcs "lib_com/*.c") +file(GLOB libComHeaders "lib_com/*.h") +add_library(lib_com ${libComSrcs} ${libComHeaders}) +if(UNIX) + target_link_libraries(lib_com PRIVATE m) +endif() +target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lib_isar) +target_include_directories(lib_com PRIVATE lib_lc3plus) + +file(GLOB libDebugSrcs "lib_debug/*.c") +file(GLOB libDebugHeaders "lib_debug/*.h") +add_library(lib_debug ${libDebugSrcs} ${libDebugHeaders}) +target_link_libraries(lib_debug lib_com) +target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend lib_isar) + +file(GLOB libEncSrcs "lib_enc/*.c") +file(GLOB libEncHeaders "lib_enc/*.h") +add_library(lib_enc ${libEncSrcs} ${libEncHeaders}) +target_link_libraries(lib_enc lib_com lib_debug) +target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lib_isar) +target_include_directories(lib_enc PRIVATE lib_lc3plus) + +file(GLOB libLC3plusSrcs "lib_lc3plus/*.c") +file(GLOB libLC3plusHeaders "lib_lc3plus/*.h") +add_library(lib_lc3plus ${libLC3plusSrcs} ${libLC3plusHeaders}) +target_include_directories(lib_lc3plus PUBLIC lib_lc3plus PRIVATE lib_com lib_debug) + +file(GLOB libRendSrcs "lib_rend/*.c") +file(GLOB libRendHeaders "lib_rend/*.h") + +add_library(lib_rend ${libRendSrcs} ${libRendHeaders}) +target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed. +target_link_libraries(lib_rend lib_lc3plus lib_isar) +target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc lib_isar) + + +file(GLOB libDecSrcs "lib_dec/*.c") +file(GLOB libDecHeaders "lib_dec/*.h") +add_library(lib_dec ${libDecSrcs} ${libDecHeaders}) +target_link_libraries(lib_dec lib_com lib_rend lib_debug lib_isar) +target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc lib_isar) + +file(GLOB libUtilSrcs "lib_util/*.c") +file(GLOB libUtilHeaders "lib_util/*.h") +add_library(lib_util ${libUtilSrcs} ${libUtilHeaders}) +target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug) +target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar) + +if(NOT WMOPS) + add_executable(ivas_lc3plus_unit_test ${CMAKE_SOURCE_DIR}/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test.c) + target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_debug lib_isar) +endif() + +file(GLOB libISARSrcs "lib_isar/*.c") +file(GLOB libISARHeaders "lib_isar/*.h") + +add_library(lib_isar ${libISARSrcs} ${libISARHeaders}) +target_link_libraries(lib_isar lib_com lib_debug lib_lc3plus) # Todo refactor: This dependency on lib_dec should be removed. +target_include_directories(lib_isar PUBLIC lib_isar PRIVATE lib_enc lib_dec lib_rend) + + +add_executable(IVAS_cod apps/encoder.c) +target_link_libraries(IVAS_cod lib_enc lib_util) +if(WIN32) + target_link_libraries(IVAS_cod Ws2_32) +endif() + +add_executable(IVAS_dec apps/decoder.c) +target_link_libraries(IVAS_dec lib_dec lib_util) +if(WIN32) + target_link_libraries(IVAS_dec Ws2_32) +endif() + +add_executable(IVAS_rend apps/renderer.c) +target_link_libraries(IVAS_rend lib_rend lib_util lib_isar) +target_include_directories(IVAS_rend PRIVATE lib_enc) + +add_executable(ISAR_post_rend apps/isar_post_rend.c) +target_link_libraries(ISAR_post_rend lib_isar lib_util) +target_include_directories(ISAR_post_rend PRIVATE lib_isar) + +if(COPY_EXECUTABLES_FROM_BUILD_DIR) + # Optionally copy executables to the same place where Make puts them (useful for tests that expect executables in specific places) + add_custom_command(TARGET IVAS_cod POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET IVAS_dec POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET ISAR_post_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + if (NOT WMOPS) + add_custom_command(TARGET ivas_lc3plus_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/split_rendering/lc3plus") + endif() +endif() + +# Allow creating packages for CMake install +install(TARGETS lib_enc lib_dec lib_rend lib_com lib_util ARCHIVE DESTINATION lib) -- GitLab From 8d14bce5907700aa296db9634ad20e093adc309f Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 13:03:40 +0100 Subject: [PATCH 054/329] some push/pop wmops added, also addedd FIX_1072_SPEEDUP_gainpanning and FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB active --- lib_com/ivas_dirac_com.c | 51 +++++++++++++ lib_com/options.h | 6 +- lib_dec/ivas_dirac_dec.c | 23 ++++-- lib_rend/ivas_dirac_output_synthesis_dec.c | 89 +++++++++++++++++++++- 4 files changed, 160 insertions(+), 9 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index ebd958e1b..796fc8960 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -960,6 +960,7 @@ void computeDiffuseness_fixed( q_intensity = add( q_factor_intensity[0], min_q_shift2 ); move16(); + push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness B <<-|" ); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ @@ -967,6 +968,28 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_energy[i], min_q_shift1 ); + +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB + Word16 shift_q = sub( q_tmp, q_ene ); + Word32 shiftEquiv; + Word16 shift_qtotal; + if( shift_q < 0 ) + { + shiftEquiv = L_lshl( 0x80000000, shift_q ); + shift_qtotal = sub( min_q_shift1, 0 ); + } + if( shift_q >= 0 ) + { + shiftEquiv = L_add( 0x7FFFFFFF, 0 ); + shift_qtotal = sub( min_q_shift1, shift_q ); + } + FOR( k = 0; k < num_freq_bands; k++ ) + { + tmp = L_shl( p_tmp_c[k], shift_qtotal ); + energy_slow[k] = Madd_32_32_r( tmp, energy_slow[k], shiftEquiv ); + move32(); + } +#else Word16 shift_q = sub( q_tmp, q_ene ); IF( shift_q < 0 ) { @@ -986,6 +1009,9 @@ void computeDiffuseness_fixed( move32(); } } +#endif + + q_ene = s_min( q_ene, q_tmp ); @@ -993,6 +1019,28 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_intensity[i], min_q_shift2 ); shift_q = sub( q_tmp, q_intensity ); +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB + if( shift_q >= 0 ) + { + shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); + shift_qtotal = sub( min_q_shift2, shift_q ); + } + if ( shift_q < 0 ) + { + shiftEquiv = L_lshl( 0x80000000, shift_q ); + shift_qtotal = sub( min_q_shift2, 0 ); + } + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) + { + p_tmp = buffer_intensity[j][i]; + FOR( k = 0; k < num_freq_bands; k++ ) + { + tmp = L_shl( p_tmp[k], shift_qtotal ); + intensity_slow[j * num_freq_bands + k] = Madd_32_32_r( tmp, intensity_slow[j * num_freq_bands + k], shiftEquiv ); + move32(); + } + } +#else IF( shift_q > 0 ) { FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) @@ -1019,8 +1067,11 @@ void computeDiffuseness_fixed( } } } +#endif + q_intensity = s_min( q_intensity, q_tmp ); } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness B <<-|" );/*/ min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); min_q_shift1 = sub( min_q_shift1, idiv1616( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 2 ) ); diff --git a/lib_com/options.h b/lib_com/options.h index fa1fd8f4e..5dfebfaa6 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -56,7 +56,7 @@ #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -/*#define WMOPS*/ /* Activate complexity and memory counters */ +//#define WMOPS /* Activate complexity and memory counters */ #ifdef WMOPS /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ /*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ @@ -153,3 +153,7 @@ #define FIX_881_HILBERT_FILTER /* VA: improve the precision of the Hilbert filter to remove 2kHz unwanted tone */ #endif #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ + + +#define FIX_1072_SPEEDUP_gainpanning /* FhG: WMOPS tuning, in development*/ +#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* "-" */ \ No newline at end of file diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 95cca12a0..318a3ec55 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2231,7 +2231,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); Word16 tmp1; - push_wmops( "ivas_dirac_dec_render" ); + push_wmops( "ivas_dirac_dec_render (IDR)" ); /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; @@ -2341,6 +2341,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE IF( !( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { + push_wmops( "(IDR) SBA_FORMAT | SBA_ISM_FORMAT" ); Word16 outchannels; idx_lfe = 0; move16(); @@ -2409,6 +2410,7 @@ void ivas_dirac_dec_render_sf_fx( } } } + pop_wmops(); /*push_wmops( "(IDR) SBA_FORMAT | SBA_ISM_FORMAT" );*/ } size = imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ); @@ -2555,7 +2557,7 @@ void ivas_dirac_dec_render_sf_fx( p_Rmat_fx = 0; move32(); } - + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { Word16 *masa_band_mapping; @@ -2706,6 +2708,7 @@ void ivas_dirac_dec_render_sf_fx( } } + push_wmops( "(IDR) LOOP1" ); FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { index_slot = add( slot_idx_start, slot_idx ); @@ -2923,6 +2926,8 @@ void ivas_dirac_dec_render_sf_fx( move16(); BREAK; default: + pop_wmops(); /* push_wmops( "ivas_dirac_dec_render (IDR)" );*/ + pop_wmops(); /*push_wmops( "(IDR) LOOP1");/*/ return; } q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; @@ -2932,6 +2937,7 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * Compute DirAC parameters at decoder side *-----------------------------------------------------------------*/ + push_wmops( "(IDR) LOOP1 DirACparams |" ); IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { Copy( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); @@ -2980,8 +2986,11 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q; move16(); + push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness <-|" ); computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); + pop_wmops(); /*push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness <-|" );/*/ } + pop_wmops(); /* push_wmops( "(IDR) LOOP1 DirACparams |" );*/ /*-----------------------------------------------------------------* * frequency domain decorrelation @@ -3083,6 +3092,7 @@ void ivas_dirac_dec_render_sf_fx( } /*Compute PSDs*/ + push_wmops( "(IDR) LOOP1 PSDs |" ); h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); num_channels_dir = hDirACRend->num_outputs_dir; @@ -3165,6 +3175,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { + push_wmops( "(IDR) LOOP1 PSDs PATH3 <-|" ); ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, DirAC_mem.reference_power_q, p_onset_filter_fx, @@ -3182,6 +3193,7 @@ void ivas_dirac_dec_render_sf_fx( md_idx, hodirac_flag, hDirAC->hConfig->dec_param_estim ); + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 <-|" );/*/ } IF( hDirAC->hConfig->dec_param_estim ) @@ -3252,7 +3264,9 @@ void ivas_dirac_dec_render_sf_fx( v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 ); q_reference_power_smooth = sub( q_reference_power_smooth, 1 ); } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs |" );*/ } + pop_wmops(); /*push_wmops( "(IDR) LOOP1" );*/ minimum_s( q_proto_direct_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) @@ -3581,7 +3595,6 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * CLDFB synthesis (and binaural rendering) *-----------------------------------------------------------------*/ - index_slot = slot_idx_start_cldfb_synth; move16(); @@ -3963,6 +3976,7 @@ void ivas_dirac_dec_render_sf_fx( } } + hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); move16(); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); @@ -4077,8 +4091,7 @@ void ivas_dirac_dec_render_sf_fx( } } } - - pop_wmops(); + pop_wmops(); /*push_wmops( "ivas_dirac_dec_render (IDR)" );*/ return; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 4686ca1e6..5b37ab7d9 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -710,11 +710,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } + push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" ); test(); IF( dec_param_estim == FALSE && hodirac_flag ) { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { + push_wmops( "(IDR) LOOP1 PSDs PATH3 B1<<<-|" ); v_multc_fixed( hSpatParamRendCom->energy_ratio1_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /* 30 + 31 - 31 -> 30 */ v_addc_fixed( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ Copy32( hSpatParamRendCom->energy_ratio1_fx[md_idx], @@ -737,19 +739,24 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); h_dirac_output_synthesis_state->direct_power_factor_q = 30; move16(); + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B1<<<-|" );/*/ } ELSE { + push_wmops( "(IDR) LOOP1 PSDs PATH3 B2<<<-|" ); ivas_dirac_dec_compute_gain_factors_fx( num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_fx, &h_dirac_output_synthesis_state->direct_power_factor_q, &h_dirac_output_synthesis_state->diffuse_power_factor_q ); + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B2<<<-|" );*/ } } ELSE IF( EQ_16( dec_param_estim, TRUE ) ) { + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" ); + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.1<<<<-|" ); /* compute direct responses */ ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, hDirACRend, @@ -764,7 +771,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sh_rot_max_order, p_Rmat, hodirac_flag ); - + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.1<<<<-|" );*/ { IF( h_dirac_output_synthesis_state->direct_responses_square_fx ) { @@ -811,12 +818,14 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } - + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop <<<<-|" ); FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) { Word16 k; IF( ch_idx != 0 ) { + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF <<<<<-|" ); + ; Word32 a, c; Word16 b, b_exp, sqr_exp, q_diff_aab, q_diff_c; Word32 mpy_a_a_b, mpy_diff_c, mpy_diff_aab; @@ -906,6 +915,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ + + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF nfreqbds <<<<<<-|" ); FOR( ; k < num_freq_bands; k++ ) { a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses @@ -987,9 +998,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF nfreqbds <<<<<<-|" );*/ + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF <<<<<-|" );*/ } ELSE { + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" ); Word32 sqr_inp, mpy_diff, sqr; Word16 sqr_exp; /*Diffuseness modellling nrg compensation*/ @@ -1027,6 +1041,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE nfreqbds <<<<<<-|" ); FOR( ; k < num_freq_bands; k++ ) { mpy_diff = Mpy_32_32( diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 @@ -1060,8 +1075,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE nfreqbds <<<<<<-|" );*/ + pop_wmops();/*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" );/*/ } } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop <<<<-|" );/*/ + Word16 temp = MAX_16; /*q0*/ move16(); tmp16 = imult1616( num_freq_bands, num_channels_dir ); @@ -1078,9 +1097,21 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } free( Q_temp_cy_cross_dir_smooth_fx ); /*Directional gain (panning)*/ + push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 gainpanning <<<<-|" ); + Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { +#ifdef FIX_1072_SPEEDUP_gainpanning /*is there any difference in any bitstream?*/ + Word16 temp_q1 = sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); + FOR( Word16 kk = 0; kk < tmp16; kk++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], temp_q1 ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ + move32(); + } + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; + move16(); +#else FOR( Word16 kk = 0; kk < tmp16; kk++ ) { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ @@ -1088,7 +1119,53 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); +#endif + } +#ifdef FIX_1072_SPEEDUP_gainpanning + Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); + FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) + { + IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) + { + Word16 i; + Word32 aux; + IF(temp_q1 < 0) + { + Word32 temp_q1_equiv = L_lshl( 0x80000000, temp_q1 ); + FOR( i = 0; i < num_freq_bands; i++ ) + { + aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] , aux, temp_q1_equiv ); + move32(); + } + } + ELSE + { + FOR( i = 0; i < num_freq_bands; i++ ) + { + aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); + aux = L_shl( aux, temp_q1 ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i], aux ); + move32(); + } + } + + } + ELSE + { + Word16 i; + FOR( i = 0; i < num_freq_bands; i++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i], h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); + move32(); + } + } + + + } + +#else FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { v_mult_fixed( h_dirac_output_synthesis_state->direct_power_factor_fx, @@ -1107,6 +1184,9 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } +#endif + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 gainpanning <<<<-|" );*/ + /*Diffuse gain*/ FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) { @@ -1124,7 +1204,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ } - + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3 <<-|" );/*/ + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" );/*/ return; } ELSE @@ -1143,7 +1224,9 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->direct_power_factor_q = 31; move16(); } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" );/*/ } + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" );/*/ diff_start_band = 0; move16(); -- GitLab From 6a2e3a1e83a250a8e6748af2bf6ad963f403cb30 Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:14:20 +0100 Subject: [PATCH 055/329] some introduction to more tunings :: FIX_1072_SPEEDUP_output_synthesis_procSlot - inactive --- lib_com/options.h | 5 +++-- lib_rend/ivas_dirac_output_synthesis_dec.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5dfebfaa6..92144ade1 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -56,7 +56,7 @@ #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -//#define WMOPS /* Activate complexity and memory counters */ +/*#define WMOPS*/ /* Activate complexity and memory counters */ #ifdef WMOPS /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ /*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ @@ -156,4 +156,5 @@ #define FIX_1072_SPEEDUP_gainpanning /* FhG: WMOPS tuning, in development*/ -#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* "-" */ \ No newline at end of file +#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* "-" */ +//#define FIX_1072_SPEEDUP_output_synthesis_procSlot /* "-" */ \ No newline at end of file diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 5b37ab7d9..404f98b1b 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -942,7 +942,18 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ } } +#ifdef FIX_1072_SPEEDUP_output_synthesis_procSlot + q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 15, b_exp ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + q_diff_c = sub( q_diffuseness, 4 ); + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + + /*Todo: simplify so that mpy+add can be merged to madd*/ + sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*q(31-sqr_exp)*/ +#else mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 @@ -970,6 +981,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr_exp = sub( 31, q_diff_c ); /*q_diff_c*/ } } +#endif + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) -- GitLab From b05d69a9edf078616466f69a705ceb5845b831c8 Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:16:18 +0100 Subject: [PATCH 056/329] cleaning up options.h --- lib_com/options.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 92144ade1..7e8912490 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,5 @@ #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ -#define FIX_1072_SPEEDUP_gainpanning /* FhG: WMOPS tuning, in development*/ -#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* "-" */ -//#define FIX_1072_SPEEDUP_output_synthesis_procSlot /* "-" */ \ No newline at end of file +#define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */ +#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* FhG: Minor WMOPS tuning, nonbe */ -- GitLab From 0917f3f7b1c455ae3c6fedf4c4e0830415137fbe Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:17:58 +0100 Subject: [PATCH 057/329] some more cleaning --- lib_com/ivas_dirac_com.c | 4 ++-- lib_com/options.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 796fc8960..97c8a88bd 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -969,7 +969,7 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_energy[i], min_q_shift1 ); -#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS Word16 shift_q = sub( q_tmp, q_ene ); Word32 shiftEquiv; Word16 shift_qtotal; @@ -1019,7 +1019,7 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_intensity[i], min_q_shift2 ); shift_q = sub( q_tmp, q_intensity ); -#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS if( shift_q >= 0 ) { shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); diff --git a/lib_com/options.h b/lib_com/options.h index 7e8912490..b47825b32 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,4 +156,4 @@ #define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */ -#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* FhG: Minor WMOPS tuning, nonbe */ +#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS /* FhG: Minor WMOPS tuning, nonbe */ -- GitLab From 491400705b0984e8379706dfd004e883507edee1 Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:22:03 +0100 Subject: [PATCH 058/329] apply clang format patch --- lib_com/ivas_dirac_com.c | 7 +++---- lib_dec/ivas_dirac_dec.c | 4 ++-- lib_rend/ivas_dirac_output_synthesis_dec.c | 12 ++++-------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 97c8a88bd..d03191084 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -973,12 +973,12 @@ void computeDiffuseness_fixed( Word16 shift_q = sub( q_tmp, q_ene ); Word32 shiftEquiv; Word16 shift_qtotal; - if( shift_q < 0 ) + if ( shift_q < 0 ) { shiftEquiv = L_lshl( 0x80000000, shift_q ); shift_qtotal = sub( min_q_shift1, 0 ); } - if( shift_q >= 0 ) + if ( shift_q >= 0 ) { shiftEquiv = L_add( 0x7FFFFFFF, 0 ); shift_qtotal = sub( min_q_shift1, shift_q ); @@ -1012,7 +1012,6 @@ void computeDiffuseness_fixed( #endif - q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ @@ -1020,7 +1019,7 @@ void computeDiffuseness_fixed( shift_q = sub( q_tmp, q_intensity ); #ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS - if( shift_q >= 0 ) + if ( shift_q >= 0 ) { shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); shift_qtotal = sub( min_q_shift2, shift_q ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 318a3ec55..81429927a 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2557,7 +2557,7 @@ void ivas_dirac_dec_render_sf_fx( p_Rmat_fx = 0; move32(); } - + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { Word16 *masa_band_mapping; @@ -2926,7 +2926,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); BREAK; default: - pop_wmops(); /* push_wmops( "ivas_dirac_dec_render (IDR)" );*/ + pop_wmops(); /* push_wmops( "ivas_dirac_dec_render (IDR)" );*/ pop_wmops(); /*push_wmops( "(IDR) LOOP1");/*/ return; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 404f98b1b..3f4111253 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1089,7 +1089,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE nfreqbds <<<<<<-|" );*/ - pop_wmops();/*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" );/*/ + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" );/*/ } } pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop <<<<-|" );/*/ @@ -1133,7 +1133,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); #endif - } #ifdef FIX_1072_SPEEDUP_gainpanning Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); @@ -1143,13 +1142,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { Word16 i; Word32 aux; - IF(temp_q1 < 0) + IF( temp_q1 < 0 ) { Word32 temp_q1_equiv = L_lshl( 0x80000000, temp_q1 ); FOR( i = 0; i < num_freq_bands; i++ ) { aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] , aux, temp_q1_equiv ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i], aux, temp_q1_equiv ); move32(); } } @@ -1163,7 +1162,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } } - } ELSE { @@ -1174,8 +1172,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } } - - } #else @@ -1237,7 +1233,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->direct_power_factor_q = 31; move16(); } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" );/*/ + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" );/*/ } pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" );/*/ -- GitLab From 59fd769bd56da5f9aec8aad04125283815b1a260 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 6 Feb 2025 14:30:48 +0000 Subject: [PATCH 059/329] Final cleanups before merge --- lib_com/ivas_dirac_com.c | 2 - lib_dec/ivas_dirac_dec.c | 21 ++-------- lib_rend/ivas_dirac_output_synthesis_dec.c | 45 ++-------------------- 3 files changed, 7 insertions(+), 61 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d03191084..e07d36b1e 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -960,7 +960,6 @@ void computeDiffuseness_fixed( q_intensity = add( q_factor_intensity[0], min_q_shift2 ); move16(); - push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness B <<-|" ); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ @@ -1070,7 +1069,6 @@ void computeDiffuseness_fixed( q_intensity = s_min( q_intensity, q_tmp ); } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness B <<-|" );/*/ min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); min_q_shift1 = sub( min_q_shift1, idiv1616( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 2 ) ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 81429927a..95cca12a0 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2231,7 +2231,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); Word16 tmp1; - push_wmops( "ivas_dirac_dec_render (IDR)" ); + push_wmops( "ivas_dirac_dec_render" ); /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; @@ -2341,7 +2341,6 @@ void ivas_dirac_dec_render_sf_fx( } ELSE IF( !( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { - push_wmops( "(IDR) SBA_FORMAT | SBA_ISM_FORMAT" ); Word16 outchannels; idx_lfe = 0; move16(); @@ -2410,7 +2409,6 @@ void ivas_dirac_dec_render_sf_fx( } } } - pop_wmops(); /*push_wmops( "(IDR) SBA_FORMAT | SBA_ISM_FORMAT" );*/ } size = imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ); @@ -2708,7 +2706,6 @@ void ivas_dirac_dec_render_sf_fx( } } - push_wmops( "(IDR) LOOP1" ); FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { index_slot = add( slot_idx_start, slot_idx ); @@ -2926,8 +2923,6 @@ void ivas_dirac_dec_render_sf_fx( move16(); BREAK; default: - pop_wmops(); /* push_wmops( "ivas_dirac_dec_render (IDR)" );*/ - pop_wmops(); /*push_wmops( "(IDR) LOOP1");/*/ return; } q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; @@ -2937,7 +2932,6 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * Compute DirAC parameters at decoder side *-----------------------------------------------------------------*/ - push_wmops( "(IDR) LOOP1 DirACparams |" ); IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { Copy( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); @@ -2986,11 +2980,8 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q; move16(); - push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness <-|" ); computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); - pop_wmops(); /*push_wmops( "(IDR) LOOP1 DirACparams computeDiffuseness <-|" );/*/ } - pop_wmops(); /* push_wmops( "(IDR) LOOP1 DirACparams |" );*/ /*-----------------------------------------------------------------* * frequency domain decorrelation @@ -3092,7 +3083,6 @@ void ivas_dirac_dec_render_sf_fx( } /*Compute PSDs*/ - push_wmops( "(IDR) LOOP1 PSDs |" ); h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); num_channels_dir = hDirACRend->num_outputs_dir; @@ -3175,7 +3165,6 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - push_wmops( "(IDR) LOOP1 PSDs PATH3 <-|" ); ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, DirAC_mem.reference_power_q, p_onset_filter_fx, @@ -3193,7 +3182,6 @@ void ivas_dirac_dec_render_sf_fx( md_idx, hodirac_flag, hDirAC->hConfig->dec_param_estim ); - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 <-|" );/*/ } IF( hDirAC->hConfig->dec_param_estim ) @@ -3264,9 +3252,7 @@ void ivas_dirac_dec_render_sf_fx( v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 ); q_reference_power_smooth = sub( q_reference_power_smooth, 1 ); } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs |" );*/ } - pop_wmops(); /*push_wmops( "(IDR) LOOP1" );*/ minimum_s( q_proto_direct_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) @@ -3595,6 +3581,7 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * CLDFB synthesis (and binaural rendering) *-----------------------------------------------------------------*/ + index_slot = slot_idx_start_cldfb_synth; move16(); @@ -3976,7 +3963,6 @@ void ivas_dirac_dec_render_sf_fx( } } - hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); move16(); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); @@ -4091,7 +4077,8 @@ void ivas_dirac_dec_render_sf_fx( } } } - pop_wmops(); /*push_wmops( "ivas_dirac_dec_render (IDR)" );*/ + + pop_wmops(); return; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 3f4111253..866badda0 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -710,13 +710,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } - push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" ); test(); IF( dec_param_estim == FALSE && hodirac_flag ) { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - push_wmops( "(IDR) LOOP1 PSDs PATH3 B1<<<-|" ); v_multc_fixed( hSpatParamRendCom->energy_ratio1_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /* 30 + 31 - 31 -> 30 */ v_addc_fixed( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ Copy32( hSpatParamRendCom->energy_ratio1_fx[md_idx], @@ -739,24 +737,19 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); h_dirac_output_synthesis_state->direct_power_factor_q = 30; move16(); - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B1<<<-|" );/*/ } ELSE { - push_wmops( "(IDR) LOOP1 PSDs PATH3 B2<<<-|" ); ivas_dirac_dec_compute_gain_factors_fx( num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_fx, &h_dirac_output_synthesis_state->direct_power_factor_q, &h_dirac_output_synthesis_state->diffuse_power_factor_q ); - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B2<<<-|" );*/ } } ELSE IF( EQ_16( dec_param_estim, TRUE ) ) { - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" ); - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.1<<<<-|" ); /* compute direct responses */ ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, hDirACRend, @@ -771,7 +764,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sh_rot_max_order, p_Rmat, hodirac_flag ); - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.1<<<<-|" );*/ + { IF( h_dirac_output_synthesis_state->direct_responses_square_fx ) { @@ -818,14 +811,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop <<<<-|" ); + FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) { Word16 k; IF( ch_idx != 0 ) { - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF <<<<<-|" ); - ; Word32 a, c; Word16 b, b_exp, sqr_exp, q_diff_aab, q_diff_c; Word32 mpy_a_a_b, mpy_diff_c, mpy_diff_aab; @@ -915,8 +906,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ - - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF nfreqbds <<<<<<-|" ); FOR( ; k < num_freq_bands; k++ ) { a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses @@ -942,22 +931,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ } } -#ifdef FIX_1072_SPEEDUP_output_synthesis_procSlot - q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 15, b_exp ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); - q_diff_c = sub( q_diffuseness, 4 ); mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 - /*Todo: simplify so that mpy+add can be merged to madd*/ - sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*q(31-sqr_exp)*/ - -#else - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 - mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 - mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 - q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 15, b_exp ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); q_diff_c = sub( q_diffuseness, 4 ); @@ -981,8 +959,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr_exp = sub( 31, q_diff_c ); /*q_diff_c*/ } } -#endif - sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) @@ -1011,12 +987,9 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF nfreqbds <<<<<<-|" );*/ - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop IF <<<<<-|" );*/ } ELSE { - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" ); Word32 sqr_inp, mpy_diff, sqr; Word16 sqr_exp; /*Diffuseness modellling nrg compensation*/ @@ -1054,7 +1027,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE nfreqbds <<<<<<-|" ); FOR( ; k < num_freq_bands; k++ ) { mpy_diff = Mpy_32_32( diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 @@ -1088,12 +1060,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE nfreqbds <<<<<<-|" );*/ - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" );/*/ } } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop <<<<-|" );/*/ - Word16 temp = MAX_16; /*q0*/ move16(); tmp16 = imult1616( num_freq_bands, num_channels_dir ); @@ -1110,8 +1078,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } free( Q_temp_cy_cross_dir_smooth_fx ); /*Directional gain (panning)*/ - push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 gainpanning <<<<-|" ); - Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { @@ -1192,9 +1158,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } - #endif - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 gainpanning <<<<-|" );*/ /*Diffuse gain*/ FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) @@ -1213,8 +1177,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3 <<-|" );/*/ - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" );/*/ + return; } ELSE @@ -1233,9 +1196,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->direct_power_factor_q = 31; move16(); } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" );/*/ } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" );/*/ diff_start_band = 0; move16(); -- GitLab From f5fe2f050dca5c506a610bb38f9290e5e057826f Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:53:56 +0100 Subject: [PATCH 060/329] Revert "apply clang format patch" This reverts commit 491400705b0984e8379706dfd004e883507edee1. --- lib_com/ivas_dirac_com.c | 7 ++++--- lib_dec/ivas_dirac_dec.c | 4 ++-- lib_rend/ivas_dirac_output_synthesis_dec.c | 12 ++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d03191084..97c8a88bd 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -973,12 +973,12 @@ void computeDiffuseness_fixed( Word16 shift_q = sub( q_tmp, q_ene ); Word32 shiftEquiv; Word16 shift_qtotal; - if ( shift_q < 0 ) + if( shift_q < 0 ) { shiftEquiv = L_lshl( 0x80000000, shift_q ); shift_qtotal = sub( min_q_shift1, 0 ); } - if ( shift_q >= 0 ) + if( shift_q >= 0 ) { shiftEquiv = L_add( 0x7FFFFFFF, 0 ); shift_qtotal = sub( min_q_shift1, shift_q ); @@ -1012,6 +1012,7 @@ void computeDiffuseness_fixed( #endif + q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ @@ -1019,7 +1020,7 @@ void computeDiffuseness_fixed( shift_q = sub( q_tmp, q_intensity ); #ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS - if ( shift_q >= 0 ) + if( shift_q >= 0 ) { shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); shift_qtotal = sub( min_q_shift2, shift_q ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 81429927a..318a3ec55 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2557,7 +2557,7 @@ void ivas_dirac_dec_render_sf_fx( p_Rmat_fx = 0; move32(); } - + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { Word16 *masa_band_mapping; @@ -2926,7 +2926,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); BREAK; default: - pop_wmops(); /* push_wmops( "ivas_dirac_dec_render (IDR)" );*/ + pop_wmops(); /* push_wmops( "ivas_dirac_dec_render (IDR)" );*/ pop_wmops(); /*push_wmops( "(IDR) LOOP1");/*/ return; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 3f4111253..404f98b1b 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1089,7 +1089,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE nfreqbds <<<<<<-|" );*/ - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" );/*/ + pop_wmops();/*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop ELSE <<<<<-|" );/*/ } } pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3.3 bigloop <<<<-|" );/*/ @@ -1133,6 +1133,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); #endif + } #ifdef FIX_1072_SPEEDUP_gainpanning Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); @@ -1142,13 +1143,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { Word16 i; Word32 aux; - IF( temp_q1 < 0 ) + IF(temp_q1 < 0) { Word32 temp_q1_equiv = L_lshl( 0x80000000, temp_q1 ); FOR( i = 0; i < num_freq_bands; i++ ) { aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i], aux, temp_q1_equiv ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] , aux, temp_q1_equiv ); move32(); } } @@ -1162,6 +1163,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } } + } ELSE { @@ -1172,6 +1174,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } } + + } #else @@ -1233,7 +1237,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->direct_power_factor_q = 31; move16(); } - pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" );/*/ + pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B3<<<-|" );/*/ } pop_wmops(); /*push_wmops( "(IDR) LOOP1 PSDs PATH3 B <<-|" );/*/ -- GitLab From 896f21e54f609aaaab580d12e6056add7a6b5899 Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:54:25 +0100 Subject: [PATCH 061/329] Revert "some more cleaning" This reverts commit 0917f3f7b1c455ae3c6fedf4c4e0830415137fbe. --- lib_com/ivas_dirac_com.c | 4 ++-- lib_com/options.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 97c8a88bd..796fc8960 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -969,7 +969,7 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_energy[i], min_q_shift1 ); -#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB Word16 shift_q = sub( q_tmp, q_ene ); Word32 shiftEquiv; Word16 shift_qtotal; @@ -1019,7 +1019,7 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_intensity[i], min_q_shift2 ); shift_q = sub( q_tmp, q_intensity ); -#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB if( shift_q >= 0 ) { shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); diff --git a/lib_com/options.h b/lib_com/options.h index b47825b32..7e8912490 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,4 +156,4 @@ #define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */ -#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS /* FhG: Minor WMOPS tuning, nonbe */ +#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* FhG: Minor WMOPS tuning, nonbe */ -- GitLab From ac90f9d69453b85c66a40220c4a4e6cc9b715d72 Mon Sep 17 00:00:00 2001 From: ber Date: Thu, 6 Feb 2025 15:54:47 +0100 Subject: [PATCH 062/329] Revert "cleaning up options.h" This reverts commit b05d69a9edf078616466f69a705ceb5845b831c8. --- lib_com/options.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7e8912490..92144ade1 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,5 +155,6 @@ #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ -#define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */ -#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* FhG: Minor WMOPS tuning, nonbe */ +#define FIX_1072_SPEEDUP_gainpanning /* FhG: WMOPS tuning, in development*/ +#define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* "-" */ +//#define FIX_1072_SPEEDUP_output_synthesis_procSlot /* "-" */ \ No newline at end of file -- GitLab From d9be453d24945793846bf52d35d2efe197a8ca17 Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 7 Feb 2025 13:31:44 +0100 Subject: [PATCH 063/329] dumping core.loc2, coder_type and ism_imp --- lib_enc/ivas_core_pre_proc_front.c | 14 +++++++++++++ lib_enc/ivas_decision_matrix_enc.c | 33 ++++++++++++++++++++---------- lib_enc/ivas_ism_enc.c | 19 +++++++++++++++++ lib_enc/ivas_ism_metadata_enc.c | 11 ++++++++++ 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 74af17216..c06c437ff 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1456,6 +1456,20 @@ ivas_error pre_proc_front_ivas_fx( Copy_Scale_sig_16_32( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->coder_type, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type.enf", -1, -1, -1 ) ); + dbgread( &st->coder_type_raw, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type_raw.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->coder_type, sizeof( int16_t ), 1, 1, "res/force_coder_type.enf" ); + dbgwrite( &st->coder_type_raw, sizeof( int16_t ), 1, 1, "res/force_coder_type_raw.enf" ); + } +#endif + + /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 08ce3cd21..e668641dc 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -207,6 +207,17 @@ void ivas_decision_matrix_enc_fx( test(); test(); +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core_loc1.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core_loc1.enf" ); + } +#endif + /* do not allow TD stereo ACELP core -> DFT stereo TCX core switching as it is on the WC complexity path */ if ( ( ( st->last_core == ACELP_CORE && EQ_16( last_element_mode, IVAS_CPE_TD ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || ( EQ_16( st->tdm_LRTD_flag, 1 ) && LE_32( st->total_brate, IVAS_16k4 ) ) ) && EQ_16( st->core, TCX_20_CORE ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) /* Override TCX in case of LRTD && primary channel has low bitrate*/ { @@ -255,17 +266,6 @@ void ivas_decision_matrix_enc_fx( } #endif -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core.enf" ); - } -#endif - /* TCX not available at low bitrates -> replace it by GSC */ test(); IF( EQ_16( st->core, TCX_20_CORE ) && LT_32( st->total_brate, STEREO_TCX_MIN_RATE ) ) @@ -305,6 +305,17 @@ void ivas_decision_matrix_enc_fx( move16(); } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core_loc2.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core_loc2.enf" ); + } +#endif + /*---------------------------------------------------------------------* * Select ACELP and GSC extension layer *---------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 2fef5a1cb..70b049ba8 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -228,6 +228,11 @@ ivas_error ivas_ism_enc_fx( st->bits_frame_nominal = sub( extract_l( Mpy_32_32( hSCE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), ISM_NB_BITS_METADATA_NOMINAL ); move16(); + +#ifdef DEBUG_MODE_INFO + dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); +#endif + /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ @@ -506,6 +511,20 @@ ivas_error ivas_ism_enc_fx( } } +#ifdef DEBUG_MODE_INFO + for ( sce_id = 0; sce_id < nchan_transport_ism; sce_id++ ) + { + float tmpF; + int16_t id; + + st = st_ivas->hSCE[sce_id]->hCoreCoder[0]; + id = st->id_element; + + tmpF = st->element_brate / 1000.0f; + dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, id, ENC ) ); + } +#endif + pop_wmops(); return error; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 9bcc34dd8..ef410b59c 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -338,6 +338,17 @@ ivas_error ivas_ism_metadata_enc_fx( } } +#ifdef DEBUG_FORCE_DIR + if ( hSCE[0]->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( ism_imp, sizeof( int16_t ), nchan_ism, fname( hSCE[0]->hCoreCoder[0]->force_dir, "force_ism_imp.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( ism_imp, sizeof( int16_t ), nchan_ism, 1, "res/force_ism_imp.enf" ); + } +#endif + /*----------------------------------------------------------------* * Write ISM common signaling *----------------------------------------------------------------*/ -- GitLab From 43633d492c8a1b5d9cb793788e09567f393f896b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 9 Feb 2025 20:46:21 +0100 Subject: [PATCH 064/329] fix instrumentation --- lib_com/ivas_dirac_com.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index e07d36b1e..2704c1f08 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -975,13 +975,13 @@ void computeDiffuseness_fixed( if ( shift_q < 0 ) { shiftEquiv = L_lshl( 0x80000000, shift_q ); - shift_qtotal = sub( min_q_shift1, 0 ); } if ( shift_q >= 0 ) { shiftEquiv = L_add( 0x7FFFFFFF, 0 ); - shift_qtotal = sub( min_q_shift1, shift_q ); } + shift_qtotal = sub( min_q_shift1, s_max( shift_q, 0 ) ); + FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp_c[k], shift_qtotal ); @@ -1018,16 +1018,16 @@ void computeDiffuseness_fixed( shift_q = sub( q_tmp, q_intensity ); #ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS - if ( shift_q >= 0 ) - { - shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); - shift_qtotal = sub( min_q_shift2, shift_q ); - } if ( shift_q < 0 ) { shiftEquiv = L_lshl( 0x80000000, shift_q ); - shift_qtotal = sub( min_q_shift2, 0 ); } + if ( shift_q >= 0 ) + { + shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); + } + shift_qtotal = sub( min_q_shift2, s_max( shift_q, 0 ) ); + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; -- GitLab From 4811ef2a2d9e80d59b78e064f8414adc4b746b89 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 10 Feb 2025 18:06:53 +1100 Subject: [PATCH 065/329] masa renderer test failures fixes --- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 3e5bb8b86..ea975dfbe 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -6658,7 +6658,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, subframe, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, q_inp ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, NULL ); #endif -- GitLab From 70147babc4843b0ec44beaf043d09e1258f1ee89 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 11 Feb 2025 17:27:59 +1100 Subject: [PATCH 066/329] missing renderer config changes --- lib_util/render_config_reader.c | 145 +++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 692f8c58d..dd8c36492 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1069,7 +1069,11 @@ static void strip_spaces( while ( pStr[read_idx] ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !isspace( (int32_t) pStr[read_idx] ) && !iscntrl( (int32_t) pStr[read_idx] ) ) +#else if ( !isspace( pStr[read_idx] ) && !iscntrl( pStr[read_idx] ) ) +#endif { pStr[write_idx++] = pStr[read_idx]; } @@ -1833,6 +1837,10 @@ ivas_error RenderConfigReader_read( uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; uint32_t aeHasERsize, aeHasERabs; +#ifdef SPLIT_REND_WITH_HEAD_ROT + bool dofProvided = false; + bool poseCorrProvided = false; +#endif uint32_t nDP; uint32_t accDPIdx; @@ -2349,7 +2357,142 @@ ivas_error RenderConfigReader_read( free( pValue ); acIdx++; } - +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( strcmp( chapter, "SPLITREND" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + fprintf( stderr, " PARAM: %s -> %s\n", item, pValue ); +#endif + if ( strcmp( item, "CODECDELAY" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_delay_ms ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "HQMODE" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.hq_mode ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "BITRATE" ) == 0 ) + { + if ( !sscanf( pValue, "%d", &hRenderConfig->split_rend_config.splitRendBitRate ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "DOF" ) == 0 ) + { + dofProvided = true; + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.dof ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + /* 0 DOF implies no pose correction */ + if ( hRenderConfig->split_rend_config.dof == 0 && !poseCorrProvided ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + } + else if ( strcmp( item, "CODEC" ) == 0 ) + { + if ( strcmp( pValue, "LCLD" ) == 0 ) + { + hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LCLD; + } + else if ( strcmp( pValue, "LC3PLUS" ) == 0 ) + { + hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "FRAMESIZE" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_frame_size_ms ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + if ( hRenderConfig->split_rend_config.codec_frame_size_ms != 5 && + hRenderConfig->split_rend_config.codec_frame_size_ms != 10 && + hRenderConfig->split_rend_config.codec_frame_size_ms != 20 ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "POSECORRECTION" ) == 0 ) + { + poseCorrProvided = true; + if ( strcmp( pValue, "CLDFB" ) == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + } + else if ( strcmp( pValue, "NONE" ) == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + /* no pose correction implies 0 DOF */ + if ( !dofProvided ) + { + hRenderConfig->split_rend_config.dof = 0; + } + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "RENDERER" ) == 0 ) + { + if ( strcmp( pValue, "CREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_CREND; + } + else if ( strcmp( pValue, "FASTCONV" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV; + } + else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN; + } + else if ( strcmp( pValue, "TDREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + else if ( strcmp( item, "LC3PLUS_HIGHRES" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.lc3plus_highres ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } +#endif +#ifdef DEBUGGING + else + { + fprintf( stderr, "Unsupported configuration property %s\n", item ); + } +#endif + } + free( pValue ); + } +#endif else if ( strcmp( chapter, "DIRECTIVITYSETTING" ) == 0 && strlen( pParams ) != 0 ) { params_idx = 0; -- GitLab From 64ac4f93dd1e6b2f09b7906ab661c4cba4643e88 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 11 Feb 2025 09:12:26 +0100 Subject: [PATCH 067/329] Add -p BASOP for build-codec-linux-instrumented-make --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4fe5ec338..16563bf57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -896,7 +896,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP - make -j -C $INSTR_DIR -- GitLab From 19726c715a0689d98b57bc4a9d18e72bd8c44b1e Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Tue, 11 Feb 2025 10:27:38 +0100 Subject: [PATCH 068/329] fix(point)ed RCcontextMapping_encode2_estimate_bandWise_start_fx() and RCcontextMapping_encode2_estimate_bandWise_fx() already. --- lib_enc/ACcontextMapping_enc_fx.c | 122 +++++++++++++++--------------- lib_enc/stat_enc.h | 3 +- 2 files changed, 64 insertions(+), 61 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 08baa4f3d..53af78878 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -16,6 +16,9 @@ #include "prot_fx_enc.h" #include "ivas_prot.h" /* Range coder header file */ +#define MAKE_NUMBER_QX(number,QX) ((number)<<(QX)) +#define MAKE_VARIABLE_QX(variable,QX) W_shl(W_deposit32_l(L_deposit_l(( variable) ) ), (QX)) + /*-------------------------------------------------------------------* * ACcontextMapping_encode2_no_mem_s17_LC_fx() * @@ -1106,8 +1109,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( } /* Finish range encoder */ - rc_tot_bits = rc_uni_enc_finish_fx( &rc_st_enc ); /* No. of bits consumed by range coder Q0*/ - bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer Q0*/ + rc_tot_bits = rc_uni_enc_finish_fx( &rc_st_enc ); /* No. of bits consumed by range coder Q0*/ + bp = add( rc_tot_bits, nbbits_ntuples ); /* Update bitstream pointer Q0*/ /* Cross-check that there is no overflow */ @@ -1215,15 +1218,15 @@ static Word16 find_last_nz_pair_fx( *-------------------------------------------------------------------*/ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( - Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ - Word16 *lastnz_out, /* Q0 */ - Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ - Word16 *stop, /* Q0 */ - Word16 mode, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ -) + Word16 *x, /* Spectral coefficients Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + Word16 *lastnz_out, /* Q0 */ + Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ + const Word16 target, /* Target bits Q0*/ + Word16 *stop, /* Q0 */ + Word16 mode, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ + ) { /* Common variables */ Word16 a1, b1; @@ -1363,7 +1366,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[lev1]; /* ESC symbol */ bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */ + bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */ a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1451,7 +1454,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( *nEncoded = lastnz2; /* Q0 */ move16(); - *stop = stop2; /* If zero, it means no overflow occured during bit-estimation Q0*/ + *stop = stop2; /* If zero, it means no overflow occured during bit-estimation Q0*/ move16(); *lastnz_out = lastnz; /* Q0 */ move16(); @@ -1512,7 +1515,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( lastnz = add( lastnz, 2 ); /* Q0 */ IF( LT_16( lastnz, 2 ) ) { - lastnz = 2; /* At least one tuple is coded Q0*/ + lastnz = 2; /* At least one tuple is coded Q0*/ move16(); } @@ -1611,37 +1614,37 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); } ELSE /* Overflow */ + { + IF( *stop ){ + *stop = tot_bits2; /* Q0 */ + move16(); + } + ELSE { - IF( *stop ){ - *stop = tot_bits2; /* Q0 */ + *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */ + move16(); + } + } + + *lastnz_out = lastnz; /* Q0 */ move16(); - } - ELSE - { - *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */ + *nEncoded = lastnz2; /* Q0 */ move16(); - } -} + /* Safety mechanism to avoid overflow */ + test(); + IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) + { + FOR( k = 0; k < lastnz2; k++ ) + { + x[k] = 0; + move16(); + } + } -*lastnz_out = lastnz; /* Q0 */ -move16(); -*nEncoded = lastnz2; /* Q0 */ -move16(); -/* Safety mechanism to avoid overflow */ -test(); -IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) -{ - FOR( k = 0; k < lastnz2; k++ ) - { - x[k] = 0; - move16(); + return tot_bits2; } } -return tot_bits2; -} -} - /*-------------------------------------------------------------------* * RCcontextMapping_encode2_estimate_bandWise_start_fx() @@ -1669,10 +1672,9 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( move16(); } - hContextMem->bit_estimate_fx = 2; /* Q0 */ - move32(); - hContextMem->bit_estimate_e = Q31; - move16(); + hContextMem->bit_estimate_accu = MAKE_NUMBER_QX(2, Q23 ); + move64(); + /* Init */ @@ -1682,18 +1684,21 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( /* bits to encode lastnz */ k = 1; move16(); + i = 2; + move16(); WHILE( LT_16( k, hContextMem->nt_half ) ) { - hContextMem->bit_estimate_fx = L_add( hContextMem->bit_estimate_fx, 1 ); /* exp(bit_estimate_e) */ - move32(); + hContextMem->bit_estimate_accu = W_add( hContextMem->bit_estimate_accu, MAKE_NUMBER_QX(1, Q23 ) ); + move64(); k = shl( k, 1 ); + i = add( i, 1 ); /* check while condition */ } /* bits to encode lastnz */ - hContextMem->nbits_old = extract_l( hContextMem->bit_estimate_fx ); /* Q0 */ + hContextMem->nbits_old = i; move16(); hContextMem->ctx = 0; @@ -1713,14 +1718,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( BREAK; } } - Word16 tmp2 = extract_l( hContextMem->bit_estimate_fx ); - Word16 tmp = norm_l( hContextMem->bit_estimate_fx ); - hContextMem->bit_estimate_e = sub( Q31, tmp ); - move16(); - hContextMem->bit_estimate_fx = L_shl( hContextMem->bit_estimate_fx, tmp ); /* exp(bit_estimate_e) */ - move32(); - return tmp2; + return hContextMem->nbits_old; } /*-------------------------------------------------------------------* @@ -1777,8 +1776,9 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */ /* Signs Bits */ - hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, imult3216( ONE_IN_Q30, s_min( a1, 1 ) ), Q1, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */ - hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, imult3216( ONE_IN_Q30, s_min( b1, 1 ) ), Q1, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */ + hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + move32(); move32(); @@ -1792,11 +1792,13 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( pki = lookup[lev1]; /* Q0 */ move16(); - hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], Q8, &hContextMem->bit_estimate_e ); /* exp(hContextMem->bit_estimate_e) */ - hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, 2 * ONE_IN_Q29, Q2, &hContextMem->bit_estimate_e ); /* Add the 2 LSB bits that were shifted out exp(hContextMem->bit_estimate_e) */ + hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) ); move32(); move32(); + + // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC]; // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */ @@ -1809,8 +1811,9 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( pki = lookup[lev1]; /* Q0 */ move16(); - symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ - hContextMem->bit_estimate_fx = BASOP_Util_Add_Mant32Exp( hContextMem->bit_estimate_fx, hContextMem->bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], Q8, &hContextMem->bit_estimate_e ); /* exp(bit_estimate_e) */ + symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ + hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + move32(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol]; @@ -1830,9 +1833,10 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( move16(); } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( L_shr( hContextMem->bit_estimate_fx, sub( Q15, hContextMem->bit_estimate_e ) ) ); /* Q0 */ + total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_accu, Q7 ) ); /* Q0 */ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); + bandBits = sub( total_output_bits, hContextMem->nbits_old ); /* Q0 */ hContextMem->nbits_old = total_output_bits; /* Q0 */ move16(); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 0f1c2e906..a3a743509 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -2348,8 +2348,7 @@ typedef struct context_rc_mem_struct { int16_t nbits_old; int16_t ctx; - Word32 bit_estimate_fx; - Word16 bit_estimate_e; + Word64 bit_estimate_accu; int16_t rateFlag; int16_t lastnz; int16_t nt_half; -- GitLab From 0a0a50baf43f721019b3d5f55672e05cbd3a547e Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Tue, 11 Feb 2025 12:51:54 +0100 Subject: [PATCH 069/329] removed bit_estimate_fx and bit_estimate_e from the ACcontextMapping_enc_fx.c completely. --- lib_enc/ACcontextMapping_enc_fx.c | 87 ++++++++++++++----------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 53af78878..2c58b4557 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1230,43 +1230,40 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { /* Common variables */ Word16 a1, b1; - Word16 k, pki, lev1; + Word16 i, k, pki, lev1; UWord16 t; Word16 lastnz, lastnz2; Word16 rateFlag; - Word32 bit_estimate_fx; - Word16 bit_estimate_e; + Word64 bit_estimate_accu; + Word16 symbol; const UWord8 *lookup; - Word32 nbits2_fx; // Q23 - Word16 nbits2_e; + Word64 nbits2_accu; /* Initialization */ - bit_estimate_fx = 2 * ONE_IN_Q29; - bit_estimate_e = 2; - move32(); - move16(); + bit_estimate_accu = MAKE_NUMBER_QX(2, Q23 ); + move64(); - nbits2_fx = 0; - nbits2_e = 0; - move32(); - move16(); + nbits2_accu = 0; + move64(); /* bits to encode lastnz */ k = 1; move16(); + i = 2; + move64(); WHILE( LT_16( k, nt / 2 ) ) { - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ONE_IN_Q30, 1, &bit_estimate_e ); - k = k << 1; + bit_estimate_accu = W_add( bit_estimate_accu, MAKE_NUMBER_QX(1, Q23 ) ); + k = shl( k, 1 ); + i = add( i, 2 ); /* check while condition */ + } - nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */ - nbits2_e = bit_estimate_e; - move32(); - move16(); + nbits2_accu = bit_estimate_accu; + move64(); IF( hm_cfg ) { @@ -1353,9 +1350,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( b1 = (Word16) abs( x[b1_i] ); lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */ - + bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); @@ -1365,9 +1361,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { pki = lookup[lev1]; /* ESC symbol */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */ - + bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1379,10 +1374,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[lev1]; symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */ + bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ - IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) ) + IF( GT_32( W_shr( bit_estimate_accu, Q8 ), L_shl( target, Q15 ) ) ) { stop2 = 1; move16(); @@ -1395,10 +1390,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ELSE { lastnz2 = add( b1_i, 1 ); - nbits2_fx = bit_estimate_fx; - move32(); - nbits2_e = bit_estimate_e; - move16(); + nbits2_accu = bit_estimate_accu; + move64(); } /* Update context for next 2-tuple */ @@ -1439,11 +1432,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */ + total_output_bits = round_fx( W_shr(bit_estimate_accu, Q7 ) ); IF( *stop ) { - total_output_bits = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) ); /* Q0 */ + total_output_bits = round_fx( W_shr( nbits2_accu, Q7 ) ); } IF( stop2 ) @@ -1468,7 +1461,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */ move16(); - return round_fx( L_add( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ), ONE_IN_Q14 ) ); /* Q0 */ + + return round_fx( L_add( W_shr( nbits2_accu, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ } ELSE /* if (!hm_cfg) */ { @@ -1534,8 +1528,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) ); /* Q0 */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( a1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, s_min( b1, 1 ) * ONE_IN_Q30, 1, &bit_estimate_e ); /* exp(bit_estimate_e) */ + bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */ lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )]; /* Q0 */ @@ -1547,8 +1541,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ move16(); - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, 2 * ONE_IN_Q29, 2, &bit_estimate_e ); /* Add 2 LSB bits corresponding to the bit-plane exp(bit_estimate_e) */ + bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1563,10 +1557,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ - bit_estimate_fx = BASOP_Util_Add_Mant32Exp( bit_estimate_fx, bit_estimate_e, ari_bit_estimate_s17_LC_fx[pki][symbol], 8, &bit_estimate_e ); /* exp(bit_estimate_e) */ + bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ - IF( GT_32( L_shr( bit_estimate_fx, sub( Q16, bit_estimate_e ) ), L_shl( target, Q15 ) ) ) /* Overflow occured */ + IF( GT_32( W_shr( bit_estimate_accu, Q8 ), L_shl( target, Q15 ) ) ) { overflow_flag = 1; move16(); @@ -1575,10 +1569,9 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */ { - nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */ - nbits2_e = bit_estimate_e; - move32(); - move16(); + nbits2_accu = bit_estimate_accu; /* exp(bit_estimate_e) */ + move64(); + lastnz2 = add( k, 2 ); } } @@ -1598,7 +1591,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - tot_bits2 = round_fx( L_shr( nbits2_fx, sub( Q15, nbits2_e ) ) ); + tot_bits2 = round_fx( W_shr( nbits2_accu, Q7 ) ); IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ { overflow_flag = 1; @@ -1606,7 +1599,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } IF( EQ_16( mode, -1 ) ) { - tot_bits2 = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */ + tot_bits2 = round_fx( W_shr( bit_estimate_accu, Q7 ) ); } IF( overflow_flag == 0 ) /* No overflow */ { @@ -1621,7 +1614,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } ELSE { - *stop = round_fx( L_shr( bit_estimate_fx, sub( Q15, bit_estimate_e ) ) ); /* Q0 */ + *stop = round_fx( W_shr( bit_estimate_accu, Q7 ) ); move16(); } } -- GitLab From 4b2c1d98dae4a80ce82a23cad1d86064869f5ede Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 11 Feb 2025 18:10:20 +0100 Subject: [PATCH 070/329] Revert call to prepare_instrumentation.sh --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16563bf57..4fe5ec338 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -896,7 +896,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR -- GitLab From 76dc2a8289c4b66c902c2f0a05bc8a2bb8922c13 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 12 Feb 2025 17:06:31 +1100 Subject: [PATCH 071/329] fixes to pre renderer and post renderer --- lib_com/ivas_rotation_com.c | 8 ++++---- lib_dec/ivas_binRenderer_internal.c | 30 ++++++++++++++--------------- lib_dec/lib_dec_fx.c | 10 +++++----- lib_isar/isar_PredEncoder.c | 4 ++-- lib_isar/isar_splitRendererPost.c | 11 ++++++++--- lib_isar/isar_splitRendererPre.c | 5 +++-- lib_isar/lib_isar_post_rend.c | 3 ++- lib_isar/lib_isar_pre_rend.c | 4 ++-- lib_rend/lib_rend.c | 6 +++--- 9 files changed, 43 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index fccc5498b..b48fdfec2 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -57,12 +57,12 @@ void Euler2Quat_fx( IVAS_QUATERNION *quat /* o : quaternion describing the rotation Q22*/ ) { - Word16 cr = getCosWord16( extract_l( L_shr_r( roll, 10 ) ) ); // Q14 - Word16 sr = getSinWord16( extract_l( L_shr_r( roll, 10 ) ) ); + Word16 cr = getCosWord16( extract_l( L_shr_r( roll, 10 ) ) ); // Q14 + Word16 sr = shr( getSinWord16( extract_l( L_shr_r( roll, 10 ) ) ), 1 ); // Q14 Word16 cp = getCosWord16( extract_l( L_shr_r( pitch, 10 ) ) ); - Word16 sp = getSinWord16( extract_l( L_shr_r( pitch, 10 ) ) ); + Word16 sp = shr( getSinWord16( extract_l( L_shr_r( pitch, 10 ) ) ), 1 ); // Q14 Word16 cy = getCosWord16( extract_l( L_shr_r( yaw, 10 ) ) ); - Word16 sy = getSinWord16( extract_l( L_shr_r( yaw, 10 ) ) ); + Word16 sy = shr( getSinWord16( extract_l( L_shr_r( yaw, 10 ) ) ), 1 ); // Q14 quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); // Q22 move32(); quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); // Q22 diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 70f8219f9..f0cda2bca 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1955,30 +1955,29 @@ void ivas_binRenderer_fx( { IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { - IVAS_QUATERNION Quaternions_rel, Quaternions_abs, *Quaternions_ref; + IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; Word32 Rmat_local[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; Word16 q_fact_orig; IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) { - Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; - Quaternions_rel.w_fx = L_negate( 12582912 ); // Q22 - Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 - q_fact_orig = Quaternions_ref->q_fact; + Quaternions_ref = hCombinedOrientationData->Quaternions[0]; + q_fact_orig = Quaternions_ref.q_fact; - modify_Quat_q_fx( Quaternions_ref, Quaternions_ref, Q22 ); + modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) { /*HOA signal already rotated by DirAC*/ - Quaternions_abs.x_fx = 0; - Quaternions_abs.y_fx = 0; - Quaternions_abs.z_fx = 0; + Quaternions_ref2.x_fx = 0; + Quaternions_ref2.y_fx = 0; + Quaternions_ref2.z_fx = 0; } ELSE { /*euler*/ - Quat2EulerDegree_fx( *Quaternions_ref, &Quaternions_abs.z_fx, &Quaternions_abs.y_fx, &Quaternions_abs.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ } FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) @@ -1991,12 +1990,11 @@ void ivas_binRenderer_fx( Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } } - Quaternions_rel.x_fx = L_sub( pMultiBinPoseData->relative_head_poses_fx[pos_idx][0], pMultiBinPoseData->relative_head_poses_fx[pos_idx - 1][0] ); - Quaternions_rel.y_fx = L_sub( pMultiBinPoseData->relative_head_poses_fx[pos_idx][1], pMultiBinPoseData->relative_head_poses_fx[pos_idx - 1][1] ); - Quaternions_rel.z_fx = L_sub( pMultiBinPoseData->relative_head_poses_fx[pos_idx][2], pMultiBinPoseData->relative_head_poses_fx[pos_idx - 1][2] ); - Quaternions_abs.x_fx = L_add( Quaternions_abs.x_fx, Quaternions_rel.x_fx ); - Quaternions_abs.y_fx = L_add( Quaternions_abs.y_fx, Quaternions_rel.y_fx ); - Quaternions_abs.z_fx = L_add( Quaternions_abs.z_fx, Quaternions_rel.z_fx ); + + Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2e6085494..9917b6f40 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1493,7 +1493,7 @@ IVAS_DEC_GetSplitBinauralBitstream( Q_out[0] = 31; Word16 num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; - for ( i = 0; i < 16; i++ ) + for ( i = 0; i < i_mult( BINAURAL_CHANNELS, numPoses ); i++ ) { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { @@ -1502,12 +1502,12 @@ IVAS_DEC_GetSplitBinauralBitstream( } } Q_buff = s_min( q1, q2 ); - for ( i = 0; i < 16; i++ ) + for ( i = 0; i < i_mult( BINAURAL_CHANNELS, numPoses ); i++ ) { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { - scale_sig32( Cldfb_RealBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); - scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + scale_sig32( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); } } Q_buff = Q_buff + Q6; @@ -1526,7 +1526,7 @@ IVAS_DEC_GetSplitBinauralBitstream( FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { - scale_sig32( output[i], Q_out[0], L_FRAME48k ); + scale_sig32( output[i], L_FRAME48k, Q_out[0] ); } } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index d2b6e0f5c..0fb2c05a5 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -999,7 +999,7 @@ void ComputePredictors_fx( iA1Mag = ( iA1Mag > PRED_QUANT_FILTER_MAG_MIN ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MIN; iA1Mag = ( iA1Mag < PRED_QUANT_FILTER_MAG_MAX ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MAX; // fA1Mag = sinf(fInvMagScale * (float)iA1Mag); - fA1Mag_fx = L_deposit_l( getSinWord16( extract_l( L_shr( L_mult0( extract_l( fInvMagScale_fx ), extract_l( iA1Mag ) ), 2 ) ) ) ); // Q14 + fA1Mag_fx = L_deposit_l( shr( getSinWord16( extract_l( L_shr( L_mult0( extract_l( fInvMagScale_fx ), extract_l( iA1Mag ) ), 2 ) ) ), 1 ) ); // Q14 // fA1Phase = atan2f(fA1Imag, fA1Real); fA1Phase_fx = BASOP_util_atan2( fA1Imag_fx, fA1Real_fx, 0 ); // Q13 @@ -1025,7 +1025,7 @@ void ComputePredictors_fx( // fA1Real = fA1Mag * cosf(fA1Phase); fA1Real_fx = L_mult0( extract_l( fA1Mag_fx ), getCosWord16( extract_l( L_shr( L_temp, 2 ) ) ) ); // Q28 // fA1Imag = fA1Mag * sinf(fA1Phase); - fA1Imag_fx = L_mult0( extract_l( fA1Mag_fx ), getSinWord16( extract_l( L_shr( L_temp, 2 ) ) ) ); // Q28 + fA1Imag_fx = L_mult0( extract_l( fA1Mag_fx ), shr( getSinWord16( extract_l( L_shr( L_temp, 2 ) ) ), 1 ) ); // Q28 // fGain2 = 1.0f / (1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag); exp = 0; diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index c313e9ca4..82ac5558d 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -858,6 +858,9 @@ void isar_splitBinPostRendMdDec_fx( angle = sub( angle, 180 ); hBinHrSplitPostRend->QuaternionsPre[sf_idx].z_fx = L_shl( angle, Q22 ); /* Q22 */ move32(); + + hBinHrSplitPostRend->QuaternionsPre[sf_idx].q_fact = Q22; + move32(); } #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS @@ -1347,7 +1350,7 @@ static void get_interpolation_vars( Word16 *q_pitch, Word16 *q_roll ) { - IVAS_QUATERNION quaternions_diff, quaternions_ref_euler, quaternions_act_euler; + IVAS_QUATERNION quaternions_diff, quaternions_ref_euler, quaternions_act_euler, quaternions_ref_q22, quaternions_act_q22; Word32 y_fx[MAX_HEAD_ROT_POSES], p_fx[MAX_HEAD_ROT_POSES], r_fx[MAX_HEAD_ROT_POSES]; int16_t pos_idx, num_poses; @@ -1371,8 +1374,10 @@ static void get_interpolation_vars( /*interpolation if actual pose is not same as one of assumed poses*/ /*get the deviation*/ - Quat2EulerDegree_fx( *Quaternions_ref, &quaternions_ref_euler.z_fx, &quaternions_ref_euler.y_fx, &quaternions_ref_euler.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ - Quat2EulerDegree_fx( *Quaternions_act, &quaternions_act_euler.z_fx, &quaternions_act_euler.y_fx, &quaternions_act_euler.x_fx ); + modify_Quat_q_fx( Quaternions_ref, &quaternions_ref_q22, Q22 ); + modify_Quat_q_fx( Quaternions_act, &quaternions_act_q22, Q22 ); + Quat2EulerDegree_fx( quaternions_ref_q22, &quaternions_ref_euler.z_fx, &quaternions_ref_euler.y_fx, &quaternions_ref_euler.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + Quat2EulerDegree_fx( quaternions_act_q22, &quaternions_act_euler.z_fx, &quaternions_act_euler.y_fx, &quaternions_act_euler.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ quaternions_diff.w_fx = -12582912; /*euler*/ //-3 in Q22 diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 092358962..bf60095cb 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2130,9 +2130,10 @@ static void isar_SplitRenderer_quant_code( FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { Word16 angle; - IVAS_QUATERNION head_pos_euler; + IVAS_QUATERNION head_pos_euler, headPosition_q22; - Quat2EulerDegree_fx( headPosition, &head_pos_euler.z_fx, &head_pos_euler.y_fx, &head_pos_euler.x_fx ); + modify_Quat_q_fx( &headPosition, &headPosition_q22, Q22 ); + Quat2EulerDegree_fx( headPosition_q22, &head_pos_euler.z_fx, &head_pos_euler.y_fx, &head_pos_euler.x_fx ); angle = (Word16) L_shr_r( head_pos_euler.x_fx, Q22 ); angle = add( angle, 180 ); ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 768b23089..c59159061 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1268,9 +1268,10 @@ ivas_error ISAR_POST_REND_SetHeadRotation( hIvasRend->headRotData.headRotEnabled = 1; /* check for Euler angle signaling */ - IF( EQ_32( headRot.w_fx, -12582912 ) ) + IF( EQ_32( headRot.w_fx, -12582912 ) && EQ_32( headRot.q_fact, Q22 ) ) { Euler2Quat_fx( deg2rad_fx( headRot.x_fx ), deg2rad_fx( headRot.y_fx ), deg2rad_fx( headRot.z_fx ), &rotQuat ); + modify_Quat_q_fx( &rotQuat, &rotQuat, Q29 ); } ELSE { diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index bafb68a15..f528d0348 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -402,7 +402,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Word16 Q_Cldfb_re = 31, Q_Cldfb_im = 31; move16(); move16(); - FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < hSplitBin->multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) { FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { @@ -410,7 +410,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_Cldfb_im = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX ), Q_Cldfb_im ); } } - FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < hSplitBin->multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) { FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index bacdec5d1..87afb721c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8962,8 +8962,8 @@ static ivas_error getSamplesInternal( { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { - scale_sig32( Cldfb_RealBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); - scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], Q_buff, CLDFB_NO_CHANNELS_MAX ); + scale_sig32( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); } } Q_buff = Q_buff + Q6; @@ -8980,7 +8980,7 @@ static ivas_error getSamplesInternal( FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { - scale_sig32( tmpBinaural_buff[i], Q_out[0], L_FRAME48k ); + scale_sig32( tmpBinaural_buff[i], L_FRAME48k, Q_out[0] ); } Q_out[0] = Q_out[0] + *outAudio.pq_fact; -- GitLab From 95a6efce548173b6b0c53bf197c5c1447615abfa Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 12 Feb 2025 11:13:52 +0100 Subject: [PATCH 072/329] applied the patches from the review. --- lib_enc/ACcontextMapping_enc_fx.c | 85 +++++++++++++++---------------- lib_enc/stat_enc.h | 2 +- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 2c58b4557..f0298a647 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -16,8 +16,8 @@ #include "prot_fx_enc.h" #include "ivas_prot.h" /* Range coder header file */ -#define MAKE_NUMBER_QX(number,QX) ((number)<<(QX)) -#define MAKE_VARIABLE_QX(variable,QX) W_shl(W_deposit32_l(L_deposit_l(( variable) ) ), (QX)) +#define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) +#define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /*-------------------------------------------------------------------* * ACcontextMapping_encode2_no_mem_s17_LC_fx() @@ -1218,15 +1218,15 @@ static Word16 find_last_nz_pair_fx( *-------------------------------------------------------------------*/ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( - Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ - Word16 *lastnz_out, /* Q0 */ - Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ - Word16 *stop, /* Q0 */ - Word16 mode, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ - ) + Word16 *x, /* Spectral coefficients Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + Word16 *lastnz_out, /* Q0 */ + Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ + const Word16 target, /* Target bits Q0*/ + Word16 *stop, /* Q0 */ + Word16 mode, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ +) { /* Common variables */ Word16 a1, b1; @@ -1234,14 +1234,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( UWord16 t; Word16 lastnz, lastnz2; Word16 rateFlag; - Word64 bit_estimate_accu; + Word64 bit_estimate_fx; Word16 symbol; const UWord8 *lookup; Word64 nbits2_accu; /* Initialization */ - bit_estimate_accu = MAKE_NUMBER_QX(2, Q23 ); + bit_estimate_fx = MAKE_NUMBER_QX(2, Q23 ); move64(); nbits2_accu = 0; @@ -1255,14 +1255,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( WHILE( LT_16( k, nt / 2 ) ) { - bit_estimate_accu = W_add( bit_estimate_accu, MAKE_NUMBER_QX(1, Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX(1, Q23 ) ); k = shl( k, 1 ); i = add( i, 2 ); /* check while condition */ } - nbits2_accu = bit_estimate_accu; + nbits2_accu = bit_estimate_fx; move64(); IF( hm_cfg ) @@ -1350,8 +1350,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( b1 = (Word16) abs( x[b1_i] ); lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); - bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); - bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); @@ -1361,8 +1361,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { pki = lookup[lev1]; /* ESC symbol */ - bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX(2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1374,10 +1374,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[lev1]; symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ - bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ - IF( GT_32( W_shr( bit_estimate_accu, Q8 ), L_shl( target, Q15 ) ) ) + IF( GT_32( W_shr( bit_estimate_fx, Q8 ), L_shl( target, Q15 ) ) ) { stop2 = 1; move16(); @@ -1390,7 +1390,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ELSE { lastnz2 = add( b1_i, 1 ); - nbits2_accu = bit_estimate_accu; + nbits2_accu = bit_estimate_fx; move64(); } @@ -1432,7 +1432,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( W_shr(bit_estimate_accu, Q7 ) ); + total_output_bits = round_fx( W_shr(bit_estimate_fx, Q7 ) ); IF( *stop ) { @@ -1528,8 +1528,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) ); /* Q0 */ - bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); - bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */ lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )]; /* Q0 */ @@ -1541,8 +1541,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ move16(); - bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX(2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1557,10 +1557,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ - bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ - IF( GT_32( W_shr( bit_estimate_accu, Q8 ), L_shl( target, Q15 ) ) ) + IF( GT_32( W_shr( bit_estimate_fx, Q8 ), L_shl( target, Q15 ) ) ) { overflow_flag = 1; move16(); @@ -1569,7 +1569,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */ { - nbits2_accu = bit_estimate_accu; /* exp(bit_estimate_e) */ + nbits2_accu = bit_estimate_fx; /* exp(bit_estimate_e) */ move64(); lastnz2 = add( k, 2 ); @@ -1599,7 +1599,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } IF( EQ_16( mode, -1 ) ) { - tot_bits2 = round_fx( W_shr( bit_estimate_accu, Q7 ) ); + tot_bits2 = round_fx( W_shr( bit_estimate_fx, Q7 ) ); } IF( overflow_flag == 0 ) /* No overflow */ { @@ -1614,7 +1614,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } ELSE { - *stop = round_fx( W_shr( bit_estimate_accu, Q7 ) ); + *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); move16(); } } @@ -1665,7 +1665,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( move16(); } - hContextMem->bit_estimate_accu = MAKE_NUMBER_QX(2, Q23 ); + hContextMem->bit_estimate_fx = MAKE_NUMBER_QX(2, Q23 ); move64(); @@ -1682,7 +1682,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( WHILE( LT_16( k, hContextMem->nt_half ) ) { - hContextMem->bit_estimate_accu = W_add( hContextMem->bit_estimate_accu, MAKE_NUMBER_QX(1, Q23 ) ); + hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) ); move64(); k = shl( k, 1 ); @@ -1769,8 +1769,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */ /* Signs Bits */ - hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); - hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); move32(); move32(); @@ -1785,13 +1785,12 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( pki = lookup[lev1]; /* Q0 */ move16(); - hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) ); + hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); move32(); move32(); - // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC]; // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */ @@ -1804,8 +1803,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( pki = lookup[lev1]; /* Q0 */ move16(); - symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ - hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ + hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); move32(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol]; @@ -1825,8 +1824,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */ move16(); - } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_accu, Q7 ) ); /* Q0 */ + } /*end of the 2-tuples loop*/ + total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index a3a743509..ee7f7f9b4 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -2348,7 +2348,7 @@ typedef struct context_rc_mem_struct { int16_t nbits_old; int16_t ctx; - Word64 bit_estimate_accu; + Word64 bit_estimate_fx; int16_t rateFlag; int16_t lastnz; int16_t nt_half; -- GitLab From 4454ffcb6b9557f8f989a470878993c52fce6f6e Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 12 Feb 2025 11:30:22 +0100 Subject: [PATCH 073/329] added a comment for the datatype (Q23). --- lib_enc/ACcontextMapping_enc_fx.c | 2 +- lib_enc/stat_enc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index f0298a647..d20db6b86 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1234,7 +1234,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( UWord16 t; Word16 lastnz, lastnz2; Word16 rateFlag; - Word64 bit_estimate_fx; + Word64 bit_estimate_fx; /* Q23 */ Word16 symbol; const UWord8 *lookup; diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index ee7f7f9b4..0fa9aeb88 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -2348,7 +2348,7 @@ typedef struct context_rc_mem_struct { int16_t nbits_old; int16_t ctx; - Word64 bit_estimate_fx; + Word64 bit_estimate_fx; /* Q23 */ int16_t rateFlag; int16_t lastnz; int16_t nt_half; -- GitLab From ea99231dc0aac04b07fbe0ef59ee1b80919e3f31 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 12 Feb 2025 12:28:52 +0100 Subject: [PATCH 074/329] applied the formatting patch. --- lib_enc/ACcontextMapping_enc_fx.c | 72 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index d20db6b86..0e816e77c 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1238,10 +1238,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 symbol; const UWord8 *lookup; - Word64 nbits2_accu; + Word64 nbits2_accu; /* Initialization */ - bit_estimate_fx = MAKE_NUMBER_QX(2, Q23 ); + bit_estimate_fx = MAKE_NUMBER_QX( 2, Q23 ); move64(); nbits2_accu = 0; @@ -1255,11 +1255,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( WHILE( LT_16( k, nt / 2 ) ) { - bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX(1, Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) ); k = shl( k, 1 ); i = add( i, 2 ); /* check while condition */ - } nbits2_accu = bit_estimate_fx; @@ -1362,7 +1361,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[lev1]; /* ESC symbol */ bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX(2, Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1373,7 +1372,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[lev1]; - symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ + symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ @@ -1390,7 +1389,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ELSE { lastnz2 = add( b1_i, 1 ); - nbits2_accu = bit_estimate_fx; + nbits2_accu = bit_estimate_fx; move64(); } @@ -1432,7 +1431,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( W_shr(bit_estimate_fx, Q7 ) ); + total_output_bits = round_fx( W_shr( bit_estimate_fx, Q7 ) ); IF( *stop ) { @@ -1542,7 +1541,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX(2, Q23 ) ); + bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1556,7 +1555,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ move16(); - symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ + symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ @@ -1607,37 +1606,37 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); } ELSE /* Overflow */ - { - IF( *stop ){ - *stop = tot_bits2; /* Q0 */ - move16(); - } - ELSE { - *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); - move16(); - } - } - - *lastnz_out = lastnz; /* Q0 */ + IF( *stop ){ + *stop = tot_bits2; /* Q0 */ move16(); - *nEncoded = lastnz2; /* Q0 */ + } + ELSE + { + *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); move16(); - /* Safety mechanism to avoid overflow */ - test(); - IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) - { - FOR( k = 0; k < lastnz2; k++ ) - { - x[k] = 0; - move16(); - } - } + } +} - return tot_bits2; +*lastnz_out = lastnz; /* Q0 */ +move16(); +*nEncoded = lastnz2; /* Q0 */ +move16(); +/* Safety mechanism to avoid overflow */ +test(); +IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) +{ + FOR( k = 0; k < lastnz2; k++ ) + { + x[k] = 0; + move16(); } } +return tot_bits2; +} +} + /*-------------------------------------------------------------------* * RCcontextMapping_encode2_estimate_bandWise_start_fx() @@ -1665,9 +1664,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( move16(); } - hContextMem->bit_estimate_fx = MAKE_NUMBER_QX(2, Q23 ); + hContextMem->bit_estimate_fx = MAKE_NUMBER_QX( 2, Q23 ); move64(); - /* Init */ @@ -1824,7 +1822,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */ move16(); - } /*end of the 2-tuples loop*/ + } /*end of the 2-tuples loop*/ total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); -- GitLab From 1ed2851535b85c983858296f3a4b977f57bcb257 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Feb 2025 21:32:05 +0530 Subject: [PATCH 075/329] Fix for 3GPP issue 1202: BASOP encoder ParamISM: strong timbre differences in the noise track Link #1202 --- lib_enc/ivas_ism_param_enc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 1430607d6..5e91a30fb 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -307,7 +307,7 @@ void ivas_param_ism_stereo_dmx_fx( /* Smoothing */ cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14 move16(); - grad = mult( sub( cardioid_left[i], last_cardioid_left ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ); /* Q14 */ /* for the right cardioid, multiply with -1 */ + Word32 grad_32 = L_mult( sub( cardioid_left[i], last_cardioid_left ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ); /* Q14+Q16 = Q30 */ /* for the right cardioid, multiply with -1 */ /* Cardioids sum up to 1 */ cardioid_right[i] = sub( ONE_IN_Q14 /* 1.0f in Q14 */, cardioid_left[i] ); /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */ move16(); @@ -316,13 +316,13 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = data[i][j]; move32(); - tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_left, mult0( j, grad ) ) ), 15 ) ); /* Qx DMX Left */ - stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ + tmp = W_extract_l( W_shr( W_mult_32_32( tmp, L_add( last_cardioid_left, L_shr( Mpy_32_32( L_shl( j, 22 ), grad_32 ), 7 ) ) ), 15 ) ); /* Qx DMX Left */ + stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ move32(); tmp = data[i][j]; move32(); - tmp = W_extract_l( W_shr( W_mult_32_16( tmp, add( last_cardioid_right, negate( mult0( j, grad ) ) ) ), 15 ) ); /* Qx DMX Right */ - stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ + tmp = W_extract_l( W_shr( W_mult_32_32( tmp, L_add( last_cardioid_right, L_shr( L_negate( Mpy_32_32( L_shl( j, 22 ), grad_32 ) ), 7 ) ) ), 15 ) ); /* Qx DMX Right */ + stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ move32(); ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */ } -- GitLab From 40b6e9836cbf04043fc209993844af4569ce76af Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 13 Feb 2025 14:36:53 +1100 Subject: [PATCH 076/329] fixes to MASA and ISM split pre-renderer --- lib_dec/ivas_objectRenderer_internal.c | 13 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 123 +++++++++++-------- 2 files changed, 81 insertions(+), 55 deletions(-) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 8a73539be..4c0b92888 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -366,6 +366,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( Word16 original_slots_rendered; Word32 *p_bin_output[BINAURAL_CHANNELS]; Word32 output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word16 q_fact_orig[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; @@ -399,6 +400,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) { originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i]; + q_fact_orig[i] = originalHeadRot[i].q_fact; } original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; @@ -408,18 +410,20 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( origTdRendHandle = st_ivas->hBinRendererTd; move32(); + FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 ); + } + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { /* Update head positions */ IF( NE_16( pos_idx, 0 ) ) { COMBINED_ORIENTATION_HANDLE pCombinedOrientationData = st_ivas->hCombinedOrientationData; - Word16 q_fact_orig; FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) { pCombinedOrientationData->Quaternions[i].w_fx = L_negate( 12582912 ); // Q22 - q_fact_orig = originalHeadRot[i].q_fact; - modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 ); /*euler*/ Quat2EulerDegree_fx( originalHeadRot[i], &pCombinedOrientationData->Quaternions[i].z_fx, @@ -433,7 +437,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( deg2rad_fx( pCombinedOrientationData->Quaternions[i].y_fx ), deg2rad_fx( pCombinedOrientationData->Quaternions[i].z_fx ), &pCombinedOrientationData->Quaternions[i] ); - modify_Quat_q_fx( &pCombinedOrientationData->Quaternions[i], &pCombinedOrientationData->Quaternions[i], q_fact_orig ); + modify_Quat_q_fx( &pCombinedOrientationData->Quaternions[i], &pCombinedOrientationData->Quaternions[i], q_fact_orig[i] ); } } @@ -482,6 +486,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( /* Restore original head rotation */ FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) { + modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], q_fact_orig[i] ); st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; move32(); } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index ea975dfbe..0d6673fa8 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -123,7 +123,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); #ifdef SPLIT_REND_WITH_HEAD_ROT -static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat, Word32 outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word8 recompute ); +static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat, Word32 outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *Q_inp_mix, const Word8 recompute ); #else static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat ); #endif @@ -694,6 +694,7 @@ static void ivas_dirac_dec_binaural_internal_fx( Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX]; Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX]; Word32 IIReneLimiter_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 Q_inp_mix; hDiracDecBin = st_ivas->hDiracDecBin[0]; #else @@ -1116,7 +1117,7 @@ static void ivas_dirac_dec_binaural_internal_fx( #endif { ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, - tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1130,7 +1131,7 @@ static void ivas_dirac_dec_binaural_internal_fx( ELSE { ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, - reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); } #else ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); @@ -1162,6 +1163,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move32(); move32(); move32(); + Euler2Quat_fx( deg2rad_fx( Quaternions_rot.x_fx ), deg2rad_fx( Quaternions_rot.y_fx ), deg2rad_fx( Quaternions_rot.z_fx ), &Quaternions_rot ); modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact ); QuatToRotMat_fx( Quaternions_rot, Rmat_local ); @@ -1173,12 +1175,15 @@ static void ivas_dirac_dec_binaural_internal_fx( } /* re-use input covariance for the side renderings */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { Copy32( st_ivas->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands ); + Copy( st_ivas->hDiracDecBin[0]->ChEne_e[ch], hDiracDecBin->ChEne_e[ch], hSpatParamRendCom->num_freq_bands ); } Copy32( st_ivas->hDiracDecBin[0]->ChCrossRe_fx, hDiracDecBin->ChCrossRe_fx, hSpatParamRendCom->num_freq_bands ); Copy32( st_ivas->hDiracDecBin[0]->ChCrossIm_fx, hDiracDecBin->ChCrossIm_fx, hSpatParamRendCom->num_freq_bands ); + Copy( st_ivas->hDiracDecBin[0]->ChCrossRe_e, hDiracDecBin->ChCrossRe_e, hSpatParamRendCom->num_freq_bands ); + Copy( st_ivas->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, @@ -1227,7 +1232,7 @@ static void ivas_dirac_dec_binaural_internal_fx( /* re-use reverb and decorr from main direction for the sides */ ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, - tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 0 ); + tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 0 ); /* copy from temporary buffer to the main split rendering buffer */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -3399,6 +3404,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 reverbIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + Word16 *Q_inp_mix, const Word8 recompute #endif ) @@ -3442,69 +3448,82 @@ static void ivas_dirac_dec_binaural_process_output_fx( #endif } - // scaling input and reverb to same q// - // input scaling is to maintain precision in ivas_dirac_dec_decorrelate_slot fn// - Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) ); - q_inp_mix = 31; - move16(); - FOR( Word16 i = 0; i < 6; i++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( recompute, 1 ) ) { - FOR( Word16 j = 0; j < nSlots; j++ ) +#endif + // scaling input and reverb to same q// + // input scaling is to maintain precision in ivas_dirac_dec_decorrelate_slot fn// + Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) ); + q_inp_mix = 31; + move16(); + FOR( Word16 i = 0; i < 6; i++ ) { - q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], nBins ), L_norm_arr( inIm_fx[i][j], nBins ) ); - move16(); - test(); + FOR( Word16 j = 0; j < nSlots; j++ ) + { + q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], nBins ), L_norm_arr( inIm_fx[i][j], nBins ) ); + move16(); + test(); #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) + IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) #else IF( ( processReverb ) && LT_16( i, 2 ) ) #endif - { - q_reverb = s_min( L_norm_arr( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); - q_inp[i][j] = s_min( q_reverb, q_inp[i][j] ); - move16(); + { + q_reverb = s_min( L_norm_arr( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); + q_inp[i][j] = s_min( q_reverb, q_inp[i][j] ); + move16(); + } + q_inp_mix = s_min( q_inp[i][j], q_inp_mix ); } - q_inp_mix = s_min( q_inp[i][j], q_inp_mix ); } - } - q_inp_mix = sub( q_inp_mix, 3 ); // gaurded bits// + q_inp_mix = sub( q_inp_mix, 3 ); // gaurded bits// - Word16 cldfb_state_shift = sub( add( add( q_inp_mix, q_mat ), sub( q_input, 16 ) ), cldfbSynDec[0]->Q_cldfb_state ); - IF( GT_16( cldfb_state_shift, shift ) ) - { - q_inp_mix = sub( add( q_inp_mix, shift ), cldfb_state_shift ); - cldfb_state_shift = shift; - move16(); - } + Word16 cldfb_state_shift = sub( add( add( q_inp_mix, q_mat ), sub( q_input, 16 ) ), cldfbSynDec[0]->Q_cldfb_state ); + IF( GT_16( cldfb_state_shift, shift ) ) + { + q_inp_mix = sub( add( q_inp_mix, shift ), cldfb_state_shift ); + cldfb_state_shift = shift; + move16(); + } - FOR( Word16 i = 0; i < 6; i++ ) - { - FOR( Word16 j = 0; j < nSlots; j++ ) + FOR( Word16 i = 0; i < 6; i++ ) { + FOR( Word16 j = 0; j < nSlots; j++ ) + { - scale_sig32( inRe_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ - scale_sig32( inIm_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ - test(); + scale_sig32( inRe_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ + scale_sig32( inIm_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ + test(); #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) + IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) #else IF( ( processReverb ) && LT_16( i, 2 ) ) #endif - { - scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ - scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ + { + scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ + scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ + } } } - } - // scaling cldfb states to q_result-1// - scale_sig32( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length, cldfb_state_shift ); - cldfbSynDec[0]->Q_cldfb_state = add( cldfbSynDec[0]->Q_cldfb_state, cldfb_state_shift ); - scale_sig32( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length, cldfb_state_shift ); - cldfbSynDec[1]->Q_cldfb_state = add( cldfbSynDec[1]->Q_cldfb_state, cldfb_state_shift ); - move16(); - move16(); + // scaling cldfb states to q_result-1// + scale_sig32( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length, cldfb_state_shift ); + cldfbSynDec[0]->Q_cldfb_state = add( cldfbSynDec[0]->Q_cldfb_state, cldfb_state_shift ); + scale_sig32( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length, cldfb_state_shift ); + cldfbSynDec[1]->Q_cldfb_state = add( cldfbSynDec[1]->Q_cldfb_state, cldfb_state_shift ); + move16(); + move16(); +#ifdef SPLIT_REND_WITH_HEAD_ROT + *Q_inp_mix = q_inp_mix; + move16(); + } + ELSE + { + q_inp_mix = *Q_inp_mix; + } +#endif q_inp_mix = add( q_inp_mix, q_input ); @@ -6511,6 +6530,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX]; Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX]; Word32 IIReneLimiter_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 Q_inp_mix; hDiracDecBin = hMasaExtRend->hDiracDecBin[0]; #else @@ -6718,7 +6738,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( pMultiBinPoseData = &( hSplitRendWrapper->multiBinPoseData ); ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, - reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -6732,7 +6752,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( else { ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, - reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 ); + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); } #else ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); @@ -6765,6 +6785,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move32(); move32(); move32(); + Euler2Quat_fx( deg2rad_fx( Quaternions_rot.x_fx ), deg2rad_fx( Quaternions_rot.y_fx ), deg2rad_fx( Quaternions_rot.z_fx ), &Quaternions_rot ); modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact ); QuatToRotMat_fx( Quaternions_rot, Rmat_local ); @@ -6824,7 +6845,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); /* re-use reverb and decorr from main direction for the sides */ ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, - reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 0 ); + reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 0 ); /* copy from temporary buffer to the main split rendering buffer */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) -- GitLab From 71d8bfca7aa86fa27d812fdecb0bb0b452cb6154 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 13 Feb 2025 15:42:40 +1100 Subject: [PATCH 077/329] fixes to MC crend --- lib_rend/ivas_crend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index faf696393..a974364f4 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2686,6 +2686,10 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( move32(); move32(); move32(); + Euler2Quat_fx( deg2rad_fx( combinedOrientationDataLocal.Quaternions[i].x_fx ), + deg2rad_fx( combinedOrientationDataLocal.Quaternions[i].y_fx ), + deg2rad_fx( combinedOrientationDataLocal.Quaternions[i].z_fx ), + &combinedOrientationDataLocal.Quaternions[i] ); modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Quaternions_orig[i].q_fact ); QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); } -- GitLab From 2e7c1ae960402cda3f53da9dd2a47e5251eb931e Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 13 Feb 2025 18:08:18 +1100 Subject: [PATCH 078/329] fixes in OSBA and OMASA --- lib_dec/ivas_omasa_dec.c | 10 +++++++++- lib_dec/ivas_osba_dec.c | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 0079ae4de..bce96994d 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -808,7 +808,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Word32 Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; Word32 *p_rend_obj[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* [8 * 2] */ - Word16 q_cldfb = 11; + Word16 q_cldfb, q_in = 11; move16(); FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); n++ ) @@ -834,10 +834,18 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); ++n ) { + q_cldfb = q_in; + Scale_sig32( st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->cldfb_state_fx, + sub( st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->p_filter_length, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->no_channels ), + sub( q_cldfb, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->Q_cldfb_state ) ); + st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->Q_cldfb_state = q_cldfb; FOR( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) { + q_cldfb = q_in; cldfbAnalysis_ts_fx_fixed_q( &( p_rend_obj[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n], &q_cldfb ); + Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); + Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); /* note: this intentionally differs from OSBA by: no scaling by 0.5 */ v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_RealBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_ImagBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 1c008caa0..47288e820 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -167,7 +167,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Word16 cldfb_slots; Word32 Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - Word16 q_cldfb = 11; + Word16 q_cldfb, q_in = 11; move16(); num_cldfb_bands = st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[0]->no_channels; @@ -186,11 +186,18 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( FOR( n = 0; n < i_mult( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses, BINAURAL_CHANNELS ); ++n ) { + q_cldfb = q_in; + Scale_sig32( st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->cldfb_state_fx, + sub( st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->p_filter_length, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->no_channels ), + sub( q_cldfb, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->Q_cldfb_state ) ); + st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->Q_cldfb_state = q_cldfb; FOR( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) { + q_cldfb = q_in; cldfbAnalysis_ts_fx_fixed_q( &( output_fx[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n], &q_cldfb ); Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); + Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); FOR( b = 0; b < num_cldfb_bands; b++ ) { st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx][b] = -- GitLab From 018322d6e02720037f50f6f003a858057f4a81cf Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Feb 2025 16:33:45 +0530 Subject: [PATCH 079/329] Fix for 3GPP issue 1291: Wrong use of imult1616() in ACELP rescaling Link #1291 --- lib_com/cnst.h | 1 + lib_com/options.h | 1 + lib_dec/acelp_core_dec_ivas_fx.c | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index a5030ac9c..197fbd3c4 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1536,6 +1536,7 @@ enum #define SHB_OVERLAP_LEN ( L_FRAME16k - L_SHB_LAHEAD ) / ( NUM_SHB_SUBFR - 1 ) #define QUANT_DIST_INIT ( 10000000000.0f ) /* Quantiser search distance initialisation */ #define HIBND_ACB_L_FAC 5 / 2 /* SHB Interpolation Factor */ +#define HIBND_ACB_L_FAC_Q1 ( 5 ) /* SHB Interpolation Factor Q1 */ #define NUM_HILBERTS 2 #define HILBERT_ORDER1 5 #define HILBERT_ORDER2 4 diff --git a/lib_com/options.h b/lib_com/options.h index d6bbaf88a..5f585d891 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,7 @@ #define FIX_ISSUE_1214 /* Ittiam: Fix for issue 1214: Energy leakage in IGF tiles for MDCT-stereo @64kbps SWB*/ #define FIX_881_HILBERT_FILTER /* VA: improve the precision of the Hilbert filter to remove 2kHz unwanted tone */ #define FIX_ISSUE_1245 /* Ittiam: Fix for issue 1245: Basop Encoder: Audible noise for silent Stereo input DTX on @24.4 kbps, @32 kbps*/ +#define FIX_ISSUE_1291 /* Ittiam: Wrong use of imult1616() in ACELP rescaling */ #define FIX_920_IGF_INIT_ERROR /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */ #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ #define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index e52c52c7c..165594e77 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -748,7 +748,11 @@ ivas_error acelp_core_dec_ivas_fx( IF( st->hMusicPF && st->hGSCDec ) { Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, +#ifdef FIX_ISSUE_1291 + shr( imult1616( st->L_frame, HIBND_ACB_L_FAC_Q1 ), 1 ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); +#else imult1616( st->L_frame, HIBND_ACB_L_FAC ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); +#endif } IF( st->hPFstat != NULL ) { -- GitLab From 3ea6e92d666de55982e2fc5dded4a33000838471 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 13:26:19 +0100 Subject: [PATCH 080/329] add new stage for checking BE with target branch --- .gitlab-ci.yml | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc48090cd..a19358b6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,6 +110,7 @@ stages: - .pre - prevalidate - build + - check-be - test - deploy @@ -410,6 +411,62 @@ stages: junit: - report-junit.xml +.check-be-to-target-anchor: &check-be-to-target-anchor + stage: check-be + needs: ["build-codec-linux-make"] + timeout: "300 minutes" + variables: + XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" + HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" + FAILED_TESTCASES_LIST: "failed-testcases.txt" + script: + - set -euxo pipefail + - *print-common-info + - *update-scripts-repo + + - if [ $USE_LTV -eq 1 ]; then + - *update-ltv-repo + - *copy-ltv-files-to-testv-dir + - testcase_timeout=$TESTCASE_TIMEOUT_LTV + - else + - testcase_timeout=$TESTCASE_TIMEOUT_STV + - fi + + - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - if [ $LEVEL_SCALING != "1.0" ];then + - *apply-testv-scaling + - fi + + - *build-and-create-reference-outputs + + - exit_code=0 + - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true + + - touch $FAILED_TESTCASES_LIST + - if [ $exit_code -ne 0 ]; then + - exit_code=$EXIT_CODE_NON_BE + - grep "FAILED" pytest_log.txt | sed 's/^FAILED //' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST + - fi + + - exit $exit_code + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" + expire_in: 1 week + when: always + paths: + - $XML_REPORT + - $HTML_REPORT + expose_as: "pytest compare results" + reports: + junit: + - $XML_REPORT_BRANCH + - $XML_REPORT_MAIN + .ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor stage: test needs: ["build-codec-linux-make"] @@ -789,6 +846,19 @@ build-codec-windows-msbuild: # Short test jobs that run in merge request pipelines # --------------------------------------------------------------- +### jobs that check for bitexactness of fx encoder and decoder +check-be-to-target-short-enc-0db: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_DECODER_PATH=./IVAS_dec_ref + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=1.0 + - SKIP_REGRESSION_CHECK="true" + <<: *check-be-to-target-anchor + ### jobs that test fx encoder -> flt decoder ivas-pytest-compare_to_main-short-enc: extends: -- GitLab From 4823811f127ba86dd516b6f840ca6570ff070cdf Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 13:27:05 +0100 Subject: [PATCH 081/329] disable jobs to save time --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a19358b6a..41e70e8eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -860,7 +860,7 @@ check-be-to-target-short-enc-0db: <<: *check-be-to-target-anchor ### jobs that test fx encoder -> flt decoder -ivas-pytest-compare_to_main-short-enc: +.ivas-pytest-compare_to_main-short-enc: extends: - .rules-pytest-to-main-short - .test-job-linux @@ -872,7 +872,7 @@ ivas-pytest-compare_to_main-short-enc: - SKIP_REGRESSION_CHECK="true" <<: *ivas-pytest-on-merge-request-anchor -ivas-pytest-compare_to_main-short-enc-lev-10: +.ivas-pytest-compare_to_main-short-enc-lev-10: extends: - .rules-pytest-to-main-short - .test-job-linux @@ -884,7 +884,7 @@ ivas-pytest-compare_to_main-short-enc-lev-10: - SKIP_REGRESSION_CHECK="true" <<: *ivas-pytest-on-merge-request-anchor -ivas-pytest-compare_to_main-short-enc-lev+10: +.ivas-pytest-compare_to_main-short-enc-lev+10: extends: - .rules-pytest-to-main-short - .test-job-linux @@ -897,7 +897,7 @@ ivas-pytest-compare_to_main-short-enc-lev+10: <<: *ivas-pytest-on-merge-request-anchor ### jobs that test flt encoder -> fx decoder -ivas-pytest-compare_to_main-short-dec: +.ivas-pytest-compare_to_main-short-dec: extends: - .rules-pytest-to-main-short - .test-job-linux @@ -909,7 +909,7 @@ ivas-pytest-compare_to_main-short-dec: - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -ivas-pytest-compare_to_main-short-dec-lev-10: +.ivas-pytest-compare_to_main-short-dec-lev-10: extends: - .rules-pytest-to-main-short - .test-job-linux @@ -921,7 +921,7 @@ ivas-pytest-compare_to_main-short-dec-lev-10: - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -ivas-pytest-compare_to_main-short-dec-lev+10: +.ivas-pytest-compare_to_main-short-dec-lev+10: extends: - .rules-pytest-to-main-short - .test-job-linux -- GitLab From 74319da31f87d17fdc7ccf301485ffa83e4dfa90 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 13:52:02 +0100 Subject: [PATCH 082/329] set REFERENCE_BRANCH correctly --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 41e70e8eb..d34fbf169 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -416,6 +416,7 @@ stages: needs: ["build-codec-linux-make"] timeout: "300 minutes" variables: + REFERENCE_BRANCH: "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" FAILED_TESTCASES_LIST: "failed-testcases.txt" @@ -441,7 +442,7 @@ stages: - exit_code=0 - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true + - zero_errors_branch=$(cat $XML_REPORT | grep -c 'errors="0"') || true - touch $FAILED_TESTCASES_LIST - if [ $exit_code -ne 0 ]; then -- GitLab From 0c8ec9b91662d084a339802d4b68fb2a19d2bcb6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 14:28:42 +0100 Subject: [PATCH 083/329] first shorter test version with needs relation --- .gitlab-ci.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d34fbf169..9a8e4cf44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -185,7 +185,7 @@ stages: - enc_dmx_arg="--compare_enc_dmx" - fi - - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? + - python3 -m pytest -k "stereo and at" $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? .update-scripts-repo: &update-scripts-repo - cd $SCRIPTS_DIR @@ -441,7 +441,7 @@ stages: - *build-and-create-reference-outputs - exit_code=0 - - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest -k "stereo and at" --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - zero_errors_branch=$(cat $XML_REPORT | grep -c 'errors="0"') || true - touch $FAILED_TESTCASES_LIST @@ -467,6 +467,7 @@ stages: junit: - $XML_REPORT_BRANCH - $XML_REPORT_MAIN + - $FAILED_TESTCASES_LIST .ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor stage: test @@ -485,6 +486,9 @@ stages: - set -euxo pipefail - *print-common-info - *update-scripts-repo + + - ls + - if [ $USE_LTV -eq 1 ]; then - *update-ltv-repo - *copy-ltv-files-to-testv-dir @@ -860,6 +864,22 @@ check-be-to-target-short-enc-0db: - SKIP_REGRESSION_CHECK="true" <<: *check-be-to-target-anchor +check-regressions-short-enc-0db: + stage: test + needs: + - job: "check-be-to-target-short-enc-0db" + artifacts: true + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_DECODER_PATH=./IVAS_dec_ref + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=1.0 + - SKIP_REGRESSION_CHECK="true" + <<: *ivas-pytest-on-merge-request-anchor + ### jobs that test fx encoder -> flt decoder .ivas-pytest-compare_to_main-short-enc: extends: -- GitLab From cde22561d513cb94e03a99e2d1a478265a4002a2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 14:35:06 +0100 Subject: [PATCH 084/329] remove needs: in anchor to not overwrite value from job --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a8e4cf44..05f531b7f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -471,7 +471,6 @@ stages: .ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor stage: test - needs: ["build-codec-linux-make"] timeout: "300 minutes" variables: XML_REPORT_BRANCH: "report-junit-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" -- GitLab From 2a5b563122d4e82278c17d17f22e5b645faf0bf7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 14:41:07 +0100 Subject: [PATCH 085/329] fix artifacts --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05f531b7f..4fa731231 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -450,6 +450,8 @@ stages: - grep "FAILED" pytest_log.txt | sed 's/^FAILED //' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST - fi + - cat $FAILED_TESTCASES_LIST + - exit $exit_code allow_failure: @@ -462,12 +464,12 @@ stages: paths: - $XML_REPORT - $HTML_REPORT + - $FAILED_TESTCASES_LIST expose_as: "pytest compare results" reports: junit: - - $XML_REPORT_BRANCH - - $XML_REPORT_MAIN - - $FAILED_TESTCASES_LIST + - $XML_REPORT + - $XML_REPORT .ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor stage: test -- GitLab From 403c61ad3b7ff7f0ff81075c0325592894b6ae32 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 14:50:52 +0100 Subject: [PATCH 086/329] improve failed testcase parsing and add dbg artifact --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4fa731231..747f03d13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -441,13 +441,13 @@ stages: - *build-and-create-reference-outputs - exit_code=0 - - python3 -m pytest -k "stereo and at" --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest -k "stereo and at" --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - zero_errors_branch=$(cat $XML_REPORT | grep -c 'errors="0"') || true - touch $FAILED_TESTCASES_LIST - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE - - grep "FAILED" pytest_log.txt | sed 's/^FAILED //' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST - fi - cat $FAILED_TESTCASES_LIST @@ -465,6 +465,7 @@ stages: - $XML_REPORT - $HTML_REPORT - $FAILED_TESTCASES_LIST + - pytest_log.txt expose_as: "pytest compare results" reports: junit: -- GitLab From 3cae2338706c558cdb1a3b92258076b3c435d959 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 15:02:25 +0100 Subject: [PATCH 087/329] amend pipeline for getting the failed testcases --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 747f03d13..77bba1c95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -447,7 +447,7 @@ stages: - touch $FAILED_TESTCASES_LIST - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST - fi - cat $FAILED_TESTCASES_LIST -- GitLab From 4535432e323fffaf8b8462f4bed0d685b5d187cc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 15:10:42 +0100 Subject: [PATCH 088/329] check artifacts for BE in comparison job --- .gitlab-ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77bba1c95..b15c5939f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,7 @@ variables: ENCODER_TEST: "" COMPARE_DMX: "" SKIP_REGRESSION_CHECK: "" + FAILED_TESTCASES_LIST: "failed-testcases.txt" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -419,7 +420,6 @@ stages: REFERENCE_BRANCH: "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" - FAILED_TESTCASES_LIST: "failed-testcases.txt" script: - set -euxo pipefail - *print-common-info @@ -487,9 +487,16 @@ stages: script: - set -euxo pipefail - *print-common-info - - *update-scripts-repo - - ls + - cat $FAILED_TESTCASES_LIST + - if [ -f "$FAILED_TESTCASES_LIST" ]; then + - $TEST_SUITE=$(cat $FAILED_TESTCASES_LIST) + - else + - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." + - exit 0 + - fi + + - *update-scripts-repo - if [ $USE_LTV -eq 1 ]; then - *update-ltv-repo -- GitLab From dde36765f44603386812b899a932524d5a30dc09 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 15:22:43 +0100 Subject: [PATCH 089/329] check for file being empty --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fc3c1fa0..7db27dd63 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -489,7 +489,7 @@ stages: - *print-common-info - cat $FAILED_TESTCASES_LIST - - if [ -f "$FAILED_TESTCASES_LIST" ]; then + - if [ -f "$FAILED_TESTCASES_LIST" ] && [ ! -z "$( ls -A $FAILED_TESTCASES_LIST )" ]; then - $TEST_SUITE=$(cat $FAILED_TESTCASES_LIST) - else - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." -- GitLab From 27456c3c28a80e478a94dfc22a4a1d16b1485719 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 15:37:45 +0100 Subject: [PATCH 090/329] fix check for empty file --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7db27dd63..77fb89dbe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -488,8 +488,7 @@ stages: - set -euxo pipefail - *print-common-info - - cat $FAILED_TESTCASES_LIST - - if [ -f "$FAILED_TESTCASES_LIST" ] && [ ! -z "$( ls -A $FAILED_TESTCASES_LIST )" ]; then + - if [ -s $FAILED_TESTCASES_LIST ]; then - $TEST_SUITE=$(cat $FAILED_TESTCASES_LIST) - else - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." -- GitLab From fe6d391188618437e769f57f858eebed7b8f5d42 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 13 Feb 2025 15:54:40 +0100 Subject: [PATCH 091/329] remove unncessary code increasing i --- lib_enc/ACcontextMapping_enc_fx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 0e816e77c..6b0129123 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1230,7 +1230,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { /* Common variables */ Word16 a1, b1; - Word16 i, k, pki, lev1; + Word16 k, pki, lev1; UWord16 t; Word16 lastnz, lastnz2; Word16 rateFlag; @@ -1250,14 +1250,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* bits to encode lastnz */ k = 1; move16(); - i = 2; - move64(); WHILE( LT_16( k, nt / 2 ) ) { bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) ); k = shl( k, 1 ); - i = add( i, 2 ); /* check while condition */ } -- GitLab From b79cca58f691da72f9ca7cb32548af5ebbded60c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 15:55:10 +0100 Subject: [PATCH 092/329] [revert-me] force TCX20 to provoke diff for testing --- lib_enc/transient_detection_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index d9859a1a1..b0d131258 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -804,6 +804,8 @@ void SetTCXModeInfo_ivas_fx( hTcxEnc->tcxMode = TCX_20; move16(); } + + hTcxEnc->tcxMode = TCX_20; } ELSE { -- GitLab From 42a1d25e5b743dfaa4cbd1873b5070caea330930 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 16:05:51 +0100 Subject: [PATCH 093/329] fix variable assignment --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77fb89dbe..a3c12f6c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -489,7 +489,7 @@ stages: - *print-common-info - if [ -s $FAILED_TESTCASES_LIST ]; then - - $TEST_SUITE=$(cat $FAILED_TESTCASES_LIST) + - TEST_SUITE=$(cat $FAILED_TESTCASES_LIST) - else - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." - exit 0 -- GitLab From a494d1d67767cf35567cef8c7b4203db68df04df Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 16:16:35 +0100 Subject: [PATCH 094/329] remove newlines from artifact file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3c12f6c9..dbdd25f75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -447,7 +447,7 @@ stages: - touch $FAILED_TESTCASES_LIST - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' > $FAILED_TESTCASES_LIST + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' | tr "\n" " " > $FAILED_TESTCASES_LIST - fi - cat $FAILED_TESTCASES_LIST -- GitLab From 3d459969828c4ea73d0220258a190002a2cc7fbe Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 16:24:54 +0100 Subject: [PATCH 095/329] try without additional "" --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dbdd25f75..fcad772f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -447,7 +447,7 @@ stages: - touch $FAILED_TESTCASES_LIST - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | awk -F'::' '{print "\"" $1 "::" $2 "\"" }' | tr "\n" " " > $FAILED_TESTCASES_LIST + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | tr "\n" " " > $FAILED_TESTCASES_LIST - fi - cat $FAILED_TESTCASES_LIST -- GitLab From 37049c2c4fd6ab53c600c6785090560e10e40e10 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 13 Feb 2025 16:37:08 +0100 Subject: [PATCH 096/329] clean up RCcontextMapping_encode2_estimate_bandWise_start_fx() --- lib_enc/ACcontextMapping_enc_fx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 6b0129123..dd9e57626 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1672,8 +1672,6 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( /* bits to encode lastnz */ k = 1; move16(); - i = 2; - move16(); WHILE( LT_16( k, hContextMem->nt_half ) ) { @@ -1681,12 +1679,11 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( move64(); k = shl( k, 1 ); - i = add( i, 1 ); /* check while condition */ } /* bits to encode lastnz */ - hContextMem->nbits_old = i; + hContextMem->nbits_old = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */; move16(); hContextMem->ctx = 0; -- GitLab From e0c6fd18548e729d9f00fce04bf099b6e64449ab Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 16:59:25 +0100 Subject: [PATCH 097/329] try with moving the pytest cache instead of file parsing --- .gitlab-ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fcad772f7..2c570229b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,7 @@ variables: COMPARE_DMX: "" SKIP_REGRESSION_CHECK: "" FAILED_TESTCASES_LIST: "failed-testcases.txt" + PYTEST_CACHE_ARTIFACT: "pytest_cache.zip" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -441,6 +442,7 @@ stages: - *build-and-create-reference-outputs - exit_code=0 + - rm -rf .pytest_cache || true - python3 -m pytest -k "stereo and at" --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - zero_errors_branch=$(cat $XML_REPORT | grep -c 'errors="0"') || true @@ -452,6 +454,7 @@ stages: - cat $FAILED_TESTCASES_LIST + - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache - exit $exit_code allow_failure: @@ -466,6 +469,7 @@ stages: - $HTML_REPORT - $FAILED_TESTCASES_LIST - pytest_log.txt + - $PYTEST_CACHE_ARTIFACT expose_as: "pytest compare results" reports: junit: @@ -489,7 +493,9 @@ stages: - *print-common-info - if [ -s $FAILED_TESTCASES_LIST ]; then - - TEST_SUITE=$(cat $FAILED_TESTCASES_LIST) + - rm -rf .pytest_cache || true + - unzip $PYTEST_CACHE_ARTIFACT + - PYTEST_ADDOPTS="--last-failed" - else - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." - exit 0 -- GitLab From 29a875d5c013fbb6c259024358e6e1f76a55606b Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Thu, 13 Feb 2025 17:04:04 +0100 Subject: [PATCH 098/329] identation problem in one of the functions, due to { in the wrong place. --- lib_enc/ACcontextMapping_enc_fx.c | 49 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index dd9e57626..9715f6bb8 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1603,37 +1603,38 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); } ELSE /* Overflow */ + { + IF( *stop ) + { + *stop = tot_bits2; /* Q0 */ + move16(); + } + ELSE { - IF( *stop ){ - *stop = tot_bits2; /* Q0 */ + *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); + move16(); + } + } + + *lastnz_out = lastnz; /* Q0 */ move16(); - } - ELSE - { - *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); + *nEncoded = lastnz2; /* Q0 */ move16(); - } -} + /* Safety mechanism to avoid overflow */ + test(); + IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) + { + FOR( k = 0; k < lastnz2; k++ ) + { + x[k] = 0; + move16(); + } + } -*lastnz_out = lastnz; /* Q0 */ -move16(); -*nEncoded = lastnz2; /* Q0 */ -move16(); -/* Safety mechanism to avoid overflow */ -test(); -IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) -{ - FOR( k = 0; k < lastnz2; k++ ) - { - x[k] = 0; - move16(); + return tot_bits2; } } -return tot_bits2; -} -} - /*-------------------------------------------------------------------* * RCcontextMapping_encode2_estimate_bandWise_start_fx() -- GitLab From cae305518a72bc5ff14db3c6f3c0c1e1dae209ba Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Thu, 13 Feb 2025 17:09:46 +0100 Subject: [PATCH 099/329] indentation problem due to missing return. --- lib_enc/ACcontextMapping_enc_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 9715f6bb8..a0e819313 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1633,6 +1633,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( return tot_bits2; } + return 0; } -- GitLab From 4e815c1a00fb533432ff7ac7525261f731c7f4e0 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Thu, 13 Feb 2025 17:14:58 +0100 Subject: [PATCH 100/329] indentation problem due to return inside if statement. --- lib_enc/ACcontextMapping_enc_fx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index a0e819313..149ad36b0 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1228,6 +1228,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ ) { + Word16 retval; /* Common variables */ Word16 a1, b1; Word16 k, pki, lev1; @@ -1239,6 +1240,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 symbol; const UWord8 *lookup; Word64 nbits2_accu; + retval = 0; + move16(); /* Initialization */ bit_estimate_fx = MAKE_NUMBER_QX( 2, Q23 ); @@ -1458,7 +1461,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); - return round_fx( L_add( W_shr( nbits2_accu, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ + retval = round_fx( L_add( W_shr( nbits2_accu, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ } ELSE /* if (!hm_cfg) */ { @@ -1631,9 +1634,9 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } } - return tot_bits2; + retval = tot_bits2; } - return 0; + return retval; } -- GitLab From 6be56cb42c5094400bdba05e8704d138f0531e5a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 17:22:40 +0100 Subject: [PATCH 101/329] set PYTEST_ADDOPTS as env var --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c570229b..7ae61dc30 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -495,7 +495,7 @@ stages: - if [ -s $FAILED_TESTCASES_LIST ]; then - rm -rf .pytest_cache || true - unzip $PYTEST_CACHE_ARTIFACT - - PYTEST_ADDOPTS="--last-failed" + - export PYTEST_ADDOPTS=--last-failed - else - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." - exit 0 -- GitLab From 8597d69739c136ca71a0c5b552f2d336c2aae7d6 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Thu, 13 Feb 2025 17:29:53 +0100 Subject: [PATCH 102/329] indentation problem persists --- lib_enc/ACcontextMapping_enc_fx.c | 57 ++++++++++++++----------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 149ad36b0..cad29d320 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1228,7 +1228,6 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ ) { - Word16 retval; /* Common variables */ Word16 a1, b1; Word16 k, pki, lev1; @@ -1240,8 +1239,6 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 symbol; const UWord8 *lookup; Word64 nbits2_accu; - retval = 0; - move16(); /* Initialization */ bit_estimate_fx = MAKE_NUMBER_QX( 2, Q23 ); @@ -1461,7 +1458,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); - retval = round_fx( L_add( W_shr( nbits2_accu, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ + return round_fx( L_add( W_shr( nbits2_accu, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ } ELSE /* if (!hm_cfg) */ { @@ -1606,37 +1603,35 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); } ELSE /* Overflow */ - { - IF( *stop ) - { - *stop = tot_bits2; /* Q0 */ - move16(); - } - ELSE { - *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); - move16(); - } - } - - *lastnz_out = lastnz; /* Q0 */ + IF( *stop ){ + *stop = tot_bits2; /* Q0 */ move16(); - *nEncoded = lastnz2; /* Q0 */ + } + ELSE + { + *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); move16(); - /* Safety mechanism to avoid overflow */ - test(); - IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) - { - FOR( k = 0; k < lastnz2; k++ ) - { - x[k] = 0; - move16(); - } - } + } +} - retval = tot_bits2; +*lastnz_out = lastnz; /* Q0 */ +move16(); +*nEncoded = lastnz2; /* Q0 */ +move16(); +/* Safety mechanism to avoid overflow */ +test(); +IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) +{ + FOR( k = 0; k < lastnz2; k++ ) + { + x[k] = 0; + move16(); } - return retval; +} + +return tot_bits2; +} } @@ -1688,7 +1683,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( } /* bits to encode lastnz */ - hContextMem->nbits_old = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */; + hContextMem->nbits_old = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */ move16(); hContextMem->ctx = 0; -- GitLab From b48d823bdd916292c018e338c0fe9df8d28340af Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 17:31:42 +0100 Subject: [PATCH 103/329] overwrite cache b4 every pytest call --- .gitlab-ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ae61dc30..5017a4112 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -476,6 +476,12 @@ stages: - $XML_REPORT - $XML_REPORT +.overwrite-pytest-cache-with-artifact: &overwrite-pytest-cache-with-artifact + - if [ -f $PYTEST_CACHE_ARTIFACT ] then + - rm -rf .pytest_cache || true + - unzip $PYTEST_CACHE_ARTIFACT + - fi + .ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor stage: test timeout: "300 minutes" @@ -493,8 +499,7 @@ stages: - *print-common-info - if [ -s $FAILED_TESTCASES_LIST ]; then - - rm -rf .pytest_cache || true - - unzip $PYTEST_CACHE_ARTIFACT + - *overwrite-pytest-cache-with-artifact - export PYTEST_ADDOPTS=--last-failed - else - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." @@ -524,6 +529,8 @@ stages: # this per default builds the branch and the reference and creates the reference outputs - *build-and-create-reference-outputs - exit_code=0 + # need to restore cache again + - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || exit_code=$? - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH @@ -541,6 +548,8 @@ stages: - git pull - make clean - make -j + # need to restore cache again + - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN -- GitLab From b76abea1c07f129a2b4bd72e8907cc432aae5105 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 17:45:48 +0100 Subject: [PATCH 104/329] fix syntax error --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5017a4112..3e034bebd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -477,7 +477,7 @@ stages: - $XML_REPORT .overwrite-pytest-cache-with-artifact: &overwrite-pytest-cache-with-artifact - - if [ -f $PYTEST_CACHE_ARTIFACT ] then + - if [ -f $PYTEST_CACHE_ARTIFACT ]; then - rm -rf .pytest_cache || true - unzip $PYTEST_CACHE_ARTIFACT - fi -- GitLab From 94fe3242b661346909ff5ebb142191d8a6d4fc41 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 17:47:16 +0100 Subject: [PATCH 105/329] [revert-me] deactivate more jobs for faster testing --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e034bebd..4e5748231 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -817,7 +817,7 @@ build-codec-linux-make: - make -j # ensure that codec builds on linux with instrumentation active -build-codec-linux-instrumented-make: +.build-codec-linux-instrumented-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -834,7 +834,7 @@ build-codec-linux-instrumented-make: - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP - make -j -C $INSTR_DIR -build-codec-linux-debugging-make: +.build-codec-linux-debugging-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -852,7 +852,7 @@ build-codec-linux-debugging-make: - *activate-debug-mode-info-if-set - make -j -build-codec-windows-msbuild: +.build-codec-windows-msbuild: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -1352,7 +1352,7 @@ coverage-test-on-main-scheduled: # --------------------------------------------------------------- # check bitexactness to EVS -be-2-evs-26444: +.be-2-evs-26444: extends: - .test-job-linux rules: -- GitLab From bd5f9b08172ba992243c71f005cc6e58fcdbac45 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 18:00:29 +0100 Subject: [PATCH 106/329] add missing jobs --- .gitlab-ci.yml | 111 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e5748231..881b41b8b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -885,13 +885,10 @@ check-be-to-target-short-enc-0db: - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - SKIP_REGRESSION_CHECK="true" + - rm -rf tests/dut tests/ref <<: *check-be-to-target-anchor -check-regressions-short-enc-0db: - stage: test - needs: - - job: "check-be-to-target-short-enc-0db" - artifacts: true +check-be-to-target-short-enc-+10db: extends: - .rules-pytest-to-main-short - .test-job-linux @@ -899,12 +896,66 @@ check-regressions-short-enc-0db: - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 + - LEVEL_SCALING=3.162 - SKIP_REGRESSION_CHECK="true" - <<: *ivas-pytest-on-merge-request-anchor + - rm -rf tests/dut tests/ref + <<: *check-be-to-target-anchor -### jobs that test fx encoder -> flt decoder -.ivas-pytest-compare_to_main-short-enc: +check-be-to-target-short-enc--10db: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_DECODER_PATH=./IVAS_dec_ref + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=0.3162 + - SKIP_REGRESSION_CHECK="true" + - rm -rf tests/dut tests/ref + <<: *check-be-to-target-anchor + +check-be-to-target-short-dec-0db: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_ENCODER_PATH=./IVAS_cod_ref + - TEST_SUITE="$SHORT_TEST_SUITE" + - LEVEL_SCALING=1.0 + - rm -rf tests/dut tests/ref + <<: *check-be-to-target-anchor + +check-be-to-target-short-dec-+10db: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_ENCODER_PATH=./IVAS_cod_ref + - TEST_SUITE="$SHORT_TEST_SUITE" + - LEVEL_SCALING=3.162 + - rm -rf tests/dut tests/ref + <<: *check-be-to-target-anchor + +check-be-to-target-short-dec--10db: + extends: + - .rules-pytest-to-main-short + - .test-job-linux + before_script: + - USE_LTV=0 + - DUT_ENCODER_PATH=./IVAS_cod_ref + - TEST_SUITE="$SHORT_TEST_SUITE" + - LEVEL_SCALING=0.3162 + - rm -rf tests/dut tests/ref + <<: *check-be-to-target-anchor + +### jobs that check for regressions on non-BE testcases +check-regressions-short-enc-0db: + stage: test + needs: + - job: "check-be-to-target-short-enc-0db" + artifacts: true extends: - .rules-pytest-to-main-short - .test-job-linux @@ -914,9 +965,14 @@ check-regressions-short-enc-0db: - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - SKIP_REGRESSION_CHECK="true" + - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -.ivas-pytest-compare_to_main-short-enc-lev-10: +check-regressions-short-enc-+10db: + stage: test + needs: + - job: "check-be-to-target-short-enc-+10db" + artifacts: true extends: - .rules-pytest-to-main-short - .test-job-linux @@ -924,11 +980,16 @@ check-regressions-short-enc-0db: - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=0.3162 + - LEVEL_SCALING=3.162 - SKIP_REGRESSION_CHECK="true" + - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -.ivas-pytest-compare_to_main-short-enc-lev+10: +check-regressions-short-enc--10db: + stage: test + needs: + - job: "check-be-to-target-short-enc--10db" + artifacts: true extends: - .rules-pytest-to-main-short - .test-job-linux @@ -936,12 +997,16 @@ check-regressions-short-enc-0db: - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=3.162 + - LEVEL_SCALING=0.3162 - SKIP_REGRESSION_CHECK="true" + - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -### jobs that test flt encoder -> fx decoder -.ivas-pytest-compare_to_main-short-dec: +check-regressions-short-dec-0db: + stage: test + needs: + - job: "check-be-to-target-short-dec-0db" + artifacts: true extends: - .rules-pytest-to-main-short - .test-job-linux @@ -953,7 +1018,11 @@ check-regressions-short-enc-0db: - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -.ivas-pytest-compare_to_main-short-dec-lev-10: +check-regressions-short-enc-+10db: + stage: test + needs: + - job: "check-be-to-target-short-enc-+10db" + artifacts: true extends: - .rules-pytest-to-main-short - .test-job-linux @@ -961,11 +1030,15 @@ check-regressions-short-enc-0db: - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=0.3162 + - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -.ivas-pytest-compare_to_main-short-dec-lev+10: +check-regressions-short-enc--10db: + stage: test + needs: + - job: "check-be-to-target-short-enc--10db" + artifacts: true extends: - .rules-pytest-to-main-short - .test-job-linux @@ -973,7 +1046,7 @@ check-regressions-short-enc-0db: - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=3.162 + - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -- GitLab From 4fcc08c18f5b08ff9ce4fa602a21d41b58aff97a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Feb 2025 18:01:49 +0100 Subject: [PATCH 107/329] fix job names --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 881b41b8b..32003043d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1018,10 +1018,10 @@ check-regressions-short-dec-0db: - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -check-regressions-short-enc-+10db: +check-regressions-short-dec-+10db: stage: test needs: - - job: "check-be-to-target-short-enc-+10db" + - job: "check-be-to-target-short-dec-+10db" artifacts: true extends: - .rules-pytest-to-main-short @@ -1034,10 +1034,10 @@ check-regressions-short-enc-+10db: - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -check-regressions-short-enc--10db: +check-regressions-short-dec--10db: stage: test needs: - - job: "check-be-to-target-short-enc--10db" + - job: "check-be-to-target-short-dec--10db" artifacts: true extends: - .rules-pytest-to-main-short -- GitLab From 9c6af891a99b1d612528b8fd18e870fcf3c42d97 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 14 Feb 2025 08:53:21 +0100 Subject: [PATCH 108/329] one variable still had a name from the development nomenklature. --- lib_enc/ACcontextMapping_enc_fx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index cad29d320..aad058c27 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1238,13 +1238,13 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 symbol; const UWord8 *lookup; - Word64 nbits2_accu; + Word64 nbits2_fx; /* Initialization */ bit_estimate_fx = MAKE_NUMBER_QX( 2, Q23 ); move64(); - nbits2_accu = 0; + nbits2_fx = 0; move64(); /* bits to encode lastnz */ @@ -1258,7 +1258,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ } - nbits2_accu = bit_estimate_fx; + nbits2_fx = bit_estimate_fx; move64(); IF( hm_cfg ) @@ -1386,7 +1386,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ELSE { lastnz2 = add( b1_i, 1 ); - nbits2_accu = bit_estimate_fx; + nbits2_fx = bit_estimate_fx; move64(); } @@ -1432,7 +1432,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( IF( *stop ) { - total_output_bits = round_fx( W_shr( nbits2_accu, Q7 ) ); + total_output_bits = round_fx( W_shr( nbits2_fx, Q7 ) ); } IF( stop2 ) @@ -1458,7 +1458,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); - return round_fx( L_add( W_shr( nbits2_accu, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ + return round_fx( L_add( W_shr( nbits2_fx, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ } ELSE /* if (!hm_cfg) */ { @@ -1565,7 +1565,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */ { - nbits2_accu = bit_estimate_fx; /* exp(bit_estimate_e) */ + nbits2_fx = bit_estimate_fx; /* exp(bit_estimate_e) */ move64(); lastnz2 = add( k, 2 ); @@ -1587,7 +1587,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - tot_bits2 = round_fx( W_shr( nbits2_accu, Q7 ) ); + tot_bits2 = round_fx( W_shr( nbits2_fx, Q7 ) ); IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ { overflow_flag = 1; -- GitLab From 9ced24f50a9f43c5eb4a476dd55639158d96be69 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 14 Feb 2025 09:47:39 +0100 Subject: [PATCH 109/329] removed some compiler warnings and commented the representations a bit better. --- lib_enc/ACcontextMapping_enc_fx.c | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index aad058c27..4c12b6907 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -16,8 +16,8 @@ #include "prot_fx_enc.h" #include "ivas_prot.h" /* Range coder header file */ -#define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) -#define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) +#define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) /* evaulated at compile time */ +#define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /* evaluated at run time */ /*-------------------------------------------------------------------* * ACcontextMapping_encode2_no_mem_s17_LC_fx() @@ -1346,8 +1346,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( b1 = (Word16) abs( x[b1_i] ); lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */ lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); @@ -1357,8 +1357,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { pki = lookup[lev1]; /* ESC symbol */ - bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1370,10 +1370,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[lev1]; symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ - bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ - IF( GT_32( W_shr( bit_estimate_fx, Q8 ), L_shl( target, Q15 ) ) ) + IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) { stop2 = 1; move16(); @@ -1428,11 +1428,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( W_shr( bit_estimate_fx, Q7 ) ); + total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ IF( *stop ) { - total_output_bits = round_fx( W_shr( nbits2_fx, Q7 ) ); + total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ } IF( stop2 ) @@ -1458,7 +1458,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); - return round_fx( L_add( W_shr( nbits2_fx, Q7 ), ONE_IN_Q14 ) ); /* Q0 */ + return round_fx( L_add( W_extract_l( W_shr( nbits2_fx, Q7 ) ), ONE_IN_Q14 ) ); /* Q0 */ } ELSE /* if (!hm_cfg) */ { @@ -1524,8 +1524,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) ); /* Q0 */ - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */ lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )]; /* Q0 */ @@ -1537,8 +1537,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ move16(); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) ); a1 = shr( a1, 1 ); b1 = shr( b1, 1 ); @@ -1553,10 +1553,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( move16(); symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ - bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ - IF( GT_32( W_shr( bit_estimate_fx, Q8 ), L_shl( target, Q15 ) ) ) + IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) { overflow_flag = 1; move16(); @@ -1587,7 +1587,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ - tot_bits2 = round_fx( W_shr( nbits2_fx, Q7 ) ); + tot_bits2 = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ { overflow_flag = 1; @@ -1595,7 +1595,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } IF( EQ_16( mode, -1 ) ) { - tot_bits2 = round_fx( W_shr( bit_estimate_fx, Q7 ) ); + tot_bits2 = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ } IF( overflow_flag == 0 ) /* No overflow */ { @@ -1610,7 +1610,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } ELSE { - *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) ); + *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ move16(); } } @@ -1683,7 +1683,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( } /* bits to encode lastnz */ - hContextMem->nbits_old = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */ + hContextMem->nbits_old = round_fx( W_extract_l( W_shr( hContextMem->bit_estimate_fx, Q7 ) ) ); /* Q0 */ move16(); hContextMem->ctx = 0; @@ -1761,8 +1761,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */ /* Signs Bits */ - hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); - hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); + hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); + hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) ); move32(); move32(); @@ -1777,8 +1777,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( pki = lookup[lev1]; /* Q0 */ move16(); - hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); - hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); + hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) ); move32(); move32(); @@ -1796,7 +1796,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( pki = lookup[lev1]; /* Q0 */ move16(); symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ - hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); + hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); move32(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol]; @@ -1817,7 +1817,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( move16(); } /*end of the 2-tuples loop*/ - total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */ + total_output_bits = round_fx( W_extract_l( W_shr( hContextMem->bit_estimate_fx, Q7 ) ) ); /* Q0 */ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); -- GitLab From e731929cc029b67ec24b93c80ae3fedaa284ff82 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 14 Feb 2025 19:47:48 +1100 Subject: [PATCH 110/329] fixes in external renderer --- apps/renderer.c | 1 + lib_dec/ivas_binRenderer_internal.c | 7 ++-- lib_rend/ivas_dirac_dec_binaural_functions.c | 3 ++ lib_rend/lib_rend.c | 40 +++++++++++++++----- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 6f55853d6..3537e7c25 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -53,6 +53,7 @@ #include "wmc_auto.h" #include "prot_fx.h" +#include "debug.h" #define WMC_TOOL_SKIP diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index f0cda2bca..97d7905f3 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1228,7 +1228,7 @@ ivas_error ivas_rend_openCldfbRend( } /* Allocate memories and buffers needed for convolutional module in CICP19 */ - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, 1, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) { return error; } @@ -2127,11 +2127,12 @@ void ivas_rend_CldfbMultiBinRendProcess( Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word16 Q_in_orig = Q_in; - move16(); + Word16 Q_in_orig; FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { + Q_in_orig = Q_in; + move16(); FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0d6673fa8..04964dfec 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -6796,9 +6796,12 @@ static void ivas_masa_ext_rend_parambin_internal_fx( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { Copy32( hMasaExtRend->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands ); + Copy( hMasaExtRend->hDiracDecBin[0]->ChEne_e[ch], hDiracDecBin->ChEne_e[ch], hSpatParamRendCom->num_freq_bands ); } Copy32( hMasaExtRend->hDiracDecBin[0]->ChCrossRe_fx, hDiracDecBin->ChCrossRe_fx, hSpatParamRendCom->num_freq_bands ); Copy32( hMasaExtRend->hDiracDecBin[0]->ChCrossIm_fx, hDiracDecBin->ChCrossIm_fx, hSpatParamRendCom->num_freq_bands ); + Copy( hMasaExtRend->hDiracDecBin[0]->ChCrossRe_e, hDiracDecBin->ChCrossRe_e, hSpatParamRendCom->num_freq_bands ); + Copy( hMasaExtRend->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 87afb721c..1432c1eac 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -398,7 +398,7 @@ static void copyBufferToCLDFBarray_fx( assert( ( buffer.config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); readPtr = buffer.data_fx; - numCldfbSamples = (UWord32) shl( buffer.config.numSamplesPerChannel, 1 ); + numCldfbSamples = (UWord32) shr( buffer.config.numSamplesPerChannel, 1 ); num_bands = (UWord32) Mpy_32_32( numCldfbSamples, ONE_BY_CLDFB_NO_COL_MAX_Q31 ); FOR( chnlIdx = 0; chnlIdx < (UWord32) buffer.config.numChannels; ++chnlIdx ) { @@ -430,7 +430,7 @@ static void accumulateCLDFBArrayToBuffer_fx( assert( ( buffer->config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); writePtr = buffer->data_fx; - numCldfbSamples = (UWord32) shl( buffer->config.numSamplesPerChannel, 1 ); + numCldfbSamples = (UWord32) shr( buffer->config.numSamplesPerChannel, 1 ); num_bands = (UWord32) Mpy_32_32( numCldfbSamples, ONE_BY_CLDFB_NO_COL_MAX_Q31 ); FOR( chnlIdx = 0; chnlIdx < (uint32_t) buffer->config.numChannels; ++chnlIdx ) { @@ -3924,6 +3924,9 @@ static ivas_error ivas_pre_rend_init( { return IVAS_ERR_FAILED_ALLOC; } + + pSplitRendEncBuffer->q_factor = 0; + pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; } ELSE { @@ -3934,6 +3937,8 @@ static ivas_error ivas_pre_rend_init( bufConfig2.is_cldfb = 0; pSplitRendEncBuffer->config = bufConfig2; pSplitRendEncBuffer->data_fx = NULL; + pSplitRendEncBuffer->pq_fact = NULL; + pSplitRendEncBuffer->q_factor = 0; move16(); move16(); move16(); @@ -4937,11 +4942,20 @@ ivas_error IVAS_REND_SetHeadRotation( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* check for Euler angle signaling */ + IF( EQ_32( headRot.w_fx, L_negate( 12582912 ) ) && EQ_16( headRot.q_fact, Q22 ) ) + { + Euler2Quat_fx( deg2rad_fx( headRot.x_fx ), deg2rad_fx( headRot.y_fx ), deg2rad_fx( headRot.z_fx ), &rotQuat ); + modify_Quat_q_fx( &rotQuat, &rotQuat, Q29 ); + } +#else /* check for Euler angle signaling */ IF( EQ_32( headRot.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) { Euler2Quat_fx( deg2rad_fx( headRot.x_fx ), deg2rad_fx( headRot.y_fx ), deg2rad_fx( headRot.z_fx ), &rotQuat ); } +#endif ELSE { rotQuat = headRot; @@ -6254,6 +6268,7 @@ static ivas_error renderIsmToSplitBinaural( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; const SPLIT_REND_WRAPPER *pSplitRendWrapper; IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + IVAS_QUATERNION localHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 i; Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; Word16 output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; @@ -6299,9 +6314,9 @@ static ivas_error renderIsmToSplitBinaural( { pCombinedOrientationData->Quaternions[i].w_fx = L_negate( 12582912 ); // Q22 q_fact_orig = originalHeadRot[i].q_fact; - modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 ); + modify_Quat_q_fx( &originalHeadRot[i], &localHeadRot[i], Q22 ); /*euler*/ - Quat2EulerDegree_fx( originalHeadRot[i], + Quat2EulerDegree_fx( localHeadRot[i], &pCombinedOrientationData->Quaternions[i].z_fx, &pCombinedOrientationData->Quaternions[i].y_fx, &pCombinedOrientationData->Quaternions[i].x_fx ); @@ -7571,6 +7586,9 @@ static ivas_error renderSbaToMultiBinaural( IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &tmpRotBuffer, *sbaInput->base.ctx.pOutSampleRate ), pos_idx ) ), IVAS_ERR_OK ) ) + { + return error; + } FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) { @@ -8850,7 +8868,8 @@ static ivas_error getSamplesInternal( Word16 num_poses_orig; num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; move16(); - outAudio = hIvasRend->splitRendEncBuffer; + outAudio.config = hIvasRend->splitRendEncBuffer.config; + outAudio.data_fx = hIvasRend->splitRendEncBuffer.data_fx; ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); @@ -8949,7 +8968,7 @@ static ivas_error getSamplesInternal( Q_out[0] = 31; Word16 num_poses = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; - for ( i = 0; i < 16; i++ ) + for ( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { @@ -8958,7 +8977,7 @@ static ivas_error getSamplesInternal( } } Q_buff = s_min( q1, q2 ); - for ( i = 0; i < 16; i++ ) + for ( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { @@ -8966,7 +8985,7 @@ static ivas_error getSamplesInternal( scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); } } - Q_buff = Q_buff + Q6; + Q_buff = Q_buff + *outAudio.pq_fact; IF( EQ_16( cldfb_in_flag, 0 ) ) { @@ -9008,7 +9027,8 @@ static ivas_error getSamplesInternal( convertInternalBitsBuffToBitsBuffer( hBits, bits ); /* reset to outAudioOrig in case of PCM output */ - outAudio = outAudioOrig; + outAudio.config = outAudioOrig.config; + outAudio.data_fx = outAudioOrig.data_fx; IF( NE_16( pcm_out_flag, 0 ) ) { @@ -9272,8 +9292,10 @@ void IVAS_REND_cldfbAnalysis_ts_wrapper( { Word16 Q_cldfb = Q_in; + assert( Q_in == h_cldfb->Q_cldfb_state ); cldfbAnalysis_ts_fx_fixed_q( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb, &Q_cldfb ); + *Q_out = sub( Q_in, 5 ); return; -- GitLab From dbb55697955ed456f41e51f63e5498fb9438a941 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 09:52:13 +0100 Subject: [PATCH 111/329] improve reporting in be check job --- .gitlab-ci.yml | 69 +++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32003043d..5007018a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,7 @@ variables: COMPARE_DMX: "" SKIP_REGRESSION_CHECK: "" FAILED_TESTCASES_LIST: "failed-testcases.txt" + ERRORS_TESTCASES_LIST: "errors-testcases.txt" PYTEST_CACHE_ARTIFACT: "pytest_cache.zip" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." @@ -305,6 +306,14 @@ stages: tags: - ivas-windows +.print-results-banner: &print-results-banner + - set +x + - echo "" + - echo "==================================================================================================================" + - echo "================================================== TEST RESULTS ==================================================" + - echo "==================================================================================================================" + - echo "" + # template for test jobs on linux that need the TESTV_DIR .test-job-linux-needs-testv-dir: extends: .test-job-linux @@ -444,17 +453,37 @@ stages: - exit_code=0 - rm -rf .pytest_cache || true - python3 -m pytest -k "stereo and at" --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - - zero_errors_branch=$(cat $XML_REPORT | grep -c 'errors="0"') || true - touch $FAILED_TESTCASES_LIST + - touch $ERRORS_TESTCASES_LIST + - touch $PYTEST_CACHE_ARTIFACT - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE + - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | tr "\n" " " > $FAILED_TESTCASES_LIST - - fi + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' > failed_testcases_for_printing.txt + - num_failures=$(wc -l < failed_testcases_for_printing.txt) - - cat $FAILED_TESTCASES_LIST + - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' | tr "\n" " " > $ERRORS_TESTCASES_LIST + - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' > errors_testcases_for_printing.txt + - num_errors=$(wc -l < errors_testcases_for_printing.txt) - - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache + - *print-results-banner + - echo "Found these $num_failures non-bitexact testcases:" + - cat failed_testcases_for_printing.txt + + - if [ $num_errors -ne 0 ]; then + - exit_code=1 + - echo "There were errors present in the following testcases:" + - cat errors_testcases_for_printing.txt + - fi + + - exit $exit_code + - else + - *print-results-banner + - echo "All testcases are bitexact." + - fi - exit $exit_code allow_failure: @@ -502,7 +531,10 @@ stages: - *overwrite-pytest-cache-with-artifact - export PYTEST_ADDOPTS=--last-failed - else - - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME. No need to check for regressions." + # turn off echoing back of commands for result printout + - *print-results-banner + - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME." + - echo "No need to check for regressions. All is fine." - exit 0 - fi @@ -528,10 +560,9 @@ stages: ### run branch first # this per default builds the branch and the reference and creates the reference outputs - *build-and-create-reference-outputs - - exit_code=0 # need to restore cache again - *overwrite-pytest-cache-with-artifact - - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH @@ -550,34 +581,14 @@ stages: - make -j # need to restore cache again - *overwrite-pytest-cache-with-artifact - - python3 -m pytest --tb=no $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN - # If outputs of main and branch are equal, have equal reports and no run errors were encountered, the job will pass. - - diff_sba=0 - - diff_param=0 - - diff_report=0 - # SHORT_TEST_SUITE_ENCODER does not contain test_sba.py. This leads to non-existing output folders being compared and to diff_sba=1. Therefore, this is skipped for the encoder tests - - if [ "$TEST_SUITE" != "$SHORT_TEST_SUITE_ENCODER" ]; then - - python3 scripts/batch_comp_audio.py --tool pyaudio3dtools -sd tests/dut/sba_bs/raw tests/dut_branch/sba_bs/raw || diff_sba=$? - - fi - - python3 scripts/batch_comp_audio.py --tool pyaudio3dtools -sd tests/dut/param_file/dec tests/dut_branch/param_file/dec || diff_param=$? - - diff $CSV_BRANCH $CSV_MAIN || diff_report=$? - - if [ $diff_param -eq 0 ] && [ $diff_sba -eq 0 ] && [ $diff_report -eq 0 ] && [ $zero_errors_branch -eq 1 ]; then - - echo "Output BE to main, identical report and no run errors encountered." - # Add dummy files to avoid warning on missing artifacts - - touch changes_crashes.csv - - touch changes_MLD.csv - - touch changes_MAXIMUM_ABS_DIFF.csv - - touch changes_MIN_SSNR.csv - - touch changes_MIN_ODG.csv - - exit 0; - - fi - ### compare the two csv files for regressions - regressions_found=0 - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH || regressions_found=$? + - exit_code=0 - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit_code=$EXIT_CODE_NON_BE; fi - if [ $zero_errors_branch != 1 ]; then echo "Run errors encountered!"; exit_code=$EXIT_CODE_NON_BE; fi - if [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then -- GitLab From e7adcd904f205e4aa4577394a8eb58af7f831ded Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 14 Feb 2025 09:59:49 +0100 Subject: [PATCH 112/329] applied the clang patch. --- lib_enc/ACcontextMapping_enc_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 4c12b6907..203f39707 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -16,8 +16,8 @@ #include "prot_fx_enc.h" #include "ivas_prot.h" /* Range coder header file */ -#define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) /* evaulated at compile time */ -#define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /* evaluated at run time */ +#define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) /* evaulated at compile time */ +#define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /* evaluated at run time */ /*-------------------------------------------------------------------* * ACcontextMapping_encode2_no_mem_s17_LC_fx() @@ -1588,7 +1588,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /*end of the 2-tuples loop*/ tot_bits2 = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ - IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ + IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ { overflow_flag = 1; move16(); @@ -1816,7 +1816,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */ move16(); - } /*end of the 2-tuples loop*/ + } /*end of the 2-tuples loop*/ total_output_bits = round_fx( W_extract_l( W_shr( hContextMem->bit_estimate_fx, Q7 ) ) ); /* Q0 */ // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); -- GitLab From 6e747abbf37c5e0cbe41d683cb416c10b83d3d6c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 10:32:00 +0100 Subject: [PATCH 113/329] condense printout --- .gitlab-ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5007018a3..b8b21b72b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -309,10 +309,10 @@ stages: .print-results-banner: &print-results-banner - set +x - echo "" - - echo "==================================================================================================================" - - echo "================================================== TEST RESULTS ==================================================" - - echo "==================================================================================================================" - - echo "" + - > + echo -e "==================================================================================================================\n +================================================== TEST RESULTS ==================================================\n +==================================================================================================================\n" # template for test jobs on linux that need the TESTV_DIR .test-job-linux-needs-testv-dir: @@ -533,8 +533,7 @@ stages: - else # turn off echoing back of commands for result printout - *print-results-banner - - echo "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME." - - echo "No need to check for regressions. All is fine." + - echo -e "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME.\nNo need to check for regressions. All is fine." - exit 0 - fi -- GitLab From 0cae04a9ef1b5ceac92c43f42f2c51e70be10c0d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 10:33:44 +0100 Subject: [PATCH 114/329] fix artifact-related zip error --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8b21b72b..d8eecaabe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -454,9 +454,6 @@ stages: - rm -rf .pytest_cache || true - python3 -m pytest -k "stereo and at" --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - - touch $FAILED_TESTCASES_LIST - - touch $ERRORS_TESTCASES_LIST - - touch $PYTEST_CACHE_ARTIFACT - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache @@ -481,6 +478,10 @@ stages: - exit $exit_code - else + # create empty files to not have errors at artifact stage + - touch $FAILED_TESTCASES_LIST + - touch $ERRORS_TESTCASES_LIST + - touch $PYTEST_CACHE_ARTIFACT - *print-results-banner - echo "All testcases are bitexact." - fi @@ -497,6 +498,7 @@ stages: - $XML_REPORT - $HTML_REPORT - $FAILED_TESTCASES_LIST + - $ERRORS_TESTCASES_LIST - pytest_log.txt - $PYTEST_CACHE_ARTIFACT expose_as: "pytest compare results" -- GitLab From b39991b5fdadac3d4ed624d569d955b5ba187906 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 10:35:17 +0100 Subject: [PATCH 115/329] collapse into one line --- .gitlab-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8eecaabe..5ee556e60 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -309,10 +309,7 @@ stages: .print-results-banner: &print-results-banner - set +x - echo "" - - > - echo -e "==================================================================================================================\n -================================================== TEST RESULTS ==================================================\n -==================================================================================================================\n" + - echo -e "==================================================================================================================\n================================================== TEST RESULTS ==================================================\n==================================================================================================================\n" # template for test jobs on linux that need the TESTV_DIR .test-job-linux-needs-testv-dir: -- GitLab From db14b5ea2514f5349ed819e2b27b6052a19dfcb3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 10:42:12 +0100 Subject: [PATCH 116/329] ignore return codes for grep pipes --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ee556e60..d672a4b98 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -455,12 +455,12 @@ stages: - exit_code=$EXIT_CODE_NON_BE - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | tr "\n" " " > $FAILED_TESTCASES_LIST - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' > failed_testcases_for_printing.txt + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | tr "\n" " " > $FAILED_TESTCASES_LIST || true + - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' > failed_testcases_for_printing.txt || true - num_failures=$(wc -l < failed_testcases_for_printing.txt) - - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' | tr "\n" " " > $ERRORS_TESTCASES_LIST - - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' > errors_testcases_for_printing.txt + - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' | tr "\n" " " > $ERRORS_TESTCASES_LIST || true + - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' > errors_testcases_for_printing.txt || true - num_errors=$(wc -l < errors_testcases_for_printing.txt) - *print-results-banner -- GitLab From 499c80b726336eb6294211a28ce07ed3cc389b51 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 10:57:43 +0100 Subject: [PATCH 117/329] rework if and result reporting in regression branch --- .gitlab-ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d672a4b98..c0e04314d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -587,14 +587,16 @@ stages: - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH || regressions_found=$? - exit_code=0 - - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit_code=$EXIT_CODE_NON_BE; fi - - if [ $zero_errors_branch != 1 ]; then echo "Run errors encountered!"; exit_code=$EXIT_CODE_NON_BE; fi - - if [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then + - *print-results-banner + - if [ $zero_errors_branch != 1 ]; then + - echo "Run errors encountered!" + - exit_code=$EXIT_CODE_FAIL + - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then - if [ $allow_regressions_flag == 0 ]; then - - echo "Detected regression wrt to main, [allow regression] not set!" + - echo "Detected regression wrt to $CI_MERGE_REQUEST_TARGET_BRANCH_NAME, [allow regression] not set!" - exit_code=$EXIT_CODE_FAIL; - else - - echo "Detected regression wrt to main, [allow regression] set." + - echo "Detected regression wrt to $CI_MERGE_REQUEST_TARGET_BRANCH_NAME, [allow regression] set." - exit_code=$EXIT_CODE_NON_BE; - fi - fi -- GitLab From 5eb39f0dd6600569a66c417297df647e0b17aa08 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 11:23:00 +0100 Subject: [PATCH 118/329] remove SKIP_REGrESSION_CHECK --- .gitlab-ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0e04314d..36bb0d5d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -895,7 +895,6 @@ check-be-to-target-short-enc-0db: - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - - SKIP_REGRESSION_CHECK="true" - rm -rf tests/dut tests/ref <<: *check-be-to-target-anchor @@ -908,7 +907,6 @@ check-be-to-target-short-enc-+10db: - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=3.162 - - SKIP_REGRESSION_CHECK="true" - rm -rf tests/dut tests/ref <<: *check-be-to-target-anchor @@ -921,7 +919,6 @@ check-be-to-target-short-enc--10db: - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=0.3162 - - SKIP_REGRESSION_CHECK="true" - rm -rf tests/dut tests/ref <<: *check-be-to-target-anchor @@ -975,7 +972,6 @@ check-regressions-short-enc-0db: - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - - SKIP_REGRESSION_CHECK="true" - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor @@ -992,7 +988,6 @@ check-regressions-short-enc-+10db: - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=3.162 - - SKIP_REGRESSION_CHECK="true" - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor @@ -1009,7 +1004,6 @@ check-regressions-short-enc--10db: - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=0.3162 - - SKIP_REGRESSION_CHECK="true" - rm -rf tests/dut tests/ref <<: *ivas-pytest-on-merge-request-anchor -- GitLab From 8a5c23e97fd44728ac6ede26212596c0a3c9bd14 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 11:34:47 +0100 Subject: [PATCH 119/329] move printout of regression testcases into results section --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36bb0d5d5..ec7634a6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -584,7 +584,7 @@ stages: ### compare the two csv files for regressions - regressions_found=0 - - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH || regressions_found=$? + - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH > regression_log.txt || regressions_found=$? - exit_code=0 - *print-results-banner @@ -592,6 +592,7 @@ stages: - echo "Run errors encountered!" - exit_code=$EXIT_CODE_FAIL - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then + - cat regression_log.txt - if [ $allow_regressions_flag == 0 ]; then - echo "Detected regression wrt to $CI_MERGE_REQUEST_TARGET_BRANCH_NAME, [allow regression] not set!" - exit_code=$EXIT_CODE_FAIL; -- GitLab From 9db1630e8057b7f6d16f35371c6dd2675b41672c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 12:14:58 +0100 Subject: [PATCH 120/329] add infos for local reproduction to check-be tests --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ec7634a6f..e80445293 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,8 @@ variables: FAILED_TESTCASES_LIST: "failed-testcases.txt" ERRORS_TESTCASES_LIST: "errors-testcases.txt" PYTEST_CACHE_ARTIFACT: "pytest_cache.zip" + REF_COMMIT_FILE: "ref-branch-git-sha" + CUT_COMMIT_FILE: "CuT-branch-git-sha" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -145,6 +147,7 @@ stages: - fi .build-reference-binaries: &build-reference-binaries + - git rev-parse HEAD > $CUT_COMMIT_FILE - current_commit_sha=$(git rev-parse HEAD) ### build reference binaries - git checkout $REFERENCE_BRANCH @@ -158,6 +161,7 @@ stages: - mv ./IVAS_rend ./IVAS_rend_ref ### Return to current branch - git restore . + - git rev-parse HEAD > $REF_COMMIT_FILE - git checkout $current_commit_sha @@ -467,6 +471,10 @@ stages: - echo "Found these $num_failures non-bitexact testcases:" - cat failed_testcases_for_printing.txt + - echo "Reproduce locally with:" + - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" + - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" + - if [ $num_errors -ne 0 ]; then - exit_code=1 - echo "There were errors present in the following testcases:" @@ -498,6 +506,8 @@ stages: - $ERRORS_TESTCASES_LIST - pytest_log.txt - $PYTEST_CACHE_ARTIFACT + - $REF_COMMIT_FILE + - $CUT_COMMIT_FILE expose_as: "pytest compare results" reports: junit: -- GitLab From 5f54c650b822bc251d02df4806786079818e694d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 12:17:25 +0100 Subject: [PATCH 121/329] add infos also to regression check jobs --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e80445293..fd0596d4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -601,6 +601,9 @@ stages: - if [ $zero_errors_branch != 1 ]; then - echo "Run errors encountered!" - exit_code=$EXIT_CODE_FAIL + - echo "Reproduce locally with:" + - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" + - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then - cat regression_log.txt - if [ $allow_regressions_flag == 0 ]; then @@ -610,6 +613,9 @@ stages: - echo "Detected regression wrt to $CI_MERGE_REQUEST_TARGET_BRANCH_NAME, [allow regression] set." - exit_code=$EXIT_CODE_NON_BE; - fi + - echo "Reproduce locally with:" + - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" + - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - fi - exit $exit_code -- GitLab From b8f5e73dc5e8c9383ee681d0ed8fce68aa47e20a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 12:27:28 +0100 Subject: [PATCH 122/329] change formatting in FAILED_TESTCASE_LIST and ERRORS_TESTCASES_LIST to this should make command pasteable --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd0596d4d..f351c5c27 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -459,12 +459,12 @@ stages: - exit_code=$EXIT_CODE_NON_BE - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' | tr "\n" " " > $FAILED_TESTCASES_LIST || true - - grep "^FAILED" pytest_log.txt | sed 's/^FAILED //' | sed 's/] - .*/]/' > failed_testcases_for_printing.txt || true + - grep "^FAILED" pytest_log.txt | sed "s/^FAILED /'/" | sed "s/] - .*/]'/" | tr "\n" " " > $FAILED_TESTCASES_LIST || true + - grep "^FAILED" pytest_log.txt | sed "s/^FAILED //" | sed "s/] - .*/]/" > failed_testcases_for_printing.txt || true - num_failures=$(wc -l < failed_testcases_for_printing.txt) - - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' | tr "\n" " " > $ERRORS_TESTCASES_LIST || true - - grep "^ERROR" pytest_log.txt | sed 's/^ERROR //' | sed 's/] - .*/]/' > errors_testcases_for_printing.txt || true + - grep "^ERROR" pytest_log.txt | sed "s/^ERROR /'/" | sed "s/] - .*/]'/" | tr "\n" " " > $ERRORS_TESTCASES_LIST || true + - grep "^ERROR" pytest_log.txt | sed "s/^ERROR //" | sed "s/] - .*/]/" > errors_testcases_for_printing.txt || true - num_errors=$(wc -l < errors_testcases_for_printing.txt) - *print-results-banner -- GitLab From 556377cbfec6ae4006d2609e4a6c6f0681223f01 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Feb 2025 12:37:05 +0100 Subject: [PATCH 123/329] add notion about where to find the command lines --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f351c5c27..875a4a478 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -474,7 +474,7 @@ stages: - echo "Reproduce locally with:" - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - + - echo "The individual command lines can be found in the html report in the job artifacts." - if [ $num_errors -ne 0 ]; then - exit_code=1 - echo "There were errors present in the following testcases:" @@ -604,6 +604,7 @@ stages: - echo "Reproduce locally with:" - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" + - echo "The individual command lines can be found in the changes*.csv files in the job artifacts." - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then - cat regression_log.txt - if [ $allow_regressions_flag == 0 ]; then @@ -616,6 +617,7 @@ stages: - echo "Reproduce locally with:" - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" + - echo "The individual command lines can be found in the changes*.csv files in the job artifacts." - fi - exit $exit_code -- GitLab From 923d397d3ac1f3dd98ce019e34d3bca222908d04 Mon Sep 17 00:00:00 2001 From: rtyag Date: Sat, 15 Feb 2025 00:53:26 +1100 Subject: [PATCH 124/329] q factor fix with TD in to pre renderer --- lib_isar/isar_splitRendererPre.c | 12 +++++------- lib_rend/lib_rend.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index bf60095cb..306753bd6 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -3129,8 +3129,6 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( Word16 Q_in = Q_sig, q_final = 0; move16(); move16(); - // float Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - // float Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; UWord8 useLc3plus; Word32 *in_delayed_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; Word16 i; @@ -3154,12 +3152,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( { /* Artificially delay input to head pose correction analysis by LC3plus coding delay, so that audio and metadata are in sync after decoding */ mvl2l( hSplitBin->lc3plusDelayBuffers_fx[i] + frame_size, hSplitBin->lc3plusDelayBuffers_fx[i], (Word16) hSplitBin->lc3plusDelaySamples ); - // mvr2r( hSplitBin->lc3plusDelayBuffers[i] + frame_size, hSplitBin->lc3plusDelayBuffers[i], (int16_t) hSplitBin->lc3plusDelaySamples ); in_delayed_fx[i] = hSplitBin->lc3plusDelayBuffers_fx[i]; - // in_delayed[i] = hSplitBin->lc3plusDelayBuffers[i]; + Scale_sig32( hSplitBin->lc3plusDelayBuffers_fx[i], (Word16) hSplitBin->lc3plusDelaySamples, sub( Q_in, hSplitBin->lc3plusDelayBuffers_q ) ); mvl2l( in_fx[i], hSplitBin->lc3plusDelayBuffers_fx[i] + hSplitBin->lc3plusDelaySamples, frame_size ); - // mvr2r(in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, frame_size); } + hSplitBin->lc3plusDelayBuffers_q = Q_in; } ELSE { @@ -3180,12 +3177,13 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( IF( ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out_flag ) ) { Word32 in_delayed_cldfb[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k] = { 0 }; + Word16 gd_bits = sub( Q_sig, Q11 ); FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { Copy32( in_delayed_fx[i], in_delayed_cldfb[i], L_FRAME48k ); - Scale_sig32( in_delayed_cldfb[i], L_FRAME48k, -4 ); + Scale_sig32( in_delayed_cldfb[i], L_FRAME48k, -gd_bits ); } - Q_sig = sub( Q_sig, 4 ); + Q_sig = sub( Q_sig, gd_bits ); num_slots = ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ? CLDFB_NO_COL_MAX : ( hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ); move32(); num_cldfb_bands = hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1432c1eac..e5bf2ec99 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7167,6 +7167,8 @@ static ivas_error renderMcToSplitBinaural( Word16 exp = *outAudio.pq_fact; move16(); CREND_HANDLE hCrend; + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + Word16 q_fact_orig; #ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = mcInput->crendWrapper->hCrend[0]; #else @@ -7219,17 +7221,18 @@ static ivas_error renderMcToSplitBinaural( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); } + FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[i], &Quaternions_orig[i] ); + } + FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { /* Update head positions */ - IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; - Word16 q_fact_orig; FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) { - Copy_Quat_fx( &combinedOrientationDataLocal.Quaternions[i], &Quaternions_orig[i] ); - Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 - q_fact_orig = combinedOrientationDataLocal.Quaternions[i].q_fact; + q_fact_orig = Quaternions_orig[i].q_fact; modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Q22 ); /*euler*/ Quat2EulerDegree_fx( combinedOrientationDataLocal.Quaternions[i], -- GitLab From cc69948eab1d0ea64c323ee8402901d54297b499 Mon Sep 17 00:00:00 2001 From: rtyag Date: Sat, 15 Feb 2025 22:19:18 +1100 Subject: [PATCH 125/329] crash fix with 5_1 input --- lib_rend/lib_rend.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e5bf2ec99..1c79e6f40 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7169,11 +7169,6 @@ static ivas_error renderMcToSplitBinaural( CREND_HANDLE hCrend; IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; Word16 q_fact_orig; -#ifdef SPLIT_REND_WITH_HEAD_ROT - hCrend = mcInput->crendWrapper->hCrend[0]; -#else - hCrend = mcInput->crendWrapper->hCrend; -#endif push_wmops( "renderMcToSplitBinaural" ); inConfig = mcInput->base.inConfig; @@ -7289,6 +7284,11 @@ static ivas_error renderMcToSplitBinaural( } ELSE { +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = mcInput->crendWrapper->hCrend[0]; +#else + hCrend = mcInput->crendWrapper->hCrend; +#endif /* crend processing overview: * 1. rotateFrameMc: inputBuffer to tmpRotBuffer * 2. crend_process: tmpRotBuffer to tmpRendBuffer -- GitLab From f0d096137777f9777898fae667bda7389a1a5db3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Sat, 15 Feb 2025 23:48:24 +1100 Subject: [PATCH 126/329] fixes in quat shift, post renderer q fact saving --- lib_com/ivas_prot_fx.h | 9 ++++----- lib_com/ivas_rotation_com.c | 30 +++++++++++++---------------- lib_dec/ivas_binRenderer_internal.c | 10 +++++----- lib_isar/isar_stat.h | 1 + lib_isar/lib_isar_post_rend.c | 8 +++++--- lib_rend/ivas_crend.c | 5 +++-- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 88e8ed7ac..c3de7cee7 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5961,11 +5961,10 @@ void modify_Quat_q_fx( ); void modify_Rmat_q_fx( - Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ - Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ - Word16 num_subframes, - Word16 q_cur, /* i : current q factor for rotation matrix */ - Word16 q_new /* i : target q factor for rotation matrix */ + Word32 Rmat_in[3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[3][3], /* o : real-space rotation matrix for this rotation*/ + Word16 q_cur, /* i : current q factor for rotation matrix */ + Word16 q_new /* i : target q factor for rotation matrix */ ); #endif diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index b48fdfec2..a6d7a8ae6 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -116,10 +116,10 @@ void modify_Quat_q_fx( Word16 q_new /* i : quaternion describing the rotation */ ) { - out_quat->w_fx = L_shl( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new - out_quat->x_fx = L_shl( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new - out_quat->y_fx = L_shl( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new - out_quat->z_fx = L_shl( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->w_fx = L_shl_sat( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->x_fx = L_shl_sat( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->y_fx = L_shl_sat( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new + out_quat->z_fx = L_shl_sat( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->q_fact = q_new; return; } @@ -130,24 +130,20 @@ void modify_Quat_q_fx( * Rotation matrix q factor modification *------------------------------------------------------------------------*/ void modify_Rmat_q_fx( - Word32 Rmat_in[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* i : real-space rotation matrix for this rotation */ - Word32 Rmat_out[MAX_PARAM_SPATIAL_SUBFRAMES][3][3], /* o : real-space rotation matrix for this rotation*/ - Word16 num_subframes, - Word16 q_cur, /* i : current q factor for rotation matrix */ - Word16 q_new /* i : target q factor for rotation matrix */ + Word32 Rmat_in[3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[3][3], /* o : real-space rotation matrix for this rotation*/ + Word16 q_cur, /* i : current q factor for rotation matrix */ + Word16 q_new /* i : target q factor for rotation matrix */ ) { - Word16 i, j, k; + Word16 j, k; - FOR( i = 0; i < num_subframes; i++ ) + FOR( j = 0; j < 3; j++ ) { - FOR( j = 0; j < 3; j++ ) + FOR( k = 0; k < 3; k++ ) { - FOR( k = 0; k < 3; k++ ) - { - Rmat_out[i][j][k] = L_shl( Rmat_in[i][j][k], sub( q_new, q_cur ) ); - move32(); - } + Rmat_out[j][k] = L_shl( Rmat_in[j][k], sub( q_new, q_cur ) ); + move32(); } } return; diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 97d7905f3..eb0a081f4 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1956,7 +1956,7 @@ void ivas_binRenderer_fx( IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; - Word32 Rmat_local[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; + Word32 Rmat_local[3][3]; Word16 q_fact_orig; IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) @@ -2000,17 +2000,17 @@ void ivas_binRenderer_fx( modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); - QuatToRotMat_fx( Quaternions_abs, Rmat_local[0] ); + QuatToRotMat_fx( Quaternions_abs, Rmat_local ); - modify_Rmat_q_fx( Rmat_local, Rmat_local, 1, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) { - rotateFrame_sd_cldfb_fixed( Rmat_local[0], RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } else { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local[0], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 228bc94df..171f82022 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -237,6 +237,7 @@ typedef struct ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec; int16_t first_good_frame_received; ISAR_LC3PLUS_DEC_HANDLE hLc3plusDec; + Word16 Q_last; } ISAR_SPLIT_POST_REND_WRAPPER; diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index c59159061..7cfd50e49 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1486,6 +1486,7 @@ static ivas_error renderSplitBinauralWithPostRot( { isar_splitBinLCLDDecProcess( hSplitBin->hSplitBinLCLDDec, &bits, Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, &Q_cldfb_final[sf_idx], SplitRendBFI ); // Q_cldfb_final + hSplitBin->Q_last = Q_cldfb_final[sf_idx]; /* copy data over to 5ms buffer */ FOR( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) { @@ -1526,6 +1527,7 @@ static ivas_error renderSplitBinauralWithPostRot( { return error; } + hSplitBin->Q_last = Q_out[sf_idx][0]; /* cache the remaining 15ms */ splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; @@ -1540,7 +1542,7 @@ static ivas_error renderSplitBinauralWithPostRot( { Word16 readOffset = sub( numColPerChannelCacheSize, splitBinInput->numCachedSamples ); readPtr_fx = splitBinInput->bufferData_fx; - Q_cldfb_final[sf_idx] = Q_cldfb_final[sf_idx - 1]; + Q_cldfb_final[sf_idx] = hSplitBin->Q_last; isPostRendInputCldfb = 1; readPtr_fx += 2 * readOffset * CLDFB_NO_CHANNELS_MAX * BINAURAL_CHANNELS; @@ -1566,8 +1568,8 @@ static ivas_error renderSplitBinauralWithPostRot( Word16 readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; mvl2l( splitBinInput->bufferData_fx + readOffset, &tmpCrendBuffer_fx[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); mvl2l( splitBinInput->bufferData_fx + readOffset + numSamplesPerChannelCacheSize, &tmpCrendBuffer_fx[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); - Q_out[sf_idx][0] = Q_out[sf_idx - 1][0]; - Q_out[sf_idx][1] = Q_out[sf_idx - 1][1]; + Q_out[sf_idx][0] = hSplitBin->Q_last; + Q_out[sf_idx][1] = hSplitBin->Q_last; splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; } } diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index a974364f4..1c77b9dcc 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2519,8 +2519,8 @@ ivas_error ivas_rend_crendProcessSplitBin( move32(); modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Quaternions_orig[i].q_fact ); QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx[i], combinedOrientationDataLocal.Rmat_fx[i], sub( shl( Quaternions_orig[i].q_fact, 1 ), 32 ), Q30 ); } - modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx, combinedOrientationDataLocal.Rmat_fx, MAX_PARAM_SPATIAL_SUBFRAMES, sub( shl( Quaternions_orig[0].q_fact, 1 ), 32 ), Q30 ); /* render inplace to first two channels of tmpInputBuffer */ @@ -2692,8 +2692,9 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( &combinedOrientationDataLocal.Quaternions[i] ); modify_Quat_q_fx( &combinedOrientationDataLocal.Quaternions[i], &combinedOrientationDataLocal.Quaternions[i], Quaternions_orig[i].q_fact ); QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx[i], combinedOrientationDataLocal.Rmat_fx[i], sub( shl( Quaternions_orig[i].q_fact, 1 ), 32 ), Q30 ); } - modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx, combinedOrientationDataLocal.Rmat_fx, MAX_PARAM_SPATIAL_SUBFRAMES, sub( shl( Quaternions_orig[0].q_fact, 1 ), 32 ), Q30 ); + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; move32(); -- GitLab From a145e762d148ede33e8cb20bd348f03db822625d Mon Sep 17 00:00:00 2001 From: rtyag Date: Sun, 16 Feb 2025 00:59:07 +1100 Subject: [PATCH 127/329] pcm out fix, 5ms lcld framing fix --- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/lib_isar_pre_rend.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 2695b397d..9b70c1515 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -996,7 +996,7 @@ Word32 DecodeLCLDFrame( *Q_out = Q; FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) { - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + FOR( i = 0; i < psLCLDDecoder->iNumBlocks; i++ ) { FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f528d0348..5ebfd8e61 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -374,6 +374,8 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( #endif codec_frame_size_ms, pBits, max_bands, pOutput_fx, Q_out[0], low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); + Q_out[1] = Q_out[0]; + move16(); pop_wmops(); return error; } -- GitLab From fbfeb33385a0eb76ff04df482c65291db778ba6c Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 17 Feb 2025 20:15:08 +1100 Subject: [PATCH 128/329] addition of -p BASOP to instrumentation job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4fe5ec338..16563bf57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -896,7 +896,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP - make -j -C $INSTR_DIR -- GitLab From 4b7574d6caaa4ee87b5cc11918dbce5415d15d3d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:37:00 +0100 Subject: [PATCH 129/329] add pre and post check for being up-to-date with target --- .gitlab-ci.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 875a4a478..97de3b670 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,6 +117,7 @@ stages: - build - check-be - test + - postvalidate - deploy # --------------------------------------------------------------- @@ -229,6 +230,13 @@ stages: - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } +.rules-merge-request: + extends: .rules-basis + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + .rules-pytest-to-ref-short: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" @@ -774,6 +782,35 @@ uninterruptible: # verification jobs # --------------------------------------------------------------- +branch-is-up-to-date-with-target-pre: + extends: + - .rules-merge-request + stage: prevalidate + needs: [] + tags: + - ivas-basop-linux + script: + - *get-commits-behind-count + - | + if [ $commits_behind_count -ne 0 ]; then + echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." + exit 1 + fi + +branch-is-up-to-date-with-target-post: + extends: + - .rules-merge-request + stage: postvalidate + tags: + - ivas-basop-linux + script: + - *get-commits-behind-count + - | + if [ $commits_behind_count -ne 0 ]; then + echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." + exit 1 + fi + clang-format-check: extends: - .test-job-linux -- GitLab From 543229ce49a777b1cfab2ac3c0f198f6c745b6a9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:40:07 +0100 Subject: [PATCH 130/329] add up-to-date check to BE test as well --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97de3b670..597e15e40 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -441,6 +441,14 @@ stages: HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" script: - set -euxo pipefail + + - *get-commits-behind-count + - | + if [ $commits_behind_count -ne 0 ]; then + echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run. Checking bitexactness now can result in meaningless results. Run\n\t git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." + exit 1 + fi + - *print-common-info - *update-scripts-repo -- GitLab From 5ab4502a9c76ada0195f5ad59756b0e8cbc5c12b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:42:11 +0100 Subject: [PATCH 131/329] add missing anchor --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 597e15e40..bcfed96df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -217,6 +217,11 @@ stages: - cd $LTV_DIR - git pull - cd - + +.get-commits-behind-count: &get-commits-behind-count + - echo $CI_COMMIT_SHA + - echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - commits_behind_count=$(git rev-list --count $CI_COMMIT_SHA..origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) .copy-ltv-files-to-testv-dir: ©-ltv-files-to-testv-dir - cp "$LTV_DIR"/*.wav scripts/testv/ -- GitLab From e28286c8c2df0cb223ce0620b28942626f23ad48 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:44:54 +0100 Subject: [PATCH 132/329] fix rule template --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bcfed96df..b6be74fd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -236,11 +236,11 @@ stages: - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } .rules-merge-request: - extends: .rules-basis rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_PIPELINE_SOURCE == 'push' when: never + - when: never .rules-pytest-to-ref-short: rules: -- GitLab From 53228a4ae9aa28723f0059092363dd8f5319a738 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:51:33 +0100 Subject: [PATCH 133/329] check for up-to-date with main in regression jobs, too also rename anchor as it is only used for the regressions checks now --- .gitlab-ci.yml | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6be74fd5..0d757075f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -436,6 +436,14 @@ stages: junit: - report-junit.xml +.check-up-to-date-in-comparison-jobs: &check-up-to-date-in-comparison-jobs + - *get-commits-behind-count + - | + if [ $commits_behind_count -ne 0 ]; then + echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run. Checking bitexactness or testing for regressions now can result in meaningless results. Run\n\t git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." + exit 1 + fi + .check-be-to-target-anchor: &check-be-to-target-anchor stage: check-be needs: ["build-codec-linux-make"] @@ -445,16 +453,11 @@ stages: XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" script: - - set -euxo pipefail + - *check-up-to-date-in-comparison-jobs + - *print-common-info - - *get-commits-behind-count - - | - if [ $commits_behind_count -ne 0 ]; then - echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run. Checking bitexactness now can result in meaningless results. Run\n\t git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." - exit 1 - fi + - set -euxo pipefail - - *print-common-info - *update-scripts-repo - if [ $USE_LTV -eq 1 ]; then @@ -541,7 +544,7 @@ stages: - unzip $PYTEST_CACHE_ARTIFACT - fi -.ivas-pytest-on-merge-request-anchor: &ivas-pytest-on-merge-request-anchor +.check-regressions-pytest-anchor: &check-regressions-pytest-anchor stage: test timeout: "300 minutes" variables: @@ -554,9 +557,11 @@ stages: IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" script: - - set -euxo pipefail + - *check-up-to-date-in-comparison-jobs - *print-common-info + - set -euxo pipefail + - if [ -s $FAILED_TESTCASES_LIST ]; then - *overwrite-pytest-cache-with-artifact - export PYTEST_ADDOPTS=--last-failed @@ -1042,7 +1047,7 @@ check-regressions-short-enc-0db: - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - rm -rf tests/dut tests/ref - <<: *ivas-pytest-on-merge-request-anchor + <<: *check-regressions-pytest-anchor check-regressions-short-enc-+10db: stage: test @@ -1058,7 +1063,7 @@ check-regressions-short-enc-+10db: - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref - <<: *ivas-pytest-on-merge-request-anchor + <<: *check-regressions-pytest-anchor check-regressions-short-enc--10db: stage: test @@ -1074,7 +1079,7 @@ check-regressions-short-enc--10db: - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref - <<: *ivas-pytest-on-merge-request-anchor + <<: *check-regressions-pytest-anchor check-regressions-short-dec-0db: stage: test @@ -1090,7 +1095,7 @@ check-regressions-short-dec-0db: - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=1.0 - rm -rf tests/dut tests/ref - <<: *ivas-pytest-on-merge-request-anchor + <<: *check-regressions-pytest-anchor check-regressions-short-dec-+10db: stage: test @@ -1106,7 +1111,7 @@ check-regressions-short-dec-+10db: - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref - <<: *ivas-pytest-on-merge-request-anchor + <<: *check-regressions-pytest-anchor check-regressions-short-dec--10db: stage: test @@ -1122,7 +1127,7 @@ check-regressions-short-dec--10db: - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref - <<: *ivas-pytest-on-merge-request-anchor + <<: *check-regressions-pytest-anchor # --------------------------------------------------------------- # Short test jobs for running from web interface or schedule -- GitLab From 978268149b7ce3d432ac43b6f34721f6ea731a5c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:53:09 +0100 Subject: [PATCH 134/329] add commit files to regression check artifacts --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d757075f..5bd1627ae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -665,6 +665,8 @@ stages: - $CSV_MAIN - $SUMMARY_HTML_ARTIFACT_NAME - $IMAGES_ARTIFACT_NAME + - $REF_COMMIT_FILE + - $CUT_COMMIT_FILE - changes_crashes.csv - changes_MLD.csv - changes_MAXIMUM_ABS_DIFF.csv -- GitLab From 752cb148959cac020d7a6bdca4580e54f18f8842 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 12:57:33 +0100 Subject: [PATCH 135/329] remove empty needs in build stage --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5bd1627ae..aeb3c601b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -312,13 +312,11 @@ stages: .build-job-linux: stage: build timeout: "2 minutes" - needs: [] tags: - ivas-basop-linux .build-job-windows: stage: build - needs: [] timeout: "4 minutes" tags: - ivas-windows -- GitLab From 61fb4a0eaa696effa2b3cb2ce8b59d4b5c0b9cd8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 14:06:47 +0100 Subject: [PATCH 136/329] Revert "[revert-me] deactivate more jobs for faster testing" This reverts commit 94fe3242b661346909ff5ebb142191d8a6d4fc41. --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aeb3c601b..6961113f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -902,7 +902,7 @@ build-codec-linux-make: - make -j # ensure that codec builds on linux with instrumentation active -.build-codec-linux-instrumented-make: +build-codec-linux-instrumented-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -919,7 +919,7 @@ build-codec-linux-make: - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP - make -j -C $INSTR_DIR -.build-codec-linux-debugging-make: +build-codec-linux-debugging-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -937,7 +937,7 @@ build-codec-linux-make: - *activate-debug-mode-info-if-set - make -j -.build-codec-windows-msbuild: +build-codec-windows-msbuild: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -1504,7 +1504,7 @@ coverage-test-on-main-scheduled: # --------------------------------------------------------------- # check bitexactness to EVS -.be-2-evs-26444: +be-2-evs-26444: extends: - .test-job-linux rules: -- GitLab From 09823bfe6741dfcec344878c7120320f4e3c594a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 14:07:31 +0100 Subject: [PATCH 137/329] Revert "[revert-me] force TCX20 to provoke diff for testing" This reverts commit b79cca58f691da72f9ca7cb32548af5ebbded60c. --- lib_enc/transient_detection_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index b0d131258..d9859a1a1 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -804,8 +804,6 @@ void SetTCXModeInfo_ivas_fx( hTcxEnc->tcxMode = TCX_20; move16(); } - - hTcxEnc->tcxMode = TCX_20; } ELSE { -- GitLab From 3af8351a7f5d0794817df190871841d59233e272 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 14:12:11 +0100 Subject: [PATCH 138/329] remove pytest filter which was used for testing only --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6961113f4..d0b4e4d6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -193,7 +193,7 @@ stages: - enc_dmx_arg="--compare_enc_dmx" - fi - - python3 -m pytest -k "stereo and at" $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? .update-scripts-repo: &update-scripts-repo - cd $SCRIPTS_DIR @@ -475,7 +475,7 @@ stages: - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest -k "stereo and at" --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE -- GitLab From 960fffa18703d87baedeb23b2a12f9c21fd04860 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 15:05:12 +0100 Subject: [PATCH 139/329] check for up to date branch after build of reference --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0b4e4d6a..8e1d38a6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -438,6 +438,7 @@ stages: - *get-commits-behind-count - | if [ $commits_behind_count -ne 0 ]; then + set +x echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run. Checking bitexactness or testing for regressions now can result in meaningless results. Run\n\t git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 1 fi @@ -451,7 +452,6 @@ stages: XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" script: - - *check-up-to-date-in-comparison-jobs - *print-common-info - set -euxo pipefail @@ -472,6 +472,7 @@ stages: - fi - *build-and-create-reference-outputs + - *check-up-to-date-in-comparison-jobs - exit_code=0 - rm -rf .pytest_cache || true @@ -555,7 +556,6 @@ stages: IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" script: - - *check-up-to-date-in-comparison-jobs - *print-common-info - set -euxo pipefail @@ -592,6 +592,7 @@ stages: ### run branch first # this per default builds the branch and the reference and creates the reference outputs - *build-and-create-reference-outputs + - *check-up-to-date-in-comparison-jobs # need to restore cache again - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true -- GitLab From 2de341b9b6f0b35595bcfe85b8746366f7202e6e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Feb 2025 15:12:35 +0100 Subject: [PATCH 140/329] add --show_improvements arg to basop_check_for_changes.py --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e1d38a6f..f0dfa5668 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -619,7 +619,7 @@ stages: ### compare the two csv files for regressions - regressions_found=0 - - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH > regression_log.txt || regressions_found=$? + - python3 scripts/basop_check_for_changes_in_testcases.py --show_improvements --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH > regression_log.txt || regressions_found=$? - exit_code=0 - *print-results-banner -- GitLab From 38678a41ba18f765d3c49e114772ee16609621ad Mon Sep 17 00:00:00 2001 From: Anjaneyulu Sana Date: Mon, 17 Feb 2025 22:34:25 +0530 Subject: [PATCH 141/329] Fix for 3GPP issue 1262: Saturated signal in discrete multichannel output with fx encoder in v2 release --- lib_enc/ivas_mct_enc.c | 2 ++ lib_enc/ivas_mdct_core_enc.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 8c194bed1..5510f1eb1 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -401,6 +401,8 @@ ivas_error ivas_mct_enc_fx( move16(); st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[1] = sub( 31, q_spec ); move16(); + st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e = sub( 31, q_spec ); + move16(); IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 18bee6777..4997a6715 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -2672,6 +2672,11 @@ void ivas_mdct_quant_coder_fx( st->hTcxEnc->spectrum_e[n] = min_shift; move16(); } + if ( GT_16( nSubframes, 1 ) ) + { + st->hTcxEnc->spectrum_long_e = min_shift; + move16(); + } } EstimateStereoTCXNoiseLevel_fx( sts, quantized_spectrum_fx, gain_tcx_fx, gain_tcx_e, L_frame, noiseFillingBorder, hm_active, ignore_chan, fac_ns_fx, param_core, MCT_flag ); -- GitLab From dfdaaaa72496aa328d0c80a09d24861fa7e6a3f8 Mon Sep 17 00:00:00 2001 From: Anjaneyulu Sana Date: Mon, 17 Feb 2025 22:59:10 +0530 Subject: [PATCH 142/329] Fix for 3GPP issue 1287: Major spectral difference between signal decoded from fixed- and floating-point encoded bitstreams at 13.2kbps for OSBA inputs --- lib_enc/igf_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index a85843be2..e23417e70 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -2666,9 +2666,10 @@ void IGFEncApplyMono_ivas_fx( FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) { - common_pPowerSpectrum_fx[i] = L_shl( common_pPowerSpectrum_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) ); + common_pPowerSpectrum_fx[i] = L_shl( pPowerSpectrumParameter_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) ); move16(); } + pPowerSpectrumParameter_fx = common_pPowerSpectrum_fx; } IGF_ErodeSpectrum_ivas_fx( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx, 0 ); } -- GitLab From 74f66bf8e65f7b3e63d8df19e27d02b07af0feeb Mon Sep 17 00:00:00 2001 From: ber Date: Tue, 18 Feb 2025 09:47:30 +0100 Subject: [PATCH 143/329] further cleanup --- lib_com/options.h | 1 - lib_rend/ivas_dirac_output_synthesis_dec.c | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 92144ade1..2747226b4 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,4 +157,3 @@ #define FIX_1072_SPEEDUP_gainpanning /* FhG: WMOPS tuning, in development*/ #define FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB /* "-" */ -//#define FIX_1072_SPEEDUP_output_synthesis_procSlot /* "-" */ \ No newline at end of file diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 404f98b1b..6a7a73c18 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -942,18 +942,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ } } -#ifdef FIX_1072_SPEEDUP_output_synthesis_procSlot - q_diff_aab = add( h_dirac_output_synthesis_state->direct_responses_q + sub( sub( 15, b_exp ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); - q_diff_c = sub( q_diffuseness, 4 ); - - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 - mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 - mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 - - /*Todo: simplify so that mpy+add can be merged to madd*/ - sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*q(31-sqr_exp)*/ - -#else mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 @@ -981,7 +969,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr_exp = sub( 31, q_diff_c ); /*q_diff_c*/ } } -#endif sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ -- GitLab From fc11d020838a7da70152594f05efce479afaddcb Mon Sep 17 00:00:00 2001 From: ber Date: Tue, 18 Feb 2025 11:34:22 +0100 Subject: [PATCH 144/329] tiny fix --- lib_com/ivas_dirac_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 9fe68f250..38abc76f3 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -968,7 +968,7 @@ void computeDiffuseness_fixed( q_tmp = add( q_factor_energy[i], min_q_shift1 ); -#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESSB +#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS Word16 shift_q = sub( q_tmp, q_ene ); Word32 shiftEquiv; Word16 shift_qtotal; -- GitLab From 74d1e1951db936a260f30cd2fefe11c1a41e9cf9 Mon Sep 17 00:00:00 2001 From: ber Date: Tue, 18 Feb 2025 11:39:19 +0100 Subject: [PATCH 145/329] apply clang format patch --- lib_com/ivas_dirac_com.c | 5 ++--- lib_dec/ivas_dirac_dec.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 8 ++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 38abc76f3..2704c1f08 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -972,11 +972,11 @@ void computeDiffuseness_fixed( Word16 shift_q = sub( q_tmp, q_ene ); Word32 shiftEquiv; Word16 shift_qtotal; - if( shift_q < 0 ) + if ( shift_q < 0 ) { shiftEquiv = L_lshl( 0x80000000, shift_q ); } - if( shift_q >= 0 ) + if ( shift_q >= 0 ) { shiftEquiv = L_add( 0x7FFFFFFF, 0 ); } @@ -1011,7 +1011,6 @@ void computeDiffuseness_fixed( #endif - q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ed1f292b2..95cca12a0 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2555,7 +2555,7 @@ void ivas_dirac_dec_render_sf_fx( p_Rmat_fx = 0; move32(); } - + IF( ( hDirAC->hConfig->dec_param_estim == FALSE ) ) { Word16 *masa_band_mapping; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index ba8048267..866badda0 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1099,7 +1099,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); #endif - } #ifdef FIX_1072_SPEEDUP_gainpanning Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); @@ -1109,13 +1108,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { Word16 i; Word32 aux; - IF(temp_q1 < 0) + IF( temp_q1 < 0 ) { Word32 temp_q1_equiv = L_lshl( 0x80000000, temp_q1 ); FOR( i = 0; i < num_freq_bands; i++ ) { aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] , aux, temp_q1_equiv ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i] = Madd_32_32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + i], aux, temp_q1_equiv ); move32(); } } @@ -1129,7 +1128,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } } - } ELSE { @@ -1140,8 +1138,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } } - - } #else -- GitLab From 1a123fc971435e2fe4d8962871823377a3ef213f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 18 Feb 2025 13:25:52 +0100 Subject: [PATCH 146/329] use new folder structure for lc3plus tests --- .gitlab-ci.yml | 2 +- CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6bc7b1cc..11cf88e1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1050,7 +1050,7 @@ lc3-wrapper-unit-test: - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - cmake --build cmake-build -- -j - - scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test + - scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test # compare split-rendering bitexactness between target and source branch split-rendering-pytest-on-merge-request: diff --git a/CMakeLists.txt b/CMakeLists.txt index 17799f0db..887bc6df0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,7 @@ target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_ target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar) if(NOT WMOPS) - add_executable(ivas_lc3plus_unit_test ${CMAKE_SOURCE_DIR}/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test.c) + add_executable(ivas_lc3plus_unit_test ${CMAKE_SOURCE_DIR}/scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test.c) target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_debug lib_isar) endif() -- GitLab From 041a84a88bd0b6fb260f23366ad55072de5dba66 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 18 Feb 2025 14:11:47 +0100 Subject: [PATCH 147/329] fix copy command in CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 887bc6df0..adc86288c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,7 +213,7 @@ if(COPY_EXECUTABLES_FROM_BUILD_DIR) add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET ISAR_post_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") if (NOT WMOPS) - add_custom_command(TARGET ivas_lc3plus_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/split_rendering/lc3plus") + add_custom_command(TARGET ivas_lc3plus_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/split_rendering/lc3plus_basop") endif() endif() -- GitLab From 1a3093376b1cb4217bcf558fd2dbe1cc9ee31fb8 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 19 Feb 2025 10:43:52 +1100 Subject: [PATCH 148/329] fix for lc3plus sanitizer --- lib_isar/isar_lc3plus_enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index f6bb0284d..bf76e2e59 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -147,6 +147,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( #endif ( *handle )->pcm_conversion_buffer = NULL; + ( *handle )->scratch = NULL; ( *handle )->num_encs = 0; if ( ( ( *handle )->handles = malloc( config.channels * sizeof( ISAR_LC3PLUS_ENC_HANDLE ) ) ) == NULL ) { -- GitLab From 48ece3d0c459c1563c8f25f674d063c7b6a86a2d Mon Sep 17 00:00:00 2001 From: Anjaneyulu Sana Date: Wed, 19 Feb 2025 14:00:48 +0530 Subject: [PATCH 149/329] Fix for 3GPP issue 1258: Decoder: Click artifact for Stereo to Mono Decoding --- lib_dec/ivas_core_dec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 8d88074a8..9aaddb2fb 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -782,6 +782,7 @@ ivas_error ivas_core_dec_fx( /* for inactive frames with mono output, copy and (if necessary) downmix buffers */ ELSE IF( EQ_16( hCPE->nchan_out, 1 ) ) { + Word16 shift1, shift2; sts[0] = hCPE->hCoreCoder[0]; sts[1] = hCPE->hCoreCoder[1]; @@ -800,6 +801,15 @@ ivas_error ivas_core_dec_fx( move16(); sts[1]->hHQ_core->Q_old_wtda = sub( 15, sts[1]->hHQ_core->exp_old_out ); move16(); + + shift1 = norm_arr( sts[0]->hHQ_core->old_out_fx, L_FRAME48k ); + shift2 = norm_arr( sts[1]->hHQ_core->old_out_fx, L_FRAME48k ); + scale_sig( sts[0]->hHQ_core->old_out_fx, L_FRAME48k, shift1 ); + scale_sig( sts[1]->hHQ_core->old_out_fx, L_FRAME48k, shift2 ); + sts[0]->hHQ_core->Q_old_wtda = add( sts[0]->hHQ_core->Q_old_wtda, shift1 ); + sts[1]->hHQ_core->Q_old_wtda = add( sts[1]->hHQ_core->Q_old_wtda, shift2 ); + move16(); + move16(); } } -- GitLab From 100b1737cfdef8feb539912f3a4a8a616f1a3160 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 20 Feb 2025 11:41:36 +1100 Subject: [PATCH 150/329] WMOPS SKIP for two UWords32 () lines --- .gitlab-ci.yml | 2 +- lib_isar/isar_lcld_decoder.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16563bf57..4fe5ec338 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -896,7 +896,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 9b70c1515..371aee854 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1860,8 +1860,10 @@ static Word32 ReadLCLDData_fx( #ifdef USE_DEMOD_TABLES const int32_t( *paiDemodTable )[2] = NULL; #endif +#define WMC_TOOL_SKIP pauiHuffmanTable = (const UWord32( * )[HUFF_DEC_TABLE_SIZE]) c_apauiHuffDecTables[iAlloc]; pauiHuffmanTableDPCM = (const UWord32( * )[HUFF_DEC_TABLE_SIZE]) c_apauiHuffDecTables[ALLOC_TABLE_SIZE + iAlloc]; +#undef WMC_TOOL_SKIP #ifdef USE_DEMOD_TABLES paiDemodTable = c_apaiDemodTables[iAlloc]; #endif -- GitLab From 56ef608aae1d8760768844d3b9b7e3774ecc663a Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 20 Feb 2025 17:04:29 +1100 Subject: [PATCH 151/329] setting lc3plus scrtach buffer to NULL before malloc --- lib_isar/isar_lc3plus_dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 1c63158b3..2aec77746 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -116,6 +116,7 @@ ivas_error ISAR_LC3PLUS_DEC_Open( ( *handle )->handles = NULL; ( *handle )->selective_decoding_states = NULL; ( *handle )->bitstream_caches = NULL; + ( *handle )->scratch = NULL; if ( ( ( *handle )->handles = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_HANDLE ) ) ) == NULL ) { -- GitLab From 3adbd6fbee1af752c0dae017f684a30aef7f2029 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 20 Feb 2025 11:01:39 +0100 Subject: [PATCH 152/329] use ignorelist in USAN job --- .gitlab-ci.yml | 10 ++++++++-- Makefile | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1bc5a6f07..855f5d571 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -553,9 +553,15 @@ stages: - *copy-ltv-files-to-testv-dir - python3 ci/remove_unsupported_testcases.py $PRM_FILES - *build-reference-and-dut-binaries + + - make_args="CLANG=$CLANG_NUM" + - if [[ $CLANG_NUM == 3 ]]; then + - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1" + - python3 scripts/basop_create_ignorelist_for_ubsan.py + - make_args="$make_args IGNORELIST=1" + - fi - make clean - - make -j CLANG=$CLANG_NUM - - if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1"; fi + - make -j $make_args - testcase_timeout=$TESTCASE_TIMEOUT_LTV_SANITIZERS - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH artifacts: diff --git a/Makefile b/Makefile index 4e92bc951..e444cc54b 100644 --- a/Makefile +++ b/Makefile @@ -82,10 +82,14 @@ ifeq "$(CLANG)" "3" CC = $(CCCLANG) # NOTE: keep in sync with list in CMakeLists.txt usan_checks = undefined,float-divide-by-zero,implicit-conversion,local-bounds -CFLAGS += -fsanitize=$(usan_checks) +CFLAGS += -fsanitize=$(usan_checks) CFLAGS += -fsanitize-recover=$(usan_checks) LDFLAGS += -fsanitize=$(usan_checks) LDFLAGS += -fsanitize-recover=$(usan_checks) + +ifeq "$(IGNORELIST)" "1" +CFLAGS += -fsanitize-ignorelist=ubsan_ignorelist.txt +LDFLAGS += -fsanitize-ignorelist=ubsan_ignorelist.txt endif ifeq "$(RELEASE)" "1" -- GitLab From fc5fb077d82513ee77924703f210e305063a3052 Mon Sep 17 00:00:00 2001 From: Anjaneyulu Sana Date: Wed, 19 Feb 2025 14:37:14 +0530 Subject: [PATCH 153/329] Updates in MCT core encoder path for precision improvement --- lib_com/ivas_prot_fx.h | 19 ++++++++++--------- lib_enc/igf_enc.c | 4 ++-- lib_enc/ivas_lfe_enc.c | 7 ++++--- lib_enc/ivas_mct_core_enc.c | 38 ++++++++++++++++++------------------- lib_enc/ivas_mct_enc_mct.c | 25 ++++++++++++++---------- lib_enc/tcx_utils_enc_fx.c | 4 ++-- 6 files changed, 52 insertions(+), 45 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5ce037b9a..1682c255b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3341,15 +3341,16 @@ void ivas_omasa_enc_fx( ); void mctStereoIGF_enc_fx( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ - Word16 q_origSpec, /* i : Q for MDCT spectrum */ - Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/ - Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect.*/ - Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx and powSpecMsInv_fx*/ - Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + Encoder_State **sts, /* i/o: encoder state structure */ + Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ + Word16 q_origSpec, /* i : Q for MDCT spectrum */ + Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ + Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx */ + Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as powerSpec_fx but for inverse spect.*/ + Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS], /* i : Q for powSpecMsInv_fx */ + Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ + const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ ); void ivas_mct_core_enc_fx( diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index d20169e73..0ce087508 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -943,9 +943,9 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); sfbEnergyR = add_sat( EPSILON_FX, BASOP_Util_Divide3216_Scale( sum2_32_fx( pMDCTSpectrum_fx + swb_offset[sfb], width, &tmp_e ) /*exp: tmp_e*/, width, &sfbEnergyR_e ) ); // sfbEnergyR_e sfbEnergyR_e = add( sfbEnergyR_e, add( tmp_e, -15 ) ); - gain = sfbEnergyR; // gain_e + gain = L_shl( sfbEnergyR, 16 ); // gain_e move32(); - gain_e = add( sfbEnergyR_e, 16 ); + gain_e = sfbEnergyR_e; IF( element_mode > EVS_MONO ) { diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index e72270e6c..e219e8b37 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -199,12 +199,13 @@ static void ivas_lfe_enc_quant_fx( q_lfe_abs_sum = sub( q_lfe_abs_sum, q_tmp ); } - tmp = BASOP_Util_Divide3232_Scale( max_value, W_extract_l( lfe_abs_sum ), &q_tmp ); - tmp = L_shl( tmp, sub( q_lfe_abs_sum, sub( 15, q_tmp ) ) ); /* Q0 (max_value / lfe_abs_sum) */ + tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( max_value, W_extract_l( lfe_abs_sum ), &q_tmp ) ); + // tmp = L_shl( tmp, sub( q_lfe_abs_sum, sub( 15, q_tmp ) ) ); /* Q0 (max_value / lfe_abs_sum) */ + q_tmp = sub( Q16, sub( q_lfe_abs_sum, sub( 15, q_tmp ) ) ); /* log2_f(max_value / lfe_abs_sum) -> Q25 */ tmp = BASOP_Util_Log2( tmp ); - tmp = L_add( tmp, 1040187392 ) /* (31<<25) -> 1040187392 */; /* Q25 */ + tmp = L_add( tmp, L_shl( sub( Q31, q_tmp ), Q25 ) ) /* (31<<25) -> 1040187392 */; /* Q25 */ /* IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f(max_value / lfe_abs_sum) */ tmp = Mpy_32_16_1( tmp, IVAS_LFE_SHIFTS_PER_DOUBLE ); /* 25-15 -> Q10 */ diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index f5f179778..52fd554d8 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -247,7 +247,7 @@ void ivas_mct_core_enc_fx( Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ Word16 total_side_bits; Word16 chBitRatios[MCT_MAX_CHANNELS]; - Word16 q_powSpec[MCT_MAX_CHANNELS], q_spec, q_origSpec, tmp_s; + Word16 q_powSpec[MCT_MAX_CHANNELS], q_powerSpecMsInv[MCT_MAX_CHANNELS], q_spec, q_origSpec, tmp_s; Word16 tmp_q_powSpec[L_FRAME48k], tmp_q_powSpecInv[L_FRAME48k], *tmp_q_psi[2]; Word64 W_tmp; Encoder_State *sts[MCT_MAX_CHANNELS]; @@ -437,7 +437,7 @@ void ivas_mct_core_enc_fx( FOR( i = 0; i < L_subframeTCX; i++ ) { W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -445,7 +445,7 @@ void ivas_mct_core_enc_fx( move16(); W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -459,7 +459,7 @@ void ivas_mct_core_enc_fx( { /* power spectrum: MDCT^2 + MDST^2 */ W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp ); tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -471,7 +471,7 @@ void ivas_mct_core_enc_fx( mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate */ W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -480,7 +480,7 @@ void ivas_mct_core_enc_fx( } W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp ); tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -490,7 +490,7 @@ void ivas_mct_core_enc_fx( /* power spectrum: MDCT^2 + MDST^2 */ W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][0], sts[ch]->hTcxEnc->spectrum_fx[n][0] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp ); tmp_q_powSpec[n * L_subframeTCX] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -513,7 +513,7 @@ void ivas_mct_core_enc_fx( } W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 @@ -524,31 +524,31 @@ void ivas_mct_core_enc_fx( /* Aligning the Q-factors */ { + q_powSpec[ch] = Q31; + move16(); + q_powerSpecMsInv[ch] = Q31; + move16(); /* NOTE: This logic has been added because using a constant headroom while computing `powSpec` and `powSpecMsInv` leads to significant precision loss, which results in poor quality. */ FOR( i = 0; i < L_FRAME48k; i++ ) { - if ( powerSpec_fx[ch][i] == 0 ) + IF( powerSpec_fx[ch][i] != 0 ) { - tmp_q_powSpec[i] = 63; + q_powSpec[ch] = s_min( q_powSpec[ch], add( tmp_q_powSpec[i], norm_l( powerSpec_fx[ch][i] ) ) ); move16(); } - if ( powerSpecMsInv_fx[ch][0][i] == 0 ) + IF( powerSpecMsInv_fx[ch][0][i] != 0 ) { - tmp_q_powSpecInv[i] = 63; + q_powerSpecMsInv[ch] = s_min( q_powerSpecMsInv[ch], add( tmp_q_powSpecInv[i], norm_l( powerSpecMsInv_fx[ch][0][i] ) ) ); move16(); } } - minimum_s( tmp_q_powSpec, L_FRAME48k, &q_powSpec[ch] ); - minimum_s( tmp_q_powSpecInv, L_FRAME48k, &tmp_s ); - q_powSpec[ch] = s_min( q_powSpec[ch], tmp_s ); - move16(); FOR( n = 0; n < nSubframes; n++ ) { FOR( i = 0; i < L_subframeTCX; i++ ) { - powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) ); - powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) ); + powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powerSpecMsInv[ch] ) ); + powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i + ( n * L_subframeTCX )], q_powSpec[ch] ) ); move32(); move32(); } @@ -606,7 +606,7 @@ void ivas_mct_core_enc_fx( { IF( hMCT->currBlockDataCnt > 0 ) { - mctStereoIGF_enc_fx( hMCT, sts, orig_spectrum_fx, q_origSpec, powerSpec_fx, powerSpecMsInv_fx, q_powSpec, inv_spectrum_fx, sp_aud_decision0 ); + mctStereoIGF_enc_fx( hMCT, sts, orig_spectrum_fx, q_origSpec, powerSpec_fx, q_powSpec, powerSpecMsInv_fx, q_powerSpecMsInv, inv_spectrum_fx, sp_aud_decision0 ); } ELSE { diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index 4b84ea9cb..654c00db4 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -981,15 +981,16 @@ void write_mct_bitstream_fx( * IGF analysis of channels after MCT processing *--------------------------------------------------------------------*/ void mctStereoIGF_enc_fx( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ - Word16 q_origSpec, /* i : Q for MDCT spectrum */ - Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/ - Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect.*/ - Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx and powSpecMsInv_fx*/ - Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + Encoder_State **sts, /* i/o: encoder state structure */ + Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ + Word16 q_origSpec, /* i : Q for MDCT spectrum */ + Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ + Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx */ + Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as powerSpec_fx but for inverse spect.*/ + Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS], /* i : Q for powSpecMsInv_fx */ + Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ + const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ ) { Word32 *p_powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV]; @@ -999,6 +1000,7 @@ void mctStereoIGF_enc_fx( Word16 b, nSubframes, L_subframeTCX; Word16 p_ch[2], n, ch, ch1, ch2, s = 31; + Word16 q_pSI_ch[2]; Word16 q_pS_ch[2]; Encoder_State *p_st[NB_DIV]; Encoder_State *st; @@ -1062,7 +1064,9 @@ void mctStereoIGF_enc_fx( p_inv_spectrum_fx[0][n] = inv_spectrum_fx[ch1][n]; p_inv_spectrum_fx[1][n] = inv_spectrum_fx[ch2][n]; q_pS_ch[0] = q_powerSpec[ch1]; + q_pSI_ch[0] = q_powerSpecMsInv[ch1]; q_pS_ch[1] = q_powerSpec[ch2]; + q_pSI_ch[1] = q_powerSpecMsInv[ch2]; move16(); move16(); @@ -1075,6 +1079,7 @@ void mctStereoIGF_enc_fx( { s = s_min( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[n] ) ); s = s_min( s, q_pS_ch[ch] ); + s = s_min( s, q_pSI_ch[ch] ); } FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -1085,7 +1090,7 @@ void mctStereoIGF_enc_fx( move16(); move16(); - scale_sig32( p_powerSpecMsInv_fx[ch][0], L_FRAME48k, sub( s, q_pS_ch[ch] ) ); + scale_sig32( p_powerSpecMsInv_fx[ch][0], L_FRAME48k, sub( s, q_pSI_ch[ch] ) ); scale_sig32( &p_powerSpec_fx[ch][0], sts[ch]->hTcxEnc->L_frameTCX, sub( s, q_pS_ch[ch] ) ); q_powerSpec[ch1] = s; q_powerSpec[ch2] = s; diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 1e35c78c4..27c8e6f5f 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3842,7 +3842,7 @@ void ProcessIGF_ivas_fx( ITF_Detect_ivas_fx( hIGFEnc->spec_be_igf, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc->spec_be_igf_e ) ); test(); - IF( LT_32( L_deposit_l( hIGFEnc->tns_predictionGain ), 9646899 /* 1.15 in Q23 */ ) && LT_32( L_deposit_l( predictionGain ), 9646899 /* 1.15 in Q23 */ ) ) + IF( LT_16( hIGFEnc->tns_predictionGain, ONE_POINT_ONE_FIVE_Q7 ) && LT_16( predictionGain, ONE_POINT_ONE_FIVE_Q7 ) ) { hIGFEnc->flatteningTrigger = 1; move16(); @@ -3949,7 +3949,7 @@ void ProcessStereoIGF_fx( ITF_Detect_ivas_fx( hIGFEnc[ch]->spec_be_igf, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &Q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc[ch]->spec_be_igf_e ) ); test(); - hIGFEnc[ch]->flatteningTrigger = LT_32( hIGFEnc[ch]->tns_predictionGain, ONE_POINT_ONE_FIVE_Q23 ) && LT_32( predictionGain, ONE_POINT_ONE_FIVE_Q7 ); + hIGFEnc[ch]->flatteningTrigger = LT_16( hIGFEnc[ch]->tns_predictionGain, ONE_POINT_ONE_FIVE_Q7 ) && LT_16( predictionGain, ONE_POINT_ONE_FIVE_Q7 ); move16(); hIGFEnc[ch]->infoTotalBitsPerFrameWritten = 0; -- GitLab From f016e6dd8aa1358d8f459755d87fa721f8a40fa1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 20 Feb 2025 12:27:45 +0100 Subject: [PATCH 154/329] fix missing endif --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index e444cc54b..9d18cbde3 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,7 @@ ifeq "$(IGNORELIST)" "1" CFLAGS += -fsanitize-ignorelist=ubsan_ignorelist.txt LDFLAGS += -fsanitize-ignorelist=ubsan_ignorelist.txt endif +endif ifeq "$(RELEASE)" "1" CFLAGS += -DRELEASE -- GitLab From 550a38ef5fb2ae8ee48555504ae3b1b13b7d3a9c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 20 Feb 2025 13:28:25 +0100 Subject: [PATCH 155/329] remove redundant builds and set bash strict mode --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 855f5d571..c1e56d48d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -552,8 +552,9 @@ stages: - *update-scripts-repo - *copy-ltv-files-to-testv-dir - python3 ci/remove_unsupported_testcases.py $PRM_FILES - - *build-reference-and-dut-binaries + - *build-reference-binaries + - set -euxo pipefail - make_args="CLANG=$CLANG_NUM" - if [[ $CLANG_NUM == 3 ]]; then - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1" -- GitLab From 5b353253c634f52b393c8afe68023d964715dfec Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 13:35:37 +0100 Subject: [PATCH 156/329] rename WMOPS_LC3PLUS back to WMOPS --- lib_lc3plus/basop_util_lc3plus.h | 8 +- lib_lc3plus/dec_lc3.c | 94 ++++++++++---------- lib_lc3plus/enc_lc3.c | 112 ++++++++++++------------ lib_lc3plus/plc_classify_fx.c | 16 ++-- lib_lc3plus/plc_phecu_fec_hq_fx.c | 106 +++++++++++----------- lib_lc3plus/plc_phecu_peak_locator_fx.c | 4 +- lib_lc3plus/plc_phecu_setf0hz_fx.c | 4 +- lib_lc3plus/plc_phecu_tools_fx.c | 4 +- lib_lc3plus/plc_update_aft_imdct_fx.c | 8 +- lib_lc3plus/plc_update_fx.c | 4 +- lib_lc3plus/plc_xcorr_fx.c | 8 +- lib_lc3plus/pvq_enc_fx.c | 4 +- lib_lc3plus/pvq_index_fx.c | 8 +- lib_lc3plus/sns_quantize_scf_fx.c | 20 ++--- 14 files changed, 200 insertions(+), 200 deletions(-) diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h index f22d531cf..5f4f5c56b 100644 --- a/lib_lc3plus/basop_util_lc3plus.h +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -316,14 +316,14 @@ void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word void BASOP_rfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); void BASOP_irfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); -#if WMOPS_LC3PLUS +#if WMOPS extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #endif static __inline void basop_memcpy(void *dst, const void *src, size_t n) { -#if WMOPS_LC3PLUS +#if WMOPS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif /* check for overlapping memory */ @@ -333,7 +333,7 @@ static __inline void basop_memcpy(void *dst, const void *src, size_t n) static __inline void basop_memmove(void *dst, const void *src, size_t n) { -#if WMOPS_LC3PLUS +#if WMOPS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif memmove(dst, src, n); @@ -341,7 +341,7 @@ static __inline void basop_memmove(void *dst, const void *src, size_t n) static __inline void basop_memset(void *dst, int val, size_t n) { -#if WMOPS_LC3PLUS +#if WMOPS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif memset(dst, val, n); diff --git a/lib_lc3plus/dec_lc3.c b/lib_lc3plus/dec_lc3.c index 59a061862..40818106e 100644 --- a/lib_lc3plus/dec_lc3.c +++ b/lib_lc3plus/dec_lc3.c @@ -148,7 +148,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s memset(q_d_fx, 0, decoder->frame_length * sizeof(*q_d_fx)); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Decoder"); #endif @@ -164,18 +164,18 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s if (bfi != 1) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("Dec(bfi=0)"); #endif } else { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("Dec(bfi=1)"); #endif } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Entropy dec"); #endif IF (sub(bfi, 1) != 0) @@ -186,11 +186,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s BW_cutoff_idx_nf = BW_cutoff_idx; move16(); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); /* Entropy dec */ #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Ari dec"); #endif IF (sub(bfi, 1) != 0) @@ -243,11 +243,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processAriDecoderScaling_fx(sqQdec, decoder->yLen, q_d_fx, &q_fx_exp); } } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); /* Ari dec */ #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("SnsQuantScfDec"); #endif IF (sub(bfi, 1) != 0) @@ -260,11 +260,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q, currentScratch); #endif } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("PLC::ComputeStabFac"); #endif if (h_DecSetup->plcAd) @@ -272,11 +272,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processPLCcomputeStabFac_main(scf_q, h_DecSetup->plcAd->old_scf_q, h_DecSetup->plcAd->old_old_scf_q, bfi, h_DecSetup->prev_bfi, h_DecSetup->prev_prev_bfi, &h_DecSetup->plcAd->stab_fac); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Partial Concealment"); #endif IF (sub(bfi, 1) != 0) @@ -295,13 +295,13 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s &h_DecSetup->prev_gg_e, &BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns_fx, &h_DecSetup->pc_nbLostFramesInRow); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif IF (sub(bfi, 1) != 0) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Residual dec"); #endif processResidualDecoding_fx(q_d_fx, q_fx_exp, decoder->yLen, resBitBuf, fill_bits @@ -309,11 +309,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Noisefill"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ @@ -326,19 +326,19 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("applyGlobalGain"); #endif processApplyGlobalGain_fx(q_d_fx, &q_fx_exp, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Tns_dec"); #endif /* currentScratch Size = 48 bytes */ @@ -348,45 +348,45 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif #ifdef ENABLE_HR_MODE -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("SnsInterpScfDec"); #endif processSnsInterpolateScf_fx(scf_q_ip, int_scf_fx_ip, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Mdct shaping_dec"); #endif processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); processMdctShaping_fx(q_d_fx, int_scf_fx_ip, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif #else -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("SnsInterpScfDec"); #endif /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Mdct shaping_dec"); #endif processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); processMdctShaping_fx(q_d_fx, int_scf_fx, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* end int_scf_fx */ @@ -406,7 +406,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("PLC::Main"); #endif /* currentScratch Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ @@ -432,7 +432,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->alpha_type_2_table #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif @@ -446,7 +446,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("PLC/PC::DampingScrambling"); #endif if (h_DecSetup->plcAd) @@ -462,11 +462,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Imdct"); #endif /* currentScratch Size = 4 * MAX_LEN */ @@ -499,11 +499,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("PLC::Update"); #endif @@ -514,11 +514,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("LtpfDec"); #endif /* currentScratch Size = 0.5 * MAX_LEN + 20 bytes */ @@ -533,7 +533,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms, #endif currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif @@ -547,7 +547,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Output scaling"); #endif { @@ -579,15 +579,15 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } } } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); /* Output scaling */ #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); /* Decoder */ #endif @@ -623,7 +623,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo { fec_num_bytes = num_bytes; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("fec_dec"); #endif @@ -632,7 +632,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec, scratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif @@ -668,7 +668,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo { fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("fec_dec"); #endif @@ -679,7 +679,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo &decoder->n_pccw, &channel_bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec, scratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif diff --git a/lib_lc3plus/enc_lc3.c b/lib_lc3plus/enc_lc3.c index ada4bf87e..30ff9971b 100644 --- a/lib_lc3plus/enc_lc3.c +++ b/lib_lc3plus/enc_lc3.c @@ -61,7 +61,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ # endif #endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Encoder"); #endif @@ -134,7 +134,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* Scale 24-bit input data */ IF (sub(bits_per_sample, 24) == 0) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Scale_signal24"); #endif scale_signal24_fx(s_in, s_in_scaled, &h_EncSetup->x_exp, h_EncSetup->stEnc_mdct_mem, @@ -142,7 +142,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, encoder->r12k8_mem_out_len, h_EncSetup->mdct_mem32, encoder->frame_length, h_EncSetup->resamp_mem32, h_EncSetup->olpa_mem_s12k8, &h_EncSetup->resamp_exp); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif } @@ -161,7 +161,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Mdct"); #endif @@ -174,12 +174,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif encoder->W_fx, encoder->W_size, h_EncSetup->stEnc_mdct_mem, encoder->stEnc_mdct_mem_len, d_fx, &d_fx_exp, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* begin s_12k8 */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Resamp12k8"); #endif /* currentScratch Size = 2.25 * MAX_LEN bytes */ @@ -198,11 +198,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ , bits_per_sample ); #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Olpa"); #endif /* currentScratch Size = 392 bytes */ @@ -212,11 +212,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ &h_EncSetup->pitch_flag, #endif h_EncSetup->resamp_exp, encoder->frame_dms, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("LtpfEnc"); #endif /* currentScratch Size = 512 bytes */ @@ -229,12 +229,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ,encoder->hrmode #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* end s_12k8 */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("AttackDetector"); #endif /* currentScratch Size = ??? bytes */ @@ -243,12 +243,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #else attack_detector_fx(encoder, h_EncSetup, s_in_scaled, sub(h_EncSetup->x_exp, 15), currentScratch); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* begin ener_fx */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("PerBandEnergy"); #endif /* currentScratch Size = 160 bytes */ @@ -258,11 +258,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ , encoder->hrmode #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Near Nyquist Detector"); #endif /* Near Nyquist Detector */ @@ -283,10 +283,10 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->ltpf_mem_ltpf_on = 0; move16(); ltpf_idx[1] = 0; move16(); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("BW Cutoff-Detection"); #endif IF (h_EncSetup->lfe == 0) @@ -311,11 +311,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ { BW_cutoff_idx = 0; } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("SnsCompScf"); #endif @@ -324,39 +324,39 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processSnsComputeScf_fx(ener_fx, ener_fx_exp, encoder->fs_idx, encoder->bands_number, scf, h_EncSetup->attdec_detected, encoder->attdec_damping, currentScratch, encoder->sns_damping ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("SnsQuantScfEnc"); #endif /* currentScratch Size = 500 bytes */ processSnsQuantizeScfEncoder_fx(scf, L_scf_idx, scf_q, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("SnsInterpScfEnc"); #endif /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 1, encoder->bands_number, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Mdct shaping_enc"); #endif processMdctShaping_fx(d_fx, int_scf_fx, int_scf_fx_exp, encoder->bands_offset, encoder->bands_number); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* end int_scf_fx_exp */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("BandwidthControl_enc"); #endif if (encoder->bandwidth < L_shr_pos(encoder->fs, 1)) @@ -364,10 +364,10 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ process_cutoff_bandwidth(d_fx, encoder->yLen, encoder->bw_ctrl_cutoff_bin); BW_cutoff_idx = s_min(BW_cutoff_idx, encoder->bw_index); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Tns_enc"); #endif /* currentScratch Size = 2 * MAX_LEN + 220 */ @@ -392,11 +392,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->tns_bits = tns_numfilters; move16(); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Est. Global Gain"); #endif /* currentScratch Size = 4 * MAX_LEN bytes */ @@ -430,12 +430,12 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ , encoder->hrmode, h_EncSetup->regBits, encoder->frame_dms #endif ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* begin q_d_fx16 */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Quant. 1"); #endif #ifdef ENABLE_HR_MODE @@ -448,11 +448,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->targetBitsAri, &h_EncSetup->mem_specBits, &nBits, encoder->fs_idx, &lastnz, codingdata, &lsbMode, -1); #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Adj. Global Gain"); #endif #ifdef ENABLE_HR_MODE @@ -466,11 +466,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processAdjustGlobalGain_fx(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, &gain_e, h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx); #endif /* ENABLE_HR_MODE */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Quant. 2"); #endif IF (sub(gainChange, 1) == 0) @@ -485,11 +485,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ 0); #endif /* ENABLE_HR_MODE */ } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Res. Cod."); #endif IF (lsbMode == 0) @@ -516,11 +516,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ numResBits = 0; move16(); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Noise fac"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ @@ -543,21 +543,21 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ fac_ns_idx = 7; move16(); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Entropy cod"); #endif processEncoderEntropy(bytes, &bp_side, &mask_side, h_EncSetup->targetBitsAri, h_EncSetup->targetBytes, encoder->yLen, encoder->BW_cutoff_bits, tns_numfilters, lsbMode, lastnz, tns_order, fac_ns_idx, quantizedGain, BW_cutoff_idx, ltpf_idx, L_scf_idx, bfi_ext, encoder->fs_idx); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Ari cod"); #endif processAriEncoder_fx(bytes, bp_side, mask_side, h_EncSetup->targetBitsAri, @@ -568,17 +568,17 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif tns_order, tns_numfilters, indexes, lastnz, codingdata, resBits, numResBits, lsbMode, h_EncSetup->enable_lpc_weighting, currentScratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Reorder Bitstream Enc"); #endif test(); IF (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("Reorder Ari dec"); #endif @@ -606,17 +606,17 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); /* Ari dec */ #endif processReorderBitstream_fx(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, currentScratch); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif /* end q_d_fx16 */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif @@ -638,14 +638,14 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 if (encoder->epmode && encoder->combined_channel_coding == 0) { output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("fec_enc"); #endif fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, encoder->channel_setup[ch]->n_pccw, scratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif @@ -663,14 +663,14 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 { input_size = output_size; output_size = (Word32)encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_start("fec_enc"); #endif fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw, scratch); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_end(); #endif } diff --git a/lib_lc3plus/plc_classify_fx.c b/lib_lc3plus/plc_classify_fx.c index d30b516a4..bbb01826a 100644 --- a/lib_lc3plus/plc_classify_fx.c +++ b/lib_lc3plus/plc_classify_fx.c @@ -45,7 +45,7 @@ static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_ { Word32 current_byte = 0; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PLC::array_insert_and_shift"); #endif @@ -58,7 +58,7 @@ static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_ current_byte = change_bit_at_position(current_byte, *bit_position, value); array[*byte_position] = current_byte; move16(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -73,7 +73,7 @@ static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Wor Word32 current_byte_tdc = 0, current_byte_ns = 0; Word16 counter_loc_tdc = 0, counter_loc_ns = 0, counter_tmp = 0; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PLC::array_calculate"); #endif @@ -104,7 +104,7 @@ static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Wor #ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER *counter_phecu = sub(sub(overall_counter, counter_loc_tdc), counter_loc_ns); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -130,7 +130,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost Word32 class; ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PLC::processPLCclassify_fx"); #endif @@ -246,7 +246,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost } Dyn_Mem_Deluxe_Out(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -268,7 +268,7 @@ Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, W Word16 *old_scf_q_mod_exp; Word16 *band_offsets_local; ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PLC::spectral_centroid_fx_lc"); #endif @@ -415,7 +415,7 @@ Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, W # endif Dyn_Mem_Deluxe_Out(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return sc; diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c index aaf6a9bd0..ca2a345f4 100644 --- a/lib_lc3plus/plc_phecu_fec_hq_fx.c +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -127,12 +127,12 @@ static Word16 plc_phEcu_nonpure_tone_ana_fx(const Word16* plocs, const Word16 static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 sinFactor, Word16 *re_out_ptr, Word16 *im_out_ptr) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::rotate_W16_fx"); #endif *re_out_ptr = msu_r(L_mult(re_in, cosFactor), im_in, sinFactor); /* 2 ops no move when inlined */ *im_out_ptr = mac_r(L_mult(re_in, sinFactor), im_in, cosFactor); /* 2 ops no move when inlined */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return; @@ -141,7 +141,7 @@ static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 s static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFactor, Word16 cosFactor) { Word16 scale_fx; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::valley_magnitude_adj_fx"); #endif @@ -158,7 +158,7 @@ static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFa *re_ptr = mult_r(scale_fx, shl_sat(*re_ptr, 1)); /* no moves , should be inlined */ *im_ptr = mult_r(scale_fx, shl_sat(*im_ptr, 1)); /* no moves , should be inlined */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return; @@ -188,7 +188,7 @@ Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::rand_phase_fx"); #endif @@ -201,7 +201,7 @@ Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return seed2; @@ -354,13 +354,13 @@ void trans_burst_ana_fx( if (time_offs == 0) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(1st)"); #endif } else { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(N)"); #endif } @@ -699,7 +699,7 @@ void trans_burst_ana_fx( L_acc = L_sub((INT32_MAX >> 1) + 1, L_mult0(alpha[k], alpha[k])); { - /* use lower complex(WMOPS_LC3PLUS/ROM) 2nd-order sqrt approximation */ + /* use lower complex(WMOPS/ROM) 2nd-order sqrt approximation */ Word32 L_man, L_acc2 = L_acc; Word16 tmp, expo_in, expo2, man_in, man; /* updated code using the 2nd order approximation routine */ @@ -797,7 +797,7 @@ void trans_burst_ana_fx( #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -826,7 +826,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::imax_fx"); #endif @@ -913,7 +913,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return posi; @@ -959,7 +959,7 @@ static Word16 imax_fx( /* o: The location, relative to the Word16 P_in_plocs; Word16 n_real_interp_tail; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::spec_ana_fx(1st)"); #endif #ifdef DYNMEM_COUNT @@ -1008,7 +1008,7 @@ static Word16 imax_fx( /* o: The location, relative to the rectLength = sub(Lprot, shl_pos(hamm_len2, 1)); /* The length of the rectangular portion of the Hamming-Rectangular window. */ { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::WhrAnaWin+fft"); #endif @@ -1016,7 +1016,7 @@ static Word16 imax_fx( /* o: The location, relative to the windowing_L(xfp, L_xfp, sp_ana_win, rectLength, hamm_len2); BASOP_rfftN(L_xfp, Lprot, &fft_scale, buffer_fft); } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); /* anawin+fft */ #endif @@ -1035,7 +1035,7 @@ static Word16 imax_fx( /* o: The location, relative to the basop_memset(xfp + stop_band_start, 0, (stop_band_length) * sizeof(Word16)); } - peak_range_1 = s_min(Lprot2p1, MAX_LPROT_RED / 2 + 1); /* limit preliminary only active for 48k to save WMOPS_LC3PLUS */ + peak_range_1 = s_min(Lprot2p1, MAX_LPROT_RED / 2 + 1); /* limit preliminary only active for 48k to save WMOPS */ basop_memmove(X_sav, xfp, (Lprot) * sizeof(Word16)); @@ -1052,7 +1052,7 @@ static Word16 imax_fx( /* o: The location, relative to the plc_phEcu_peak_locator_fx(xfp, peak_range_1, plocs, num_plocs, sens, Xmax, Xmin, MAX_LPROT_RED, buffer_fft); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::Peaks_refine"); #endif @@ -1173,7 +1173,7 @@ static Word16 imax_fx( /* o: The location, relative to the } } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); /* peaks refine */ #endif @@ -1217,7 +1217,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -1307,13 +1307,13 @@ static Word16 imax_fx( /* o: The location, relative to the if (time_offs == 0) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::subst_spec_fx(1st)"); #endif } else { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::subst_spec_fx(N)"); #endif } @@ -1669,7 +1669,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -1700,7 +1700,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::my_wtda_fx"); #endif @@ -1760,7 +1760,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return; @@ -1807,7 +1807,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::rec_wtda_fx"); #endif @@ -1849,7 +1849,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif @@ -1893,7 +1893,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::rec_frame_fx"); #endif @@ -1912,11 +1912,11 @@ static Word16 imax_fx( /* o: The location, relative to the fft_scale = -1; move16(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::IFFT_fx"); #endif BASOP_irfftN(L_x, Lprot, &fft_scale, buffer_fft); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif @@ -1955,7 +1955,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return; @@ -2036,13 +2036,13 @@ static Word16 imax_fx( /* o: The location, relative to the if (!prev_bfi) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(1st)"); #endif } else { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(N)"); #endif } @@ -2244,7 +2244,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -2256,7 +2256,7 @@ static Word16 imax_fx( /* o: The location, relative to the { Word32 acc; Word16 z; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::sqrt2ndOrder"); #endif @@ -2268,7 +2268,7 @@ static Word16 imax_fx( /* o: The location, relative to the z = mac_r(acc, z, x); /* in Q15 */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return z; @@ -2297,7 +2297,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::windowing_L"); #endif @@ -2335,7 +2335,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -2359,7 +2359,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::windowing_ola"); #endif @@ -2375,7 +2375,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -2460,7 +2460,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::sqrtMagnApprox_fx"); #endif @@ -2478,7 +2478,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return sum; @@ -2520,7 +2520,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::fft_spec2_sqrt_approx_fx"); #endif @@ -2547,7 +2547,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return; @@ -2584,7 +2584,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::imax2_jacobsen_mag_fx"); #endif @@ -2667,7 +2667,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return posi; /* Q15. The position either left or right relative to the index of the middle of the 3 given @@ -2692,7 +2692,7 @@ static Word16 imax_fx( /* o: The location, relative to the #define FHG_FFT_UPSHIFT 2 -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::intlvW32_2_flippedW16"); #endif #ifdef DYNMEM_COUNT @@ -2750,7 +2750,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -2766,7 +2766,7 @@ static Word16 imax_fx( /* o: The location, relative to the Counter numPairsLocal; Word32 *pX_L; Word16 *pX_re, *pX_im; -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::flippedW16_2_intlvW32"); #endif #ifdef DYNMEM_COUNT @@ -2802,7 +2802,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -2818,7 +2818,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_In("get_sin_cosQ10", sizeof(struct { Word16 sign_val, idx, idx2, idx3; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::get_sin_cosQ10opt"); #endif @@ -2871,7 +2871,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -2902,7 +2902,7 @@ static Word16 imax_fx( /* o: The location, relative to the })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhEcu::nonpure_tone_ana_fx"); #endif @@ -3144,7 +3144,7 @@ static Word16 imax_fx( /* o: The location, relative to the } /* bands available*/ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif diff --git a/lib_lc3plus/plc_phecu_peak_locator_fx.c b/lib_lc3plus/plc_phecu_peak_locator_fx.c index 78a6ec281..531ee8f6f 100644 --- a/lib_lc3plus/plc_phecu_peak_locator_fx.c +++ b/lib_lc3plus/plc_phecu_peak_locator_fx.c @@ -65,7 +65,7 @@ void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 Word16 *fsc_idx; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::peak_locator_fx(1st)"); #endif sc_idx = (Word16 *)scratchAlign(scratchBuffer, 0); /* ByteSize = 2 * (1+ inp_len+1) */ @@ -378,7 +378,7 @@ void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } diff --git a/lib_lc3plus/plc_phecu_setf0hz_fx.c b/lib_lc3plus/plc_phecu_setf0hz_fx.c index 264aa19c3..6fffe632c 100644 --- a/lib_lc3plus/plc_phecu_setf0hz_fx.c +++ b/lib_lc3plus/plc_phecu_setf0hz_fx.c @@ -32,7 +32,7 @@ plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::plc_phEcuSetF0Hz_fx"); #endif @@ -50,7 +50,7 @@ plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif diff --git a/lib_lc3plus/plc_phecu_tools_fx.c b/lib_lc3plus/plc_phecu_tools_fx.c index 32eff68f2..9574499c9 100644 --- a/lib_lc3plus/plc_phecu_tools_fx.c +++ b/lib_lc3plus/plc_phecu_tools_fx.c @@ -167,7 +167,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::winEnCalc"); #endif @@ -235,7 +235,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ L_tot = L_shl(L_tot,tmp); *exp = sub(*exp, tmp); move16(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT diff --git a/lib_lc3plus/plc_update_aft_imdct_fx.c b/lib_lc3plus/plc_update_aft_imdct_fx.c index 6be74bb61..2bdab6eaf 100644 --- a/lib_lc3plus/plc_update_aft_imdct_fx.c +++ b/lib_lc3plus/plc_update_aft_imdct_fx.c @@ -37,7 +37,7 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("processPLCUpdateAfterIMDCT "); #endif @@ -160,7 +160,7 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea *prev_prev_bfi = *prev_bfi; move16(); *prev_bfi = bfi; move16(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif @@ -254,7 +254,7 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx Word16 exp_out; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::UpdateXfp_w_E_hist_fx"); #endif @@ -331,7 +331,7 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx } } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT diff --git a/lib_lc3plus/plc_update_fx.c b/lib_lc3plus/plc_update_fx.c index b219aa674..305140ce7 100644 --- a/lib_lc3plus/plc_update_fx.c +++ b/lib_lc3plus/plc_update_fx.c @@ -85,7 +85,7 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W Word16 fs_idx,local_prev_bfi; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("PhECU::GF::process_plc_spec_2_shape_fx"); #endif @@ -210,7 +210,7 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT diff --git a/lib_lc3plus/plc_xcorr_fx.c b/lib_lc3plus/plc_xcorr_fx.c index 92fc0fc16..1a4782c32 100644 --- a/lib_lc3plus/plc_xcorr_fx.c +++ b/lib_lc3plus/plc_xcorr_fx.c @@ -52,7 +52,7 @@ Word16 plc_norm_corr_blocks_fx( /* o: norm_corr range [-1 })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("plc_norm_corr_blocks_fx"); #endif @@ -166,7 +166,7 @@ Word16 plc_norm_corr_blocks_fx( /* o: norm_corr range [-1 #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return norm_corr; @@ -192,7 +192,7 @@ Word16 plc_xcorr_lc_fx( /* o: quantized output xcorr in Q })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("plc_xcorr_lc_fx"); #endif @@ -241,7 +241,7 @@ Word16 plc_xcorr_lc_fx( /* o: quantized output xcorr in Q #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif return norm_xcorr_est_q; diff --git a/lib_lc3plus/pvq_enc_fx.c b/lib_lc3plus/pvq_enc_fx.c index 3f073eb57..9c164dda5 100644 --- a/lib_lc3plus/pvq_enc_fx.c +++ b/lib_lc3plus/pvq_enc_fx.c @@ -144,7 +144,7 @@ void pvq_enc_search_fx( Word16 pulses_far, pulses, pulsesA, pulsesB; ); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("pvq_enc_search_fx"); #endif @@ -362,7 +362,7 @@ void pvq_enc_search_fx( } Dyn_Mem_Deluxe_Out(); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } diff --git a/lib_lc3plus/pvq_index_fx.c b/lib_lc3plus/pvq_index_fx.c index 200862977..c7d63c840 100644 --- a/lib_lc3plus/pvq_index_fx.c +++ b/lib_lc3plus/pvq_index_fx.c @@ -318,7 +318,7 @@ void mpvq_deindex_fx( /* o : void #ifdef DYNMEM_COUNT Dyn_Mem_In("mpvq_deindex_fx", sizeof(struct { Word16 leading_sign; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("mpvq_deindex_fx"); #endif @@ -337,7 +337,7 @@ void mpvq_deindex_fx( /* o : void #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif } @@ -488,7 +488,7 @@ PvqEntry_fx mpvq_index_fx( /* o : leading_sign_index, i UWord32 lead_sign_ind; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("mpvq_index_fx"); #endif @@ -504,7 +504,7 @@ PvqEntry_fx mpvq_index_fx( /* o : leading_sign_index, i #ifdef DYNMEM_COUNT Dyn_Mem_Out(); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif diff --git a/lib_lc3plus/sns_quantize_scf_fx.c b/lib_lc3plus/sns_quantize_scf_fx.c index fe8b38344..991381285 100644 --- a/lib_lc3plus/sns_quantize_scf_fx.c +++ b/lib_lc3plus/sns_quantize_scf_fx.c @@ -36,7 +36,7 @@ static Word16 stage1_base( /* o : idx Word32 L_min_mse, L_mse; })); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("stage1_base"); #endif @@ -89,7 +89,7 @@ static Word16 stage1_base( /* o : idx } ASSERT(idx >= 0 && idx < R); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT @@ -183,7 +183,7 @@ static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, Word16 *st1_idx0Ptr, Word16 *st1_idx1Ptr) { -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("processQuantize_stage1ScfEncStage1_fx"); #endif @@ -201,7 +201,7 @@ static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, *st1_idx1Ptr, st1_vector); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif @@ -306,7 +306,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( shape_far = (Word16 *)scratchAlign(pulses_far, sizeof(*pulses_far) * M); /* Size = 2 * M */ #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("pvq_enc_find_best_submode_pre_post_fx"); #endif @@ -414,7 +414,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( *sub_mode_ptr = extract_l(L_section); move16(); /* 0,1,2,3 */ -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT @@ -505,7 +505,7 @@ static void processQuantize_stage2ScfEncStage2_fx( proc_target_lp = (Word16 *)buffer_pvq_enc_find_best_submode_pre_post_fx; /* size = 2*M */ #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("processQuantize_stage2ScfEncStage2_fx"); #endif @@ -631,7 +631,7 @@ static void processQuantize_stage2ScfEncStage2_fx( L_prm_idx[2] = L_deposit_l(enc_PVQ_OA.lead_sign_ind); /* LS shape single bit */ } -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif #ifdef DYNMEM_COUNT @@ -676,7 +676,7 @@ static Word16 scfdec_stage2_fx( /* o: ber flag */ ); #endif -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_start("scfdec_stage2_fx"); #endif @@ -740,7 +740,7 @@ static Word16 scfdec_stage2_fx( /* o: ber flag */ /* scaling aligend with encoder search */ pvq_dec_scale_vec_fx(dec_adj_glob_vec, gValQ13, st2_vector); -#ifdef WMOPS_LC3PLUS +#ifdef WMOPS BASOP_sub_sub_end(); #endif Dyn_Mem_Deluxe_Out(); -- GitLab From 8e5805db34d06087c111e94bd73c445ba9d4609c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 13:36:09 +0100 Subject: [PATCH 157/329] change #if WMOPS to #ifdef WMOPS --- lib_lc3plus/basop_util_lc3plus.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h index 5f4f5c56b..3ff6d8d06 100644 --- a/lib_lc3plus/basop_util_lc3plus.h +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -316,14 +316,14 @@ void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word void BASOP_rfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); void BASOP_irfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); -#if WMOPS +#ifdef WMOPS extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #endif static __inline void basop_memcpy(void *dst, const void *src, size_t n) { -#if WMOPS +#ifdef WMOPS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif /* check for overlapping memory */ @@ -333,7 +333,7 @@ static __inline void basop_memcpy(void *dst, const void *src, size_t n) static __inline void basop_memmove(void *dst, const void *src, size_t n) { -#if WMOPS +#ifdef WMOPS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif memmove(dst, src, n); @@ -341,7 +341,7 @@ static __inline void basop_memmove(void *dst, const void *src, size_t n) static __inline void basop_memset(void *dst, int val, size_t n) { -#if WMOPS +#ifdef WMOPS multiCounter[currCounter].move16 += (UWord32)n / 2; #endif memset(dst, val, n); -- GitLab From ad9e2d665f986dce90e10a35cada7f2e3744d89b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 13:37:18 +0100 Subject: [PATCH 158/329] rename BASOP_sub(_sub)_start() to push_wmops() --- lib_lc3plus/dec_lc3.c | 48 ++++++++++----------- lib_lc3plus/enc_lc3.c | 56 ++++++++++++------------- lib_lc3plus/plc_classify_fx.c | 8 ++-- lib_lc3plus/plc_phecu_fec_hq_fx.c | 54 ++++++++++++------------ lib_lc3plus/plc_phecu_peak_locator_fx.c | 2 +- lib_lc3plus/plc_phecu_setf0hz_fx.c | 2 +- lib_lc3plus/plc_phecu_tools_fx.c | 2 +- lib_lc3plus/plc_update_aft_imdct_fx.c | 4 +- lib_lc3plus/plc_update_fx.c | 2 +- lib_lc3plus/plc_xcorr_fx.c | 4 +- lib_lc3plus/pvq_enc_fx.c | 2 +- lib_lc3plus/pvq_index_fx.c | 4 +- lib_lc3plus/sns_quantize_scf_fx.c | 10 ++--- 13 files changed, 99 insertions(+), 99 deletions(-) diff --git a/lib_lc3plus/dec_lc3.c b/lib_lc3plus/dec_lc3.c index 40818106e..1f302608a 100644 --- a/lib_lc3plus/dec_lc3.c +++ b/lib_lc3plus/dec_lc3.c @@ -149,7 +149,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Decoder"); + push_wmops("Decoder"); #endif #ifdef ENABLE_RFRAME @@ -165,18 +165,18 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s if (bfi != 1) { #ifdef WMOPS - BASOP_sub_sub_start("Dec(bfi=0)"); + push_wmops("Dec(bfi=0)"); #endif } else { #ifdef WMOPS - BASOP_sub_sub_start("Dec(bfi=1)"); + push_wmops("Dec(bfi=1)"); #endif } #ifdef WMOPS - BASOP_sub_start("Entropy dec"); + push_wmops("Entropy dec"); #endif IF (sub(bfi, 1) != 0) { @@ -191,7 +191,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Ari dec"); + push_wmops("Ari dec"); #endif IF (sub(bfi, 1) != 0) { @@ -248,7 +248,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("SnsQuantScfDec"); + push_wmops("SnsQuantScfDec"); #endif IF (sub(bfi, 1) != 0) { @@ -265,7 +265,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("PLC::ComputeStabFac"); + push_wmops("PLC::ComputeStabFac"); #endif if (h_DecSetup->plcAd) { @@ -277,7 +277,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Partial Concealment"); + push_wmops("Partial Concealment"); #endif IF (sub(bfi, 1) != 0) { @@ -302,7 +302,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s IF (sub(bfi, 1) != 0) { #ifdef WMOPS - BASOP_sub_start("Residual dec"); + push_wmops("Residual dec"); #endif processResidualDecoding_fx(q_d_fx, q_fx_exp, decoder->yLen, resBitBuf, fill_bits #ifdef ENABLE_HR_MODE @@ -314,7 +314,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Noisefill"); + push_wmops("Noisefill"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ IF (zero_frame == 0) @@ -331,7 +331,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("applyGlobalGain"); + push_wmops("applyGlobalGain"); #endif processApplyGlobalGain_fx(q_d_fx, &q_fx_exp, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); #ifdef WMOPS @@ -339,7 +339,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Tns_dec"); + push_wmops("Tns_dec"); #endif /* currentScratch Size = 48 bytes */ processTnsDecoder_fx(indexes, q_d_fx, decoder->yLen, tns_order, &q_fx_exp, BW_cutoff_idx, decoder->frame_dms, @@ -354,7 +354,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #ifdef ENABLE_HR_MODE #ifdef WMOPS - BASOP_sub_start("SnsInterpScfDec"); + push_wmops("SnsInterpScfDec"); #endif processSnsInterpolateScf_fx(scf_q_ip, int_scf_fx_ip, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); @@ -363,7 +363,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Mdct shaping_dec"); + push_wmops("Mdct shaping_dec"); #endif processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); @@ -373,7 +373,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #else #ifdef WMOPS - BASOP_sub_start("SnsInterpScfDec"); + push_wmops("SnsInterpScfDec"); #endif /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); @@ -382,7 +382,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Mdct shaping_dec"); + push_wmops("Mdct shaping_dec"); #endif processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); processMdctShaping_fx(q_d_fx, int_scf_fx, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); @@ -407,7 +407,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("PLC::Main"); + push_wmops("PLC::Main"); #endif /* currentScratch Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ processPLCmain_fx(decoder->plcMeth, &h_DecSetup->concealMethod, &h_DecSetup->nbLostFramesInRow, bfi, @@ -447,7 +447,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("PLC/PC::DampingScrambling"); + push_wmops("PLC/PC::DampingScrambling"); #endif if (h_DecSetup->plcAd) { @@ -467,7 +467,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Imdct"); + push_wmops("Imdct"); #endif /* currentScratch Size = 4 * MAX_LEN */ ProcessingIMDCT(q_d_fx, &q_fx_exp, decoder->W_fx, h_DecSetup->stDec_ola_mem_fx, &h_DecSetup->stDec_ola_mem_fx_exp, @@ -504,7 +504,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("PLC::Update"); + push_wmops("PLC::Update"); #endif processPLCupdate_fx(h_DecSetup->plcAd, x_fx, q_fx_exp, h_DecSetup->concealMethod, decoder->frame_length, @@ -519,7 +519,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("LtpfDec"); + push_wmops("LtpfDec"); #endif /* currentScratch Size = 0.5 * MAX_LEN + 20 bytes */ process_ltpf_decoder_fx(&q_fx_exp, decoder->frame_length, decoder->ltpf_mem_x_len, decoder->fs_idx, @@ -548,7 +548,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif #ifdef WMOPS - BASOP_sub_start("Output scaling"); + push_wmops("Output scaling"); #endif { scale = sub(sub(31 + 16, bits_per_sample), q_fx_exp); @@ -624,7 +624,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo fec_num_bytes = num_bytes; #ifdef WMOPS - BASOP_sub_start("fec_dec"); + push_wmops("fec_dec"); #endif decoder->error_report = @@ -669,7 +669,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); #ifdef WMOPS - BASOP_sub_start("fec_dec"); + push_wmops("fec_dec"); #endif channel_bfi = bfi; diff --git a/lib_lc3plus/enc_lc3.c b/lib_lc3plus/enc_lc3.c index 30ff9971b..46d011d4f 100644 --- a/lib_lc3plus/enc_lc3.c +++ b/lib_lc3plus/enc_lc3.c @@ -62,7 +62,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif /* CR8_F_ADAPT_MDCT_DCT_PRECISION */ #ifdef WMOPS - BASOP_sub_start("Encoder"); + push_wmops("Encoder"); #endif /* BUFFER INITIALISATION. Some buffers may overlap since they are not used in the whole encoding process */ @@ -135,7 +135,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ IF (sub(bits_per_sample, 24) == 0) { #ifdef WMOPS - BASOP_sub_start("Scale_signal24"); + push_wmops("Scale_signal24"); #endif scale_signal24_fx(s_in, s_in_scaled, &h_EncSetup->x_exp, h_EncSetup->stEnc_mdct_mem, encoder->stEnc_mdct_mem_len, h_EncSetup->r12k8_mem_in, encoder->r12k8_mem_in_len, @@ -162,7 +162,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ } #ifdef WMOPS - BASOP_sub_start("Mdct"); + push_wmops("Mdct"); #endif /* currentScratch Size = 4 * MAX_LEN */ @@ -180,7 +180,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* begin s_12k8 */ #ifdef WMOPS - BASOP_sub_start("Resamp12k8"); + push_wmops("Resamp12k8"); #endif /* currentScratch Size = 2.25 * MAX_LEN bytes */ #ifdef ENABLE_HR_MODE @@ -203,7 +203,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Olpa"); + push_wmops("Olpa"); #endif /* currentScratch Size = 392 bytes */ process_olpa_fx(&h_EncSetup->olpa_mem_s6k4_exp, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, &pitch, @@ -217,7 +217,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("LtpfEnc"); + push_wmops("LtpfEnc"); #endif /* currentScratch Size = 512 bytes */ process_ltpf_coder_fx(<pf_bits, pitch, h_EncSetup->ltpf_enable, &h_EncSetup->ltpf_mem_in_exp, @@ -235,7 +235,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* end s_12k8 */ #ifdef WMOPS - BASOP_sub_start("AttackDetector"); + push_wmops("AttackDetector"); #endif /* currentScratch Size = ??? bytes */ #ifdef ENABLE_HR_MODE @@ -249,7 +249,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* begin ener_fx */ #ifdef WMOPS - BASOP_sub_start("PerBandEnergy"); + push_wmops("PerBandEnergy"); #endif /* currentScratch Size = 160 bytes */ processPerBandEnergy_fx(ener_fx, &ener_fx_exp, d_fx, d_fx_exp, encoder->bands_offset, encoder->fs_idx, @@ -263,7 +263,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Near Nyquist Detector"); + push_wmops("Near Nyquist Detector"); #endif /* Near Nyquist Detector */ processNearNyquistdetector_fx(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, @@ -287,7 +287,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ BASOP_sub_end(); #endif #ifdef WMOPS - BASOP_sub_start("BW Cutoff-Detection"); + push_wmops("BW Cutoff-Detection"); #endif IF (h_EncSetup->lfe == 0) { @@ -316,7 +316,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("SnsCompScf"); + push_wmops("SnsCompScf"); #endif @@ -329,7 +329,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("SnsQuantScfEnc"); + push_wmops("SnsQuantScfEnc"); #endif /* currentScratch Size = 500 bytes */ @@ -339,7 +339,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("SnsInterpScfEnc"); + push_wmops("SnsInterpScfEnc"); #endif /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 1, encoder->bands_number, currentScratch); @@ -348,7 +348,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Mdct shaping_enc"); + push_wmops("Mdct shaping_enc"); #endif processMdctShaping_fx(d_fx, int_scf_fx, int_scf_fx_exp, encoder->bands_offset, encoder->bands_number); @@ -357,7 +357,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif /* end int_scf_fx_exp */ #ifdef WMOPS - BASOP_sub_start("BandwidthControl_enc"); + push_wmops("BandwidthControl_enc"); #endif if (encoder->bandwidth < L_shr_pos(encoder->fs, 1)) { @@ -368,7 +368,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ BASOP_sub_end(); #endif #ifdef WMOPS - BASOP_sub_start("Tns_enc"); + push_wmops("Tns_enc"); #endif /* currentScratch Size = 2 * MAX_LEN + 220 */ @@ -397,7 +397,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Est. Global Gain"); + push_wmops("Est. Global Gain"); #endif /* currentScratch Size = 4 * MAX_LEN bytes */ h_EncSetup->targetBitsQuant = sub(h_EncSetup->targetBitsInit, add(h_EncSetup->tns_bits, ltpf_bits)); @@ -436,7 +436,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* begin q_d_fx16 */ #ifdef WMOPS - BASOP_sub_start("Quant. 1"); + push_wmops("Quant. 1"); #endif #ifdef ENABLE_HR_MODE processQuantizeSpec_fx(d_fx, d_fx_exp, gain32, gain_e, q_d_fx24, encoder->yLen, h_EncSetup->targetBitsQuant, @@ -453,7 +453,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Adj. Global Gain"); + push_wmops("Adj. Global Gain"); #endif #ifdef ENABLE_HR_MODE //gain32 = L_shl_pos((Word32)gain, 16); @@ -471,7 +471,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Quant. 2"); + push_wmops("Quant. 2"); #endif IF (sub(gainChange, 1) == 0) { @@ -490,7 +490,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Res. Cod."); + push_wmops("Res. Cod."); #endif IF (lsbMode == 0) { @@ -521,7 +521,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Noise fac"); + push_wmops("Noise fac"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ IF (h_EncSetup->lfe == 0) @@ -548,7 +548,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Entropy cod"); + push_wmops("Entropy cod"); #endif processEncoderEntropy(bytes, &bp_side, &mask_side, h_EncSetup->targetBitsAri, h_EncSetup->targetBytes, encoder->yLen, encoder->BW_cutoff_bits, tns_numfilters, lsbMode, lastnz, tns_order, @@ -558,7 +558,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Ari cod"); + push_wmops("Ari cod"); #endif processAriEncoder_fx(bytes, bp_side, mask_side, h_EncSetup->targetBitsAri, #ifdef ENABLE_HR_MODE @@ -573,13 +573,13 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_start("Reorder Bitstream Enc"); + push_wmops("Reorder Bitstream Enc"); #endif test(); IF (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) { #ifdef WMOPS - BASOP_sub_start("Reorder Ari dec"); + push_wmops("Reorder Ari dec"); #endif #ifdef ENABLE_HR_MODE @@ -639,7 +639,7 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 { output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); #ifdef WMOPS - BASOP_sub_start("fec_enc"); + push_wmops("fec_enc"); #endif fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, @@ -664,7 +664,7 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 input_size = output_size; output_size = (Word32)encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); #ifdef WMOPS - BASOP_sub_start("fec_enc"); + push_wmops("fec_enc"); #endif fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw, diff --git a/lib_lc3plus/plc_classify_fx.c b/lib_lc3plus/plc_classify_fx.c index bbb01826a..d902df10b 100644 --- a/lib_lc3plus/plc_classify_fx.c +++ b/lib_lc3plus/plc_classify_fx.c @@ -46,7 +46,7 @@ static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_ Word32 current_byte = 0; #ifdef WMOPS - BASOP_sub_sub_start("PLC::array_insert_and_shift"); + push_wmops("PLC::array_insert_and_shift"); #endif IF( overall_counter != NULL) @@ -74,7 +74,7 @@ static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Wor Word16 counter_loc_tdc = 0, counter_loc_ns = 0, counter_tmp = 0; #ifdef WMOPS - BASOP_sub_sub_start("PLC::array_calculate"); + push_wmops("PLC::array_calculate"); #endif for (i = length - 1; i >= 0; i--) @@ -131,7 +131,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost ); #ifdef WMOPS - BASOP_sub_sub_start("PLC::processPLCclassify_fx"); + push_wmops("PLC::processPLCclassify_fx"); #endif UNUSED(yLen); @@ -269,7 +269,7 @@ Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, W Word16 *band_offsets_local; ); #ifdef WMOPS - BASOP_sub_sub_start("PLC::spectral_centroid_fx_lc"); + push_wmops("PLC::spectral_centroid_fx_lc"); #endif #ifdef ENABLE_HR_MODE diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c index ca2a345f4..a2e65aa42 100644 --- a/lib_lc3plus/plc_phecu_fec_hq_fx.c +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -128,7 +128,7 @@ static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 s Word16 *im_out_ptr) { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::rotate_W16_fx"); + push_wmops("PhECU::rotate_W16_fx"); #endif *re_out_ptr = msu_r(L_mult(re_in, cosFactor), im_in, sinFactor); /* 2 ops no move when inlined */ *im_out_ptr = mac_r(L_mult(re_in, sinFactor), im_in, cosFactor); /* 2 ops no move when inlined */ @@ -142,7 +142,7 @@ static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFa { Word16 scale_fx; #ifdef WMOPS - BASOP_sub_sub_start("PhECU::valley_magnitude_adj_fx"); + push_wmops("PhECU::valley_magnitude_adj_fx"); #endif /* y = 0.5*((2*rand(1,10000) + 1*cos(2*pi*x)) - 1 */ /* y will be in -1 to 1 range */ @@ -189,7 +189,7 @@ Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::rand_phase_fx"); + push_wmops("PhECU::rand_phase_fx"); #endif seed2 = extract_l(L_mac0(13849, seed, 31821)); @@ -355,13 +355,13 @@ void trans_burst_ana_fx( if (time_offs == 0) { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(1st)"); + push_wmops("PhECU::trans_burst_ana_fx(1st)"); #endif } else { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::trans_burst_ana_fx(N)"); + push_wmops("PhECU::trans_burst_ana_fx(N)"); #endif } @@ -827,7 +827,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::imax_fx"); + push_wmops("PhECU::imax_fx"); #endif /* Seek the extremum of the parabola P(x) defined by 3 consecutive points @@ -960,7 +960,7 @@ static Word16 imax_fx( /* o: The location, relative to the Word16 n_real_interp_tail; #ifdef WMOPS - BASOP_sub_sub_start("PhECU::spec_ana_fx(1st)"); + push_wmops("PhECU::spec_ana_fx(1st)"); #endif #ifdef DYNMEM_COUNT Dyn_Mem_In("spec_ana_fx", sizeof(struct { @@ -1009,7 +1009,7 @@ static Word16 imax_fx( /* o: The location, relative to the /* The length of the rectangular portion of the Hamming-Rectangular window. */ { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::WhrAnaWin+fft"); + push_wmops("PhECU::WhrAnaWin+fft"); #endif /* Apply hamming-rect window */ @@ -1053,7 +1053,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef WMOPS - BASOP_sub_sub_start("PhECU::Peaks_refine"); + push_wmops("PhECU::Peaks_refine"); #endif /* Refine peaks */ @@ -1308,13 +1308,13 @@ static Word16 imax_fx( /* o: The location, relative to the if (time_offs == 0) { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::subst_spec_fx(1st)"); + push_wmops("PhECU::subst_spec_fx(1st)"); #endif } else { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::subst_spec_fx(N)"); + push_wmops("PhECU::subst_spec_fx(N)"); #endif } @@ -1701,7 +1701,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::my_wtda_fx"); + push_wmops("PhECU::my_wtda_fx"); #endif L_w_audio = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * 2 * MAX_L_FRAME */ @@ -1808,7 +1808,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::rec_wtda_fx"); + push_wmops("PhECU::rec_wtda_fx"); #endif rec_buf = scratchAlign(scratchBuffer, 0); /* Size = 2 * 2 * MAX_L_FRAME */ @@ -1894,7 +1894,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::rec_frame_fx"); + push_wmops("PhECU::rec_frame_fx"); #endif L_x = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LPROT */ @@ -1913,7 +1913,7 @@ static Word16 imax_fx( /* o: The location, relative to the fft_scale = -1; move16(); #ifdef WMOPS - BASOP_sub_sub_start("PhECU::IFFT_fx"); + push_wmops("PhECU::IFFT_fx"); #endif BASOP_irfftN(L_x, Lprot, &fft_scale, buffer_fft); #ifdef WMOPS @@ -2037,13 +2037,13 @@ static Word16 imax_fx( /* o: The location, relative to the if (!prev_bfi) { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(1st)"); + push_wmops("PhECU::hq_phase_ecu_fx(1st)"); #endif } else { #ifdef WMOPS - BASOP_sub_sub_start("PhECU::hq_phase_ecu_fx(N)"); + push_wmops("PhECU::hq_phase_ecu_fx(N)"); #endif } @@ -2257,7 +2257,7 @@ static Word16 imax_fx( /* o: The location, relative to the Word32 acc; Word16 z; #ifdef WMOPS - BASOP_sub_sub_start("PhECU::sqrt2ndOrder"); + push_wmops("PhECU::sqrt2ndOrder"); #endif ASSERT(x >= 16384); @@ -2298,7 +2298,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::windowing_L"); + push_wmops("PhECU::windowing_L"); #endif pX = x; @@ -2360,7 +2360,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::windowing_ola"); + push_wmops("PhECU::windowing_ola"); #endif pX = x; @@ -2461,7 +2461,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::sqrtMagnApprox_fx"); + push_wmops("PhECU::sqrtMagnApprox_fx"); #endif /* Get values and move pointers */ @@ -2521,7 +2521,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::fft_spec2_sqrt_approx_fx"); + push_wmops("PhECU::fft_spec2_sqrt_approx_fx"); #endif /* Magnitude at 0. only real component */ @@ -2585,7 +2585,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::imax2_jacobsen_mag_fx"); + push_wmops("PhECU::imax2_jacobsen_mag_fx"); #endif /* Jacobsen estimates peak offset relative y_0 using @@ -2693,7 +2693,7 @@ static Word16 imax_fx( /* o: The location, relative to the #define FHG_FFT_UPSHIFT 2 #ifdef WMOPS - BASOP_sub_sub_start("PhECU::intlvW32_2_flippedW16"); + push_wmops("PhECU::intlvW32_2_flippedW16"); #endif #ifdef DYNMEM_COUNT Dyn_Mem_In("intlvW32_2_flippedW16", sizeof(struct { @@ -2767,7 +2767,7 @@ static Word16 imax_fx( /* o: The location, relative to the Word32 *pX_L; Word16 *pX_re, *pX_im; #ifdef WMOPS - BASOP_sub_sub_start("PhECU::flippedW16_2_intlvW32"); + push_wmops("PhECU::flippedW16_2_intlvW32"); #endif #ifdef DYNMEM_COUNT Dyn_Mem_In("flippedW16_2_intlvW32", sizeof(struct { @@ -2819,7 +2819,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::get_sin_cosQ10opt"); + push_wmops("PhECU::get_sin_cosQ10opt"); #endif /* sin table has a range up to pi/2 (256+1)=257 coeffs*/ @@ -2903,7 +2903,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif #ifdef WMOPS - BASOP_sub_sub_start("PhEcu::nonpure_tone_ana_fx"); + push_wmops("PhEcu::nonpure_tone_ana_fx"); #endif Word16 nonpure_tone_detect; /* output variable */ diff --git a/lib_lc3plus/plc_phecu_peak_locator_fx.c b/lib_lc3plus/plc_phecu_peak_locator_fx.c index 531ee8f6f..0670aac38 100644 --- a/lib_lc3plus/plc_phecu_peak_locator_fx.c +++ b/lib_lc3plus/plc_phecu_peak_locator_fx.c @@ -66,7 +66,7 @@ void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 })); #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::peak_locator_fx(1st)"); + push_wmops("PhECU::peak_locator_fx(1st)"); #endif sc_idx = (Word16 *)scratchAlign(scratchBuffer, 0); /* ByteSize = 2 * (1+ inp_len+1) */ cand_pairs_buf = (Word16 *)scratchAlign(sc_idx, sizeof(*sc_idx) * (1+inp_len+1)); /* ByteSize = 2 * (1+ 1+ inp_len+1 ) */ diff --git a/lib_lc3plus/plc_phecu_setf0hz_fx.c b/lib_lc3plus/plc_phecu_setf0hz_fx.c index 6fffe632c..ecfa6e108 100644 --- a/lib_lc3plus/plc_phecu_setf0hz_fx.c +++ b/lib_lc3plus/plc_phecu_setf0hz_fx.c @@ -33,7 +33,7 @@ plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::plc_phEcuSetF0Hz_fx"); + push_wmops("PhECU::plc_phEcuSetF0Hz_fx"); #endif result = 0; move16(); diff --git a/lib_lc3plus/plc_phecu_tools_fx.c b/lib_lc3plus/plc_phecu_tools_fx.c index 9574499c9..40c25bdb0 100644 --- a/lib_lc3plus/plc_phecu_tools_fx.c +++ b/lib_lc3plus/plc_phecu_tools_fx.c @@ -168,7 +168,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ #ifdef WMOPS - BASOP_sub_sub_start("PhECU::winEnCalc"); + push_wmops("PhECU::winEnCalc"); #endif L_tot = INT32_MAX; move32(); /*acc is on negative side , but as all accumulation is positive, we make use of one extra bit */ diff --git a/lib_lc3plus/plc_update_aft_imdct_fx.c b/lib_lc3plus/plc_update_aft_imdct_fx.c index 2bdab6eaf..9a0c60b28 100644 --- a/lib_lc3plus/plc_update_aft_imdct_fx.c +++ b/lib_lc3plus/plc_update_aft_imdct_fx.c @@ -38,7 +38,7 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea #ifdef WMOPS - BASOP_sub_sub_start("processPLCUpdateAfterIMDCT "); + push_wmops("processPLCUpdateAfterIMDCT "); #endif @@ -255,7 +255,7 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx })); #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::UpdateXfp_w_E_hist_fx"); + push_wmops("PhECU::UpdateXfp_w_E_hist_fx"); #endif IF (sub(bfi,1) != 0) diff --git a/lib_lc3plus/plc_update_fx.c b/lib_lc3plus/plc_update_fx.c index 305140ce7..85e20020f 100644 --- a/lib_lc3plus/plc_update_fx.c +++ b/lib_lc3plus/plc_update_fx.c @@ -86,7 +86,7 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W })); #endif #ifdef WMOPS - BASOP_sub_sub_start("PhECU::GF::process_plc_spec_2_shape_fx"); + push_wmops("PhECU::GF::process_plc_spec_2_shape_fx"); #endif IF(sub(bfi, 1) != 0) diff --git a/lib_lc3plus/plc_xcorr_fx.c b/lib_lc3plus/plc_xcorr_fx.c index 1a4782c32..882bfced4 100644 --- a/lib_lc3plus/plc_xcorr_fx.c +++ b/lib_lc3plus/plc_xcorr_fx.c @@ -53,7 +53,7 @@ Word16 plc_norm_corr_blocks_fx( /* o: norm_corr range [-1 #endif #ifdef WMOPS - BASOP_sub_sub_start("plc_norm_corr_blocks_fx"); + push_wmops("plc_norm_corr_blocks_fx"); #endif /* Calculate normalized correlation with added shift and block interleaving possibility */ @@ -193,7 +193,7 @@ Word16 plc_xcorr_lc_fx( /* o: quantized output xcorr in Q #endif #ifdef WMOPS - BASOP_sub_sub_start("plc_xcorr_lc_fx"); + push_wmops("plc_xcorr_lc_fx"); #endif norm_xcorr_est_q = 0; move16(); diff --git a/lib_lc3plus/pvq_enc_fx.c b/lib_lc3plus/pvq_enc_fx.c index 9c164dda5..4f6a0aac3 100644 --- a/lib_lc3plus/pvq_enc_fx.c +++ b/lib_lc3plus/pvq_enc_fx.c @@ -145,7 +145,7 @@ void pvq_enc_search_fx( ); #ifdef WMOPS - BASOP_sub_sub_start("pvq_enc_search_fx"); + push_wmops("pvq_enc_search_fx"); #endif pulses_far = pulses_fin[0]; move16(); diff --git a/lib_lc3plus/pvq_index_fx.c b/lib_lc3plus/pvq_index_fx.c index c7d63c840..0a4bc6694 100644 --- a/lib_lc3plus/pvq_index_fx.c +++ b/lib_lc3plus/pvq_index_fx.c @@ -319,7 +319,7 @@ void mpvq_deindex_fx( /* o : void Dyn_Mem_In("mpvq_deindex_fx", sizeof(struct { Word16 leading_sign; })); #endif #ifdef WMOPS - BASOP_sub_sub_start("mpvq_deindex_fx"); + push_wmops("mpvq_deindex_fx"); #endif basop_memset(vec_out, 0, (entry->dim) * sizeof(Word16)); @@ -489,7 +489,7 @@ PvqEntry_fx mpvq_index_fx( /* o : leading_sign_index, i })); #endif #ifdef WMOPS - BASOP_sub_sub_start("mpvq_index_fx"); + push_wmops("mpvq_index_fx"); #endif ASSERT(k_val_local <= KMAX_FX); diff --git a/lib_lc3plus/sns_quantize_scf_fx.c b/lib_lc3plus/sns_quantize_scf_fx.c index 991381285..db18777bd 100644 --- a/lib_lc3plus/sns_quantize_scf_fx.c +++ b/lib_lc3plus/sns_quantize_scf_fx.c @@ -37,7 +37,7 @@ static Word16 stage1_base( /* o : idx })); #endif #ifdef WMOPS - BASOP_sub_sub_start("stage1_base"); + push_wmops("stage1_base"); #endif /* find first vector error energy for */ @@ -184,7 +184,7 @@ static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, { #ifdef WMOPS - BASOP_sub_sub_start("processQuantize_stage1ScfEncStage1_fx"); + push_wmops("processQuantize_stage1ScfEncStage1_fx"); #endif #ifdef ENABLE_HR_MODE @@ -307,7 +307,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( #endif #ifdef WMOPS - BASOP_sub_sub_start("pvq_enc_find_best_submode_pre_post_fx"); + push_wmops("pvq_enc_find_best_submode_pre_post_fx"); #endif /* construct pulse vectors and en1 normalized shape vectors */ /* use shape Q in Q14 */ @@ -506,7 +506,7 @@ static void processQuantize_stage2ScfEncStage2_fx( #endif #ifdef WMOPS - BASOP_sub_sub_start("processQuantize_stage2ScfEncStage2_fx"); + push_wmops("processQuantize_stage2ScfEncStage2_fx"); #endif /* fixed setup for a given bitrate of 38 , no moves needed */ @@ -677,7 +677,7 @@ static Word16 scfdec_stage2_fx( /* o: ber flag */ #endif #ifdef WMOPS - BASOP_sub_sub_start("scfdec_stage2_fx"); + push_wmops("scfdec_stage2_fx"); #endif dec_pulses = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * M = 32 bytes */ -- GitLab From d450a2d5abf83cf55ad4be84d1d48ebecf65ef6c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 13:37:41 +0100 Subject: [PATCH 159/329] rename BASOP_sub(_sub)_end() to pop_wmops() --- lib_lc3plus/dec_lc3.c | 46 ++++++++++---------- lib_lc3plus/enc_lc3.c | 56 ++++++++++++------------- lib_lc3plus/plc_classify_fx.c | 8 ++-- lib_lc3plus/plc_phecu_fec_hq_fx.c | 48 ++++++++++----------- lib_lc3plus/plc_phecu_peak_locator_fx.c | 2 +- lib_lc3plus/plc_phecu_setf0hz_fx.c | 2 +- lib_lc3plus/plc_phecu_tools_fx.c | 2 +- lib_lc3plus/plc_update_aft_imdct_fx.c | 4 +- lib_lc3plus/plc_update_fx.c | 2 +- lib_lc3plus/plc_xcorr_fx.c | 4 +- lib_lc3plus/pvq_enc_fx.c | 2 +- lib_lc3plus/pvq_index_fx.c | 4 +- lib_lc3plus/sns_quantize_scf_fx.c | 10 ++--- 13 files changed, 95 insertions(+), 95 deletions(-) diff --git a/lib_lc3plus/dec_lc3.c b/lib_lc3plus/dec_lc3.c index 1f302608a..1b23927c6 100644 --- a/lib_lc3plus/dec_lc3.c +++ b/lib_lc3plus/dec_lc3.c @@ -187,7 +187,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s move16(); } #ifdef WMOPS - BASOP_sub_end(); /* Entropy dec */ + pop_wmops(); /* Entropy dec */ #endif #ifdef WMOPS @@ -244,7 +244,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } } #ifdef WMOPS - BASOP_sub_end(); /* Ari dec */ + pop_wmops(); /* Ari dec */ #endif #ifdef WMOPS @@ -261,7 +261,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -273,7 +273,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s h_DecSetup->prev_bfi, h_DecSetup->prev_prev_bfi, &h_DecSetup->plcAd->stab_fac); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -296,7 +296,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s &h_DecSetup->prev_fac_ns_fx, &h_DecSetup->pc_nbLostFramesInRow); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif IF (sub(bfi, 1) != 0) @@ -310,7 +310,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -327,7 +327,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s ); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -335,7 +335,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif processApplyGlobalGain_fx(q_d_fx, &q_fx_exp, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -349,7 +349,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef ENABLE_HR_MODE @@ -359,7 +359,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processSnsInterpolateScf_fx(scf_q_ip, int_scf_fx_ip, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -369,7 +369,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processMdctShaping_fx(q_d_fx, int_scf_fx_ip, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #else #ifdef WMOPS @@ -378,7 +378,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 0, decoder->bands_number, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -387,7 +387,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processScfScaling(int_scf_fx_exp, decoder->bands_number, &q_fx_exp); processMdctShaping_fx(q_d_fx, int_scf_fx, int_scf_fx_exp, decoder->bands_offset, decoder->bands_number); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* end int_scf_fx */ #endif /* ENABLE_HR_MODE */ @@ -433,7 +433,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef ENABLE_HR_MODE @@ -463,7 +463,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s ); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -500,7 +500,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif /* ENABLE_HR_MODE */ #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -515,7 +515,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -534,7 +534,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef ENABLE_HR_MODE @@ -580,15 +580,15 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } } #ifdef WMOPS - BASOP_sub_end(); /* Output scaling */ + pop_wmops(); /* Output scaling */ #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef WMOPS - BASOP_sub_end(); /* Decoder */ + pop_wmops(); /* Decoder */ #endif @@ -633,7 +633,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo &decoder->m_fec, scratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif for (ch = 0; ch < decoder->channels; ch++) @@ -680,7 +680,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo &decoder->n_pc, &decoder->m_fec, scratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif decoder->epmr = MIN(decoder->epmr, channel_epmr); diff --git a/lib_lc3plus/enc_lc3.c b/lib_lc3plus/enc_lc3.c index 46d011d4f..f2276a2ed 100644 --- a/lib_lc3plus/enc_lc3.c +++ b/lib_lc3plus/enc_lc3.c @@ -143,7 +143,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->mdct_mem32, encoder->frame_length, h_EncSetup->resamp_mem32, h_EncSetup->olpa_mem_s12k8, &h_EncSetup->resamp_exp); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif } ELSE @@ -175,7 +175,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ encoder->W_fx, encoder->W_size, h_EncSetup->stEnc_mdct_mem, encoder->stEnc_mdct_mem_len, d_fx, &d_fx_exp, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* begin s_12k8 */ @@ -199,7 +199,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ); #endif /* ENABLE_HR_MODE */ #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -213,7 +213,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif h_EncSetup->resamp_exp, encoder->frame_dms, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -230,7 +230,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* end s_12k8 */ @@ -244,7 +244,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ attack_detector_fx(encoder, h_EncSetup, s_in_scaled, sub(h_EncSetup->x_exp, 15), currentScratch); #endif #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* begin ener_fx */ @@ -259,7 +259,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -284,7 +284,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ltpf_idx[1] = 0; move16(); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS push_wmops("BW Cutoff-Detection"); @@ -312,7 +312,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ BW_cutoff_idx = 0; } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -325,7 +325,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->attdec_detected, encoder->attdec_damping, currentScratch, encoder->sns_damping ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -335,7 +335,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processSnsQuantizeScfEncoder_fx(scf, L_scf_idx, scf_q, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -344,7 +344,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* currentScratch Size = 128 bytes */ processSnsInterpolateScf_fx(scf_q, int_scf_fx, int_scf_fx_exp, 1, encoder->bands_number, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -353,7 +353,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processMdctShaping_fx(d_fx, int_scf_fx, int_scf_fx_exp, encoder->bands_offset, encoder->bands_number); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* end int_scf_fx_exp */ #ifdef WMOPS @@ -365,7 +365,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ BW_cutoff_idx = s_min(BW_cutoff_idx, encoder->bw_index); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS push_wmops("Tns_enc"); @@ -393,7 +393,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ move16(); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -431,7 +431,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif ); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* begin q_d_fx16 */ @@ -449,7 +449,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ codingdata, &lsbMode, -1); #endif /* ENABLE_HR_MODE */ #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -467,7 +467,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx); #endif /* ENABLE_HR_MODE */ #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -486,7 +486,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif /* ENABLE_HR_MODE */ } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -517,7 +517,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ move16(); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -544,7 +544,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ move16(); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -554,7 +554,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ encoder->yLen, encoder->BW_cutoff_bits, tns_numfilters, lsbMode, lastnz, tns_order, fac_ns_idx, quantizedGain, BW_cutoff_idx, ltpf_idx, L_scf_idx, bfi_ext, encoder->fs_idx); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -569,7 +569,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ tns_order, tns_numfilters, indexes, lastnz, codingdata, resBits, numResBits, lsbMode, h_EncSetup->enable_lpc_weighting, currentScratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif #ifdef WMOPS @@ -607,17 +607,17 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif #ifdef WMOPS - BASOP_sub_end(); /* Ari dec */ + pop_wmops(); /* Ari dec */ #endif processReorderBitstream_fx(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, currentScratch); } #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif /* end q_d_fx16 */ #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif Dyn_Mem_Deluxe_Out(); @@ -646,7 +646,7 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 encoder->channel_setup[ch]->n_pccw, scratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif lc3buf += output_size2; @@ -671,7 +671,7 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 scratch); #ifdef WMOPS - BASOP_sub_end(); + pop_wmops(); #endif } diff --git a/lib_lc3plus/plc_classify_fx.c b/lib_lc3plus/plc_classify_fx.c index d902df10b..cf455e68d 100644 --- a/lib_lc3plus/plc_classify_fx.c +++ b/lib_lc3plus/plc_classify_fx.c @@ -59,7 +59,7 @@ static void array_insert_and_shift(Word32 *array, UWord8 value, Word16 longterm_ array[*byte_position] = current_byte; move16(); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -105,7 +105,7 @@ static void array_calculate(Word32 *array_tdc, Word32 *array_ns, int length, Wor *counter_phecu = sub(sub(overall_counter, counter_loc_tdc), counter_loc_ns); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } #endif @@ -247,7 +247,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost Dyn_Mem_Deluxe_Out(); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -416,7 +416,7 @@ Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, W Dyn_Mem_Deluxe_Out(); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return sc; } diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c index a2e65aa42..e73a1faa8 100644 --- a/lib_lc3plus/plc_phecu_fec_hq_fx.c +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -133,7 +133,7 @@ static void rotate_W16_fx(Word16 re_in, Word16 im_in, Word16 cosFactor, Word16 s *re_out_ptr = msu_r(L_mult(re_in, cosFactor), im_in, sinFactor); /* 2 ops no move when inlined */ *im_out_ptr = mac_r(L_mult(re_in, sinFactor), im_in, cosFactor); /* 2 ops no move when inlined */ #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; } @@ -159,7 +159,7 @@ static void valley_magnitude_adj_fx(Word16 *re_ptr, Word16 *im_ptr, Word16 uniFa *im_ptr = mult_r(scale_fx, shl_sat(*im_ptr, 1)); /* no moves , should be inlined */ #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; } @@ -202,7 +202,7 @@ Word16 rand_phase_fx(const Word16 seed, Word16 *sin_F, Word16 *cos_F) Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return seed2; } @@ -798,7 +798,7 @@ void trans_burst_ana_fx( Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -914,7 +914,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return posi; /* Q15. The position either left or right relative to the index of the middle of the 3 given data points. */ @@ -1017,7 +1017,7 @@ static Word16 imax_fx( /* o: The location, relative to the BASOP_rfftN(L_xfp, Lprot, &fft_scale, buffer_fft); } #ifdef WMOPS - BASOP_sub_sub_end(); /* anawin+fft */ + pop_wmops(); /* anawin+fft */ #endif /* Convert 32 Bit intlv FFT into phecu 16 bit flipped fft format */ @@ -1174,7 +1174,7 @@ static Word16 imax_fx( /* o: The location, relative to the } #ifdef WMOPS - BASOP_sub_sub_end(); /* peaks refine */ + pop_wmops(); /* peaks refine */ #endif logic16(); @@ -1218,7 +1218,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -1670,7 +1670,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -1761,7 +1761,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; } @@ -1850,7 +1850,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; @@ -1917,7 +1917,7 @@ static Word16 imax_fx( /* o: The location, relative to the #endif BASOP_irfftN(L_x, Lprot, &fft_scale, buffer_fft); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif pX_L = &L_x[0]; @@ -1956,7 +1956,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; } @@ -2245,7 +2245,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -2269,7 +2269,7 @@ static Word16 imax_fx( /* o: The location, relative to the #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return z; } @@ -2336,7 +2336,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -2376,7 +2376,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -2479,7 +2479,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return sum; } @@ -2548,7 +2548,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; } @@ -2668,7 +2668,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return posi; /* Q15. The position either left or right relative to the index of the middle of the 3 given data points. */ @@ -2751,7 +2751,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -2803,7 +2803,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -2872,7 +2872,7 @@ static Word16 imax_fx( /* o: The location, relative to the Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -3145,7 +3145,7 @@ static Word16 imax_fx( /* o: The location, relative to the } /* bands available*/ #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return nonpure_tone_detect; diff --git a/lib_lc3plus/plc_phecu_peak_locator_fx.c b/lib_lc3plus/plc_phecu_peak_locator_fx.c index 0670aac38..42729e800 100644 --- a/lib_lc3plus/plc_phecu_peak_locator_fx.c +++ b/lib_lc3plus/plc_phecu_peak_locator_fx.c @@ -379,7 +379,7 @@ void plc_phEcu_peak_locator_fx(const Word16 *inp, /* i: vector with values >=0 Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } diff --git a/lib_lc3plus/plc_phecu_setf0hz_fx.c b/lib_lc3plus/plc_phecu_setf0hz_fx.c index ecfa6e108..3dd5b1a08 100644 --- a/lib_lc3plus/plc_phecu_setf0hz_fx.c +++ b/lib_lc3plus/plc_phecu_setf0hz_fx.c @@ -51,7 +51,7 @@ plc_phEcuSetF0Hz_fx(/* output Q7 bin frequency [0.. 255.xxxx] "1 sign, 8 bits Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return result; /*Q7*/ diff --git a/lib_lc3plus/plc_phecu_tools_fx.c b/lib_lc3plus/plc_phecu_tools_fx.c index 40c25bdb0..c78d406a4 100644 --- a/lib_lc3plus/plc_phecu_tools_fx.c +++ b/lib_lc3plus/plc_phecu_tools_fx.c @@ -236,7 +236,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ *exp = sub(*exp, tmp); move16(); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); diff --git a/lib_lc3plus/plc_update_aft_imdct_fx.c b/lib_lc3plus/plc_update_aft_imdct_fx.c index 9a0c60b28..9ba483792 100644 --- a/lib_lc3plus/plc_update_aft_imdct_fx.c +++ b/lib_lc3plus/plc_update_aft_imdct_fx.c @@ -161,7 +161,7 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea *prev_bfi = bfi; move16(); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT @@ -332,7 +332,7 @@ void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, Word16 *xfp_fx } #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); diff --git a/lib_lc3plus/plc_update_fx.c b/lib_lc3plus/plc_update_fx.c index 85e20020f..7abb2b613 100644 --- a/lib_lc3plus/plc_update_fx.c +++ b/lib_lc3plus/plc_update_fx.c @@ -211,7 +211,7 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W } #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); diff --git a/lib_lc3plus/plc_xcorr_fx.c b/lib_lc3plus/plc_xcorr_fx.c index 882bfced4..d8c6d8390 100644 --- a/lib_lc3plus/plc_xcorr_fx.c +++ b/lib_lc3plus/plc_xcorr_fx.c @@ -167,7 +167,7 @@ Word16 plc_norm_corr_blocks_fx( /* o: norm_corr range [-1 Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return norm_corr; } @@ -242,7 +242,7 @@ Word16 plc_xcorr_lc_fx( /* o: quantized output xcorr in Q Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return norm_xcorr_est_q; } diff --git a/lib_lc3plus/pvq_enc_fx.c b/lib_lc3plus/pvq_enc_fx.c index 4f6a0aac3..b41d5ad0e 100644 --- a/lib_lc3plus/pvq_enc_fx.c +++ b/lib_lc3plus/pvq_enc_fx.c @@ -363,7 +363,7 @@ void pvq_enc_search_fx( Dyn_Mem_Deluxe_Out(); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } diff --git a/lib_lc3plus/pvq_index_fx.c b/lib_lc3plus/pvq_index_fx.c index 0a4bc6694..966dd7d13 100644 --- a/lib_lc3plus/pvq_index_fx.c +++ b/lib_lc3plus/pvq_index_fx.c @@ -338,7 +338,7 @@ void mpvq_deindex_fx( /* o : void Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif } @@ -505,7 +505,7 @@ PvqEntry_fx mpvq_index_fx( /* o : leading_sign_index, i Dyn_Mem_Out(); #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return result; diff --git a/lib_lc3plus/sns_quantize_scf_fx.c b/lib_lc3plus/sns_quantize_scf_fx.c index db18777bd..f1f0ba423 100644 --- a/lib_lc3plus/sns_quantize_scf_fx.c +++ b/lib_lc3plus/sns_quantize_scf_fx.c @@ -90,7 +90,7 @@ static Word16 stage1_base( /* o : idx ASSERT(idx >= 0 && idx < R); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); @@ -202,7 +202,7 @@ static void processQuantize_stage1ScfEncStage1_fx(const Word16 *target_st1, #endif #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif return; @@ -415,7 +415,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( move16(); /* 0,1,2,3 */ #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); @@ -632,7 +632,7 @@ static void processQuantize_stage2ScfEncStage2_fx( } #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif #ifdef DYNMEM_COUNT Dyn_Mem_Out(); @@ -741,7 +741,7 @@ static Word16 scfdec_stage2_fx( /* o: ber flag */ pvq_dec_scale_vec_fx(dec_adj_glob_vec, gValQ13, st2_vector); #ifdef WMOPS - BASOP_sub_sub_end(); + pop_wmops(); #endif Dyn_Mem_Deluxe_Out(); return BER_dec; -- GitLab From 22de76b1337866c8b7623585aa9fd6fb47eb0fdf Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 13:39:10 +0100 Subject: [PATCH 160/329] remove LC3plus multiCounter declaration --- lib_lc3plus/basop_util_lc3plus.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h index 3ff6d8d06..d9abc7f5d 100644 --- a/lib_lc3plus/basop_util_lc3plus.h +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -316,11 +316,6 @@ void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word void BASOP_rfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); void BASOP_irfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif - static __inline void basop_memcpy(void *dst, const void *src, size_t n) { #ifdef WMOPS -- GitLab From 0a66c422a7dad11ee3f7a6c945c4ba61ef242eef Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 14:12:32 +0100 Subject: [PATCH 161/329] fix functions which do not have a return statement at the end which causes issues with WMC tool --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 ++ lib_lc3plus/lc3.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 5867a44b3..6dbcde371 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -277,6 +277,8 @@ static Word16 get_panning_tangent_gain( lim_r = sub( idx, 1 ); /*Q0*/ } } + assert("should not be reached, added to avoid issues with WMC tool instrumentation"); + return 0; /* should not be reached, added to avoid issues with WMC tool instrumentation */ } static Word16 get_panning( diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c index 68dd8a0bb..88ccc186e 100644 --- a/lib_lc3plus/lc3.c +++ b/lib_lc3plus/lc3.c @@ -86,6 +86,8 @@ int lc3plus_samplerate_supported(int samplerate) #endif default: return 0; } + assert("should not be reached, added to avoid issues with WMC tool instrumentation"); + return 0; /* should not be reached, added to avoid issues with WMC tool instrumentation */ } static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) @@ -96,6 +98,8 @@ static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) return 1; default: return 0; } + assert("should not be reached, added to avoid issues with WMC tool instrumentation"); + return 0; /* should not be reached, added to avoid issues with WMC tool instrumentation */ } static int lc3plus_frame_size_supported(int frame_dms) @@ -111,6 +115,8 @@ static int lc3plus_frame_size_supported(int frame_dms) return 1; default: return 0; } + assert("should not be reached, added to avoid issues with WMC tool instrumentation"); + return 0; /* should not be reached, added to avoid issues with WMC tool instrumentation */ } static int null_in_list(void **list, int n) -- GitLab From 5d864fbb54b790235e5c81aea5437e1cd2df45ff Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 20 Feb 2025 14:21:52 +0100 Subject: [PATCH 162/329] clang-format --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 6dbcde371..9ddaa5c7e 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -277,7 +277,7 @@ static Word16 get_panning_tangent_gain( lim_r = sub( idx, 1 ); /*Q0*/ } } - assert("should not be reached, added to avoid issues with WMC tool instrumentation"); + assert( "should not be reached, added to avoid issues with WMC tool instrumentation" ); return 0; /* should not be reached, added to avoid issues with WMC tool instrumentation */ } -- GitLab From 81b0eae0d1ed28a9e59a25f0397ef9b8887693ba Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 20 Feb 2025 14:58:30 +0100 Subject: [PATCH 163/329] fix order of arguments in basop_check_for_changes.py script --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1bc5a6f07..1aa93e06c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -491,7 +491,7 @@ stages: ### compare the two csv files for regressions - regressions_found=0 - - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH || regressions_found=$? + - python3 scripts/basop_check_for_changes_in_testcases.py --xml_report $XML_REPORT_BRANCH $CSV_BRANCH $CSV_MAIN || regressions_found=$? - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit_code=$EXIT_CODE_NON_BE; fi - if [ $zero_errors_branch != 1 ]; then echo "Run errors encountered!"; exit_code=$EXIT_CODE_NON_BE; fi -- GitLab From 10c03e0a51a27a6e37d269f7ecb930926a407a6e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 20 Feb 2025 14:58:30 +0100 Subject: [PATCH 164/329] fix order of arguments in basop_check_for_changes.py script --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3f527373..51d5bc42e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -619,7 +619,7 @@ stages: ### compare the two csv files for regressions - regressions_found=0 - - python3 scripts/basop_check_for_changes_in_testcases.py --show_improvements --xml_report $XML_REPORT_BRANCH $CSV_MAIN $CSV_BRANCH > regression_log.txt || regressions_found=$? + - python3 scripts/basop_check_for_changes_in_testcases.py --show_improvements --xml_report $XML_REPORT_BRANCH $CSV_BRANCH $CSV_MAIN > regression_log.txt || regressions_found=$? - exit_code=0 - *print-results-banner -- GitLab From a2d7f097464c57e8949bd25d333312e43a6c241a Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 21 Feb 2025 14:07:49 +0100 Subject: [PATCH 165/329] proper way of porting SUPPORT_FORCE_TCX10_TCX20 --- apps/encoder.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/encoder.c b/apps/encoder.c index 165d03543..0cdb2cff9 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -2000,10 +2000,24 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( { return IVAS_ENC_FORCE_GSC; } - else if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) ) + if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) +#ifdef SUPPORT_FORCE_TCX10_TCX20 + || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) +#endif + ) { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + return IVAS_ENC_FORCE_TCX20; +#else return IVAS_ENC_FORCE_TCX; +#endif } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX10; + } +#endif else if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) { return IVAS_ENC_FORCE_HQ; -- GitLab From ff8a621a25b32357e22ed3f256ef62cfea74f66b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 21 Feb 2025 14:27:21 +0100 Subject: [PATCH 166/329] fix check-be tests comparison was always done with full chain BASOP codec, not using the flt ref en/decoder where applicable --- .gitlab-ci.yml | 81 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51d5bc42e..65ae34075 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ variables: TESTV_DIR: "/usr/local/testv" LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" - REFERENCE_BRANCH: "ivas-float-update" + FLOAT_REF_BRANCH: "ivas-float-update" BUILD_OUTPUT: "build_output.txt" SCRIPTS_DIR: "/usr/local/scripts" EXIT_CODE_NON_BE: 123 @@ -17,6 +17,8 @@ variables: DUT_DECODER_PATH: "./IVAS_dec" REF_ENCODER_PATH: "./IVAS_cod_ref" REF_DECODER_PATH: "./IVAS_dec_ref" + MERGE_TARGET_ENCODER_PATH: "./IVAS_cod_merge_target" + MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" @@ -37,8 +39,9 @@ variables: FAILED_TESTCASES_LIST: "failed-testcases.txt" ERRORS_TESTCASES_LIST: "errors-testcases.txt" PYTEST_CACHE_ARTIFACT: "pytest_cache.zip" - REF_COMMIT_FILE: "ref-branch-git-sha" - CUT_COMMIT_FILE: "CuT-branch-git-sha" + FLOAT_REF_COMMIT_FILE: "float-ref-git-sha" + CUT_COMMIT_FILE: "CuT-git-sha" + MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -147,14 +150,13 @@ stages: - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h - fi -.build-reference-binaries: &build-reference-binaries +.build-float-ref-binaries: &build-float-ref-binaries - git rev-parse HEAD > $CUT_COMMIT_FILE - current_commit_sha=$(git rev-parse HEAD) ### build reference binaries - - git checkout $REFERENCE_BRANCH + - git checkout $FLOAT_REF_BRANCH - git pull - *activate-debug-mode-info-if-set - - cat lib_com/options.h - make clean - make -j - mv ./IVAS_cod ./$REF_ENCODER_PATH @@ -162,20 +164,35 @@ stages: - mv ./IVAS_rend ./IVAS_rend_ref ### Return to current branch - git restore . - - git rev-parse HEAD > $REF_COMMIT_FILE + - git rev-parse HEAD > $FLOAT_REF_COMMIT_FILE - git checkout $current_commit_sha +.build-merge-target-binaries: &build-merge-target-binaries + - current_commit_sha=$(git rev-parse HEAD) + ### build merge target binaries + - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git pull + - *activate-debug-mode-info-if-set + - make clean + - make -j + - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH + - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH + - mv ./IVAS_rend ./IVAS_rend_merge_target + ### Return to current branch + - git restore . + - git rev-parse HEAD > $MERGE_TARGET_COMMIT_FILE + - git checkout $current_commit_sha -.build-reference-and-dut-binaries: &build-reference-and-dut-binaries +.build-float-ref-and-dut-binaries: &build-float-ref-and-dut-binaries ### build reference binaries - - *build-reference-binaries + - *build-float-ref-binaries ### build dut binaries - *activate-debug-mode-info-if-set - make clean - make -j -.build-and-create-reference-outputs: &build-and-create-reference-outputs - - *build-reference-and-dut-binaries +.build-and-create-float-ref-outputs: &build-and-create-float-ref-outputs + - *build-float-ref-and-dut-binaries ### prepare pytest # create short test vectors @@ -365,7 +382,7 @@ stages: - if [ "$COMPARE_DMX" = "true" ] || [ "$ENCODER_TEST" = "true" ]; then - BUILD_WITH_DEBUG_MODE_INFO="true" - fi - - *build-and-create-reference-outputs + - *build-and-create-float-ref-outputs - comp_args="--mld --ssnr --odg" - if [ "$ENCODER_TEST" = "true" ]; then @@ -448,15 +465,16 @@ stages: needs: ["build-codec-linux-make"] timeout: "300 minutes" variables: - REFERENCE_BRANCH: "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" + PYTEST_LOG_TARGET_BRANCH: "pytest-log-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME.txt" script: - *print-common-info - set -euxo pipefail - *update-scripts-repo + - python3 tests/create_short_testvectors.py - if [ $USE_LTV -eq 1 ]; then - *update-ltv-repo @@ -471,12 +489,16 @@ stages: - *apply-testv-scaling - fi - - *build-and-create-reference-outputs + - *build-float-ref-binaries + - *build-merge-target-binaries - *check-up-to-date-in-comparison-jobs + - exit_code_target=0 + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --mld --ssnr --odg --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -495,7 +517,7 @@ stages: - cat failed_testcases_for_printing.txt - echo "Reproduce locally with:" - - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" + - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - echo "The individual command lines can be found in the html report in the job artifacts." - if [ $num_errors -ne 0 ]; then @@ -529,8 +551,10 @@ stages: - $ERRORS_TESTCASES_LIST - pytest_log.txt - $PYTEST_CACHE_ARTIFACT - - $REF_COMMIT_FILE + - $FLOAT_REF_COMMIT_FILE - $CUT_COMMIT_FILE + - $MERGE_TARGET_COMMIT_FILE + - $PYTEST_LOG_TARGET_BRANCH expose_as: "pytest compare results" reports: junit: @@ -591,7 +615,7 @@ stages: ### run branch first # this per default builds the branch and the reference and creates the reference outputs - - *build-and-create-reference-outputs + - *build-and-create-float-ref-outputs - *check-up-to-date-in-comparison-jobs # need to restore cache again - *overwrite-pytest-cache-with-artifact @@ -627,7 +651,7 @@ stages: - echo "Run errors encountered!" - exit_code=$EXIT_CODE_FAIL - echo "Reproduce locally with:" - - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" + - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - echo "The individual command lines can be found in the changes*.csv files in the job artifacts." - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then @@ -640,7 +664,7 @@ stages: - exit_code=$EXIT_CODE_NON_BE; - fi - echo "Reproduce locally with:" - - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" + - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - echo "The individual command lines can be found in the changes*.csv files in the job artifacts." - fi @@ -664,8 +688,9 @@ stages: - $CSV_MAIN - $SUMMARY_HTML_ARTIFACT_NAME - $IMAGES_ARTIFACT_NAME - - $REF_COMMIT_FILE + - $FLOAT_REF_COMMIT_FILE - $CUT_COMMIT_FILE + - $MERGE_TARGET_COMMIT_FILE - changes_crashes.csv - changes_MLD.csv - changes_MAXIMUM_ABS_DIFF.csv @@ -695,7 +720,7 @@ stages: - *copy-ltv-files-to-testv-dir - python3 ci/remove_unsupported_testcases.py $PRM_FILES - - *build-reference-binaries + - *build-float-ref-binaries - set -euxo pipefail - make_args="CLANG=$CLANG_NUM" - if [[ $CLANG_NUM == 3 ]]; then @@ -740,7 +765,7 @@ stages: - if [ $LEVEL_SCALING != "1.0" ];then - *apply-testv-scaling - fi - - *build-reference-and-dut-binaries + - *build-float-ref-and-dut-binaries ### run pytest - exit_code=0 @@ -975,6 +1000,7 @@ check-be-to-target-short-enc-0db: before_script: - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref + - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - rm -rf tests/dut tests/ref @@ -987,6 +1013,7 @@ check-be-to-target-short-enc-+10db: before_script: - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref + - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref @@ -999,6 +1026,7 @@ check-be-to-target-short-enc--10db: before_script: - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref + - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref @@ -1011,6 +1039,7 @@ check-be-to-target-short-dec-0db: before_script: - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref + - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=1.0 - rm -rf tests/dut tests/ref @@ -1023,6 +1052,7 @@ check-be-to-target-short-dec-+10db: before_script: - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref + - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref @@ -1035,6 +1065,7 @@ check-be-to-target-short-dec--10db: before_script: - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref + - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref @@ -1466,7 +1497,7 @@ coverage-test-on-main-scheduled: - *update-scripts-repo - *update-ltv-repo - *copy-ltv-files-to-testv-dir - - *build-reference-binaries + - *build-float-ref-binaries # Build DuT binaries with GCOV - make clean - make GCOV=1 -j @@ -1665,7 +1696,7 @@ voip-be-on-merge-request: - *print-common-info - *update-scripts-repo - *update-ltv-repo - - *build-reference-and-dut-binaries + - *build-float-ref-and-dut-binaries - *complexity-measurements-setup - which coan artifacts: -- GitLab From 548bdacb70227acf2f10c292563f021c385ce1c7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 21 Feb 2025 14:38:17 +0100 Subject: [PATCH 167/329] add missing build for branch --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65ae34075..292d8ae41 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -491,6 +491,8 @@ stages: - *build-float-ref-binaries - *build-merge-target-binaries + - make clean + - make -j - *check-up-to-date-in-comparison-jobs - exit_code_target=0 -- GitLab From e463cc92c149c82a8142eb0045a072ed5cca73f3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 21 Feb 2025 15:41:28 +0100 Subject: [PATCH 168/329] run prepare_combined_files script --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 292d8ae41..1ea012c2a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -485,6 +485,8 @@ stages: - fi - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 scripts/prepare_combined_format_inputs.py + - if [ $LEVEL_SCALING != "1.0" ];then - *apply-testv-scaling - fi -- GitLab From 83f0fa157e3bffb2be6a0706fa358a65c258d7bd Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 24 Feb 2025 10:39:56 +1100 Subject: [PATCH 169/329] bug fix for cases when rotation happens in DirAC --- lib_dec/ivas_binRenderer_internal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 0b079177b..bc428106c 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1956,7 +1956,7 @@ void ivas_binRenderer_fx( { IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; Word32 Rmat_local[3][3]; - Word16 q_fact_orig; + Word16 q_fact_orig, extra_shift = 0; IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) { @@ -1972,6 +1972,7 @@ void ivas_binRenderer_fx( Quaternions_ref2.x_fx = 0; Quaternions_ref2.y_fx = 0; Quaternions_ref2.z_fx = 0; + extra_shift = 1; } ELSE { @@ -2028,9 +2029,9 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 move32(); - Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 move32(); } } -- GitLab From afde1c1eb2ea21dbd04d0cde5e68be5860a30de6 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 24 Feb 2025 12:30:15 +1100 Subject: [PATCH 170/329] cldfb in lc3plus coding, bug fix for q fact of TD in to lc3plus --- lib_isar/lib_isar_pre_rend.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 5ebfd8e61..3b19c1ad0 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -474,28 +474,40 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs / 20; /* CLDFB synthesis of main pose */ - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - Word32 *Cldfb_In_BinReal_p_fx[CLDFB_NO_COL_MAX]; - Word32 *Cldfb_In_BinImag_p_fx[CLDFB_NO_COL_MAX]; q1 = 31; q2 = 31; move16(); move16(); - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); - q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); + q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); + } } + q_final = s_min( q1, q2 ); q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 3 ); // guard bits q_final = s_min( q_final, Q25 ); - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); - Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); + Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); + } } + } + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Word32 *Cldfb_In_BinReal_p_fx[CLDFB_NO_COL_MAX]; + Word32 *Cldfb_In_BinImag_p_fx[CLDFB_NO_COL_MAX]; + FOR( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) { @@ -514,6 +526,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; move16(); } + assert( Q_out[0] == Q_out[1] ); #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; -- GitLab From c1781082bdb607eb3b887167229c5b1f1cbd678b Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 24 Feb 2025 08:35:30 +0000 Subject: [PATCH 171/329] Update 2 files - /.gitlab/issue_templates/float-update-porting.md - /.gitlab/merge_request_templates/float-update-porting.md --- .gitlab/issue_templates/float-update-porting.md | 2 -- .gitlab/merge_request_templates/float-update-porting.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab/issue_templates/float-update-porting.md b/.gitlab/issue_templates/float-update-porting.md index 84d15a8c8..19bbf7ba8 100644 --- a/.gitlab/issue_templates/float-update-porting.md +++ b/.gitlab/issue_templates/float-update-porting.md @@ -2,7 +2,5 @@ - Original merge request in float repo: -- Branch for float ref update: -- Branch for BASOP update: /label ~Type:FloatUpdatePorting ~Status::ToDo diff --git a/.gitlab/merge_request_templates/float-update-porting.md b/.gitlab/merge_request_templates/float-update-porting.md index 7ffdee333..5b6d90dad 100644 --- a/.gitlab/merge_request_templates/float-update-porting.md +++ b/.gitlab/merge_request_templates/float-update-porting.md @@ -1,6 +1,6 @@ - Link to issue in BASOP repo: -- Link to original issue in float repo: +- Link to original MR in float repo: - Requested reviewers: /label Type:FloatUpdatePorting -- GitLab From e21996d8675465373eb719b2aed585878a2aa0c3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 24 Feb 2025 11:23:37 +0100 Subject: [PATCH 172/329] fix bug in renaming of the codec binaries for use by pytest --- .gitlab-ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ea012c2a..a7f044dad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,12 +13,20 @@ variables: SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm" LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" TEST_SUITE: "" + # These path variables are used by the pytest calls. + # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod" DUT_DECODER_PATH: "./IVAS_dec" REF_ENCODER_PATH: "./IVAS_cod_ref" REF_DECODER_PATH: "./IVAS_dec_ref" MERGE_TARGET_ENCODER_PATH: "./IVAS_cod_merge_target" MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target" + # These path variables are used for building the binaries + # They should never be overwritten! + REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref" + REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref" + MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_merge_target" + MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" @@ -159,8 +167,8 @@ stages: - *activate-debug-mode-info-if-set - make clean - make -j - - mv ./IVAS_cod ./$REF_ENCODER_PATH - - mv ./IVAS_dec ./$REF_DECODER_PATH + - mv ./IVAS_cod ./$REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./IVAS_dec ./$REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_rend ./IVAS_rend_ref ### Return to current branch - git restore . @@ -175,8 +183,8 @@ stages: - *activate-debug-mode-info-if-set - make clean - make -j - - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH - - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH + - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_rend ./IVAS_rend_merge_target ### Return to current branch - git restore . -- GitLab From e244424a47e4891cd6691793300af23260bd9013 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 24 Feb 2025 14:58:29 +0100 Subject: [PATCH 173/329] implement minimal pipeline for draft MRs for basop part of porting work --- .gitlab-ci.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 147eb7c00..3487ad701 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -304,6 +304,8 @@ stages: .rules-mr-to-main-or-main-pc-or-manual: rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main-pc") - if: $CI_PIPELINE_SOURCE == 'push' @@ -373,9 +375,20 @@ stages: - if: $CI_PIPELINE_SOURCE == 'push' when: never +.rules-merge-request-no-draft: + extends: .rules-basis + rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + .rules-merge-request-to-main-pc: extends: .rules-basis rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main-pc' - if: $CI_PIPELINE_SOURCE == 'push' when: never @@ -777,6 +790,19 @@ branch-is-up-to-date-with-target-post: exit 1 fi +# fail pipeline in the final stage for pipelines on Draft MRs +# this also only runs on Draft MRs, so should always fail +fail-pipeline-if-in-draft: + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + stage: postvalidate + tags: + - ivas-linux + script: + - echo "Your MR is still in Draft state, set it to ready to be mergable, then retrigger the pipeline." + - exit 1 # --------------------------------------------------------------- # verification jobs @@ -1376,6 +1402,8 @@ be-2-evs-26444: extends: - .test-job-linux rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "evs-26444" - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main-pc") tags: @@ -1451,7 +1479,7 @@ voip-be-on-merge-request: .codec-smoke-test: extends: - .test-job-linux-needs-testv-dir - - .rules-merge-request + - .rules-merge-request-no-draft timeout: "20 minutes" tags: - ivas-basop-linux -- GitLab From 9b7142544faa531899085296274782f8b922715d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 24 Feb 2025 15:06:49 +0100 Subject: [PATCH 174/329] dummy commit to trigger CI -- GitLab From 42023f79808d5a4eb3103741cd872ccdc983a9ab Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 24 Feb 2025 09:14:12 -0500 Subject: [PATCH 175/329] possible fix to 1320 --- lib_enc/ivas_td_low_rate_enc.c | 53 ++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index 95762fa29..a39a17d99 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -222,6 +222,10 @@ void encod_gen_2sbfr( LPD_state_HANDLE hLPDmem = st->hLPDmem; +#ifdef FIX_1320_LOWRATE_ACELP + Word16 gcode16; + Word32 Lgcode, Ltmp; +#endif #ifdef MSAN_FIX set16_fx( cn, 0, 2 * L_SUBFR ); /* Target vector in residual domain */ #endif @@ -269,8 +273,12 @@ void encod_gen_2sbfr( // Scale_sig( &hLPDmem->mem_w0, M + 1, sub( add( *Q_new, hLPDmem->e_mem_syn ), Q16 ) ); // M + 1 to sync mem_syn exponent with mem_w0 exponent // hLPDmem->e_mem_syn = sub( Q16, *Q_new ); - find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); +#ifndef FIX_1320_LOWRATE_ACELP + find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); +#else + find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); +#endif /*Scale_sig(h1, L_SUBFR, shift); */ /*Q14-shift */ Copy_Scale_sig( h1, h2, 2 * L_SUBFR, -2 ); Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ @@ -300,8 +308,11 @@ void encod_gen_2sbfr( * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); - +#else + lp_filt_exc_enc_ivas_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); +#endif /* update long-term pitch gain for speech/music classifier */ st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277, gain_pit ) ); // Q14 move16(); @@ -334,14 +345,30 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); +#ifndef FIX_1320_LOWRATE_ACELP hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); +#else + Lgcode = L_shl_sat( gain_code, sub( Q_new, 0 ) ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + hLPDmem->tilt_code = est_tilt_ivas_fx(exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0); +#endif move16(); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP hLPDmem->mem_w0 = sub( sub( xn[2 * L_SUBFR - 1], mult_r( gain_pit, y1[2 * L_SUBFR - 1] ) ), mult_r( extract_h( gain_code ), y2[2 * L_SUBFR - 1] ) ); +#else + Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add(5, shift ) ); /*Q15+shift*/ + Ltmp = L_negate( Ltmp ); + Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_msu( Ltmp, y1[2 * L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ +#endif move16(); /*-----------------------------------------------------------------* @@ -349,6 +376,7 @@ void encod_gen_2sbfr( * Save the non-enhanced excitation for FEC_exc *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP FOR( i = 0; i < 2 * L_SUBFR; i++ ) { exc2[i + i_subfr] = mult( gain_pit, exc[i + i_subfr] ); @@ -356,7 +384,20 @@ void encod_gen_2sbfr( exc[i + i_subfr] = add( exc2[i + i_subfr], mult( extract_h( gain_code ), code[i] ) ); move16(); } - +#else + FOR(i = 0; i < 2 * L_SUBFR; i++) + { + /* code in Q9, gain_pit in Q14 */ + exc2[i + i_subfr] = shl_sat( mult( gain_pit, exc[i + i_subfr] ), 1 ); + Ltmp = L_mult( gcode16, code[i] ); /* Q10 */ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc[i + i_subfr] = round_fx_sat( Ltmp ); + move16(); + move16(); + } +#endif /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ @@ -370,9 +411,11 @@ void encod_gen_2sbfr( * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - +#ifndef FIX_1320_LOWRATE_ACELP E_UTIL_synthesis( 0, p_Aq, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1, M ); - +#else + Syn_filt_s(1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); +#endif p_Aw += 2 * ( M + 1 ); p_Aq += 2 * ( M + 1 ); -- GitLab From 7de3bc969f7709963211055a4be0df334663f3b5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 24 Feb 2025 09:38:14 -0500 Subject: [PATCH 176/329] small correction to the fix --- lib_com/options.h | 2 ++ lib_enc/ivas_td_low_rate_enc.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0c8105d8c..8204162b7 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,4 +164,6 @@ #define FIX_ISSUE_1247 #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ #define FIX_1285_DECODER_CRASH + +#define FIX_1320_LOWRATE_ACELP #endif diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index a39a17d99..e29810db0 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -302,8 +302,11 @@ void encod_gen_2sbfr( * Gain clipping test to avoid unstable synthesis on frame erasure *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP clip_gain = gp_clip_fx( st->element_mode, st->core_brate, st->voicing_fx, i_subfr, coder_type, xn, st->clip_var_fx, Q_new ); // Q0 - +#else + clip_gain = gp_clip_fx( st->element_mode, st->core_brate, st->voicing_fx, i_subfr, coder_type, xn, st->clip_var_fx, sub( Q_new, 1 ) ); // Q0 +#endif /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ @@ -348,7 +351,7 @@ void encod_gen_2sbfr( #ifndef FIX_1320_LOWRATE_ACELP hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); #else - Lgcode = L_shl_sat( gain_code, sub( Q_new, 0 ) ); /* scaled gain_code with Qnew -> Q16*/ + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); /*Q0*/ hLPDmem->tilt_code = est_tilt_ivas_fx(exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0); #endif -- GitLab From dc11ee23067a74b0572c2dd331a99640d7c6ca5f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 24 Feb 2025 09:55:30 -0500 Subject: [PATCH 177/329] fix clang --- lib_enc/ivas_td_low_rate_enc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index e29810db0..d09134951 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -352,8 +352,8 @@ void encod_gen_2sbfr( hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); #else Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ - hLPDmem->tilt_code = est_tilt_ivas_fx(exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0); + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); #endif move16(); @@ -365,12 +365,12 @@ void encod_gen_2sbfr( hLPDmem->mem_w0 = sub( sub( xn[2 * L_SUBFR - 1], mult_r( gain_pit, y1[2 * L_SUBFR - 1] ) ), mult_r( extract_h( gain_code ), y2[2 * L_SUBFR - 1] ) ); #else Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ - Ltmp = L_shl( Ltmp, add(5, shift ) ); /*Q15+shift*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ Ltmp = L_negate( Ltmp ); - Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ Ltmp = L_msu( Ltmp, y1[2 * L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ #endif move16(); @@ -388,14 +388,14 @@ void encod_gen_2sbfr( move16(); } #else - FOR(i = 0; i < 2 * L_SUBFR; i++) + FOR( i = 0; i < 2 * L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ exc2[i + i_subfr] = shl_sat( mult( gain_pit, exc[i + i_subfr] ), 1 ); - Ltmp = L_mult( gcode16, code[i] ); /* Q10 */ - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ + Ltmp = L_mult( gcode16, code[i] ); /* Q10 */ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ exc[i + i_subfr] = round_fx_sat( Ltmp ); move16(); move16(); @@ -417,7 +417,7 @@ void encod_gen_2sbfr( #ifndef FIX_1320_LOWRATE_ACELP E_UTIL_synthesis( 0, p_Aq, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1, M ); #else - Syn_filt_s(1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); + Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); #endif p_Aw += 2 * ( M + 1 ); p_Aq += 2 * ( M + 1 ); -- GitLab From bbc6fea61ff3becd414c2abc783a4818d662f7b2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 13 Feb 2025 14:02:03 -0500 Subject: [PATCH 178/329] fixes to overflow in preprocessing --- lib_com/options.h | 1 + lib_enc/ivas_stereo_classifier.c | 4 ++++ lib_enc/speech_music_classif_fx.c | 11 +++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 974237f4c..2d359665c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,4 +168,5 @@ #define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */ #define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS /* FhG: Minor WMOPS tuning, nonbe */ #define FIX_1320_LOWRATE_ACELP +#define FIX_1297_OVERFLOW /* VA: fixes issue with overflows in pre-processing */ #endif diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index c84fd73f1..4913f2545 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -1647,7 +1647,11 @@ static void edge_detect_fx( } } +#ifndef FIX_1297_OVERFLOW *edge_str = extract_l( L_shr( edge_min, 10 ) ); // Q15 +#else + *edge_str = extract_h( L_shl_sat( edge_min, 16 - 10 ) ); // Q15 +#endif move16(); *edge_type = et; // Q0 move16(); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 32b521ef4..295cff8a1 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2303,14 +2303,21 @@ Word16 ivas_smc_gmm_fx( *high_lpn_flag = 1; move32(); } - +#ifndef FIX_1297_OVERFLOW hSpMusClas->lpm_fx = extract_l( L_shr( lpm_fx, 11 ) ); // Q7 move16(); hSpMusClas->lps_fx = extract_l( L_shr( lps_fx, 11 ) ); // Q7 move16(); hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 11 ) ); // Q7 move16(); - +#else + hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 + move16(); + hSpMusClas->lps_fx = extract_h( L_shl_sat( lps_fx, 16 - 11 ) ); // Q7 + move16(); + hSpMusClas->lpn_fx = extract_h( L_shl_sat( lpn_fx, 16 - 11 ) ); // Q7 + move16(); +#endif /* determine HQ Generic speech class */ IF( st->hHQ_core != NULL ) { -- GitLab From 89812809bebc8e1dbd5c87502203ff08e13b797d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 13 Feb 2025 15:27:40 -0500 Subject: [PATCH 179/329] fix for possible assert in guas_enc (1298) --- lib_com/options.h | 1 + lib_enc/gaus_enc_fx.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2d359665c..e7c3f2ce5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,4 +169,5 @@ #define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS /* FhG: Minor WMOPS tuning, nonbe */ #define FIX_1320_LOWRATE_ACELP #define FIX_1297_OVERFLOW /* VA: fixes issue with overflows in pre-processing */ +#define FIX_1298 /* VA: fix possible assert in gaus_enc */ #endif diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index a9add7ea8..a7d60642b 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -980,9 +980,13 @@ void gauss2v_ivas_fx( /* eneri = round_fx(ener[i]) + round_fx(ener[j]) + 2*round_fx(dotprod) */ /* Use ScalingShift to stay aligned with ener[] */ eneri = L_shl( dotprod, 1 ); /* One left shift added for factor of 2 */ +#ifndef FIX_1298 eneri = L_add( ener[i], eneri ); eneri = L_add( ener[j], eneri ); /* Q31 */ - +#else + eneri = L_add_sat( ener[i], eneri ); + eneri = L_add_sat( ener[j], eneri ); /* Q31 */ +#endif lo1 = L_Extract_lc( cor32, &hi1 ); cor2 = Sad_32( 0, hi1, lo1 ); /* Square + Add */ -- GitLab From 20387d7dd12d252d2611f807d9534887654ffc4a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 14 Feb 2025 13:49:39 -0500 Subject: [PATCH 180/329] possible modification to improve #1300 --- lib_com/options.h | 1 + lib_enc/ivas_stereo_ica_enc.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index e7c3f2ce5..2788649c8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,4 +170,5 @@ #define FIX_1320_LOWRATE_ACELP #define FIX_1297_OVERFLOW /* VA: fixes issue with overflows in pre-processing */ #define FIX_1298 /* VA: fix possible assert in gaus_enc */ +#define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */ #endif diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 9d06a5523..4c77f86af 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -1965,6 +1965,8 @@ void stereo_tca_enc_fx( Word16 temp_exp, tempF_16fx; Word16 scalar_value = BASOP_Util_Divide1616_Scale( currentNCShift, dsFactor, &temp_exp ); /* Q15-temp_exp */ + +#ifndef FIX_1300_ICA_SHIFT_QUANT_IMPROV IF( temp_exp < 0 ) { scalar_value = shl( scalar_value, sub( temp_exp, Q3 ) ); // Q12 @@ -1976,6 +1978,11 @@ void stereo_tca_enc_fx( hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, shl( 1, sub( 14, temp_exp ) ), ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ move16(); } +#else + scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ + hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ +#endif + tempF_fx = tempF_16fx; move32(); } -- GitLab From 5dc906cb2e73c390ae3ad6c41605b0acf9612ef1 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 14 Feb 2025 14:55:44 -0500 Subject: [PATCH 181/329] fix clang --- lib_enc/ivas_stereo_ica_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 4c77f86af..5b79f416a 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -1979,8 +1979,8 @@ void stereo_tca_enc_fx( move16(); } #else - scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ - hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ + scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ + hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ #endif tempF_fx = tempF_16fx; -- GitLab From 06e004881ce5add9c083ad74a8cf4d539b85e940 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 25 Feb 2025 21:13:26 +1100 Subject: [PATCH 182/329] rotation matrix q factor setting to Q30 --- lib_com/options.h | 16 +++++++++++----- lib_isar/isar_splitRendererPre.c | 4 ++-- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 ++ lib_rend/lib_rend.c | 2 ++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 90237fa34..51beb86ef 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -125,11 +125,6 @@ #define FIX_ISSUE_1187 /* Ittiam: Fix for issue 1187: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from bass_pf_enc_fx function*/ #define FIX_ISSUE_1186 /* Ittiam: Fix for Issue 1186: Energy/scaling issue for ISM-1 at all bitrates */ #define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */ -#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT -#define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS -#define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ -#endif #define FIX_ISSUE_1185 /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/ #define FIX_ISSUE_1209 /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/ #define FIX_ISSUE_1218 /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/ @@ -169,4 +164,15 @@ #define FIX_ISSUE_1247 #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ #define FIX_1285_DECODER_CRASH + +/* #################### Start BASOP porting switches ############################ */ + +#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +#define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +#define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ +#endif + +/* #################### End BASOP porting switches ############################ */ + #endif diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 306753bd6..8dd0cdf95 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -944,7 +944,7 @@ static void isar_split_rend_quant_md_fx( { FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { - quant_val = L_sub( hMd->pred_mat_re_fx[ch1][ch2], L_shr_r( ( ch1 == ch2 ) ? ONE_IN_Q31 : 0, sub( Q31, Q_frame ) ) ); + quant_val = L_sub_sat( hMd->pred_mat_re_fx[ch1][ch2], L_shr_r( ( ch1 == ch2 ) ? ONE_IN_Q31 : 0, sub( Q31, Q_frame ) ) ); quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PRED_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( quant_val, L_shr_r( ISAR_SPLIT_REND_PRED_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); hMd->pred_mat_re_idx[ch1][ch2] = (Word16) L_shr_r( Mpy_32_32( onebyquantstep, quant_val ), sub( Q_frame, 5 ) ); // Q25*Q26 = Q20 -> Q16 -> Q0 } @@ -972,7 +972,7 @@ static void isar_split_rend_quant_md_fx( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { - quant_val = L_sub( hMd->pred_mat_re_fx[ch1][ch2], L_shr_r( fix_pos_rot_mat[ch1][ch2], sub( Q31, Q_frame ) ) ); + quant_val = L_sub_sat( hMd->pred_mat_re_fx[ch1][ch2], L_shr_r( fix_pos_rot_mat[ch1][ch2], sub( Q31, Q_frame ) ) ); quant_val = L_min( L_shr_r( ISAR_SPLIT_REND_PRED_MAX_VAL_Q30, sub( Q30, Q_frame ) ), L_max( quant_val, L_shr_r( ISAR_SPLIT_REND_PRED_MIN_VAL_Q30, sub( Q30, Q_frame ) ) ) ); hMd->pred_mat_re_idx[ch1][ch2] = (Word16) L_shr_r( Mpy_32_32( onebyquantstep, quant_val ), sub( Q_frame, 5 ) ); // Q25*Q26 = Q20 -> Q16 -> Q0 diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 51dafc8dd..a88ea9375 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1179,6 +1179,7 @@ static void ivas_dirac_dec_binaural_internal_fx( Euler2Quat_fx( deg2rad_fx( Quaternions_rot.x_fx ), deg2rad_fx( Quaternions_rot.y_fx ), deg2rad_fx( Quaternions_rot.z_fx ), &Quaternions_rot ); modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact ); QuatToRotMat_fx( Quaternions_rot, Rmat_local ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( Quaternions_ref->q_fact, 1 ), 32 ), Q30 ); hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); @@ -6862,6 +6863,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Euler2Quat_fx( deg2rad_fx( Quaternions_rot.x_fx ), deg2rad_fx( Quaternions_rot.y_fx ), deg2rad_fx( Quaternions_rot.z_fx ), &Quaternions_rot ); modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact ); QuatToRotMat_fx( Quaternions_rot, Rmat_local ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( Quaternions_ref->q_fact, 1 ), 32 ), Q30 ); hDiracDecBin = hMasaExtRend->hDiracDecBin[pos_idx]; assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f3dfe51e9..a8ca4528c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7272,6 +7272,7 @@ static ivas_error renderMcToSplitBinaural( Copy_Quat_fx( &Quaternions_abs, &combinedOrientationDataLocal.Quaternions[i] ); QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx[i], combinedOrientationDataLocal.Rmat_fx[i], sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); } IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_7_1 ) ) @@ -7595,6 +7596,7 @@ static ivas_error renderSbaToMultiBinaural( Copy_Quat_fx( &Quaternions_abs, &combinedOrientationDataLocal.Quaternions[i] ); QuatToRotMat_fx( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat_fx[i] ); + modify_Rmat_q_fx( combinedOrientationDataLocal.Rmat_fx[i], combinedOrientationDataLocal.Rmat_fx[i], sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); } /* copy input for in-place rotation */ -- GitLab From 3064dbd12837fdec68c7b8617f01c8a59ef10b9b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 14 Feb 2025 15:09:06 -0500 Subject: [PATCH 183/329] correction of constants --- lib_com/options.h | 1 + lib_enc/ivas_stereo_td_analysis.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2788649c8..288145122 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,4 +171,5 @@ #define FIX_1297_OVERFLOW /* VA: fixes issue with overflows in pre-processing */ #define FIX_1298 /* VA: fix possible assert in gaus_enc */ #define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */ +#define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ #endif diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index 49ac895ef..a938083e6 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -74,9 +74,13 @@ #define RATIO_MAX 1.5f /* Maximum correlation ratio */ #define RATIO_MAX_FX_Q30 ( 1610612736 ) /* 1.5f in Q30 */ /* Maximum correlation ratio */ +#ifdef FIX_1301_CORRECT_TD_CNST +#define RATIO_MAX_FX_Q24 ( 25165824 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ +#define RATIO_MAX_FX_Q23 ( 12582912 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ +#else #define RATIO_MAX_FX_Q24 ( 2516582 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ #define RATIO_MAX_FX_Q23 ( 1258291 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ - +#endif #define LIMIT_ADAP_FAC_FX_Q16 ( 9830 ) /* 0.15f in Q16 */ #define MIN_ADAP_FAC_FX_Q16 ( 6554 ) /*0.1f in Q16*/ #define M_ADAP_FX_Q31 ( 1932735 ) /* 0.0009f in Q31 */ -- GitLab From 6237fb9cb1fee12e6d7a1d9bbe9ee8d9d740aa62 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 14 Feb 2025 15:12:22 -0500 Subject: [PATCH 184/329] fix clang format --- lib_enc/ivas_stereo_td_analysis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index a938083e6..4e8b51c11 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -78,8 +78,8 @@ #define RATIO_MAX_FX_Q24 ( 25165824 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ #define RATIO_MAX_FX_Q23 ( 12582912 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ #else -#define RATIO_MAX_FX_Q24 ( 2516582 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ -#define RATIO_MAX_FX_Q23 ( 1258291 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ +#define RATIO_MAX_FX_Q24 ( 2516582 ) /* 1.5f in Q24 */ /* Maximum correlation ratio */ +#define RATIO_MAX_FX_Q23 ( 1258291 ) /* 1.5f in Q23 */ /* Maximum correlation ratio */ #endif #define LIMIT_ADAP_FAC_FX_Q16 ( 9830 ) /* 0.15f in Q16 */ #define MIN_ADAP_FAC_FX_Q16 ( 6554 ) /*0.1f in Q16*/ -- GitLab From cae6da2568bee735bbc6347ca81c5c1a4d677d2e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 17 Feb 2025 15:40:20 -0500 Subject: [PATCH 185/329] more correction on constant error, plus one potential saturation was missing --- lib_enc/ivas_stereo_td_analysis.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index 4e8b51c11..f80c74c69 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -262,7 +262,11 @@ Word16 stereo_tdm_ener_analysis_fx( rms_thd_fx = L_shr( rms_thd_fx, 2 ); /*Q16*/ /*rms_thd_fx *= 0.25f*/ test(); test(); +#ifdef FIX_1301_CORRECT_TD_CNST + IF( LE_32( hStereoTD->tdm_lt_rms_L_fx, 4915200 /* 75 in Q16*/ ) || LE_32( hStereoTD->tdm_lt_rms_R_fx, 4915200 /* 75 in Q16*/ ) /*|| sts[0]->last_coder_type == TRANSITION */ ) +#else IF( LE_32( hStereoTD->tdm_lt_rms_L_fx, 4915200 /* 75 in Q16*/ ) || LE_32( hStereoTD->tdm_lt_rms_R_fx, 75 /* 75 in Q16*/ ) /*|| sts[0]->last_coder_type == TRANSITION */ ) +#endif { rms_thd_fx = L_shr( rms_thd_fx, 5 ); /* Q16*/ /*rms_thd_fx *= 0.03125f*/ } @@ -336,6 +340,10 @@ Word16 stereo_tdm_ener_analysis_fx( move16(); } +#ifdef FIX_1301_CORRECT_TD_CNST + rms_L_fx = L_shl( rms_L_fx, sub( Q16, q_rms_L ) ); /* All the following energy comparison are done in Q16 */ + rms_R_fx = L_shl( rms_R_fx, sub( Q16, q_rms_R ) ); +#endif test(); IF( EQ_16( hStereoTD->prev_fr_LRTD_TD_dec, 1 ) && side_can_change == 0 ) { @@ -434,7 +442,11 @@ Word16 stereo_tdm_ener_analysis_fx( ELSE { /*ratio_L = ( 1.0f - cosf( EVS_PI * ratio_L / 2.0f ) ) / 2.0f;*/ +#ifdef FIX_1301_CORRECT_TD_CNST + ratio_L_fx = L_deposit_h( sub_sat( ONE_IN_Q14, getCosWord16( extract_l( Mpy_32_32( 1647099 /* EVS_PI/2 in Q20 */, ratio_L_fx ) ) ) ) ); // Q31 (Q14 + Q1(division by 2.0f) + Q16) +#else ratio_L_fx = L_deposit_h( sub( ONE_IN_Q14, getCosWord16( extract_l( Mpy_32_32( 1647099 /* EVS_PI/2 in Q20 */, ratio_L_fx ) ) ) ) ); // Q31 (Q14 + Q1(division by 2.0f) + Q16) +#endif } test(); @@ -482,7 +494,7 @@ Word16 stereo_tdm_ener_analysis_fx( { test(); test(); - IF( GE_32( hCPE->element_brate, IVAS_48k ) && sts[0]->hVAD->hangover_cnt != 0 && LT_32( L_max( hStereoTD->tdm_lt_rms_L_fx, hStereoTD->tdm_lt_rms_R_fx ), 33554432 /* 512.0f */ ) ) + IF( GE_32( hCPE->element_brate, IVAS_48k ) && sts[0]->hVAD->hangover_cnt != 0 && LT_32( L_max( hStereoTD->tdm_lt_rms_L_fx, hStereoTD->tdm_lt_rms_R_fx ), 33554432 /* 512.0f in Q16*/ ) ) { ratio_L_fx = check_bounds_l( ratio_L_fx, 644245094 /*0.3f in Q31*/, 1503238554 /*0.7f in Q31*/ ); /* Q31 */ } @@ -491,7 +503,7 @@ Word16 stereo_tdm_ener_analysis_fx( test(); test(); test(); - IF( ( GT_32( hCPE->hStereoTCA->instTargetGain_fx, 644245094 /*1.2f in Q29*/ ) || GT_32( hCPE->hStereoTCA->targetGain_fx, ONE_IN_Q29 ) ) && LT_32( ratio_L_fx, 858993459 /*0.4f*/ ) ) + IF( ( GT_32( hCPE->hStereoTCA->instTargetGain_fx, 644245094 /*1.2f in Q29*/ ) || GT_32( hCPE->hStereoTCA->targetGain_fx, ONE_IN_Q29 ) ) && LT_32( ratio_L_fx, 858993459 /*0.4f in Q31*/ ) ) { ratio_L_fx = 858993459; /*0.4f in Q31*/ move32(); @@ -569,7 +581,7 @@ Word16 stereo_tdm_ener_analysis_fx( } } - IF( LT_16( sub( sts[1]->lp_speech_fx, sts[1]->lp_noise_fx ), 12800 /*50.0f*/ ) ) /* likely presence of noisy content */ + IF( LT_16( sub( sts[1]->lp_speech_fx, sts[1]->lp_noise_fx ), 12800 /*50.0f in Q8*/ ) ) /* likely presence of noisy content */ { /* pointing in the right direction, inverse it else do nothing */ test(); @@ -1063,7 +1075,11 @@ static void NOOP_decision_fx( } ELSE { - if ( LT_32( sts[0]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) ) +#ifdef FIX_1301_CORRECT_TD_CNST + if ( LT_32( sts[0]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) ) +#else + if ( LT_32( sts[0]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) ) +#endif { tdm_NOOP_switch_flag = 1; move16(); -- GitLab From 7b46b2feacdf05d77fe95c1dae2a336ab3b0c294 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 17 Feb 2025 15:42:59 -0500 Subject: [PATCH 186/329] fix clang --- lib_enc/ivas_stereo_td_analysis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index f80c74c69..5bc62bc8b 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -341,7 +341,7 @@ Word16 stereo_tdm_ener_analysis_fx( } #ifdef FIX_1301_CORRECT_TD_CNST - rms_L_fx = L_shl( rms_L_fx, sub( Q16, q_rms_L ) ); /* All the following energy comparison are done in Q16 */ + rms_L_fx = L_shl( rms_L_fx, sub( Q16, q_rms_L ) ); /* All the following energy comparison are done in Q16 */ rms_R_fx = L_shl( rms_R_fx, sub( Q16, q_rms_R ) ); #endif test(); @@ -655,7 +655,7 @@ Word16 stereo_tdm_ener_analysis_fx( #ifdef FIX_ISSUE_1125 ratio_L_fx = tdm_ratio_tabl_fx_Q30[idx]; // Q30 #else - ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 + ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 #endif move32(); @@ -666,7 +666,7 @@ Word16 stereo_tdm_ener_analysis_fx( #ifdef FIX_ISSUE_1125 ratio_L_fx = tdm_ratio_tabl_fx_Q30[idx]; // Q30 #else - ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 + ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31 #endif move32(); } @@ -1076,9 +1076,9 @@ static void NOOP_decision_fx( ELSE { #ifdef FIX_1301_CORRECT_TD_CNST - if ( LT_32( sts[0]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) ) + if ( LT_32( sts[0]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 320000 /* 5000.f in Q6 */ ) ) #else - if ( LT_32( sts[0]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) ) + if ( LT_32( sts[0]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) && LT_32( sts[1]->ee_old_fx, 160000 /* 5000.f in Q6 */ ) ) #endif { tdm_NOOP_switch_flag = 1; -- GitLab From e542dfcd2f18111c2476a983e714c9296265b34e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 12:13:48 +0100 Subject: [PATCH 187/329] overwrite REFERENCE_BRANCH for merges to main-pc --- .gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3487ad701..960a2fa77 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -986,12 +986,19 @@ build-codec-linux-debugging-make: # Short test jobs that run in merge request pipelines # --------------------------------------------------------------- +.set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch + - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then + - *update-scripts-repo + - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh) + - fi + ### jobs that test fx encoder -> flt decoder ivas-pytest-compare_to_main-short-enc: extends: - .rules-pytest-to-main-short - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" @@ -1004,6 +1011,7 @@ ivas-pytest-compare_to_main-short-enc-lev-10: - .rules-pytest-to-main-short - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" @@ -1016,6 +1024,7 @@ ivas-pytest-compare_to_main-short-enc-lev+10: - .rules-pytest-to-main-short - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" @@ -1029,6 +1038,7 @@ ivas-pytest-compare_to_main-short-dec: - .rules-mr-to-main-or-main-pc-or-manual - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" @@ -1041,6 +1051,7 @@ ivas-pytest-compare_to_main-short-dec-lev-10: - .rules-mr-to-main-or-main-pc-or-manual - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" @@ -1053,6 +1064,7 @@ ivas-pytest-compare_to_main-short-dec-lev+10: - .rules-mr-to-main-or-main-pc-or-manual - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" @@ -1071,6 +1083,7 @@ ivas-pytest-compare_to_ref-short-enc: - .rules-mr-to-main-or-main-pc-or-manual - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - ENCODER_TEST="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1084,6 +1097,7 @@ ivas-pytest-compare_to_ref-short-enc-lev-10: - .rules-mr-to-main-or-main-pc-or-manual - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - ENCODER_TEST="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1097,6 +1111,7 @@ ivas-pytest-compare_to_ref-short-enc-lev+10: - .rules-mr-to-main-or-main-pc-or-manual - .test-job-linux before_script: + - *set-reference-for-basop-port-branch - USE_LTV=0 - ENCODER_TEST="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH -- GitLab From 36ea560259dafb4e02837dae799f19da1170d56c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 13:48:11 +0100 Subject: [PATCH 188/329] make sure that script output is displayed on failure --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 960a2fa77..9f2773613 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -989,7 +989,8 @@ build-codec-linux-debugging-make: .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then - *update-scripts-repo - - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh) + - # this double call is there so the error printout is visible in case the schell script fails + - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh) || ci/get_float_ref_branch_name.sh - fi ### jobs that test fx encoder -> flt decoder -- GitLab From 66c69bc5f5393f5100b822df5bdb516c7914ad42 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 13:51:59 +0100 Subject: [PATCH 189/329] fix script call and aadd redirectt --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f2773613..9780e4341 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -989,8 +989,8 @@ build-codec-linux-debugging-make: .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then - *update-scripts-repo - - # this double call is there so the error printout is visible in case the schell script fails - - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh) || ci/get_float_ref_branch_name.sh + - # redirect to stdout so that the error message is visible in case of script failure + - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh | tee /dev/tty) - fi ### jobs that test fx encoder -> flt decoder -- GitLab From d82c7937826f9276410931737b0ca83fdfc66fa1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 13:52:53 +0100 Subject: [PATCH 190/329] hopefully fix invalid yml error --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9780e4341..5b9789138 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -989,7 +989,7 @@ build-codec-linux-debugging-make: .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then - *update-scripts-repo - - # redirect to stdout so that the error message is visible in case of script failure + # redirect to stdout so that the error message is visible in case of script failure - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh | tee /dev/tty) - fi -- GitLab From 162f6c3568c2ed9c7990b0445864f2cdc7b7ca81 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 25 Feb 2025 13:57:21 +0100 Subject: [PATCH 191/329] update copyright header to 2025 --- LICENSE.md | 2 +- apps/decoder.c | 2 +- apps/encoder.c | 2 +- apps/renderer.c | 2 +- lib_com/basop32.c | 2 +- lib_com/basop32.h | 2 +- lib_com/basop_com_lpc.c | 2 +- lib_com/basop_lsf_tools.c | 2 +- lib_com/basop_proto_func.h | 2 +- lib_com/basop_settings.h | 2 +- lib_com/basop_tcx_utils.c | 2 +- lib_com/basop_util.c | 2 +- lib_com/basop_util.h | 2 +- lib_com/bitstream.c | 2 +- lib_com/bitstream_fx.c | 2 +- lib_com/cldfb.c | 2 +- lib_com/cng_exc.c | 2 +- lib_com/cnst.h | 2 +- lib_com/common_api_types.h | 2 +- lib_com/core_com_config.c | 2 +- lib_com/deemph.c | 2 +- lib_com/delay_comp.c | 2 +- lib_com/disclaimer.c | 2 +- lib_com/enh40.c | 2 +- lib_com/enh40.h | 2 +- lib_com/enr_1_az.c | 2 +- lib_com/env_adj.c | 2 +- lib_com/env_stab.c | 2 +- lib_com/env_stab_trans.c | 2 +- lib_com/fft.c | 2 +- lib_com/fft_cldfb_fx.c | 2 +- lib_com/fft_fx.c | 2 +- lib_com/fft_rel.c | 2 +- lib_com/fill_spectrum.c | 2 +- lib_com/findpulse.c | 2 +- lib_com/frame_ener.c | 2 +- lib_com/frame_ener_fx.c | 2 +- lib_com/get_gain.c | 2 +- lib_com/get_gain_fx.c | 2 +- lib_com/gs_gains.c | 2 +- lib_com/gs_gains_fx.c | 2 +- lib_com/gs_preech.c | 2 +- lib_com/gs_preech_fx.c | 2 +- lib_com/hp50.c | 2 +- lib_com/hp50_fx.c | 2 +- lib_com/hq2_bit_alloc_fx.c | 2 +- lib_com/hq2_core_com.c | 2 +- lib_com/hq2_core_com_fx.c | 2 +- lib_com/hq2_noise_inject_fx.c | 2 +- lib_com/hq_conf.c | 2 +- lib_com/hq_tools_fx.c | 2 +- lib_com/ifft_rel.c | 2 +- lib_com/int_lsp.c | 2 +- lib_com/interleave_spectrum.c | 2 +- lib_com/interpol.c | 2 +- lib_com/isf_dec_amr_wb_fx.c | 2 +- lib_com/ivas_agc_com_fx.c | 2 +- lib_com/ivas_arith.c | 2 +- lib_com/ivas_avq_pos_reorder_com.c | 2 +- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_cov_smooth.c | 2 +- lib_com/ivas_dirac_com.c | 2 +- lib_com/ivas_entropy_coder_common.c | 2 +- lib_com/ivas_error.h | 2 +- lib_com/ivas_error_utils.h | 2 +- lib_com/ivas_fb_mixer.c | 2 +- lib_com/ivas_filters.c | 2 +- lib_com/ivas_ism_com.c | 2 +- lib_com/ivas_lfe_com.c | 2 +- lib_com/ivas_masa_com.c | 2 +- lib_com/ivas_mc_com.c | 2 +- lib_com/ivas_mc_param_com.c | 2 +- lib_com/ivas_mcmasa_com.c | 2 +- lib_com/ivas_mct_com.c | 2 +- lib_com/ivas_mdct_core_com.c | 2 +- lib_com/ivas_mdct_imdct_fx.c | 2 +- lib_com/ivas_mdft_imdft.c | 2 +- lib_com/ivas_omasa_com.c | 2 +- lib_com/ivas_pca_tools.c | 2 +- lib_com/ivas_prot.h | 2 +- lib_com/ivas_prot_fx.h | 2 +- lib_com/ivas_qmetadata_com.c | 2 +- lib_com/ivas_qspherical_com.c | 2 +- lib_com/ivas_rom_com.c | 2 +- lib_com/ivas_rom_com.h | 2 +- lib_com/ivas_rom_com_fx.c | 2 +- lib_com/ivas_rom_com_fx.h | 2 +- lib_com/ivas_sba_config.c | 2 +- lib_com/ivas_sns_com_fx.c | 2 +- lib_com/ivas_spar_com.c | 2 +- lib_com/ivas_spar_com_quant_util.c | 2 +- lib_com/ivas_stat_com.h | 2 +- lib_com/ivas_stereo_dft_com.c | 2 +- lib_com/ivas_stereo_eclvq_com_fx.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 2 +- lib_com/ivas_stereo_mdct_bands_com.c | 2 +- lib_com/ivas_stereo_mdct_stereo_com.c | 2 +- lib_com/ivas_stereo_psychlpc_com.c | 2 +- lib_com/ivas_stereo_td_bit_alloc.c | 2 +- lib_com/ivas_tools.c | 2 +- lib_com/ivas_transient_det.c | 2 +- lib_com/lag_wind.c | 2 +- lib_com/lerp.c | 2 +- lib_com/limit_t0.c | 2 +- lib_com/logqnorm_fx.c | 2 +- lib_com/longarith.c | 2 +- lib_com/lpc_tools_fx.c | 2 +- lib_com/lsf_tools_fx.c | 2 +- lib_com/mime.h | 2 +- lib_com/modif_fs.c | 2 +- lib_com/move.h | 2 +- lib_com/mslvq_com.c | 2 +- lib_com/mslvq_com_fx.c | 2 +- lib_com/nelp_fx.c | 2 +- lib_com/options.h | 2 +- lib_com/ppp_fx.c | 2 +- lib_com/preemph.c | 2 +- lib_com/prot.h | 2 +- lib_com/prot_fx.h | 2 +- lib_com/reordvct_fx.c | 2 +- lib_com/rom_basop_util.c | 2 +- lib_com/rom_basop_util.h | 2 +- lib_com/rom_com.c | 2 +- lib_com/rom_com.h | 2 +- lib_com/rom_com_fx.c | 2 +- lib_com/rom_com_fx.h | 2 +- lib_com/scale_mem_fx.c | 2 +- lib_com/stat_com.h | 2 +- lib_com/stl.h | 2 +- lib_com/swb_bwe_com_fx.c | 2 +- lib_com/swb_bwe_com_lr_fx.c | 2 +- lib_com/swb_tbe_com.c | 2 +- lib_com/tcx_mdct_window.c | 2 +- lib_com/tools.c | 2 +- lib_com/tools_fx.c | 2 +- lib_com/typedef.h | 2 +- lib_com/wtda.c | 2 +- lib_debug/debug.c | 2 +- lib_debug/debug.h | 2 +- lib_debug/sba_debug.c | 2 +- lib_debug/sba_debug.h | 2 +- lib_debug/snr.c | 2 +- lib_dec/ACcontextMapping_dec.c | 2 +- lib_dec/FEC.c | 2 +- lib_dec/FEC_HQ_core.c | 2 +- lib_dec/FEC_HQ_phase_ecu.c | 2 +- lib_dec/FEC_adapt_codebook.c | 2 +- lib_dec/FEC_clas_estim.c | 2 +- lib_dec/FEC_lsf_estim.c | 2 +- lib_dec/FEC_pitch_estim.c | 2 +- lib_dec/FEC_scale_syn.c | 2 +- lib_dec/LD_music_post_filter.c | 2 +- lib_dec/TonalComponentDetection.c | 2 +- lib_dec/acelp_core_dec.c | 2 +- lib_dec/acelp_core_dec_ivas_fx.c | 2 +- lib_dec/acelp_core_switch_dec.c | 2 +- lib_dec/amr_wb_dec.c | 2 +- lib_dec/ari_dec.c | 2 +- lib_dec/ari_hm_dec.c | 2 +- lib_dec/arith_coder_dec.c | 2 +- lib_dec/avq_dec.c | 2 +- lib_dec/bass_psfilter.c | 2 +- lib_dec/cng_dec.c | 2 +- lib_dec/core_dec_init.c | 2 +- lib_dec/core_dec_reconf.c | 2 +- lib_dec/core_dec_switch.c | 2 +- lib_dec/core_switching_dec.c | 2 +- lib_dec/d_gain2p.c | 2 +- lib_dec/dec2t32.c | 2 +- lib_dec/dec4t64.c | 2 +- lib_dec/dec_LPD.c | 2 +- lib_dec/dec_ace.c | 2 +- lib_dec/dec_acelp.c | 2 +- lib_dec/dec_acelp_tcx_main.c | 2 +- lib_dec/dec_amr_wb.c | 2 +- lib_dec/dec_gen_voic.c | 2 +- lib_dec/dec_higher_acelp.c | 2 +- lib_dec/dec_nelp.c | 2 +- lib_dec/dec_pit_exc.c | 2 +- lib_dec/dec_post.c | 2 +- lib_dec/dec_ppp.c | 2 +- lib_dec/dec_prm.c | 2 +- lib_dec/dec_tcx.c | 2 +- lib_dec/dec_tran.c | 2 +- lib_dec/dec_uv.c | 2 +- lib_dec/decision_matrix_dec.c | 2 +- lib_dec/dlpc_avq.c | 2 +- lib_dec/dlpc_stoch.c | 2 +- lib_dec/er_dec_acelp.c | 2 +- lib_dec/er_dec_tcx.c | 2 +- lib_dec/er_scale_syn.c | 2 +- lib_dec/er_sync_exc.c | 2 +- lib_dec/er_util.c | 2 +- lib_dec/evs_dec.c | 2 +- lib_dec/fd_cng_dec.c | 2 +- lib_dec/gain_dec.c | 2 +- lib_dec/gaus_dec.c | 2 +- lib_dec/gs_dec.c | 2 +- lib_dec/gs_dec_amr_wb.c | 2 +- lib_dec/hdecnrm.c | 2 +- lib_dec/hf_synth.c | 2 +- lib_dec/hq_classifier_dec.c | 2 +- lib_dec/hq_conf_fec.c | 2 +- lib_dec/hq_core_dec.c | 2 +- lib_dec/hq_env_dec.c | 2 +- lib_dec/hq_hr_dec.c | 2 +- lib_dec/hq_lr_dec.c | 2 +- lib_dec/igf_dec.c | 2 +- lib_dec/igf_scf_dec.c | 2 +- lib_dec/init_dec.c | 2 +- lib_dec/inov_dec.c | 2 +- lib_dec/ivas_agc_dec.c | 2 +- lib_dec/ivas_agc_dec_fx.c | 2 +- lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_core_dec.c | 2 +- lib_dec/ivas_corecoder_dec_reconfig.c | 2 +- lib_dec/ivas_cpe_dec.c | 2 +- lib_dec/ivas_cpe_dec_fx.c | 2 +- lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_decision_matrix_dec.c | 2 +- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_dirac_output_synthesis_cov.c | 2 +- lib_dec/ivas_entropy_decoder.c | 2 +- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_ism_dec.c | 2 +- lib_dec/ivas_ism_dtx_dec.c | 2 +- lib_dec/ivas_ism_metadata_dec.c | 2 +- lib_dec/ivas_ism_param_dec.c | 2 +- lib_dec/ivas_ism_renderer.c | 2 +- lib_dec/ivas_jbm_dec.c | 2 +- lib_dec/ivas_lfe_dec.c | 2 +- lib_dec/ivas_lfe_dec_fx.c | 2 +- lib_dec/ivas_lfe_plc.c | 2 +- lib_dec/ivas_lfe_plc_fx.c | 2 +- lib_dec/ivas_ls_custom_dec.c | 2 +- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_mc_paramupmix_dec.c | 2 +- lib_dec/ivas_mcmasa_dec.c | 2 +- lib_dec/ivas_mct_core_dec.c | 2 +- lib_dec/ivas_mct_dec.c | 2 +- lib_dec/ivas_mct_dec_mct.c | 2 +- lib_dec/ivas_mct_dec_mct_fx.c | 2 +- lib_dec/ivas_mdct_core_dec.c | 2 +- lib_dec/ivas_mono_dmx_renderer.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 2 +- lib_dec/ivas_out_setup_conversion.c | 2 +- lib_dec/ivas_output_config.c | 2 +- lib_dec/ivas_pca_dec.c | 2 +- lib_dec/ivas_pca_dec_fx.c | 2 +- lib_dec/ivas_post_proc.c | 2 +- lib_dec/ivas_qmetadata_dec.c | 2 +- lib_dec/ivas_qspherical_dec.c | 2 +- lib_dec/ivas_range_uni_dec.c | 2 +- lib_dec/ivas_rom_dec.c | 2 +- lib_dec/ivas_rom_dec.h | 2 +- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_sba_dirac_stereo_dec.c | 2 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 +- lib_dec/ivas_sba_rendering_internal.c | 2 +- lib_dec/ivas_sce_dec.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_sns_dec.c | 2 +- lib_dec/ivas_sns_dec_fx.c | 2 +- lib_dec/ivas_spar_decoder.c | 2 +- lib_dec/ivas_spar_md_dec.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/ivas_stereo_adapt_GR_dec.c | 2 +- lib_dec/ivas_stereo_cng_dec.c | 2 +- lib_dec/ivas_stereo_dft_dec.c | 2 +- lib_dec/ivas_stereo_dft_dec_dmx.c | 2 +- lib_dec/ivas_stereo_dft_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_plc.c | 2 +- lib_dec/ivas_stereo_dft_plc_fx.c | 2 +- lib_dec/ivas_stereo_eclvq_dec.c | 2 +- lib_dec/ivas_stereo_esf_dec.c | 2 +- lib_dec/ivas_stereo_ica_dec.c | 2 +- lib_dec/ivas_stereo_icbwe_dec.c | 2 +- lib_dec/ivas_stereo_mdct_core_dec.c | 2 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec.c | 2 +- lib_dec/ivas_stereo_switching_dec.c | 2 +- lib_dec/ivas_stereo_td_dec.c | 2 +- lib_dec/ivas_svd_dec.c | 2 +- lib_dec/ivas_tcx_core_dec.c | 2 +- lib_dec/ivas_td_low_rate_dec.c | 2 +- lib_dec/jbm_jb4_circularbuffer.c | 2 +- lib_dec/jbm_jb4_circularbuffer.h | 2 +- lib_dec/jbm_jb4_inputbuffer.c | 2 +- lib_dec/jbm_jb4_inputbuffer.h | 2 +- lib_dec/jbm_jb4_jmf.c | 2 +- lib_dec/jbm_jb4_jmf.h | 2 +- lib_dec/jbm_jb4sb.c | 2 +- lib_dec/jbm_jb4sb.h | 2 +- lib_dec/jbm_pcmdsp_apa.c | 2 +- lib_dec/jbm_pcmdsp_apa.h | 2 +- lib_dec/jbm_pcmdsp_fifo.c | 2 +- lib_dec/jbm_pcmdsp_fifo.h | 2 +- lib_dec/jbm_pcmdsp_similarityestimation.c | 2 +- lib_dec/jbm_pcmdsp_similarityestimation.h | 2 +- lib_dec/jbm_pcmdsp_window.c | 2 +- lib_dec/jbm_pcmdsp_window.h | 2 +- lib_dec/lead_deindexing.c | 2 +- lib_dec/lib_dec.c | 2 +- lib_dec/lib_dec.h | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_dec/lp_exc_d.c | 2 +- lib_dec/lsf_dec.c | 2 +- lib_dec/lsf_msvq_ma_dec.c | 2 +- lib_dec/nelp_dec.c | 2 +- lib_dec/peak_vq_dec.c | 2 +- lib_dec/pit_dec.c | 2 +- lib_dec/pitch_extr.c | 2 +- lib_dec/post_dec.c | 2 +- lib_dec/ppp_dec.c | 2 +- lib_dec/pvq_core_dec.c | 2 +- lib_dec/pvq_decode.c | 2 +- lib_dec/range_dec.c | 2 +- lib_dec/re8_dec.c | 2 +- lib_dec/rom_dec.c | 2 +- lib_dec/rom_dec.h | 2 +- lib_dec/rst_dec.c | 2 +- lib_dec/stat_dec.h | 2 +- lib_dec/stat_noise_uv_dec.c | 2 +- lib_dec/swb_bwe_dec.c | 2 +- lib_dec/swb_bwe_dec_hr.c | 2 +- lib_dec/swb_bwe_dec_lr.c | 2 +- lib_dec/swb_tbe_dec.c | 2 +- lib_dec/syn_outp.c | 2 +- lib_dec/tcq_core_dec.c | 2 +- lib_dec/tcx_utils_dec.c | 2 +- lib_dec/tns_base_dec.c | 2 +- lib_dec/tonalMDCTconcealment.c | 2 +- lib_dec/transition_dec.c | 2 +- lib_dec/updt_dec.c | 2 +- lib_dec/vlpc_1st_dec.c | 2 +- lib_dec/vlpc_2st_dec.c | 2 +- lib_dec/voiced_dec.c | 2 +- lib_dec/waveadjust_fec_dec.c | 2 +- lib_enc/ari_enc.c | 2 +- lib_enc/ari_hm_enc.c | 2 +- lib_enc/arith_coder_enc.c | 2 +- lib_enc/avq_cod.c | 2 +- lib_enc/bass_psfilter_enc.c | 2 +- lib_enc/bw_detect.c | 2 +- lib_enc/cng_enc.c | 2 +- lib_enc/cod2t32.c | 2 +- lib_enc/cod4t64.c | 2 +- lib_enc/cod4t64_fast.c | 2 +- lib_enc/cod_ace.c | 2 +- lib_enc/cod_tcx.c | 2 +- lib_enc/cod_uv.c | 2 +- lib_enc/comvad_decision.c | 2 +- lib_enc/cor_shif.c | 2 +- lib_enc/core_enc_2div.c | 2 +- lib_enc/core_enc_init.c | 2 +- lib_enc/core_enc_ol.c | 2 +- lib_enc/core_enc_reconf.c | 2 +- lib_enc/core_enc_switch.c | 2 +- lib_enc/core_enc_updt.c | 2 +- lib_enc/core_switching_enc.c | 2 +- lib_enc/corr_xh.c | 2 +- lib_enc/decision_matrix_enc.c | 2 +- lib_enc/detect_transient.c | 2 +- lib_enc/detect_transient_fx.c | 2 +- lib_enc/diffcod.c | 2 +- lib_enc/dtx.c | 2 +- lib_enc/enc_acelp.c | 2 +- lib_enc/enc_acelp_tcx_main.c | 2 +- lib_enc/enc_acelpx.c | 2 +- lib_enc/enc_amr_wb.c | 2 +- lib_enc/enc_gain.c | 2 +- lib_enc/enc_gen_voic.c | 2 +- lib_enc/enc_prm.c | 2 +- lib_enc/fd_cng_enc.c | 2 +- lib_enc/find_tilt.c | 2 +- lib_enc/find_uv.c | 2 +- lib_enc/find_wsp.c | 2 +- lib_enc/frame_spec_dif_cor_rate.c | 2 +- lib_enc/gain_enc.c | 2 +- lib_enc/gp_clip_fx.c | 2 +- lib_enc/gs_enc.c | 2 +- lib_enc/guided_plc_enc.c | 2 +- lib_enc/hf_cod_amrwb.c | 2 +- lib_enc/hq_classifier_enc.c | 2 +- lib_enc/hq_core_enc.c | 2 +- lib_enc/hq_env_enc.c | 2 +- lib_enc/hq_hr_enc.c | 2 +- lib_enc/hq_lr_enc.c | 2 +- lib_enc/hvq_enc.c | 2 +- lib_enc/igf_enc.c | 2 +- lib_enc/igf_scf_enc.c | 2 +- lib_enc/init_enc.c | 2 +- lib_enc/inov_enc.c | 2 +- lib_enc/isf_enc_amr_wb.c | 2 +- lib_enc/isf_enc_amr_wb_fx.c | 2 +- lib_enc/ivas_agc_enc.c | 2 +- lib_enc/ivas_core_enc.c | 2 +- lib_enc/ivas_core_pre_proc.c | 2 +- lib_enc/ivas_core_pre_proc_front.c | 2 +- lib_enc/ivas_corecoder_enc_reconfig.c | 2 +- lib_enc/ivas_cpe_enc.c | 2 +- lib_enc/ivas_decision_matrix_enc.c | 2 +- lib_enc/ivas_dirac_enc.c | 2 +- lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_enc_cov_handler.c | 2 +- lib_enc/ivas_entropy_coder.c | 2 +- lib_enc/ivas_front_vad.c | 2 +- lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_ism_dtx_enc.c | 2 +- lib_enc/ivas_ism_enc.c | 2 +- lib_enc/ivas_ism_metadata_enc.c | 2 +- lib_enc/ivas_ism_param_enc.c | 2 +- lib_enc/ivas_lfe_enc.c | 2 +- lib_enc/ivas_masa_enc.c | 2 +- lib_enc/ivas_mc_param_enc.c | 2 +- lib_enc/ivas_mc_paramupmix_enc.c | 2 +- lib_enc/ivas_mcmasa_enc.c | 2 +- lib_enc/ivas_mct_core_enc.c | 2 +- lib_enc/ivas_mct_enc.c | 2 +- lib_enc/ivas_mct_enc_mct.c | 2 +- lib_enc/ivas_mdct_core_enc.c | 2 +- lib_enc/ivas_omasa_enc.c | 2 +- lib_enc/ivas_osba_enc.c | 2 +- lib_enc/ivas_pca_enc.c | 2 +- lib_enc/ivas_qmetadata_enc.c | 2 +- lib_enc/ivas_qspherical_enc.c | 2 +- lib_enc/ivas_range_uni_enc.c | 2 +- lib_enc/ivas_rom_enc.h | 2 +- lib_enc/ivas_rom_enc_fx.c | 2 +- lib_enc/ivas_sba_enc.c | 2 +- lib_enc/ivas_sce_enc.c | 2 +- lib_enc/ivas_sns_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 2 +- lib_enc/ivas_spar_md_enc.c | 2 +- lib_enc/ivas_stat_enc.h | 2 +- lib_enc/ivas_stereo_adapt_GR_enc.c | 2 +- lib_enc/ivas_stereo_classifier.c | 2 +- lib_enc/ivas_stereo_cng_enc.c | 2 +- lib_enc/ivas_stereo_dft_enc.c | 2 +- lib_enc/ivas_stereo_dft_enc_itd.c | 2 +- lib_enc/ivas_stereo_dft_td_itd.c | 2 +- lib_enc/ivas_stereo_dmx_evs.c | 2 +- lib_enc/ivas_stereo_eclvq_enc.c | 2 +- lib_enc/ivas_stereo_ica_enc.c | 2 +- lib_enc/ivas_stereo_icbwe_enc.c | 2 +- lib_enc/ivas_stereo_mdct_core_enc.c | 2 +- lib_enc/ivas_stereo_mdct_igf_enc.c | 2 +- lib_enc/ivas_stereo_mdct_stereo_enc.c | 2 +- lib_enc/ivas_stereo_switching_enc.c | 2 +- lib_enc/ivas_stereo_td_analysis.c | 2 +- lib_enc/ivas_stereo_td_enc.c | 2 +- lib_enc/ivas_tcx_core_enc.c | 2 +- lib_enc/ivas_td_low_rate_enc.c | 2 +- lib_enc/lead_indexing.c | 2 +- lib_enc/lib_enc.c | 2 +- lib_enc/lib_enc.h | 2 +- lib_enc/long_enr.c | 2 +- lib_enc/lp_exc_e.c | 2 +- lib_enc/lsf_enc.c | 2 +- lib_enc/lsf_msvq_ma_enc.c | 2 +- lib_enc/ltd_stable.c | 2 +- lib_enc/mdct_classifier.c | 2 +- lib_enc/mdct_selector.c | 2 +- lib_enc/mslvq_enc.c | 2 +- lib_enc/multi_harm.c | 2 +- lib_enc/nelp_enc.c | 2 +- lib_enc/nelp_enc_fx.c | 2 +- lib_enc/pit_enc.c | 2 +- lib_enc/pitch_ol.c | 2 +- lib_enc/pitch_ol2.c | 2 +- lib_enc/plc_enc_ext.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_enc/rom_enc.c | 2 +- lib_enc/rom_enc.h | 2 +- lib_enc/setmodeindex.c | 2 +- lib_enc/stat_enc.h | 2 +- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- lib_enc/swb_tbe_enc.c | 2 +- lib_rend/ivas_allrad_dec.c | 2 +- lib_rend/ivas_crend.c | 2 +- lib_rend/ivas_dirac_ana.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- lib_rend/ivas_dirac_decorr_dec.c | 2 +- lib_rend/ivas_dirac_onsets_dec.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 2 +- lib_rend/ivas_dirac_rend.c | 2 +- lib_rend/ivas_efap.c | 2 +- lib_rend/ivas_hrtf.c | 2 +- lib_rend/ivas_limiter.c | 2 +- lib_rend/ivas_masa_merge.c | 2 +- lib_rend/ivas_mcmasa_ana.c | 2 +- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_objectRenderer_hrFilt.c | 2 +- lib_rend/ivas_objectRenderer_mix.c | 2 +- lib_rend/ivas_objectRenderer_sfx.c | 2 +- lib_rend/ivas_objectRenderer_sources.c | 2 +- lib_rend/ivas_objectRenderer_vec.c | 2 +- lib_rend/ivas_omasa_ana.c | 2 +- lib_rend/ivas_orient_trk.c | 2 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_prot_rend.h | 2 +- lib_rend/ivas_reflections.c | 2 +- lib_rend/ivas_render_config.c | 2 +- lib_rend/ivas_reverb.c | 2 +- lib_rend/ivas_reverb_delay_line.c | 2 +- lib_rend/ivas_reverb_fft_filter.c | 2 +- lib_rend/ivas_reverb_filter_design.c | 2 +- lib_rend/ivas_reverb_iir_filter.c | 2 +- lib_rend/ivas_reverb_utils.c | 2 +- lib_rend/ivas_rom_TdBinauralRenderer.c | 2 +- lib_rend/ivas_rom_TdBinauralRenderer.h | 2 +- lib_rend/ivas_rom_binauralRenderer.c | 2 +- lib_rend/ivas_rom_binauralRenderer.h | 2 +- lib_rend/ivas_rom_binaural_crend_head.c | 2 +- lib_rend/ivas_rom_binaural_crend_head.h | 2 +- lib_rend/ivas_rom_rend.c | 2 +- lib_rend/ivas_rom_rend.h | 2 +- lib_rend/ivas_rotation.c | 2 +- lib_rend/ivas_sba_rendering.c | 2 +- lib_rend/ivas_shoebox.c | 2 +- lib_rend/ivas_stat_rend.h | 2 +- lib_rend/ivas_td_decorr.c | 2 +- lib_rend/ivas_vbap.c | 2 +- lib_rend/lib_rend.c | 2 +- lib_rend/lib_rend.h | 2 +- lib_util/audio_file_reader.c | 2 +- lib_util/audio_file_reader.h | 2 +- lib_util/audio_file_writer.c | 2 +- lib_util/audio_file_writer.h | 2 +- lib_util/bitstream_reader.c | 2 +- lib_util/bitstream_reader.h | 2 +- lib_util/bitstream_writer.c | 2 +- lib_util/bitstream_writer.h | 2 +- lib_util/cmdl_tools.c | 2 +- lib_util/cmdl_tools.h | 2 +- lib_util/cmdln_parser.c | 2 +- lib_util/cmdln_parser.h | 2 +- lib_util/evs_rtp_payload.c | 2 +- lib_util/evs_rtp_payload.h | 2 +- lib_util/g192.c | 2 +- lib_util/g192.h | 2 +- lib_util/hrtf_file_reader.c | 2 +- lib_util/hrtf_file_reader.h | 2 +- lib_util/ism_file_reader.c | 2 +- lib_util/ism_file_reader.h | 2 +- lib_util/ism_file_writer.c | 2 +- lib_util/ism_file_writer.h | 2 +- lib_util/jbm_file_reader.c | 2 +- lib_util/jbm_file_reader.h | 2 +- lib_util/jbm_file_writer.c | 2 +- lib_util/jbm_file_writer.h | 2 +- lib_util/ls_custom_file_reader.c | 2 +- lib_util/ls_custom_file_reader.h | 2 +- lib_util/masa_file_reader.c | 2 +- lib_util/masa_file_reader.h | 2 +- lib_util/masa_file_writer.c | 2 +- lib_util/masa_file_writer.h | 2 +- lib_util/mime_io.c | 2 +- lib_util/mime_io.h | 2 +- lib_util/render_config_reader.c | 2 +- lib_util/render_config_reader.h | 2 +- lib_util/rotation_file_reader.c | 2 +- lib_util/rotation_file_reader.h | 2 +- lib_util/rtpdump.c | 2 +- lib_util/rtpdump.h | 2 +- lib_util/test_fft.c | 2 +- lib_util/test_fft.h | 2 +- lib_util/test_mdct.c | 2 +- lib_util/tinywavein_c.h | 2 +- lib_util/tinywaveout_c.h | 2 +- lib_util/vector3_pair_file_reader.c | 2 +- lib_util/vector3_pair_file_reader.h | 2 +- readme.txt | 2 +- 576 files changed, 576 insertions(+), 576 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 1c60a85b1..ca74eaf48 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/decoder.c b/apps/decoder.c index 058722569..1c59a02e7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/encoder.c b/apps/encoder.c index b06b5de0d..b6526ae2b 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/apps/renderer.c b/apps/renderer.c index f5c0a8847..81750925e 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 200757026..7fab24660 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop32.h b/lib_com/basop32.h index 96fd8d166..9bbf24f1c 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_com_lpc.c b/lib_com/basop_com_lpc.c index 5de4fa5d3..5cfb3bed0 100644 --- a/lib_com/basop_com_lpc.c +++ b/lib_com/basop_com_lpc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_lsf_tools.c b/lib_com/basop_lsf_tools.c index 3e49411d6..2c49ad4cf 100644 --- a/lib_com/basop_lsf_tools.c +++ b/lib_com/basop_lsf_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h index be8b46782..29db9c9c1 100644 --- a/lib_com/basop_proto_func.h +++ b/lib_com/basop_proto_func.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h index a2ef70417..9a344afc4 100644 --- a/lib_com/basop_settings.h +++ b/lib_com/basop_settings.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index 17f0e23ba..378faae0f 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 19b654e5e..b7ee35ab3 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 92994542e..a6db7dc8d 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 9e61c2571..e5754fa35 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 1acf69c2a..6163fc4ff 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index b6eafd993..1907ef327 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c index 794b6de29..494305e6f 100644 --- a/lib_com/cng_exc.c +++ b/lib_com/cng_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 197fbd3c4..26903f525 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index b98f2e7d1..553a34f56 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index e002617ab..8d360c6a3 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/deemph.c b/lib_com/deemph.c index 8cddd7580..b2b43cf72 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 38a077f9e..9e6c450cd 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index 44fc3627a..ba0973f97 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enh40.c b/lib_com/enh40.c index 89960030f..570f4b211 100644 --- a/lib_com/enh40.c +++ b/lib_com/enh40.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enh40.h b/lib_com/enh40.h index ff1a86b92..9c3742f3e 100644 --- a/lib_com/enh40.h +++ b/lib_com/enh40.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index e11a500db..81fb78262 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c index 554cf1dbe..18520e188 100644 --- a/lib_com/env_adj.c +++ b/lib_com/env_adj.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c index be19b55e0..b80fd0a8b 100644 --- a/lib_com/env_stab.c +++ b/lib_com/env_stab.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c index e3f98d881..8c6ec265f 100644 --- a/lib_com/env_stab_trans.c +++ b/lib_com/env_stab_trans.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft.c b/lib_com/fft.c index be42d29cb..352a24be9 100644 --- a/lib_com/fft.c +++ b/lib_com/fft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_cldfb_fx.c b/lib_com/fft_cldfb_fx.c index 80e643362..b26b1bc9f 100644 --- a/lib_com/fft_cldfb_fx.c +++ b/lib_com/fft_cldfb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index ba895d83c..1b095e346 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index aa3b578bd..839b2faaf 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c index 5a4f7c4bc..12ed75f0a 100644 --- a/lib_com/fill_spectrum.c +++ b/lib_com/fill_spectrum.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c index cc7d2bf3b..f2347d5b3 100644 --- a/lib_com/findpulse.c +++ b/lib_com/findpulse.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c index 40e1167e5..e89c4dfad 100644 --- a/lib_com/frame_ener.c +++ b/lib_com/frame_ener.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index f89c1264b..4428c0796 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c index bf4c1adfb..89b5fa3de 100644 --- a/lib_com/get_gain.c +++ b/lib_com/get_gain.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c index 66abe96ae..d4c2413c3 100644 --- a/lib_com/get_gain_fx.c +++ b/lib_com/get_gain_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c index 13fdbd67c..9adb448a4 100644 --- a/lib_com/gs_gains.c +++ b/lib_com/gs_gains.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index d6aee58c5..35236b603 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c index a2b2405db..58b49172d 100644 --- a/lib_com/gs_preech.c +++ b/lib_com/gs_preech.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index a75604a14..9d905bcf2 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hp50.c b/lib_com/hp50.c index cd9ed3e98..6920063d4 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index a1700047e..84bbf8b3c 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c index 4742c81c2..61d00ce98 100644 --- a/lib_com/hq2_bit_alloc_fx.c +++ b/lib_com/hq2_bit_alloc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c index a30655394..bc4edb869 100644 --- a/lib_com/hq2_core_com.c +++ b/lib_com/hq2_core_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index 86c02fa88..bf0af5e87 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index b85aaa027..bc96fe0f8 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c index 84b843fb4..c139a493c 100644 --- a/lib_com/hq_conf.c +++ b/lib_com/hq_conf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 7b7da27e6..4426f85d9 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index e3b62bdb5..423eea46d 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index 37ca1ca4b..0f673b8fd 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c index f65b7a5c5..745ee6ac3 100644 --- a/lib_com/interleave_spectrum.c +++ b/lib_com/interleave_spectrum.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/interpol.c b/lib_com/interpol.c index ceafad116..45021f1c2 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/isf_dec_amr_wb_fx.c b/lib_com/isf_dec_amr_wb_fx.c index 3b98b1346..5ab82ee6d 100644 --- a/lib_com/isf_dec_amr_wb_fx.c +++ b/lib_com/isf_dec_amr_wb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 9159fa259..b2c09fa07 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c index 56f4c599c..2f729bbd4 100644 --- a/lib_com/ivas_arith.c +++ b/lib_com/ivas_arith.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c index cd50e9ab2..ac539b787 100644 --- a/lib_com/ivas_avq_pos_reorder_com.c +++ b/lib_com/ivas_avq_pos_reorder_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1fe54d164..6612fac1f 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 8b13f3fd1..445ea8c78 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 2704c1f08..cf942cc4a 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c index 8793723cd..d28828d6f 100644 --- a/lib_com/ivas_entropy_coder_common.c +++ b/lib_com/ivas_entropy_coder_common.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 1198008f6..bbf951ab3 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_error_utils.h b/lib_com/ivas_error_utils.h index b686cf283..0c3d5ce04 100644 --- a/lib_com/ivas_error_utils.h +++ b/lib_com/ivas_error_utils.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index df8f7d0f5..498de0188 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index 32ebe479f..7705deb6a 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 1dd7f0f87..74e9641aa 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c index 56f14a18b..4d993d64f 100644 --- a/lib_com/ivas_lfe_com.c +++ b/lib_com/ivas_lfe_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 1ff433344..35db926d0 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c index 39ba64d0e..88d6c1b5e 100644 --- a/lib_com/ivas_mc_com.c +++ b/lib_com/ivas_mc_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c index be3f35606..d69da849a 100644 --- a/lib_com/ivas_mc_param_com.c +++ b/lib_com/ivas_mc_param_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c index fe29c8486..da0b8f1c4 100644 --- a/lib_com/ivas_mcmasa_com.c +++ b/lib_com/ivas_mcmasa_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com.c index 3d2d4c99b..b220d69a7 100644 --- a/lib_com/ivas_mct_com.c +++ b/lib_com/ivas_mct_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdct_core_com.c b/lib_com/ivas_mdct_core_com.c index f3ad466cc..a5cfb8673 100644 --- a/lib_com/ivas_mdct_core_com.c +++ b/lib_com/ivas_mdct_core_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdct_imdct_fx.c b/lib_com/ivas_mdct_imdct_fx.c index 37c525109..542f5ca74 100644 --- a/lib_com/ivas_mdct_imdct_fx.c +++ b/lib_com/ivas_mdct_imdct_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c index 4ed267ba5..0f24fba81 100644 --- a/lib_com/ivas_mdft_imdft.c +++ b/lib_com/ivas_mdft_imdft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index a86f90acb..eb230b224 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools.c index 6ccc07523..5689e81c0 100644 --- a/lib_com/ivas_pca_tools.c +++ b/lib_com/ivas_pca_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5ea7b0765..2493add28 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 1682c255b..80bdda3c2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index 85d4332e0..cbc67de00 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c index c3608d248..8ef48be2e 100644 --- a/lib_com/ivas_qspherical_com.c +++ b/lib_com/ivas_qspherical_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 5a864835c..560d1ee8e 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index b58e183eb..6004760e3 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index cc138d070..8ea2b91e4 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h index e1f4d0a6e..3344a35d2 100644 --- a/lib_com/ivas_rom_com_fx.h +++ b/lib_com/ivas_rom_com_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 370e8caa4..94ceb8e3c 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index 5931c4ea1..788fb3c56 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 14de6cc15..0ebae0de6 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 81044fb40..0f0e003dd 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 090db04db..249d1e963 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com.c index 8b377bdbc..1157fffcf 100644 --- a/lib_com/ivas_stereo_dft_com.c +++ b/lib_com/ivas_stereo_dft_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index 30d95afe9..b4fb66429 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index be9f35868..78a3c90ca 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c index 8c21798b6..b1750fd16 100644 --- a/lib_com/ivas_stereo_mdct_bands_com.c +++ b/lib_com/ivas_stereo_mdct_bands_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com.c index 45e734fea..dd94358af 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com.c +++ b/lib_com/ivas_stereo_mdct_stereo_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index e34e8fd18..996b262db 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 0f5eb402e..14ab8131e 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index d6210dfc7..ec3c30723 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index dccf4db02..b5ea507eb 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c index 505cc0753..e0871fa70 100644 --- a/lib_com/lag_wind.c +++ b/lib_com/lag_wind.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 2fd9321be..bb33d9922 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/limit_t0.c b/lib_com/limit_t0.c index dfbfbb796..d49cad283 100644 --- a/lib_com/limit_t0.c +++ b/lib_com/limit_t0.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c index c7852bbe4..833ff03fb 100644 --- a/lib_com/logqnorm_fx.c +++ b/lib_com/logqnorm_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 68ba282d5..66c5dd15e 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index 1c0fb7500..ef6c0b0ff 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 0a8a86aee..08e74b9b7 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mime.h b/lib_com/mime.h index 80d984617..6e9e5fc87 100644 --- a/lib_com/mime.h +++ b/lib_com/mime.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 06119b69e..4af93522d 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/move.h b/lib_com/move.h index 5c325fb1d..7762ec79a 100644 --- a/lib_com/move.h +++ b/lib_com/move.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index bab16f165..34e2083b9 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 7c6658e8f..14c9b6d97 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c index b37d57093..39d57299e 100644 --- a/lib_com/nelp_fx.c +++ b/lib_com/nelp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/options.h b/lib_com/options.h index 288145122..03b40ce1c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ppp_fx.c b/lib_com/ppp_fx.c index 791813dc7..cc6b59bdb 100644 --- a/lib_com/ppp_fx.c +++ b/lib_com/ppp_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/preemph.c b/lib_com/preemph.c index 66a12c621..490a18aef 100644 --- a/lib_com/preemph.c +++ b/lib_com/preemph.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/prot.h b/lib_com/prot.h index 647a18bf1..16f4659a0 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index cf7072cf5..284986bb4 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/reordvct_fx.c b/lib_com/reordvct_fx.c index 3b741203a..62eb2f352 100644 --- a/lib_com/reordvct_fx.c +++ b/lib_com/reordvct_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c index 4a0eed6b6..c3bfc6eef 100644 --- a/lib_com/rom_basop_util.c +++ b/lib_com/rom_basop_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_basop_util.h b/lib_com/rom_basop_util.h index f2e81f0a1..e7811db89 100644 --- a/lib_com/rom_basop_util.h +++ b/lib_com/rom_basop_util.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 5e61db76e..bad47f065 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 19447609c..274a33a18 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index e669a8995..611658884 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h index 5c30ad5da..29e763757 100644 --- a/lib_com/rom_com_fx.h +++ b/lib_com/rom_com_fx.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 9dd997680..002821050 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 45a16dc1a..c468ef114 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stl.h b/lib_com/stl.h index 6643f5948..0de974226 100644 --- a/lib_com/stl.h +++ b/lib_com/stl.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 09f72b230..eda099cd9 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 7c2c35551..d0b8d0100 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 105c4db15..2aa781a43 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index 110a1160d..cececd8f5 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tools.c b/lib_com/tools.c index 733e5634a..4d9f5e956 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 063f49fc4..efa9d7e5a 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/typedef.h b/lib_com/typedef.h index 3d86229dd..d3aba3e98 100644 --- a/lib_com/typedef.h +++ b/lib_com/typedef.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/wtda.c b/lib_com/wtda.c index 6bce31db9..a7ea5314c 100644 --- a/lib_com/wtda.c +++ b/lib_com/wtda.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/debug.c b/lib_debug/debug.c index 23de1bd36..0cfa00e81 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/debug.h b/lib_debug/debug.h index e88def922..64b1de154 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c index a85bc7be0..c05ae96ef 100644 --- a/lib_debug/sba_debug.c +++ b/lib_debug/sba_debug.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/sba_debug.h b/lib_debug/sba_debug.h index 60f74401d..2be427d52 100644 --- a/lib_debug/sba_debug.h +++ b/lib_debug/sba_debug.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/snr.c b/lib_debug/snr.c index bd8af44e8..cf15a2907 100644 --- a/lib_debug/snr.c +++ b/lib_debug/snr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c index cf5b4a9b7..186a22bc7 100644 --- a/lib_dec/ACcontextMapping_dec.c +++ b/lib_dec/ACcontextMapping_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC.c b/lib_dec/FEC.c index fc669bf26..3dd25fd27 100644 --- a/lib_dec/FEC.c +++ b/lib_dec/FEC.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c index 794f6dab3..6a119b365 100644 --- a/lib_dec/FEC_HQ_core.c +++ b/lib_dec/FEC_HQ_core.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 2df90bf11..85b25b336 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_adapt_codebook.c b/lib_dec/FEC_adapt_codebook.c index b2dcc5560..f07b5952a 100644 --- a/lib_dec/FEC_adapt_codebook.c +++ b/lib_dec/FEC_adapt_codebook.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c index 4d461a0dc..77501d3fa 100644 --- a/lib_dec/FEC_clas_estim.c +++ b/lib_dec/FEC_clas_estim.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_lsf_estim.c b/lib_dec/FEC_lsf_estim.c index 1fa0758f7..49a4adafc 100644 --- a/lib_dec/FEC_lsf_estim.c +++ b/lib_dec/FEC_lsf_estim.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_pitch_estim.c b/lib_dec/FEC_pitch_estim.c index 1b9ed9484..bae1a8539 100644 --- a/lib_dec/FEC_pitch_estim.c +++ b/lib_dec/FEC_pitch_estim.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_scale_syn.c b/lib_dec/FEC_scale_syn.c index 7d23dd6f7..5c3581f4f 100644 --- a/lib_dec/FEC_scale_syn.c +++ b/lib_dec/FEC_scale_syn.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c index b2b69cc45..494df80ce 100644 --- a/lib_dec/LD_music_post_filter.c +++ b/lib_dec/LD_music_post_filter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c index 040d4569d..a8ad442c0 100644 --- a/lib_dec/TonalComponentDetection.c +++ b/lib_dec/TonalComponentDetection.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 5350d6dbc..2374f1b7c 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index e9e4625ce..066a3eab5 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index fd4f3cb7c..b25a46f03 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index d441f6ead..47e1f0be1 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c index 8dedcea1e..b45cb5d9c 100644 --- a/lib_dec/ari_dec.c +++ b/lib_dec/ari_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index f290ca9fb..da7722325 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index a9579d5d2..93bd8877c 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/avq_dec.c b/lib_dec/avq_dec.c index 27bb2c324..1e54dc9d9 100644 --- a/lib_dec/avq_dec.c +++ b/lib_dec/avq_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index a33149fff..478a81474 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c index 515dd295a..5f2ee4f7e 100644 --- a/lib_dec/cng_dec.c +++ b/lib_dec/cng_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 48464fb35..37c397bbf 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c index f8f6d6a6f..6bcd541ef 100644 --- a/lib_dec/core_dec_reconf.c +++ b/lib_dec/core_dec_reconf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 9fb0cf788..09bd8e846 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index a8041cd53..4c48a6fa8 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/d_gain2p.c b/lib_dec/d_gain2p.c index bcdeaa041..cc19164ca 100644 --- a/lib_dec/d_gain2p.c +++ b/lib_dec/d_gain2p.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec2t32.c b/lib_dec/dec2t32.c index 6b94be229..13c9ebade 100644 --- a/lib_dec/dec2t32.c +++ b/lib_dec/dec2t32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec4t64.c b/lib_dec/dec4t64.c index e931b0a68..d448123b1 100644 --- a/lib_dec/dec4t64.c +++ b/lib_dec/dec4t64.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index 9af4fa20e..4c0b6a79a 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c index da306d76e..76754d2e6 100644 --- a/lib_dec/dec_ace.c +++ b/lib_dec/dec_ace.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_acelp.c b/lib_dec/dec_acelp.c index 7cae62391..075822eb6 100644 --- a/lib_dec/dec_acelp.c +++ b/lib_dec/dec_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c index 4e5d4e3ae..d8b8509d9 100644 --- a/lib_dec/dec_acelp_tcx_main.c +++ b/lib_dec/dec_acelp_tcx_main.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_amr_wb.c b/lib_dec/dec_amr_wb.c index 0874e988a..4cf26936b 100644 --- a/lib_dec/dec_amr_wb.c +++ b/lib_dec/dec_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_gen_voic.c b/lib_dec/dec_gen_voic.c index fd4f3cb7c..b25a46f03 100644 --- a/lib_dec/dec_gen_voic.c +++ b/lib_dec/dec_gen_voic.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_higher_acelp.c b/lib_dec/dec_higher_acelp.c index 2a9bb28cb..77bd8dd6d 100644 --- a/lib_dec/dec_higher_acelp.c +++ b/lib_dec/dec_higher_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_nelp.c b/lib_dec/dec_nelp.c index e7a8ca967..167c70dbf 100644 --- a/lib_dec/dec_nelp.c +++ b/lib_dec/dec_nelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_pit_exc.c b/lib_dec/dec_pit_exc.c index e5ee5c0c0..5a894a39c 100644 --- a/lib_dec/dec_pit_exc.c +++ b/lib_dec/dec_pit_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c index 10836b779..5cb811408 100644 --- a/lib_dec/dec_post.c +++ b/lib_dec/dec_post.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_ppp.c b/lib_dec/dec_ppp.c index e7a8ca967..167c70dbf 100644 --- a/lib_dec/dec_ppp.c +++ b/lib_dec/dec_ppp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c index 33c62a67a..7b4567f7a 100644 --- a/lib_dec/dec_prm.c +++ b/lib_dec/dec_prm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 708527df5..aca84d9d9 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1,7 +1,7 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_tran.c b/lib_dec/dec_tran.c index 88f93c733..3522990d9 100644 --- a/lib_dec/dec_tran.c +++ b/lib_dec/dec_tran.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_uv.c b/lib_dec/dec_uv.c index e748899a9..9e7ce9558 100644 --- a/lib_dec/dec_uv.c +++ b/lib_dec/dec_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/decision_matrix_dec.c b/lib_dec/decision_matrix_dec.c index a96d130cb..9ee7741c0 100644 --- a/lib_dec/decision_matrix_dec.c +++ b/lib_dec/decision_matrix_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dlpc_avq.c b/lib_dec/dlpc_avq.c index 3514dda88..748544423 100644 --- a/lib_dec/dlpc_avq.c +++ b/lib_dec/dlpc_avq.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dlpc_stoch.c b/lib_dec/dlpc_stoch.c index c1956b8d9..5645c9462 100644 --- a/lib_dec/dlpc_stoch.c +++ b/lib_dec/dlpc_stoch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_dec_acelp.c b/lib_dec/er_dec_acelp.c index 68731d8f1..047de37fb 100644 --- a/lib_dec/er_dec_acelp.c +++ b/lib_dec/er_dec_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 2d8fdd56a..f2bd70247 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_scale_syn.c b/lib_dec/er_scale_syn.c index a45d9a0bd..eea698fa6 100644 --- a/lib_dec/er_scale_syn.c +++ b/lib_dec/er_scale_syn.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_sync_exc.c b/lib_dec/er_sync_exc.c index 8b2b54876..05720aca8 100644 --- a/lib_dec/er_sync_exc.c +++ b/lib_dec/er_sync_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c index 88c1af13f..9cd1332e6 100644 --- a/lib_dec/er_util.c +++ b/lib_dec/er_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index d441f6ead..47e1f0be1 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 51ae2d59f..dd3adb247 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gain_dec.c b/lib_dec/gain_dec.c index d441f6ead..47e1f0be1 100644 --- a/lib_dec/gain_dec.c +++ b/lib_dec/gain_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gaus_dec.c b/lib_dec/gaus_dec.c index d441f6ead..47e1f0be1 100644 --- a/lib_dec/gaus_dec.c +++ b/lib_dec/gaus_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gs_dec.c b/lib_dec/gs_dec.c index 79457ca5d..4d34802bb 100644 --- a/lib_dec/gs_dec.c +++ b/lib_dec/gs_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gs_dec_amr_wb.c b/lib_dec/gs_dec_amr_wb.c index d441f6ead..47e1f0be1 100644 --- a/lib_dec/gs_dec_amr_wb.c +++ b/lib_dec/gs_dec_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hdecnrm.c b/lib_dec/hdecnrm.c index 56e7b45fe..19627a4f3 100644 --- a/lib_dec/hdecnrm.c +++ b/lib_dec/hdecnrm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hf_synth.c b/lib_dec/hf_synth.c index 8070239de..fc8c8da5f 100644 --- a/lib_dec/hf_synth.c +++ b/lib_dec/hf_synth.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_classifier_dec.c b/lib_dec/hq_classifier_dec.c index 0fe8682da..c899b52ff 100644 --- a/lib_dec/hq_classifier_dec.c +++ b/lib_dec/hq_classifier_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_conf_fec.c b/lib_dec/hq_conf_fec.c index fd4f3cb7c..b25a46f03 100644 --- a/lib_dec/hq_conf_fec.c +++ b/lib_dec/hq_conf_fec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c index 5a1f34a11..cd29271f1 100644 --- a/lib_dec/hq_core_dec.c +++ b/lib_dec/hq_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_env_dec.c b/lib_dec/hq_env_dec.c index fc894ba6c..d029c2fa8 100644 --- a/lib_dec/hq_env_dec.c +++ b/lib_dec/hq_env_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_hr_dec.c b/lib_dec/hq_hr_dec.c index fd4f3cb7c..b25a46f03 100644 --- a/lib_dec/hq_hr_dec.c +++ b/lib_dec/hq_hr_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index dd5876ea9..8547d9712 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 785dc6a86..64a8d798b 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/igf_scf_dec.c b/lib_dec/igf_scf_dec.c index 1c0985cf4..68174a8c2 100644 --- a/lib_dec/igf_scf_dec.c +++ b/lib_dec/igf_scf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 3c20d7b27..2b8091305 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c index 84f371717..be630cee0 100644 --- a/lib_dec/inov_dec.c +++ b/lib_dec/inov_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 3bfbcee10..46246da44 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index 8996f087d..f5418abc6 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index f23c0b710..748bdec38 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 9aaddb2fb..92b43092b 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 56a45ddb0..89ca9a5ba 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index bc61a3baa..4a6f34081 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index f36a227b3..c22c617c0 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 70d0a21a7..351331bb2 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index 6196d31fb..a8c151edb 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 95cca12a0..7d2f7be4f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index fd039fe96..13d8fc940 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder.c index 5f64c1123..0c489fb04 100644 --- a/lib_dec/ivas_entropy_decoder.c +++ b/lib_dec/ivas_entropy_decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 35844b5e5..73e2b5d01 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index a5f7f7b06..14e83fe83 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 106653e48..0365005be 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index ae33f2794..833ed5e16 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index c7fce8dd5..1f7af935d 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 2f2a0fda5..738e5a598 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 427959388..5317e803e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index a9ed90a8a..e9f3a7b28 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index ec58c45c0..616b15c6e 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 8ae40e2be..89b232254 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 2c2b5d5eb..f5e7816ad 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 25badc608..eabee357b 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 983eb3309..aa42f4f91 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 4175d15de..50d03b577 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index c1bf455a5..b12236746 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 3f5f1d098..687efb3ce 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index 7c4c3743c..824370bb8 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a8cda4e58..a92f21f6d 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 7ba41f344..52431d36a 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c index 3ed0998d1..331bdc253 100644 --- a/lib_dec/ivas_mct_dec_mct_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 9c189e6a1..2158dec1c 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 6ef615601..231aee8aa 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 256ce8f96..3a6480386 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 509217616..0fb4163be 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index f9d14c995..a5285b5cb 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 59a560f33..02f37672d 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 64995d8a0..cb96d3b0d 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_pca_dec.c b/lib_dec/ivas_pca_dec.c index 9e3fbe939..f2f5274be 100644 --- a/lib_dec/ivas_pca_dec.c +++ b/lib_dec/ivas_pca_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 1700c2527..4a0c62e8d 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index b961b6dbb..dc4a1b01b 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 434fc958d..c225f126a 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c index 446c64b6c..43ac60305 100644 --- a/lib_dec/ivas_qspherical_dec.c +++ b/lib_dec/ivas_qspherical_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c index 3da244dd8..6d6631f73 100644 --- a/lib_dec/ivas_range_uni_dec.c +++ b/lib_dec/ivas_range_uni_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index e73246176..812d9957f 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index e79c50856..11752380d 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e27bc0638..65faabdc0 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 15a652bc1..1cfc7aa2e 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 5867a44b3..12a34e170 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 7cc1ebbb6..434fdf5fa 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 0bee68afb..5f384870f 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 6c22b3a98..ce4992046 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 7823d2f7c..86fd2fb3e 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 0451aad08..37489e58f 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten FORschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 0bdc62756..cddbf8cdf 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index c33c5da63..3ad16b981 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index cf01ce54f..b1522be36 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_adapt_GR_dec.c b/lib_dec/ivas_stereo_adapt_GR_dec.c index fbaa98534..c67a52b6c 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 2ad6085ca..c8985d7cd 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 94234a1e1..5449521d6 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index e97ba23de..99cea064b 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 961120073..b76bddbbc 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_plc.c b/lib_dec/ivas_stereo_dft_plc.c index 3988b275a..5a9122b00 100644 --- a/lib_dec/ivas_stereo_dft_plc.c +++ b/lib_dec/ivas_stereo_dft_plc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index ded3b48f4..9e6878faf 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_eclvq_dec.c b/lib_dec/ivas_stereo_eclvq_dec.c index c74649d90..ed26543d3 100644 --- a/lib_dec/ivas_stereo_eclvq_dec.c +++ b/lib_dec/ivas_stereo_eclvq_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_esf_dec.c b/lib_dec/ivas_stereo_esf_dec.c index e52528044..80603f6c0 100644 --- a/lib_dec/ivas_stereo_esf_dec.c +++ b/lib_dec/ivas_stereo_esf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index a28afdad9..b72e66c5f 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 8b8887c9c..6bba90feb 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 233dcc225..e11120d38 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 3014dba06..bf343da7f 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 829173da0..4a788be83 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index ad6d58ebf..a8b74c447 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index c53135f0a..d296e3f33 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 77cf192c2..a22502188 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index d3a3d7bc6..37ffc5128 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index 7df267b1d..dbbc22b4d 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer.c index bc12026c9..cdabe4700 100644 --- a/lib_dec/jbm_jb4_circularbuffer.c +++ b/lib_dec/jbm_jb4_circularbuffer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h index ec6a5c7be..de614eeea 100644 --- a/lib_dec/jbm_jb4_circularbuffer.h +++ b/lib_dec/jbm_jb4_circularbuffer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer.c index 27a1d6ff1..55113ee13 100644 --- a/lib_dec/jbm_jb4_inputbuffer.c +++ b/lib_dec/jbm_jb4_inputbuffer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_inputbuffer.h b/lib_dec/jbm_jb4_inputbuffer.h index b9c9c5ef6..769cccba6 100644 --- a/lib_dec/jbm_jb4_inputbuffer.h +++ b/lib_dec/jbm_jb4_inputbuffer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_jmf.c b/lib_dec/jbm_jb4_jmf.c index 8e5215dae..940df5ecb 100644 --- a/lib_dec/jbm_jb4_jmf.c +++ b/lib_dec/jbm_jb4_jmf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_jmf.h b/lib_dec/jbm_jb4_jmf.h index b08f5502c..6b5a00434 100644 --- a/lib_dec/jbm_jb4_jmf.h +++ b/lib_dec/jbm_jb4_jmf.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index a19f8bfd7..4878b7d64 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index 55565be4a..939fad2cb 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 92aee035e..10b91a60c 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 7acdf599c..1fe7481df 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c index 35a08b2de..00e5ce7f0 100644 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ b/lib_dec/jbm_pcmdsp_fifo.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index 12b7f5b14..1375c5713 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index b6eeaf0e1..cc13c0148 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index 123d0c3c1..086f88181 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c index ea15ab7a1..eba40ec98 100644 --- a/lib_dec/jbm_pcmdsp_window.c +++ b/lib_dec/jbm_pcmdsp_window.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index 9102e027f..3551380de 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lead_deindexing.c b/lib_dec/lead_deindexing.c index dbe4a43e8..35a1adf15 100644 --- a/lib_dec/lead_deindexing.c +++ b/lib_dec/lead_deindexing.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8e228facb..81d78932a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 28fbe71b9..0c4d54db8 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7e2e69ec4..2cc4c6387 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lp_exc_d.c b/lib_dec/lp_exc_d.c index e7a8ca967..167c70dbf 100644 --- a/lib_dec/lp_exc_d.c +++ b/lib_dec/lp_exc_d.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index f963d7317..abc1aab9d 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lsf_msvq_ma_dec.c b/lib_dec/lsf_msvq_ma_dec.c index 313c2798e..042eec9ab 100644 --- a/lib_dec/lsf_msvq_ma_dec.c +++ b/lib_dec/lsf_msvq_ma_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/nelp_dec.c b/lib_dec/nelp_dec.c index 895fdaae2..1dc550e6d 100644 --- a/lib_dec/nelp_dec.c +++ b/lib_dec/nelp_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/peak_vq_dec.c b/lib_dec/peak_vq_dec.c index 7b039f26f..67ab06e08 100644 --- a/lib_dec/peak_vq_dec.c +++ b/lib_dec/peak_vq_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pit_dec.c b/lib_dec/pit_dec.c index 7d906b12e..c74e05591 100644 --- a/lib_dec/pit_dec.c +++ b/lib_dec/pit_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pitch_extr.c b/lib_dec/pitch_extr.c index 53a6b154a..3d10f2158 100644 --- a/lib_dec/pitch_extr.c +++ b/lib_dec/pitch_extr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/post_dec.c b/lib_dec/post_dec.c index 3643a2810..380b256b0 100644 --- a/lib_dec/post_dec.c +++ b/lib_dec/post_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ppp_dec.c b/lib_dec/ppp_dec.c index d1de09bc7..7ea6e47a5 100644 --- a/lib_dec/ppp_dec.c +++ b/lib_dec/ppp_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pvq_core_dec.c b/lib_dec/pvq_core_dec.c index 936720d06..2bdb05e5f 100644 --- a/lib_dec/pvq_core_dec.c +++ b/lib_dec/pvq_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pvq_decode.c b/lib_dec/pvq_decode.c index 8e752f0ac..9228e2f5d 100644 --- a/lib_dec/pvq_decode.c +++ b/lib_dec/pvq_decode.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/range_dec.c b/lib_dec/range_dec.c index fd4f3cb7c..b25a46f03 100644 --- a/lib_dec/range_dec.c +++ b/lib_dec/range_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/re8_dec.c b/lib_dec/re8_dec.c index e748899a9..9e7ce9558 100644 --- a/lib_dec/re8_dec.c +++ b/lib_dec/re8_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rom_dec.c b/lib_dec/rom_dec.c index 787966f72..3f5243286 100644 --- a/lib_dec/rom_dec.c +++ b/lib_dec/rom_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h index f057b804a..8c1021682 100644 --- a/lib_dec/rom_dec.h +++ b/lib_dec/rom_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rst_dec.c b/lib_dec/rst_dec.c index 3b7436831..3feb2af8e 100644 --- a/lib_dec/rst_dec.c +++ b/lib_dec/rst_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 5c7f894b9..c892ae732 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/stat_noise_uv_dec.c b/lib_dec/stat_noise_uv_dec.c index e748899a9..9e7ce9558 100644 --- a/lib_dec/stat_noise_uv_dec.c +++ b/lib_dec/stat_noise_uv_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index 0f9863bdf..68272a79f 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_bwe_dec_hr.c b/lib_dec/swb_bwe_dec_hr.c index e2be97ae4..06d666ffd 100644 --- a/lib_dec/swb_bwe_dec_hr.c +++ b/lib_dec/swb_bwe_dec_hr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_bwe_dec_lr.c b/lib_dec/swb_bwe_dec_lr.c index ff2af374e..7bd79fa23 100644 --- a/lib_dec/swb_bwe_dec_lr.c +++ b/lib_dec/swb_bwe_dec_lr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 6035e402d..80dfad505 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/syn_outp.c b/lib_dec/syn_outp.c index 96ac16dba..543b69d8d 100644 --- a/lib_dec/syn_outp.c +++ b/lib_dec/syn_outp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tcq_core_dec.c b/lib_dec/tcq_core_dec.c index 403c5db5b..f7f81a0fa 100644 --- a/lib_dec/tcq_core_dec.c +++ b/lib_dec/tcq_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tcx_utils_dec.c b/lib_dec/tcx_utils_dec.c index efee08d61..1fc02caee 100644 --- a/lib_dec/tcx_utils_dec.c +++ b/lib_dec/tcx_utils_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tns_base_dec.c b/lib_dec/tns_base_dec.c index 68e2e313c..c74a5f4e1 100644 --- a/lib_dec/tns_base_dec.c +++ b/lib_dec/tns_base_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 0ac877450..6a74d3b87 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/transition_dec.c b/lib_dec/transition_dec.c index d441f6ead..47e1f0be1 100644 --- a/lib_dec/transition_dec.c +++ b/lib_dec/transition_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/updt_dec.c b/lib_dec/updt_dec.c index 2b370b05d..6ffe42f8c 100644 --- a/lib_dec/updt_dec.c +++ b/lib_dec/updt_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/vlpc_1st_dec.c b/lib_dec/vlpc_1st_dec.c index 97a511fb6..78821eb05 100644 --- a/lib_dec/vlpc_1st_dec.c +++ b/lib_dec/vlpc_1st_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/vlpc_2st_dec.c b/lib_dec/vlpc_2st_dec.c index e748899a9..9e7ce9558 100644 --- a/lib_dec/vlpc_2st_dec.c +++ b/lib_dec/vlpc_2st_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/voiced_dec.c b/lib_dec/voiced_dec.c index 87f19fd33..4fbd33bdf 100644 --- a/lib_dec/voiced_dec.c +++ b/lib_dec/voiced_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/waveadjust_fec_dec.c b/lib_dec/waveadjust_fec_dec.c index b573d3d7f..65de1e11f 100644 --- a/lib_dec/waveadjust_fec_dec.c +++ b/lib_dec/waveadjust_fec_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c index cda9d3c82..da4d1486b 100644 --- a/lib_enc/ari_enc.c +++ b/lib_enc/ari_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c index a227784dc..c6e11a3f0 100644 --- a/lib_enc/ari_hm_enc.c +++ b/lib_enc/ari_hm_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c index 5680feed4..5625b6cf4 100644 --- a/lib_enc/arith_coder_enc.c +++ b/lib_enc/arith_coder_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/avq_cod.c b/lib_enc/avq_cod.c index 8e752f0ac..9228e2f5d 100644 --- a/lib_enc/avq_cod.c +++ b/lib_enc/avq_cod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/bass_psfilter_enc.c b/lib_enc/bass_psfilter_enc.c index 8e752f0ac..9228e2f5d 100644 --- a/lib_enc/bass_psfilter_enc.c +++ b/lib_enc/bass_psfilter_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 2cba6f328..d86351ae8 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c index 15dc89516..192a71f92 100644 --- a/lib_enc/cng_enc.c +++ b/lib_enc/cng_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod2t32.c b/lib_enc/cod2t32.c index e7a8ca967..167c70dbf 100644 --- a/lib_enc/cod2t32.c +++ b/lib_enc/cod2t32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod4t64.c b/lib_enc/cod4t64.c index b4081d00f..9be976783 100644 --- a/lib_enc/cod4t64.c +++ b/lib_enc/cod4t64.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index e4c8124e6..16651b8f2 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod_ace.c b/lib_enc/cod_ace.c index 3ee7cc7b2..46d7a42d1 100644 --- a/lib_enc/cod_ace.c +++ b/lib_enc/cod_ace.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 963cc1650..25f615e6a 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod_uv.c b/lib_enc/cod_uv.c index e748899a9..9e7ce9558 100644 --- a/lib_enc/cod_uv.c +++ b/lib_enc/cod_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/comvad_decision.c b/lib_enc/comvad_decision.c index f6ca036b2..efb9c1d78 100644 --- a/lib_enc/comvad_decision.c +++ b/lib_enc/comvad_decision.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cor_shif.c b/lib_enc/cor_shif.c index 825401325..0e2004abf 100644 --- a/lib_enc/cor_shif.c +++ b/lib_enc/cor_shif.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_2div.c b/lib_enc/core_enc_2div.c index 0fe8682da..c899b52ff 100644 --- a/lib_enc/core_enc_2div.c +++ b/lib_enc/core_enc_2div.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index e98956efe..41f3d0ac5 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_ol.c b/lib_enc/core_enc_ol.c index d86e50ff1..c282f7649 100644 --- a/lib_enc/core_enc_ol.c +++ b/lib_enc/core_enc_ol.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c index 24729c124..29c215059 100644 --- a/lib_enc/core_enc_reconf.c +++ b/lib_enc/core_enc_reconf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index b6f723c2b..3c0f41446 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c index 95f1c67b6..4533af002 100644 --- a/lib_enc/core_enc_updt.c +++ b/lib_enc/core_enc_updt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 67c7a552f..08789dbde 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/corr_xh.c b/lib_enc/corr_xh.c index 68195a7ec..9fd3cb8a2 100644 --- a/lib_enc/corr_xh.c +++ b/lib_enc/corr_xh.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/decision_matrix_enc.c b/lib_enc/decision_matrix_enc.c index 34d9fd39d..5e0c266ca 100644 --- a/lib_enc/decision_matrix_enc.c +++ b/lib_enc/decision_matrix_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/detect_transient.c b/lib_enc/detect_transient.c index 4922b9e4c..c2bbde080 100644 --- a/lib_enc/detect_transient.c +++ b/lib_enc/detect_transient.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index a3dba9d27..51f1cb476 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/diffcod.c b/lib_enc/diffcod.c index 3c07227e2..9f6bb4283 100644 --- a/lib_enc/diffcod.c +++ b/lib_enc/diffcod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index fd519a119..726508b0c 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_acelp.c b/lib_enc/enc_acelp.c index e1517cb69..bf5688ef1 100644 --- a/lib_enc/enc_acelp.c +++ b/lib_enc/enc_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_acelp_tcx_main.c b/lib_enc/enc_acelp_tcx_main.c index fc894ba6c..d029c2fa8 100644 --- a/lib_enc/enc_acelp_tcx_main.c +++ b/lib_enc/enc_acelp_tcx_main.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_acelpx.c b/lib_enc/enc_acelpx.c index 661cc4b7b..f6e2b0379 100644 --- a/lib_enc/enc_acelpx.c +++ b/lib_enc/enc_acelpx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_amr_wb.c b/lib_enc/enc_amr_wb.c index 0fe8682da..c899b52ff 100644 --- a/lib_enc/enc_amr_wb.c +++ b/lib_enc/enc_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_gain.c b/lib_enc/enc_gain.c index a82d2075a..491d5d2f3 100644 --- a/lib_enc/enc_gain.c +++ b/lib_enc/enc_gain.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_gen_voic.c b/lib_enc/enc_gen_voic.c index 0fe8682da..c899b52ff 100644 --- a/lib_enc/enc_gen_voic.c +++ b/lib_enc/enc_gen_voic.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index 6c6ade036..554521732 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 5fdc5e6f0..3b1b81730 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c index 952805169..efd1b44d2 100644 --- a/lib_enc/find_tilt.c +++ b/lib_enc/find_tilt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index 2e14972c7..c6ae02a76 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c index 00729bde0..89b77d351 100644 --- a/lib_enc/find_wsp.c +++ b/lib_enc/find_wsp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/frame_spec_dif_cor_rate.c b/lib_enc/frame_spec_dif_cor_rate.c index 09ecb0cc8..9185f37bd 100644 --- a/lib_enc/frame_spec_dif_cor_rate.c +++ b/lib_enc/frame_spec_dif_cor_rate.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gain_enc.c b/lib_enc/gain_enc.c index bd3da322a..276e20738 100644 --- a/lib_enc/gain_enc.c +++ b/lib_enc/gain_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index b4845a1a4..d7614473b 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gs_enc.c b/lib_enc/gs_enc.c index 4468194be..900c381bf 100644 --- a/lib_enc/gs_enc.c +++ b/lib_enc/gs_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/guided_plc_enc.c b/lib_enc/guided_plc_enc.c index c10866a49..6c0e9022d 100644 --- a/lib_enc/guided_plc_enc.c +++ b/lib_enc/guided_plc_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hf_cod_amrwb.c b/lib_enc/hf_cod_amrwb.c index d1de09bc7..7ea6e47a5 100644 --- a/lib_enc/hf_cod_amrwb.c +++ b/lib_enc/hf_cod_amrwb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_classifier_enc.c b/lib_enc/hq_classifier_enc.c index 273cba75c..634f42971 100644 --- a/lib_enc/hq_classifier_enc.c +++ b/lib_enc/hq_classifier_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index dc29b801b..a3a75cc95 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_env_enc.c b/lib_enc/hq_env_enc.c index 4e446e1c5..e8859676c 100644 --- a/lib_enc/hq_env_enc.c +++ b/lib_enc/hq_env_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c index f73925978..42f661f6e 100644 --- a/lib_enc/hq_hr_enc.c +++ b/lib_enc/hq_hr_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c index b184c5ac6..d0941db74 100644 --- a/lib_enc/hq_lr_enc.c +++ b/lib_enc/hq_lr_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hvq_enc.c b/lib_enc/hvq_enc.c index b693d838b..adf7751a1 100644 --- a/lib_enc/hvq_enc.c +++ b/lib_enc/hvq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 0ce087508..89dc1bf30 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index e9ef96e1a..192d7e597 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 7ce9f8ff5..8448843dc 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/inov_enc.c b/lib_enc/inov_enc.c index 754e202e5..08f1e768f 100644 --- a/lib_enc/inov_enc.c +++ b/lib_enc/inov_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/isf_enc_amr_wb.c b/lib_enc/isf_enc_amr_wb.c index 08af81cf8..7bb7c56fe 100644 --- a/lib_enc/isf_enc_amr_wb.c +++ b/lib_enc/isf_enc_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c index 047a7409c..4851ed155 100644 --- a/lib_enc/isf_enc_amr_wb_fx.c +++ b/lib_enc/isf_enc_amr_wb_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index dcc55f5ad..649c5bae5 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 0c7fe9094..6dc3d10ec 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 31b14ed10..96a3e110f 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 6ab82420f..c18134e0a 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 847cdd0f6..b1d819f5c 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index ea42591ca..42305ec19 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 27da71324..280443fc5 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 017aa2904..ec55850fd 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index a7fb71461..2bab65c42 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 5c19d8e02..95a114b67 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index da4826776..0dd0f5aa1 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index f52bdadb4..5460ccb12 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 7a499ce67..7ad7d40e4 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index f098dc0e4..95b37435c 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 3dc12da91..7f41b27a8 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 32138faba..68391eabd 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 5e91a30fb..bef6912bd 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index e219e8b37..8ccb59c9c 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 583a37006..f4fe68c59 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 43162f6de..859ce3a9b 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 61f817b2f..c94946b2d 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index ad52915d1..3687df381 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 52fd554d8..0ed03eb1c 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 5510f1eb1..dbced19fd 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index 654c00db4..ae561c0d0 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 4997a6715..6f1d4117d 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index a9ebf8ec3..f09d4513d 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 9d7c92dd0..ab8252854 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index 4e133567c..8b61cb6c8 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 00b62f2f6..387f82463 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc.c index 4bf3650e6..eb60d4849 100644 --- a/lib_enc/ivas_qspherical_enc.c +++ b/lib_enc/ivas_qspherical_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_range_uni_enc.c b/lib_enc/ivas_range_uni_enc.c index a93f470f5..35ecad69c 100644 --- a/lib_enc/ivas_range_uni_enc.c +++ b/lib_enc/ivas_range_uni_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index 501965bfa..0d0941cc4 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c index e4361b933..b26972b8a 100644 --- a/lib_enc/ivas_rom_enc_fx.c +++ b/lib_enc/ivas_rom_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index ef76d67c9..b247900a0 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index dd9cb61a0..1760e757f 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 5566c1547..8f93c4d76 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index e1b3905c2..a0c5be842 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 1d367dd52..8b23eca5f 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index db72219cd..c7343fe4e 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_adapt_GR_enc.c b/lib_enc/ivas_stereo_adapt_GR_enc.c index a47029be4..62fed34f7 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 4913f2545..e83bccd09 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c index 92add6cdd..4727cd188 100644 --- a/lib_enc/ivas_stereo_cng_enc.c +++ b/lib_enc/ivas_stereo_cng_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index d532a9af1..cf246368f 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index f65b5114c..70a467232 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index e64e5a1ec..dd7f575b7 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index be470e2cf..7b0e7df62 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_eclvq_enc.c b/lib_enc/ivas_stereo_eclvq_enc.c index 118baaa69..cd0e6fe2d 100644 --- a/lib_enc/ivas_stereo_eclvq_enc.c +++ b/lib_enc/ivas_stereo_eclvq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 5b79f416a..0235630d2 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc.c index 9cf899bcb..8c2d136b7 100644 --- a/lib_enc/ivas_stereo_icbwe_enc.c +++ b/lib_enc/ivas_stereo_icbwe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index ffc671d41..e85c01db2 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c index 190255fd9..38be1a6a4 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index 4c73ba2e7..9c729709d 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index a1e5592e5..786c45cb3 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index 5bc62bc8b..79e05bf09 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 02bdd1561..304754fc3 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index f072e5436..bc6df4f56 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index d09134951..e5514b7eb 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lead_indexing.c b/lib_enc/lead_indexing.c index d20e6a703..3a6a477b9 100644 --- a/lib_enc/lead_indexing.c +++ b/lib_enc/lead_indexing.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 319ebdf87..9a82fc05e 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index c23f56df9..176e35236 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/long_enr.c b/lib_enc/long_enr.c index aba21a1fe..31ab8f019 100644 --- a/lib_enc/long_enr.c +++ b/lib_enc/long_enr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lp_exc_e.c b/lib_enc/lp_exc_e.c index 7d23dd6f7..5c3581f4f 100644 --- a/lib_enc/lp_exc_e.c +++ b/lib_enc/lp_exc_e.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index 06e686f81..3ac84b28e 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 6ee7bb9c3..830f1ecd6 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ltd_stable.c b/lib_enc/ltd_stable.c index 825401325..0e2004abf 100644 --- a/lib_enc/ltd_stable.c +++ b/lib_enc/ltd_stable.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/mdct_classifier.c b/lib_enc/mdct_classifier.c index b157e0ff9..047f02355 100644 --- a/lib_enc/mdct_classifier.c +++ b/lib_enc/mdct_classifier.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/mdct_selector.c b/lib_enc/mdct_selector.c index 9d6f499db..952043e3a 100644 --- a/lib_enc/mdct_selector.c +++ b/lib_enc/mdct_selector.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/mslvq_enc.c b/lib_enc/mslvq_enc.c index 9f95d696c..a49d435c3 100644 --- a/lib_enc/mslvq_enc.c +++ b/lib_enc/mslvq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/multi_harm.c b/lib_enc/multi_harm.c index 7d23dd6f7..5c3581f4f 100644 --- a/lib_enc/multi_harm.c +++ b/lib_enc/multi_harm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/nelp_enc.c b/lib_enc/nelp_enc.c index d1de09bc7..7ea6e47a5 100644 --- a/lib_enc/nelp_enc.c +++ b/lib_enc/nelp_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index a0ed2f523..3bd8e340d 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c index 224203cb0..5bde0f450 100644 --- a/lib_enc/pit_enc.c +++ b/lib_enc/pit_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pitch_ol.c b/lib_enc/pitch_ol.c index 65b32d74c..0853fd9fd 100644 --- a/lib_enc/pitch_ol.c +++ b/lib_enc/pitch_ol.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c index 1ce646476..dc77e0dfa 100644 --- a/lib_enc/pitch_ol2.c +++ b/lib_enc/pitch_ol2.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/plc_enc_ext.c b/lib_enc/plc_enc_ext.c index 404ee401e..17c76dee6 100644 --- a/lib_enc/plc_enc_ext.c +++ b/lib_enc/plc_enc_ext.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 711d7069a..99483ebb9 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc.c index e1f2442bc..abdb1249d 100644 --- a/lib_enc/rom_enc.c +++ b/lib_enc/rom_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index bad6e9f86..35fd3027d 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c index 1cc6168c3..b7ff1d2b6 100644 --- a/lib_enc/setmodeindex.c +++ b/lib_enc/setmodeindex.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 0fa9aeb88..d012c5a96 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index c324b9ac9..acd984509 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 018ac1f0e..db4e51127 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index 193648a4e..4a4c1ff89 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -1,7 +1,7 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 12bc769fa..67d47e89d 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana.c index f2bc10e6a..06744dc6e 100644 --- a/lib_rend/ivas_dirac_ana.c +++ b/lib_rend/ivas_dirac_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 71ecb5106..e2ab6cd3e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index 1788536e4..01fd1e610 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec.c index f53f41404..c6119cc34 100644 --- a/lib_rend/ivas_dirac_onsets_dec.c +++ b/lib_rend/ivas_dirac_onsets_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 866badda0..0fe7cdef1 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index cafd70966..b563d4399 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 0bf3b85a4..8947809d1 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index ab69784c7..506d76efd 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 17211d1c6..595573016 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge.c index 9e6807b00..e8d06d0bb 100644 --- a/lib_rend/ivas_masa_merge.c +++ b/lib_rend/ivas_masa_merge.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 106ca56f4..0b0c8ffeb 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index f323b615d..8b689b94b 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 4d5ad355a..ab09a82b5 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 5616da037..a328a51bf 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 8c6fd8663..caa393355 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index f01f66797..af60f7746 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c index 5e4d9d6ac..c8efd80ad 100644 --- a/lib_rend/ivas_objectRenderer_vec.c +++ b/lib_rend/ivas_objectRenderer_vec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana.c index 26f0cefcf..7d6129d20 100644 --- a/lib_rend/ivas_omasa_ana.c +++ b/lib_rend/ivas_omasa_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index a3e833455..bb6f26346 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 359bea7e6..980e5ca17 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4afd38886..b642e05d7 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index c5d118858..e5e8cdb56 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index d35a6c005..792b485a7 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index c70e325e3..9e621ce83 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c index c8db27955..3eeb4ede4 100644 --- a/lib_rend/ivas_reverb_delay_line.c +++ b/lib_rend/ivas_reverb_delay_line.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 79cb544b2..3befcde91 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index b1499839c..428cf3353 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index 7049fa580..217e16dd8 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index ddb95aaf0..46ef576a8 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.c b/lib_rend/ivas_rom_TdBinauralRenderer.c index f6921bc92..cee2a9753 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index 7cdd84d6d..89d86f112 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binauralRenderer.c b/lib_rend/ivas_rom_binauralRenderer.c index fa4cbd7aa..e7dbbae70 100644 --- a/lib_rend/ivas_rom_binauralRenderer.c +++ b/lib_rend/ivas_rom_binauralRenderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 8e7bd4a55..4b1428ac8 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head.c index 60925a31f..068ce0927 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.c +++ b/lib_rend/ivas_rom_binaural_crend_head.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 0004a05d7..bc0d3cd17 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index d99a4ad76..54940355c 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index c80fab8ce..e7d6c6293 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 758d787b1..39720469b 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 0309cf61f..7c7a20223 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c index 6e27da202..9ed0d8d33 100644 --- a/lib_rend/ivas_shoebox.c +++ b/lib_rend/ivas_shoebox.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 38b2fe524..44207c79a 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_td_decorr.c b/lib_rend/ivas_td_decorr.c index c4507aae1..af51a7820 100644 --- a/lib_rend/ivas_td_decorr.c +++ b/lib_rend/ivas_td_decorr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap.c index 24465c3e7..e1a6868d8 100644 --- a/lib_rend/ivas_vbap.c +++ b/lib_rend/ivas_vbap.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 86eea321b..a1c551405 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 74e6070b5..22ed7ed65 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index ff9a9b33b..ca5e6e496 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_reader.h b/lib_util/audio_file_reader.h index 185d8c077..571c1e765 100644 --- a/lib_util/audio_file_reader.h +++ b/lib_util/audio_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c index 0f2f5335d..fb7a64c42 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_writer.h b/lib_util/audio_file_writer.h index 0b1c3315f..2622992ce 100644 --- a/lib_util/audio_file_writer.h +++ b/lib_util/audio_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c index 841d6e1de..2bd6f46aa 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_reader.h b/lib_util/bitstream_reader.h index e33de4897..fb6f9f9b9 100644 --- a/lib_util/bitstream_reader.h +++ b/lib_util/bitstream_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_writer.c b/lib_util/bitstream_writer.c index d19a05898..8c4b64cd4 100644 --- a/lib_util/bitstream_writer.c +++ b/lib_util/bitstream_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_writer.h b/lib_util/bitstream_writer.h index b0fab9e44..f3efd4ddf 100644 --- a/lib_util/bitstream_writer.h +++ b/lib_util/bitstream_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index 337583ab9..bec772ce4 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h index 7c3c05ba1..327acb93d 100644 --- a/lib_util/cmdl_tools.h +++ b/lib_util/cmdl_tools.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index fe2c1b1db..b2c8f85bc 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h index 4721d968f..2627d5566 100644 --- a/lib_util/cmdln_parser.h +++ b/lib_util/cmdln_parser.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/evs_rtp_payload.c b/lib_util/evs_rtp_payload.c index c122716f3..a0c514bad 100644 --- a/lib_util/evs_rtp_payload.c +++ b/lib_util/evs_rtp_payload.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/evs_rtp_payload.h b/lib_util/evs_rtp_payload.h index 004ecf79b..357d98557 100644 --- a/lib_util/evs_rtp_payload.h +++ b/lib_util/evs_rtp_payload.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/g192.c b/lib_util/g192.c index bec637464..d6c6ec475 100644 --- a/lib_util/g192.c +++ b/lib_util/g192.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/g192.h b/lib_util/g192.h index 6d6104d45..8014f5236 100644 --- a/lib_util/g192.h +++ b/lib_util/g192.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 3410ada71..8920e6780 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index e222fd4d1..104cc5c7a 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index f6f020639..f3d782aeb 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_reader.h b/lib_util/ism_file_reader.h index 886ebb34b..c785cc294 100644 --- a/lib_util/ism_file_reader.h +++ b/lib_util/ism_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 093414293..94bab6dd2 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_writer.h b/lib_util/ism_file_writer.h index 34cc4e711..6bf1a3e31 100644 --- a/lib_util/ism_file_writer.h +++ b/lib_util/ism_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_reader.c b/lib_util/jbm_file_reader.c index 01ca956f7..b657ab789 100644 --- a/lib_util/jbm_file_reader.c +++ b/lib_util/jbm_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_reader.h b/lib_util/jbm_file_reader.h index 379506ee6..e824e1eee 100644 --- a/lib_util/jbm_file_reader.h +++ b/lib_util/jbm_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c index 6e26fe703..76a5a67d2 100644 --- a/lib_util/jbm_file_writer.c +++ b/lib_util/jbm_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_writer.h b/lib_util/jbm_file_writer.h index fad5ec81e..aca768a1a 100644 --- a/lib_util/jbm_file_writer.h +++ b/lib_util/jbm_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 90b734d07..01d1f0307 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ls_custom_file_reader.h b/lib_util/ls_custom_file_reader.h index b5def3376..46b20a4ff 100644 --- a/lib_util/ls_custom_file_reader.h +++ b/lib_util/ls_custom_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 5b8d759c2..9351d9bc9 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_reader.h b/lib_util/masa_file_reader.h index de55035c7..7510598c3 100644 --- a/lib_util/masa_file_reader.h +++ b/lib_util/masa_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 8bf55ba86..0939d0829 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h index d7f53d4b6..2d476e28f 100644 --- a/lib_util/masa_file_writer.h +++ b/lib_util/masa_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 8a6262953..782f818d0 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mime_io.h b/lib_util/mime_io.h index 6ce5070c4..dbd21c9c7 100644 --- a/lib_util/mime_io.h +++ b/lib_util/mime_io.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 692f8c58d..b6122ec0f 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 445ced79a..5edf73ded 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 987d40c85..468f80765 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rotation_file_reader.h b/lib_util/rotation_file_reader.h index 3f98ea5b0..8d6206bd6 100644 --- a/lib_util/rotation_file_reader.h +++ b/lib_util/rotation_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c index 9f8784947..e3eb4c1f4 100644 --- a/lib_util/rtpdump.c +++ b/lib_util/rtpdump.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rtpdump.h b/lib_util/rtpdump.h index b97ec97d8..5b8b31e8d 100644 --- a/lib_util/rtpdump.h +++ b/lib_util/rtpdump.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/test_fft.c b/lib_util/test_fft.c index 5c0e2b33f..1b52fe351 100644 --- a/lib_util/test_fft.c +++ b/lib_util/test_fft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/test_fft.h b/lib_util/test_fft.h index 7a3567f89..6c9629090 100644 --- a/lib_util/test_fft.h +++ b/lib_util/test_fft.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/test_mdct.c b/lib_util/test_mdct.c index 91095df38..69d83588d 100644 --- a/lib_util/test_mdct.c +++ b/lib_util/test_mdct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/tinywavein_c.h b/lib_util/tinywavein_c.h index 0fd1b7a65..b86d97c96 100644 --- a/lib_util/tinywavein_c.h +++ b/lib_util/tinywavein_c.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h index 9b11e325a..693beccf9 100644 --- a/lib_util/tinywaveout_c.h +++ b/lib_util/tinywaveout_c.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index 380e69e27..ec14ebc71 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/vector3_pair_file_reader.h b/lib_util/vector3_pair_file_reader.h index 3255fb315..6515d32d5 100644 --- a/lib_util/vector3_pair_file_reader.h +++ b/lib_util/vector3_pair_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/readme.txt b/readme.txt index 25275a795..9b1ab852d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other -- GitLab From ae0ce593631e20e644b3628a998dfe325b7a3dd9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 14:05:11 +0100 Subject: [PATCH 192/329] try yet another variant --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b9789138..2c8e1fa4f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -989,8 +989,9 @@ build-codec-linux-debugging-make: .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then - *update-scripts-repo - # redirect to stdout so that the error message is visible in case of script failure - - REFERENCE_BRANCH=$(ci/get_float_ref_branch_name.sh | tee /dev/tty) + # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file + - ci/get_float_ref_branch_name.sh | tee tmp_ref_branch.txt + - REFERENCE_BRANCH=$(cat tmp_ref_branch.txt) - fi ### jobs that test fx encoder -> flt decoder -- GitLab From c5c93ce4c8077616238afe577ed7ed5f4c834e9b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 14:08:21 +0100 Subject: [PATCH 193/329] add validation job for branch naming --- .gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c8e1fa4f..673d6393d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -804,6 +804,18 @@ fail-pipeline-if-in-draft: - echo "Your MR is still in Draft state, set it to ready to be mergable, then retrigger the pipeline." - exit 1 +# this branch runs on merges to main-pc only and will fail if the branch itself does not conform to the naming conventions +check-naming-of-branch-for-main-pc-merges: + extends: + - .rules-merge-request-to-main-pc + stage: prevalidate + tags: + - ivas-basop-linux + script: + - *update-scripts-repo + - ci/get_float_ref_branch_name.sh + + # --------------------------------------------------------------- # verification jobs # --------------------------------------------------------------- -- GitLab From 6418e7705aa671d063a525605573dd0f6b381955 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 14:10:44 +0100 Subject: [PATCH 194/329] correct usage of script --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 673d6393d..e2ce45be0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -813,7 +813,7 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - ci/get_float_ref_branch_name.sh + - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME # --------------------------------------------------------------- @@ -1002,7 +1002,7 @@ build-codec-linux-debugging-make: - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then - *update-scripts-repo # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file - - ci/get_float_ref_branch_name.sh | tee tmp_ref_branch.txt + - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt - REFERENCE_BRANCH=$(cat tmp_ref_branch.txt) - fi -- GitLab From a1087326945d9ab7ea1c25c46757dba5cff9b3df Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 14:16:32 +0100 Subject: [PATCH 195/329] introduce MR tag for skipping the name check --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e2ce45be0..be883ccae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -813,8 +813,9 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - + - if [ ! "$CI_MERGE_REQUEST_TITLE" =~ "\[skip[ -_]name[ -_]check\]" ]; then + - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME + - fi # --------------------------------------------------------------- # verification jobs @@ -999,7 +1000,7 @@ build-codec-linux-debugging-make: # --------------------------------------------------------------- .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then + - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ] && [ ! "$CI_MERGE_REQUEST_TITLE" =~ "\[skip[ -_]name[ -_]check\]" ]; then - *update-scripts-repo # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt -- GitLab From b6cb533d4f3a9f046e9a6d30b6974fac8fe22126 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 14:19:45 +0100 Subject: [PATCH 196/329] fix if --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be883ccae..0a21e83d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -813,7 +813,7 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - if [ ! "$CI_MERGE_REQUEST_TITLE" =~ "\[skip[ -_]name[ -_]check\]" ]; then + - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]]; then - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi @@ -1000,7 +1000,7 @@ build-codec-linux-debugging-make: # --------------------------------------------------------------- .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ] && [ ! "$CI_MERGE_REQUEST_TITLE" =~ "\[skip[ -_]name[ -_]check\]" ]; then + - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]]; then - *update-scripts-repo # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt -- GitLab From 0cfe1705750f642dcf30a2e96e7d737396a55504 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 25 Feb 2025 19:09:18 +0530 Subject: [PATCH 197/329] Fix for 3GPP issue 1291: Wrong use of imult1616() in ACELP rescaling - 2 Correction for L_frame=320 --- lib_dec/acelp_core_dec_ivas_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index e9e4625ce..712a3339f 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -749,7 +749,7 @@ ivas_error acelp_core_dec_ivas_fx( { Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, #ifdef FIX_ISSUE_1291 - shr( imult1616( st->L_frame, HIBND_ACB_L_FAC_Q1 ), 1 ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); #else imult1616( st->L_frame, HIBND_ACB_L_FAC ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); #endif @@ -803,7 +803,7 @@ ivas_error acelp_core_dec_ivas_fx( Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); /* save and delay synthesis to be used by SWB BWE */ - Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn + Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1) IF( st->hBWE_FD != NULL ) { #ifdef FIX_ISSUE_1290 -- GitLab From ecc4b246021750b2c11eb1075e5a8449098790d8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 25 Feb 2025 15:36:58 +0100 Subject: [PATCH 198/329] also exclude name check if branch is tagged as CI --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0a21e83d7..0c910a633 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -813,7 +813,7 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]]; then + - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi @@ -1000,7 +1000,7 @@ build-codec-linux-debugging-make: # --------------------------------------------------------------- .set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]]; then + - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - *update-scripts-repo # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt -- GitLab From df4ab5e6d98ccf2250ef0b6daa10b9b7c1f0ec91 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Tue, 25 Feb 2025 15:39:37 +0100 Subject: [PATCH 199/329] replaced the costly basop_util_mant2exp() function with a 64 bit addtion. there is a potential overflow which needs to be adressed first. --- lib_com/ivas_prot_fx.h | 6 +++++ lib_com/ivas_tools.c | 39 +++++++++++++++++++++++++++++++ lib_enc/speech_music_classif_fx.c | 23 ++++++------------ 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 1682c255b..1b6e7be85 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4714,6 +4714,12 @@ Word32 dot_product_cholesky_fixed( const Word16 exp_A, Word16 *exp_sum ); +Word64 dot_product_cholesky_fixed64( + const Word32 *x, /* i : vector x */ + const Word32 *A, /* i : Cholesky matrix A */ + const Word16 N /* i : vector & matrix size */ +); + void v_mult_mat_fx( Word32 *y_fx, /* o : the product x*A */ Word16 *y_q_fx, diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index d6210dfc7..9f1a42f29 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -642,6 +642,45 @@ Word32 dot_product_cholesky_fixed( return suma; } +/*---------------------------------------------------------------------* + * dot_product_cholesky() + * + * Calculates dot product of type x'*A*A'*x, where x is column vector of size m, + * and A is a Cholesky decomposition of some Hermitian matrix S whose size is m*m. + * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) + *---------------------------------------------------------------------*/ + +/*! r: the dot product x'*A*A'*x */ +Word64 dot_product_cholesky_fixed64( + const Word32 *x, /* i : vector x Q31 - exp_x*/ + const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ + const Word16 N /* i : vector & matrix size Q0*/ +) +{ + Word16 i, j; + Word64 suma, tmp_sum; + Word32 mul; + const Word32 *pt_x, *pt_A; + pt_A = A; + suma = 0; + move32(); + FOR( i = 0; i < N; i++ ) + { + tmp_sum = 0; + move32(); + pt_x = x; + + FOR( j = 0; j <= i; j++ ) + { + mul = Mpy_32_32( *pt_x++, *pt_A++ ); + tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); + } + + suma = W_mac_32_32( suma, tmp_sum, tmp_sum ); // TODO: make sure that this does not overflow. + } + + return suma; +} void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ const Word32 *x, /* i : vector x Qx*/ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 295cff8a1..34744131f 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1683,10 +1683,8 @@ Word16 ivas_smc_gmm_fx( Word16 flag_odv; Word32 lps_fx, lpm_fx, lpn_fx; Word32 ps_fx[N_SMC_MIXTURES], pm_fx[N_SMC_MIXTURES], pn_fx[N_SMC_MIXTURES]; - Word32 lprob_fx; - Word16 lprob_exp = 0; + Word64 wprob_fx; Word32 fvm_fx[N_PCA_COEF]; - Word16 fvm_exp = 0; Word32 sum_PS_fx, ps_diff_fx, ps_sta_fx; Word32 dlp_fx, wrelE_fx, wdrop_fx, wght_fx; Word32 wrise_fx; @@ -2273,23 +2271,16 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - fvm_exp = sub( 31, Qfact_FV ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } -- GitLab From 8295f90d72abf9233508fbe0b7e0e2b30ee5f8ca Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 26 Feb 2025 12:41:24 +1100 Subject: [PATCH 200/329] add MLD to the SR pytest --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86ae985d1..995875be9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1133,7 +1133,7 @@ split-rendering-pytest-on-merge-request: - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --mld --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check -- GitLab From b2b43289ffbd1613ba80803b771ec1ad15ab5c73 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 26 Feb 2025 13:25:40 +1100 Subject: [PATCH 201/329] revert -- add MLD to the SR pytest, need changes to split rendering pytest first --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 995875be9..86ae985d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1133,7 +1133,7 @@ split-rendering-pytest-on-merge-request: - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --mld --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check -- GitLab From 832751e64a46f710d9c53d326d0b75994b6ce0e1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 26 Feb 2025 12:41:22 +0530 Subject: [PATCH 202/329] Modifications in acelp encode sub-function call stack, bug fixes and saturation removal in GenShapedSHBExcitation_enc --- lib_com/prot_fx.h | 45 +++--- lib_com/swb_tbe_com_fx.c | 213 ++++++++++++----------------- lib_enc/acelp_core_switch_enc_fx.c | 10 +- lib_enc/analy_sp_fx.c | 46 +++---- lib_enc/core_enc_init.c | 22 ++- lib_enc/core_enc_reconf.c | 7 +- lib_enc/core_enc_switch.c | 2 +- lib_enc/enc_gen_voic_fx.c | 16 +-- lib_enc/enc_pit_exc_fx.c | 14 +- lib_enc/enc_tran_fx.c | 5 +- lib_enc/enc_uv_fx.c | 10 +- lib_enc/find_tar_fx.c | 82 +++++------ lib_enc/ivas_td_low_rate_enc.c | 17 ++- lib_enc/multi_harm_fx.c | 2 +- lib_enc/pit_enc_fx.c | 176 ++++++++++++------------ lib_enc/prot_fx_enc.h | 135 +++++++++--------- lib_enc/swb_tbe_enc_fx.c | 14 +- 17 files changed, 385 insertions(+), 431 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index cf7072cf5..485ddb33d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3035,7 +3035,7 @@ void GenShapedSHBExcitation_fx( void GenShapedSHBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ Word32 *mem_csfilt, /* i/o: memory */ Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ @@ -3051,33 +3051,30 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ Word16 *shb_res, Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ Word16 *Q_bwe_exc, Word16 *Q_bwe_exc_fb, const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ const Word32 bitrate, - const Word16 prev_bfi -#if 1 // def ADD_IVAS_TBE_CODE - , /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + const Word16 prev_bfi, + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -#endif + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ ); void GenShapedSHBExcitation_ivas_dec_fx( @@ -11113,7 +11110,7 @@ void init_coder_ace_plus_ivas_fx( ); void core_coder_reconfig_ivas_fx( - Encoder_State *st ); + Encoder_State *st, const int32_t last_total_brate ); void core_coder_mode_switch_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 92271c1f1..6cdf1185a 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -2879,7 +2879,7 @@ void GenShapedSHBExcitation_fx( void GenShapedSHBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ Word32 *mem_csfilt, /* i/o: memory */ Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ @@ -2901,24 +2901,24 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 *Q_bwe_exc, Word16 *Q_bwe_exc_fb, const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, /* i : bitrate */ - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling Q0 */ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling Q0 */ + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ ) { Word16 i, j, k; @@ -2963,13 +2963,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word32 White_exc16k_32[L_FRAME16k]; Word16 White_exc16k_tmp[L_FRAME16k]; Word16 prev_Q_bwe_exc_fb; - Word16 chk1, chk2; - chk1 = 0; - chk2 = 0; - move16(); - move16(); -#if 1 // def ADD_IVAS_TBE_CODE Word16 alpha, step, mem_csfilt_left, mem_csfilt_right, excNoisyEnvLeft[L_FRAME16k], excNoisyEnvRight[L_FRAME16k]; Word16 cbsize; Word16 mix_factor, old_fact, new_fact, fact, old_scale, new_scale, step_scale; @@ -2984,7 +2978,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( mix_factor = 0; /* Q15 */ move16(); -#endif + set16_fx( zero_mem, 0, LPC_SHB_ORDER ); set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER ); FOR( i = 0; i < L_FRAME32k; i = i + 2 ) @@ -3016,11 +3010,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* i: exc16k in Q_bwe_exc */ /* o: exc16kWhtnd in Q_bwe_exc */ -#if 1 // def ADD_IVAS_TBE_CODE IF( GE_32( extl_brate, SWB_TBE_2k8 ) ) -#else - IF( GE_32( bitrate, ACELP_24k40 ) ) -#endif { temp2 = 0; move16(); @@ -3041,25 +3031,21 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* Estimate pow1 associated with Low band nonlinear extended excitation */ /* pow1=0.00001f */ tmp = sub( shl( *Q_bwe_exc, 1 ), 31 ); - pow1 = L_shl_sat( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ + W_tmp = W_shl( 21475 /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ FOR( k = 0; k < L_FRAME16k; k++ ) { /*excTmp2[k ] = (float)(fabs(exc16kWhtnd[k]));*/ excTmp2[k] = abs_s( exc16kWhtnd[k] ); move16(); - chk1 = s_or( chk1, exc16kWhtnd[k] ); /* pow1 += exc16kWhtnd[k] * exc16kWhtnd[k]; */ - pow1 = L_mac0_sat( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ + W_tmp = W_mac_16_16( W_tmp, exc16kWhtnd[k], exc16kWhtnd[k] ); // 2*Q_bwe_exc+1 } - Q_pow1 = shl( *Q_bwe_exc, 1 ); + exp = W_norm( W_tmp ); + pow1 = W_extract_h( W_shl( W_tmp, exp ) ); // 2*Q_bwe_exc+1+exp-32 = // tmp+exp + Q_pow1 = add( tmp, exp ); - test(); -#if 1 // ADD_IVAS_TBE_CODE IF( flag_ACELP16k == 0 ) -#else - IF( ( LE_32( bitrate, ACELP_13k20 ) ) && ( GE_32( bitrate, ACELP_7k20 ) ) ) -#endif { /* varEnvShape = mean_fx(voice_factors, 4); */ /* unroll the loop */ @@ -3105,12 +3091,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( test(); test(); test(); -#if 1 // def ADD_IVAS_TBE_CODE test(); IF( EQ_16( element_mode, EVS_MONO ) && *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) ) -#else - IF( *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) ) -#endif { /* pre-init smoothing filter to avoid energy drop outs */ L_tmp = L_mult( excTmp2[0], 1638 ); @@ -3137,7 +3119,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( *mem_csfilt = Mult_32_16( L_tmp, varEnvShape ); move32(); } -#if 1 // def ADD_IVAS_TBE_CODE + IF( MSFlag > 0 ) { // varEnvShape = 0.995f; @@ -3196,7 +3178,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } } ELSE -#endif { /* Track the low band envelope */ L_tmp = L_shl( *mem_csfilt, sub( Q_excTmp2, *Q_bwe_exc ) ); @@ -3222,7 +3203,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( *mem_csfilt = L_shr( L_tmp, sub( Q_excTmp2, *Q_bwe_exc ) ); move32(); } -#if 1 // def ADD_IVAS_TBE_CODE + test(); IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { @@ -3261,7 +3242,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } } ELSE -#endif { /* create a random excitation - Reuse exc16k memory */ create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); // Q5 @@ -3282,36 +3262,32 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* calculate pow22 */ /* pow22=0.00001f */ tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 ); - Word64 sum = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */ + W_tmp = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */ Q_White_exc16k = getScaleFactor32( White_exc16k_32, L_FRAME16k ); FOR( k = 0; k < L_FRAME16k; k++ ) { /* White_exc16k[k] *= excNoisyEnv[k]; */ White_exc16k[k] = extract_h( L_shl( White_exc16k_32[k], Q_White_exc16k ) ); // Q_excTmp2 + 6 + Q_White_exc16k - 16 ==> Q_excTmp2 + Q_White_exc16k - 10 move16(); - chk2 = s_or( chk2, White_exc16k[k] ); /* i: excNoisyEnv in (Q_excTmp2) */ /* i: White_exc16k in Q6 */ /* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */ + /* pow22 += White_exc16k[k] * White_exc16k[k]; */ - sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2 + Q_White_exc16k - 10)*/ + W_tmp = W_mac0_16_16( W_tmp, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2 + Q_White_exc16k - 10)*/ } - Q_pow22 = W_norm( sum ); - pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2 + Q_White_exc16k - 10)+Q_pow22-32 + Q_pow22 = W_norm( W_tmp ); + pow22 = W_extract_h( W_shl( W_tmp, Q_pow22 ) ); // 2*(Q_excTmp2 + Q_White_exc16k - 10)+Q_pow22-32 Q_pow22 = sub( add( Q_pow22, shl( sub( add( Q_White_exc16k, Q_excTmp2 ), 10 ), 1 ) ), 32 ); Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) ); } -#if 1 // def ADD_IVAS_TBE_CODE flag_plosive = 0; move16(); test(); test(); test(); IF( GE_32( extl_brate, SWB_TBE_2k8 ) || EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) -#else - IF( GE_32( bitrate, ACELP_24k40 ) ) -#endif { IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */ { @@ -3545,7 +3521,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( ELSE /* decoder side */ { test(); -#if 1 // def ADD_IVAS_TBE_CODE IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { IF( *vf_ind == 0 ) @@ -3563,7 +3538,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } } ELSE -#endif { /* *vf_ind is an integer scale by 0.125f*/ tmp = shl( *vf_ind, ( 15 - 3 ) ); @@ -3576,10 +3550,9 @@ void GenShapedSHBExcitation_ivas_enc_fx( } } } -#if 1 // def ADD_IVAS_TBE_CODE + test(); IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) ) -#endif { voice_factors[0] = mult_r( voice_factors[0], tmp2 ); move16(); @@ -3593,103 +3566,94 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#if 1 // def ADD_IVAS_TBE_CODE - Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc + test(); IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL ) { /* save buffers for IC-BWE */ // mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k); - Copy( exc16kWhtnd, nlExc16k, L_FRAME16k ); + Copy( exc16kWhtnd, nlExc16k, L_FRAME16k ); // Q_bwe_exc *nlExc16k_e = sub( 15, *Q_bwe_exc ); move16(); + // v_multc(White_exc16k, (float)sqrt(pow1 / pow22), mixExc16k, L_FRAME16k); - /*Word16 temp_fac = divide3232(L_shr(pow1, Q_pow1), pow22); - Word16 temp_fac_exp = 0; - temp_fac = Sqrt16(temp_fac, &temp_fac_exp);*/ L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); - Word16 temp_fac = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15 - // v_multc_fixed_16_16(White_exc16k,shr(temp_fac, temp_fac_exp) , mixExc16k, L_FRAME16k); + Word16 temp_fac = round_fx_sat( L_tmp ); // Q15-exp + FOR( k = 0; k < L_FRAME16k; k++ ) { - mixExc16k[k] = mult_r( White_exc16k[k], temp_fac ); // Q_bwe_exc + mixExc16k[k] = mult_r( White_exc16k[k], temp_fac ); // Q_White_exc16k+15-exp-15 = Q_White_exc16k-exp move16(); } - *mixExc16k_e = sub( 15, *Q_bwe_exc ); + *mixExc16k_e = sub( 15, sub( Q_White_exc16k, exp ) ); move16(); } -#endif - FOR( k = 0; k < L_FRAME16k; k++ ) - { - White_exc16k_FB[k] = White_exc16k[k]; /* Q_bwe_exc */ - move16(); - } + Copy( White_exc16k, White_exc16k_FB, L_FRAME16k ); // Q_White_exc16k prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; + *Q_bwe_exc_fb = Q_White_exc16k; move16(); - *Q_bwe_exc_fb = *Q_bwe_exc; move16(); - deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); - /* i/o: White_exc16k (Q_bwe_exc) */ - /* i: tbe_demph (Q_bwe_exc) */ + Word16 tbe_demph_fx = shl_sat( *tbe_demph, sub( Q_White_exc16k, *Q_bwe_exc ) ); // Q_White_exc16k + + deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, &tbe_demph_fx ); + /* i/o: White_exc16k (Q_White_exc16k) */ + /* i: tbe_demph_fx (Q_White_exc16k) */ + *tbe_demph = shr_sat( tbe_demph_fx, sub( Q_White_exc16k, *Q_bwe_exc ) ); + move16(); -#if 1 // def ADD_IVAS_TBE_CODE test(); IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) { IF( !flag_plosive ) /* use only LB excitation in case of plosives */ { /* re-scale gaussian excitation at the beginning to gradually move from old energy to new energy */ - // old_scale = (float)sqrt(*prev_pow_exc16kWhtnd / pow1); - // old_scale = divide3232(*prev_pow_exc16kWhtnd, pow1); // exp = Q15 - (Q_pow1) - // Word16 old_scale_exp = Q15 - (Q_pow1); - // old_scale = Sqrt16(old_scale, &old_scale_exp); - // old_scale = shl(old_scale, old_scale_exp); //Q15 - L_tmp = root_a_over_b_fx( *prev_pow_exc16kWhtnd, 0, pow1, Q_pow1, &exp ); - IF( exp < 0 ) - { - L_tmp = L_shl( L_tmp, exp ); - exp = 0; - move16(); - } - old_scale = round_fx_sat( L_tmp ); // exp + /* old_scale = (float) sqrt( *prev_pow_exc16kWhtnd / pow1 ); */ + old_scale = round_fx_sat( root_a_over_b_fx( *prev_pow_exc16kWhtnd, 0, pow1, Q_pow1, &exp ) ); // exp + old_scale = shl( old_scale, s_min( 0, exp ) ); // limit Q factor to 15 + exp = s_max( 0, exp ); + // new_scale = 1.0f; new_scale = shr( 32767, exp ); // exp + // step_scale = (new_scale - old_scale) / (L_FRAME16k / 2); step_scale = mult_r( sub( new_scale, old_scale ), 205 ); // exp scale = old_scale; // exp move16(); + /* interpolate between the old and the new value of the mixing factor */ old_fact = *prev_mix_factor; // Q15 + new_fact = mix_factor; // Q15 move16(); - new_fact = mix_factor; // Q15 move16(); + // step = (new_fact - old_fact) / (L_FRAME16k / 2); step = mult_r( sub( new_fact, old_fact ), 205 ); // Q15 fact = old_fact; // Q15 move16(); + + shift = add( exp, sub( *Q_bwe_exc, Q_White_exc16k ) ); + /* mixing of LB and gaussian excitation in the first half of the frame */ FOR( k = 0; k < L_FRAME16k / 2; k++ ) { - // exc16kWhtnd[k] = (float)fact * (White_exc16k[k] * scale) + (float)(1 - fact) * exc16kWhtnd[k]; - // exc16kWhtnd[k] = add(mult_r(fact, mult(shl(White_exc16k[k], *Q_bwe_exc), scale)), mult_r(sub(32767, fact), exc16kWhtnd[k])); - L_tmp = L_add_sat( L_shl_sat( L_mult( fact, mult_r( White_exc16k[k], scale ) ), exp ), // Q15 + Q_bwe_exc + (Q15-exp) - Q15 + exp + Q1 - L_mult( sub( 32767, fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc + Q16 - exc16kWhtnd[k] = round_fx_sat( L_tmp ); // Q_bwe_exc + /* exc16kWhtnd[k] = (float)fact * (White_exc16k[k] * scale) + (float)(1 - fact) * exc16kWhtnd[k]; */ + L_tmp = L_shl_sat( L_mult( fact, mult_r( White_exc16k[k], scale ) ), shift ); // Q_bwe_exc+16 + exc16kWhtnd[k] = mac_r_sat( L_tmp, sub( 32767, fact ), exc16kWhtnd[k] ); // Q_bwe_exc move16(); + fact = add_sat( fact, step ); // Q15 scale = add_sat( scale, step_scale ); // exp } + shift = sub( *Q_bwe_exc, Q_White_exc16k ); /* mixing of LB and gaussian excitation in the second half of the frame */ FOR( ; k < L_FRAME16k; k++ ) { // exc16kWhtnd[k] = (float)new_fact * White_exc16k[k] + (float)(1 - new_fact) * exc16kWhtnd[k]; - // exc16kWhtnd[k] = add(mult_r(new_fact, shl(White_exc16k[k], *Q_bwe_exc)), mult_r(sub(32767, new_fact), exc16kWhtnd[k])); - L_tmp = L_add( L_mult( new_fact, White_exc16k[k] ), - mult_r( sub( 32767, new_fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc + Q15 + Q1 => Q_bwe_exc + Q16 - exc16kWhtnd[k] = round_fx( L_tmp ); // Q_bwe_exc + L_tmp = L_shl_sat( L_mult( new_fact, White_exc16k[k] ), shift ); // Q_bwe_exc+16 + exc16kWhtnd[k] = mac_r( L_tmp, sub( 32767, new_fact ), exc16kWhtnd[k] ); // Q_bwe_exc move16(); } } @@ -3697,32 +3661,28 @@ void GenShapedSHBExcitation_ivas_enc_fx( PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE -#endif { -#if 1 // def ADD_IVAS_TBE_CODE test(); IF( EQ_16( coder_type, UNVOICED ) || EQ_16( MSFlag, 1 ) ) -#else - IF( EQ_16( coder_type, UNVOICED ) ) -#endif { - L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); + scale = 0; + move16(); + test(); - if ( chk1 == 0 && chk2 == 0 ) + IF( pow1 != 0 && pow22 != 0 ) { - L_tmp = 0; - move32(); + L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); + scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ } - scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ + FOR( k = 0; k < L_FRAME16k; k++ ) { - /* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */ - L_tmp = L_mult( White_exc16k[k], scale ); // Q_bwe_exc + Q15 + Q1 => Q_bwe_exc + Q16 - /* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */ - exc16kWhtnd[k] = round_fx_sat( L_tmp ); // Q_bwe_exc + exc16kWhtnd[k] = mult_r_sat( White_exc16k[k], scale ); // Q_White_exc16k move16(); - /* exc16kWhtnd: Q_bwe_exc */ } + + Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc + PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc /* i/o: exc16kWhtnd (Q_bwe_exc) */ /* i/o: tbe_premph (Q_bwe_exc) */ @@ -3785,13 +3745,13 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ } + shift = sub( *Q_bwe_exc, Q_White_exc16k ); FOR( j = 0; j < lSubFr; j++ ) { /*exc16kWhtnd[k+j] = temp1 * exc16kWhtnd[k+j] + temp2 * White_exc16k[k+j]; */ - L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc)*/ + L_tmp = L_shl_sat( L_mult( temp2, White_exc16k[k + j] ), shift ); // 16+(Q_bwe_exc) exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); // Q_bwe_exc move16(); - /* Q_bwe_exc */ } k = add( k, lSubFr ); @@ -3813,11 +3773,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( } } -#if 1 // def ADD_IVAS_TBE_CODE IF( LT_32( extl_brate, SWB_TBE_2k8 ) ) -#else - IF( LT_32( bitrate, ACELP_24k40 ) ) -#endif { syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 ); /* i: exc16kWhtnd in Q_bwe_exc */ @@ -3928,8 +3884,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp ); Scale_sig( fb_tbe_demph, 1, tmp ); syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 ); - /* i: White_exc16k_FB in (14-n2) */ - /* o: White_exc16k_FB_temp in (14-n2) */ + /* i: White_exc16k_FB in (Q_bwe_exc_fb) */ + /* o: White_exc16k_FB_temp in (Q_bwe_exc_fb) */ FOR( i = 0; i < 10; i++ ) { @@ -3951,10 +3907,11 @@ void GenShapedSHBExcitation_ivas_enc_fx( set16_fx( White_exc16k_FB, 0, L_FRAME16k ); } -#if 1 // def ADD_IVAS_TBE_CODE *prev_pow_exc16kWhtnd = L_shr_sat( pow1, Q_pow1 ); // power goes above MAX_32 *prev_mix_factor = mix_factor; -#endif + move32(); + move16(); + return; } diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 47c735a85..8268d48b1 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -570,6 +570,7 @@ static void encod_gen_voic_core_switch_ivas_fx( Word16 h2[L_SUBFR + ( M + 1 )]; Word16 dummyF[NB_SUBFR16k]; Word16 lp_select, lp_flag; + Word16 q_h1; LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ BSTR_ENC_HANDLE hBstr; @@ -634,9 +635,8 @@ static void encod_gen_voic_core_switch_ivas_fx( find_targets_ivas_fx( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, TILT_FAC_FX, xn, cn, h1 ); } - /*Scale_sig(h1, L_SUBFR, shift); */ /*Q14-shift */ - Copy_Scale_sig( h1, h2, L_SUBFR, -2 ); - Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + q_h1 = sub( 14, norm_s( h1[0] ) ); + Copy_Scale_sig( h1, h2, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); /* Q_new */ @@ -646,8 +646,9 @@ static void encod_gen_voic_core_switch_ivas_fx( * Adaptive exc. construction *----------------------------------------------------------------*/ set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */ + pitch = pit_encode_ivas_fx( hBstr, - st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ ); /* Q6 */ + st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/, Q_new ); /* Q6 */ /*-----------------------------------------------------------------* * Find adaptive exitation @@ -666,6 +667,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ + Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index c0d1a8bca..d5333ae13 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -445,29 +445,29 @@ static void find_enr_dft_ivas_fx( * Spectral analysis of 12.8kHz input *-------------------------------------------------------------------*/ void ivas_analy_sp_fx( - const Word16 element_mode, /* i : element mode Q0*/ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 input_Fs, /* i : input sampling rate Q0*/ - Word16 *speech, /* i : speech buffer Q_new - preemph_bits */ - const Word16 Q_new, /* i : current scaling exp Q0 */ - Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */ - Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */ - Word32 *lf_E, /* o : per bin E for first... q_lf_E */ - Word16 *q_lf_E, /* o : per bin E for first... Q0 */ - Word16 *Etot, /* o : total input energy Q8 */ - const Word16 min_band, /* i : minimum critical band Q0 */ - const Word16 max_band, /* i : maximum critical band Q0 */ - Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */ - Word16 *q_Bin_E, /* o : per-bin energy spectrum Q7 */ - Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */ - Word16 *q_Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */ - Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */ - Word16 *q_PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */ - Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */ - Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies)*/ - Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */ - Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */ - Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */ + const Word16 element_mode, /* i : element mode Q0 */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 input_Fs, /* i : input sampling rate Q0 */ + Word16 *speech, /* i : speech buffer Q_new */ + const Word16 Q_new, /* i : current scaling exp Q0 */ + Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */ + Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */ + Word32 *lf_E, /* o : per bin E for first... q_lf_E */ + Word16 *q_lf_E, /* o : per bin E for first... Q0 */ + Word16 *Etot, /* o : total input energy Q8 */ + const Word16 min_band, /* i : minimum critical band Q0 */ + const Word16 max_band, /* i : maximum critical band Q0 */ + Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */ + Word16 *q_Bin_E, /* o : per-bin energy spectrum Q0 */ + Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame q_Bin_E_old */ + Word16 *q_Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q0 */ + Word32 *PS, /* o : per-bin energy spectrum q_PS */ + Word16 *q_PS, /* o : per-bin energy spectrum Q0 */ + Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */ + Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies) */ + Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */ + Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */ + Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */ ) { Word16 *pt; diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index e98956efe..74f73bf52 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -53,8 +53,8 @@ static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); static void init_core_sig_ana_ivas_fx( Encoder_State *st ); static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ); -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift ); +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate); +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate); /*-----------------------------------------------------------------------* * init_coder_ace_plus() * @@ -223,11 +223,11 @@ void init_coder_ace_plus_ivas_fx( } /* Initialize Signal Buffers */ - init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr ); + init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate); /* Initialize ACELP */ - init_acelp_ivas_fx( st, L_frame_old, 0 ); + init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate); if ( st->ini_frame == 0 ) { @@ -442,7 +442,7 @@ static void init_tcx_ivas_fx( * Initialization of signal buffers *-----------------------------------------------------------------------*/ /*copy of evs function since it was static */ -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ) +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate) { LPD_state_HANDLE hLPDmem = st->hLPDmem; @@ -478,7 +478,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol test(); test(); test(); - IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) { lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); test(); @@ -530,7 +530,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol move16(); } /*coming from TCXonly modes*/ - ELSE IF( !st->tcxonly && GE_32( st->last_total_brate, ACELP_32k ) ) + ELSE IF( !st->tcxonly && GE_32(last_total_brate, ACELP_32k ) ) { Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); @@ -647,7 +647,7 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st ) * * *-----------------------------------------------------------------------*/ -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift ) +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate) { Word16 mem_syn_r_size_old; Word16 mem_syn_r_size_new; @@ -753,7 +753,7 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh test(); test(); test(); - IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) { Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ IF( EQ_16( st->L_frame, L_FRAME16k ) ) @@ -959,8 +959,6 @@ static void init_modes_ivas_fx( Word8 n; Word32 tmp32; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - (void) last_total_brate; - /* Restrict ACE/TCX20/TCX10 mode */ move16(); @@ -1050,7 +1048,7 @@ static void init_modes_ivas_fx( } /* Reconfigure core */ - core_coder_reconfig_ivas_fx( st ); + core_coder_reconfig_ivas_fx( st, last_total_brate); return; diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c index 24729c124..890194966 100644 --- a/lib_enc/core_enc_reconf.c +++ b/lib_enc/core_enc_reconf.c @@ -49,7 +49,8 @@ *-----------------------------------------------------------------*/ void core_coder_reconfig_ivas_fx( - Encoder_State *st ) + Encoder_State *st, + const int32_t last_total_brate ) { Word16 i, bwidth, index; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; @@ -324,7 +325,7 @@ void core_coder_reconfig_ivas_fx( test(); test(); test(); - IF( ( LT_32( st->total_brate, ACELP_24k40 ) ) && ( ( GT_32( st->total_brate, st->last_total_brate ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) + IF( ( LT_32( st->total_brate, ACELP_24k40 ) ) && ( ( GT_32( st->total_brate, last_total_brate ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) { /* low-freq memQuantZeros_fx must be reset partially if bitrate increased */ FOR( i = 0; i < hTcxEnc->nmStartLine; i++ ) @@ -333,7 +334,7 @@ void core_coder_reconfig_ivas_fx( move16(); } } - ELSE IF( ( GE_32( st->total_brate, ACELP_24k40 ) ) && ( LE_32( st->total_brate, ACELP_32k ) ) && ( GE_32( st->last_total_brate, ACELP_13k20 ) ) && ( LT_32( st->last_total_brate, ACELP_24k40 ) ) ) + ELSE IF( ( GE_32( st->total_brate, ACELP_24k40 ) ) && ( LE_32( st->total_brate, ACELP_32k ) ) && ( GE_32( last_total_brate, ACELP_13k20 ) ) && ( LT_32( last_total_brate, ACELP_24k40 ) ) ) { FOR( i = 0; i < st->L_frame; i++ ) /* memQuantZeros_fx won't be updated */ { diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index b6f723c2b..81b299057 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -206,7 +206,7 @@ void core_coder_mode_switch_ivas_fx( st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 ); move16(); - core_coder_reconfig_ivas_fx( st ); + core_coder_reconfig_ivas_fx( st, last_total_brate); } ELSE { diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 96e7e274c..1053f8b00 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -465,13 +465,13 @@ void encod_gen_voic_ivas_fx( Word16 shift_wsp; Word16 harm_flag_acelp; Word16 lp_select, lp_flag, L_frame; + Word16 q_h1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; /*------------------------------------------------------------------* @@ -554,16 +554,16 @@ void encod_gen_voic_ivas_fx( find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ - Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/ + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); *pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, - L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ + L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */ + move16(); - // tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx); tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); /*-----------------------------------------------------------------* @@ -588,7 +588,7 @@ void encod_gen_voic_ivas_fx( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ - + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); @@ -597,10 +597,6 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } - /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ - hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /* Q14 */ - move16(); - /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index e0d4f5016..e03db0c47 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -580,7 +580,7 @@ void enc_pit_exc_ivas_fx( Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/ Word16 h1_q15[PIT_EXC_L_SUBFR + ( M + 1 )]; - SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; + Word16 q_h1; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; @@ -740,8 +740,8 @@ void enc_pit_exc_ivas_fx( find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */ - Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + q_h1 = sub( 14, norm_s( h1[0] ) ); + Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */ @@ -750,9 +750,12 @@ void enc_pit_exc_ivas_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ + *pt_pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, - L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ + L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */ move16(); + Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ @@ -779,9 +782,6 @@ void enc_pit_exc_ivas_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } - /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ - hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ - gpit_tmp = gain_pit; move16(); /*Q14*/ test(); diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index b4495d4ff..bf04daff5 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -467,6 +467,7 @@ Word16 encod_tran_ivas_fx( Word16 L_frame_fx; Word16 shift_wsp; Word32 L_tmp; + Word16 q_h1; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -540,7 +541,9 @@ Word16 encod_tran_ivas_fx( find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); + q_h1 = sub( 14, norm_s( h1[0] ) ); + Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) ); /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 32c397613..0be344d72 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -93,8 +93,8 @@ void encod_unvoiced_fx( i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ @@ -279,6 +279,7 @@ void encod_unvoiced_ivas_fx( Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i; Word16 index, i_subfr_idx; Word16 unbits_PI; + Word16 q_h1; acelp_cfg = &( st_fx->acelp_cfg ); SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; @@ -319,8 +320,9 @@ void encod_unvoiced_ivas_fx( find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); - Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index c758db8f3..4e15bc828 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -171,16 +171,19 @@ void find_targets_ivas_fx( Word16 tilt_fac, /* i : tilt factor Q15*/ Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/ Word16 *cn, /* o : target vector in residual domain Q_new*/ - Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/ + Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/ ) { Word16 i; Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */ Word16 scale, scaleq, j, d, s, s2, tmp; Word16 Aqs[M + 1]; - Word32 Ltmp; + Word32 h1_32[6 * L_SUBFR]; + Word16 sf; + Word64 Ltmp64; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif /*------------------------------------------------------------------------* * Find the target vector for excitation search: @@ -200,12 +203,14 @@ void find_targets_ivas_fx( temp[i] = sub_sat( speech[i + i_subfr - M], mem_syn[i] ); /* Q_new - 1 */ move16(); } - Syn_filt_s( 1, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); - Residu3_fx( Ap, temp + M, xn, L_subfr, 0 ); /* xn in Q_new -1*/ + syn_filt_fx( 0, p_Aq, M, &res[i_subfr], temp + M, L_subfr, temp, 0 ); - deemph_fx( xn, tilt_fac, L_subfr, mem_w0 ); /* xn in Q_new -1 */ + Residu3_fx( Ap, temp + M, xn, L_subfr, 0 ); /* xn in Q_new */ + + deemph_fx( xn, tilt_fac, L_subfr, mem_w0 ); /* xn in Q_new */ + *mem_w0 = shr( *mem_w0, 1 ); // Q_new - 1 /*-----------------------------------------------------------------* * Find target in residual domain (cn[]) for innovation search @@ -216,13 +221,13 @@ void find_targets_ivas_fx( temp[0] = 0; move16(); preemph_copy_fx( xn, cn, tilt_fac, shr( L_subfr, 1 ), temp ); - syn_filt_s_lc_fx( 1, Ap, cn, temp, shr( L_subfr, 1 ) ); /* Q-1 -> Q-2 */ - Residu3_lc_fx( p_Aq, M, temp, cn, shr( L_subfr, 1 ), 1 ); /* Q-2 -> Q-1 */ - Scale_sig( cn, shr( L_subfr, 1 ), 1 ); /* Q_new */ + syn_filt_s_lc_fx( 1, Ap, cn, temp, shr( L_subfr, 1 ) ); /* Q_new -> Q_new - 1 */ + Residu3_lc_fx( p_Aq, M, temp, cn, shr( L_subfr, 1 ), 1 ); /* Q_new - 1 -> Q_new */ /* second half: res[] --> cn[] (approximated and faster) */ Copy( &res[i_subfr + shr( L_subfr, 1 )], cn + shr( L_subfr, 1 ), shr( L_subfr, 1 ) ); /* Q_new */ } + scale_sig( xn, L_subfr, -1 ); // Q_new - 1 /*---------------------------------------------------------------* * Compute impulse response, h1[], of weighted synthesis filter * @@ -242,67 +247,48 @@ void find_targets_ivas_fx( Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */ s = add( scale, 1 ); s2 = 16384; + move16(); } - set16_fx( h1, 0, L_subfr ); + + set32_fx( h1_32, 0, L_subfr ); Overflow = 0; move16(); FOR( i = 0; i < M; i++ ) { - Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ + Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= i; j++ ) { - Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ } - h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ + h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ + move32(); } - Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ + + Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) { - Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ } - h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ + h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */ + move32(); - // PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to prevent saturation/overflow and the subsequent loop\n") FOR( i = M + 1; i < L_subfr; i++ ) { - Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */ + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ FOR( j = 2; j <= M; j++ ) { - Ltmp = L_msu_o( Ltmp, Aqs[j], h1[i - j], &Overflow ); /* Q27 */ - } - h1[i] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ - } - IF( Overflow ) - { - s2 = shr( s2, 1 ); - FOR( i = 0; i < M; i++ ) - { - Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ - FOR( j = 1; j <= i; j++ ) - { - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ - } - h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ - } - Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ - FOR( j = 1; j <= M; j++ ) - { - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ - } - h1[M] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */ - FOR( i = M + 1; i < L_subfr; i++ ) - { - Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */ - FOR( j = 2; j <= M; j++ ) - { - Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ - } - h1[i] = round_fx( L_shl( Ltmp, s ) ); /* Q11 + s */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ } + h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ + move32(); } + sf = sub( L_norm_arr( h1_32, L_subfr ), 1 ); + Copy_Scale_sig32_16( h1_32, h1, L_subfr, sf ); // Q11 + sf + tmp = 0; - Deemph2( h1, tilt_fac, L_subfr, &tmp ); + move16(); + Deemph2( h1, tilt_fac, L_subfr, &tmp ); // Q11 + sf - 1 return; } diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index d09134951..5fffadc77 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -219,6 +219,7 @@ void encod_gen_2sbfr( Word32 norm_gain_code; Word16 pitch_limit_flag; Word16 error; + Word16 q_h1; LPD_state_HANDLE hLPDmem = st->hLPDmem; @@ -269,26 +270,23 @@ void encod_gen_2sbfr( Copy( &res[i_subfr], &exc[i_subfr], 2 * L_SUBFR ); // Q_new - // Scaling mem_syn buffer to Q_new - 1 from e_mem_syn - // Scale_sig( &hLPDmem->mem_w0, M + 1, sub( add( *Q_new, hLPDmem->e_mem_syn ), Q16 ) ); // M + 1 to sync mem_syn exponent with mem_w0 exponent - // hLPDmem->e_mem_syn = sub( Q16, *Q_new ); - - #ifndef FIX_1320_LOWRATE_ACELP find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); #else find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); #endif - /*Scale_sig(h1, L_SUBFR, shift); */ /*Q14-shift */ - Copy_Scale_sig( h1, h2, 2 * L_SUBFR, -2 ); - Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + + q_h1 = sub( 14, norm_s( h1[0] ) ); + Copy_Scale_sig( h1, h2, 2 * L_SUBFR, sub( 11, q_h1 ) ); /*------------------------------------------------------------------------* * Close-loop pitch search on the 1st and 3rd subfr only and quantization * Adaptive exc. construction *------------------------------------------------------------------------*/ + *pt_pitch = pit_encode_ivas_fx( st->hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 0, L_frame, coder_type, &pitch_limit_flag, i_subfr, exc, 2 * L_SUBFR, st->pitch, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); + move16(); - *pt_pitch = pit_encode_ivas_fx( st->hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 0, L_frame, coder_type, &pitch_limit_flag, i_subfr, exc, 2 * L_SUBFR, st->pitch, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); + Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); @@ -310,6 +308,7 @@ void encod_gen_2sbfr( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ + Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ #ifndef FIX_1320_LOWRATE_ACELP lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 86fe541bb..78ef81c60 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -652,7 +652,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni pt1++; pt2++; } - tmp2 = L_shr_sat( tmp2_32, 7 ); // q15-> q8 + tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8 IF( EQ_16( bwidth, NB ) ) { diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 3793ee00d..80e144743 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -487,26 +487,27 @@ Word16 pit_encode_fx( /* o : Fractional pitc return pitch_cl; } -Word16 pit_encode_ivas_fx( /* o : Fractional pitch for each subframe */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 pitch_bits[], /* i : pitch bits */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *exc, /* i/o: pointer to excitation signal frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 *pitch, /* i : open loop pitch estimates in current frame */ - Word16 *T0_min, /* i/o: lower limit for close-loop search */ - Word16 *T0_max, /* i/o: higher limit for close-loop search */ - Word16 *T0, /* i/o: close loop integer pitch */ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ - const Word16 *h1, /* i : weighted filter input response */ - const Word16 *xn, /* i : target vector */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +Word16 pit_encode_ivas_fx( /* o : Fractional pitch for each subframe */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 pitch_bits[], /* i : pitch bits */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 *pitch, /* i : open loop pitch estimates in current frame */ + Word16 *T0_min, /* i/o: lower limit for close-loop search */ + Word16 *T0_max, /* i/o: higher limit for close-loop search */ + Word16 *T0, /* i/o: close loop integer pitch */ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ + const Word16 *h1, /* i : weighted filter input response Q(14 - norm_s(h1[0]) */ + const Word16 *xn, /* i : target vector Q_new */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ + Word16 Q_new /* i */ ) { Word16 pitch_cl; @@ -617,6 +618,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional { nBits = pitch_bits[i_subfr >> L_sufr_sft]; } + test(); IF( EQ_16( coder_type, AUDIO ) ) { /*-------------------------------------------------------* @@ -628,7 +630,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional move16(); test(); test(); - if ( EQ_16( L_subfr, L_frame / 2 ) && i_subfr != 0 && EQ_16( L_frame, L_FRAME ) ) + if ( EQ_16( L_subfr, shr( L_frame, 1 ) ) && i_subfr != 0 && EQ_16( L_frame, L_FRAME ) ) { pit_flag = L_SUBFR; move16(); @@ -656,7 +658,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional } /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_subfr ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_subfr, Q_new ); move16(); pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } @@ -684,19 +686,17 @@ Word16 pit_encode_ivas_fx( /* o : Fractional test(); IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 5 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR, Q_new ); move16(); } ELSE IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR, Q_new ); move16(); } pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } -#if 1 - //#ifdef ADD_LRTD ELSE IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) { /*-------------------------------------------------------* @@ -731,7 +731,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional IF( nBits > 0 ) { /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, Q_new ); move16(); IF( EQ_16( delta, 8 ) ) { @@ -748,7 +748,6 @@ Word16 pit_encode_ivas_fx( /* o : Fractional move16(); } } -#endif ELSE { /*-------------------------------------------------------* @@ -778,12 +777,12 @@ Word16 pit_encode_ivas_fx( /* o : Fractional { IF( *limit_flag == 0 ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, Q_new ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR, Q_new ); move16(); } } @@ -791,18 +790,18 @@ Word16 pit_encode_ivas_fx( /* o : Fractional { IF( *limit_flag == 0 ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, Q_new ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR, Q_new ); move16(); } } ELSE IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR, Q_new ); } pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); @@ -812,12 +811,12 @@ Word16 pit_encode_ivas_fx( /* o : Fractional test(); IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 6 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR, Q_new ); move16(); } ELSE IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR, Q_new ); move16(); } @@ -858,7 +857,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional } /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, Q_new ); move16(); } ELSE IF( EQ_32( core_brate, ACELP_8k85 ) ) @@ -881,7 +880,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional } /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, Q_new ); move16(); } ELSE @@ -908,7 +907,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional } /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, Q_new ); move16(); } @@ -1156,19 +1155,20 @@ Word16 delta_pit_enc_fx( /* o : pitch index * * Find the closed loop pitch period with 1/4 subsample resolution. *-------------------------------------------------------------------*/ -Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */ - const Word16 exc[], /* i : excitation buffer Q_new*/ - const Word16 xn[], /* i : target signal Q_new-1+shift*/ - const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ - const Word16 t0_min, /* i : minimum value in the searched range. Q0*/ - const Word16 t0_max, /* i : maximum value in the searched range. Q0*/ - Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ - const Word16 i_subfr, /* i : flag to first subframe */ - const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ - const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ - const Word16 t0_fr1, /* i : minimum value for resolution 1 */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 L_subfr /* i : size of subframe */ +Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */ + const Word16 exc[], /* i : excitation buffer Q_new */ + const Word16 xn[], /* i : target signal Q_new-1 */ + const Word16 h[], /* i : weighted synthesis filter impulse response Q(14 - norm_s[h[0]) */ + const Word16 t0_min, /* i : minimum value in the searched range. Q0 */ + const Word16 t0_max, /* i : maximum value in the searched range. Q0 */ + Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ + const Word16 i_subfr, /* i : flag to first subframe */ + const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ + const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ + const Word16 t0_fr1, /* i : minimum value for resolution 1 */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 L_subfr, /* i : size of subframe */ + Word16 Q_new /* i */ ) { Word16 i; @@ -1225,7 +1225,7 @@ Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch move16(); move16(); /* corr[t_min..t_max] */ - norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); + norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr, Q_new ); /*-----------------------------------------------------------------* * Find integer pitch @@ -1238,7 +1238,7 @@ Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch FOR( i = add( t0_min, 1 ); i <= t0_max; i++ ) { - if ( corr[i] >= max_val ) + if ( GE_16( corr[i], max_val ) ) { t0 = i; move16(); @@ -1346,6 +1346,7 @@ Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch return ( t0 ); } + Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ const Word16 exc[], /* i : excitation buffer Q_new*/ const Word16 xn[], /* i : target signal Q_new-1+shift*/ @@ -1545,43 +1546,35 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag * excitation) *---------------------------------------------------------------------*/ void norm_corr_ivas_fx( - const Word16 exc[], /* i : excitation buffer Q_new*/ - const Word16 xn[], /* i : target signal Q_new-1+shift*/ - const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ - const Word16 t_min, /* i : minimum value of searched range */ - const Word16 t_max, /* i : maximum value of searched range */ - Word16 ncorr[], /* o : normalized correlation Q15 */ - const Word16 L_subfr /* i : subframe size */ + const Word16 exc[], /* i : excitation buffer Q_new */ + const Word16 xn[], /* i : target signal Q_new-1 */ + const Word16 h[], /* i : weighted synthesis filter impulse response Q(14 - norm_s(h[0])) */ + const Word16 t_min, /* i : minimum value of searched range */ + const Word16 t_max, /* i : maximum value of searched range */ + Word16 ncorr[], /* o : normalized correlation */ + const Word16 L_subfr, /* i : subframe size */ + Word16 Q_new /* i */ ) { Word16 i, k, t; - Word16 corr, exp_corr, norm, exp_norm, exp, scale; + Word16 corr, exp_corr, norm, exp_norm, exp; Word16 excf[L_FRAME16k]; + Word16 ncorr_e[15 + 2 * L_INTERPOL1 + 1]; + Word16 h_e, e_max; Word32 L_tmp; Word64 W_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif k = negate( t_min ); - + h_e = add( 1, norm_s( h[0] ) ); // exponent of h /*-----------------------------------------------------------------* * compute the filtered excitation for the first delay t_min *-----------------------------------------------------------------*/ - conv_fx( &exc[k], h, excf, L_subfr ); - - /* Compute rounded down 1/sqrt(energy of xn[]) */ - L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); - FOR( i = 1; i < L_subfr; i++ ) - { - L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); - } - exp = norm_l( L_tmp ); - exp = sub( 30, exp ); - - exp = add( exp, 2 ); /* energy of xn[] x 2 + rounded up */ - scale = negate( shr( exp, 1 ) ); /* (1< 0; i-- ) { /* saturation can occur in add() */ - /*excf[i] = add(mult(exc[k], h[i]), excf[i - 1]); move16(); */ excf[i] = round_fx_sat( L_mac_sat( L_mult( excf[i - 1], 32767 ), exc[k], h[i] ) ); + move16(); } excf[0] = mult_r( exc[k], h[0] ); move16(); } } + // Aligning the values of ncorr to a common exponent + maximum_fx( ncorr_e, t_max + 1 - t_min, &e_max ); + FOR( t = t_min; t <= t_max; t++ ) + { + ncorr[t] = shr( ncorr[t], sub( e_max, ncorr_e[t - t_min] ) ); + move16(); + } return; } + void norm_corr_fx( const Word16 exc[], /* i : excitation buffer Q_new*/ const Word16 xn[], /* i : target signal Q_new-1+shift*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 711d7069a..a3a7bd910 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -954,15 +954,18 @@ void norm_corr_fx( Word16 ncorr[], /* o : normalized correlation Q15 */ const Word16 L_subfr /* i : subframe size */ ); + void norm_corr_ivas_fx( - const Word16 exc[], /* i : excitation buffer Q_new*/ - const Word16 xn[], /* i : target signal Q_new-1+shift*/ - const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ - const Word16 t_min, /* i : minimum value of searched range */ - const Word16 t_max, /* i : maximum value of searched range */ - Word16 ncorr[], /* o : normalized correlation Q15 */ - const Word16 L_subfr /* i : subframe size */ + const Word16 exc[], /* i : excitation buffer Q_new */ + const Word16 xn[], /* i : target signal Q_new-1 */ + const Word16 h[], /* i : weighted synthesis filter impulse response Q(14 - norm_s(h[0])) */ + const Word16 t_min, /* i : minimum value of searched range */ + const Word16 t_max, /* i : maximum value of searched range */ + Word16 ncorr[], /* o : normalized correlation */ + const Word16 L_subfr, /* i : subframe size */ + Word16 Q_new /* i */ ); + Word16 peak_avrg_ratio_fx( const Word32 total_brate, /* Q0 */ const Word32 *input_hi_fx, /* i : i signal Q_coeff*/ @@ -1024,20 +1027,23 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag const Word16 L_frame, /* i : length of the frame */ const Word16 L_subfr /* i : size of subframe */ ); -Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */ - const Word16 exc[], /* i : excitation buffer Q_new*/ - const Word16 xn[], /* i : target signal Q_new-1+shift*/ - const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ - const Word16 t0_min, /* i : minimum value in the searched range. Q0*/ - const Word16 t0_max, /* i : maximum value in the searched range. Q0*/ - Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ - const Word16 i_subfr, /* i : flag to first subframe */ - const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ - const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ - const Word16 t0_fr1, /* i : minimum value for resolution 1 */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 L_subfr /* i : size of subframe */ + +Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */ + const Word16 exc[], /* i : excitation buffer Q_new */ + const Word16 xn[], /* i : target signal Q_new-1 */ + const Word16 h[], /* i : weighted synthesis filter impulse response Q(14 - norm_s[h[0]) */ + const Word16 t0_min, /* i : minimum value in the searched range. Q0 */ + const Word16 t0_max, /* i : maximum value in the searched range. Q0 */ + Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ + const Word16 i_subfr, /* i : flag to first subframe */ + const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ + const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ + const Word16 t0_fr1, /* i : minimum value for resolution 1 */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 L_subfr, /* i : size of subframe */ + Word16 Q_new /* i */ ); + void pit_Q_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -2222,29 +2228,29 @@ void analy_sp_fx( ); void ivas_analy_sp_fx( - const Word16 element_mode, /* i : element mode */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 input_Fs, /* i : input sampling rate */ - Word16 *speech, /* i : speech buffer Q_new - preemph_bits */ - const Word16 Q_new, /* i : current scaling exp Q0 */ - Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */ - Word16 *q_fr_bands, /* o : Q of energy in critical frequency bands Q0 */ - Word32 *lf_E, /* o : per bin E for first... Q0 */ - Word16 *q_lf_E, /* o : Q of per bin E for first... q_lf_E */ - Word16 *Etot, /* o : total input energy Q8 */ - const Word16 min_band, /* i : minimum critical band Q0 */ - const Word16 max_band, /* i : maximum critical band Q0 */ - Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */ - Word16 *q_Bin_E, /* o : Q of per-bin energy spectrum Q0 */ - Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame q_Bin_E_old */ - Word16 *q_Bin_E_old, /* o : Q of per-bin energy spectrum of the previous frame Q0 */ - Word32 *PS, /* o : per-bin energy spectrum q_PS */ - Word16 *q_PS, /* o : Q of per-bin energy spectrum Q0 */ - Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */ - Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies)*/ - Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */ - Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */ - Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */ + const Word16 element_mode, /* i : element mode Q0 */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 input_Fs, /* i : input sampling rate Q0 */ + Word16 *speech, /* i : speech buffer Q_new */ + const Word16 Q_new, /* i : current scaling exp Q0 */ + Word32 *fr_bands, /* o : energy in critical frequency bands q_fr_bands */ + Word16 *q_fr_bands, /* o : energy in critical frequency bands Q0 */ + Word32 *lf_E, /* o : per bin E for first... q_lf_E */ + Word16 *q_lf_E, /* o : per bin E for first... Q0 */ + Word16 *Etot, /* o : total input energy Q8 */ + const Word16 min_band, /* i : minimum critical band Q0 */ + const Word16 max_band, /* i : maximum critical band Q0 */ + Word32 *Bin_E, /* o : per-bin energy spectrum q_Bin_E */ + Word16 *q_Bin_E, /* o : per-bin energy spectrum Q0 */ + Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame q_Bin_E_old */ + Word16 *q_Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q0 */ + Word32 *PS, /* o : per-bin energy spectrum q_PS */ + Word16 *q_PS, /* o : per-bin energy spectrum Q0 */ + Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */ + Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (q_band_energies) */ + Word16 *q_band_energies, /* o : Q of energy in critical frequency bands without minimum noise floor MODE2_E_MIN */ + Word16 *fft_buff, /* o : FFT coefficients (q_fft_buff) */ + Word16 *q_fft_buff /* o : Q of FFT coefficients Q0 */ ); void find_wsp_fx( const Word16 Az[], @@ -2337,7 +2343,7 @@ void find_targets_ivas_fx( Word16 tilt_fac, /* i : tilt factor Q15*/ Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/ Word16 *cn, /* o : target vector in residual domain Q_new*/ - Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/ + Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/ ); void E_ACELP_adaptive_codebook( @@ -3424,26 +3430,27 @@ Word16 pit_encode_fx( /* o : Fractional pitc const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ ); -Word16 pit_encode_ivas_fx( /* o : Fractional pitch for each subframe */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 pitch_bits[], /* i : pitch bits */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *exc, /* i/o: pointer to excitation signal frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 *pitch, /* i : open loop pitch estimates in current frame */ - Word16 *T0_min, /* i/o: lower limit for close-loop search */ - Word16 *T0_max, /* i/o: higher limit for close-loop search */ - Word16 *T0, /* i/o: close loop integer pitch */ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ - const Word16 *h1, /* i : weighted filter input response */ - const Word16 *xn, /* i : target vector */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +Word16 pit_encode_ivas_fx( /* o : Fractional pitch for each subframe */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 pitch_bits[], /* i : pitch bits */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 *pitch, /* i : open loop pitch estimates in current frame */ + Word16 *T0_min, /* i/o: lower limit for close-loop search */ + Word16 *T0_max, /* i/o: higher limit for close-loop search */ + Word16 *T0, /* i/o: close loop integer pitch */ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ + const Word16 *h1, /* i : weighted filter input response Q(14 - norm_s(h1[0]) */ + const Word16 *xn, /* i : target vector Q_new */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ + Word16 Q_new /* i */ ); Word16 lp_filt_exc_enc_fx( diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index f67d81c71..7422a5a15 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -3706,13 +3706,13 @@ void swb_tbe_enc_ivas_fx( Q_bwe_exc_fb = hBWE_TD->prev_Q_bwe_exc_fb; move16(); - GenShapedSHBExcitation_ivas_enc_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, - hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, - &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, - shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, nlExc16k_e, mixExc16k_fx, mixExc16k_e, st_fx->extl_brate, MSFlag, - EnvSHBres_4k_norm_fx, Q_EnvSHBres_4k_norm, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx ); + GenShapedSHBExcitation_ivas_enc_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, + hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, + vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, + shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, + &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, + nlExc16k_e, mixExc16k_fx, mixExc16k_e, st_fx->extl_brate, MSFlag, EnvSHBres_4k_norm_fx, Q_EnvSHBres_4k_norm, + &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx ); *Q_white_exc = Q_bwe_exc_fb; move16(); -- GitLab From 01b3c4b5c17bc6b6d165e52e7c638b15ccfd8c28 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 26 Feb 2025 12:46:11 +0530 Subject: [PATCH 203/329] Clang formatting changes --- lib_com/prot_fx.h | 39 ++++++++++++++++++++------------------- lib_enc/core_enc_init.c | 20 ++++++++++---------- lib_enc/core_enc_switch.c | 2 +- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 485ddb33d..412b5aa35 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3051,30 +3051,30 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ Word16 *shb_res, Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ Word16 *Q_bwe_exc, Word16 *Q_bwe_exc_fb, const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ const Word32 bitrate, const Word16 prev_bfi, - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ ); void GenShapedSHBExcitation_ivas_dec_fx( @@ -11110,7 +11110,8 @@ void init_coder_ace_plus_ivas_fx( ); void core_coder_reconfig_ivas_fx( - Encoder_State *st, const int32_t last_total_brate ); + Encoder_State *st, + const int32_t last_total_brate ); void core_coder_mode_switch_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index 74f73bf52..657ef8d96 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -53,8 +53,8 @@ static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); static void init_core_sig_ana_ivas_fx( Encoder_State *st ); static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate); -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate); +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); /*-----------------------------------------------------------------------* * init_coder_ace_plus() * @@ -223,11 +223,11 @@ void init_coder_ace_plus_ivas_fx( } /* Initialize Signal Buffers */ - init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate); + init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); /* Initialize ACELP */ - init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate); + init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate ); if ( st->ini_frame == 0 ) { @@ -442,7 +442,7 @@ static void init_tcx_ivas_fx( * Initialization of signal buffers *-----------------------------------------------------------------------*/ /*copy of evs function since it was static */ -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate) +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) { LPD_state_HANDLE hLPDmem = st->hLPDmem; @@ -478,7 +478,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol test(); test(); test(); - IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) { lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); test(); @@ -530,7 +530,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol move16(); } /*coming from TCXonly modes*/ - ELSE IF( !st->tcxonly && GE_32(last_total_brate, ACELP_32k ) ) + ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) { Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); @@ -647,7 +647,7 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st ) * * *-----------------------------------------------------------------------*/ -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate) +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) { Word16 mem_syn_r_size_old; Word16 mem_syn_r_size_new; @@ -753,7 +753,7 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh test(); test(); test(); - IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) { Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ IF( EQ_16( st->L_frame, L_FRAME16k ) ) @@ -1048,7 +1048,7 @@ static void init_modes_ivas_fx( } /* Reconfigure core */ - core_coder_reconfig_ivas_fx( st, last_total_brate); + core_coder_reconfig_ivas_fx( st, last_total_brate ); return; diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index 81b299057..98e926a2b 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -206,7 +206,7 @@ void core_coder_mode_switch_ivas_fx( st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 ); move16(); - core_coder_reconfig_ivas_fx( st, last_total_brate); + core_coder_reconfig_ivas_fx( st, last_total_brate ); } ELSE { -- GitLab From a1211a4adebb7620583a6b5002d6de1234f0da49 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 26 Feb 2025 08:42:58 +0100 Subject: [PATCH 204/329] fix weird CI errors by pulling branches explicitly from origin --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef9e8cc54..16f8030ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -223,7 +223,7 @@ stages: - current_commit_sha=$(git rev-parse HEAD) ### build reference binaries - git checkout $FLOAT_REF_BRANCH - - git pull + - git pull origin $FLOAT_REF_BRANCH - *activate-debug-mode-info-if-set - make clean - make -j @@ -239,7 +239,7 @@ stages: - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - git pull + - git pull $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - *activate-debug-mode-info-if-set - make clean - make -j @@ -278,7 +278,7 @@ stages: - git fetch - git restore . # Just as a precaution - git checkout $BASOP_CI_BRANCH_PC_REPO - - git pull + - git pull $BASOP_CI_BRANCH_PC_REPO - cd - - cp -r $SCRIPTS_DIR/ci . - cp -r $SCRIPTS_DIR/scripts . -- GitLab From 39798c72231ddba0a3487ddded22d78e2d0b2f71 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 26 Feb 2025 08:45:14 +0100 Subject: [PATCH 205/329] fix git pull commands - forgot "origin" --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16f8030ef..0613f3af7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -239,7 +239,7 @@ stages: - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - git pull $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - *activate-debug-mode-info-if-set - make clean - make -j @@ -278,7 +278,7 @@ stages: - git fetch - git restore . # Just as a precaution - git checkout $BASOP_CI_BRANCH_PC_REPO - - git pull $BASOP_CI_BRANCH_PC_REPO + - git pull origin $BASOP_CI_BRANCH_PC_REPO - cd - - cp -r $SCRIPTS_DIR/ci . - cp -r $SCRIPTS_DIR/scripts . -- GitLab From 4411e4bb692ed7f3a893596525044e1d910bafaa Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 26 Feb 2025 09:26:15 +0100 Subject: [PATCH 206/329] dummy commit to trigger CI -- GitLab From 76b5ae0a23945c3d3e627331d696efd62d808b5e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 26 Feb 2025 10:24:35 +0100 Subject: [PATCH 207/329] dummy commit to trigger CI -- GitLab From e86a8b5fe7ce3094bf769099ef03cc506dcc800f Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 26 Feb 2025 11:03:31 +0100 Subject: [PATCH 208/329] the cholesky_fixed64 function returns Q10 instead of Q18 now. --- lib_com/ivas_tools.c | 9 +++++---- lib_enc/speech_music_classif_fx.c | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 9f1a42f29..6cb13740a 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -660,10 +660,11 @@ Word64 dot_product_cholesky_fixed64( Word16 i, j; Word64 suma, tmp_sum; Word32 mul; + Word32 tmp; const Word32 *pt_x, *pt_A; pt_A = A; suma = 0; - move32(); + move64(); FOR( i = 0; i < N; i++ ) { tmp_sum = 0; @@ -675,10 +676,10 @@ Word64 dot_product_cholesky_fixed64( mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); } - - suma = W_mac_32_32( suma, tmp_sum, tmp_sum ); // TODO: make sure that this does not overflow. + tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow + tmp = W_extract_l( tmp_sum ); + suma = W_mac_32_32( suma, tmp, tmp ); } - return suma; } void v_mult_mat_fixed( diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 34744131f..da93127bf 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2271,16 +2271,16 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } -- GitLab From 83f55d062391b690dec53bf8d43f83929c1f9e1f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 26 Feb 2025 11:41:53 +0100 Subject: [PATCH 209/329] fix MSVC build --- Workspace_msvc/lib_com.vcxproj.filters | 252 +++-- Workspace_msvc/lib_dec.vcxproj.filters | 1197 ++++++++++++++++++------ Workspace_msvc/lib_enc.vcxproj.filters | 1072 +++++++++++---------- Workspace_msvc/renderer.vcxproj | 2 +- apps/renderer.c | 56 +- lib_com/options.h | 4 - lib_com/stat_com.h | 7 + lib_dec/stat_dec.h | 6 - lib_enc/stat_enc.h | 2 +- 9 files changed, 1680 insertions(+), 918 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 195d4deb1..c58edbff6 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -82,7 +82,6 @@ common_all_c - common_all_c @@ -161,7 +160,6 @@ common_all_c - common_evs_c @@ -216,7 +214,6 @@ common_all_c - common_all_c @@ -361,65 +358,192 @@ common_all_c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + @@ -493,7 +617,6 @@ common_h - common_h @@ -504,6 +627,9 @@ common_h + + common_all_c + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index b9dbd7fd5..348c5fbda 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -1,305 +1,912 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + - - - - - - - - - - - - + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + + + {6d564218-e0e5-4a7b-80b3-6b10661ad36c} + + + {33d78f8d-2d43-40f5-a9b1-711097bd6746} + + + {044baa49-b157-45ed-8bec-29b6d7172e82} + + + {adc81a29-2517-49f0-819f-e8cea3d49ae3} + \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index ac23c810f..0c3220178 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -1,851 +1,839 @@ - + - - enc_ivas_c + + + encoder_evs_c - - enc_ivas_c + + encoder_evs_c - - enc_ivas_c + + encoder_evs_c - - enc_ivas_c + + encoder_evs_c - - enc_ivas_c + + encoder_evs_c - - enc_ivas_c + + encoder_evs_c - - enc_evs_c + + encoder_evs_c - - enc_evs_c + + encoder_evs_c - enc_evs_c + encoder_evs_c + + + encoder_evs_c - enc_evs_c + encoder_evs_c + + + encoder_evs_c - enc_evs_c + encoder_evs_c + + + encoder_evs_c - enc_evs_c + encoder_evs_c - - enc_evs_c + + encoder_evs_c - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c - - - enc_evs_c + encoder_evs_c - - enc_evs_c + + encoder_evs_c - enc_evs_c + + encoder_evs_c - - enc_evs_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_evs_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - - enc_all_c + + encoder_ivas_c - enc_all_c + + encoder_ivas_c - - enc_evs_c + + encoder_ivas_c - enc_ivas_c - - - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c - - - enc_all_c + encoder_ivas_c - - enc_evs_c - - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - enc_ivas_c - - - enc_ivas_c - - - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_ivas_c + + + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c + + + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - enc_ivas_c + encoder_ivas_c - - - enc_ivas_c - - - enc_ivas_c + + encoder_ivas_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - enc_all_c + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c - - enc_all_c + + encoder_all_c + + + encoder_all_c - enc_evs_c + encoder_all_c - - enc_evs_c + + encoder_all_c - - enc_ivas_c + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + - enc_h + encoder_h + + + encoder_h - enc_h + encoder_h - enc_h + encoder_h - enc_h + encoder_h - - enc_h - - - enc_h + encoder_all_c - - {b7ee0526-8b79-4554-a3ec-04e51d38475f} + + {34137975-e4fd-40f0-938f-02fd46da5e22} - - {dabed049-70a2-48f2-9da6-3b81a3664033} + + {c24a3dcd-cde3-411b-aecf-747c29d87668} - - {5717f1cb-c593-400b-b23a-45c422fd95c8} + + {e78e5d72-8d6d-4b00-a6e0-64a62c9cf8f2} - - {6cccabbe-510f-43d3-90e1-8ed5ea3837d7} + + {597ebb71-22ba-41e8-b4bf-e8691bda2e5b} \ No newline at end of file diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index 1f95040e1..70a130e31 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -65,7 +65,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks diff --git a/apps/renderer.c b/apps/renderer.c index f5c0a8847..cf8112313 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -48,7 +48,6 @@ #include "vector3_pair_file_reader.h" #include "wmc_auto.h" -#include "prot_fx.h" #define WMC_TOOL_SKIP @@ -56,11 +55,15 @@ * Local constants *------------------------------------------------------------------------------------------*/ +#define Q15 15 +#define Q22 22 +#define Q31 31 +#define ONE_IN_Q31 0x7fffffff + #define RENDERER_MAX_CLI_ARG_LENGTH ( FILENAME_MAX ) #define RENDERER_MAX_METADATA_LENGTH 8192 #define RENDERER_MAX_METADATA_LINE_LENGTH 1024 - #define IVAS_MAX16B_FLT 32767.0f #define IVAS_MIN16B_FLT ( -32768.0f ) #define IVAS_MAX16B_FX 32767 @@ -428,6 +431,47 @@ static Word16 find_guard_bits( Word32 n ) : n <= 1024 ? 10 : 11; } + +static Word32 floatToFixed( float f, Word16 Q ) +{ + Word64 result_32; + + if ( f == 1.0f && Q == Q15 ) + return IVAS_MAX16B_FX; + if ( f == 1.0f && Q == Q31 ) + return MAXVAL_WORD32; + if ( Q < 0 ) + result_32 = (Word64) ( (float) ( f ) / (double) ( (unsigned Word64) 1 << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) ); + else + result_32 = (Word64) ( f * (double) ( (unsigned Word64) 1 << Q ) + ( f >= 0 ? 0.5 : -0.5 ) ); + if ( result_32 > MAX_32 ) + return MAX_32; + if ( result_32 < MIN_32 ) + return MIN_32; + + return (Word32) result_32; +} + +/* note: This function is defined inside the library too with different name but same functionality */ +static void floatToFixed_arrL_app( float *f, Word32 *i, Word16 Q, Word16 l ) +{ + for ( int j = 0; j < l; j++ ) + { + Word64 i64_val = floatToFixed( f[j], Q ); + IF( i64_val > MAX_32 ) + { + i64_val = MAX_32; + } + ELSE IF( i64_val < MIN_32 ) + { + i64_val = MIN_32; + } + i[j] = (Word32) i64_val; + } + + return; +} + static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer buffer, const Word16 chBeginIdx, @@ -930,8 +974,8 @@ int main( /* Set up output custom layout configuration */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - floatToFixed_arrL( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); - floatToFixed_arrL( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL_app( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL_app( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); @@ -1018,8 +1062,8 @@ int main( if ( args.inConfig.multiChannelBuses[i].audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - floatToFixed_arrL( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); - floatToFixed_arrL( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL_app( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL_app( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); diff --git a/lib_com/options.h b/lib_com/options.h index 288145122..9d5ca2e4c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -41,10 +41,6 @@ /* ################### Start DEBUGGING switches ######################## */ -#ifdef _MSC_VER -#pragma warning(disable:4310) /* cast truncates constant value this affects mainly constants tables*/ -#endif - /*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ #ifdef DEBUGGING #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 45a16dc1a..26b219217 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -102,6 +102,13 @@ typedef struct } ARCODEC, *PARCODEC; +struct dispMem_fx +{ + Word16 prev_state; /*Q0 */ + Word32 prev_gain_code; /*Q16 */ + Word16 prev_gain_pit[6]; /*Q14 */ +}; + /*---------------------------------------------------------------* * ACELP Encoder/Decoder Static RAM * *---------------------------------------------------------------*/ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 5c7f894b9..3e82d8c06 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1258,12 +1258,6 @@ typedef struct amrwb_io_dec_structure } AMRWB_IO_DEC_DATA, *AMRWB_IO_DEC_HANDLE; -struct dispMem_fx -{ - Word16 prev_state; /*Q0 */ - Word32 prev_gain_code; /*Q16 */ - Word16 prev_gain_pit[6]; /*Q14 */ -}; /*----------------------------------------------------------------------------------* * diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 0fa9aeb88..78fef6e22 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -43,7 +43,7 @@ #include "stat_com.h" #include "cnst.h" #include "ivas_cnst.h" -#include "stat_dec.h" /* Compilation switches */ + /*------------------------------------------------------------------------------------------* * Indice -- GitLab From 9508caea7d67fcbe993ab3ed4226caec014d29f1 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 26 Feb 2025 12:59:02 +0100 Subject: [PATCH 210/329] fix MSVC warning C4701 mentioned in MR1091 --- lib_com/ivas_dirac_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 2704c1f08..407b62da6 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -970,7 +970,7 @@ void computeDiffuseness_fixed( #ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS Word16 shift_q = sub( q_tmp, q_ene ); - Word32 shiftEquiv; + Word32 shiftEquiv = L_add( 0, 0 ); Word16 shift_qtotal; if ( shift_q < 0 ) { -- GitLab From 887852872817fce5dcfc9053ffbb4c3e0b4675cd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 26 Feb 2025 12:59:02 +0100 Subject: [PATCH 211/329] fix MSVC warning C4701 mentioned in MR1091 --- lib_com/ivas_dirac_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 2704c1f08..407b62da6 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -970,7 +970,7 @@ void computeDiffuseness_fixed( #ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS Word16 shift_q = sub( q_tmp, q_ene ); - Word32 shiftEquiv; + Word32 shiftEquiv = L_add( 0, 0 ); Word16 shift_qtotal; if ( shift_q < 0 ) { -- GitLab From d3d63a8b48f4661a64f9dfc3307c043fd090ed9b Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 26 Feb 2025 14:37:27 +0100 Subject: [PATCH 212/329] applied the clang patch. --- lib_com/ivas_tools.c | 4 ++-- lib_enc/speech_music_classif_fx.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 6cb13740a..2b62a0e5a 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -654,7 +654,7 @@ Word32 dot_product_cholesky_fixed( Word64 dot_product_cholesky_fixed64( const Word32 *x, /* i : vector x Q31 - exp_x*/ const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ - const Word16 N /* i : vector & matrix size Q0*/ + const Word16 N /* i : vector & matrix size Q0*/ ) { Word16 i, j; @@ -676,7 +676,7 @@ Word64 dot_product_cholesky_fixed64( mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); } - tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow + tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); suma = W_mac_32_32( suma, tmp, tmp ); } diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index da93127bf..fe6647a6c 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2271,15 +2271,15 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } -- GitLab From 82c5e4ca92329673e3fcaca14d11e967c2f37350 Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 26 Feb 2025 15:35:42 +0100 Subject: [PATCH 213/329] make DEBUG_FORCE_DIR inactive by default --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 46ea18c9d..92c0dd78c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -50,7 +50,7 @@ #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ #define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ #define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ -#define DEBUG_FORCE_DIR /* Force modes/parameters by reading from external binary files */ +/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ #define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ #endif -- GitLab From bfad31be34fc246c8a128dea91c6ca90e56088cb Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 26 Feb 2025 15:52:16 +0100 Subject: [PATCH 214/329] clang format --- lib_enc/ivas_core_pre_proc_front.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 9fc530fa4..184c07505 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1786,7 +1786,7 @@ ivas_error pre_proc_front_ivas_fx( dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); - dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); + dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); } #endif -- GitLab From c7d647c34c6a5a8345e1f28fab9bb63aee47d779 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 27 Feb 2025 09:26:19 +0530 Subject: [PATCH 215/329] Adding fix for non-uniform q in first_VQstages --- lib_enc/gs_enc_fx.c | 4 ++++ lib_enc/ivas_core_pre_proc_front.c | 2 +- lib_enc/lsf_enc_fx.c | 16 ++++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 357e88410..7ae8fb42e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -679,7 +679,11 @@ void encod_audio_ivas_fx( *--------------------------------------------------------------------------------------*/ edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); + scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); + scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); + Q_exc = Q_new; + move16(); /*--------------------------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *--------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 6ab82420f..a77c4e36a 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -627,7 +627,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); set32_fx( sig_out, 0, 960 ); - headroom = 1; + headroom = 2; move16(); test(); diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 3f3f91392..52f15471f 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -2133,7 +2133,7 @@ static void first_VQstages( L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } - set32_fx( dist[1], L_tmp, maxC ); + set32_fx( dist[1], L_shr( L_tmp, 1 ), maxC ); /*Q-1 + x2.56 +x2.56 */ /* Set up initial error (residual) vectors */ pTmp = resid[1]; @@ -2192,15 +2192,15 @@ static void first_VQstages( /* compute weighted codebook element and its energy */ FOR( c2 = 0; c2 < N; c2++ ) { - Tmp[c2] = shl( mult( w[c2], cbp[c2] ), 2 ); /* Q8 + x2.56 -Q15 +Q2 */ + Tmp[c2] = extract_h( L_shl( L_mult0( w[c2], cbp[c2] ), 6 ) ); /* Q8 + x2.56 + q6 -q16 */ move16(); } - en = L_mult( cbp[0], Tmp[0] ); + en = L_mult( cbp[0], Tmp[0] ); /*x2.56 + x2.56 + Q-2 +Q1 */ FOR( c2 = 1; c2 < N; c2++ ) { - en = L_mac( en, cbp[c2], Tmp[c2] ); /*x2.56 + x2.56 + Q-5 +Q1 */ + en = L_mac( en, cbp[c2], Tmp[c2] ); /*x2.56 + x2.56 + Q-2 +Q1 */ } cbp += N; move16(); @@ -2208,15 +2208,15 @@ static void first_VQstages( /* iterate over all parent nodes */ FOR( c = 0; c < m; c++ ) { - pTmp = &resid[0][c * N]; + pTmp = &resid[0][c * N]; /*x2.56*/ move16(); - L_tmp = L_mult( pTmp[0], Tmp[0] ); + L_tmp = L_mult( pTmp[0], Tmp[0] ); /*x2.56 + x2.56 + Q-2 +Q1 */ FOR( c2 = 1; c2 < N; c2++ ) { - L_tmp = L_mac( L_tmp, pTmp[c2], Tmp[c2] ); /* */ + L_tmp = L_mac( L_tmp, pTmp[c2], Tmp[c2] ); /*x2.56 + x2.56 + Q-2 +Q1 */ } - L_tmp = L_add( dist[0][c], L_sub( en, L_shl( L_tmp, 1 ) ) ); + L_tmp = L_add( dist[0][c], L_sub( en, L_shl( L_tmp, 1 ) ) ); /*x2.56 + x2.56 -1*/ IF( LE_32( L_tmp, dist[1][p_max] ) ) { -- GitLab From 9173eff44984352693077f63909f1e7cbb94c67d Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 27 Feb 2025 20:07:44 +1100 Subject: [PATCH 216/329] fix for SPLIT PCM output cases, save 32 bit bin outputs --- lib_dec/ivas_jbm_dec.c | 13 ++++++------- lib_dec/ivas_stat_dec.h | 1 + lib_dec/lib_dec_fx.c | 25 +++++++++---------------- lib_isar/isar_splitRendererPre.c | 4 ++-- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index cc31e1412..5ad45a282 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2686,14 +2686,13 @@ ivas_error ivas_jbm_dec_render_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); - move16(); - } - ELSE - { - nchan_out_syn_output = nchan_out; - move16(); + FOR( i = 0; i < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) + { + Copy32( p_output_fx[i], st_ivas->hSplitBinRend->hMultiBinCldfbData->output_fx[i], *nSamplesRendered ); + } } + nchan_out_syn_output = nchan_out; + move16(); IF( st_ivas->hDecoderConfig->Opt_Limiter ) #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 2d71508f7..c9942de12 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -896,6 +896,7 @@ typedef struct { Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 output_fx[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; } ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9917b6f40..025b407d1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1324,8 +1324,6 @@ IVAS_DEC_GetSplitBinauralBitstream( AUDIO_CONFIG output_config; Word32 output_Fs; Word32 *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; - Word32 output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; - Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; FOR( Word32 i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) @@ -1413,24 +1411,15 @@ IVAS_DEC_GetSplitBinauralBitstream( /* Decode and render */ - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, pcmBuf_out, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - /* change buffer layout */ - FOR( i = 0; i < numSamplesPerChannelToDecode; ++i ) - { - FOR( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) - { - output[j][i] = (Word32) pcmBuf[add( i_mult( i, i_mult( BINAURAL_CHANNELS, numPoses ) ), j )]; - move32(); - } - } FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - pOutput[i] = output[i]; + pOutput[i] = hSplitBinRend->hMultiBinCldfbData->output_fx[i]; move32(); } @@ -1510,7 +1499,7 @@ IVAS_DEC_GetSplitBinauralBitstream( scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); } } - Q_buff = Q_buff + Q6; + Q_buff = add( Q_buff, Q6 ); IF( NE_16( td_input, 0 ) ) { @@ -1521,14 +1510,17 @@ IVAS_DEC_GetSplitBinauralBitstream( FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { - Q_out[0] = s_min( Q_out[0], L_norm_arr( output[i], L_FRAME48k ) ); + Q_out[0] = s_min( Q_out[0], L_norm_arr( pOutput[i], L_FRAME48k ) ); } FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { - scale_sig32( output[i], L_FRAME48k, Q_out[0] ); + scale_sig32( pOutput[i], L_FRAME48k, Q_out[0] ); } + Q_out[0] = add( Q_out[0], Q11 ); + Q_out[1] = Q_out[0]; } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, Quaternion, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, @@ -1546,6 +1538,7 @@ IVAS_DEC_GetSplitBinauralBitstream( return error; } + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ IF( pcm_out_flag ) { diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 8dd0cdf95..6cb44b015 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -3250,7 +3250,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( /*scaling to max Q*/ Word16 scale_factor = 31; move32(); - FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) { @@ -3258,7 +3258,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( } } scale_factor = sub( scale_factor, 2 ); - FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) { -- GitLab From cedd8d6fecad8081d81dd4f0a246a5b084795a14 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 27 Feb 2025 16:10:52 +0530 Subject: [PATCH 217/329] Fix for EVS BE issue --- lib_enc/lsf_enc_fx.c | 193 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 191 insertions(+), 2 deletions(-) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 52f15471f..45a4e014a 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -2125,6 +2125,196 @@ static void first_VQstages( set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); + /* Set up inital distance vector */ + L_tmp = L_deposit_l( 0 ); + FOR( j = 0; j < N; j++ ) + { + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + } + set32_fx( dist[1], L_tmp, maxC ); + + /* Set up initial error (residual) vectors */ + pTmp = resid[1]; + move16(); + FOR( c = 0; c < maxC; c++ ) + { + Copy( u, pTmp, N ); + pTmp += N; + } + + /*----------------------------------------------------------------* + * LSF quantization + *----------------------------------------------------------------*/ + + /* Loop over all stages */ + m = 1; + move16(); + FOR( s = 0; s < stagesVQ; s++ ) + { + /* set codebook pointer to point to first stage */ + cbp = cb[s]; + move16(); + + /* save pointer to the beginning of the current stage */ + cb_stage = cbp; + move16(); + + /* swap pointers to parent and current nodes */ + pTmp_short = indices[0]; + indices[0] = indices[1]; + move16(); + indices[1] = pTmp_short; + move16(); + + pTmp = resid[0]; + resid[0] = resid[1]; + move16(); + resid[1] = pTmp; + move16(); + + pTmp32 = dist[0]; + dist[0] = dist[1]; + move32(); + dist[1] = pTmp32; + move32(); + + /* p_max points to maximum distortion node (worst of best) */ + p_max = 0; + move16(); + + /* set distortions to a large value */ + set32_fx( dist[1], MAXINT32, maxC ); + + FOR( j = 0; j < levels[s]; j++ ) + { + /* compute weighted codebook element and its energy */ + FOR( c2 = 0; c2 < N; c2++ ) + { + Tmp[c2] = shl( mult( w[c2], cbp[c2] ), 2 ); /* Q8 + x2.56 -Q15 +Q2 */ + move16(); + } + + en = L_mult( cbp[0], Tmp[0] ); + + FOR( c2 = 1; c2 < N; c2++ ) + { + en = L_mac( en, cbp[c2], Tmp[c2] ); /*x2.56 + x2.56 + Q-5 +Q1 */ + } + cbp += N; + move16(); + + /* iterate over all parent nodes */ + FOR( c = 0; c < m; c++ ) + { + pTmp = &resid[0][c * N]; + move16(); + L_tmp = L_mult( pTmp[0], Tmp[0] ); + FOR( c2 = 1; c2 < N; c2++ ) + { + L_tmp = L_mac( L_tmp, pTmp[c2], Tmp[c2] ); /* */ + } + + L_tmp = L_add( dist[0][c], L_sub( en, L_shl( L_tmp, 1 ) ) ); + + IF( LE_32( L_tmp, dist[1][p_max] ) ) + { + /* replace worst */ + dist[1][p_max] = L_tmp; + move32(); + indices[1][p_max * stagesVQ + s] = j; + move16(); + parents[p_max] = c; + move16(); + + /* limit number of times inner loop is entered */ + IF( LT_16( counter, max_inner ) ) + { + counter = add( counter, 1 ); + IF( LT_16( counter, max_inner ) ) + { + /* find new worst */ + p_max = maximum_32_fx( dist[1], maxC, &f_tmp ); + } + ELSE + { + /* find minimum distortion */ + p_max = minimum_32_fx( dist[1], maxC, &f_tmp ); + } + } + } + } + } + + /*------------------------------------------------------------* + * Compute error vectors for each node + *------------------------------------------------------------*/ + cs = 0; + move16(); + FOR( c = 0; c < maxC; c++ ) + { + /* subtract codebook entry from the residual vector of the parent node */ + pTmp = resid[1] + c * N; + move16(); + Copy( resid[0] + parents[c] * N, pTmp, N ); + Vr_subt( pTmp, cb_stage + ( indices[1][cs + s] ) * N, pTmp, N ); + + /* get indices that were used for parent node */ + Copy( indices[0] + parents[c] * stagesVQ, indices[1] + cs, s ); + cs = add( cs, stagesVQ ); + } + + m = maxC; + move16(); + } + + Copy( indices[1], indices_VQstage, maxC * stagesVQ ); + + return; +} + +static void first_VQstages_ivas_fx( + const Word16 *const *cb, + Word16 u[], /* i : vector to be encoded (prediction and mean removed) */ + Word16 *levels, /* i : number of levels in each stage */ + Word16 stagesVQ, /* i : number of stages */ + Word16 w[], /* i : weights */ + Word16 N, /* i : vector dimension */ + Word16 max_inner, /* i : maximum number of swaps in inner loop */ + Word16 indices_VQstage[] ) +{ + Word16 resid_buf[2 * LSFMBEST * M], *resid[2]; + Word32 dist_buf[2 * LSFMBEST], *dist[2], en; + Word32 f_tmp, L_tmp, L_tmp1, *pTmp32; + Word16 Tmp[M], *pTmp, cs; + Word16 *pTmp_short, idx_buf[2 * LSFMBEST * MAX_VQ_STAGES], parents[LSFMBEST], counter = 0, j, + m, s, c, c2, p_max, *indices[2]; + Word16 maxC = LSFMBEST; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + /*float dd[16];*/ + const Word16 *cb_stage, *cbp; + + /* Set pointers to previous (parent) and current node (parent node is indexed [0], current node is indexed [1]) */ + indices[0] = idx_buf; + move16(); + indices[1] = idx_buf + maxC * stagesVQ; + move16(); + resid[0] = resid_buf; + move16(); + resid[1] = resid_buf + maxC * N; + move16(); + dist[0] = dist_buf; + move16(); + dist[1] = dist_buf + maxC; + move16(); + + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( parents, 0, maxC ); + /* Set up inital distance vector */ L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) @@ -2273,7 +2463,6 @@ static void first_VQstages( return; } - /*--------------------------------------------------------------------------- * vq_enc_lsf_lvq() * @@ -2457,7 +2646,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( IF( stagesVQ > 0 ) { /* first VQ stages */ - first_VQstages( cb, u, levels, stagesVQ, w, M, MSVQ_MAXCNT, indices_firstVQ ); + first_VQstages_ivas_fx( cb, u, levels, stagesVQ, w, M, MSVQ_MAXCNT, indices_firstVQ ); } -- GitLab From d034a0b0bcd88313c3cfd77992a70270b546ffa1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 27 Feb 2025 12:54:31 +0100 Subject: [PATCH 218/329] disable per-testcase timeouts on msan jobs --- .gitlab-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c51f8c54d..d3eb06636 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -750,8 +750,12 @@ stages: - fi - make clean - make -j $make_args - - testcase_timeout=$TESTCASE_TIMEOUT_LTV_SANITIZERS - - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH + - testcase_timeout_arg="--testcase_timeout $TESTCASE_TIMEOUT_LTV_SANITIZERS" + # disable per-testcase timeout for msan to evaluate what is going on that it takes so long + - if [[ $CLANG_NUM = 1 ]]; then + - testcase_timeout_arg="" + - fi + - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml $testcase_timeout_arg --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH artifacts: name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" when: always -- GitLab From 50852fa60db649b94a3e7da799c17a82af7579fe Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 27 Feb 2025 18:30:52 +0530 Subject: [PATCH 219/329] Fix for 3GPP issue 1308: Large differences between BASOP and float for critical item in MDCT-stereo @96kbps Link #1308 --- lib_com/lpc_tools_fx.c | 85 +++++++++++++++++++++++++++++++++++++++ lib_com/prot_fx.h | 1 + lib_com/stat_com.h | 1 + lib_com/tns_base.c | 2 + lib_enc/cod_tcx.c | 41 ++++++++++--------- lib_enc/prot_fx_enc.h | 3 +- lib_enc/tns_base_enc_fx.c | 74 +++++++++++++++++++++++++++++----- 7 files changed, 175 insertions(+), 32 deletions(-) diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index ef6c0b0ff..bde05b4f4 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -1210,6 +1210,91 @@ Word16 E_LPC_lsp_unweight( return 0; } +/* + * E_LPC_schur_ivas + * + * Parameters: + * R I: Rh[M+1] Vector of autocorrelations (msb) + * reflCoeff O: rc[M] Reflection coefficients. Q15 + * epsP O: error vector + * + * Function: + * Schur algorithm to compute + * the LPC parameters from the autocorrelations of speech. + * + * Returns: + * void + */ +Word32 E_LPC_schur_ivas( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, const Word16 m ) +{ + Word16 i, j, temp16, mMi, s; + Word32 g0[M], *g1, tmp32; + const Word32 min_epsP = 1; /* > 0.01f*2^27/2^30 */ + Word32 tmp_epsP; + + s = getScaleFactor32( r, add( m, 1 ) ); + IF( s != 0 ) + { + scale_sig32( r, add( m, 1 ), s ); /* scale in-place */ + } + + g1 = r; + Copy32( r + 1, g0, m ); + + /* compute g0[0]/g1[0], where g0[0] < g1[0] */ + temp16 = negate( divide3232( g0[0], g1[0] ) ); + reflCoeff[0] = temp16; + move16(); + // epsP[0] = r[0]; + move32(); + + + FOR( i = 0; i < m; i++ ) + { + /* g1[0] = g0[0]*temp16 + g1[0]; */ + tmp32 = Mpy_32_16_1( g0[0], temp16 ); + g1[0] = L_add( g1[0], tmp32 ); + move32(); + + mMi = sub( m, i ); + FOR( j = 1; j < mMi; j++ ) + { + /* g0[j-1] = g0[j] + g1[j]*temp16; + g1[j] = g0[j]*temp16 + g1[j]; */ + g0[j - 1] = L_add( g0[j], Mpy_32_16_1( g1[j], temp16 ) ); + move32(); + g1[j] = L_add( g1[j], Mpy_32_16_1( g0[j], temp16 ) ); + move32(); + } + temp16 = negate( divide3232( g0[0], g1[0] ) ); + reflCoeff[i + 1] = temp16; + move16(); + + /* Prediction errors */ + tmp_epsP = L_shr( g1[0], s ); + if ( tmp_epsP <= 0 ) + { + tmp_epsP = min_epsP; + move32(); + } + // epsP[i + 1] = tmp_epsP; + move32(); + } + + /* epsP[i+1] = g0[0]*temp16 + g1[0]; */ + tmp_epsP = L_add( g1[0], Mpy_32_16_1( g0[0], temp16 ) ); + tmp_epsP = L_shr( tmp_epsP, s ); + if ( tmp_epsP <= 0 ) + { + tmp_epsP = min_epsP; + move32(); + } + + /* prediction gain = divide3232(L_shr(epsP[0], PRED_GAIN_E), g1[0]); */ + + + return g1[0]; +} /* * E_LPC_schur diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c67e2da28..5a6e24046 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1198,6 +1198,7 @@ Word16 E_LPC_lsp_unweight( ); Word32 E_LPC_schur( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, Word32 epsP[] /*Qr*/, const Word16 m ); +Word32 E_LPC_schur_ivas( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, const Word16 m ); void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/, const Word16 *old_lsf /*15Q16*/, Word16 lpcOrder, Word8 lpcRep /*Q0*/ ); diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 2340c7a75..b1b1d1f61 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -197,6 +197,7 @@ typedef struct TNS_filter_structure Word16 order; /* Filter order. */ Word16 coefIndex[TNS_MAX_FILTER_ORDER]; /* Quantized filter coefficients. */ Word16 predictionGain; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q7 */ + Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q23 */ Word16 avgSqrCoef; /* Average squared filter coefficient. E(0), Q15 */ } STnsFilter; diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index af4a87d34..b5fd1f41f 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1202,6 +1202,8 @@ void ResetTnsData( STnsData *pTnsData ) move16(); pTnsFilter->predictionGain = ONE_IN_Q7; /*Q7*/ move16(); + pTnsFilter->predictionGain32 = ONE_IN_Q23; /*Q23*/ + move32(); pTnsFilter->avgSqrCoef = 0; move16(); pTnsFilter->filterType = TNS_FILTER_OFF; /*Q0*/ diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 25f615e6a..d0d36b502 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -55,8 +55,9 @@ * *-------------------------------------------------------------------*/ -#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 ) -#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 ) +#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 ) +#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 ) +#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ( 25165824 ) void TNSAnalysisStereo_fx( Encoder_State **sts, /* i : encoder state handle */ Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum Qx*/ @@ -72,7 +73,7 @@ void TNSAnalysisStereo_fx( Encoder_State *st = NULL; TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; - Word16 maxPredictionGain_fx = 0, meanPredictionGain_fx; + Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; move16(); individual_decision[0] = 0; @@ -144,7 +145,7 @@ void TNSAnalysisStereo_fx( BREAK; } - CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k], NULL ); + CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k] ); } } } @@ -209,7 +210,7 @@ void TNSAnalysisStereo_fx( test(); IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word16 maxPredGain_fx = -ONE_IN_Q7; + Word32 maxPredGain_fx = -ONE_IN_Q23; move16(); sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; @@ -227,30 +228,30 @@ void TNSAnalysisStereo_fx( * both filters for the decision */ - meanPredictionGain_fx = mac_r( L_mult( pFilter[0]->predictionGain, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain, 16384 /*0.5f Q15*/ ); // Q7 - maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7 + meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 + maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 test(); test(); test(); - IF( GT_16( pFilter[0]->predictionGain, pTnsParameters[0]->minPredictionGain ) && LT_32( sts[0]->element_brate, IVAS_80k ) && - GT_16( pFilter[1]->predictionGain, pTnsParameters[1]->minPredictionGain ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && + GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { - pFilter[0]->predictionGain = pFilter[1]->predictionGain = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ move16(); move16(); } test(); - IF( LT_16( abs_s( sub( pFilter[0]->predictionGain, pFilter[1]->predictionGain ) ), mult( SIMILAR_TNS_THRESHOLD_FX_IN_Q15, meanPredictionGain_fx ) ) && + IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - maxPredGain_fx = s_max( maxPredGain_fx, meanPredictionGain_fx ); + maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); test(); test(); - IF( GT_16( meanPredictionGain_fx, pTnsParameters[0]->minPredictionGain ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -456,7 +457,7 @@ void TNSAnalysisStereo_fx( test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_16( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -476,7 +477,7 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - maxPredictionGain_fx = s_max( maxPredictionGain_fx, maxPredGain_fx ); + maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); } } } @@ -514,7 +515,7 @@ void TNSAnalysisStereo_fx( IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word16 maxPredGain_fx = -ONE_IN_Q7; // Q7 + Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 move16(); sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; @@ -525,9 +526,9 @@ void TNSAnalysisStereo_fx( pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - maxPredGain_fx = s_max( maxPredGain_fx, pFilter->predictionGain ); + maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); test(); - IF( GT_16( pFilter->predictionGain, pTnsParameters->minPredictionGain ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -601,7 +602,7 @@ void TNSAnalysisStereo_fx( move16(); test(); test(); - IF( !bWhitenedDomain && LT_16( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -616,7 +617,7 @@ void TNSAnalysisStereo_fx( move16(); } } - maxPredictionGain_fx = s_max( maxPredictionGain_fx, maxPredGain_fx ); + maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); } } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 38552ba0d..a8e7f1047 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1629,8 +1629,7 @@ void CalculateTnsFilt_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ const Word32 pSpectrum[], /* i : MDCT spectrum Qx*/ const Word16 pSpectrum_e, - STnsData *pTnsData, /* o : TNS data struct */ - Word16 *predictionGain /* o : TNS prediction gain Q7*/ + STnsData *pTnsData /* o : TNS data struct */ ); /** Detect TNS parameters. diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index d1763e039..cc9596ba0 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -26,6 +26,8 @@ */ static void GetFilterParameters( Word32 rxx[], Word16 maxOrder, STnsFilter *pTnsFilter ); +static void GetFilterParameters_ivas( Word32 rxx[], Word16 maxOrder, STnsFilter *pTnsFilter ); + /** Quantization for reflection coefficients. * * @param parCoeff input reflection coefficients. @@ -313,8 +315,7 @@ void CalculateTnsFilt_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ const Word32 pSpectrum[], /* i : MDCT spectrum */ const Word16 pSpectrum_e, - STnsData *pTnsData, /* o : TNS data struct */ - Word16 *predictionGain /* o : TNS prediction gain */ + STnsData *pTnsData /* o : TNS data struct */ ) { Word32 norms[TNS_MAX_NUM_OF_FILTERS][MAX_SUBDIVISIONS]; @@ -410,17 +411,10 @@ void CalculateTnsFilt_fx( pFilter->spectrumLength = spectrumLength; move16(); /* Limit the maximum order to spectrum length/4 */ - GetFilterParameters( rxx, s_min( pTnsConfig->maxOrder, shr( pFilter->spectrumLength, 2 ) ), pFilter ); + GetFilterParameters_ivas( rxx, s_min( pTnsConfig->maxOrder, shr( pFilter->spectrumLength, 2 ) ), pFilter ); } } - IF( predictionGain ) - { - assert( pTnsConfig->nMaxFilters == 1 ); - *predictionGain = pTnsData->filter->predictionGain; - move16(); - } - return; } @@ -845,7 +839,67 @@ Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream, /********************************/ /* Private functions */ /********************************/ +static void GetFilterParameters_ivas( Word32 rxx[], Word16 maxOrder, STnsFilter *pTnsFilter ) +{ + Word16 i; + Word16 parCoeff[TNS_MAX_FILTER_ORDER + 1]; + Word32 rxx_0; + Word32 L_tmp; +#if TNS_COEF_RES == 5 + Word16 const *values = tnsCoeff5; +#elif TNS_COEF_RES == 4 + Word16 const *values = tnsCoeff4; +#elif TNS_COEF_RES == 3 + Word16 const *values = tnsCoeff3; +#endif + Word16 *indexes = pTnsFilter->coefIndex; + + rxx_0 = rxx[0]; + move32(); + /* compute TNS filter in lattice (ParCor) form with LeRoux-Gueguen algorithm */ + L_tmp = E_LPC_schur_ivas( rxx, parCoeff, maxOrder ); + BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, this value is compared against a threshold. */ + Word16 temp_e = 0; + move16(); + Word16 temp = BASOP_Util_Divide3232_Scale( rxx_0, L_tmp, &temp_e ); + pTnsFilter->predictionGain32 = L_shl( temp, ( sub( add( 16, temp_e ), PRED_GAIN_E ) ) ); // Q23 + move32(); + pTnsFilter->predictionGain = extract_h( pTnsFilter->predictionGain32 ); // Q7 + move16(); + BASOP_SATURATE_WARNING_ON_EVS + /* non-linear quantization of TNS lattice coefficients with given resolution */ + Parcor2Index( parCoeff, indexes, maxOrder ); + /* reduce filter order by truncating trailing zeros */ + i = sub( maxOrder, 1 ); + + test(); + WHILE( ( i >= 0 ) && ( indexes[i] == 0 ) ) + { + i = sub( i, 1 ); + } + + + pTnsFilter->order = add( i, 1 ); + move16(); + + /* compute avg(coef*coef) */ + L_tmp = L_deposit_l( 0 ); + + FOR( i = pTnsFilter->order - 1; i >= 0; i-- ) + { + Word16 value; + + value = shr( values[indexes[i] + INDEX_SHIFT], 1 ); + + L_tmp = L_mac0( L_tmp, value, value ); + } + + pTnsFilter->avgSqrCoef = round_fx( L_tmp ); + move16(); + /* assert(maxOrder == 8); + pTnsFilter->avgSqrCoef = shr(pTnsFilter->avgSqrCoef, 3); */ +} static void GetFilterParameters( Word32 rxx[], Word16 maxOrder, STnsFilter *pTnsFilter ) { Word16 i; -- GitLab From 643d82a6a705e2fa53484c8941c439b18e8023d1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 27 Feb 2025 18:34:48 +0530 Subject: [PATCH 220/329] Clang formatting changes --- lib_com/stat_com.h | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_enc/tns_base_enc_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index b1b1d1f61..af097da84 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -197,7 +197,7 @@ typedef struct TNS_filter_structure Word16 order; /* Filter order. */ Word16 coefIndex[TNS_MAX_FILTER_ORDER]; /* Quantized filter coefficients. */ Word16 predictionGain; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q7 */ - Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q23 */ + Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q23 */ Word16 avgSqrCoef; /* Average squared filter coefficient. E(0), Q15 */ } STnsFilter; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a8e7f1047..58da977a7 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1629,7 +1629,7 @@ void CalculateTnsFilt_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ const Word32 pSpectrum[], /* i : MDCT spectrum Qx*/ const Word16 pSpectrum_e, - STnsData *pTnsData /* o : TNS data struct */ + STnsData *pTnsData /* o : TNS data struct */ ); /** Detect TNS parameters. diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index cc9596ba0..452842e30 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -879,7 +879,7 @@ static void GetFilterParameters_ivas( Word32 rxx[], Word16 maxOrder, STnsFilter i = sub( i, 1 ); } - + pTnsFilter->order = add( i, 1 ); move16(); @@ -894,7 +894,7 @@ static void GetFilterParameters_ivas( Word32 rxx[], Word16 maxOrder, STnsFilter L_tmp = L_mac0( L_tmp, value, value ); } - + pTnsFilter->avgSqrCoef = round_fx( L_tmp ); move16(); /* assert(maxOrder == 8); -- GitLab From 9778e0b4fb9e4c9a420b1ce19416ed22a35618b1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 28 Feb 2025 09:30:06 +0100 Subject: [PATCH 221/329] whitespace --- lib_com/ivas_tools.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index e0a971951..dc45e3f0e 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -642,6 +642,7 @@ Word32 dot_product_cholesky_fixed( return suma; } + /*---------------------------------------------------------------------* * dot_product_cholesky() * @@ -665,6 +666,7 @@ Word64 dot_product_cholesky_fixed64( pt_A = A; suma = 0; move64(); + FOR( i = 0; i < N; i++ ) { tmp_sum = 0; @@ -676,12 +678,15 @@ Word64 dot_product_cholesky_fixed64( mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); } + tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); suma = W_mac_32_32( suma, tmp, tmp ); } + return suma; } + void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ const Word32 *x, /* i : vector x Qx*/ -- GitLab From 50219449150be1331a9e943a99dff4ca2a62ad6e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 28 Feb 2025 14:12:07 +0530 Subject: [PATCH 222/329] USAN fixes for encoder and decoder --- lib_com/ivas_dirac_com.c | 8 ++++++++ lib_com/options.h | 1 + lib_dec/ivas_td_low_rate_dec.c | 13 +++++++++++++ lib_enc/ivas_mct_core_enc.c | 13 +++++++++++++ lib_enc/ivas_qmetadata_enc.c | 17 +++++++++++++++++ lib_enc/ivas_stereo_ica_enc.c | 14 +++++++++----- lib_enc/ivas_tcx_core_enc.c | 9 +++++++++ lib_rend/ivas_dirac_output_synthesis_dec.c | 4 ++++ 8 files changed, 74 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 0e8050451..557db9696 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -974,7 +974,11 @@ void computeDiffuseness_fixed( Word16 shift_qtotal; if ( shift_q < 0 ) { +#ifdef FIX_USAN_ISSUES + shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); +#else shiftEquiv = L_lshl( 0x80000000, shift_q ); +#endif } if ( shift_q >= 0 ) { @@ -1020,7 +1024,11 @@ void computeDiffuseness_fixed( #ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS if ( shift_q < 0 ) { +#ifdef FIX_USAN_ISSUES + shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); +#else shiftEquiv = L_lshl( 0x80000000, shift_q ); +#endif } if ( shift_q >= 0 ) { diff --git a/lib_com/options.h b/lib_com/options.h index a37ccf387..50c5066fa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define FIX_ISSUE_1291 /* Ittiam: Wrong use of imult1616() in ACELP rescaling */ #define FIX_920_IGF_INIT_ERROR /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */ #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ +#define FIX_USAN_ISSUES /* Ittiam: Fix issues reported by USAN */ #define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ #define FIX_ISSUE_1279 /* VA: correction of wrong scaling update */ diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index dbbc22b4d..a4380bd4e 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -139,8 +139,21 @@ void tdm_low_rate_dec_fx( edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); +#ifdef FIX_USAN_ISSUES + IF( bwe_exc != NULL ) + { + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx, + L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); + } + ELSE + { + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], NULL, st->hGSCDec->last_exc_dct_in_fx, + L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); + } +#else Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx, L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); +#endif /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 0ed03eb1c..7a5a83155 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -337,8 +337,21 @@ void ivas_mct_core_enc_fx( IF( switch_bw ) { +#ifdef FIX_USAN_ISSUES + IF( sts[ch_core]->hIGFEnc == NULL ) + { + initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, + sts[ch_core]->igf, NULL, 0 ); + } + ELSE + { + initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, + sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 ); + } +#else initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 ); +#endif } IF( sts[ch_core]->igf ) diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 387f82463..3f0218e97 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -2503,7 +2503,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( } ELSE { +#ifdef FIX_USAN_ISSUES + avg_elevation_index = (UWord16) L_add( avg_elevation_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_elevation_offset ) ); +#else avg_elevation_index = u_extract_l( UL_addNsD( avg_elevation_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_elevation_offset ) ) ); +#endif } // avg_elevation_index = (uint16_t) ( ( avg_elevation_index + avg_elevation_alphabet ) % avg_elevation_alphabet ); avg_elevation_index = u_extract_l( UL_addNsD( avg_elevation_index, avg_elevation_alphabet ) % avg_elevation_alphabet ); @@ -2638,8 +2642,13 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( FOR( avg_azimuth_offset = 0; avg_azimuth_offset < q_direction->cfg.search_effort; avg_azimuth_offset++ ) { set_zero_fx( avg_direction_vector, 3 ); +#ifdef FIX_USAN_ISSUES + avg_azimuth_index = (UWord16) L_add( avg_azimuth_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_azimuth_offset ) ); + avg_azimuth_index = (UWord16) ( L_add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet ); +#else avg_azimuth_index = (UWord16) add( avg_azimuth_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_azimuth_offset ) ); avg_azimuth_index = (UWord16) ( add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet ); +#endif all_zero_dist_azimuth_indexes = 1; move16(); azimuth_bits_ec = ivas_qmetadata_encode_quasi_uniform_length_fx( ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet ); @@ -5445,7 +5454,11 @@ static Word16 encode_surround_coherence_hr_fx( } ELSE { +#ifdef FIX_USAN_ISSUES + no_idx16 = add( shr( nbits_fr, 4 ), 1 ); +#else no_idx16 = shr_r( nbits_fr, 4 ); +#endif } /* write combined index */ @@ -5467,7 +5480,11 @@ static Word16 encode_surround_coherence_hr_fx( } ELSE { +#ifdef FIX_USAN_ISSUES + no_idx16 = add( shr( nbits_fr1, 4 ), 1 ); +#else no_idx16 = shr_r( nbits_fr1, 4 ); +#endif } assert( no_idx16 <= 4 ); diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 0235630d2..72876ae35 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -1096,9 +1096,13 @@ static void corrStatsEst_fx( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], 429496730 /* 0.2 in Q31*/ ), hStereoTCA->delay_0_mem_exp, L_mult0( 26214 /* 0.8 in Q15*/, corrLagStats[0] ), Q16, &temp ); /* Q31-temp */ move32(); +#ifdef FIX_USAN_ISSUES + Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, L_negate( hStereoTCA->delay_0_mem_fx[0] ), hStereoTCA->delay_0_mem_exp, &exp ) ); /* Q31-exp */ +#else Word32 inpp = L_abs( BASOP_Util_Add_Mant32Exp( reg_prv_corr_fx, reg_prv_corr_exp, -hStereoTCA->delay_0_mem_fx[0], hStereoTCA->delay_0_mem_exp, &exp ) ); /* Q31-exp */ - inpp = L_shl_sat( inpp, sub( exp, 5 ) ); /* Q26 */ - IF( GT_32( inpp, 1677721600 ) ) // 25 in Q26 +#endif + inpp = L_shl_sat( inpp, sub( exp, 5 ) ); /* Q26 */ + IF( GT_32( inpp, 1677721600 ) ) // 25 in Q26 { set32_fx( &( hStereoTCA->delay_0_mem_fx[0] ), hStereoTCA->delay_0_mem_fx[MAX_DELAYREGLEN - 1], MAX_DELAYREGLEN - 1 ); hStereoTCA->delay_0_mem_exp = temp; @@ -1979,8 +1983,8 @@ void stereo_tca_enc_fx( move16(); } #else - scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ - hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ + scalar_value = shl_sat( scalar_value, sub( temp_exp, 5 ) ); /*Q10*/ + hStereoTCA->indx_ica_NCShift = usquant_fx( scalar_value, &tempF_16fx, 0, 512 /* 0.5 in Q10 */, ( 1 << STEREO_BITS_TCA_CORRSTATS ) ); /* Q0 */ #endif tempF_fx = tempF_16fx; @@ -2272,7 +2276,7 @@ static void unclr_calc_corr_features_fx( prod_i_exp = sub( 62, add( shl( q_com, 1 ), add( n1, n2 ) ) ); sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, prod_i, prod_i_exp, &sum_prod_exp ); /* Q31-sum_prod_exp */ #else - sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, Mpy_32_32( buf1[i], buf2[i] ), sub( 62, shl( q_com, 1 ) ), &sum_prod_exp ); /* Q31-sum_prod_exp */ + sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, Mpy_32_32( buf1[i], buf2[i] ), sub( 62, shl( q_com, 1 ) ), &sum_prod_exp ); /* Q31-sum_prod_exp */ #endif } diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index bc6df4f56..c7fc58099 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -1061,7 +1061,12 @@ Word16 ivas_acelp_tcx20_switching_fx( IF( LE_32( offset, 0xAA153 ) ) /* 0xAA153 -> 32.f * log2(10)/10 */ { +#ifdef FIX_USAN_ISSUES + offset = (Word32) 0xFFD57AB5; /* 0xFFD57AB5 -> -128.f * log2(10)/10; */ + move32(); +#else offset = L_add( 0xFFD57AB5, 0 ); /* 0xFFD57AB5 -> -128.f * log2(10)/10; */ +#endif } offset_tcx = offset; move32(); @@ -1164,7 +1169,11 @@ Word16 ivas_acelp_tcx20_switching_fx( { *pt_ener_sfr = -668739840; /* 0xFFEC1185 -> log2(1e-6) in 6Q25 */ move32(); +#ifdef FIX_USAN_ISSUES + tmp32 = (Word32) 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ +#else tmp32 = 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ +#endif move32(); } ELSE diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 0fe7cdef1..d6c999aa0 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1110,7 +1110,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word32 aux; IF( temp_q1 < 0 ) { +#ifdef FIX_USAN_ISSUES + Word32 temp_q1_equiv = L_lshl( (Word32) 0x80000000, temp_q1 ); +#else Word32 temp_q1_equiv = L_lshl( 0x80000000, temp_q1 ); +#endif FOR( i = 0; i < num_freq_bands; i++ ) { aux = Mpy_32_32( h_dirac_output_synthesis_state->direct_power_factor_fx[i], h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + i] ); -- GitLab From d29e5c5e6eba221b818ea52c966833297ded4bbb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 28 Feb 2025 15:14:54 +0530 Subject: [PATCH 223/329] Clang formatting changes --- lib_enc/ivas_tcx_core_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index c7fc58099..cecc1bf80 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -1172,7 +1172,7 @@ Word16 ivas_acelp_tcx20_switching_fx( #ifdef FIX_USAN_ISSUES tmp32 = (Word32) 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ #else - tmp32 = 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ + tmp32 = 0xFFEC1185; /* 0xFFEC1185 -> log2(1e-6) in 15Q16 */ #endif move32(); } -- GitLab From 77fbd2f57f72a36859b492777453df1f9d1c614e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 28 Feb 2025 10:51:30 +0100 Subject: [PATCH 224/329] adjust artifacts and instructions to match new files produced --- .gitlab-ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3eb06636..3c20ff80e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -673,7 +673,7 @@ stages: - echo "Reproduce locally with:" - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - - echo "The individual command lines can be found in the changes*.csv files in the job artifacts." + - echo "The individual command lines can be found in the regressions_crashes.csv files in the job artifacts." - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then - cat regression_log.txt - if [ $allow_regressions_flag == 0 ]; then @@ -686,7 +686,7 @@ stages: - echo "Reproduce locally with:" - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - - echo "The individual command lines can be found in the changes*.csv files in the job artifacts." + - echo "The individual command lines can be found in the regressions_*.csv files in the job artifacts." - fi - exit $exit_code @@ -711,11 +711,8 @@ stages: - $FLOAT_REF_COMMIT_FILE - $CUT_COMMIT_FILE - $MERGE_TARGET_COMMIT_FILE - - changes_crashes.csv - - changes_MLD.csv - - changes_MAXIMUM_ABS_DIFF.csv - - changes_MIN_SSNR.csv - - changes_MIN_ODG.csv + - regressions_*.csv + - improvements_*.csv expose_as: "pytest compare results" reports: junit: -- GitLab From 1a093686ea84d43dc8234f81cad8b2456e75211c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 28 Feb 2025 12:07:10 +0100 Subject: [PATCH 225/329] rename sWB constants to ssWB to avoid macro redefinition after WMC tool --- lib_lc3plus/constants.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c index c13c4e49e..c02cf5c69 100644 --- a/lib_lc3plus/constants.c +++ b/lib_lc3plus/constants.c @@ -1439,7 +1439,7 @@ RAM_ALIGN const Word16 PhECU_whr16ms_WB_Q15[Lprot_hamm_len2_16k] = {/* From matl #define PhECU_whr16ms_WB_Q15 NULL #endif #ifdef SUBSET_SSWB -RAM_ALIGN const Word16 PhECU_whr16ms_sWB_Q15[Lprot_hamm_len2_24k] = +RAM_ALIGN const Word16 PhECU_whr16ms_ssWB_Q15[Lprot_hamm_len2_24k] = {/* From matlab */ 2621, 2636, 2679, 2750, 2850, 2979, 3135, 3319, 3530, 3769, 4034, 4325, 4641, 4982, 5347, 5736, 6148, 6582, 7036, 7511, 8006, 8519, 9049, 9596, 10158, 10735, 11324, 11926, 12539, 13162, @@ -1560,7 +1560,7 @@ RAM_ALIGN const Word16 PhECU_preTdaFx16ms_WB_Q14[256] = { #define PhECU_preTdaFx16ms_WB_Q14 NULL #endif #ifdef SUBSET_SSWB -RAM_ALIGN const Word16 PhECU_preTdaFx16ms_sWB_Q14[384] = { +RAM_ALIGN const Word16 PhECU_preTdaFx16ms_ssWB_Q14[384] = { -22499, -22471, -22152, -21551, -20715, -19688, -18527, -17277, -15982, -14679, -13393, -12145, -10954, -9826, -8760, -7763, -6831, -5958, -5149, -4394, -3688, -3029, -2410, -1831, -1285, -769, -279, 186, 630, 1055, 1462, 1856, 2236, 2606, 2966, 3317, 3662, 3999, 4330, 4658, 4981, 5301, @@ -1699,7 +1699,7 @@ RAM_ALIGN const Word16 *const PhECU_wins[5][3] = { /* 3ms hamm(left part) , 16ms(center IWHR(periodic)*MDCT-anaQ14) , 2ms(initial MDCT-ana in Q14) */ /*8 kHz*/ {PhECU_whr16ms_NB_Q15, PhECU_preTdaFx16ms_NB_Q14, PhECU_preTdaFx16ms_128_pre_Q14}, /*16 kHz*/ {PhECU_whr16ms_WB_Q15, PhECU_preTdaFx16ms_WB_Q14, PhECU_preTdaFx16ms_256_pre_Q14}, - /*24 kHz*/ {PhECU_whr16ms_sWB_Q15, PhECU_preTdaFx16ms_sWB_Q14, PhECU_preTdaFx16ms_384_pre_Q14}, + /*24 kHz*/ {PhECU_whr16ms_ssWB_Q15, PhECU_preTdaFx16ms_ssWB_Q14, PhECU_preTdaFx16ms_384_pre_Q14}, /*32 kHz*/ {PhECU_whr16ms_SWB_Q15, PhECU_preTdaFx16ms_SWB_Q14, PhECU_preTdaFx16ms_512_pre_Q14}, /*48 kHz*/ {PhECU_whr16ms_FB_Q15, PhECU_preTdaFx16ms_FB_Q14, PhECU_preTdaFx16ms_768_pre_Q14}}; -- GitLab From 5f8ae98a1d0e89005331b074938c801f0fe63b06 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 28 Feb 2025 12:16:33 +0100 Subject: [PATCH 226/329] can't use wildcards with "expose as" -> use explicit paths --- .gitlab-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c20ff80e..fc4c023dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -711,8 +711,16 @@ stages: - $FLOAT_REF_COMMIT_FILE - $CUT_COMMIT_FILE - $MERGE_TARGET_COMMIT_FILE - - regressions_*.csv - - improvements_*.csv + - regressions_crashes.csv + - regressions_MLD.csv + - regressions_MAXIMUM_ABS_DIFF.csv + - regressions_MIN_SSNR.csv + - regressions_MIN_ODG.csv + - improvements_crashes.csv + - improvements_MLD.csv + - improvements_MAXIMUM_ABS_DIFF.csv + - improvements_MIN_SSNR.csv + - improvements_MIN_ODG.csv expose_as: "pytest compare results" reports: junit: -- GitLab From db8929b2b43f157801b52d0b29da6e4cf6d183e9 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 28 Feb 2025 16:50:49 +0530 Subject: [PATCH 227/329] Removal of redundant files from lib_dec --- Workspace_msvc/lib_dec.vcxproj | 99 --------- Workspace_msvc/lib_dec.vcxproj.filters | 295 ------------------------- lib_dec/ACcontextMapping_dec.c | 45 ---- lib_dec/FEC.c | 54 ----- lib_dec/FEC_HQ_phase_ecu.c | 44 ---- lib_dec/FEC_adapt_codebook.c | 51 ----- lib_dec/FEC_clas_estim.c | 44 ---- lib_dec/FEC_lsf_estim.c | 49 ---- lib_dec/FEC_pitch_estim.c | 42 ---- lib_dec/FEC_scale_syn.c | 42 ---- lib_dec/LD_music_post_filter.c | 44 ---- lib_dec/TonalComponentDetection.c | 47 ---- lib_dec/acelp_core_dec.c | 49 ---- lib_dec/acelp_core_switch_dec.c | 42 ---- lib_dec/amr_wb_dec.c | 43 ---- lib_dec/avq_dec.c | 42 ---- lib_dec/cng_dec.c | 47 ---- lib_dec/core_dec_reconf.c | 43 ---- lib_dec/core_dec_switch.c | 48 ---- lib_dec/d_gain2p.c | 43 ---- lib_dec/dec2t32.c | 55 ----- lib_dec/dec4t64.c | 43 ---- lib_dec/dec_LPD.c | 54 ----- lib_dec/dec_ace.c | 42 ---- lib_dec/dec_acelp.c | 46 ---- lib_dec/dec_acelp_tcx_main.c | 43 ---- lib_dec/dec_amr_wb.c | 48 ---- lib_dec/dec_gen_voic.c | 42 ---- lib_dec/dec_higher_acelp.c | 50 ----- lib_dec/dec_nelp.c | 41 ---- lib_dec/dec_pit_exc.c | 48 ---- lib_dec/dec_post.c | 159 ------------- lib_dec/dec_ppp.c | 41 ---- lib_dec/dec_tran.c | 47 ---- lib_dec/dec_uv.c | 40 ---- lib_dec/decision_matrix_dec.c | 50 ----- lib_dec/dlpc_avq.c | 47 ---- lib_dec/dlpc_stoch.c | 49 ---- lib_dec/er_dec_acelp.c | 42 ---- lib_dec/er_dec_tcx.c | 45 ---- lib_dec/er_scale_syn.c | 49 ---- lib_dec/er_sync_exc.c | 43 ---- lib_dec/er_util.c | 43 ---- lib_dec/evs_dec.c | 43 ---- lib_dec/gain_dec.c | 43 ---- lib_dec/gaus_dec.c | 43 ---- lib_dec/gs_dec.c | 50 ----- lib_dec/gs_dec_amr_wb.c | 43 ---- lib_dec/hdecnrm.c | 85 ------- lib_dec/hf_synth.c | 112 ---------- lib_dec/hq_classifier_dec.c | 42 ---- lib_dec/hq_conf_fec.c | 42 ---- lib_dec/hq_core_dec.c | 56 ----- lib_dec/hq_env_dec.c | 41 ---- lib_dec/hq_hr_dec.c | 42 ---- lib_dec/hq_lr_dec.c | 105 --------- lib_dec/igf_dec.c | 141 ------------ lib_dec/igf_scf_dec.c | 41 ---- lib_dec/inov_dec.c | 50 ----- lib_dec/ivas_agc_dec.c | 37 ---- lib_dec/ivas_cpe_dec.c | 69 ------ lib_dec/ivas_dec.c | 49 ---- lib_dec/ivas_lfe_dec.c | 36 --- lib_dec/ivas_lfe_plc.c | 46 ---- lib_dec/ivas_mct_dec_mct.c | 41 ---- lib_dec/ivas_pca_dec.c | 44 ---- lib_dec/ivas_sba_dirac_stereo_dec.c | 43 ---- lib_dec/ivas_sce_dec.c | 43 ---- lib_dec/ivas_sns_dec.c | 41 ---- lib_dec/ivas_stereo_dft_plc.c | 40 ---- lib_dec/ivas_stereo_mdct_core_dec.c | 42 ---- lib_dec/jbm_pcmdsp_fifo.c | 40 ---- lib_dec/lead_deindexing.c | 47 ---- lib_dec/lib_dec.c | 37 ---- lib_dec/lp_exc_d.c | 41 ---- lib_dec/lsf_dec.c | 58 ----- lib_dec/lsf_msvq_ma_dec.c | 43 ---- lib_dec/nelp_dec.c | 49 ---- lib_dec/peak_vq_dec.c | 77 ------- lib_dec/pit_dec.c | 43 ---- lib_dec/pitch_extr.c | 45 ---- lib_dec/post_dec.c | 59 ----- lib_dec/ppp_dec.c | 43 ---- lib_dec/pvq_core_dec.c | 44 ---- lib_dec/pvq_decode.c | 42 ---- lib_dec/range_dec.c | 42 ---- lib_dec/re8_dec.c | 40 ---- lib_dec/rst_dec.c | 49 ---- lib_dec/stat_noise_uv_dec.c | 40 ---- lib_dec/swb_bwe_dec_hr.c | 49 ---- lib_dec/swb_bwe_dec_lr.c | 51 ----- lib_dec/syn_outp.c | 49 ---- lib_dec/tcq_core_dec.c | 44 ---- lib_dec/tcx_utils_dec.c | 49 ---- lib_dec/tns_base_dec.c | 43 ---- lib_dec/transition_dec.c | 43 ---- lib_dec/updt_dec.c | 44 ---- lib_dec/vlpc_1st_dec.c | 42 ---- lib_dec/vlpc_2st_dec.c | 40 ---- lib_dec/voiced_dec.c | 55 ----- lib_dec/waveadjust_fec_dec.c | 77 ------- 101 files changed, 5315 deletions(-) delete mode 100644 lib_dec/ACcontextMapping_dec.c delete mode 100644 lib_dec/FEC.c delete mode 100644 lib_dec/FEC_HQ_phase_ecu.c delete mode 100644 lib_dec/FEC_adapt_codebook.c delete mode 100644 lib_dec/FEC_clas_estim.c delete mode 100644 lib_dec/FEC_lsf_estim.c delete mode 100644 lib_dec/FEC_pitch_estim.c delete mode 100644 lib_dec/FEC_scale_syn.c delete mode 100644 lib_dec/LD_music_post_filter.c delete mode 100644 lib_dec/TonalComponentDetection.c delete mode 100644 lib_dec/acelp_core_dec.c delete mode 100644 lib_dec/acelp_core_switch_dec.c delete mode 100644 lib_dec/amr_wb_dec.c delete mode 100644 lib_dec/avq_dec.c delete mode 100644 lib_dec/cng_dec.c delete mode 100644 lib_dec/core_dec_reconf.c delete mode 100644 lib_dec/core_dec_switch.c delete mode 100644 lib_dec/d_gain2p.c delete mode 100644 lib_dec/dec2t32.c delete mode 100644 lib_dec/dec4t64.c delete mode 100644 lib_dec/dec_LPD.c delete mode 100644 lib_dec/dec_ace.c delete mode 100644 lib_dec/dec_acelp.c delete mode 100644 lib_dec/dec_acelp_tcx_main.c delete mode 100644 lib_dec/dec_amr_wb.c delete mode 100644 lib_dec/dec_gen_voic.c delete mode 100644 lib_dec/dec_higher_acelp.c delete mode 100644 lib_dec/dec_nelp.c delete mode 100644 lib_dec/dec_pit_exc.c delete mode 100644 lib_dec/dec_post.c delete mode 100644 lib_dec/dec_ppp.c delete mode 100644 lib_dec/dec_tran.c delete mode 100644 lib_dec/dec_uv.c delete mode 100644 lib_dec/decision_matrix_dec.c delete mode 100644 lib_dec/dlpc_avq.c delete mode 100644 lib_dec/dlpc_stoch.c delete mode 100644 lib_dec/er_dec_acelp.c delete mode 100644 lib_dec/er_dec_tcx.c delete mode 100644 lib_dec/er_scale_syn.c delete mode 100644 lib_dec/er_sync_exc.c delete mode 100644 lib_dec/er_util.c delete mode 100644 lib_dec/evs_dec.c delete mode 100644 lib_dec/gain_dec.c delete mode 100644 lib_dec/gaus_dec.c delete mode 100644 lib_dec/gs_dec.c delete mode 100644 lib_dec/gs_dec_amr_wb.c delete mode 100644 lib_dec/hdecnrm.c delete mode 100644 lib_dec/hf_synth.c delete mode 100644 lib_dec/hq_classifier_dec.c delete mode 100644 lib_dec/hq_conf_fec.c delete mode 100644 lib_dec/hq_core_dec.c delete mode 100644 lib_dec/hq_env_dec.c delete mode 100644 lib_dec/hq_hr_dec.c delete mode 100644 lib_dec/hq_lr_dec.c delete mode 100644 lib_dec/igf_dec.c delete mode 100644 lib_dec/igf_scf_dec.c delete mode 100644 lib_dec/inov_dec.c delete mode 100644 lib_dec/ivas_agc_dec.c delete mode 100644 lib_dec/ivas_cpe_dec.c delete mode 100644 lib_dec/ivas_dec.c delete mode 100644 lib_dec/ivas_lfe_dec.c delete mode 100644 lib_dec/ivas_lfe_plc.c delete mode 100644 lib_dec/ivas_mct_dec_mct.c delete mode 100644 lib_dec/ivas_pca_dec.c delete mode 100644 lib_dec/ivas_sba_dirac_stereo_dec.c delete mode 100644 lib_dec/ivas_sce_dec.c delete mode 100644 lib_dec/ivas_sns_dec.c delete mode 100644 lib_dec/ivas_stereo_dft_plc.c delete mode 100644 lib_dec/ivas_stereo_mdct_core_dec.c delete mode 100644 lib_dec/jbm_pcmdsp_fifo.c delete mode 100644 lib_dec/lead_deindexing.c delete mode 100644 lib_dec/lib_dec.c delete mode 100644 lib_dec/lp_exc_d.c delete mode 100644 lib_dec/lsf_dec.c delete mode 100644 lib_dec/lsf_msvq_ma_dec.c delete mode 100644 lib_dec/nelp_dec.c delete mode 100644 lib_dec/peak_vq_dec.c delete mode 100644 lib_dec/pit_dec.c delete mode 100644 lib_dec/pitch_extr.c delete mode 100644 lib_dec/post_dec.c delete mode 100644 lib_dec/ppp_dec.c delete mode 100644 lib_dec/pvq_core_dec.c delete mode 100644 lib_dec/pvq_decode.c delete mode 100644 lib_dec/range_dec.c delete mode 100644 lib_dec/re8_dec.c delete mode 100644 lib_dec/rst_dec.c delete mode 100644 lib_dec/stat_noise_uv_dec.c delete mode 100644 lib_dec/swb_bwe_dec_hr.c delete mode 100644 lib_dec/swb_bwe_dec_lr.c delete mode 100644 lib_dec/syn_outp.c delete mode 100644 lib_dec/tcq_core_dec.c delete mode 100644 lib_dec/tcx_utils_dec.c delete mode 100644 lib_dec/tns_base_dec.c delete mode 100644 lib_dec/transition_dec.c delete mode 100644 lib_dec/updt_dec.c delete mode 100644 lib_dec/vlpc_1st_dec.c delete mode 100644 lib_dec/vlpc_2st_dec.c delete mode 100644 lib_dec/voiced_dec.c delete mode 100644 lib_dec/waveadjust_fec_dec.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index d6e4a7c67..3d447fe21 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -136,152 +136,94 @@ - false - false - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -294,16 +236,13 @@ - - - @@ -315,7 +254,6 @@ - @@ -323,10 +261,8 @@ - - @@ -336,13 +272,11 @@ - - @@ -355,78 +289,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 348c5fbda..cc7594415 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -1,17 +1,10 @@  - - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c @@ -21,120 +14,63 @@ decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - - - decoder_evs_c - decoder_evs_c decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c - - decoder_evs_c - decoder_evs_c decoder_evs_c - - decoder_evs_c - - - decoder_evs_c - decoder_evs_c decoder_evs_c - - decoder_evs_c - - - decoder_evs_c - decoder_evs_c decoder_evs_c - - decoder_evs_c - - - decoder_evs_c - decoder_evs_c decoder_evs_c - - decoder_evs_c - decoder_ivas_c @@ -147,15 +83,9 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -192,15 +122,9 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -228,9 +152,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -255,9 +176,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -279,24 +197,15 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -321,9 +230,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -339,9 +245,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -363,15 +266,9 @@ decoder_ivas_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -393,9 +290,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -405,9 +299,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -417,27 +308,15 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -453,69 +332,36 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -525,18 +371,9 @@ decoder_all_c - - decoder_all_c - - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -549,105 +386,54 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -657,15 +443,9 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -681,102 +461,57 @@ decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -792,33 +527,18 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -828,33 +548,18 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c deleted file mode 100644 index 186a22bc7..000000000 --- a/lib_dec/ACcontextMapping_dec.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "ivas_rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "ivas_prot.h" /* Range coder header file */ -#include diff --git a/lib_dec/FEC.c b/lib_dec/FEC.c deleted file mode 100644 index 3dd25fd27..000000000 --- a/lib_dec/FEC.c +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "prot.h" -#include "wmc_auto.h" - - -#define WMC_TOOL_SKIP -/*-------------------------------------------------------------------* - * pulseRes_preCalc() - * - * calculates some conditions for Pulse resynchronization to take place - *-------------------------------------------------------------------*/ - -#undef WMC_TOOL_SKIP diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c deleted file mode 100644 index 85b25b336..000000000 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "rom_dec.h" -#include "rom_com.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/FEC_adapt_codebook.c b/lib_dec/FEC_adapt_codebook.c deleted file mode 100644 index f07b5952a..000000000 --- a/lib_dec/FEC_adapt_codebook.c +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_dec.h" -#include "prot.h" -#include "wmc_auto.h" - -/*------------------------------------------------------------------------- - * FEC_synchro_exc() - * - * Perform resynchronisation of the last glottal pulse in voiced frame lost - *------------------------------------------------------------------------*/ - -/*! r: do_WI flag */ diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c deleted file mode 100644 index 77501d3fa..000000000 --- a/lib_dec/FEC_clas_estim.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include "cnst.h" -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "stat_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/FEC_lsf_estim.c b/lib_dec/FEC_lsf_estim.c deleted file mode 100644 index 49a4adafc..000000000 --- a/lib_dec/FEC_lsf_estim.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * FEC_lsf2lsp_interp_flt() - * - * - LSP calculation - * - A(z) calculation - *-------------------------------------------------------------------*/ diff --git a/lib_dec/FEC_pitch_estim.c b/lib_dec/FEC_pitch_estim.c deleted file mode 100644 index bae1a8539..000000000 --- a/lib_dec/FEC_pitch_estim.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/FEC_scale_syn.c b/lib_dec/FEC_scale_syn.c deleted file mode 100644 index 5c3581f4f..000000000 --- a/lib_dec/FEC_scale_syn.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c deleted file mode 100644 index 494df80ce..000000000 --- a/lib_dec/LD_music_post_filter.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "wmc_auto.h" diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c deleted file mode 100644 index a8ad442c0..000000000 --- a/lib_dec/TonalComponentDetection.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#define _USE_MATH_DEFINES - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "stat_com.h" -#include "wmc_auto.h" -#include "ivas_prot.h" diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c deleted file mode 100644 index 2374f1b7c..000000000 --- a/lib_dec/acelp_core_dec.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - - -#include -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_cnst.h" -#include "ivas_prot.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c deleted file mode 100644 index b25a46f03..000000000 --- a/lib_dec/acelp_core_switch_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c deleted file mode 100644 index 47e1f0be1..000000000 --- a/lib_dec/amr_wb_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/avq_dec.c b/lib_dec/avq_dec.c deleted file mode 100644 index 1e54dc9d9..000000000 --- a/lib_dec/avq_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "wmc_auto.h" -#include diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c deleted file mode 100644 index 5f2ee4f7e..000000000 --- a/lib_dec/cng_dec.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "ivas_cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c deleted file mode 100644 index 6bcd541ef..000000000 --- a/lib_dec/core_dec_reconf.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "wmc_auto.h" -#include "prot_fx.h" diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c deleted file mode 100644 index 09bd8e846..000000000 --- a/lib_dec/core_dec_switch.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------* - * mode_switch_decoder_LPD() - * - * - *-------------------------------------------------------------*/ diff --git a/lib_dec/d_gain2p.c b/lib_dec/d_gain2p.c deleted file mode 100644 index cc19164ca..000000000 --- a/lib_dec/d_gain2p.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec2t32.c b/lib_dec/dec2t32.c deleted file mode 100644 index 13c9ebade..000000000 --- a/lib_dec/dec2t32.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*----------------------------------------------------------------------------------* - * dec_acelp_2t32() - * - * 12 bits algebraic codebook decoder. - * 2 track x 32 positions per track = 64 samples. - * - * 12 bits --> 2 pulses in a frame of 64 samples. - * - * All pulses can have two (2) possible amplitudes: +1 or -1. - * Each pulse can have 32 possible positions. - * - * See cod2t32.c for more details of the algebraic code. - *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/dec4t64.c b/lib_dec/dec4t64.c deleted file mode 100644 index d448123b1..000000000 --- a/lib_dec/dec4t64.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c deleted file mode 100644 index 4c0b6a79a..000000000 --- a/lib_dec/dec_LPD.c +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "cnst.h" -#include "basop_proto_func.h" -#include "stat_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" - - -/*-------------------------------------------------------------------* - * decoder_LPD() - * - * Core decoder MODE2 - *--------------------------------------------------------------------*/ diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c deleted file mode 100644 index 76754d2e6..000000000 --- a/lib_dec/dec_ace.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec_acelp.c b/lib_dec/dec_acelp.c deleted file mode 100644 index 075822eb6..000000000 --- a/lib_dec/dec_acelp.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c deleted file mode 100644 index d8b8509d9..000000000 --- a/lib_dec/dec_acelp_tcx_main.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "prot.h" -#include "rom_com.h" -#include -#include "options.h" -#include "stat_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec_amr_wb.c b/lib_dec/dec_amr_wb.c deleted file mode 100644 index 4cf26936b..000000000 --- a/lib_dec/dec_amr_wb.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * decod_amr_wb() - * - * Decode excitation signal in AMR-WB IO mode - *---------------------------------------------------------------------*/ diff --git a/lib_dec/dec_gen_voic.c b/lib_dec/dec_gen_voic.c deleted file mode 100644 index b25a46f03..000000000 --- a/lib_dec/dec_gen_voic.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec_higher_acelp.c b/lib_dec/dec_higher_acelp.c deleted file mode 100644 index 77bd8dd6d..000000000 --- a/lib_dec/dec_higher_acelp.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-----------------------------------------------------------------* - * transf_cdbk_dec() - * - * Transform domain contribution decoding - *-----------------------------------------------------------------*/ diff --git a/lib_dec/dec_nelp.c b/lib_dec/dec_nelp.c deleted file mode 100644 index 167c70dbf..000000000 --- a/lib_dec/dec_nelp.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec_pit_exc.c b/lib_dec/dec_pit_exc.c deleted file mode 100644 index 5a894a39c..000000000 --- a/lib_dec/dec_pit_exc.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * dec_pit_exc() - * - * Decode pitch-only contribution (used by the GSC technology) - *-------------------------------------------------------------------*/ diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c deleted file mode 100644 index 5cb811408..000000000 --- a/lib_dec/dec_post.c +++ /dev/null @@ -1,159 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - -#define FORMAT_POST_FILT_G1 0.75f /*0.75f*/ /*denominator 0.9,0.75,0.15,0.9*/ - - -/*-------------------------------------------------------------------------- - * Local function prototypes - *--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------* - * Function Init_post_filter_ivas() - * - * Post-filter initialization - *--------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------- - * nb_post_filt_ivas() - * - * Main routine to perform post filtering of NB signals - *--------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------- - * formant_post_filt_ivas: - * - * WB and SWB formant post-filtering - *--------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------- - * Dec_postfilt() - * - * Adaptive postfilter main function - * Short-term postfilter : - * Hst(z) = Hst0(z) Hst1(z) - * Hst0(z) = 1/g0 A(gamma2)(z) / A(gamma1)(z) - * if {hi} = i.r. filter A(gamma2)/A(gamma1) (truncated) - * g0 = SUM(|hi|) if > 1 - * g0 = 1. else - * Hst1(z) = 1/(1 - |mu|) (1 + mu z-1) - * with mu = k1 * gamma3 - * k1 = 1st parcor calculated on {hi} - * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0 - * Long-term postfilter : - * harmonic postfilter : H0(z) = gl * (1 + b * z-p) - * b = gamma_g * gain_ltp - * gl = 1 / 1 + b - * computation of delay p on A(gamma2)(z) s(z) - * sub optimal search - * 1. search around 1st subframe delay (3 integer values) - * 2. search around best integer with fract. delays (1/8) - *----------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------- - * Dec_formant_postfilt - * - * Post - adaptive postfilter main function - * Short term postfilter : - * Hst(z) = Hst0(z) Hst1(z) - * Hst0(z) = 1/g0 A(gamma2)(z) / A(gamma1)(z) - * if {hi} = i.r. filter A(gamma2)/A(gamma1) (truncated) - * g0 = SUM(|hi|) if > 1 - * g0 = 1. else - * Hst1(z) = 1/(1 - |mu|) (1 + mu z-1) - * with mu = k1 * gamma3 - * k1 = 1st parcor calculated on {hi} - * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0 - *----------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------- - * pst_ltp() - * - * Perform harmonic postfilter - *----------------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------------- - * search_del() - * - * Computes best (shortest) integer LTP delay + fine search - *---------------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------------- - * filt_plt() - * - * Perform long term postfilter - *----------------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------------- - * compute_ltp_l() - * - * compute delayed signal, num & den of gain for fractional delay - * with long interpolation filter - *----------------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------------- - * select_ltp() - * - * selects best of (gain1, gain2) - * with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1 - * and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2 - *----------------------------------------------------------------------------*/ - -/*! r: 1 = 1st gain, 2 = 2nd gain */ - - -/*------------------------------------------------------------------------------------ - * modify_pst_param() - * - * Modify gamma1 and gamma2 values in function of the long-term noise level - *-----------------------------------------------------------------------------------*/ diff --git a/lib_dec/dec_ppp.c b/lib_dec/dec_ppp.c deleted file mode 100644 index 167c70dbf..000000000 --- a/lib_dec/dec_ppp.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/dec_tran.c b/lib_dec/dec_tran.c deleted file mode 100644 index 3522990d9..000000000 --- a/lib_dec/dec_tran.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * decod_tran() - * - * Decode transition (TC) frames - *-------------------------------------------------------------------*/ diff --git a/lib_dec/dec_uv.c b/lib_dec/dec_uv.c deleted file mode 100644 index 9e7ce9558..000000000 --- a/lib_dec/dec_uv.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/decision_matrix_dec.c b/lib_dec/decision_matrix_dec.c deleted file mode 100644 index 9ee7741c0..000000000 --- a/lib_dec/decision_matrix_dec.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "stat_dec.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-----------------------------------------------------------------* - * decision_matrix_dec() - * - * ACELP/HQ core selection - * Read ACELP signaling bits from the bitstream - * Set extension layers - *-----------------------------------------------------------------*/ diff --git a/lib_dec/dlpc_avq.c b/lib_dec/dlpc_avq.c deleted file mode 100644 index 748544423..000000000 --- a/lib_dec/dlpc_avq.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" - -/*------------------------------------------------------------------* - * dlpc_avq() - * - * Variable bitrate multiple LPC un-quantizer - *------------------------------------------------------------------*/ diff --git a/lib_dec/dlpc_stoch.c b/lib_dec/dlpc_stoch.c deleted file mode 100644 index 5645c9462..000000000 --- a/lib_dec/dlpc_stoch.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" - -/*------------------------------------------------------------------* - * lpc_unquantize() - * - * - *------------------------------------------------------------------*/ diff --git a/lib_dec/er_dec_acelp.c b/lib_dec/er_dec_acelp.c deleted file mode 100644 index 047de37fb..000000000 --- a/lib_dec/er_dec_acelp.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c deleted file mode 100644 index f2bd70247..000000000 --- a/lib_dec/er_dec_tcx.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include "cnst.h" -#include "ivas_cnst.h" -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/er_scale_syn.c b/lib_dec/er_scale_syn.c deleted file mode 100644 index eea698fa6..000000000 --- a/lib_dec/er_scale_syn.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "wmc_auto.h" - - -/*----------------------------------------------------------------------------------* - * Damping_fact_flt() - * - * Estimate damping factor - *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/er_sync_exc.c b/lib_dec/er_sync_exc.c deleted file mode 100644 index 05720aca8..000000000 --- a/lib_dec/er_sync_exc.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "wmc_auto.h" diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c deleted file mode 100644 index 9cd1332e6..000000000 --- a/lib_dec/er_util.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "stat_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c deleted file mode 100644 index 47e1f0be1..000000000 --- a/lib_dec/evs_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/gain_dec.c b/lib_dec/gain_dec.c deleted file mode 100644 index 47e1f0be1..000000000 --- a/lib_dec/gain_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/gaus_dec.c b/lib_dec/gaus_dec.c deleted file mode 100644 index 47e1f0be1..000000000 --- a/lib_dec/gaus_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/gs_dec.c b/lib_dec/gs_dec.c deleted file mode 100644 index 4d34802bb..000000000 --- a/lib_dec/gs_dec.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * decod_audio() - * - * Decode audio (AC) frames - *-------------------------------------------------------------------*/ diff --git a/lib_dec/gs_dec_amr_wb.c b/lib_dec/gs_dec_amr_wb.c deleted file mode 100644 index 47e1f0be1..000000000 --- a/lib_dec/gs_dec_amr_wb.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/hdecnrm.c b/lib_dec/hdecnrm.c deleted file mode 100644 index 19627a4f3..000000000 --- a/lib_dec/hdecnrm.c +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "wmc_auto.h" - - -/*--------------------------------------------------------------------------*/ -/* Function decode_huff_context() */ -/* */ -/* Context based Huffman decoding for indices of quantized norms */ -/*--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------*/ -/* Function hdecnrm() */ -/* */ -/* Huffman decoding for indices of quantized norms */ -/*--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * huff_dec() - * - * Huffman decoding - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * hdecnrm_context() - * - * Huffman decoding for indices of quantized norms - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * hdecnrm_resize() - * - * - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * hdecnrm_trans() - * - * Huffman decoding for indices of quantized norms - *--------------------------------------------------------------------------*/ diff --git a/lib_dec/hf_synth.c b/lib_dec/hf_synth.c deleted file mode 100644 index fc8c8da5f..000000000 --- a/lib_dec/hf_synth.c +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "basop32.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------------------* - * hf_synthesis_amr_wb() - * - * HF noise synthesis - * - Generate HF noise between 6 and 8 kHz, mix it with signal obtained by linear resampling. - * - Set energy of high band - *-----------------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------------------* - * EnhanceClass() - * - * - *-----------------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------------------* - * envelope() - * - * - *-----------------------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * AdaptiveStartBand() - * - * adaptively select the start band of bandwidth extension - *---------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------* - * hp400_12k8() - * - * 2nd order Cheb2 high pass filter with cut off frequency at 400 Hz. - * Optimized for fixed-point to get the following frequency response: - * - * frequency : 0Hz 100Hz 200Hz 300Hz 400Hz 630Hz 1.5kHz 3kHz - * dB loss : -infdB -30dB -20dB -10dB -3dB +6dB +1dB 0dB - * - * Algorithm : - * - * y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] - * + a[1]*y[i-1] + a[2]*y[i-2]; - * - * short b[3] = {3660, -7320, 3660}; in Q12 - * short a[3] = {4096, 7320, -3540}; in Q12 - * - * float b[3] = {0.893554687, -1.787109375, 0.893554687}; - * float a[3] = {1.000000000, 1.787109375, -0.864257812}; - *-----------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * filt_6k_7k() - * - * 15th order band pass 6kHz to 7kHz FIR filter - * - * frequency :4kHz 5kHz 5.5kHz 6kHz 6.5kHz 7kHz 7.5kHz 8kHz - * dB loss : -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB - * (gain = 4.0) - *-------------------------------------------------------------------*/ diff --git a/lib_dec/hq_classifier_dec.c b/lib_dec/hq_classifier_dec.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_dec/hq_classifier_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/hq_conf_fec.c b/lib_dec/hq_conf_fec.c deleted file mode 100644 index b25a46f03..000000000 --- a/lib_dec/hq_conf_fec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c deleted file mode 100644 index cd29271f1..000000000 --- a/lib_dec/hq_core_dec.c +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "ivas_prot.h" - -/*-------------------------------------------------------------------------- - * hq_core_dec() - * - * HQ core decoder - *--------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * hq_core_dec_init() - * - * Initialize HQ core state structure - *-------------------------------------------------------------------*/ diff --git a/lib_dec/hq_env_dec.c b/lib_dec/hq_env_dec.c deleted file mode 100644 index d029c2fa8..000000000 --- a/lib_dec/hq_env_dec.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/hq_hr_dec.c b/lib_dec/hq_hr_dec.c deleted file mode 100644 index b25a46f03..000000000 --- a/lib_dec/hq_hr_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c deleted file mode 100644 index 8547d9712..000000000 --- a/lib_dec/hq_lr_dec.c +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "prot.h" -#include "stl.h" -#include "basop_util.h" -#include "wmc_auto.h" - -/*--------------------------------------------------------------------------* - * Local function prototypes - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * hq_lr_dec() - * - * HQ low rate decoding routine - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------------ - * small_symbol_dec_tran() - * - * Huffman decoding of differential energies - *--------------------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * small_symbol_dec() - * - * Huffman decoding of differential energies (MSB and LSB) - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * large_symbol_dec() - * - * - *--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------* - * band_energy_dequant() - * - * - *--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------* - * p2a_threshold_dequant() - * - * - *--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------* - * mdct_spectrum_fine_gain_dec() - * - * - *--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------* - * spt_shorten_domain_set_dec() - * - * update the shorten band information based on p2a analysis - *--------------------------------------------------------------------------*/ diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c deleted file mode 100644 index 64a8d798b..000000000 --- a/lib_dec/igf_dec.c +++ /dev/null @@ -1,141 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "stat_dec.h" -#include "ivas_prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - - -/*-------------------------------------------------------------------* - * IGF_replaceTCXNoise_1_flr() - * - * measures TCX noise - *-------------------------------------------------------------------*/ - -/*! r: number of noise bands */ - - -/*-------------------------------------------------------------------* - * IGF_replaceTCXNoise_2_flt() - * - * replaces TCX noise - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGF_replaceTCXNoise_2_new_flt() - * - * - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGF_decode_whitening_level_flt() - * - * reads whitening levels - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGF_getMDCTSquare_flt() - * - * square the MDCT spectrum - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGF_calcSfbEnergy_flt() - * - * calculate energy per SFB - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGF_setLinesToZero_flt() - * - * set power spectrum values to zero, needed for energy calculation - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGF_RefineGrid_flt() - * - * refines the IGF grid - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGFDecReadData_flt() - * - * reads whitening information from the bitstream - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGFDecUpdateInfo_flt() - * - * updates the start/stop frequency of IGF according to igfGridIdx - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * IGFDecStoreTCX10SubFrameData_flt() - * - * store the IGF bitstream information for TCX10 subframes - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * IGFDecRestoreTCX10SubFrameData_flt() - * - * restore the IGF bitstream information for TCX10 subframes - *-------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------* - * init_igf_dec_flt() - * - * Initialize IGF decoder parameters - *-----------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------* - * get_igf_startline_flt() - * - * - *-----------------------------------------------------------------------*/ diff --git a/lib_dec/igf_scf_dec.c b/lib_dec/igf_scf_dec.c deleted file mode 100644 index 68174a8c2..000000000 --- a/lib_dec/igf_scf_dec.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "stat_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c deleted file mode 100644 index be630cee0..000000000 --- a/lib_dec/inov_dec.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*----------------------------------------------------------------------* - * inov_decode() - * - * Decode the algebraic innovation and do pitch sharpening - *----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c deleted file mode 100644 index 46246da44..000000000 --- a/lib_dec/ivas_agc_dec.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include -#include "options.h" -#include "wmc_auto.h" diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c deleted file mode 100644 index 4a6f34081..000000000 --- a/lib_dec/ivas_cpe_dec.c +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "prot_fx.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" -#include - - -/*--------------------------------------------------------------------------* - * Local function prototypes - *--------------------------------------------------------------------------*/ - - -/*--------------------------------------------------------------------------* - * ivas_cpe_dec() - * - * Channel Pair Element (CPE) decoding routine - *--------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------- - * read_stereo_mode_and_bwidth() - * - * Read stereo technology info & audio bandwidth - *-------------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------------- - * stereo_mode_combined_format_dec() - * - * Set stereo format in a combined format - *-------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c deleted file mode 100644 index 351331bb2..000000000 --- a/lib_dec/ivas_dec.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "ivas_prot_rend.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" - - -/*--------------------------------------------------------------------------* - * ivas_dec() - * - * Principal IVAS decoder routine - *--------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c deleted file mode 100644 index e9f3a7b28..000000000 --- a/lib_dec/ivas_lfe_dec.c +++ /dev/null @@ -1,36 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include "options.h" -#include "wmc_auto.h" diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c deleted file mode 100644 index 89b232254..000000000 --- a/lib_dec/ivas_lfe_plc.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include "prot.h" -#include "ivas_prot.h" -#include "ivas_rom_com.h" -#include -#ifdef DEBUGGING -#include "debug.h" -#endif -#include "wmc_auto.h" - -/*------------------------------------------------------------------------------------------* - * Local constants - *------------------------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c deleted file mode 100644 index 52431d36a..000000000 --- a/lib_dec/ivas_mct_dec_mct.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include "ivas_cnst.h" -#include "ivas_prot.h" -#include "prot.h" -#include "wmc_auto.h" -#include -#include "stat_enc.h" -#include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_pca_dec.c b/lib_dec/ivas_pca_dec.c deleted file mode 100644 index f2f5274be..000000000 --- a/lib_dec/ivas_pca_dec.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include "prot.h" -#include "ivas_prot.h" -#include -#include "ivas_cnst.h" -#include "wmc_auto.h" - - -/*-----------------------------------------------------------------------* - * Local function definitions - *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c deleted file mode 100644 index 1cfc7aa2e..000000000 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" -#include "ivas_rom_com.h" -#include "ivas_rom_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c deleted file mode 100644 index 5f384870f..000000000 --- a/lib_dec/ivas_sce_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_prot.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c deleted file mode 100644 index 86fd2fb3e..000000000 --- a/lib_dec/ivas_sns_dec.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "ivas_rom_com.h" -#include "ivas_cnst.h" -#include -#include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_dft_plc.c b/lib_dec/ivas_stereo_dft_plc.c deleted file mode 100644 index 5a9122b00..000000000 --- a/lib_dec/ivas_stereo_dft_plc.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_cnst.h" -#include "ivas_prot.h" -#include "math.h" -#include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c deleted file mode 100644 index e11120d38..000000000 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "stat_com.h" -#include "ivas_prot.h" -#include "ivas_stat_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c deleted file mode 100644 index 00e5ce7f0..000000000 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -/*! @file jbm_pcmdsp_fifo.c Ringbuffer (FIFO) with fixed capacity for audio samples */ - -#include -#include "options.h" diff --git a/lib_dec/lead_deindexing.c b/lib_dec/lead_deindexing.c deleted file mode 100644 index 35a1adf15..000000000 --- a/lib_dec/lead_deindexing.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c deleted file mode 100644 index 81d78932a..000000000 --- a/lib_dec/lib_dec.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include -#include -#include "lib_dec.h" -#include "wmc_auto.h" diff --git a/lib_dec/lp_exc_d.c b/lib_dec/lp_exc_d.c deleted file mode 100644 index 167c70dbf..000000000 --- a/lib_dec/lp_exc_d.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c deleted file mode 100644 index abc1aab9d..000000000 --- a/lib_dec/lsf_dec.c +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "basop_proto_func.h" -#include "ivas_prot.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" - - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * lsf_dec() - * - * LSF decoder - *---------------------------------------------------------------------*/ diff --git a/lib_dec/lsf_msvq_ma_dec.c b/lib_dec/lsf_msvq_ma_dec.c deleted file mode 100644 index 042eec9ab..000000000 --- a/lib_dec/lsf_msvq_ma_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" diff --git a/lib_dec/nelp_dec.c b/lib_dec/nelp_dec.c deleted file mode 100644 index 1dc550e6d..000000000 --- a/lib_dec/nelp_dec.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * nelp_decoder() - * - * NELP decoder - *-------------------------------------------------------------------*/ diff --git a/lib_dec/peak_vq_dec.c b/lib_dec/peak_vq_dec.c deleted file mode 100644 index 67ab06e08..000000000 --- a/lib_dec/peak_vq_dec.c +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - - -/*------------------------------------------------------------------------* - * Local function prototypes - *------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * hvq_dec() - * - * HVQ decoder - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * peak_vq_dec() - * - * Vector de-quantization of MDCT peaks - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * dequant_peaks() - * - * Reads codebook vector and scales peak - *--------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - * hvq_dec_pos() - * - * HVQ decode peak positions - *--------------------------------------------------------------------------*/ diff --git a/lib_dec/pit_dec.c b/lib_dec/pit_dec.c deleted file mode 100644 index c74e05591..000000000 --- a/lib_dec/pit_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/pitch_extr.c b/lib_dec/pitch_extr.c deleted file mode 100644 index 3d10f2158..000000000 --- a/lib_dec/pitch_extr.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "basop_util.h" -#include "wmc_auto.h" diff --git a/lib_dec/post_dec.c b/lib_dec/post_dec.c deleted file mode 100644 index 380b256b0..000000000 --- a/lib_dec/post_dec.c +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Function prototypes - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * post_decoder_flt() - * - * Perform post-processing - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * bass_pf_1sf_delay() - * - * Perform low-frequency postfiltering - *---------------------------------------------------------------------*/ diff --git a/lib_dec/ppp_dec.c b/lib_dec/ppp_dec.c deleted file mode 100644 index 7ea6e47a5..000000000 --- a/lib_dec/ppp_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/pvq_core_dec.c b/lib_dec/pvq_core_dec.c deleted file mode 100644 index 2bdb05e5f..000000000 --- a/lib_dec/pvq_core_dec.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "stl.h" -#include "wmc_auto.h" diff --git a/lib_dec/pvq_decode.c b/lib_dec/pvq_decode.c deleted file mode 100644 index 9228e2f5d..000000000 --- a/lib_dec/pvq_decode.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/range_dec.c b/lib_dec/range_dec.c deleted file mode 100644 index b25a46f03..000000000 --- a/lib_dec/range_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/re8_dec.c b/lib_dec/re8_dec.c deleted file mode 100644 index 9e7ce9558..000000000 --- a/lib_dec/re8_dec.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/rst_dec.c b/lib_dec/rst_dec.c deleted file mode 100644 index 3feb2af8e..000000000 --- a/lib_dec/rst_dec.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*----------------------------------------------------------------------------------* - * CNG_reset_dec() - * - * Reset decoder static variables in case of CNG frame - *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/stat_noise_uv_dec.c b/lib_dec/stat_noise_uv_dec.c deleted file mode 100644 index 9e7ce9558..000000000 --- a/lib_dec/stat_noise_uv_dec.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/swb_bwe_dec_hr.c b/lib_dec/swb_bwe_dec_hr.c deleted file mode 100644 index 06d666ffd..000000000 --- a/lib_dec/swb_bwe_dec_hr.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * swb_bwe_dec_hr() - * - * HR SWB BWE decoder - *-------------------------------------------------------------------*/ diff --git a/lib_dec/swb_bwe_dec_lr.c b/lib_dec/swb_bwe_dec_lr.c deleted file mode 100644 index 7bd79fa23..000000000 --- a/lib_dec/swb_bwe_dec_lr.c +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "stat_com.h" -#include "wmc_auto.h" - - -/*-------------------------------------------------------------------* - * DecodeSWBGenericParameters() - * - * Decoding of generic subband coding parameters - *-------------------------------------------------------------------*/ diff --git a/lib_dec/syn_outp.c b/lib_dec/syn_outp.c deleted file mode 100644 index 543b69d8d..000000000 --- a/lib_dec/syn_outp.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * syn_output() - * - * Output synthesis signal with compensation for saturation - * returns number of clipped samples - *-------------------------------------------------------------------*/ diff --git a/lib_dec/tcq_core_dec.c b/lib_dec/tcq_core_dec.c deleted file mode 100644 index f7f81a0fa..000000000 --- a/lib_dec/tcq_core_dec.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" diff --git a/lib_dec/tcx_utils_dec.c b/lib_dec/tcx_utils_dec.c deleted file mode 100644 index 1fc02caee..000000000 --- a/lib_dec/tcx_utils_dec.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*--------------------------------------------------------------- - * tcx_decoder_memory_update_flt() - * - * - *--------------------------------------------------------------*/ diff --git a/lib_dec/tns_base_dec.c b/lib_dec/tns_base_dec.c deleted file mode 100644 index c74a5f4e1..000000000 --- a/lib_dec/tns_base_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "stat_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/transition_dec.c b/lib_dec/transition_dec.c deleted file mode 100644 index 47e1f0be1..000000000 --- a/lib_dec/transition_dec.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/updt_dec.c b/lib_dec/updt_dec.c deleted file mode 100644 index 6ffe42f8c..000000000 --- a/lib_dec/updt_dec.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "cnst.h" -#include -#include "wmc_auto.h" diff --git a/lib_dec/vlpc_1st_dec.c b/lib_dec/vlpc_1st_dec.c deleted file mode 100644 index 78821eb05..000000000 --- a/lib_dec/vlpc_1st_dec.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_dec/vlpc_2st_dec.c b/lib_dec/vlpc_2st_dec.c deleted file mode 100644 index 9e7ce9558..000000000 --- a/lib_dec/vlpc_2st_dec.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_dec/voiced_dec.c b/lib_dec/voiced_dec.c deleted file mode 100644 index 4fbd33bdf..000000000 --- a/lib_dec/voiced_dec.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * ppp_voiced_decoder() - * - * Voiced decoder for SC-VBR - *-------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * sc_vbr_dec_init_flt() - * - * Initialize SC-VBR decoder - *---------------------------------------------------------------------*/ diff --git a/lib_dec/waveadjust_fec_dec.c b/lib_dec/waveadjust_fec_dec.c deleted file mode 100644 index 65de1e11f..000000000 --- a/lib_dec/waveadjust_fec_dec.c +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" - - -/*-------------------------------------------------------------------* - * Local functions - * - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * waveform_adj2() - * - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * concealment_decode() - * - * - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * concealment_update() - * - * - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * concealment_update2() - * - * - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * concealment_signal_tuning() - * - * - *-------------------------------------------------------------------*/ -- GitLab From 17167fdb9d4c9e7460f5fabdbbbf7b3042ae5aaf Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 3 Mar 2025 15:43:04 +1100 Subject: [PATCH 228/329] test MLD, SSNR and PEAQ with split rendering tests --- .gitlab-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index faaf7fa54..b4fbe56eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-sr-obj-scores" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -1372,8 +1372,11 @@ split-rendering-pytest-on-merge-request: - if [ $ref_using_target == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi + - comp_args="--mld --ssnr --odg" + - echo "$comp_args" + # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py $comp_args --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check -- GitLab From 4efb8dc052a8a2bcc64d83643560c732a2894349 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Feb 2025 17:13:29 +0100 Subject: [PATCH 229/329] port FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP; under NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD --- lib_com/cnst.h | 4 ++++ lib_com/options.h | 1 + lib_enc/dtx_fx.c | 9 +++++---- lib_enc/ivas_ism_dtx_enc.c | 4 ++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 26903f525..87aafb11a 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -932,6 +932,10 @@ typedef enum #define GAIN_PRED_ORDER 4 /* Gain quantization - prediction order for gain quantizer (only for AMR-WB IO mode) */ #define MEAN_ENER 30 /* Gain quantization - average innovation energy */ +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD +#define DTX_THR 5 /* DTX - lp_noise threshold for DTX at higher bitrates */ +#endif + #define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */ #define CNG_ISF_FACT 0.9f /* CNG & DTX - CNG spectral envelope smoothing factor */ #define STEP_AMR_WB_SID 2.625f /* CNG & DTX - CNG energy quantization step */ diff --git a/lib_com/options.h b/lib_com/options.h index 50c5066fa..9fed7783e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,4 +170,5 @@ #define FIX_1298 /* VA: fix possible assert in gaus_enc */ #define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ +#define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ #endif diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 17965e99e..c003185a2 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -30,8 +30,7 @@ #define CNG_TYPE_HO 20 /* hangover for switching between CNG types */ -/* _DIFF_FLOAT_FIX_ : lp_noise_fx threshold is different between float (15) and fix (5*256) */ -#define LP_NOISE_LV 5 /* LP_NOISE level */ +#define LP_NOISE_LV DTX_THR /* LP_NOISE level */ #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ @@ -104,7 +103,6 @@ void dtx_ivas_fx( } ELSE { - /* _DIFF_FLOAT_FIX_ : lp_noise_fx threshold is different between float (15) and fix (5*256) */ test(); test(); test(); @@ -232,7 +230,11 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ); +#else LT_16( st_fx->lp_noise_fx, 3840 /*15 in Q8*/ ); +#endif } test(); test(); @@ -674,7 +676,6 @@ void dtx_fx( } ELSE { - /* _DIFF_FLOAT_FIX_ : lp_noise_fx threshold is different between float (15) and fix (5*256) */ last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 95b37435c..3439baff1 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -177,7 +177,11 @@ Word16 ivas_ism_dtx_enc_fx( ( EQ_16( nchan_ism, 2 ) && LE_32( ivas_total_brate, IVAS_48k ) ) || ( EQ_16( nchan_ism, 3 ) && LE_32( ivas_total_brate, IVAS_80k ) ) || ( EQ_16( nchan_ism, 4 ) && LE_32( ivas_total_brate, IVAS_96k ) ) || +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + LT_16( lp_noise_max_fx, ( DTX_THR << 8 ) ) ) ) +#else LT_16( lp_noise_max_fx, ( 15 << 8 ) ) ) ) +#endif { dtx_flag = 0; move16(); -- GitLab From 2158608ceaa6fa982d915f5757ac3dad174f233f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 20 Feb 2025 17:00:36 +0100 Subject: [PATCH 230/329] replace LP_NOISE_LV by DTX_THR --- lib_enc/dtx_fx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index c003185a2..a1478d3f8 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -30,8 +30,9 @@ #define CNG_TYPE_HO 20 /* hangover for switching between CNG types */ -#define LP_NOISE_LV DTX_THR /* LP_NOISE level */ - +#ifndef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD +#define DTX_THR 5 /* LP_NOISE level */ +#endif #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ #define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ @@ -106,7 +107,7 @@ void dtx_ivas_fx( test(); test(); test(); - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); test(); test(); @@ -115,9 +116,9 @@ void dtx_ivas_fx( #ifdef NONBE_1211_DTX_BR_SWITCHING last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || - LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ); + LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); #else - last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); + last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); br_dtx_flag = 0; move16(); #endif @@ -231,7 +232,7 @@ void dtx_ivas_fx( br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || #ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD - LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ); + LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); #else LT_16( st_fx->lp_noise_fx, 3840 /*15 in Q8*/ ); #endif @@ -676,9 +677,9 @@ void dtx_fx( } ELSE { - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); - last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); + last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); br_dtx_flag = 0; move16(); } @@ -773,8 +774,8 @@ void dtx_fx( if ( st_fx->dtx_sce_sba == 0 ) #endif { - br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || - EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) ) ); + br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || + EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) ); } test(); test(); -- GitLab From b28ea2b217927e16c52f8aaca103daa952ec2cd3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 14:44:44 +0530 Subject: [PATCH 231/329] Fix for 3GPP issue 708: OSBA decoder crash [main] Link #708 --- lib_com/options.h | 1 + lib_dec/ivas_sba_dec.c | 5 +++++ lib_enc/lib_enc.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 9fed7783e..b24ac8267 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,4 +171,5 @@ #define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ +#define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 65faabdc0..94f1affde 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -351,7 +351,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); test(); test(); +#ifdef NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH + test(); + IF( hSpar->hPCA == NULL && EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, PCA_BRATE ) && EQ_16( st_ivas->sba_order, 1 ) && ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) +#else IF( hSpar->hPCA == NULL && EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, PCA_BRATE ) && EQ_16( st_ivas->sba_order, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +#endif { IF( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) { diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 0475d65c4..6035687ed 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1095,7 +1095,11 @@ static ivas_error configureEncoder( } +#ifdef NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH + if ( hEncoderConfig->Opt_PCA_ON && !( ( hEncoderConfig->ivas_format == SBA_FORMAT || hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) +#else if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) +#endif { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); } -- GitLab From 6573454e89836ba3aef50719d36441e952cbc135 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 3 Mar 2025 11:31:31 +0100 Subject: [PATCH 232/329] update copyright header to 2025 --- apps/isar_post_rend.c | 2 +- lib_com/ivas_rotation_com.c | 2 +- lib_isar/isar_MSPred.c | 2 +- lib_isar/isar_NoiseGen.c | 2 +- lib_isar/isar_PerceptualModel.c | 2 +- lib_isar/isar_PredDecoder.c | 2 +- lib_isar/isar_PredEncoder.c | 2 +- lib_isar/isar_RMSEnvGrouping.c | 2 +- lib_isar/isar_cnst.h | 2 +- lib_isar/isar_lc3plus_common.c | 2 +- lib_isar/isar_lc3plus_common.h | 2 +- lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_dec.h | 2 +- lib_isar/isar_lc3plus_enc.c | 2 +- lib_isar/isar_lc3plus_enc.h | 2 +- lib_isar/isar_lc3plus_payload.c | 2 +- lib_isar/isar_lc3plus_payload.h | 2 +- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 2 +- lib_isar/isar_lcld_prot.h | 2 +- lib_isar/isar_lcld_rom_tables.c | 2 +- lib_isar/isar_lcld_rom_tables.h | 2 +- lib_isar/isar_prot.h | 2 +- lib_isar/isar_rom_post_rend.c | 2 +- lib_isar/isar_rom_post_rend.h | 2 +- lib_isar/isar_splitRend_lcld_dec.c | 2 +- lib_isar/isar_splitRend_lcld_enc.c | 2 +- lib_isar/isar_splitRendererPLC.c | 2 +- lib_isar/isar_splitRendererPost.c | 2 +- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/isar_splitRenderer_utils.c | 2 +- lib_isar/isar_stat.h | 2 +- lib_isar/lib_isar_post_rend.c | 2 +- lib_isar/lib_isar_post_rend.h | 2 +- lib_isar/lib_isar_pre_rend.c | 2 +- lib_isar/lib_isar_pre_rend.h | 2 +- lib_util/split_rend_bfi_file_reader.c | 2 +- lib_util/split_rend_bfi_file_reader.h | 2 +- lib_util/split_render_file_read_write.c | 2 +- lib_util/split_render_file_read_write.h | 2 +- 40 files changed, 40 insertions(+), 40 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 278503690..d9095054b 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index a6d7a8ae6..e6f1808e4 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_MSPred.c b/lib_isar/isar_MSPred.c index 4dea48a9b..1df47d695 100644 --- a/lib_isar/isar_MSPred.c +++ b/lib_isar/isar_MSPred.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c index a61f26fc2..b872e89c9 100644 --- a/lib_isar/isar_NoiseGen.c +++ b/lib_isar/isar_NoiseGen.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index 85864ae0d..ad3329500 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index eab82fe12..c55a88011 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 0fb2c05a5..85dc5f8f8 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 450356d02..3c40cb096 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 72ff5b892..046beabdc 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 32e30e97c..2e5a31cb6 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 08ffff60a..570609442 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 2aec77746..bad857764 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index 309ec4e06..5e297a407 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index bf76e2e59..2f9ab6f01 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h index a2bc10bfc..6d0f47030 100644 --- a/lib_isar/isar_lc3plus_enc.h +++ b/lib_isar/isar_lc3plus_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index fa47189ca..cd053978d 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h index 3af6757fa..c225c9159 100644 --- a/lib_isar/isar_lc3plus_payload.h +++ b/lib_isar/isar_lc3plus_payload.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 371aee854..682176a91 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 784f6f92e..b9c60b8d4 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index a37134857..fffeb6c5c 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_rom_tables.c b/lib_isar/isar_lcld_rom_tables.c index d101c0eac..3b35a3282 100644 --- a/lib_isar/isar_lcld_rom_tables.c +++ b/lib_isar/isar_lcld_rom_tables.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_lcld_rom_tables.h b/lib_isar/isar_lcld_rom_tables.h index 4f1e80583..19d40751f 100644 --- a/lib_isar/isar_lcld_rom_tables.h +++ b/lib_isar/isar_lcld_rom_tables.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 1f2009b66..82fbe631d 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index 13a786b16..99742bc4f 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h index 2bfac9140..b9acd75e1 100644 --- a/lib_isar/isar_rom_post_rend.h +++ b/lib_isar/isar_rom_post_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 98ca3d3ad..d275a0aff 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index 0f442a2f2..15ed27dfd 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 5266cfd6b..037c43048 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 82ac5558d..6f6af1484 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 6cb44b015..a766418d1 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 44b3822a7..fa51d44ef 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 171f82022..fec4a5d80 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 7cfd50e49..dd2884731 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index cc32086fa..ef437eaa3 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 3b19c1ad0..c44767404 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 928fb001d..a4d03e8a5 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 96b78972f..3fc633317 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h index 341ef3ed6..679c424a1 100644 --- a/lib_util/split_rend_bfi_file_reader.h +++ b/lib_util/split_rend_bfi_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 8a4dea8fd..e52f9fe86 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 1d6529ef2..bdda7e598 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other -- GitLab From 0e1ff48ee48f5d60918aa6f0d99489f8fa90fe8a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 19:09:04 +0530 Subject: [PATCH 233/329] Crash fixes for LTV encoder, ASAN/MSAN fixes --- lib_com/stat_com.h | 3 +- lib_com/tns_base.c | 2 + lib_enc/cod_tcx.c | 127 ++++++++++++++++++++++++---- lib_enc/ext_sig_ana_fx.c | 4 + lib_enc/igf_enc.c | 13 ++- lib_enc/ivas_core_pre_proc_front.c | 8 +- lib_enc/ivas_mct_core_enc.c | 4 + lib_enc/ivas_mct_enc_mct.c | 8 ++ lib_enc/ivas_stereo_mdct_core_enc.c | 9 +- lib_enc/prot_fx_enc.h | 10 ++- lib_enc/tcx_utils_enc_fx.c | 9 +- lib_enc/tns_base_enc_fx.c | 6 +- 12 files changed, 171 insertions(+), 32 deletions(-) diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index af097da84..9edc28c03 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -197,7 +197,8 @@ typedef struct TNS_filter_structure Word16 order; /* Filter order. */ Word16 coefIndex[TNS_MAX_FILTER_ORDER]; /* Quantized filter coefficients. */ Word16 predictionGain; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q7 */ - Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q23 */ + Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. predictionGain_e */ + Word16 predictionGain_e; /*Exponent for predictionGain32 */ Word16 avgSqrCoef; /* Average squared filter coefficient. E(0), Q15 */ } STnsFilter; diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index b5fd1f41f..515746bd5 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1204,6 +1204,8 @@ void ResetTnsData( STnsData *pTnsData ) move16(); pTnsFilter->predictionGain32 = ONE_IN_Q23; /*Q23*/ move32(); + pTnsFilter->predictionGain_e = PRED_GAIN_E; + move16(); pTnsFilter->avgSqrCoef = 0; move16(); pTnsFilter->filterType = TNS_FILTER_OFF; /*Q0*/ diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index d0d36b502..78fe246e3 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -74,8 +74,11 @@ void TNSAnalysisStereo_fx( TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; + move32(); + Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; + move16(); + Word16 sum_e = 0; move16(); - individual_decision[0] = 0; move16(); individual_decision[1] = 0; @@ -210,7 +213,9 @@ void TNSAnalysisStereo_fx( test(); IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; + Word32 maxPredGain_fx = -ONE_IN_Q31; + move32(); + Word16 maxPredGain_e = 0; move16(); sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; @@ -228,30 +233,74 @@ void TNSAnalysisStereo_fx( * both filters for the decision */ - meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 - maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 - + meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = meanPredictionGain_fx; + maxPredictionGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } + Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); + if ( flag_1 < 0 ) + { + flag_1 = 0; + move16(); + } test(); test(); test(); - IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && - GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && + flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + move32(); + move32(); + pFilter[0]->predictionGain_e = pFilter[1]->predictionGain_e = meanPredictionGain_e; /* more TNS filter sync at 48kbps */ + move16(); + move16(); + pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ move16(); move16(); } + flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); - IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && + IF( flag && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredGain_fx = meanPredictionGain_fx; + maxPredGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -454,10 +503,16 @@ void TNSAnalysisStereo_fx( move16(); } } + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -477,7 +532,15 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } @@ -515,7 +578,9 @@ void TNSAnalysisStereo_fx( IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 + Word32 maxPredGain_fx = -ONE_IN_Q31; // Q31 + move32(); + Word16 maxPredGain_e = 0; move16(); sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; @@ -526,9 +591,23 @@ void TNSAnalysisStereo_fx( pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); + IF ( flag < 0 ) + { + maxPredGain_fx = pFilter->predictionGain32; + move32(); + maxPredGain_e = pFilter->predictionGain_e; + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); - IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -600,9 +679,15 @@ void TNSAnalysisStereo_fx( sts[ch]->hTcxEnc->fUseTns[k] = 0; } move16(); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -617,7 +702,15 @@ void TNSAnalysisStereo_fx( move16(); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index fc4a1889a..c437be5be 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1372,7 +1372,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( st->igf ) { Word16 q_spectrum = sub( Q31, hTcxEnc->spectrum_e[frameno] ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); +#else + ProcessIGF_ivas_fx( st, N_MAX + L_MDCT_OVLP_MAX, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); +#endif } } } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 2c9f5a371..6ac6e6811 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -2577,7 +2577,10 @@ Word16 IGFEncWriteConcatenatedBitstream( *-------------------------------------------------------------------*/ void IGFEncApplyMono_ivas_fx( - Encoder_State *st, /* i : Encoder state */ + Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ +#endif const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ Word16 e_mdct, /* i : exponent of pMDCTspectrum */ @@ -2658,12 +2661,20 @@ void IGFEncApplyMono_ivas_fx( IF( pPowerSpectrumParameter_fx ) { +#ifndef MSAN_FIX FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) +#else + FOR( Word16 i = 0; i < powerSpectrum_len; i++ ) +#endif { common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, pPowerSpectrumParameter_exp[i] ); } +#ifndef MSAN_FIX FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) +#else + FOR( Word16 i = 0; i < powerSpectrum_len; i++ ) +#endif { common_pPowerSpectrum_fx[i] = L_shl( pPowerSpectrumParameter_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) ); move16(); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index e866dd146..b7a10a4f3 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -630,12 +630,6 @@ ivas_error pre_proc_front_ivas_fx( headroom = 2; move16(); - test(); - test(); - if ( ( st->bwidth == NB || st->max_bwidth == NB ) && GT_32( st->input_Fs, 8000 ) ) - { - headroom = add( headroom, 1 ); - } test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -731,7 +725,7 @@ ivas_error pre_proc_front_ivas_fx( shift = sub( norm_s( inp_max ), headroom ); Word16 Q_min; - shift = s_max( shift, 0 ); + shift = s_max( shift, -1 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max, L_Q_MEM, &Q_min ); *Q_new = s_min( shift, Q_min ); diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 7a5a83155..d11447c03 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -656,7 +656,11 @@ void ivas_mct_core_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#else + ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#endif st->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec ); st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index ae561c0d0..7e8547841 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -1118,7 +1118,11 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#else + ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#endif st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); move16(); @@ -1159,7 +1163,11 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#else + ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#endif st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); move16(); diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index e85c01db2..b43c8dfdb 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -676,8 +676,11 @@ void stereo_mdct_core_enc_fx( q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ - +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#else + ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#endif } } } @@ -718,7 +721,11 @@ void stereo_mdct_core_enc_fx( Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#else + ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#endif } } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 58da977a7..4d8b74380 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1250,7 +1250,10 @@ void AVQ_cod_lpc_fx( ); void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ + Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ +#endif Word32 *pMDCTSpectrum, /* i : MDCT spectrum */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ Word16 *q_spectrum, /* i/o: Q of spectrum */ @@ -3092,7 +3095,10 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | Word16 last_core_acelp /**< in: Q0 | indictaor if last frame was acelp coded */ ); -void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ +void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ +#endif const int16_t igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ Word16 e_mdct, /* i : exponent of pMDCTspectrum */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 27c8e6f5f..5e7ca7be8 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3783,7 +3783,10 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) * *---------------------------------------------------------------------*/ void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ + Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ +#endif Word32 *pMDCTSpectrum, /* i : MDCT spectrum (*q_spectrum) */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ Word16 *q_spectrum, /* i/o: Q of spectrum */ @@ -3830,7 +3833,11 @@ void ProcessIGF_ivas_fx( IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, *q_spectrum ) ); +#ifndef MSAN_FIX IGFEncApplyMono_ivas_fx( st, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); +#else + IGFEncApplyMono_ivas_fx( st, powerSpec_len, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); +#endif curr_order = 0; move16(); diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 452842e30..f1881a427 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -862,9 +862,11 @@ static void GetFilterParameters_ivas( Word32 rxx[], Word16 maxOrder, STnsFilter Word16 temp_e = 0; move16(); Word16 temp = BASOP_Util_Divide3232_Scale( rxx_0, L_tmp, &temp_e ); - pTnsFilter->predictionGain32 = L_shl( temp, ( sub( add( 16, temp_e ), PRED_GAIN_E ) ) ); // Q23 + pTnsFilter->predictionGain32 = L_deposit_h( temp ); move32(); - pTnsFilter->predictionGain = extract_h( pTnsFilter->predictionGain32 ); // Q7 + pTnsFilter->predictionGain_e = temp_e; + move16(); + pTnsFilter->predictionGain = shl_sat( temp, sub( temp_e, PRED_GAIN_E ) ); // Q7 move16(); BASOP_SATURATE_WARNING_ON_EVS /* non-linear quantization of TNS lattice coefficients with given resolution */ -- GitLab From 584e1f745784ba714a23de577eee39e0a7edf542 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 19:16:30 +0530 Subject: [PATCH 234/329] Clang formatting changes --- lib_enc/cod_tcx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 78fe246e3..88e028c86 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -593,7 +593,7 @@ void TNSAnalysisStereo_fx( // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF ( flag < 0 ) + IF( flag < 0 ) { maxPredGain_fx = pFilter->predictionGain32; move32(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4d8b74380..2e151df8f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1252,7 +1252,7 @@ void AVQ_cod_lpc_fx( void ProcessIGF_ivas_fx( Encoder_State *st, /* i : Encoder state */ #ifdef MSAN_FIX - Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ #endif Word32 *pMDCTSpectrum, /* i : MDCT spectrum */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ -- GitLab From 3a1f5fa87f739f3cb38d61146d2817d6118471f6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 28 Feb 2025 19:20:51 +0530 Subject: [PATCH 235/329] Fix for 3GPP issue 1311: BASOP encoder for 80kbps Stereo does not trigger dtx when it should Link #1311 --- lib_enc/dtx_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index a1478d3f8..be4368f69 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -35,7 +35,7 @@ #endif #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ -#define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ +#define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ /*-------------------------------------------------------------------* * Local function prototypes @@ -107,7 +107,7 @@ void dtx_ivas_fx( test(); test(); test(); - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); test(); test(); @@ -118,7 +118,7 @@ void dtx_ivas_fx( ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); #else - last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); + last_br_flag = LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_IVAS ) ); br_dtx_flag = 0; move16(); #endif @@ -135,7 +135,7 @@ void dtx_ivas_fx( test(); test(); test(); - if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && NE_16( st_fx->element_mode, IVAS_SCE ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { st_fx->cng_type = LP_CNG; move16(); @@ -254,8 +254,6 @@ void dtx_ivas_fx( { st_fx->last_total_brate_cng = -1; move16(); - st_fx->last_rf_mode_cng = st_fx->rf_mode; - move16(); } ELSE { @@ -265,6 +263,8 @@ void dtx_ivas_fx( move16(); st_fx->last_codec_mode_cng = st_fx->codec_mode; move16(); + st_fx->last_rf_mode_cng = st_fx->rf_mode; + move16(); } IF( hDtxEnc->cnt_SID == 0 ) @@ -321,7 +321,7 @@ void dtx_ivas_fx( test(); test(); test(); - IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ + IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ { test(); test(); -- GitLab From 7edb193c68a1c0c4ce8f9da3c5846c2d171e66fc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 22:40:28 +0530 Subject: [PATCH 236/329] Fix for 3GPP issue 1256: Usage of NS2SA()-macro on variables Link #1256 --- lib_com/core_com_config.c | 4 +-- lib_com/ivas_fb_mixer.c | 6 ++-- lib_com/tcx_ltp_fx.c | 2 +- lib_com/window_ola_fx.c | 6 ++-- lib_dec/FEC_HQ_phase_ecu_fx.c | 30 +++++++++--------- lib_dec/acelp_core_dec_ivas_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 2 +- lib_dec/core_switching_dec.c | 8 ++--- lib_dec/core_switching_dec_fx.c | 4 +-- lib_dec/evs_dec_fx.c | 16 +++++----- lib_dec/fd_cng_dec_fx.c | 8 ++--- lib_dec/init_dec_fx.c | 4 +-- lib_dec/ivas_core_dec.c | 8 ++--- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_init_dec.c | 4 +-- lib_dec/ivas_ism_param_dec.c | 1 - lib_dec/ivas_jbm_dec.c | 26 +++++++-------- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_mc_param_dec.c | 8 ++--- lib_dec/ivas_mc_paramupmix_dec.c | 2 +- lib_dec/ivas_mct_dec.c | 10 +++--- lib_dec/ivas_mdct_core_dec.c | 4 +-- lib_dec/ivas_post_proc.c | 24 +++++++------- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec.c | 2 +- lib_dec/ivas_stereo_dft_dec_dmx.c | 4 +-- lib_dec/ivas_stereo_dft_dec_fx.c | 4 +-- lib_dec/ivas_stereo_ica_dec.c | 12 +++---- lib_dec/ivas_stereo_icbwe_dec.c | 28 ++++++++-------- lib_dec/ivas_stereo_mdct_stereo_dec.c | 4 +-- lib_dec/ivas_stereo_switching_dec.c | 12 +++---- lib_dec/ivas_stereo_td_dec.c | 8 ++--- lib_dec/swb_bwe_dec.c | 2 +- lib_dec/swb_bwe_dec_fx.c | 2 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/core_enc_init_fx.c | 2 +- lib_enc/core_switching_enc_fx.c | 4 +-- lib_enc/fd_cng_enc_fx.c | 4 +-- lib_enc/hq_core_enc.c | 2 +- lib_enc/init_enc.c | 2 +- lib_enc/init_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc.c | 24 +++++++------- lib_enc/ivas_core_pre_proc_front.c | 8 ++--- lib_enc/ivas_corecoder_enc_reconfig.c | 2 +- lib_enc/ivas_cpe_enc.c | 6 ++-- lib_enc/ivas_front_vad.c | 2 +- lib_enc/ivas_lfe_enc.c | 4 +-- lib_enc/ivas_mc_paramupmix_enc.c | 4 +-- lib_enc/ivas_mcmasa_enc.c | 16 +++++----- lib_enc/ivas_osba_enc.c | 4 +-- lib_enc/ivas_stereo_ica_enc.c | 10 +++--- lib_enc/ivas_stereo_switching_enc.c | 6 ++-- lib_enc/lib_enc.c | 2 +- lib_enc/swb_bwe_enc_fx.c | 28 ++++++++-------- lib_enc/swb_pre_proc_fx.c | 44 +++++++++++++------------- lib_enc/swb_tbe_enc_fx.c | 8 ++--- 57 files changed, 225 insertions(+), 226 deletions(-) diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 8d360c6a3..fdf935461 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -1235,8 +1235,8 @@ void init_tcx_window_cfg_fx( } /*Mid-OLA*/ /*compute minimum length for "half" window: lookahead - 5ms. It must be also multiple of 2*/ - hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_FX2( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); /*Q0*/ - hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_FX2( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); /*Q0*/ + hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); /*Q0*/ + hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); /*Q0*/ move16(); move16(); assert( GT_16( hTcxCfg->tcx_mdct_window_half_length, 16 ) && "Half window can not be large enough!" ); diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 498de0188..43f468fb0 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1289,7 +1289,7 @@ static ivas_error ivas_filterbank_setup_fx( ivas_get_active_bins_fx( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - IF( EQ_16( pCfg->fb_latency, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) ) + IF( EQ_16( pCfg->fb_latency, NS2SA_FX2( sampling_rate, DELAY_FB_1_NS ) ) ) { pAll_fb_fr_fx[0] = ivas_fb_fr_12band_1ms_re_fx; // Q30 move32(); @@ -1478,7 +1478,7 @@ static ivas_error ivas_fb_mixer_get_window_fx( error = IVAS_ERR_OK; move32(); - IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_4_NS ) ) ) + IF( EQ_16( fade_len, NS2SA_FX2( sampling_rate, DELAY_FB_4_NS ) ) ) { SWITCH( sampling_rate ) { @@ -1495,7 +1495,7 @@ static ivas_error ivas_fb_mixer_get_window_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" ); } } - ELSE IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) ) + ELSE IF( EQ_16( fade_len, NS2SA_FX2( sampling_rate, DELAY_FB_1_NS ) ) ) { SWITCH( sampling_rate ) { diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index 55228e0b3..9d7cb9254 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -1282,7 +1282,7 @@ void tcx_ltp_post( filtIdx = 0; /* just to avoid comilation warnings */ move16(); - tcx_buf_len = NS2SA( st->output_Fs, TCXLTP_DELAY_NS ); /* Q0 */ + tcx_buf_len = NS2SA_FX2( st->output_Fs, TCXLTP_DELAY_NS ); /* Q0 */ SideInfoOnly = 0; move16(); if ( GE_32( total_brate, HQ_96k ) ) diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index 19725735a..2948e725e 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -833,13 +833,13 @@ void core_switching_OLA_fx( IF( ( output_frame - L_FRAME16k ) == 0 ) /* no resampling */ { - Copy( mem_over_hp + 2, tmp_buf_switch + i_mult2( SWITCH_GAP_LENGTH_8k, delta ), NS2SA( output_Fs, DELAY_CLDFB_NS ) ); + Copy( mem_over_hp + 2, tmp_buf_switch + i_mult2( SWITCH_GAP_LENGTH_8k, delta ), NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) ); } ELSE { IF( ( output_frame - L_FRAME8k ) == 0 ) /* not done yet */ { - Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */ + Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */ } ELSE { @@ -950,7 +950,7 @@ void core_switching_OLA_fx( pt = synth; pt2 = tmp_buf_switch; - tmp = NS2SA( output_Fs, DELAY_CLDFB_NS ); + tmp = NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ); move16(); pt3 = synth_subfr_bwe; diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 708fc39e6..dd63b6508 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2156,7 +2156,7 @@ static void ivas_subst_spec_fx( ELSE { // tmp = NS2SA(output_frame*50,PH_ECU_ALDO_OLP2_NS-PH_ECU_LOOKAHEAD_NS); - tmp = NS2SA_FX2( output_frame * 50, PH_ECU_ALDO_OLP2_NS ); + tmp = NS2SA_FX2( L_mult0( output_frame, 50 ), PH_ECU_ALDO_OLP2_NS ); move16(); tmp = sub( tmp, ph_ecu_lookahead ); tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) ); @@ -2559,7 +2559,7 @@ static void subst_spec_fx( } ELSE { - tmp = NS2SA( output_frame * 50, PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS ); + tmp = NS2SA_FX2( L_mult0( output_frame, 50 ), PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS ); move16(); tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) ); tmp = sub( tmp, shr( output_frame, 1 ) ); @@ -2920,9 +2920,9 @@ static void ivas_rec_wtda_fx( Word16 copy_len; Word16 ola_len; - copy_len = NS2SA( output_frame * FRAMES_PER_SEC, ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */ + copy_len = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */ move16(); - ola_len = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */ + ola_len = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */ move16(); xf_len = 26; @@ -2980,7 +2980,7 @@ static void ivas_rec_wtda_fx( } /* extract reconstructed frame with aldo window */ - timesh = sub( NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) ); + timesh = sub( NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) ); set16_fx( xsubst_, 0, add( sub( shl( output_frame, 1 ), Lprot ), timesh ) ); Copy( X, xsubst_ + add( sub( shl( output_frame, 1 ), Lprot ), timesh ), sub( Lprot, timesh ) ); @@ -2988,9 +2988,9 @@ static void ivas_rec_wtda_fx( /* Copy and OLA look ahead zero part of MDCT window from decoded signal */ IF( element_mode != EVS_MONO ) { - Copy( old_dec, xsubst_ + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */ + Copy( old_dec, xsubst_ + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */ pOld = old_dec + copy_len; - pNew = xsubst_ + add( copy_len, NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) ); + pNew = xsubst_ + add( copy_len, NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ) ); tmp = div_s( 1, shl( ola_len, 1 ) ); // Q15 tmp = round_fx( L_shl( L_mult( tmp, EVS_PI_FX ), 2 ) ); // Q15 sinq_fx( tmp, 0, ola_len, xfwin ); @@ -4583,7 +4583,7 @@ static void ivas_fec_noise_filling_fx( } ELSE { - kk = NS2SA( L * FRAMES_PER_SEC, N_ZERO_MDCT_NS ); + kk = NS2SA_FX2( L_mult0( L, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ); p_mdct_ola = old_out + kk; } @@ -4939,7 +4939,7 @@ static void ivas_hq_phase_ecu_fx( IF( element_mode == EVS_MONO ) { - ph_ecu_lookahead = NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ); + ph_ecu_lookahead = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ); move16(); } ELSE @@ -5018,7 +5018,7 @@ static void ivas_hq_phase_ecu_fx( alpha, beta, *beta_mute, Xavg, element_mode, ph_ecu_lookahead, noise_fac ); /* reconstructed frame in tda domain */ - old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) ); + old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ) ); ivas_rec_frame_fx( X, ecu_rec, output_frame, *Q_spec, old_dec, element_mode, num_p, plocs ); *last_fec = 0; @@ -5223,11 +5223,11 @@ void ivas_hq_ecu_fx( move16(); IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - fec_alg_input = prevsynth + NS2SA( output_frame * FRAMES_PER_SEC, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ); + fec_alg_input = prevsynth + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ); } ELSE { - fec_alg_input = prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ); + fec_alg_input = prevsynth - NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ); } /* init (values ar changed after) */ @@ -5286,7 +5286,7 @@ void ivas_hq_ecu_fx( } ELSE { - ivas_hq_phase_ecu_fx( prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, Q_spec, num_p, plocs, plocsi, + ivas_hq_phase_ecu_fx( prevsynth - NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, Q_spec, num_p, plocs, plocsi, env_stab, last_fec, ph_ecu_active, prev_bfi, old_is_transient, mag_chg_1st, Xavg, beta_mute, st_fx->bwidth, output_frame, corr, st_fx->element_mode ); @@ -5354,7 +5354,7 @@ void hq_ecu_fx( #ifdef IVAS_FEC_ECU_TO_COMPLETE fec_ecu_pitch_fx( fec_alg_input, prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing ); #else - fec_ecu_pitch_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing ); + fec_ecu_pitch_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing ); #endif } ELSE @@ -5409,7 +5409,7 @@ void hq_ecu_fx( ( LT_32( st_fx->total_brate, 48000 ) && ( ( ph_ecu_HqVoicing || GT_16( corr, 27853 ) ) && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) ) ) ) { - fec_alg_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth ); + fec_alg_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth ); *last_fec = 1; move16(); *ph_ecu_active = 0; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 42e4e36ef..6e56bc154 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -2101,7 +2101,7 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); #ifdef MSAN_FIX Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 387533957..f1772b9a7 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -242,7 +242,7 @@ ivas_error acelp_core_switch_dec_fx( *Q_syn = 0; move16(); - Copy_Scale_sig( synth_intFreq + sub( NS2SA( i_mult( L_frame_for_cs, 50 ), ( SWITCH_GAP_LENGTH_NS - DELAY_CLDFB_NS ) ), 2 ), mem_synth, add( NS2SA( i_mult( L_frame_for_cs, 50 ), DELAY_CLDFB_NS ), 2 ), negate( st_fx->Q_syn ) ); /* Copy mem with Q0 */ + Copy_Scale_sig( synth_intFreq + sub( NS2SA_FX2( i_mult( L_frame_for_cs, 50 ), ( SWITCH_GAP_LENGTH_NS - DELAY_CLDFB_NS ) ), 2 ), mem_synth, add( NS2SA_FX2( i_mult( L_frame_for_cs, 50 ), DELAY_CLDFB_NS ), 2 ), negate( st_fx->Q_syn ) ); /* Copy mem with Q0 */ /*----------------------------------------------------------------* * BWE decoding diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 4c48a6fa8..aa04a70cb 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -110,11 +110,11 @@ ivas_error core_switching_pre_dec_ivas_fx( /* reset old HB synthesis buffer */ IF( EQ_16( st->last_L_frame, L_FRAME ) ) { - st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); + st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); } ELSE { - st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); } move16(); set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); @@ -189,7 +189,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_core = HQ_CORE; move16(); - Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 } @@ -221,7 +221,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); } - delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); /*TODO To be tested:control not entering the block*/ test(); test(); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 17df8b5ca..d654b3af4 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1765,7 +1765,7 @@ ivas_error core_switching_post_dec_ivas_fx( Copy_Scale_sig( st_fx->previoussynth_fx, synth, delay_comp, *Qsynth ); /* Qsynth */ /* Overlap between TCX-LB and TCX-FB*/ - Word16 tmpDelta = NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ); + Word16 tmpDelta = NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ); Word32 L_tmp2; FOR( i = 0; i < tmpDelta; i++ ) { @@ -1924,7 +1924,7 @@ ivas_error core_switching_post_dec_ivas_fx( } IF( output_mem_fx != NULL ) { - Scale_sig( output_mem_fx, NS2SA( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ } *Qsynth = Qtmp; move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index de6448433..945e149f2 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -919,7 +919,7 @@ ivas_error evs_dec_fx( IF( ( EQ_16( st_fx->bwidth, SWB ) || EQ_16( st_fx->bwidth, FB ) ) && ( ( EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) { - GenTransition_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx, + GenTransition_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, shl( NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), 1 ), hb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->mem_resamp_HB_32k_fx, &( hBWE_TD->syn_dm_phase ), st_fx->output_Fs, hBWE_TD->int_3_over_2_tbemem_dec_fx, st_fx->rf_flag, st_fx->total_brate ); @@ -929,7 +929,7 @@ ivas_error evs_dec_fx( } ELSE IF( EQ_16( st_fx->bwidth, WB ) && EQ_16( st_fx->last_extl, WB_TBE ) ) { - GenTransition_WB_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, st_fx->prev_Qx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx, + GenTransition_WB_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, st_fx->prev_Qx, shl( NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), 1 ), hb_synth_fx, hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, st_fx->output_Fs, hBWE_TD->mem_resamp_HB_fx ); hb_synth_fx_exp = st_fx->prev_Qx; @@ -1327,12 +1327,12 @@ ivas_error evs_dec_fx( { IF( EQ_32( st_fx->output_Fs, 8000 ) ) { - Copy( hTcxDec->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*st_fx->q_prev_synth_buffer_fx*/ + Copy( hTcxDec->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*st_fx->q_prev_synth_buffer_fx*/ } ELSE { - Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /*st_fx->Qprev_synth_buffer_fx*/ - Copy( hTcxDec->FBTCXdelayBuf + NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st_fx->delay_buf_out_fx, NS2SA( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*Q0*/ + Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /*st_fx->Qprev_synth_buffer_fx*/ + Copy( hTcxDec->FBTCXdelayBuf + NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st_fx->delay_buf_out_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*Q0*/ } } } @@ -1362,7 +1362,7 @@ ivas_error evs_dec_fx( Scale_sig( output_sp, output_frame, timeIn_e ); /*timeIn_e*/ - tcx_ltp_post( st_fx, hTcxLtpDec, st_fx->core, output_frame /*hTcxDec->L_frameTCX*/, NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS ) + tmps, + tcx_ltp_post( st_fx, hTcxLtpDec, st_fx->core, output_frame /*hTcxDec->L_frameTCX*/, add( NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS ), tmps ), output_sp, hTcxDec->FBTCXdelayBuf ); Copy( output_sp, synth_fx, output_frame ); /*timeIn_e*/ @@ -1397,8 +1397,8 @@ ivas_error evs_dec_fx( ELSE { - Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/ - Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ) - NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/ + Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/ + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/ } } } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index fa7e602a5..8a902448f 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3621,9 +3621,9 @@ void generate_comfort_noise_dec_fx( IF( st->hTcxCfg->last_aldo != 0 ) { - FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ ) + FOR( i = 0; i < hFdCngCom->frameSize - NS2SA( st->sr_core, N_ZERO_MDCT_NS ); i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ move16(); } } @@ -4160,9 +4160,9 @@ void generate_comfort_noise_dec_ivas_fx( IF( st->hTcxCfg->last_aldo != 0 ) { - FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ ) + FOR( i = 0; i < hFdCngCom->frameSize - NS2SA( st->sr_core, N_ZERO_MDCT_NS ); i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ move16(); } } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index d709ff5fc..a96774113 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -493,8 +493,8 @@ ivas_error init_decoder_fx( set16_fx( st_fx->hTcxDec->FBTCXdelayBuf, 0, 111 ); - st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA( st_fx->output_Fs, PH_ECU_MEM_NS ); - st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); + st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); + st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); } ELSE { diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 92b43092b..261a3c74e 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1639,15 +1639,15 @@ ivas_error ivas_core_dec_fx( move16(); move16(); - Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -( Q11 ) ); // Q0 + Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -( Q11 ) ); // Q0 st->q_prev_synth_buffer_fx = 0; move16(); exp_ouput = Find_Max_Norm32( output_32_fx[n], output_frame ); exp_ouput = add( exp_ouput, Q11 ); - exp_prev_synth_buffer = Find_Max_Norm16( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + exp_prev_synth_buffer = Find_Max_Norm16( st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); exp_prev_synth_buffer = add( exp_prev_synth_buffer, st->q_prev_synth_buffer_fx ); - exp_old_out = Find_Max_Norm16( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( add( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ), NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ) ); + exp_old_out = Find_Max_Norm16( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( add( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ), NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ) ); exp_delay_buf_out = Find_Max_Norm16( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); exp_synth_history = Find_Max_Norm16( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ) ); exp_max = s_min( exp_synth_history, exp_ouput ); @@ -1660,7 +1660,7 @@ ivas_error ivas_core_dec_fx( Scale_sig32( output_fx_loc, output_frame, sub( exp_max, Q11 ) ); // Q(31-exp_max) Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), exp_max ); // exp_max Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ), exp_max ); // Q(31-exp_max) - Scale_sig( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, L_sub( DELAY_BWE_TOTAL_NS, DELAY_CLDFB_NS ) ), sub( exp_max, st->q_prev_synth_buffer_fx ) ); // Q(exp_max - prev_synth_buffer_fx) + Scale_sig( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), sub( exp_max, st->q_prev_synth_buffer_fx ) ); // Q(exp_max - prev_synth_buffer_fx) Scale_sig( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ), sub( exp_max, 0 ) ); // Q(31-exp_max) st->q_prev_synth_buffer_fx = sub( exp_max, st->q_prev_synth_buffer_fx ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 7d2f7be4f..9849647ea 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2093,7 +2093,7 @@ void ivas_dirac_dec_render_fx( output_f_local_fx[ch] = output_f_local_buff_fx[ch]; set_zero_fx( output_f_local_fx[ch], nSamplesAsked ); } - slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL + slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 73e2b5d01..037ef4eb9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2034,7 +2034,7 @@ ivas_error ivas_init_decoder_fx( } } - granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2333,7 +2333,7 @@ ivas_error ivas_init_decoder_fx( /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 1f7af935d..424e6fb86 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -797,7 +797,6 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { - move16(); // NS2SA IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5317e803e..3b66d3107 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -431,8 +431,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) { @@ -522,7 +522,7 @@ ivas_error ivas_jbm_dec_tc_fx( #ifdef MSAN_FIX FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), hCPE->q_prev_synth_fx - 11 ); // q_prev_synth_fx + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx } #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); @@ -537,7 +537,7 @@ ivas_error ivas_jbm_dec_tc_fx( #ifdef MSAN_FIX FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); @@ -968,8 +968,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) { @@ -1008,7 +1008,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, 11 ) ); // q_prev_synth_fx + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); #endif @@ -1028,8 +1028,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 } IF( hCPE->hCoreCoder[0] != NULL ) @@ -1427,8 +1427,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) @@ -1473,7 +1473,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, 11 ) ); // q_prev_synth_fx + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); #endif @@ -1484,7 +1484,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); #endif // MSAN_FIX diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index aa42f4f91..4ca5c05b0 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -836,7 +836,7 @@ ivas_error ivas_masa_dec_open_fx( nchan_to_allocate = add( nchan_to_allocate, 1 ); } - IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 50d03b577..459dcc4d4 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -534,7 +534,7 @@ ivas_error ivas_param_mc_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -1941,10 +1941,10 @@ void ivas_param_mc_dec_render_fx( /*slots_to_render = min(sub(hParamMC->num_slots, hParamMC->slots_rendered), nSamplesAsked / NS2SA(output_Fs, CLDFB_SLOT_NS)); *nSamplesRendered = slots_to_render * NS2SA(output_Fs, CLDFB_SLOT_NS);*/ Word16 temp_e; - Word16 temp = BASOP_Util_Divide1616_Scale( nSamplesAsked, NS2SA( output_Fs, CLDFB_SLOT_NS ), &temp_e ); + Word16 temp = BASOP_Util_Divide1616_Scale( nSamplesAsked, NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ), &temp_e ); temp = shr( temp, sub( 15, temp_e ) ); slots_to_render = s_min( sub( hParamMC->num_slots, hParamMC->slots_rendered ), temp ); - *nSamplesRendered = imult1616( slots_to_render, NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + *nSamplesRendered = imult1616( slots_to_render, NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ) ); move16(); Word16 j, k; first_sf = hParamMC->subframes_rendered; @@ -2272,7 +2272,7 @@ void ivas_param_mc_dec_render_fx( hParamMC->subframes_rendered = last_sf; move16(); - *nSamplesAvailableNext = imult1616( sub( hParamMC->num_slots, hParamMC->slots_rendered ), NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + *nSamplesAvailableNext = imult1616( sub( hParamMC->num_slots, hParamMC->slots_rendered ), NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ) ); move16(); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index b12236746..be53d79c8 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -418,7 +418,7 @@ ivas_error ivas_mc_paramupmix_dec_open( move16(); } - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a92f21f6d..c95a5285a 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -430,11 +430,11 @@ ivas_error ivas_mct_dec_fx( Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { - Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA( sts[n]->output_Fs, 3125000 ), -Q11 ); + Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA_FX2( sts[n]->output_Fs, 3125000 ), -Q11 ); } ELSE { - set16_fx( output_mem_fx, 0, NS2SA( sts[n]->output_Fs, 3125000 ) ); + set16_fx( output_mem_fx, 0, NS2SA_FX2( sts[n]->output_Fs, 3125000 ) ); } Word16 Q_synth = sub( 15, e_sig[n] ); @@ -461,9 +461,9 @@ ivas_error ivas_mct_dec_fx( #endif /* Save synthesis for HQ FEC */ Word32 output_fx_[L_FRAME48k]; - Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 - Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); // Q11 -> Q16 - Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); // Q11 -> Q0 + Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 + Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); // Q11 -> Q16 + Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -Q11 ); // Q11 -> Q0 sts[n]->q_prev_synth_buffer_fx = 0; move16(); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 2158dec1c..190cc6b14 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1361,7 +1361,7 @@ void ivas_mdct_core_reconstruct_fx( /* Update */ Copy( synth_buf_fx + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); - Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); + Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ); Copy( synth_bufFB_fx + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB ); st->hTcxDec->q_old_synth = q_syn; st->hTcxDec->q_synth_history_fx = st->hTcxDec->q_old_synth; @@ -1371,7 +1371,7 @@ void ivas_mdct_core_reconstruct_fx( IF( st->hHQ_core != NULL ) { - Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); } Copy( st->lsp_q_cng, st->old_lsp_q_cng, M ); diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index dc4a1b01b..853aa365f 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -159,7 +159,7 @@ void ivas_post_proc_fx( ELSE { /*Use channel 0 side info.*/ - tcx_ltp_post32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k], output_q ); + tcx_ltp_post32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k], output_q ); } } } @@ -268,7 +268,7 @@ void stereo_dft_dec_core_switching_fx( IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( sba_dirac_stereo_dtx_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { /* In case of a TCX to ACELP switch next frame */ - Copy32( &output_fx[st->L_frame - NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ + Copy32( &output_fx[st->L_frame - NS2SA( ( st->L_frame * FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ /* BPF */ test(); @@ -315,8 +315,8 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = - L_add( hCPE->input_mem_fx[0][NS2SA_FX2( L_add( L_sub( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )], hb_synth_fx[i] ); /*Q11*/ + hCPE->input_mem_fx[0][( ( NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = + L_add( hCPE->input_mem_fx[0][NS2SA( ( ( L_frameTCX * FRAMES_PER_SEC ) - STEREO_DFT32MS_OVL_NS ) + delay_tdbwe, i )], hb_synth_fx[i] ); /*Q11*/ move32(); } } @@ -325,7 +325,7 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = hb_synth_fx[i]; /*Q11*/ + hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = hb_synth_fx[i]; /*Q11*/ move32(); } } @@ -368,7 +368,7 @@ void stereo_dft_dec_core_switching_fx( /* In case of TCX frames, output LB TCX is zeroed out until the end but in case of an TCX->ACELP switch, this memory is needed, hence it is backed up */ /* Unlike the case when DFT32MS is disabled, there is only 1 DFT analysis window, hence in the TCX frame we don't want to do a DFT analysis FOR LB TCX but in a potential ACELP frame, we want the memories of the LB TCX FOR the last OLA samples so that HB analysis can be skipped */ - Copy32( &output_fx[st->L_frame - NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ + Copy32( &output_fx[st->L_frame - NS2SA_FX2( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ /*zero the rest FOR avoiding adding contribution except the last samples which are not considered in DFT analysis (potentially used in next ACELP frame)*/ IF( GT_32( st->last_core_brate, SID_2k40 ) ) @@ -418,8 +418,8 @@ void stereo_dft_dec_core_switching_fx( delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); /*Q0*/ move16(); - Copy32( &st->hHQ_core->oldOut_fx[( nZeros - ( delay_comp + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ) )], hCPE->input_mem_fx[0], NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*Q11*/ - Copy32( synth_fx, synth_tmp_fx, output_frame ); /*q*/ + Copy32( &st->hHQ_core->oldOut_fx[nZeros - ( delay_comp + NS2SA( output_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) )], hCPE->input_mem_fx[0], NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*Q11*/ + Copy32( synth_fx, synth_tmp_fx, output_frame ); /*q*/ Word16 mem_len; mem_len = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /*Q0*/ @@ -462,11 +462,11 @@ void stereo_dft_dec_core_switching_fx( Word32 delay_dft_dec_lb_inv = (Word32) ( calc_inv / delay_dft_dec_lb ); FOR( i = 0; i < delay_dft_dec_lb; i++ ) { - hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = - Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], L_shl( i, qdelay_dft_dec_lb ) ); /*Q11 + qdelay_dft_dec_lb -31*/ + hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = + Mpy_32_32( hCPE->input_mem_LB_fx[0][( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i], L_shl( i, qdelay_dft_dec_lb ) ); /*Q11 + qdelay_dft_dec_lb -31*/ move32(); - hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = - L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); /*Q11*/ + hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = + L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); /*Q11*/ move32(); } stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 94f1affde..417079541 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -223,7 +223,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } /* determine new granularity */ - granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ + granularity_new = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); /* this will change anyway only with binaural */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 12a34e170..573a9c17f 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1293,7 +1293,7 @@ void ivas_sba_dirac_stereo_dec_fx( sba_mono_flag = (Word16) EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ); move16(); - memOffset = NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); + memOffset = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); move16(); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 5449521d6..b0100063a 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -289,7 +289,7 @@ void stereo_dft_dec_analyze_fx( move16(); /* Offset FOR the time buffers */ - assert( ( delay >= -NS2SA_FX2( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA_FX2( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_OVL_NS ) ) ); + assert( ( delay >= -NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_OVL_NS ) ) ); mem_size = add( delay_dec, delay ); /* Update buffers */ diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index 99cea064b..0db9ab09f 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -61,8 +61,8 @@ void stereo_dft_dmx_out_reset_fx( hStereoDftDmx->prevTargetGain_fx = ONE_IN_Q29; /* Q29 */ move32(); - set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA_FX2( 48000, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA_FX2( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); return; } diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index b76bddbbc..ca4cfdb69 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -99,7 +99,7 @@ void stereo_dft_dec_reset_fx( Word16 i; Word16 j, b; #ifdef MSAN_FIX - set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ) ); + set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); #endif /*Configuration*/ @@ -1360,7 +1360,7 @@ void stereo_dft_dec_res_fx( set32_fx( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); - set32_fx( hCPE->input_mem_fx[1], 0, NS2SA_FX2( 8000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_fx[1], 0, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) ); set16_fx( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k ); hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; move16(); diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index b72e66c5f..08ac60ffc 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -126,7 +126,7 @@ void stereo_tca_dec_fx( dsFactor = BASOP_Util_Divide3232_Scale( output_Fs, 8000, &exp_ds ); dsFactor = shr( dsFactor, sub( 15, exp_ds ) ); /* Q0 */ - tempMax = NS2SA( output_Fs, L_NCSHIFT_NS ); /* Q0 */ + tempMax = NS2SA_FX2( output_Fs, L_NCSHIFT_NS ); /* Q0 */ hStereoTCA->corrLagStats = s_min( hStereoTCA->indx_ica_NCShift * dsFactor, tempMax ); /* Q0 */ bothChannelShift = 0; @@ -343,14 +343,14 @@ void stereo_tca_scale_R_channel_fx( return; } /* Scale the Right channel with the gain */ - l_ica_ovl = NS2SA( output_Fs, STEREO_L_TCA_OVLP_NS ); /* Q0 */ + l_ica_ovl = NS2SA_FX2( output_Fs, STEREO_L_TCA_OVLP_NS ); /* Q0 */ move16(); test(); IF( EQ_16( hCPE->nchan_out, 1 ) ) { /* in mono DMX, the scaling is done before synchro_synthesis() */ - flat_old = NS2SA( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); /* Q0 */ move16(); test(); @@ -365,18 +365,18 @@ void stereo_tca_scale_R_channel_fx( hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */ move32(); - flat_old = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ move16(); } } ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - flat_old = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ move16(); } ELSE { - flat_old = NS2SA( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS ); /* Q0 */ move16(); } diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 6bba90feb..b634d4557 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -339,7 +339,7 @@ void stereo_icBWE_dec_fx( move32(); alpha_fx = add_sat( alpha_fx, winSlope_fx ); /* Q15 */ } - FOR( ; i < NS2SA( st->output_Fs, FRAME_SIZE_NS ); i++ ) + FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) { synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], icbweM2Ref_fx ); // Qsyth - 1 move32(); @@ -766,7 +766,7 @@ void stereo_icBWE_dec_fx( alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */ } } - FOR( ; i < NS2SA( st->output_Fs, FRAME_SIZE_NS ); i++ ) + FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) { synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], icbweM2Ref_fx ); /* Qsyn - 1 */ move32(); @@ -933,7 +933,7 @@ void stereo_icBWE_dec_fx( } } - FOR( ; i < NS2SA( st->output_Fs, FRAME_SIZE_NS ); i++ ) + FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) { synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], icbweM2Ref_fx ); /* Qsyn - 1 */ move32(); @@ -1015,7 +1015,7 @@ void stereo_icBWE_decproc_fx( output_Fs = hCPE->hCoreCoder[0]->output_Fs; /* Q0 */ move32(); - memOffset = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); /* Q0 */ + memOffset = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); /* Q0 */ /* LRTD stereo mode - 2xBWEs used */ test(); @@ -1070,8 +1070,8 @@ void stereo_icBWE_decproc_fx( set32_fx( hStereoICBWE->memOutHB_fx[0], 0, memOffset ); set32_fx( hStereoICBWE->memOutHB_fx[1], 0, memOffset ); - set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } test(); @@ -1123,13 +1123,13 @@ void stereo_icBWE_decproc_fx( Copy32( outputHB[refChanIndx_bwe], temp0_fx + memOffset, sub( output_frame, memOffset ) ); /* Q11 */ Copy32( outputHB[!refChanIndx_bwe], temp1_fx + memOffset, sub( output_frame, memOffset ) ); /* Q11 */ - decoderDelay = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ + decoderDelay = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ test(); IF( last_core != ACELP_CORE && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { /* hb_synth of mid band is faded out in the 1.25 ms prior to DFT analysis and the icbwe is faded in time domain */ - icbweOLASize = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); /* Q0 */ + icbweOLASize = NS2SA_FX2( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); /* Q0 */ FOR( i = 0; i < decoderDelay; i++ ) { @@ -1286,15 +1286,15 @@ void stereo_icBWE_decproc_fx( ELSE { /* This is generated in the ACELP frame and windowed. This process is akin to GenTransition for IC-BWE */ - v_add_32( output[0], hStereoICBWE->memTransitionHB_fx[hStereoICBWE->prev_refChanIndx_bwe], output[0], NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - v_add_32( output[1], hStereoICBWE->memTransitionHB_fx[!hStereoICBWE->prev_refChanIndx_bwe], output[1], NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + v_add_32( output[0], hStereoICBWE->memTransitionHB_fx[hStereoICBWE->prev_refChanIndx_bwe], output[0], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + v_add_32( output[1], hStereoICBWE->memTransitionHB_fx[!hStereoICBWE->prev_refChanIndx_bwe], output[1], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } set32_fx( hStereoICBWE->memOutHB_fx[0], 0, memOffset ); set32_fx( hStereoICBWE->memOutHB_fx[1], 0, memOffset ); - set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } } } @@ -1304,13 +1304,13 @@ void stereo_icBWE_decproc_fx( } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( last_core, ACELP_CORE ) ) { - Word16 delay_tdbwe = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); + Word16 delay_tdbwe = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); FOR( n = 0; n < hCPE->nchan_out; n++ ) { FOR( i = 0; i < delay_tdbwe; i++ ) { - output[n][NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i] = L_add_sat( output[n][NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i], outputHB[0][i] ); + output[n][NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i] = L_add_sat( output[n][NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i], outputHB[0][i] ); move32(); } } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 4a788be83..20fa578f8 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -947,7 +947,7 @@ void applyDmxMdctStereo_fx( test(); IF( LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) ) { - crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); + crossfade_len = NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); move16(); SWITCH( hCPE->hCoreCoder[0]->output_Fs ) { @@ -994,7 +994,7 @@ void applyDmxMdctStereo_fx( } ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && LE_32( hCPE->last_element_brate, IVAS_32k ) ) { - crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, DELAY_CLDFB_NS ); /* Q0 */ + crossfade_len = NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, DELAY_CLDFB_NS ); /* Q0 */ move16(); SWITCH( hCPE->hCoreCoder[0]->output_Fs ) { diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index a8b74c447..c6466183b 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -415,7 +415,7 @@ ivas_error stereo_memory_dec_fx( IF( hCPE->hCoreCoder[0]->last_core != ACELP_CORE ) { - Copy32( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ + Copy32( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA_FX2( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ } } @@ -470,7 +470,7 @@ ivas_error stereo_memory_dec_fx( } /* memory update - needed in TD stereo, TCX/HQ frame -> DFT stereo, ACELP frame switching */ - Copy32( hCPE->input_mem_LB_fx[0], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( s_min( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), 16000 ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ + Copy32( hCPE->input_mem_LB_fx[0], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( s_min( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), 16000 ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ /* allocate ICBWE structure */ IF( hCPE->hStereoICBWE == NULL ) @@ -1034,11 +1034,11 @@ ivas_error stereo_memory_dec_fx( IF( hCPE->prev_synth_chs_fx[1] == NULL ) { st = hCPE->hCoreCoder[1]; - IF( ( hCPE->prev_synth_chs_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * NS2SA( st->output_Fs, FRAME_SIZE_NS ) ) ) == NULL ) + IF( ( hCPE->prev_synth_chs_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); } - set32_fx( hCPE->prev_synth_chs_fx[1], 0, NS2SA( st->output_Fs, FRAME_SIZE_NS ) ); + set32_fx( hCPE->prev_synth_chs_fx[1], 0, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ) ); } IF( hCPE->hStereoICBWE == NULL && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) @@ -2143,7 +2143,7 @@ void stereo_td2dft_update_fx( /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { - ovl_TCX = NS2SA_FX2( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); /* Q0 */ + ovl_TCX = NS2SA_FX2( L_mult0( sts[n]->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /* Q0 */ move16(); Copy32( synth_fx + sts[n]->hTcxDec->L_frameTCX + hq_delay_comp - ovl_TCX, hCPE->input_mem_fx[n], sub( ovl_TCX, hq_delay_comp ) ); /* Q11 */ Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + ovl_TCX - hq_delay_comp, hq_delay_comp ); /* Q11 */ @@ -2161,7 +2161,7 @@ void stereo_td2dft_update_fx( /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { - ovl_TCX = NS2SA_FX2( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); /* Q0 */ + ovl_TCX = NS2SA_FX2( L_mult0( sts[n]->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /* Q0 */ move16(); Copy32( synth_fx + add( sts[n]->hTcxDec->L_frameTCX, sub( hq_delay_comp, ovl_TCX ) ), hCPE->input_mem_fx[n], sub( ovl_TCX, hq_delay_comp ) ); /* Q11 */ Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + sub( ovl_TCX, hq_delay_comp ), hq_delay_comp ); /* Q11 */ diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index d296e3f33..c975da8d6 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -680,17 +680,17 @@ void stereo_tdm_combine_fx( output_Fs = hCPE->hCoreCoder[0]->output_Fs; /* Q0 */ move32(); - tdm_n_OVA = NS2SA( output_Fs, TDM_L_NOVA_NS ); /* Q0 */ + tdm_n_OVA = NS2SA_FX2( output_Fs, TDM_L_NOVA_NS ); /* Q0 */ move16(); IF( flag_HB ) { - upmixing_delay = NS2SA( output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ); /* Q0 */ + upmixing_delay = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ); /* Q0 */ move16(); } ELSE { - upmixing_delay = NS2SA( output_Fs, ACELP_LOOK_NS + DELAY_CLDFB_NS ); /* Q0 */ + upmixing_delay = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + DELAY_CLDFB_NS ); /* Q0 */ move16(); } @@ -845,7 +845,7 @@ void stereo_tdm_combine_fx( } incr_fx = Mpy_32_32( L_sub( ONE_IN_Q29, fac_fx ), step ); /* Q29 */ - FOR( i = 0; i < NS2SA( output_Fs, ACELP_LOOK_NS ); i++ ) + FOR( i = 0; i < NS2SA_FX2( output_Fs, ACELP_LOOK_NS ); i++ ) { PCh_2_L_fx[i] = L_shl_sat( Mpy_32_32( PCh_2_L_fx[i], fac_fx ), 2 ); /* Qx */ move32(); diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index 68272a79f..6b80108a8 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -654,7 +654,7 @@ void fd_bwe_dec_init_fx( ) { set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); hBWE_FD->prev_mode = NORMAL; move16(); hBWE_FD->prev_Energy_fx = 0; diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 7a6abb790..9552bbf2f 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1223,7 +1223,7 @@ void fd_bwe_dec_init( { hBWE_FD->old_wtda_wb_fx_exp = 0; move16(); - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); hBWE_FD->old_wtda_swb_fx_exp = 0; move16(); diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index d5bbfab29..d7dd47256 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -455,7 +455,7 @@ void amr_wb_enc_fx( IF( EQ_32( st->input_Fs, 16000 ) ) { /* no resampling needed, only delay adjustement to account for the FIR resampling delay */ - tmps = NS2SA_FX2( 16000, DELAY_FIR_RESAMPL_NS ); + tmps = NS2SA( 16000, DELAY_FIR_RESAMPL_NS ); Copy_Scale_sig( &st->mem_decim16k_fx[tmps], new_inp_16k, tmps, -1 ); /* Input in Q0 -> Output in Q-1 to mimic the resampling filter */ Copy_Scale_sig( st->input_fx, new_inp_16k + tmps, sub( input_frame, tmps ), -1 ); /* Input in Q0 -> Output in Q-1 to mimic the resampling filter */ Copy( st->input_fx + input_frame - shl( tmps, 1 ), st->mem_decim16k_fx, shl( tmps, 1 ) ); /* memory still in Q0 */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index f6b5b5984..1f5b0df1e 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -526,7 +526,7 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; - hTcxEnc->new_speech_TCX = st->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) - NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ); + hTcxEnc->new_speech_TCX = st->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) - NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 07468363f..da1139d15 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -430,8 +430,8 @@ void core_switching_post_enc_fx( test(); IF( ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */ { - acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA_FX2( INT_FS_FX, ACELP_LOOK_NS ), - old_inp_16k + L_INP_MEM - NS2SA_FX2( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new ); + acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA( INT_FS_FX, ACELP_LOOK_NS ), + old_inp_16k + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new ); } hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index d5be64f77..93a954ae8 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1531,7 +1531,7 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod, { FOR( i = 0; i < st->frameSize; i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA_FX2( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); move16(); } } @@ -1917,7 +1917,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, { FOR( i = 0; i < st->frameSize; i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA_FX2( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); move16(); } } diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index a3a75cc95..24579e74e 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -323,7 +323,7 @@ void hq_core_enc_ivas_fx( overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */ move16(); - nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS ); + nz = NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ); move16(); L_frame = sub( st->L_frame + st->hTcxCfg->tcx_offset, st->hTcxCfg->lfacNext ); tcx_offset = st->hTcxCfg->lfacNext; diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 8448843dc..1d4964ab8 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -429,7 +429,7 @@ ivas_error init_encoder_ivas_fx( IF( st->element_mode == EVS_MONO ) { st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); - st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); } ELSE { diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 89bbdc898..58706279e 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -71,7 +71,7 @@ ivas_error init_encoder_fx( st_fx->old_input_signal_fx = st_fx->input_buff_fx; IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - st_fx->input_fx = st_fx->input_buff_fx + st_fx->input_Fs / FRAMES_PER_SEC + NS2SA( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); + st_fx->input_fx = st_fx->input_buff_fx + st_fx->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); } ELSE { diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 96a3e110f..718a09026 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -533,7 +533,7 @@ ivas_error pre_proc_ivas_fx( sr_core_tmp = L_max( INT_FS_16k, st->sr_core ); } - L_look = NS2SA( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/ + L_look = NS2SA_FX2( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/ move16(); inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; @@ -747,7 +747,7 @@ ivas_error ivas_compute_core_buffers_fx( { lMemRecalc_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_NS ); move16(); - lMemRecalc = NS2SA( input_Fs, L_MEM_RECALC_NS ); + lMemRecalc = NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ); move16(); } @@ -765,7 +765,7 @@ ivas_error ivas_compute_core_buffers_fx( L_frame_tmp = s_max( L_FRAME16k, st->L_frame ); } - L_look = NS2SA( sr_core, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) */ + L_look = NS2SA_FX2( sr_core, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) */ move16(); new_inp_16k_fx = old_inp_16k_fx + L_INP_MEM; /* pointer to new samples of the input signal in 16kHz core */ @@ -775,7 +775,7 @@ ivas_error ivas_compute_core_buffers_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_SCE ) ) { - new_inp_16k_fx -= NS2SA( sr_core, DELAY_FIR_RESAMPL_NS ); + new_inp_16k_fx -= NS2SA_FX2( sr_core, DELAY_FIR_RESAMPL_NS ); } IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -814,8 +814,8 @@ ivas_error ivas_compute_core_buffers_fx( Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ + size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) @@ -840,7 +840,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 length_16k = NS2SA_FX2( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS ); move16(); - Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ + Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_16k_fx - lMemRecalc_16k - length_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } @@ -851,19 +851,19 @@ ivas_error ivas_compute_core_buffers_fx( IF( lMemRecalc > 0 ) { - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ + size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ + size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } } ELSE IF( st->idchan == 0 ) { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ - Copy( signal_in_fx + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ + Copy( signal_in_fx + input_frame - NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ } /*------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index b7a10a4f3..7bb67cbbd 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -432,7 +432,7 @@ ivas_error pre_proc_front_ivas_fx( IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { lMemRecalc = NS2SA_FX2( st->input_Fs, L_MEM_RECALC_NS ); - lMemRecalc_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_NS ); + lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS ); } input_Fs = st->input_Fs; /* Q0 */ @@ -575,7 +575,7 @@ ivas_error pre_proc_front_ivas_fx( IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) ) { Word16 length_inp = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS ); - Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); + Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ @@ -597,7 +597,7 @@ ivas_error pre_proc_front_ivas_fx( ELSE /* DFT stereo */ { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ - Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */ + Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */ } Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) ); /* Q(-1) */ @@ -678,7 +678,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) ) { - Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); + Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); move16(); // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx ); PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx ); diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index b1d819f5c..1b4d5da4a 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -86,7 +86,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); IF( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) ) { - len_inp_memory = add( len_inp_memory, NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); /* Q0 */ + len_inp_memory = add( len_inp_memory, NS2SA_FX2( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); /* Q0 */ } nchan_transport_old_real = nchan_transport_old; /* Q0 */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 3635ab04a..8f9a0edf6 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -873,7 +873,7 @@ ivas_error ivas_cpe_enc_fx( Word16 input_norm, q_inp32, common_q, fir_delay_len; input_norm = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( out_end_ind, out_start_ind ) ); q_inp32 = add( Q15, input_norm ); - fir_delay_len = NS2SA( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS ); + fir_delay_len = NS2SA_FX2( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS ); move16(); // Find common Q-factor between { q_inp, q_old_inp and q_inp32-16 } @@ -1408,12 +1408,12 @@ ivas_error create_cpe_enc_fx( test(); IF( EQ_16( ivas_format, STEREO_FORMAT ) || EQ_16( ivas_format, MASA_FORMAT ) || ( EQ_16( ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { - IF( ( hCPE->input_mem_fx[n] = (Word16 *) malloc( sizeof( Word16 ) * NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ) ) == NULL ) + IF( ( hCPE->input_mem_fx[n] = (Word16 *) malloc( sizeof( Word16 ) * NS2SA_FX2( input_Fs, STEREO_DFT_OVL_NS ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); } - set16_zero_fx( hCPE->input_mem_fx[n], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); + set16_zero_fx( hCPE->input_mem_fx[n], NS2SA_FX2( input_Fs, STEREO_DFT_OVL_NS ) ); } ELSE { diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 5460ccb12..3844598c6 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -417,7 +417,7 @@ ivas_error front_vad_create_fx( move16(); /* allocate delay buffer to compensate for filterbank delay */ - hFrontVad->delay_samples = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + hFrontVad->delay_samples = NS2SA_FX2( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); move16(); hFrontVad->delay_buf_fx = NULL; IF( GT_16( hFrontVad->delay_samples, 0 ) ) diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index 8ccb59c9c..fee34abd8 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -538,12 +538,12 @@ ivas_error ivas_create_lfe_enc_fx( * Input memory buffer: allocate and initialize *-----------------------------------------------------------------*/ - IF( ( hLFE->old_wtda_audio_fx = (Word32 *) malloc( sizeof( hLFE->old_wtda_audio_fx[0] ) * NS2SA( input_Fs, IVAS_LFE_FADE_NS ) ) ) == NULL ) + IF( ( hLFE->old_wtda_audio_fx = (Word32 *) malloc( sizeof( hLFE->old_wtda_audio_fx[0] ) * NS2SA_FX2( input_Fs, IVAS_LFE_FADE_NS ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LFE memory\n" ) ); } - set32_fx( hLFE->old_wtda_audio_fx, 0, NS2SA( input_Fs, IVAS_LFE_FADE_NS ) ); + set32_fx( hLFE->old_wtda_audio_fx, 0, NS2SA_FX2( input_Fs, IVAS_LFE_FADE_NS ) ); hLFE->q_old_wtda_audio = 31; move16(); diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index c94946b2d..392f1d9ab 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -201,8 +201,8 @@ ivas_error ivas_mc_paramupmix_enc_open_fx( /* assuming parameters are calculated at end of frame, compensate for MCT delay and half of decoder fb */ /* still 1.5ms off, since MCT delay is not large enough */ /* param at end of frame */ - fb_cfg->prior_input_length = (int16_t) ( NS2SA( input_Fs, 12000000L ) + NS2SA( input_Fs, DELAY_FB_4_NS / 2 ) - input_frame / 2 - NS2SA( input_Fs, DELAY_FB_1_NS / 2 ) ); - fb_cfg->prior_input_length = (int16_t) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); + fb_cfg->prior_input_length = (Word16) ( NS2SA_FX2( input_Fs, 12000000L ) + NS2SA_FX2( input_Fs, DELAY_FB_4_NS / 2 ) - input_frame / 2 - NS2SA_FX2( input_Fs, DELAY_FB_1_NS / 2 ) ); + fb_cfg->prior_input_length = (Word16) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Allocate and initialize FB mixer handle */ IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hMCParamUpmix->hFbMixer ), input_Fs, fb_cfg, 0 ) ), IVAS_ERR_OK ) ) diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 3687df381..b3f99e27c 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -200,22 +200,22 @@ ivas_error ivas_mcmasa_enc_open_fx( } /* initialize delay compensation */ - hMcMasa->num_samples_delay_comp = NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS ); + hMcMasa->num_samples_delay_comp = NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS ); move16(); #ifdef DISABLE_DIRAC_DELAY_COMP hMcMasa->num_samples_delay_comp = 0; /* disable delay compensation by setting to 0 */ #endif - tmp_f = idiv1616( hMcMasa->num_samples_delay_comp, ( NS2SA( input_Fs, DIRAC_SLOT_ENC_NS ) ) ); + tmp_f = idiv1616( hMcMasa->num_samples_delay_comp, ( NS2SA_FX2( input_Fs, DIRAC_SLOT_ENC_NS ) ) ); hMcMasa->num_slots_delay_comp = tmp_f; move16(); - IF( GT_16( hMcMasa->num_samples_delay_comp, ( NS2SA( input_Fs, DIRAC_SLOT_ENC_NS ) ) ) ) + IF( GT_16( hMcMasa->num_samples_delay_comp, ( NS2SA_FX2( input_Fs, DIRAC_SLOT_ENC_NS ) ) ) ) { hMcMasa->num_slots_delay_comp = add( hMcMasa->num_slots_delay_comp, 1 ); move16(); hMcMasa->offset_comp = negate( hMcMasa->num_samples_delay_comp ); move16(); - hMcMasa->num_samples_delay_comp = i_mult( hMcMasa->num_slots_delay_comp, NS2SA( input_Fs, DIRAC_SLOT_ENC_NS ) ); + hMcMasa->num_samples_delay_comp = i_mult( hMcMasa->num_slots_delay_comp, NS2SA_FX2( input_Fs, DIRAC_SLOT_ENC_NS ) ); move16(); hMcMasa->offset_comp = add( hMcMasa->offset_comp, hMcMasa->num_samples_delay_comp ); move16(); @@ -241,17 +241,17 @@ ivas_error ivas_mcmasa_enc_open_fx( IF( hMcMasa->separateChannelEnabled ) { /* TD Energy calculation with LP */ - IF( ( hMcMasa->delay_buffer_lfe[0] = (Word32 *) malloc( NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) + IF( ( hMcMasa->delay_buffer_lfe[0] = (Word32 *) malloc( NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); } - set_zero_fx( hMcMasa->delay_buffer_lfe[0], NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); + set_zero_fx( hMcMasa->delay_buffer_lfe[0], NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); - IF( ( hMcMasa->delay_buffer_lfe[1] = (Word32 *) malloc( NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) + IF( ( hMcMasa->delay_buffer_lfe[1] = (Word32 *) malloc( NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); } - set_zero_fx( hMcMasa->delay_buffer_lfe[1], NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); + set_zero_fx( hMcMasa->delay_buffer_lfe[1], NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); hMcMasa->hFbMixerLfe = NULL; } ELSE diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index ab8252854..5eee0975a 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -114,7 +114,7 @@ ivas_error ivas_osba_enc_open_fx( { set_val_Word32( hOSba->prev_object_dm_gains_fx[i], INV_SQRT_2_Q30, MAX_INPUT_CHANNELS ); } - len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + len = NS2SA_FX2( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); move16(); FOR( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { @@ -421,7 +421,7 @@ void ivas_osba_enc_fx( Word16 Q_out = *q_data; move16(); Word16 n, delay_s; - delay_s = NS2SA( input_Fs, IVAS_FB_ENC_DELAY_NS ); + delay_s = NS2SA_FX2( input_Fs, IVAS_FB_ENC_DELAY_NS ); IF( ism_mode == ISM_MODE_NONE ) { /*keep the delay buffer up to date*/ diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 72876ae35..e0a8a8ed4 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -112,7 +112,7 @@ static void tcaTargetCh_LA_fx( target = ptrChanL; } - tempS = NS2SA( L_mult0( input_frame, FRAMES_PER_SEC ), L_SAMPLES_LA_NS ); + tempS = NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_SAMPLES_LA_NS ); tempF1 = 0; move32(); tempF1_exp = 0; @@ -1512,7 +1512,7 @@ static void icaMemUpdate_fx( IF( hCPE->hStereoICBWE != NULL ) { assert( L_MEM_RECALC_TBE_NS <= L_MEM_RECALC_NS ); - i = NS2SA( sts[0]->input_Fs, L_MEM_RECALC_TBE_NS ); + i = NS2SA_FX2( sts[0]->input_Fs, L_MEM_RECALC_TBE_NS ); Copy_Scale_sig_32_16( bufChanL + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[0], i, -Q16 ); /* q_com-16 */ Copy_Scale_sig_32_16( bufChanR + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[1], i, -Q16 ); /* q_com-16 */ hCPE->hStereoICBWE->q_dataChan_fx = sub( q_com, Q16 ); @@ -1580,9 +1580,9 @@ void stereo_tca_enc_fx( q_com = sts[0]->q_inp32; move16(); - lMemRecalc = NS2SA( input_Fs, L_MEM_RECALC_NS ); + lMemRecalc = NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ); move16(); - lMemRecalc_SCh = NS2SA( input_Fs, L_MEM_RECALC_SCH_NS ); + lMemRecalc_SCh = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS ); move16(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) @@ -2081,7 +2081,7 @@ void stereo_tca_enc_fx( { /* Scale the Right channel with the gain */ Word16 j; - Word16 l_ica_ovl = NS2SA( input_Fs, STEREO_L_TCA_OVLP_NS ); + Word16 l_ica_ovl = NS2SA_FX2( input_Fs, STEREO_L_TCA_OVLP_NS ); Word16 winSlope = div_s( 1, l_ica_ovl ); // Q15 diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 786c45cb3..190adbf1c 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -822,7 +822,7 @@ void stereo_switching_enc_fx( offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels ); /* Q0 */ FOR( i = 0; i < offset; i++ ) { - sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */ + sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */ move32(); } sts[0]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp ); @@ -844,7 +844,7 @@ void stereo_switching_enc_fx( test(); IF( hCPE->hStereoTD != NULL && EQ_16( hCPE->hStereoTD->tdm_last_ratio_idx, LRTD_STEREO_LEFT_IS_PRIM ) ) { - v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ + v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp ); move16(); } @@ -852,7 +852,7 @@ void stereo_switching_enc_fx( { FOR( i = 0; i < offset; i++ ) { - sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */ + sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */ move32(); } sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16 - 5, q_inp ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 6035687ed..b4ca63bac 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1451,7 +1451,7 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *delay = NS2SA( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); + *delay = NS2SA_FX2( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); move16(); *delay = imult1616( *delay, hEncoderConfig->nchan_inp ); diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index c7d99cc69..01ac8383f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -225,8 +225,8 @@ void wb_bwe_enc_ivas_fx( /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis *---------------------------------------------------------------------*/ - set16_fx( old_input_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + set16_fx( old_input_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); new_input_fx = old_input_fx + Sample_Delay_WB_BWE; @@ -351,21 +351,21 @@ void swb_bwe_enc_ivas_fx( move32(); } - set16_fx( old_input_fx, 0, add( NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); + set16_fx( old_input_fx, 0, add( NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } - Sample_Delay_LP = NS2SA_FX2( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); IF( st_fx->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) @@ -381,15 +381,15 @@ void swb_bwe_enc_ivas_fx( ELSE { Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } - Sample_Delay_LP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); IF( st_fx->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) @@ -677,11 +677,11 @@ void swb_bwe_enc_fx( move32(); } - set16_fx( old_input_fx, 0, add( NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); + set16_fx( old_input_fx, 0, add( NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - Sample_Delay_SWB_BWE = NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); @@ -689,7 +689,7 @@ void swb_bwe_enc_fx( } ELSE { - Sample_Delay_SWB_BWE = NS2SA( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 3e9c07c23..3bad5fa7f 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -81,7 +81,7 @@ void wb_pre_proc_fx( move16(); } - set16_fx( old_input, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); + set16_fx( old_input, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); max_wb = 1; move16(); @@ -161,7 +161,7 @@ void wb_pre_proc_fx( test(); IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && LE_32( st_fx->total_brate, ACELP_8k00 ) ) ) && !hSC_VBR->ppp_mode ) { - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k ); Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE ); @@ -257,7 +257,7 @@ void wb_pre_proc_ivas_fx( move16(); } - set16_fx( old_input, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + STEREO_DFT_OVL_16k + L_FRAME16k ); + set16_fx( old_input, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + STEREO_DFT_OVL_16k + L_FRAME16k ); max_wb = 1; move16(); @@ -311,7 +311,7 @@ void wb_pre_proc_ivas_fx( hb_speech and the two decimator memories are in Q_wb_sp */ IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( last_element_mode, IVAS_CPE_TD ) ) { @@ -347,7 +347,7 @@ void wb_pre_proc_ivas_fx( move16(); Word16 l_recalc_4k = ( L_MEM_RECALC_16K + L_FILT16k + 1 ) / 4; move16(); - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) { @@ -391,7 +391,7 @@ void wb_pre_proc_ivas_fx( Word16 l_recalc_16k = L_FILT16k + 1; /* Note: "+1" is used because L_FILT16k is not divisible by 4 */ Word16 l_recalc_4k = ( L_FILT16k + 1 ) / 4; - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); /*Get past signal*/ Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, Q_wb_sp ); @@ -454,7 +454,7 @@ void wb_pre_proc_ivas_fx( test(); IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && EQ_32( st_fx->total_brate, 0 ) ) ) && !ppp_mode ) { - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k ); Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE ); @@ -540,7 +540,7 @@ void swb_pre_proc_fx( imagBufferFlipped[j] = imagBufferTmp[j]; } - set16_fx( old_input_fx, 0, NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); + set16_fx( old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); IF( EQ_32( st_fx->input_Fs, 32000 ) ) { @@ -549,7 +549,7 @@ void swb_pre_proc_fx( test(); IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); Copy( hBWE_FD->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); @@ -756,9 +756,9 @@ void swb_pre_proc_fx( /* Reset CLDFB synthesis buffer */ set16_fx( st_fx->cldfbSynTd->FilterStates, 0, st_fx->cldfbSynTd->p_filter_length + st_fx->cldfbSynTd->no_channels * st_fx->cldfbSynTd->no_col ); } - IF( st_fx->last_extl == -1 ) + IF( EQ_16( st_fx->last_extl, -1 ) ) { - delay = NS2SA( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); + delay = NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); FOR( i = 0; i < delay; i++ ) { shb_speech_fx[i] = mult_r( mult_r( i, 983 /*0.03f Q15*/ ), shb_speech_fx[2 * delay - 1 - i] ); @@ -813,7 +813,7 @@ void swb_pre_proc_ivas_fx( Word16 Sample_Delay_SWB_BWE32k, lMemRecalc32k, dft_ovl32k; Word32 one_by_50_Q31 = 42949673; - lMemRecalc32k = NS2SA_FX2( 32000, L_MEM_RECALC_NS ); + lMemRecalc32k = NS2SA( 32000, L_MEM_RECALC_NS ); move16(); // exp_lbEner move16(); // lMemRecalc32k move32(); // one_by_50_Q31 @@ -831,16 +831,16 @@ void swb_pre_proc_ivas_fx( imagBufferFlipped[j] = imagBufferTmp[j]; } - set16_fx( old_input_fx, 0, NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); + set16_fx( old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); IF( EQ_32( st->input_Fs, 32000 ) ) { IF( st->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS ); } Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); @@ -864,15 +864,15 @@ void swb_pre_proc_ivas_fx( test(); IF( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) && NE_16( st->extl, SWB_BWE_HIGHRATE ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); test(); IF( st->element_mode > EVS_MONO && EQ_16( st->L_frame, L_FRAME16k ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); } IF( st->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( 32000, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( 32000, DELAY_FIR_RESAMPL_NS ) ); } Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); @@ -894,15 +894,15 @@ void swb_pre_proc_ivas_fx( ELSE /* 48 kHz */ { - Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_SWB_BWE32k = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); - Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_SWB_BWE = NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_SWB_BWE32k = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS ); move16(); - Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_SWB_BWE = NS2SA( 48000, DELAY_FD_BWE_ENC_16k_NS ); move16(); } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 7422a5a15..a5e4e902b 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7332,7 +7332,7 @@ void fb_tbe_enc_fx( Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp ); elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; IF( NE_16( st->last_extl, FB_TBE ) ) { @@ -7468,16 +7468,16 @@ void fb_tbe_enc_ivas_fx( IF( EQ_16( st->L_frame, L_FRAME ) ) { - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; } ELSE { - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ) - L_FRAME48k / 2; } } ELSE { - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; } IF( NE_16( st->last_extl, FB_TBE ) ) -- GitLab From f8098d80f2d9eb69dfb23381d4aec58ab747d4d7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 10:40:10 +0530 Subject: [PATCH 237/329] Files cleanup in lib_enc --- Workspace_msvc/lib_enc.vcxproj | 66 -- Workspace_msvc/lib_enc.vcxproj.filters | 198 ---- lib_enc/ari_enc.c | 316 ------ lib_enc/ari_enc_fx.c | 223 +++++ lib_enc/ari_hm_enc.c | 53 -- lib_enc/arith_coder_enc.c | 51 - lib_enc/avq_cod.c | 42 - lib_enc/bass_psfilter_enc.c | 42 - lib_enc/bw_detect.c | 64 -- lib_enc/cng_enc.c | 429 --------- lib_enc/cng_enc_fx.c | 374 ++++++++ lib_enc/cod2t32.c | 41 - lib_enc/cod4t64.c | 48 - lib_enc/cod_ace.c | 42 - lib_enc/cod_tcx.c | 869 ----------------- lib_enc/cod_tcx_fx.c | 721 ++++++++++++++ lib_enc/cod_uv.c | 40 - lib_enc/comvad_decision.c | 41 - lib_enc/cor_shif.c | 41 - lib_enc/core_enc_2div.c | 42 - lib_enc/core_enc_init.c | 1055 -------------------- lib_enc/core_enc_init_fx.c | 1004 ++++++++++++++++++++ lib_enc/core_enc_ol.c | 46 - lib_enc/core_enc_reconf.c | 346 ------- lib_enc/core_enc_reconf_fx.c | 304 ++++++ lib_enc/core_enc_switch.c | 302 ------ lib_enc/core_enc_switch_fx.c | 259 +++++ lib_enc/core_enc_updt.c | 117 --- lib_enc/core_enc_updt_fx.c | 74 ++ lib_enc/core_switching_enc.c | 603 ------------ lib_enc/core_switching_enc_fx.c | 561 ++++++++++- lib_enc/corr_xh.c | 41 - lib_enc/decision_matrix_enc.c | 45 - lib_enc/detect_transient.c | 42 - lib_enc/diffcod.c | 149 --- lib_enc/dtx.c | 45 - lib_enc/enc_acelp.c | 91 -- lib_enc/enc_acelp_tcx_main.c | 41 - lib_enc/enc_acelpx.c | 42 - lib_enc/enc_amr_wb.c | 42 - lib_enc/enc_gain.c | 43 - lib_enc/enc_gen_voic.c | 42 - lib_enc/enc_prm.c | 231 ----- lib_enc/enc_prm_fx.c | 189 +++- lib_enc/fd_cng_enc.c | 1172 ----------------------- lib_enc/fd_cng_enc_fx.c | 1100 +++++++++++++++++++++ lib_enc/find_tilt.c | 303 ------ lib_enc/find_tilt_fx.c | 252 +++++ lib_enc/find_uv.c | 660 ------------- lib_enc/find_uv_fx.c | 539 +++++++++++ lib_enc/find_wsp.c | 98 -- lib_enc/find_wsp_fx.c | 59 +- lib_enc/frame_spec_dif_cor_rate.c | 47 - lib_enc/gain_enc.c | 55 -- lib_enc/gs_enc.c | 56 -- lib_enc/guided_plc_enc.c | 42 - lib_enc/hf_cod_amrwb.c | 43 - lib_enc/hq_classifier_enc.c | 52 - lib_enc/hq_core_enc.c | 410 -------- lib_enc/hq_core_enc_fx.c | 359 +++++++ lib_enc/hq_env_enc.c | 42 - lib_enc/hq_hr_enc.c | 280 ------ lib_enc/hq_hr_enc_fx.c | 236 ++++- lib_enc/hq_lr_enc.c | 46 - lib_enc/hvq_enc.c | 44 - lib_enc/init_enc.c | 1215 ------------------------ lib_enc/init_enc_fx.c | 1170 +++++++++++++++++++++++ lib_enc/inov_enc.c | 49 - lib_enc/isf_enc_amr_wb.c | 43 - lib_enc/ivas_entropy_coder.c | 3 +- lib_enc/lead_indexing.c | 208 ---- lib_enc/long_enr.c | 47 - lib_enc/lp_exc_e.c | 42 - lib_enc/lsf_enc.c | 49 - lib_enc/ltd_stable.c | 41 - lib_enc/mdct_classifier.c | 43 - lib_enc/mdct_selector.c | 44 - lib_enc/mslvq_enc.c | 308 ------ lib_enc/mslvq_enc_fx.c | 177 ++++ lib_enc/multi_harm.c | 42 - lib_enc/nelp_enc.c | 43 - lib_enc/pit_enc.c | 45 - lib_enc/pitch_ol.c | 48 - lib_enc/pitch_ol2.c | 274 ------ lib_enc/pitch_ol2_fx.c | 224 +++++ lib_enc/plc_enc_ext.c | 43 - lib_enc/setmodeindex.c | 97 -- lib_enc/setmodeindex_fx.c | 45 + 88 files changed, 7865 insertions(+), 11787 deletions(-) delete mode 100644 lib_enc/ari_enc.c delete mode 100644 lib_enc/ari_hm_enc.c delete mode 100644 lib_enc/arith_coder_enc.c delete mode 100644 lib_enc/avq_cod.c delete mode 100644 lib_enc/bass_psfilter_enc.c delete mode 100644 lib_enc/bw_detect.c delete mode 100644 lib_enc/cng_enc.c delete mode 100644 lib_enc/cod2t32.c delete mode 100644 lib_enc/cod4t64.c delete mode 100644 lib_enc/cod_ace.c delete mode 100644 lib_enc/cod_tcx.c delete mode 100644 lib_enc/cod_uv.c delete mode 100644 lib_enc/comvad_decision.c delete mode 100644 lib_enc/cor_shif.c delete mode 100644 lib_enc/core_enc_2div.c delete mode 100644 lib_enc/core_enc_init.c delete mode 100644 lib_enc/core_enc_ol.c delete mode 100644 lib_enc/core_enc_reconf.c delete mode 100644 lib_enc/core_enc_switch.c delete mode 100644 lib_enc/core_enc_updt.c delete mode 100644 lib_enc/core_switching_enc.c delete mode 100644 lib_enc/corr_xh.c delete mode 100644 lib_enc/decision_matrix_enc.c delete mode 100644 lib_enc/detect_transient.c delete mode 100644 lib_enc/diffcod.c delete mode 100644 lib_enc/dtx.c delete mode 100644 lib_enc/enc_acelp.c delete mode 100644 lib_enc/enc_acelp_tcx_main.c delete mode 100644 lib_enc/enc_acelpx.c delete mode 100644 lib_enc/enc_amr_wb.c delete mode 100644 lib_enc/enc_gain.c delete mode 100644 lib_enc/enc_gen_voic.c delete mode 100644 lib_enc/enc_prm.c delete mode 100644 lib_enc/fd_cng_enc.c delete mode 100644 lib_enc/find_tilt.c delete mode 100644 lib_enc/find_uv.c delete mode 100644 lib_enc/find_wsp.c delete mode 100644 lib_enc/frame_spec_dif_cor_rate.c delete mode 100644 lib_enc/gain_enc.c delete mode 100644 lib_enc/gs_enc.c delete mode 100644 lib_enc/guided_plc_enc.c delete mode 100644 lib_enc/hf_cod_amrwb.c delete mode 100644 lib_enc/hq_classifier_enc.c delete mode 100644 lib_enc/hq_core_enc.c delete mode 100644 lib_enc/hq_env_enc.c delete mode 100644 lib_enc/hq_hr_enc.c delete mode 100644 lib_enc/hq_lr_enc.c delete mode 100644 lib_enc/hvq_enc.c delete mode 100644 lib_enc/init_enc.c delete mode 100644 lib_enc/inov_enc.c delete mode 100644 lib_enc/isf_enc_amr_wb.c delete mode 100644 lib_enc/lead_indexing.c delete mode 100644 lib_enc/long_enr.c delete mode 100644 lib_enc/lp_exc_e.c delete mode 100644 lib_enc/lsf_enc.c delete mode 100644 lib_enc/ltd_stable.c delete mode 100644 lib_enc/mdct_classifier.c delete mode 100644 lib_enc/mdct_selector.c delete mode 100644 lib_enc/mslvq_enc.c delete mode 100644 lib_enc/multi_harm.c delete mode 100644 lib_enc/nelp_enc.c delete mode 100644 lib_enc/pit_enc.c delete mode 100644 lib_enc/pitch_ol.c delete mode 100644 lib_enc/pitch_ol2.c delete mode 100644 lib_enc/plc_enc_ext.c delete mode 100644 lib_enc/setmodeindex.c diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 75831970e..86e56d42a 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -239,60 +239,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -324,18 +273,13 @@ - - - - - @@ -373,18 +317,8 @@ - - - - - - - - - - diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index 0c3220178..406c01b86 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -8,75 +8,39 @@ encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c @@ -92,54 +56,33 @@ encoder_evs_c - - encoder_evs_c - encoder_evs_c encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c encoder_evs_c - - encoder_evs_c - encoder_evs_c encoder_evs_c - - encoder_evs_c - encoder_evs_c @@ -347,135 +290,72 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c encoder_all_c - - encoder_all_c - encoder_all_c @@ -494,9 +374,6 @@ encoder_all_c - - encoder_all_c - encoder_all_c @@ -506,27 +383,15 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -536,45 +401,24 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -590,39 +434,21 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -632,27 +458,15 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -668,21 +482,12 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -719,9 +524,6 @@ encoder_all_c - - encoder_all_c - encoder_all_c diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c deleted file mode 100644 index da4d1486b..000000000 --- a/lib_enc/ari_enc.c +++ /dev/null @@ -1,316 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "stat_com.h" -#include "basop_util.h" -#include "wmc_auto.h" -#include "prot_fx_enc.h" - - -/*--------------------------------------------------------------- - * ari_copy_states() - * - * Copy state - *-------------------------------------------------------------*/ - -void ari_copy_states( - Tastat *source, - Tastat *dest ) -{ - dest->low = source->low; - dest->high = source->high; - dest->bits_to_follow = source->bits_to_follow; - - return; -} - -/*--------------------------------------------------------------- - Ari encoder 14 bits routines - -------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - * ari_start_encoding_14bits() - * - * Start ArCo encoding - *-------------------------------------------------------------*/ - -void ari_start_encoding_14bits( - Tastat *s ) -{ - /* : addressing is made with walking pointer s */ - s->low = 0; - s->high = ari_q4new; - s->bits_to_follow = 0; - move32(); - move32(); - move32(); - - return; -} -void ari_start_encoding_14bits_ivas_fx( - Tastat *s ) -{ - /* : addressing is made with walking pointer s */ - s->low = 0; - s->high = ari_q4new; - s->bits_to_follow = 0; - move32(); - move32(); - move32(); - - return; -} - -/*--------------------------------------------------------------- - * ari_done_encoding_14bits_ivas_fx() - * - * Finish ArCo encoding - *-------------------------------------------------------------*/ - -Word16 ari_done_encoding_14bits_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s ) -{ - Word16 bit; - - bit = 0; - move16(); - IF( GE_32( s->low, ari_q1new ) ) - { - bit = s_xor( bit, 1 ); - } - return ari_put_bit_plus_follow( ptr, bp, add( extract_l( s->bits_to_follow ), 1 ), bit ); -} - - -/*--------------------------------------------------------------- - * ari_encode_14bits_ext_ivas_fx() - * - * encode function for extended proba tables: less branches needed for coding - * - *-------------------------------------------------------------*/ -Word16 ari_encode_14bits_ext_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s, - Word32 symbol, /* Q0 */ - UWord16 const *cum_freq /* Q0 */ -) -{ - Word32 low; - Word32 high; - Word32 range; - Word16 bits_to_follow; - Word16 i; - UWord16 temp; - Word32 L_temp1, L_temp2; - - high = L_add( s->high, 0 ); - low = L_add( s->low, 0 ); - range = L_add( L_sub( high, low ), 1 ); /* Q0 */ - - L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ ); - Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp ); - IF( symbol != 0 ) /* when symbol is 0, range remains unchanged */ - { - Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp ); - } - high = L_sub( L_add( low, range ), 1 ); /* Q0 */ - low = L_add( low, L_temp2 ); /* Q0 */ - - assert( s->bits_to_follow <= MAX_16 ); - bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ - - FOR( i = 0; i < 0x7FFF; i++ ) - { - IF( LT_32( high, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ - bits_to_follow = 0; - move16(); - } - ELSE IF( GE_32( low, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ - bits_to_follow = 0; - move16(); - low = L_sub( low, ari_q2new ); - high = L_sub( high, ari_q2new ); /* Subtract offset to top. */ - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) ) - { - /* Output an opposite bit */ - /* later if in middle half. */ - bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/ - high = L_sub( high, ari_q1new ); - } - ELSE - { - BREAK; /* Otherwise exit loop. */ - } - } - low = L_add( low, low ); /* Q0 */ - high = L_add( L_add( high, high ), 1 ); /* Scale up code range. Q0*/ - } - - s->low = low; /* Q0 */ - move32(); - s->high = high; /* Q0 */ - move32(); - s->bits_to_follow = bits_to_follow; /* Q0 */ - move32(); - - return bp; -} - - -/*------------------------------------------------------------------------ - * Function: ari_encode_14bits_high_low_fx() - * - *-------------------------------------------------------------------------*/ - -static Word16 ari_encode_14bits_high_low_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word16 bits, /* Q0 */ - Tastat *s, - Word32 high, /* Q0 */ - Word32 low /* Q0 */ -) -{ - Word16 bits_to_follow, tmp; - - bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ - move16(); - - /* while there are more than 16 bits left */ - tmp = sub( 16, bits ); /* Q0 */ - WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 ) - { - IF( LE_32( high, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ - bits_to_follow = 0; - move16(); - } - ELSE IF( GE_32( low, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ - bits_to_follow = 0; - move16(); - low = L_sub( low, ari_q2new ); /* Q0 */ - high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/ - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) - { - /* Output an opposite bit */ - /* later if in middle half. */ - bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ - high = L_sub( high, ari_q1new ); /* Q0 */ - } - ELSE - { - BREAK; /* Otherwise exit loop. */ - } - } - - low = L_add( low, low ); - high = L_add( high, high ); /* Scale up code range. */ - } - - s->low = low; /* Q0 */ - move32(); - s->high = L_sub( high, 1 ); /* Q0 */ - move32(); - s->bits_to_follow = bits_to_follow; /* Q0 */ - move16(); - - return bp; -} - -/*------------------------------------------------------------------------ - * Function: ari_encode_14bits_sign_ivas_fx() - * - * Encode a sign with equal probabilities. - *-------------------------------------------------------------------------*/ -Word16 ari_encode_14bits_sign_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word32 bits, /* Q0 */ - Tastat *s, - Word16 sign /* Q0 */ -) -{ - Word32 low, high, range; - Word32 L_tmp; - - high = L_add( s->high, 1 ); - low = L_add( s->low, 0 ); - range = L_sub( high, low ); /* Q0 */ - - L_tmp = L_shr( range, 1 ); - if ( sign != 0 ) - { - high = L_add( low, L_tmp ); /* Q0 */ - } - if ( sign == 0 ) - { - low = L_add( low, L_tmp ); /* Q0 */ - } - - return ari_encode_14bits_high_low_fx( ptr, bp, extract_l( bits ), s, high, low ); -} - -/*------------------------------------------------------------------------ - * Function: ari_done_cbr_encoding_14bits() - * - * Finish up encoding in CBR mode. - *-------------------------------------------------------------------------*/ diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c index 0ef053edd..29ddd838c 100644 --- a/lib_enc/ari_enc_fx.c +++ b/lib_enc/ari_enc_fx.c @@ -364,3 +364,226 @@ Word16 ari_done_cbr_encoding_14bits_fx( return bp; } + +void ari_start_encoding_14bits_ivas_fx( + Tastat *s ) +{ + /* : addressing is made with walking pointer s */ + s->low = 0; + s->high = ari_q4new; + s->bits_to_follow = 0; + move32(); + move32(); + move32(); + + return; +} + +/*--------------------------------------------------------------- + * ari_done_encoding_14bits_ivas_fx() + * + * Finish ArCo encoding + *-------------------------------------------------------------*/ + +Word16 ari_done_encoding_14bits_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s ) +{ + Word16 bit; + + bit = 0; + move16(); + IF( GE_32( s->low, ari_q1new ) ) + { + bit = s_xor( bit, 1 ); + } + return ari_put_bit_plus_follow( ptr, bp, add( extract_l( s->bits_to_follow ), 1 ), bit ); +} + + +/*--------------------------------------------------------------- + * ari_encode_14bits_ext_ivas_fx() + * + * encode function for extended proba tables: less branches needed for coding + * + *-------------------------------------------------------------*/ +Word16 ari_encode_14bits_ext_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s, + Word32 symbol, /* Q0 */ + UWord16 const *cum_freq /* Q0 */ +) +{ + Word32 low; + Word32 high; + Word32 range; + Word16 bits_to_follow; + Word16 i; + UWord16 temp; + Word32 L_temp1, L_temp2; + + high = L_add( s->high, 0 ); + low = L_add( s->low, 0 ); + range = L_add( L_sub( high, low ), 1 ); /* Q0 */ + + L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ ); + Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp ); + IF( symbol != 0 ) /* when symbol is 0, range remains unchanged */ + { + Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp ); + } + high = L_sub( L_add( low, range ), 1 ); /* Q0 */ + low = L_add( low, L_temp2 ); /* Q0 */ + + assert( s->bits_to_follow <= MAX_16 ); + bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ + + FOR( i = 0; i < 0x7FFF; i++ ) + { + IF( LT_32( high, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ + bits_to_follow = 0; + move16(); + } + ELSE IF( GE_32( low, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ + bits_to_follow = 0; + move16(); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); /* Subtract offset to top. */ + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) ) + { + /* Output an opposite bit */ + /* later if in middle half. */ + bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/ + high = L_sub( high, ari_q1new ); + } + ELSE + { + BREAK; /* Otherwise exit loop. */ + } + } + low = L_add( low, low ); /* Q0 */ + high = L_add( L_add( high, high ), 1 ); /* Scale up code range. Q0*/ + } + + s->low = low; /* Q0 */ + move32(); + s->high = high; /* Q0 */ + move32(); + s->bits_to_follow = bits_to_follow; /* Q0 */ + move32(); + + return bp; +} + + +/*------------------------------------------------------------------------ + * Function: ari_encode_14bits_high_low_fx() + * + *-------------------------------------------------------------------------*/ + +static Word16 ari_encode_14bits_high_low_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word16 bits, /* Q0 */ + Tastat *s, + Word32 high, /* Q0 */ + Word32 low /* Q0 */ +) +{ + Word16 bits_to_follow, tmp; + + bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ + move16(); + + /* while there are more than 16 bits left */ + tmp = sub( 16, bits ); /* Q0 */ + WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 ) + { + IF( LE_32( high, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ + bits_to_follow = 0; + move16(); + } + ELSE IF( GE_32( low, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ + bits_to_follow = 0; + move16(); + low = L_sub( low, ari_q2new ); /* Q0 */ + high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/ + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + /* Output an opposite bit */ + /* later if in middle half. */ + bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ + high = L_sub( high, ari_q1new ); /* Q0 */ + } + ELSE + { + BREAK; /* Otherwise exit loop. */ + } + } + + low = L_add( low, low ); + high = L_add( high, high ); /* Scale up code range. */ + } + + s->low = low; /* Q0 */ + move32(); + s->high = L_sub( high, 1 ); /* Q0 */ + move32(); + s->bits_to_follow = bits_to_follow; /* Q0 */ + move16(); + + return bp; +} + +/*------------------------------------------------------------------------ + * Function: ari_encode_14bits_sign_ivas_fx() + * + * Encode a sign with equal probabilities. + *-------------------------------------------------------------------------*/ +Word16 ari_encode_14bits_sign_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word32 bits, /* Q0 */ + Tastat *s, + Word16 sign /* Q0 */ +) +{ + Word32 low, high, range; + Word32 L_tmp; + + high = L_add( s->high, 1 ); + low = L_add( s->low, 0 ); + range = L_sub( high, low ); /* Q0 */ + + L_tmp = L_shr( range, 1 ); + if ( sign != 0 ) + { + high = L_add( low, L_tmp ); /* Q0 */ + } + if ( sign == 0 ) + { + low = L_add( low, L_tmp ); /* Q0 */ + } + + return ari_encode_14bits_high_low_ivas_fx( ptr, bp, extract_l( bits ), s, high, low ); +} diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c deleted file mode 100644 index c6e11a3f0..000000000 --- a/lib_enc/ari_hm_enc.c +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "stl.h" -#include "basop_util.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * EncodeIndex() - * - * - *-------------------------------------------------------------------*/ diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c deleted file mode 100644 index 5625b6cf4..000000000 --- a/lib_enc/arith_coder_enc.c +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ diff --git a/lib_enc/avq_cod.c b/lib_enc/avq_cod.c deleted file mode 100644 index 9228e2f5d..000000000 --- a/lib_enc/avq_cod.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/bass_psfilter_enc.c b/lib_enc/bass_psfilter_enc.c deleted file mode 100644 index 9228e2f5d..000000000 --- a/lib_enc/bass_psfilter_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c deleted file mode 100644 index d86351ae8..000000000 --- a/lib_enc/bw_detect.c +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k -#define BWD_MIN_BRATE_WIDER_BW_ISM IVAS_32k -#define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k -#define BWD_MAX_BRATE_WIDER_BW_ISM IVAS_64k - -#define ALPHA_BWD 0.75f -#define BWD_LT_THRESH 0.6f - -#define BWD_COUNT_MAX 100 -#define BWD_COUNT_WIDER_BW 10 -#define BWD_COUNT_WIDER_BW_MDCT 0 - -#define CLDFB_ENER_OFFSET 1.6f diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c deleted file mode 100644 index 192a71f92..000000000 --- a/lib_enc/cng_enc.c +++ /dev/null @@ -1,429 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx_enc.h" -#include "prot_fx.h" -#include "ivas_rom_com_fx.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ - -static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx ); - -static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); - - -void swb_CNG_enc_ivas_fx( - Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ -) -{ - Word16 shb_SID_updt; - - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) - { - IF( st->cng_type == LP_CNG ) - { - test(); - IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) - { - /* decide if SHB SID encoding or not */ - shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); - - /* SHB CNG encoding */ - shb_CNG_encod_ivas_fx( st, shb_SID_updt ); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) - { - /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ - delete_indice( st->hBstr, IND_CNG_ENV1 ); - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( st->hBstr, IND_UNUSED, 0, 4 ); - push_indice( st->hBstr, IND_SID_BW, 1, 1 ); - } - } - st->hTdCngEnc->last_vad = 0; - move16(); - } - ELSE - { - st->hTdCngEnc->last_vad = 1; - move16(); - } - - return; -} - - -/*---------------------------------------------------------------------* - * shb_CNG_encod() - * - * SID parameters encoding for SHB signal - *---------------------------------------------------------------------*/ - -static void shb_CNG_encod_ivas_fx( - Encoder_State *st, /* i/o: State structure */ - const Word16 update /* i : SID update flag */ -) -{ - Word16 idx_ener = 0; - move16(); - BSTR_ENC_HANDLE hBstr = st->hBstr; - - Word16 ener_mid_dec_thr_fx; - - IF( EQ_16( update, 1 ) ) - { - IF( st->element_mode == EVS_MONO ) - { - /* 6.0 in Q8 -> 1510 */ - /* 0.9 in Q15 29491 */ - /* ( 1 / log10(2.0) ) * 0.1 in Q15 ->10886 */ - idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ - } - ELSE - { - /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ - // PMT("shb_CNG_encod_fx quantization in missing") - /* 6.0 in Q8 -> 1510 */ - /* 0.7 in Q15 22938 */ - /* ( 1 / log10(2.0) ) * 0.1 in Q15 -> 10886 */ - idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 22938 ), 8 ); /* Q0 */ - } - - - if ( LT_16( st->bwidth, SWB ) ) - { - idx_ener = 0; - move16(); - } - - IF( GT_16( idx_ener, 15 ) ) - { - idx_ener = 15; - move16(); - } - ELSE IF( idx_ener < 0 ) - { - idx_ener = 0; - move16(); - } - - /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ - IF( st->element_mode != EVS_MONO ) - { - IF( EQ_16( abs_s( sub( idx_ener, st->hTdCngEnc->last_idx_ener ) ), 1 ) ) - { - - Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e; - tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 - scale = add( scale, ( 15 - 0 ) ); - tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); - tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 ); - exp1 = add( exp1, ( scale - 0 ) ); - - ener_mid_dec_thr_fx = shr( mult( tmp1, 9864 ), 1 ); // exp = exp - - tmp = BASOP_Util_Divide1616_Scale( idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 - scale = add( scale, ( 15 - 0 ) ); - tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); - tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp2 ); - exp2 = add( exp2, ( scale - 0 ) ); - - tmp2 = shr( mult( tmp1, 9864 ), 1 ); // exp = exp - - ener_mid_dec_thr_e = BASOP_Util_Add_MantExp( tmp2, exp2, ener_mid_dec_thr_fx, exp1, &ener_mid_dec_thr_fx ); - - - scale = BASOP_Util_Add_MantExp( st->hTdCngEnc->mov_shb_cng_ener_fx, 7, negate( ener_mid_dec_thr_fx ), ener_mid_dec_thr_e, &tmp ); - tmp1 = BASOP_Util_Divide1616_Scale( tmp, ener_mid_dec_thr_fx, &exp1 ); - exp1 = add( exp1, sub( scale, ener_mid_dec_thr_e ) ); - IF( LT_16( abs_s( tmp1 ), shr( 328, sub( 15, exp1 ) ) ) ) - { - idx_ener = st->hTdCngEnc->last_idx_ener; - move16(); - } - } - } - - st->hTdCngEnc->last_idx_ener = idx_ener; - move16(); - - push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); - push_indice( hBstr, IND_SID_BW, 1, 1 ); - delete_indice( hBstr, IND_CNG_ENV1 ); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); - } - ELSE - { - push_indice( hBstr, IND_UNUSED, 0, 2 ); - } - st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - st->hTdCngEnc->ho_sid_bw = L_or( st->hTdCngEnc->ho_sid_bw, 0x1L ); - move32(); - move32(); - } - ELSE IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - move32(); - push_indice( hBstr, IND_SID_BW, 0, 1 ); - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_DTX() - * - * Decide if encoding SHB SID or not - *---------------------------------------------------------------------*/ - -static Word16 shb_DTX_ivas_fx( - Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ -) -{ - Word16 i; - Word16 update; - - Word16 allow_cn_step = 0; - move16(); - Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4]; - Word16 *shb_new_speech_fx; - Word32 wb_ener_fx; - Word32 shb_ener_fx; - Word16 log_wb_ener_fx; - Word16 log_shb_ener_fx; - Word16 tmp; - Word16 exp; - Word16 fra; - Word16 att_fx; /*Q8*/ - - TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; - TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; - - -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move16(); -#endif - - shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; - Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); // old_speech_shb_fx -> Q0 - Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); // Q0 - Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); // Q0 - - shb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac - } - - shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in Q1 */ - - wb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < st->L_frame; i++ ) - { - wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac - } - - wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ - - exp = norm_l( wb_ener_fx ); - fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); - exp = sub( 30 - 1, exp ); - wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - - log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ - exp = norm_l( shb_ener_fx ); - fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); - exp = sub( 30 - 1, exp ); - shb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - - - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - Word32 att_fx32 = 0; - move32(); - Word16 index; - - apply_scale_ivas_fx( &att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index ); // Q23; - - att_fx = extract_l( L_shr( att_fx32, 15 ) ); // Q8 - } - ELSE - { - att_fx = -1664; // Q8 - move16(); - } - - - log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ - - IF( st->hDtxEnc->first_CNG == 0 ) - { - - - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; // Q8 - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; // Q8 - hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; // Q8 - hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; // Q8 - move16(); - move16(); - move16(); - move16(); - } - IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) ) - { - allow_cn_step = 1; - move16(); - } - - /* Also allow step if shb energy has dropped 12 dB */ - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 /*12 in Q8*/ ) ) - { - allow_cn_step = 1; - move16(); - } - - IF( EQ_16( allow_cn_step, 1 ) ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - move16(); - } - ELSE - { - tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */ - tmp = mult( tmp, 29491 /* .9f in Q15*/ ); /* Q8 */ - hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */ - move16(); - - tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ); - tmp = mult( tmp, 8192 /* .25f in Q15*/ ); /* Q8 */ - hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */ - move16(); - } - - hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 ); - update = 0; - - move16(); - move16(); - - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - test(); - test(); - test(); - IF( st->hDtxEnc->first_CNG == 0 ) - { - update = 1; - move16(); - } - ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); - update = 1; - move16(); - move16(); - } - ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) - { - update = 1; - move16(); - } - ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) - { - update = 1; - move16(); - } - ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) - { - update = 1; - move16(); - } - ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) - { - update = 1; - move16(); - } - - hTdCngEnc->last_SID_bwidth = st->bwidth; - move16(); - } - - /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */ - test(); - test(); - if ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_32( st->core_brate, SID_2k40 ) ) - { - update = 1; - move16(); - } - - IF( EQ_16( update, 1 ) ) - { - hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; - hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - move16(); - move16(); - } - - return ( update ); -} diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 4cfc193ec..7188bcbad 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -27,6 +27,8 @@ *---------------------------------------------------------------------*/ static void shb_CNG_encod_fx( Encoder_State *st_fx, const Word16 update_fx ); static Word16 shb_DTX_fx( Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); +static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx ); +static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); /*---------------------------------------------------------------------* * CNG_enc() * @@ -2839,3 +2841,375 @@ void calculate_hangover_attenuation_gain_ivas_fx( return; } + +void swb_CNG_enc_ivas_fx( + Encoder_State *st, /* i/o: State structure */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ +) +{ + Word16 shb_SID_updt; + + test(); + IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) + { + IF( st->cng_type == LP_CNG ) + { + test(); + IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) + { + /* decide if SHB SID encoding or not */ + shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); + + /* SHB CNG encoding */ + shb_CNG_encod_ivas_fx( st, shb_SID_updt ); + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) + { + /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ + delete_indice( st->hBstr, IND_CNG_ENV1 ); + push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); + push_indice( st->hBstr, IND_UNUSED, 0, 4 ); + push_indice( st->hBstr, IND_SID_BW, 1, 1 ); + } + } + st->hTdCngEnc->last_vad = 0; + move16(); + } + ELSE + { + st->hTdCngEnc->last_vad = 1; + move16(); + } + + return; +} + + +/*---------------------------------------------------------------------* + * shb_CNG_encod() + * + * SID parameters encoding for SHB signal + *---------------------------------------------------------------------*/ + +static void shb_CNG_encod_ivas_fx( + Encoder_State *st, /* i/o: State structure */ + const Word16 update /* i : SID update flag */ +) +{ + Word16 idx_ener = 0; + move16(); + BSTR_ENC_HANDLE hBstr = st->hBstr; + + Word16 ener_mid_dec_thr_fx; + + IF( EQ_16( update, 1 ) ) + { + IF( st->element_mode == EVS_MONO ) + { + /* 6.0 in Q8 -> 1510 */ + /* 0.9 in Q15 29491 */ + /* ( 1 / log10(2.0) ) * 0.1 in Q15 ->10886 */ + idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ + } + ELSE + { + /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ + // PMT("shb_CNG_encod_fx quantization in missing") + /* 6.0 in Q8 -> 1510 */ + /* 0.7 in Q15 22938 */ + /* ( 1 / log10(2.0) ) * 0.1 in Q15 -> 10886 */ + idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 22938 ), 8 ); /* Q0 */ + } + + + if ( LT_16( st->bwidth, SWB ) ) + { + idx_ener = 0; + move16(); + } + + IF( GT_16( idx_ener, 15 ) ) + { + idx_ener = 15; + move16(); + } + ELSE IF( idx_ener < 0 ) + { + idx_ener = 0; + move16(); + } + + /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ + IF( st->element_mode != EVS_MONO ) + { + IF( EQ_16( abs_s( sub( idx_ener, st->hTdCngEnc->last_idx_ener ) ), 1 ) ) + { + + Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e; + tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 + scale = add( scale, ( 15 - 0 ) ); + tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); + tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 ); + exp1 = add( exp1, ( scale - 0 ) ); + + ener_mid_dec_thr_fx = shr( mult( tmp1, 9864 ), 1 ); // exp = exp + + tmp = BASOP_Util_Divide1616_Scale( idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 + scale = add( scale, ( 15 - 0 ) ); + tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); + tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp2 ); + exp2 = add( exp2, ( scale - 0 ) ); + + tmp2 = shr( mult( tmp1, 9864 ), 1 ); // exp = exp + + ener_mid_dec_thr_e = BASOP_Util_Add_MantExp( tmp2, exp2, ener_mid_dec_thr_fx, exp1, &ener_mid_dec_thr_fx ); + + + scale = BASOP_Util_Add_MantExp( st->hTdCngEnc->mov_shb_cng_ener_fx, 7, negate( ener_mid_dec_thr_fx ), ener_mid_dec_thr_e, &tmp ); + tmp1 = BASOP_Util_Divide1616_Scale( tmp, ener_mid_dec_thr_fx, &exp1 ); + exp1 = add( exp1, sub( scale, ener_mid_dec_thr_e ) ); + IF( LT_16( abs_s( tmp1 ), shr( 328, sub( 15, exp1 ) ) ) ) + { + idx_ener = st->hTdCngEnc->last_idx_ener; + move16(); + } + } + } + + st->hTdCngEnc->last_idx_ener = idx_ener; + move16(); + + push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); + push_indice( hBstr, IND_SID_BW, 1, 1 ); + delete_indice( hBstr, IND_CNG_ENV1 ); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); + } + ELSE + { + push_indice( hBstr, IND_UNUSED, 0, 2 ); + } + st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); + st->hTdCngEnc->ho_sid_bw = L_or( st->hTdCngEnc->ho_sid_bw, 0x1L ); + move32(); + move32(); + } + ELSE IF( EQ_32( st->core_brate, SID_2k40 ) ) + { + st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); + move32(); + push_indice( hBstr, IND_SID_BW, 0, 1 ); + } + + return; +} + +/*---------------------------------------------------------------------* + * shb_DTX() + * + * Decide if encoding SHB SID or not + *---------------------------------------------------------------------*/ + +static Word16 shb_DTX_ivas_fx( + Encoder_State *st, /* i/o: State structure */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ +) +{ + Word16 i; + Word16 update; + + Word16 allow_cn_step = 0; + move16(); + Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4]; + Word16 *shb_new_speech_fx; + Word32 wb_ener_fx; + Word32 shb_ener_fx; + Word16 log_wb_ener_fx; + Word16 log_shb_ener_fx; + Word16 tmp; + Word16 exp; + Word16 fra; + Word16 att_fx; /*Q8*/ + + TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; + TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; + + +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move16(); +#endif + + shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; + Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); // old_speech_shb_fx -> Q0 + Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); // Q0 + Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); // Q0 + + shb_ener_fx = L_deposit_l( 0 ); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac + } + + shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in Q1 */ + + wb_ener_fx = L_deposit_l( 0 ); + FOR( i = 0; i < st->L_frame; i++ ) + { + wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac + } + + wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ + + exp = norm_l( wb_ener_fx ); + fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); + exp = sub( 30 - 1, exp ); + wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); + + log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ + exp = norm_l( shb_ener_fx ); + fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); + exp = sub( 30 - 1, exp ); + shb_ener_fx = Mpy_32_16( exp, fra, LG10 ); + + + test(); + IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + Word32 att_fx32 = 0; + move32(); + Word16 index; + + apply_scale_ivas_fx( &att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index ); // Q23; + + att_fx = extract_l( L_shr( att_fx32, 15 ) ); // Q8 + } + ELSE + { + att_fx = -1664; // Q8 + move16(); + } + + + log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ + + IF( st->hDtxEnc->first_CNG == 0 ) + { + + + hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; // Q8 + hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; // Q8 + hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; // Q8 + hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; // Q8 + move16(); + move16(); + move16(); + move16(); + } + IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) ) + { + allow_cn_step = 1; + move16(); + } + + /* Also allow step if shb energy has dropped 12 dB */ + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 /*12 in Q8*/ ) ) + { + allow_cn_step = 1; + move16(); + } + + IF( EQ_16( allow_cn_step, 1 ) ) + { + hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; + hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; + move16(); + move16(); + } + ELSE + { + tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */ + tmp = mult( tmp, 29491 /* .9f in Q15*/ ); /* Q8 */ + hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */ + move16(); + + tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ); + tmp = mult( tmp, 8192 /* .25f in Q15*/ ); /* Q8 */ + hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */ + move16(); + } + + hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 ); + update = 0; + + move16(); + move16(); + + IF( EQ_32( st->core_brate, SID_2k40 ) ) + { + test(); + test(); + test(); + IF( st->hDtxEnc->first_CNG == 0 ) + { + update = 1; + move16(); + } + ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) + { + hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); + update = 1; + move16(); + move16(); + } + ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) + { + update = 1; + move16(); + } + ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) + { + update = 1; + move16(); + } + ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) + { + update = 1; + move16(); + } + ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) + { + update = 1; + move16(); + } + + hTdCngEnc->last_SID_bwidth = st->bwidth; + move16(); + } + + /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */ + test(); + test(); + if ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_32( st->core_brate, SID_2k40 ) ) + { + update = 1; + move16(); + } + + IF( EQ_16( update, 1 ) ) + { + hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; + hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; + hTdCngEnc->shb_NO_DATA_cnt = 0; + move16(); + move16(); + move16(); + } + + return ( update ); +} diff --git a/lib_enc/cod2t32.c b/lib_enc/cod2t32.c deleted file mode 100644 index 167c70dbf..000000000 --- a/lib_enc/cod2t32.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/cod4t64.c b/lib_enc/cod4t64.c deleted file mode 100644 index 9be976783..000000000 --- a/lib_enc/cod4t64.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ diff --git a/lib_enc/cod_ace.c b/lib_enc/cod_ace.c deleted file mode 100644 index 46d7a42d1..000000000 --- a/lib_enc/cod_ace.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "prot.h" -#include -#include "options.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c deleted file mode 100644 index 88e028c86..000000000 --- a/lib_enc/cod_tcx.c +++ /dev/null @@ -1,869 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_rom_com.h" -#include "ivas_rom_com_fx.h" -#include "prot_fx_enc.h" -#include "prot_fx.h" -#include "ivas_prot_fx.h" - - -/*-------------------------------------------------------------------* - * TNSAnalysisStereo() - * - * - *-------------------------------------------------------------------*/ - -#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 ) -#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 ) -#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ( 25165824 ) -void TNSAnalysisStereo_fx( - Encoder_State **sts, /* i : encoder state handle */ - Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum Qx*/ - const Word16 bWhitenedDomain, /* i : whitened domain flag Q0*/ - Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm Q0*/ - Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame Q0*/ - Word16 param_core[][NB_DIV * NPRM_DIV], /* o : TNS parameters Q0*/ - const Word16 mct_on /* i : flag mct block (1) or stereo (0) Q0*/ -) -{ - Word16 ch, k, L_spec, L_frame, nSubframes, iFilter; - Word32 *spectrum_fx; - Encoder_State *st = NULL; - TCX_ENC_HANDLE hTcxEnc = NULL; - Word16 individual_decision[NB_DIV]; - Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; - move32(); - Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; - move16(); - Word16 sum_e = 0; - move16(); - individual_decision[0] = 0; - move16(); - individual_decision[1] = 0; - move16(); - L_spec = -1; - move16(); - L_frame = -1; - move16(); - - /* TNS filter analysis, loop over channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - continue; - } - - hTcxEnc = st->hTcxEnc; - - IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - - FOR( k = 0; k < nSubframes; k++ ) - { - /* reset tns on whitened domain flag */ - IF( !bWhitenedDomain ) - { - hTcxEnc->bTnsOnWhithenedSpectra[k] = 0; - move16(); - hTcxEnc->fUseTns[k] = 0; - move16(); - } - test(); - test(); - IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - spectrum_fx = hTcxEnc->spectrum_fx[k]; - - L_frame = hTcxEnc->L_frameTCX; - move16(); - st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; - L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; - move16(); - /*-----------------------------------------------------------* - * Temporal Noise Shaping analysis * - *-----------------------------------------------------------*/ - - IF( EQ_16( hTcxEnc->transform_type[k], TCX_5 ) ) - { - /* rearrange LF sub-window lines prior to TNS analysis & filtering */ - tcx5TnsGrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), spectrum_fx ); - } - - /* WMOPS: All initializations are either for safety or static (tables) and thus not to be counted */ - - ResetTnsData( &hTcxEnc->tnsData[k] ); - IF( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 ) - { - BREAK; - } - - CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k] ); - } - } - } - - IF( !mct_on ) - { - /* TNS decision */ - /* if framing differs between channels, keep the filter decision per channel */ - test(); - test(); - IF( ( NE_16( sts[0]->hTcxEnc->transform_type[0], sts[1]->hTcxEnc->transform_type[0] ) && - NE_16( sts[0]->hTcxEnc->transform_type[1], sts[1]->hTcxEnc->transform_type[1] ) ) || - NE_16( sts[0]->hTcxCfg->fIsTNSAllowed, sts[1]->hTcxCfg->fIsTNSAllowed ) ) - { - individual_decision[0] = individual_decision[1] = 1; - move16(); - move16(); - } - ELSE IF( bWhitenedDomain ) - { - IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - FOR( k = 0; k < nSubframes; k++ ) - { - IF( NE_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - individual_decision[k] = 1; - move16(); - } - } - } - - /* framing equal, check for similar filters, if very similar (also indicator for and M signal), - * use at least the same decision, maybe use the same filter - */ - { - Word8 isTCX10; - - IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - isTCX10 = 0; - } - ELSE - { - nSubframes = NB_DIV; - isTCX10 = 1; - } - move16(); - move16(); - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - test(); - IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - Word32 maxPredGain_fx = -ONE_IN_Q31; - move32(); - Word16 maxPredGain_e = 0; - move16(); - sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; - sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; - - FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - STnsFilter *pFilter[2]; - struct TnsParameters const *pTnsParameters[2]; - pFilter[0] = sts[0]->hTcxEnc->tnsData[k].filter + iFilter; - pTnsParameters[0] = sts[0]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - pFilter[1] = sts[1]->hTcxEnc->tnsData[k].filter + iFilter; - pTnsParameters[1] = sts[1]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - - /* if prediction gain and avgSqrCoef are both close we are pretty sure the filters are quite similar, use the avg of - * both filters for the decision - */ - - meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) - { - maxPredictionGain_fx = meanPredictionGain_fx; - maxPredictionGain_e = meanPredictionGain_e; - move32(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); - if ( flag_1 < 0 ) - { - flag_1 = 0; - move16(); - } - test(); - test(); - test(); - IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && - flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) - { - pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ - move32(); - move32(); - pFilter[0]->predictionGain_e = pFilter[1]->predictionGain_e = meanPredictionGain_e; /* more TNS filter sync at 48kbps */ - move16(); - move16(); - pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ - move16(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - IF( flag && - ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) - { - - Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 - Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) - { - maxPredGain_fx = meanPredictionGain_fx; - maxPredGain_e = meanPredictionGain_e; - move32(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - test(); - IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) - { - test(); - test(); - test(); - IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( meanLtpGain_fx, 19660 /* 0.6 in Q15*/ ) ) - { - - sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter[0]->order != 0 ) - { - pFilter[0]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - IF( pFilter[1]->order != 0 ) - { - pFilter[1]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[1]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - Word16 maxEnergyChange_fx; - maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ); - - IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) ) - { - sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter[0]->order != 0 ) - { - pFilter[0]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - IF( pFilter[1]->order != 0 ) - { - pFilter[1]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[1]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_OFF; - move16(); - pFilter[1]->filterType = TNS_FILTER_OFF; - move16(); - } - } - } - ELSE IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 && sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ - { - pFilter[0]->filterType = TNS_FILTER_ON_ZERO; - pFilter[1]->filterType = TNS_FILTER_ON_ZERO; - move16(); - move16(); - sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - } - ELSE IF( NE_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) /* sanity check */ - { - assert( 0 ); - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_OFF; - move16(); - pFilter[1]->filterType = TNS_FILTER_OFF; - move16(); - } - - test(); - test(); - IF( EQ_16( pFilter[0]->filterType, TNS_FILTER_ON ) && EQ_16( pFilter[1]->filterType, TNS_FILTER_ON ) && LT_32( sts[0]->element_brate, IVAS_80k ) ) - { - Word16 tmpIntValue = 0; - move16(); - Word16 tmpCoeff[TNS_MAX_FILTER_ORDER]; - Word16 i, maxOrder = s_max( pFilter[0]->order, pFilter[1]->order ); - - set16_fx( tmpCoeff, 0, TNS_MAX_FILTER_ORDER ); - FOR( i = 0; i < maxOrder; i++ ) - { - tmpIntValue = s_max( tmpIntValue, abs_s( sub( pFilter[0]->coefIndex[i], pFilter[1]->coefIndex[i] ) ) ); - } - - IF( EQ_16( tmpIntValue, 1 ) ) /* the TNS coefficients are sufficiently similar to equalize the two filters */ - { - FOR( i = maxOrder - 1; i >= 0; i-- ) - { - IF( LT_16( abs_s( pFilter[0]->coefIndex[i] ), abs_s( pFilter[1]->coefIndex[i] ) ) ) - { - tmpCoeff[i] = pFilter[0]->coefIndex[i]; - } - ELSE - { - tmpCoeff[i] = pFilter[1]->coefIndex[i]; - } - move16(); - IF( ( tmpIntValue > 0 ) && ( tmpCoeff[i] == 0 ) ) - { - maxOrder = sub( maxOrder, 1 ); - } - ELSE - { - tmpIntValue = 0; - move16(); - } - } - /* make sure that maxOrder is non zero and not all coefficients are zero (could happen in rare cases) */ - IF( maxOrder > 0 ) - { - FOR( i = TNS_MAX_FILTER_ORDER - 1; i >= 0; i-- ) - { - pFilter[0]->coefIndex[i] = pFilter[1]->coefIndex[i] = tmpCoeff[i]; - move16(); - move16(); - } - - pFilter[0]->order = pFilter[1]->order = maxOrder; - move16(); - move16(); - } - } - } - } - ELSE - { - individual_decision[k] = 1; - move16(); - } - } - - IF( individual_decision[k] == 0 ) - { - IF( ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[0]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[0]->hTcxEnc->fUseTns[k] = 0; - } - move16(); - - IF( ( sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[1]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[1]->hTcxEnc->fUseTns[k] = 0; - } - move16(); - } - ELSE - { - sts[0]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[1]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[0]->hTcxEnc->fUseTns[k] = 0; - move16(); - sts[1]->hTcxEnc->fUseTns[k] = 0; - move16(); - FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; - move16(); - sts[1]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; - move16(); - } - } - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - test(); - test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) - { - sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; - move16(); - sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; - move16(); - sts[0]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[1]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[0]->hTcxEnc->fUseTns[k] = 0; - move16(); - sts[1]->hTcxEnc->fUseTns[k] = 0; - move16(); - FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - ClearTnsFilterCoefficients( sts[0]->hTcxEnc->tnsData[k].filter + iFilter ); - ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); - } - } - // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) - { - maxPredictionGain_fx = maxPredGain_fx; - maxPredictionGain_e = maxPredGain_e; - move32(); - move16(); - } - } - } - } - } - - /* individual decision for each channel */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - CONTINUE; - } - - Word8 isTCX10; - - IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - isTCX10 = 0; - } - ELSE - { - nSubframes = NB_DIV; - isTCX10 = 1; - } - move16(); - move16(); - - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - test(); - test(); - IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && - ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - Word32 maxPredGain_fx = -ONE_IN_Q31; // Q31 - move32(); - Word16 maxPredGain_e = 0; - move16(); - sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; - - FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - STnsFilter *pFilter; - struct TnsParameters const *pTnsParameters; - pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; - pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - - // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF( flag < 0 ) - { - maxPredGain_fx = pFilter->predictionGain32; - move32(); - maxPredGain_e = pFilter->predictionGain_e; - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) - { - test(); - test(); - IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 /*.6f in Q15*/ ) ) - { - sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter->order != 0 ) - { - pFilter->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); - - IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) ) - { - sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter->order != 0 ) - { - pFilter->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - pFilter->filterType = TNS_FILTER_OFF; - move16(); - } - } - } - ELSE IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ - { - pFilter->filterType = TNS_FILTER_ON_ZERO; - move16(); - sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - } - ELSE - { - pFilter->filterType = TNS_FILTER_OFF; - move16(); - } - } - - IF( ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[ch]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[ch]->hTcxEnc->fUseTns[k] = 0; - } - move16(); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - test(); - IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) - { - sts[ch]->hTcxEnc->fUseTns[k] = 0; - move16(); - sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; - move16(); - sts[ch]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); - sts[ch]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; - move16(); - } - } - // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) - { - maxPredictionGain_fx = maxPredGain_fx; - maxPredictionGain_e = maxPredGain_e; - move32(); - move16(); - } - } - } - } - - - /* we have the decision, set filter data accordingly */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - CONTINUE; - } - - IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; - - FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - STnsFilter *pFilter; - pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; - SWITCH( pFilter->filterType ) - { - case TNS_FILTER_OFF: - ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); - BREAK; - case TNS_FILTER_ON_ZERO: - /* Since TNS filter of order 0 is not allowed we have to signal in the stream filter of order 1 with the 0th coefficient equal to 0 */ - ClearTnsFilterCoefficients( pFilter ); - pFilter->order = 1; - move16(); - BREAK; - } - } - } - } - } - - /* Apply filters, loop over channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - CONTINUE; - } - - IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - test(); - test(); - test(); - IF( bWhitenedDomain && ( ch > 0 ) && /* test for identical TNS filter data in both channels */ - sts[0]->hTcxCfg->fIsTNSAllowed && sts[0]->hTcxEnc->fUseTns[k] && - sts[1]->hTcxCfg->fIsTNSAllowed && sts[1]->hTcxEnc->fUseTns[k] ) - { - Word16 equalFilterData = 0; - move16(); - test(); - test(); - if ( EQ_16( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, sts[1]->hTcxCfg->pCurrentTnsConfig->nMaxFilters ) && - EQ_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) && - EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) - { - equalFilterData = 1; - move16(); - } - - IF( equalFilterData ) - { - FOR( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - const Word16 *pDataCh0 = (const Word16 *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter]; - const Word16 *pDataCh1 = (const Word16 *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter]; - Word16 i = 2 + TNS_MAX_FILTER_ORDER; /* excl. informative float data. Portable? */ - - move16(); - test(); - WHILE( ( i >= 0 ) && EQ_16( pDataCh0[i], pDataCh1[i] ) ) - { - test(); - i = sub( i, 1 ); - } - IF( i >= 0 ) - { - equalFilterData = 0; - move16(); - BREAK; - } - } - IF( equalFilterData ) - { - st->hTcxEnc->tnsData[k].nFilters = i_mult( st->hTcxEnc->tnsData[k].nFilters, -1 ); /* signals common TNS */ - move16(); - } - } - } - test(); - test(); - IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || st->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; - move16(); - spectrum_fx = st->hTcxEnc->spectrum_fx[k]; - /* If TNS should be used then get the residual after applying it inplace in the spectrum */ - IF( st->hTcxEnc->fUseTns[k] ) - { - st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[st->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; - - ApplyTnsFilter( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], spectrum_fx, 1 ); - } - - IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) - { - tcx5TnsUngrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), st->hTcxEnc->spectrum_fx[k], ENC ); - } - - st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k]; - move16(); - EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k ); - } - - IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) - { - tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, st->hTcxEnc->spectrum_fx[k] ); - tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, mdst_spectrum_fx[ch][k] ); - } - } - } - return; -} diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index b2fe04ce1..bf20608b0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -26,6 +26,9 @@ #include "debug.h" #endif +#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 ) +#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 ) +#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ( 25165824 ) /* Up to the Autocorrelation it is the same code as in GetMDCT, with the difference in the parameters in the call to tcx_windowing_analysis */ void HBAutocorrelation_fx( @@ -5363,3 +5366,721 @@ void InternalTCXDecoder_fx( return; } + + +void TNSAnalysisStereo_fx( + Encoder_State **sts, /* i : encoder state handle */ + Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum Qx*/ + const Word16 bWhitenedDomain, /* i : whitened domain flag Q0*/ + Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm Q0*/ + Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame Q0*/ + Word16 param_core[][NB_DIV * NPRM_DIV], /* o : TNS parameters Q0*/ + const Word16 mct_on /* i : flag mct block (1) or stereo (0) Q0*/ +) +{ + Word16 ch, k, L_spec, L_frame, nSubframes, iFilter; + Word32 *spectrum_fx; + Encoder_State *st = NULL; + TCX_ENC_HANDLE hTcxEnc = NULL; + Word16 individual_decision[NB_DIV]; + Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; + move16(); + + individual_decision[0] = 0; + move16(); + individual_decision[1] = 0; + move16(); + L_spec = -1; + move16(); + L_frame = -1; + move16(); + + /* TNS filter analysis, loop over channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + st = sts[ch]; + IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + continue; + } + + hTcxEnc = st->hTcxEnc; + + IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + + FOR( k = 0; k < nSubframes; k++ ) + { + /* reset tns on whitened domain flag */ + IF( !bWhitenedDomain ) + { + hTcxEnc->bTnsOnWhithenedSpectra[k] = 0; + move16(); + hTcxEnc->fUseTns[k] = 0; + move16(); + } + test(); + test(); + IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + spectrum_fx = hTcxEnc->spectrum_fx[k]; + + L_frame = hTcxEnc->L_frameTCX; + move16(); + st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; + L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; + move16(); + /*-----------------------------------------------------------* + * Temporal Noise Shaping analysis * + *-----------------------------------------------------------*/ + + IF( EQ_16( hTcxEnc->transform_type[k], TCX_5 ) ) + { + /* rearrange LF sub-window lines prior to TNS analysis & filtering */ + tcx5TnsGrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), spectrum_fx ); + } + + /* WMOPS: All initializations are either for safety or static (tables) and thus not to be counted */ + + ResetTnsData( &hTcxEnc->tnsData[k] ); + IF( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 ) + { + BREAK; + } + + CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k] ); + } + } + } + + IF( !mct_on ) + { + /* TNS decision */ + /* if framing differs between channels, keep the filter decision per channel */ + test(); + test(); + IF( ( NE_16( sts[0]->hTcxEnc->transform_type[0], sts[1]->hTcxEnc->transform_type[0] ) && + NE_16( sts[0]->hTcxEnc->transform_type[1], sts[1]->hTcxEnc->transform_type[1] ) ) || + NE_16( sts[0]->hTcxCfg->fIsTNSAllowed, sts[1]->hTcxCfg->fIsTNSAllowed ) ) + { + individual_decision[0] = individual_decision[1] = 1; + move16(); + move16(); + } + ELSE IF( bWhitenedDomain ) + { + IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + IF( NE_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + individual_decision[k] = 1; + move16(); + } + } + } + + /* framing equal, check for similar filters, if very similar (also indicator for and M signal), + * use at least the same decision, maybe use the same filter + */ + { + Word8 isTCX10; + + IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + isTCX10 = 0; + } + ELSE + { + nSubframes = NB_DIV; + isTCX10 = 1; + } + move16(); + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + test(); + IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + Word32 maxPredGain_fx = -ONE_IN_Q23; + move16(); + sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; + sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; + + FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + STnsFilter *pFilter[2]; + struct TnsParameters const *pTnsParameters[2]; + pFilter[0] = sts[0]->hTcxEnc->tnsData[k].filter + iFilter; + pTnsParameters[0] = sts[0]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; + pFilter[1] = sts[1]->hTcxEnc->tnsData[k].filter + iFilter; + pTnsParameters[1] = sts[1]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; + + /* if prediction gain and avgSqrCoef are both close we are pretty sure the filters are quite similar, use the avg of + * both filters for the decision + */ + + meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 + maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 + + test(); + test(); + test(); + IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && + GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + { + pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + move16(); + move16(); + } + test(); + IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && + ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) + { + + Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 + Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); + maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + test(); + test(); + IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + { + test(); + test(); + test(); + IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( meanLtpGain_fx, 19660 /* 0.6 in Q15*/ ) ) + { + + sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter[0]->order != 0 ) + { + pFilter[0]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + IF( pFilter[1]->order != 0 ) + { + pFilter[1]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[1]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + Word16 maxEnergyChange_fx; + maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ); + + IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) ) + { + sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter[0]->order != 0 ) + { + pFilter[0]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + IF( pFilter[1]->order != 0 ) + { + pFilter[1]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[1]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_OFF; + move16(); + pFilter[1]->filterType = TNS_FILTER_OFF; + move16(); + } + } + } + ELSE IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 && sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ + { + pFilter[0]->filterType = TNS_FILTER_ON_ZERO; + pFilter[1]->filterType = TNS_FILTER_ON_ZERO; + move16(); + move16(); + sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + } + ELSE IF( NE_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) /* sanity check */ + { + assert( 0 ); + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_OFF; + move16(); + pFilter[1]->filterType = TNS_FILTER_OFF; + move16(); + } + + test(); + test(); + IF( EQ_16( pFilter[0]->filterType, TNS_FILTER_ON ) && EQ_16( pFilter[1]->filterType, TNS_FILTER_ON ) && LT_32( sts[0]->element_brate, IVAS_80k ) ) + { + Word16 tmpIntValue = 0; + move16(); + Word16 tmpCoeff[TNS_MAX_FILTER_ORDER]; + Word16 i, maxOrder = s_max( pFilter[0]->order, pFilter[1]->order ); + + set16_fx( tmpCoeff, 0, TNS_MAX_FILTER_ORDER ); + FOR( i = 0; i < maxOrder; i++ ) + { + tmpIntValue = s_max( tmpIntValue, abs_s( sub( pFilter[0]->coefIndex[i], pFilter[1]->coefIndex[i] ) ) ); + } + + IF( EQ_16( tmpIntValue, 1 ) ) /* the TNS coefficients are sufficiently similar to equalize the two filters */ + { + FOR( i = maxOrder - 1; i >= 0; i-- ) + { + IF( LT_16( abs_s( pFilter[0]->coefIndex[i] ), abs_s( pFilter[1]->coefIndex[i] ) ) ) + { + tmpCoeff[i] = pFilter[0]->coefIndex[i]; + } + ELSE + { + tmpCoeff[i] = pFilter[1]->coefIndex[i]; + } + move16(); + IF( ( tmpIntValue > 0 ) && ( tmpCoeff[i] == 0 ) ) + { + maxOrder = sub( maxOrder, 1 ); + } + ELSE + { + tmpIntValue = 0; + move16(); + } + } + /* make sure that maxOrder is non zero and not all coefficients are zero (could happen in rare cases) */ + IF( maxOrder > 0 ) + { + FOR( i = TNS_MAX_FILTER_ORDER - 1; i >= 0; i-- ) + { + pFilter[0]->coefIndex[i] = pFilter[1]->coefIndex[i] = tmpCoeff[i]; + move16(); + move16(); + } + + pFilter[0]->order = pFilter[1]->order = maxOrder; + move16(); + move16(); + } + } + } + } + ELSE + { + individual_decision[k] = 1; + move16(); + } + } + + IF( individual_decision[k] == 0 ) + { + IF( ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 ) ) + { + sts[0]->hTcxEnc->fUseTns[k] = 1; + } + ELSE + { + sts[0]->hTcxEnc->fUseTns[k] = 0; + } + move16(); + + IF( ( sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) ) + { + sts[1]->hTcxEnc->fUseTns[k] = 1; + } + ELSE + { + sts[1]->hTcxEnc->fUseTns[k] = 0; + } + move16(); + } + ELSE + { + sts[0]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[1]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[0]->hTcxEnc->fUseTns[k] = 0; + move16(); + sts[1]->hTcxEnc->fUseTns[k] = 0; + move16(); + FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; + move16(); + sts[1]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; + move16(); + } + } + test(); + test(); + test(); + IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + { + sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; + move16(); + sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; + move16(); + sts[0]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[1]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[0]->hTcxEnc->fUseTns[k] = 0; + move16(); + sts[1]->hTcxEnc->fUseTns[k] = 0; + move16(); + FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + ClearTnsFilterCoefficients( sts[0]->hTcxEnc->tnsData[k].filter + iFilter ); + ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); + } + } + maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + } + } + } + } + + /* individual decision for each channel */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + CONTINUE; + } + + Word8 isTCX10; + + IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + isTCX10 = 0; + } + ELSE + { + nSubframes = NB_DIV; + isTCX10 = 1; + } + move16(); + move16(); + + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + test(); + test(); + IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && + ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 + move16(); + sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; + + FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + STnsFilter *pFilter; + struct TnsParameters const *pTnsParameters; + pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; + pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; + + maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + test(); + IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + { + test(); + test(); + IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 /*.6f in Q15*/ ) ) + { + sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter->order != 0 ) + { + pFilter->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); + + IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) ) + { + sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter->order != 0 ) + { + pFilter->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + pFilter->filterType = TNS_FILTER_OFF; + move16(); + } + } + } + ELSE IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ + { + pFilter->filterType = TNS_FILTER_ON_ZERO; + move16(); + sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + } + ELSE + { + pFilter->filterType = TNS_FILTER_OFF; + move16(); + } + } + + IF( ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ) + { + sts[ch]->hTcxEnc->fUseTns[k] = 1; + } + ELSE + { + sts[ch]->hTcxEnc->fUseTns[k] = 0; + } + move16(); + test(); + test(); + IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + { + sts[ch]->hTcxEnc->fUseTns[k] = 0; + move16(); + sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; + move16(); + sts[ch]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); + sts[ch]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; + move16(); + } + } + maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + } + } + } + + + /* we have the decision, set filter data accordingly */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + IF( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + CONTINUE; + } + + IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; + + FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + STnsFilter *pFilter; + pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; + SWITCH( pFilter->filterType ) + { + case TNS_FILTER_OFF: + ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); + BREAK; + case TNS_FILTER_ON_ZERO: + /* Since TNS filter of order 0 is not allowed we have to signal in the stream filter of order 1 with the 0th coefficient equal to 0 */ + ClearTnsFilterCoefficients( pFilter ); + pFilter->order = 1; + move16(); + BREAK; + } + } + } + } + } + + /* Apply filters, loop over channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + st = sts[ch]; + IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + CONTINUE; + } + + IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + test(); + test(); + test(); + IF( bWhitenedDomain && ( ch > 0 ) && /* test for identical TNS filter data in both channels */ + sts[0]->hTcxCfg->fIsTNSAllowed && sts[0]->hTcxEnc->fUseTns[k] && + sts[1]->hTcxCfg->fIsTNSAllowed && sts[1]->hTcxEnc->fUseTns[k] ) + { + Word16 equalFilterData = 0; + move16(); + test(); + test(); + if ( EQ_16( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, sts[1]->hTcxCfg->pCurrentTnsConfig->nMaxFilters ) && + EQ_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) && + EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + { + equalFilterData = 1; + move16(); + } + + IF( equalFilterData ) + { + FOR( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + const Word16 *pDataCh0 = (const Word16 *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter]; + const Word16 *pDataCh1 = (const Word16 *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter]; + Word16 i = 2 + TNS_MAX_FILTER_ORDER; /* excl. informative float data. Portable? */ + + move16(); + test(); + WHILE( ( i >= 0 ) && EQ_16( pDataCh0[i], pDataCh1[i] ) ) + { + test(); + i = sub( i, 1 ); + } + IF( i >= 0 ) + { + equalFilterData = 0; + move16(); + BREAK; + } + } + IF( equalFilterData ) + { + st->hTcxEnc->tnsData[k].nFilters = i_mult( st->hTcxEnc->tnsData[k].nFilters, -1 ); /* signals common TNS */ + move16(); + } + } + } + test(); + test(); + IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || st->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; + move16(); + spectrum_fx = st->hTcxEnc->spectrum_fx[k]; + /* If TNS should be used then get the residual after applying it inplace in the spectrum */ + IF( st->hTcxEnc->fUseTns[k] ) + { + st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[st->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; + + ApplyTnsFilter( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], spectrum_fx, 1 ); + } + + IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) + { + tcx5TnsUngrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), st->hTcxEnc->spectrum_fx[k], ENC ); + } + + st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k]; + move16(); + EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k ); + } + + IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) + { + tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, st->hTcxEnc->spectrum_fx[k] ); + tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, mdst_spectrum_fx[ch][k] ); + } + } + } + return; +} diff --git a/lib_enc/cod_uv.c b/lib_enc/cod_uv.c deleted file mode 100644 index 9e7ce9558..000000000 --- a/lib_enc/cod_uv.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/comvad_decision.c b/lib_enc/comvad_decision.c deleted file mode 100644 index efb9c1d78..000000000 --- a/lib_enc/comvad_decision.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/cor_shif.c b/lib_enc/cor_shif.c deleted file mode 100644 index 0e2004abf..000000000 --- a/lib_enc/cor_shif.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/core_enc_2div.c b/lib_enc/core_enc_2div.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_enc/core_enc_2div.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c deleted file mode 100644 index b0a1c880e..000000000 --- a/lib_enc/core_enc_init.c +++ /dev/null @@ -1,1055 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "options_warnings.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" - -#include "prot_fx.h" - -/*-----------------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------------*/ -static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); -static void init_core_sig_ana_ivas_fx( Encoder_State *st ); -static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); -/*-----------------------------------------------------------------------* - * init_coder_ace_plus() - * - * Initialization of state variables - *-----------------------------------------------------------------------*/ -void init_coder_ace_plus_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ -#ifdef FIX_920_IGF_INIT_ERROR - const Word32 igf_brate, /* i : IGF configuration bitrate */ -#endif - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - Word16 L_frame_old; /*keep old frame size for switching */ - Word16 L_subfr; - - /* Bitrate */ - st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); - move16(); - - /* Core Sampling Rate */ - st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); - st->fscale = sr2fscale_fx( st->sr_core ); - move32(); - move16(); - - /* Narrowband? */ - IF( EQ_16( st->bwidth, NB ) ) - { - st->narrowBand = 1; - move16(); - } - ELSE - { - st->narrowBand = 0; - move16(); - } - - /* Core Framing */ - L_frame_old = st->last_L_frame; - move16(); - st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - st->L_frame_past = -1; - move16(); - - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - - IF( st->ini_frame == 0 ) - { - set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); - hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2; - hTcxEnc->q_Txnq = Q15; - move16(); - hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14; - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) - { - st->nb_subfr = NB_SUBFR16k; - move16(); - } - ELSE - { - st->nb_subfr = NB_SUBFR; - move16(); - } - L_subfr = idiv1616( st->L_frame, st->nb_subfr ); - - /* Core Lookahead */ - st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); - st->encoderLookahead_FB = NS2SA_FX2( st->input_Fs, ACELP_LOOK_NS ); - move16(); - move16(); - - IF( st->ini_frame == 0 ) - { - st->acelpFramesCount = 0; - move16(); - st->prevTempFlatness_fx = 128 /*1.0f Q7*/; - move16(); - } - - /* Initialize TBE */ - IF( st->hBWE_TD != NULL ) - { - st->hBWE_TD->prev_coder_type = GENERIC; - move16(); - set16_fx( st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); - st->hBWE_TD->prev_tilt_para_fx = 0; - move16(); - set16_fx( st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); - } - - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); - test(); - /* Initialize LPC analysis/quantization */ - IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 ) - { - st->lpcQuantization = 1; - move16(); - } - ELSE - { - st->lpcQuantization = 0; - move16(); - } - - st->next_force_safety_net = 0; - move16(); - test(); - test(); - IF( ( NE_16( st->last_L_frame, st->L_frame ) ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) || ( EQ_16( st->last_core, HQ_CORE ) ) ) - { - set16_fx( st->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - } - - /* Initialize IGF */ - if ( st->hIGFEnc != NULL ) - { - st->hIGFEnc->infoStopFrequency = -1; - move16(); - } - - test(); - IF( st->igf && st->hIGFEnc != NULL ) - { -#ifdef FIX_920_IGF_INIT_ERROR - IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); -#else - IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); -#endif - } - ELSE IF( st->hIGFEnc != NULL ) - { - st->hIGFEnc->infoTotalBitsWritten = 0; - move16(); - st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; - move16(); - } - - /* Initialize Core Signal Analysis Module */ - init_core_sig_ana_ivas_fx( st ); - - - /* Initialize TCX */ - IF( hTcxEnc != NULL ) - { - init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); - } - - /* Initialize Signal Buffers */ - init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); - - /* Initialize ACELP */ - - init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate ); - - if ( st->ini_frame == 0 ) - { - st->tec_tfa = 0; - move16(); - } - - IF( st->hTECEnc != NULL ) - { - resetTecEnc_Fx( st->hTECEnc, st->tec_tfa ); - } - - test(); - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) - { - st->tec_tfa = 1; - move16(); - } - ELSE - { - st->tec_tfa = 0; - move16(); - } - - st->tec_flag = 0; - move16(); - st->tfa_flag = 0; - move16(); - - test(); - test(); - test(); - IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) - { - st->glr = 1; - move16(); - } - ELSE - { - st->glr = 0; - move16(); - } - - st->glr_reset = 0; - move16(); - - /* Initialize ACELP/TCX Modes */ - init_modes_ivas_fx( st, last_total_brate ); - - /* Adaptive BPF */ - set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); - set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); - - IF( st->ini_frame == 0 ) - { - st->Q_max_enc[0] = 15; - move16(); - st->Q_max_enc[1] = 15; - move16(); - } - - IF( GE_32( st->total_brate, HQ_48k ) ) - { - st->enablePlcWaveadjust = 1; - move16(); - } - ELSE - { - st->enablePlcWaveadjust = 0; - move16(); - } - - IF( st->hPlcExt ) - { - init_PLC_enc_fx( st->hPlcExt, st->sr_core ); - } - - st->glr_idx[0] = 0; - move16(); - st->glr_idx[1] = 0; - move16(); - st->mean_gc[0] = 0; - move16(); - st->mean_gc[1] = 0; - move16(); - st->prev_lsf4_mean = 0; - move16(); - st->last_stab_fac = 0; - move16(); - - return; -} - -/*-----------------------------------------------------------------------* - * init_tcx() - * - * Initialization of TCX - *-----------------------------------------------------------------------*/ - - -static void init_tcx_ivas_fx( - Encoder_State *st, - const Word16 L_frame_old, - const Word32 total_brate, - const Word32 last_total_brate, - const Word16 MCT_flag ) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; - hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; - st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; - move16(); - move16(); - - init_tcx_cfg_ivas_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, - st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, - st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); - - /* Init TCX target bits correction factor */ - hTcxEnc->tcx_target_bits_fac = 0x4000; /*1.0f in 1Q14*/ - move16(); - hTcxEnc->measuredBwRatio = 0x4000; /*1.0f in 1Q14*/ - move16(); - hTcxEnc->noiseTiltFactor = 9216; /*0.5625f in 1Q14*/ - move16(); - hTcxEnc->noiseLevelMemory_cnt = 0; - move16(); - - set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); - set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); - - /* TCX-LTP */ - hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); - move16(); - - test(); - test(); - test(); - test(); - IF( st->ini_frame == 0 ) - { - hTcxEnc->tcxltp_pitch_int_past = st->L_frame; - hTcxEnc->tcxltp_pitch_fr_past = 0; - hTcxEnc->tcxltp_gain_past = 0; - hTcxEnc->tcxltp_norm_corr_past = 0; - hTcxEnc->tcxltp_norm_corr_mem = 0; - hTcxEnc->kernel_switch_corr_past = 0; - hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ - hTcxEnc->enc_ste_pre_corr_past = 0; - hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ - hTcxEnc->tcxltp_on_mem = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - } - ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) && - ( EQ_32( total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) - { - Word16 pitres, pitres_old; - Word16 pit, pit_old; - - pitres_old = 4; - move16(); - if ( EQ_16( 160, shr( L_frame_old, sub( 7, norm_s( L_frame_old ) ) ) ) ) /*if ( L_frame_old%160==0 )*/ - { - pitres_old = 6; - move16(); - } - - /*pit_old = (float)st->tcxltp_pitch_int_past + (float)st->tcxltp_pitch_fr_past/(float)pitres_old;*/ - pit_old = add( hTcxEnc->tcxltp_pitch_int_past, mult_r( hTcxEnc->tcxltp_pitch_fr_past, div_s( 1, pitres_old ) ) ); - - pitres = 4; - move16(); - if ( EQ_16( 160, shr( st->L_frame, sub( 7, norm_s( st->L_frame ) ) ) ) ) /*if ( st->L_frame%160==0 )*/ - { - pitres = 6; - move16(); - } - - /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ - pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); - /* Note : the saturation here that can happens when FS == 32kHz*/ - /* assert(pit <= st->L_frame);*/ - - hTcxEnc->tcxltp_pitch_int_past = pit; - move16(); - hTcxEnc->tcxltp_pitch_fr_past = i_mult2( sub( pit, hTcxEnc->tcxltp_pitch_int_past ), pitres ); - move16(); - } - - hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); - move16(); - - return; -} - -/*-----------------------------------------------------------------------* - * init_sig_buffers() - * - * Initialization of signal buffers - *-----------------------------------------------------------------------*/ -/*copy of evs function since it was static */ -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) -{ - - LPD_state_HANDLE hLPDmem = st->hLPDmem; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Encoder Past Samples at encoder-sampling-rate */ - st->encoderPastSamples_enc = shr( imult1616( st->L_frame, 9 ), 4 ); - move16(); - - /* Initialize Signal Buffers and Pointers at encoder-sampling-rate */ - IF( st->ini_frame == 0 ) - { - set16_fx( st->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc = 0; - move16(); - set16_fx( st->buf_speech_enc_pe, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc_pe = 0; - move16(); - if ( hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->buf_speech_ltp, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - hTcxEnc->exp_buf_speech_ltp = 0; - move16(); - } - set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */ - st->exp_buf_wspeech_enc = 0; - move16(); - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) - { - lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); - test(); - IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) /* condition should be checked again */ - { - Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame ); - Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) - Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) - hTcxEnc->exp_buf_speech_ltp = s_max( hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); - move16(); - } - - // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); - st->exp_buf_wspeech_enc = st->exp_old_wsp; - move16(); - - /*Resamp buffers needed only for ACELP*/ - test(); - test(); - IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) - { - // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); - move16(); - } - ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) - { - lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); - move16(); - } - - st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; - move16(); - st->exp_mem_preemph_enc = st->exp_buf_speech_enc; - move16(); - st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 - move16(); - } - /*coming from TCXonly modes*/ - ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) - { - - Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); - // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - st->exp_buf_wspeech_enc = st->exp_old_wsp; - move16(); /*Resamp buffers needed only for ACELP*/ - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - } - hLPDmem->mem_w0 = 0; - move16(); - st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 - move16(); - } - } - - st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; - st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; - if ( hTcxEnc != NULL ) - { - hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; - } - - IF( st->hTcxEnc != NULL ) - { - st->hTcxEnc->new_speech_TCX = st->input_buff_fx + Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ); - st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB; - } - st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; - st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; - - if ( hTcxEnc != NULL ) - { - hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc; - } - - IF( st->element_mode > EVS_MONO ) - { - st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR; - } - ELSE - { - st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_subfr; - } - - test(); - test(); - IF( st->ini_frame == 0 || NE_16( st->L_frame, L_frame_old ) || EQ_16( st->last_codec_mode, MODE1 ) ) - { - set16_fx( st->buf_synth, 0, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); - } - - st->synth = st->buf_synth + st->L_frame + L_subfr; - - - return; -} - -/*-----------------------------------------------------------------------* - * init_core_sig_ana() - * - * - *-----------------------------------------------------------------------*/ -static void init_core_sig_ana_ivas_fx( Encoder_State *st ) -{ - - /* Pre-emphasis factor and memory */ - - st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ - move16(); - IF( LT_16( st->fscale, ( 16000 * FSCALE_DENOM ) / 12800 ) ) - { - st->preemph_fac = PREEMPH_FAC; /*WB*/ - move16(); - } - ELSE IF( LT_16( st->fscale, ( 24000 * FSCALE_DENOM ) / 12800 ) ) - { - st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ - move16(); - } - - st->gamma = GAMMA1; - move16(); - st->inv_gamma = GAMMA1_INV; - move16(); - IF( EQ_32( st->sr_core, 16000 ) ) - { - st->gamma = GAMMA16k; - move16(); - st->inv_gamma = GAMMA16k_INV; - move16(); - } - - - st->min_band = 1; - move16(); - st->max_band = 16; - move16(); - - IF( st->narrowBand == 0 ) - { - st->min_band = 0; - move16(); - st->max_band = 19; - move16(); - } - - - return; -} -/*-----------------------------------------------------------------------* - * init_acelp() - * - * - *-----------------------------------------------------------------------*/ -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) -{ - Word16 mem_syn_r_size_old; - Word16 mem_syn_r_size_new; - LPD_state_HANDLE hLPDmem = st->hLPDmem; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Init pitch lag */ - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - /* TCX LTP ana always runs @12.8kHz */ - st->pit_res_max = initPitchLagParameters( 12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); - move16(); - } - ELSE - { - st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); - move16(); - } - - /* Init LPDmem */ - IF( st->ini_frame == 0 ) - { - IF( hLPDmem != NULL ) - { - set16_fx( hLPDmem->syn, 0, 1 + M ); - set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); - } - - IF( st->hTcxEnc != NULL ) - { - set16_fx( st->hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); - st->hTcxEnc->q_Txnq = Q15; - move16(); - st->hTcxEnc->acelp_zir = st->hTcxEnc->Txnq + shr( st->L_frame, 1 ); - } - } - ELSE /*Rate switching*/ - { - IF( st->last_core == ACELP_CORE ) - { - lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) ); - } - ELSE - { - lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); - } - hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 ); - - /* Rate switching */ - IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) - { - IF( hLPDmem != NULL ) - { - Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); - set16_fx( hLPDmem->syn, 0, M ); - hLPDmem->q_lpd_syn = Q15; - move16(); - } - IF( st->hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); - st->hTcxEnc->q_Txnq = Q15; - move16(); - } - } - - /*AMR-WBIO->MODE2*/ - IF( EQ_16( st->last_core, AMR_WB_CORE ) ) - { - st->next_force_safety_net = 1; - move16(); - st->last_core = ACELP_CORE; - move16(); - } - /*HQ-CORE->MODE2*/ - test(); - IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) - { - /*Reset of ACELP memories*/ - st->next_force_safety_net = 1; - move16(); - st->rate_switching_reset = 1; - move16(); - IF( hLPDmem != NULL ) - { - hLPDmem->tilt_code = TILT_CODE; - move16(); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - set16_fx( hLPDmem->syn, 0, 1 + M ); - hLPDmem->q_lpd_syn = Q15; - move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); - hLPDmem->mem_w0 = 0; - move16(); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn2, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); - } - - /* unquantized LPC*/ - test(); - test(); - test(); - IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) - { - Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); - } - } - Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ - IF( st->tcxonly == 0 ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - ELSE - { - E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); - } - st->last_core = TCX_20_CORE; - move16(); - - st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ - st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - move16(); - /*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/ - set16_fx( hTcxEnc->old_out_fx, 0, st->L_frame ); - } - ELSE - { - test(); - test(); - test(); - test(); - IF( ( NE_16( st->L_frame, L_frame_old ) ) && ( LE_16( st->L_frame, L_FRAME16k ) ) && ( LE_16( L_frame_old, L_FRAME16k ) ) ) - { - /* convert quantized LSP vector */ - st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); - move16(); - IF( st->tcxonly == 0 ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - ELSE - { - E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); - } - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); - } - ELSE - { - Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); - } - - - /*Mem of deemphasis stay unchanged : hLPDmem->syn*/ - IF( hLPDmem != NULL ) - { - synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC ); - Word16 tmp, A[M + 1], Ap[M + 1], tmp_buf[M + 1]; - /* Update wsyn */ - /* lsp2a_stab( st->lsp_old, A, M ); */ - E_LPC_f_lsp_a_conversion( st->lsp_old_fx, A, M ); - weight_a_fx( A, Ap, GAMMA1, M ); - tmp = 0; - move16(); - tmp_buf[0] = 0; - move16(); - Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); - deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); - Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); - hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); - move16(); - } - } - ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) ) - { - /*Partial reset of ACELP memories*/ - st->next_force_safety_net = 1; - move16(); - st->rate_switching_reset = 1; - move16(); - - /*reset partly some memories*/ - IF( hLPDmem != NULL ) - { - hLPDmem->tilt_code = TILT_CODE; - move16(); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); - /*Resamp others memories*/ - /*Size of LPC syn memory*/ - /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ - mem_syn_r_size_old = shr( L_frame_old, 4 ); - mem_syn_r_size_new = shr( st->L_frame, 4 ); - - lerp( hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - Copy( hLPDmem->mem_syn_r + L_SYN_MEM - M, hLPDmem->mem_syn, M ); - Copy( hLPDmem->mem_syn, hLPDmem->mem_syn2, M ); - - /*Untouched memories : hLPDmem->syn & hLPDmem->mem_w0*/ - hLPDmem->mem_w0 = 0; - move16(); - } - /* unquantized LPC*/ - Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); - } - Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ - IF( st->tcxonly == 0 ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - ELSE - { - E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); - } - } - ELSE IF( !st->tcxonly && EQ_16( st->L_frame, L_FRAME16k ) && GT_32( st->last_total_brate, ACELP_32k ) ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - } - } - - test(); - test(); - if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && st->ini_frame != 0 ) - { - st->rate_switching_reset = 1; - move16(); - } - - /* Post-processing */ - /*EVS specific*/ - /* hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0;*/ - /*------------*/ - - if ( hLPDmem != NULL ) - { - hLPDmem->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - - FOR( Word16 i = 2; i < 8; i++ ) - { - hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - hLPDmem->gc_threshold = 0; - move16(); - } - - /* Pulse Search configuration */ - st->acelp_autocorr = 1; - move16(); - - /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ - test(); - test(); - if ( ( LE_32( st->total_brate, ACELP_9k60 ) || EQ_16( st->rf_mode, 1 ) ) && ( EQ_32( st->sr_core, 12800 ) ) ) - { - st->acelp_autocorr = 0; - move16(); - } - - - /*BPF parameters for adjusting gain in function of background noise*/ - IF( EQ_16( st->codec_mode, MODE2 ) ) - { - st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); - move32(); - st->pst_lp_ener_fx = 0; - move16(); - IF( EQ_16( st->last_codec_mode, MODE1 ) ) - { - st->mem_bpf_fx.lp_error = 0; - move32(); - st->pst_mem_deemp_err_fx = 0; - move16(); - } - } - - return; -} -/*-----------------------------------------------------------------------* - * init_modes() - * - * - *-----------------------------------------------------------------------*/ - -static void init_modes_ivas_fx( - Encoder_State *st, - const Word32 last_total_brate ) -{ - Word8 n; - Word32 tmp32; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Restrict ACE/TCX20/TCX10 mode */ - move16(); - st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, st->Opt_AMR_WB ); - move16(); - st->acelpEnabled = 0; - move16(); - st->tcx20Enabled = 0; - move16(); - st->tcx10Enabled = 0; - - if ( EQ_16( s_and( st->restrictedMode, 1 ), 1 ) ) - { - st->acelpEnabled = 1; - move16(); - } - if ( EQ_16( s_and( st->restrictedMode, 2 ), 2 ) ) - { - st->tcx20Enabled = 1; - move16(); - } - if ( EQ_16( s_and( st->restrictedMode, 4 ), 4 ) ) - { - st->tcx10Enabled = 1; - move16(); - } - - /* TCX mode (TCX20 TCX10_10 or NO_TCX) */ - if ( st->hTcxEnc != NULL ) - { - hTcxEnc->tcxMode = NO_TCX; - move16(); - } - - /* Bits Budget */ - /*st->bits_frame_nominal = (int)( (float)st->L_frame * (float)FSCALE_DENOM * (float)st->bitrate / ( (float)st->fscale * 12800.0f ) );*/ - /*st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f );*/ - /*328 = 0.010009765625 in 0Q15*/ - /* st->bits_frame_nominal = extract_h(L_add(L_mult(div_l(L_mult(shl(st->L_frame,2),st->bitrate),st->fscale),328),16056)); */ - - /* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ); */ - tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */ - st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ - move16(); - - IF( st->Opt_AMR_WB ) - { - st->bits_frame = st->bits_frame_nominal; - move16(); - st->bits_frame_core = st->bits_frame_nominal; - move16(); - st->frame_size_index = 0; - move16(); - } - ELSE - { - FOR( n = 0; n < FRAME_SIZE_NB; n++ ) - { - IF( LT_32( n, FRAME_SIZE_NB - 1 ) ) - { - test(); - IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) && GT_32( FrameSizeConfig[n + 1].frame_bits, st->bits_frame_nominal ) ) - { - st->frame_size_index = n; - move16(); - st->bits_frame = st->bits_frame_nominal; - move16(); - st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); - move16(); - BREAK; - } - } - ELSE - { - IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) - { - st->frame_size_index = n; - move16(); - st->bits_frame = st->bits_frame_nominal; - move16(); - st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); - move16(); - BREAK; - } - } - } - } - - /* Reconfigure core */ - core_coder_reconfig_ivas_fx( st, last_total_brate ); - - - return; -} diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 1f5b0df1e..4151725af 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -28,6 +28,11 @@ static void init_core_sig_ana_fx( Encoder_State *st ); static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift ); static void init_modes_fx( Encoder_State *st, const Word32 Last_total_brate ); static void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ); +static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); +static void init_core_sig_ana_ivas_fx( Encoder_State *st ); +static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); /*-----------------------------------------------------------------------* * init_coder_ace_plus_fx() @@ -930,5 +935,1004 @@ static void init_modes_fx( core_coder_reconfig_fx( st, last_total_brate ); + return; +} + +/*-----------------------------------------------------------------------* + * init_coder_ace_plus() + * + * Initialization of state variables + *-----------------------------------------------------------------------*/ +void init_coder_ace_plus_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ +#ifdef FIX_920_IGF_INIT_ERROR + const Word32 igf_brate, /* i : IGF configuration bitrate */ +#endif + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + Word16 L_frame_old; /*keep old frame size for switching */ + Word16 L_subfr; + + /* Bitrate */ + st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); + move16(); + + /* Core Sampling Rate */ + st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); + st->fscale = sr2fscale_fx( st->sr_core ); + move32(); + move16(); + + /* Narrowband? */ + IF( EQ_16( st->bwidth, NB ) ) + { + st->narrowBand = 1; + move16(); + } + ELSE + { + st->narrowBand = 0; + move16(); + } + + /* Core Framing */ + L_frame_old = st->last_L_frame; + move16(); + st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + st->L_frame_past = -1; + move16(); + + IF( hTcxEnc != NULL ) + { + hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + + IF( st->ini_frame == 0 ) + { + set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); + hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2; + hTcxEnc->q_Txnq = Q15; + move16(); + hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14; + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) + { + st->nb_subfr = NB_SUBFR16k; + move16(); + } + ELSE + { + st->nb_subfr = NB_SUBFR; + move16(); + } + L_subfr = idiv1616( st->L_frame, st->nb_subfr ); + + /* Core Lookahead */ + st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); + st->encoderLookahead_FB = NS2SA_FX2( st->input_Fs, ACELP_LOOK_NS ); + move16(); + move16(); + + IF( st->ini_frame == 0 ) + { + st->acelpFramesCount = 0; + move16(); + st->prevTempFlatness_fx = 128 /*1.0f Q7*/; + move16(); + } + + /* Initialize TBE */ + IF( st->hBWE_TD != NULL ) + { + st->hBWE_TD->prev_coder_type = GENERIC; + move16(); + set16_fx( st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); + st->hBWE_TD->prev_tilt_para_fx = 0; + move16(); + set16_fx( st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); + } + + st->currEnergyHF_fx = 0; + move32(); + st->currEnergyHF_e_fx = 0; + move16(); + test(); + /* Initialize LPC analysis/quantization */ + IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 ) + { + st->lpcQuantization = 1; + move16(); + } + ELSE + { + st->lpcQuantization = 0; + move16(); + } + + st->next_force_safety_net = 0; + move16(); + test(); + test(); + IF( ( NE_16( st->last_L_frame, st->L_frame ) ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) || ( EQ_16( st->last_core, HQ_CORE ) ) ) + { + set16_fx( st->mem_MA_fx, 0, M ); + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + } + + /* Initialize IGF */ + if ( st->hIGFEnc != NULL ) + { + st->hIGFEnc->infoStopFrequency = -1; + move16(); + } + + test(); + IF( st->igf && st->hIGFEnc != NULL ) + { +#ifdef FIX_920_IGF_INIT_ERROR + IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#else + IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); +#endif + } + ELSE IF( st->hIGFEnc != NULL ) + { + st->hIGFEnc->infoTotalBitsWritten = 0; + move16(); + st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; + move16(); + } + + /* Initialize Core Signal Analysis Module */ + init_core_sig_ana_ivas_fx( st ); + + + /* Initialize TCX */ + IF( hTcxEnc != NULL ) + { + init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); + } + + /* Initialize Signal Buffers */ + init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); + + /* Initialize ACELP */ + + init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate ); + + if ( st->ini_frame == 0 ) + { + st->tec_tfa = 0; + move16(); + } + + IF( st->hTECEnc != NULL ) + { + resetTecEnc_Fx( st->hTECEnc, st->tec_tfa ); + } + + test(); + test(); + test(); + IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) + { + st->tec_tfa = 1; + move16(); + } + ELSE + { + st->tec_tfa = 0; + move16(); + } + + st->tec_flag = 0; + move16(); + st->tfa_flag = 0; + move16(); + + test(); + test(); + test(); + IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) + { + st->glr = 1; + move16(); + } + ELSE + { + st->glr = 0; + move16(); + } + + st->glr_reset = 0; + move16(); + + /* Initialize ACELP/TCX Modes */ + init_modes_ivas_fx( st, last_total_brate ); + + /* Adaptive BPF */ + set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); + set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); + + IF( st->ini_frame == 0 ) + { + st->Q_max_enc[0] = 15; + move16(); + st->Q_max_enc[1] = 15; + move16(); + } + + IF( GE_32( st->total_brate, HQ_48k ) ) + { + st->enablePlcWaveadjust = 1; + move16(); + } + ELSE + { + st->enablePlcWaveadjust = 0; + move16(); + } + + IF( st->hPlcExt ) + { + init_PLC_enc_fx( st->hPlcExt, st->sr_core ); + } + + st->glr_idx[0] = 0; + move16(); + st->glr_idx[1] = 0; + move16(); + st->mean_gc[0] = 0; + move16(); + st->mean_gc[1] = 0; + move16(); + st->prev_lsf4_mean = 0; + move16(); + st->last_stab_fac = 0; + move16(); + + return; +} + +/*-----------------------------------------------------------------------* + * init_tcx() + * + * Initialization of TCX + *-----------------------------------------------------------------------*/ + + +static void init_tcx_ivas_fx( + Encoder_State *st, + const Word16 L_frame_old, + const Word32 total_brate, + const Word32 last_total_brate, + const Word16 MCT_flag ) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ + hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; + hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; + move16(); + move16(); + + init_tcx_cfg_ivas_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, + st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, + st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); + + /* Init TCX target bits correction factor */ + hTcxEnc->tcx_target_bits_fac = 0x4000; /*1.0f in 1Q14*/ + move16(); + hTcxEnc->measuredBwRatio = 0x4000; /*1.0f in 1Q14*/ + move16(); + hTcxEnc->noiseTiltFactor = 9216; /*0.5625f in 1Q14*/ + move16(); + hTcxEnc->noiseLevelMemory_cnt = 0; + move16(); + + set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); + set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); + + /* TCX-LTP */ + hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); + move16(); + + test(); + test(); + test(); + test(); + IF( st->ini_frame == 0 ) + { + hTcxEnc->tcxltp_pitch_int_past = st->L_frame; + hTcxEnc->tcxltp_pitch_fr_past = 0; + hTcxEnc->tcxltp_gain_past = 0; + hTcxEnc->tcxltp_norm_corr_past = 0; + hTcxEnc->tcxltp_norm_corr_mem = 0; + hTcxEnc->kernel_switch_corr_past = 0; + hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ + hTcxEnc->enc_ste_pre_corr_past = 0; + hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ + hTcxEnc->tcxltp_on_mem = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) && + ( EQ_32( total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + { + Word16 pitres, pitres_old; + Word16 pit, pit_old; + + pitres_old = 4; + move16(); + if ( EQ_16( 160, shr( L_frame_old, sub( 7, norm_s( L_frame_old ) ) ) ) ) /*if ( L_frame_old%160==0 )*/ + { + pitres_old = 6; + move16(); + } + + /*pit_old = (float)st->tcxltp_pitch_int_past + (float)st->tcxltp_pitch_fr_past/(float)pitres_old;*/ + pit_old = add( hTcxEnc->tcxltp_pitch_int_past, mult_r( hTcxEnc->tcxltp_pitch_fr_past, div_s( 1, pitres_old ) ) ); + + pitres = 4; + move16(); + if ( EQ_16( 160, shr( st->L_frame, sub( 7, norm_s( st->L_frame ) ) ) ) ) /*if ( st->L_frame%160==0 )*/ + { + pitres = 6; + move16(); + } + + /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ + pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); + /* Note : the saturation here that can happens when FS == 32kHz*/ + /* assert(pit <= st->L_frame);*/ + + hTcxEnc->tcxltp_pitch_int_past = pit; + move16(); + hTcxEnc->tcxltp_pitch_fr_past = i_mult2( sub( pit, hTcxEnc->tcxltp_pitch_int_past ), pitres ); + move16(); + } + + hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); + move16(); + + return; +} + +/*-----------------------------------------------------------------------* + * init_sig_buffers() + * + * Initialization of signal buffers + *-----------------------------------------------------------------------*/ +/*copy of evs function since it was static */ +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) +{ + + LPD_state_HANDLE hLPDmem = st->hLPDmem; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Encoder Past Samples at encoder-sampling-rate */ + st->encoderPastSamples_enc = shr( imult1616( st->L_frame, 9 ), 4 ); + move16(); + + /* Initialize Signal Buffers and Pointers at encoder-sampling-rate */ + IF( st->ini_frame == 0 ) + { + set16_fx( st->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc = 0; + move16(); + set16_fx( st->buf_speech_enc_pe, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc_pe = 0; + move16(); + if ( hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->buf_speech_ltp, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + hTcxEnc->exp_buf_speech_ltp = 0; + move16(); + } + set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */ + st->exp_buf_wspeech_enc = 0; + move16(); + } + ELSE + { + test(); + test(); + test(); + test(); + test(); + IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + { + lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); + test(); + IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) /* condition should be checked again */ + { + Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame ); + Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) + Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) + hTcxEnc->exp_buf_speech_ltp = s_max( hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); + move16(); + } + + // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); + st->exp_buf_wspeech_enc = st->exp_old_wsp; + move16(); + + /*Resamp buffers needed only for ACELP*/ + test(); + test(); + IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) + { + // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + /* SCaling to common exponent*/ + Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) + Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) + Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) + st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); + move16(); + } + ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) + { + lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); + Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + /* SCaling to common exponent*/ + Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); + Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); + Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); + st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); + move16(); + } + + st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; + move16(); + st->exp_mem_preemph_enc = st->exp_buf_speech_enc; + move16(); + st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 + move16(); + } + /*coming from TCXonly modes*/ + ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) + { + + Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); + // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + st->exp_buf_wspeech_enc = st->exp_old_wsp; + move16(); /*Resamp buffers needed only for ACELP*/ + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); + } + hLPDmem->mem_w0 = 0; + move16(); + st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 + move16(); + } + } + + st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; + st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; + if ( hTcxEnc != NULL ) + { + hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; + } + + IF( st->hTcxEnc != NULL ) + { + st->hTcxEnc->new_speech_TCX = st->input_buff_fx + Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ); + st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB; + } + st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; + st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; + + if ( hTcxEnc != NULL ) + { + hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc; + } + + IF( st->element_mode > EVS_MONO ) + { + st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR; + } + ELSE + { + st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_subfr; + } + + test(); + test(); + IF( st->ini_frame == 0 || NE_16( st->L_frame, L_frame_old ) || EQ_16( st->last_codec_mode, MODE1 ) ) + { + set16_fx( st->buf_synth, 0, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); + } + + st->synth = st->buf_synth + st->L_frame + L_subfr; + + + return; +} + +/*-----------------------------------------------------------------------* + * init_core_sig_ana() + * + * + *-----------------------------------------------------------------------*/ +static void init_core_sig_ana_ivas_fx( Encoder_State *st ) +{ + + /* Pre-emphasis factor and memory */ + + st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ + move16(); + IF( LT_16( st->fscale, ( 16000 * FSCALE_DENOM ) / 12800 ) ) + { + st->preemph_fac = PREEMPH_FAC; /*WB*/ + move16(); + } + ELSE IF( LT_16( st->fscale, ( 24000 * FSCALE_DENOM ) / 12800 ) ) + { + st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ + move16(); + } + + st->gamma = GAMMA1; + move16(); + st->inv_gamma = GAMMA1_INV; + move16(); + IF( EQ_32( st->sr_core, 16000 ) ) + { + st->gamma = GAMMA16k; + move16(); + st->inv_gamma = GAMMA16k_INV; + move16(); + } + + + st->min_band = 1; + move16(); + st->max_band = 16; + move16(); + + IF( st->narrowBand == 0 ) + { + st->min_band = 0; + move16(); + st->max_band = 19; + move16(); + } + + + return; +} +/*-----------------------------------------------------------------------* + * init_acelp() + * + * + *-----------------------------------------------------------------------*/ +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) +{ + Word16 mem_syn_r_size_old; + Word16 mem_syn_r_size_new; + LPD_state_HANDLE hLPDmem = st->hLPDmem; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Init pitch lag */ + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + /* TCX LTP ana always runs @12.8kHz */ + st->pit_res_max = initPitchLagParameters( 12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + move16(); + } + ELSE + { + st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + move16(); + } + + /* Init LPDmem */ + IF( st->ini_frame == 0 ) + { + IF( hLPDmem != NULL ) + { + set16_fx( hLPDmem->syn, 0, 1 + M ); + set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); + } + + IF( st->hTcxEnc != NULL ) + { + set16_fx( st->hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); + st->hTcxEnc->q_Txnq = Q15; + move16(); + st->hTcxEnc->acelp_zir = st->hTcxEnc->Txnq + shr( st->L_frame, 1 ); + } + } + ELSE /*Rate switching*/ + { + IF( st->last_core == ACELP_CORE ) + { + lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) ); + } + ELSE + { + lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); + } + hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 ); + + /* Rate switching */ + IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) + { + IF( hLPDmem != NULL ) + { + Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); + set16_fx( hLPDmem->syn, 0, M ); + hLPDmem->q_lpd_syn = Q15; + move16(); + } + IF( st->hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); + st->hTcxEnc->q_Txnq = Q15; + move16(); + } + } + + /*AMR-WBIO->MODE2*/ + IF( EQ_16( st->last_core, AMR_WB_CORE ) ) + { + st->next_force_safety_net = 1; + move16(); + st->last_core = ACELP_CORE; + move16(); + } + /*HQ-CORE->MODE2*/ + test(); + IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) + { + /*Reset of ACELP memories*/ + st->next_force_safety_net = 1; + move16(); + st->rate_switching_reset = 1; + move16(); + IF( hLPDmem != NULL ) + { + hLPDmem->tilt_code = TILT_CODE; + move16(); + set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); + set16_fx( hLPDmem->syn, 0, 1 + M ); + hLPDmem->q_lpd_syn = Q15; + move16(); + hLPDmem->q_lpd_old_exc = Q15; + move16(); + hLPDmem->mem_w0 = 0; + move16(); + set16_fx( hLPDmem->mem_syn, 0, M ); + set16_fx( hLPDmem->mem_syn2, 0, M ); + hLPDmem->q_mem_syn = Q15; + move16(); + } + + /* unquantized LPC*/ + test(); + test(); + test(); + IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + { + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); + } + } + Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + st->last_core = TCX_20_CORE; + move16(); + + st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ + st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + move16(); + /*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/ + set16_fx( hTcxEnc->old_out_fx, 0, st->L_frame ); + } + ELSE + { + test(); + test(); + test(); + test(); + IF( ( NE_16( st->L_frame, L_frame_old ) ) && ( LE_16( st->L_frame, L_FRAME16k ) ) && ( LE_16( L_frame_old, L_FRAME16k ) ) ) + { + /* convert quantized LSP vector */ + st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); + move16(); + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); + } + ELSE + { + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); + } + + + /*Mem of deemphasis stay unchanged : hLPDmem->syn*/ + IF( hLPDmem != NULL ) + { + synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC ); + Word16 tmp, A[M + 1], Ap[M + 1], tmp_buf[M + 1]; + /* Update wsyn */ + /* lsp2a_stab( st->lsp_old, A, M ); */ + E_LPC_f_lsp_a_conversion( st->lsp_old_fx, A, M ); + weight_a_fx( A, Ap, GAMMA1, M ); + tmp = 0; + move16(); + tmp_buf[0] = 0; + move16(); + Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); + deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); + Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); + hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); + move16(); + } + } + ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) ) + { + /*Partial reset of ACELP memories*/ + st->next_force_safety_net = 1; + move16(); + st->rate_switching_reset = 1; + move16(); + + /*reset partly some memories*/ + IF( hLPDmem != NULL ) + { + hLPDmem->tilt_code = TILT_CODE; + move16(); + set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); + move16(); + hLPDmem->q_lpd_old_exc = Q15; + move16(); + /*Resamp others memories*/ + /*Size of LPC syn memory*/ + /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ + mem_syn_r_size_old = shr( L_frame_old, 4 ); + mem_syn_r_size_new = shr( st->L_frame, 4 ); + + lerp( hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + Copy( hLPDmem->mem_syn_r + L_SYN_MEM - M, hLPDmem->mem_syn, M ); + Copy( hLPDmem->mem_syn, hLPDmem->mem_syn2, M ); + + /*Untouched memories : hLPDmem->syn & hLPDmem->mem_w0*/ + hLPDmem->mem_w0 = 0; + move16(); + } + /* unquantized LPC*/ + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); + } + Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + } + ELSE IF( !st->tcxonly && EQ_16( st->L_frame, L_FRAME16k ) && GT_32( st->last_total_brate, ACELP_32k ) ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + } + } + + test(); + test(); + if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && st->ini_frame != 0 ) + { + st->rate_switching_reset = 1; + move16(); + } + + /* Post-processing */ + /*EVS specific*/ + /* hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); + set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); + hLPDmem->dm_fx.prev_state = 0;*/ + /*------------*/ + + if ( hLPDmem != NULL ) + { + hLPDmem->dm_fx.prev_state = 0; + move16(); /* This corresponds to st_fx->dispMem in FLP */ + hLPDmem->dm_fx.prev_gain_code = 0; + move32(); + + FOR( Word16 i = 2; i < 8; i++ ) + { + hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; + move16(); + } + hLPDmem->gc_threshold = 0; + move16(); + } + + /* Pulse Search configuration */ + st->acelp_autocorr = 1; + move16(); + + /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ + test(); + test(); + if ( ( LE_32( st->total_brate, ACELP_9k60 ) || EQ_16( st->rf_mode, 1 ) ) && ( EQ_32( st->sr_core, 12800 ) ) ) + { + st->acelp_autocorr = 0; + move16(); + } + + + /*BPF parameters for adjusting gain in function of background noise*/ + IF( EQ_16( st->codec_mode, MODE2 ) ) + { + st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); + move32(); + st->pst_lp_ener_fx = 0; + move16(); + IF( EQ_16( st->last_codec_mode, MODE1 ) ) + { + st->mem_bpf_fx.lp_error = 0; + move32(); + st->pst_mem_deemp_err_fx = 0; + move16(); + } + } + + return; +} +/*-----------------------------------------------------------------------* + * init_modes() + * + * + *-----------------------------------------------------------------------*/ + +static void init_modes_ivas_fx( + Encoder_State *st, + const Word32 last_total_brate ) +{ + Word8 n; + Word32 tmp32; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Restrict ACE/TCX20/TCX10 mode */ + move16(); + st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, st->Opt_AMR_WB ); + move16(); + st->acelpEnabled = 0; + move16(); + st->tcx20Enabled = 0; + move16(); + st->tcx10Enabled = 0; + + if ( EQ_16( s_and( st->restrictedMode, 1 ), 1 ) ) + { + st->acelpEnabled = 1; + move16(); + } + if ( EQ_16( s_and( st->restrictedMode, 2 ), 2 ) ) + { + st->tcx20Enabled = 1; + move16(); + } + if ( EQ_16( s_and( st->restrictedMode, 4 ), 4 ) ) + { + st->tcx10Enabled = 1; + move16(); + } + + /* TCX mode (TCX20 TCX10_10 or NO_TCX) */ + if ( st->hTcxEnc != NULL ) + { + hTcxEnc->tcxMode = NO_TCX; + move16(); + } + + /* Bits Budget */ + /*st->bits_frame_nominal = (int)( (float)st->L_frame * (float)FSCALE_DENOM * (float)st->bitrate / ( (float)st->fscale * 12800.0f ) );*/ + /*st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f );*/ + /*328 = 0.010009765625 in 0Q15*/ + /* st->bits_frame_nominal = extract_h(L_add(L_mult(div_l(L_mult(shl(st->L_frame,2),st->bitrate),st->fscale),328),16056)); */ + + /* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ); */ + tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */ + st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ + move16(); + + IF( st->Opt_AMR_WB ) + { + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = st->bits_frame_nominal; + move16(); + st->frame_size_index = 0; + move16(); + } + ELSE + { + FOR( n = 0; n < FRAME_SIZE_NB; n++ ) + { + IF( LT_32( n, FRAME_SIZE_NB - 1 ) ) + { + test(); + IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) && GT_32( FrameSizeConfig[n + 1].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = n; + move16(); + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); + move16(); + BREAK; + } + } + ELSE + { + IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = n; + move16(); + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); + move16(); + BREAK; + } + } + } + } + + /* Reconfigure core */ + core_coder_reconfig_ivas_fx( st, last_total_brate ); + + return; } diff --git a/lib_enc/core_enc_ol.c b/lib_enc/core_enc_ol.c deleted file mode 100644 index c282f7649..000000000 --- a/lib_enc/core_enc_ol.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c deleted file mode 100644 index 2bffd1728..000000000 --- a/lib_enc/core_enc_reconf.c +++ /dev/null @@ -1,346 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-----------------------------------------------------------------* - * Funtion core_coder_reconfig * - * ~~~~~~~~~~~~~~~~~~~ * - * - reconfig core coder when switching to another frame type * - *-----------------------------------------------------------------*/ - -void core_coder_reconfig_ivas_fx( - Encoder_State *st, - const int32_t last_total_brate ) -{ - Word16 i, bwidth, index; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - /*Configuration of ACELP*/ - BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); - - /*Configuration of partial copy*/ - IF( st->Opt_RF_ON ) - { - st->hRF->acelp_cfg_rf.mode_index = 1; - st->hRF->acelp_cfg_rf.midLpc = 0; - st->hRF->acelp_cfg_rf.midLpc_enable = 0; - st->hRF->acelp_cfg_rf.pre_emphasis = 0; - st->hRF->acelp_cfg_rf.formant_enh = 1; - st->hRF->acelp_cfg_rf.formant_tilt = 1; - st->hRF->acelp_cfg_rf.voice_tilt = 1; - st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; - st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - } - - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - st->nb_bits_header_tcx = 2; /* signal class */ - move16(); - } - ELSE IF( st->tcxonly ) - { - st->nb_bits_header_tcx = 1 + 1; /*TCX20/TCX10 + last_core*/ - st->nb_bits_header_tcx = add( st->nb_bits_header_tcx, 2 ); /* Siganl class*/ - move16(); - move16(); - } - ELSE - { - st->nb_bits_header_ace = 1 + 2 + 1; /*TCX/ACELP+coder_type + last_core*/ - st->nb_bits_header_tcx = st->nb_bits_header_ace; - move16(); - move16(); - - IF( st->hTcxCfg != NULL ) - { - IF( st->hTcxCfg->lfacNext <= 0 ) - { - st->nb_bits_header_ace = sub( st->nb_bits_header_ace, 1 ); /*No last_core*/ - move16(); - } - } - } - - - /*Switch off TCX or ACELP?*/ - IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) - { - st->acelpEnabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 1 ) ), 1 ) ); - st->tcx20Enabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 2 ) ), 2 ) ); - move16(); - move16(); - } - st->prevEnergyHF_fx = st->currEnergyHF_fx = 1073725440l /*65535.0f Q14*/; /* prevent block switch */ - st->currEnergyHF_e_fx = 17; - move32(); - move16(); - - /*Sanity check : don't need to be instrumented*/ - IF( st->tcxonly == 0 ) - { - assert( st->acelpEnabled || st->tcx20Enabled || st->frame_size_index == 0 ); - } - ELSE - { - assert( st->tcx10Enabled || st->tcx20Enabled || st->frame_size_index == 0 ); - } - - /* TCX-LTP */ - IF( st->hTcxEnc != NULL ) - { - hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); - move16(); - } - - /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ - - st->acelp_autocorr = 1; - move16(); - - test(); - if ( ( LE_32( st->total_brate, ACELP_9k60 ) ) && ( EQ_32( st->sr_core, INT_FS_12k8 ) ) ) - { - st->acelp_autocorr = 0; - move16(); - } - - /*Get bandwidth mode*/ - IF( st->narrowBand ) - { - move16(); - bwidth = NB; - } - ELSE IF( LE_32( st->sr_core, INT_FS_16k ) ) - { - move16(); - bwidth = WB; - } - ELSE - { - move16(); - bwidth = SWB; - } - - /*Scale TCX for non-active frames to adjust loudness with ACELP*/ - IF( st->hTcxCfg != NULL ) - { - st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/; - move16(); - - test(); - IF( LT_16( bwidth, 2 ) && ( st->tcxonly == 0 ) ) - { - /*const Word16 scaleTableSize = sizeof(scaleTcxTable) / sizeof(scaleTcxTable[0]);*/ - - FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) - { - - test(); - test(); - IF( EQ_16( bwidth, scaleTcxTable[i].bwmode ) && - GE_32( st->total_brate, scaleTcxTable[i].bitrateFrom ) && - LT_32( st->total_brate, scaleTcxTable[i].bitrateTo ) ) - { - if ( st->rf_mode ) - { - i = sub( i, 1 ); - } - move16(); - st->hTcxCfg->na_scale = scaleTcxTable[i].scale; - BREAK; - } - } - } - } - st->enableTcxLpc = 0; - move16(); - IF( GT_16( st->element_mode, IVAS_SCE ) ) - { - test(); - test(); - st->enableTcxLpc = ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR_CPE ) || st->rf_mode ) ); - move16(); - } - ELSE - { - test(); - test(); - if ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR ) || st->rf_mode != 0 ) ) - { - st->enableTcxLpc = 1; - move16(); - } - } - test(); - IF( st->ini_frame == 0 || EQ_16( st->last_codec_mode, MODE1 ) ) - { - st->envWeighted = 0; - move16(); - } - - test(); - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && - ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) - { - IF( st->tec_tfa == 0 ) - { - FOR( i = 0; i < MAX_TEC_SMOOTHING_DEG; i++ ) - { - st->hTECEnc->loBuffer[i] = 0; - move16(); - } - } - st->tec_tfa = 1; - move16(); - } - ELSE - { - st->tec_tfa = 0; - move16(); - } - - st->enablePlcWaveadjust = 0; - move16(); - if ( GE_32( st->total_brate, HQ_48k ) ) - { - st->enablePlcWaveadjust = 1; - move16(); - } - - - move16(); - st->glr = 0; - test(); - test(); - test(); - if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) ) - { - move16(); - st->glr = 1; - } - - IF( st->glr ) - { - move16(); - st->nb_bits_header_ace = add( st->nb_bits_header_ace, G_LPC_RECOVERY_BITS ); - } - IF( hTcxEnc != NULL ) - { - test(); - IF( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, WB ) ) - { - IF( st->rf_mode == 0 ) - { - index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index ) ); - } - ELSE - { - index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index - 1 ) ); - } - hTcxEnc->nmStartLine = startLineWB[index]; - move16(); - } - ELSE /* (st->bwidth == SWB || st->bwidth == FB) */ - { - IF( st->rf_mode == 0 ) - { - index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index ), 3 ) ); - } - ELSE - { - index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index - 1 ), 3 ) ); - } - test(); - test(); - if ( GE_32( st->total_brate, IVAS_96k ) && LE_32( st->total_brate, IVAS_192k ) && GT_16( st->element_mode, IVAS_SCE ) ) - { - index = sub( index, 1 ); - } - hTcxEnc->nmStartLine = startLineSWB[index]; - move16(); - test(); - test(); - IF( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) ) - { - hTcxEnc->nmStartLine = shr( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), 2 ); /* low-rate stereo is more efficient than dual-mono due to stereo processing */ - move16(); - } - } - } - - IF( hTcxEnc != NULL ) - { - test(); - test(); - test(); - test(); - test(); - IF( ( LT_32( st->total_brate, ACELP_24k40 ) ) && ( ( GT_32( st->total_brate, last_total_brate ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) - { - /* low-freq memQuantZeros_fx must be reset partially if bitrate increased */ - FOR( i = 0; i < hTcxEnc->nmStartLine; i++ ) - { - hTcxEnc->memQuantZeros[i] = 0; - move16(); - } - } - ELSE IF( ( GE_32( st->total_brate, ACELP_24k40 ) ) && ( LE_32( st->total_brate, ACELP_32k ) ) && ( GE_32( last_total_brate, ACELP_13k20 ) ) && ( LT_32( last_total_brate, ACELP_24k40 ) ) ) - { - FOR( i = 0; i < st->L_frame; i++ ) /* memQuantZeros_fx won't be updated */ - { - hTcxEnc->memQuantZeros[i] = 0; - move16(); - } - } - } -} diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c index 3140422be..3637dd53f 100644 --- a/lib_enc/core_enc_reconf_fx.c +++ b/lib_enc/core_enc_reconf_fx.c @@ -334,3 +334,307 @@ void core_coder_reconfig_fx( } } } + + +/*-----------------------------------------------------------------* + * Funtion core_coder_reconfig * + * ~~~~~~~~~~~~~~~~~~~ * + * - reconfig core coder when switching to another frame type * + *-----------------------------------------------------------------*/ + +void core_coder_reconfig_ivas_fx( + Encoder_State *st, + const int32_t last_total_brate ) +{ + Word16 i, bwidth, index; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + /*Configuration of ACELP*/ + BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); + + /*Configuration of partial copy*/ + IF( st->Opt_RF_ON ) + { + st->hRF->acelp_cfg_rf.mode_index = 1; + st->hRF->acelp_cfg_rf.midLpc = 0; + st->hRF->acelp_cfg_rf.midLpc_enable = 0; + st->hRF->acelp_cfg_rf.pre_emphasis = 0; + st->hRF->acelp_cfg_rf.formant_enh = 1; + st->hRF->acelp_cfg_rf.formant_tilt = 1; + st->hRF->acelp_cfg_rf.voice_tilt = 1; + st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; + st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->nb_bits_header_tcx = 2; /* signal class */ + move16(); + } + ELSE IF( st->tcxonly ) + { + st->nb_bits_header_tcx = 1 + 1; /*TCX20/TCX10 + last_core*/ + st->nb_bits_header_tcx = add( st->nb_bits_header_tcx, 2 ); /* Siganl class*/ + move16(); + move16(); + } + ELSE + { + st->nb_bits_header_ace = 1 + 2 + 1; /*TCX/ACELP+coder_type + last_core*/ + st->nb_bits_header_tcx = st->nb_bits_header_ace; + move16(); + move16(); + + IF( st->hTcxCfg != NULL ) + { + IF( st->hTcxCfg->lfacNext <= 0 ) + { + st->nb_bits_header_ace = sub( st->nb_bits_header_ace, 1 ); /*No last_core*/ + move16(); + } + } + } + + + /*Switch off TCX or ACELP?*/ + IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) + { + st->acelpEnabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 1 ) ), 1 ) ); + st->tcx20Enabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 2 ) ), 2 ) ); + move16(); + move16(); + } + st->prevEnergyHF_fx = st->currEnergyHF_fx = 1073725440l /*65535.0f Q14*/; /* prevent block switch */ + st->currEnergyHF_e_fx = 17; + move32(); + move16(); + + /*Sanity check : don't need to be instrumented*/ + IF( st->tcxonly == 0 ) + { + assert( st->acelpEnabled || st->tcx20Enabled || st->frame_size_index == 0 ); + } + ELSE + { + assert( st->tcx10Enabled || st->tcx20Enabled || st->frame_size_index == 0 ); + } + + /* TCX-LTP */ + IF( st->hTcxEnc != NULL ) + { + hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); + move16(); + } + + /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ + + st->acelp_autocorr = 1; + move16(); + + test(); + if ( ( LE_32( st->total_brate, ACELP_9k60 ) ) && ( EQ_32( st->sr_core, INT_FS_12k8 ) ) ) + { + st->acelp_autocorr = 0; + move16(); + } + + /*Get bandwidth mode*/ + IF( st->narrowBand ) + { + move16(); + bwidth = NB; + } + ELSE IF( LE_32( st->sr_core, INT_FS_16k ) ) + { + move16(); + bwidth = WB; + } + ELSE + { + move16(); + bwidth = SWB; + } + + /*Scale TCX for non-active frames to adjust loudness with ACELP*/ + IF( st->hTcxCfg != NULL ) + { + st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/; + move16(); + + test(); + IF( LT_16( bwidth, 2 ) && ( st->tcxonly == 0 ) ) + { + /*const Word16 scaleTableSize = sizeof(scaleTcxTable) / sizeof(scaleTcxTable[0]);*/ + + FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) + { + + test(); + test(); + IF( EQ_16( bwidth, scaleTcxTable[i].bwmode ) && + GE_32( st->total_brate, scaleTcxTable[i].bitrateFrom ) && + LT_32( st->total_brate, scaleTcxTable[i].bitrateTo ) ) + { + if ( st->rf_mode ) + { + i = sub( i, 1 ); + } + move16(); + st->hTcxCfg->na_scale = scaleTcxTable[i].scale; + BREAK; + } + } + } + } + st->enableTcxLpc = 0; + move16(); + IF( GT_16( st->element_mode, IVAS_SCE ) ) + { + test(); + test(); + st->enableTcxLpc = ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR_CPE ) || st->rf_mode ) ); + move16(); + } + ELSE + { + test(); + test(); + if ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR ) || st->rf_mode != 0 ) ) + { + st->enableTcxLpc = 1; + move16(); + } + } + test(); + IF( st->ini_frame == 0 || EQ_16( st->last_codec_mode, MODE1 ) ) + { + st->envWeighted = 0; + move16(); + } + + test(); + test(); + test(); + IF( EQ_16( st->bwidth, SWB ) && + ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) + { + IF( st->tec_tfa == 0 ) + { + FOR( i = 0; i < MAX_TEC_SMOOTHING_DEG; i++ ) + { + st->hTECEnc->loBuffer[i] = 0; + move16(); + } + } + st->tec_tfa = 1; + move16(); + } + ELSE + { + st->tec_tfa = 0; + move16(); + } + + st->enablePlcWaveadjust = 0; + move16(); + if ( GE_32( st->total_brate, HQ_48k ) ) + { + st->enablePlcWaveadjust = 1; + move16(); + } + + + move16(); + st->glr = 0; + test(); + test(); + test(); + if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) ) + { + move16(); + st->glr = 1; + } + + IF( st->glr ) + { + move16(); + st->nb_bits_header_ace = add( st->nb_bits_header_ace, G_LPC_RECOVERY_BITS ); + } + IF( hTcxEnc != NULL ) + { + test(); + IF( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, WB ) ) + { + IF( st->rf_mode == 0 ) + { + index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index ) ); + } + ELSE + { + index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index - 1 ) ); + } + hTcxEnc->nmStartLine = startLineWB[index]; + move16(); + } + ELSE /* (st->bwidth == SWB || st->bwidth == FB) */ + { + IF( st->rf_mode == 0 ) + { + index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index ), 3 ) ); + } + ELSE + { + index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index - 1 ), 3 ) ); + } + test(); + test(); + if ( GE_32( st->total_brate, IVAS_96k ) && LE_32( st->total_brate, IVAS_192k ) && GT_16( st->element_mode, IVAS_SCE ) ) + { + index = sub( index, 1 ); + } + hTcxEnc->nmStartLine = startLineSWB[index]; + move16(); + test(); + test(); + IF( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) ) + { + hTcxEnc->nmStartLine = shr( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), 2 ); /* low-rate stereo is more efficient than dual-mono due to stereo processing */ + move16(); + } + } + } + + IF( hTcxEnc != NULL ) + { + test(); + test(); + test(); + test(); + test(); + IF( ( LT_32( st->total_brate, ACELP_24k40 ) ) && ( ( GT_32( st->total_brate, last_total_brate ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) + { + /* low-freq memQuantZeros_fx must be reset partially if bitrate increased */ + FOR( i = 0; i < hTcxEnc->nmStartLine; i++ ) + { + hTcxEnc->memQuantZeros[i] = 0; + move16(); + } + } + ELSE IF( ( GE_32( st->total_brate, ACELP_24k40 ) ) && ( LE_32( st->total_brate, ACELP_32k ) ) && ( GE_32( last_total_brate, ACELP_13k20 ) ) && ( LT_32( last_total_brate, ACELP_24k40 ) ) ) + { + FOR( i = 0; i < st->L_frame; i++ ) /* memQuantZeros_fx won't be updated */ + { + hTcxEnc->memQuantZeros[i] = 0; + move16(); + } + } + } +} diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c deleted file mode 100644 index f2375fb50..000000000 --- a/lib_enc/core_enc_switch.c +++ /dev/null @@ -1,302 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" - - -/*-------------------------------------------------------------------* - * core_coder_mode_switch() - * - * - *-------------------------------------------------------------------*/ -void core_coder_mode_switch_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word32 last_total_brate, /* i : last bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - Word16 i, fscale, switchWB; - Word32 sr_core; - Word16 bSwitchFromAmrwbIO; - Word16 tcxonly_tmp, exp_res; - - switchWB = 0; - move16(); - bSwitchFromAmrwbIO = 0; - move16(); - exp_res = 0; - move16(); - - - if ( EQ_16( st->last_core, AMR_WB_CORE ) ) - { - bSwitchFromAmrwbIO = 1; - move16(); - } - - /* force active frame for the first frame when switching from high bitrates when DTX is enabled*/ - sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); - - fscale = sr2fscale_fx( sr_core ); - if ( EQ_16( st->last_codec_mode, MODE1 ) ) - { - switchWB = 1; /*force init when coming from MODE1*/ - move16(); - } - - tcxonly_tmp = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); - - if ( NE_32( tcxonly_tmp, st->tcxonly ) ) - { - switchWB = 1; /*force init when coming from MODE1*/ - move16(); - } - - test(); - test(); - IF( EQ_32( fscale, st->fscale ) && !bSwitchFromAmrwbIO && !switchWB ) - { - st->sr_core = sr_core; - move16(); - Word16 tmp = BASOP_Util_Divide3232_Scale( sr_core, FRAMES_PER_SEC, &exp_res ); - st->L_frame = shr( tmp, sub( 15, exp_res ) ); // Q0 - move16(); - - st->tcxonly = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); - move16(); - - Word16 exp_tmp1 = 0; - move16(); - Word16 tmp1 = BASOP_Util_Divide1616_Scale( ONE_IN_Q9, 128, &exp_tmp1 ); - - Word16 exp_tmp2 = 0; - move16(); - Word16 tmp2 = BASOP_Util_Divide3232_Scale( st->total_brate, 100, &exp_tmp2 ); - - Word16 exp_tmp3 = 0; - move16(); - Word16 tmp3 = BASOP_Util_Divide3232_Scale( st->L_frame, st->fscale, &exp_tmp3 ); - - Word32 tmp4 = L_mult0( tmp1, tmp2 ); // exp_tmp1 + exp_tmp2 - Word32 tmp5 = L_shl( Mpy_32_16_1( tmp4, tmp3 ), 1 ); // exp_tmp1 + exp_tmp2 + exp_tmp3 - st->bits_frame_nominal = extract_l( L_shr( tmp5, sub( 31, ( add( add( exp_tmp1, exp_tmp2 ), exp_tmp3 ) ) ) ) ); - move16(); - st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); - move16(); - /* switch IGF configuration */ - IF( st->igf ) - { - IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); - } - st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth ); - move16(); - - st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth ); - move16(); - if ( st->tcxonly ) - { - st->hTcxCfg->tcxRateLoopOpt = 2; - move16(); - } - else - { - st->hTcxCfg->tcxRateLoopOpt = 0; - move16(); - } - if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - st->hTcxCfg->tcxRateLoopOpt = 3; - move16(); - } - st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode ); - st->hTcxCfg->resq = getResq( st->total_brate ); - hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); - test(); - if ( st->hTcxCfg->resq && !st->tcxonly ) - { - st->hTcxCfg->tcxRateLoopOpt = 1; - move16(); - } - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode ); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - - IF( st->hTcxCfg->fIsTNSAllowed ) - { - InitTnsConfigs_ivas_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); - - SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, st->element_mode == IVAS_CPE_MDCT ); - } - - IF( EQ_16( st->bwidth, NB ) ) - { - st->narrowBand = 1; - st->min_band = 1; - st->max_band = 16; - } - ELSE - { - st->narrowBand = 0; - st->min_band = 0; - st->max_band = 19; - } - - move16(); - move16(); - move16(); - - FOR( i = 0; i < FRAME_SIZE_NB; i++ ) - { - IF( EQ_32( FrameSizeConfig[i].frame_bits, st->bits_frame_nominal ) ) - { - st->frame_size_index = i; - st->bits_frame = FrameSizeConfig[i].frame_bits; - st->bits_frame_core = FrameSizeConfig[i].frame_net_bits; - move16(); - move16(); - move16(); - BREAK; - } - } - - st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 ); - move16(); - core_coder_reconfig_ivas_fx( st, last_total_brate ); - } - ELSE - { - st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); - move16(); - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - } - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); - Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); - st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); - move16(); - shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); - Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); -#ifdef FIX_920_IGF_INIT_ERROR - init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag ); -#else - init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag ); -#endif - if ( st->hLPDmem != NULL ) - { - st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; - move16(); - } - } - - test(); - IF( st->igf && st->hBWE_TD != NULL ) - { - /* reset TBE */ - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->bwidth, WB ) && NE_16( st->last_extl, WB_TBE ) ) || - ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || - ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) - { - TBEreset_enc_fx( st, st->bwidth ); - } - ELSE - { - set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - } - } - test(); - IF( st->envWeighted && !st->enableTcxLpc ) - { - /* Unweight the envelope */ - st->inv_gamma = BASOP_Util_Divide1616_Scale( MAX16B, st->gamma, &exp_res ); - move16(); - st->inv_gamma = shr( st->inv_gamma, sub( Q1, exp_res ) ); /* Q14 */ - move16(); - E_LPC_lsp_unweight( st->lsp_old_fx, st->lsp_old_fx, st->lsf_old_fx, st->inv_gamma, M ); - st->envWeighted = 0; - move16(); - } - - IF( GE_32( st->total_brate, HQ_48k ) ) - { - st->enablePlcWaveadjust = 1; - move16(); - } - ELSE - { - st->enablePlcWaveadjust = 0; - move16(); - } - - test(); - test(); - if ( ( GT_32( last_total_brate, HQ_32k ) || EQ_16( st->last_codec_mode, MODE1 ) ) && ( st->element_mode == EVS_MONO ) ) - { - st->glr_reset = 1; - move16(); - } - - return; -} diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index 1096cfb49..82bb5fca9 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -223,3 +223,262 @@ void core_coder_mode_switch_fx( st->glr_reset = 1; } } + + +/*-------------------------------------------------------------------* + * core_coder_mode_switch() + * + * + *-------------------------------------------------------------------*/ +void core_coder_mode_switch_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word32 last_total_brate, /* i : last bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + Word16 i, fscale, switchWB; + Word32 sr_core; + Word16 bSwitchFromAmrwbIO; + Word16 tcxonly_tmp, exp_res; + + switchWB = 0; + move16(); + bSwitchFromAmrwbIO = 0; + move16(); + exp_res = 0; + move16(); + + + if ( EQ_16( st->last_core, AMR_WB_CORE ) ) + { + bSwitchFromAmrwbIO = 1; + move16(); + } + + /* force active frame for the first frame when switching from high bitrates when DTX is enabled*/ + sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); + + fscale = sr2fscale_fx( sr_core ); + if ( EQ_16( st->last_codec_mode, MODE1 ) ) + { + switchWB = 1; /*force init when coming from MODE1*/ + move16(); + } + + tcxonly_tmp = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); + + if ( NE_32( tcxonly_tmp, st->tcxonly ) ) + { + switchWB = 1; /*force init when coming from MODE1*/ + move16(); + } + + test(); + test(); + IF( EQ_32( fscale, st->fscale ) && !bSwitchFromAmrwbIO && !switchWB ) + { + st->sr_core = sr_core; + move16(); + Word16 tmp = BASOP_Util_Divide3232_Scale( sr_core, FRAMES_PER_SEC, &exp_res ); + st->L_frame = shr( tmp, sub( 15, exp_res ) ); // Q0 + move16(); + + st->tcxonly = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); + move16(); + + Word16 exp_tmp1 = 0; + move16(); + Word16 tmp1 = BASOP_Util_Divide1616_Scale( ONE_IN_Q9, 128, &exp_tmp1 ); + + Word16 exp_tmp2 = 0; + move16(); + Word16 tmp2 = BASOP_Util_Divide3232_Scale( st->total_brate, 100, &exp_tmp2 ); + + Word16 exp_tmp3 = 0; + move16(); + Word16 tmp3 = BASOP_Util_Divide3232_Scale( st->L_frame, st->fscale, &exp_tmp3 ); + + Word32 tmp4 = L_mult0( tmp1, tmp2 ); // exp_tmp1 + exp_tmp2 + Word32 tmp5 = L_shl( Mpy_32_16_1( tmp4, tmp3 ), 1 ); // exp_tmp1 + exp_tmp2 + exp_tmp3 + st->bits_frame_nominal = extract_l( L_shr( tmp5, sub( 31, ( add( add( exp_tmp1, exp_tmp2 ), exp_tmp3 ) ) ) ) ); + move16(); + st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); + move16(); + /* switch IGF configuration */ + IF( st->igf ) + { + IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); + } + st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth ); + move16(); + + st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth ); + move16(); + if ( st->tcxonly ) + { + st->hTcxCfg->tcxRateLoopOpt = 2; + move16(); + } + else + { + st->hTcxCfg->tcxRateLoopOpt = 0; + move16(); + } + if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->hTcxCfg->tcxRateLoopOpt = 3; + move16(); + } + st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode ); + st->hTcxCfg->resq = getResq( st->total_brate ); + hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); + test(); + if ( st->hTcxCfg->resq && !st->tcxonly ) + { + st->hTcxCfg->tcxRateLoopOpt = 1; + move16(); + } + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode ); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + + IF( st->hTcxCfg->fIsTNSAllowed ) + { + InitTnsConfigs_ivas_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); + + SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, st->element_mode == IVAS_CPE_MDCT ); + } + + IF( EQ_16( st->bwidth, NB ) ) + { + st->narrowBand = 1; + st->min_band = 1; + st->max_band = 16; + } + ELSE + { + st->narrowBand = 0; + st->min_band = 0; + st->max_band = 19; + } + + move16(); + move16(); + move16(); + + FOR( i = 0; i < FRAME_SIZE_NB; i++ ) + { + IF( EQ_32( FrameSizeConfig[i].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = i; + st->bits_frame = FrameSizeConfig[i].frame_bits; + st->bits_frame_core = FrameSizeConfig[i].frame_net_bits; + move16(); + move16(); + move16(); + BREAK; + } + } + + st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 ); + move16(); + core_coder_reconfig_ivas_fx( st, last_total_brate ); + } + ELSE + { + st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); + move16(); + IF( hTcxEnc != NULL ) + { + hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + } + st->currEnergyHF_fx = 0; + move32(); + st->currEnergyHF_e_fx = 0; + move16(); + Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag ); +#else + init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag ); +#endif + if ( st->hLPDmem != NULL ) + { + st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; + move16(); + } + } + + test(); + IF( st->igf && st->hBWE_TD != NULL ) + { + /* reset TBE */ + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->bwidth, WB ) && NE_16( st->last_extl, WB_TBE ) ) || + ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || + ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) + { + TBEreset_enc_fx( st, st->bwidth ); + } + ELSE + { + set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); + set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; + move16(); + } + } + test(); + IF( st->envWeighted && !st->enableTcxLpc ) + { + /* Unweight the envelope */ + st->inv_gamma = BASOP_Util_Divide1616_Scale( MAX16B, st->gamma, &exp_res ); + move16(); + st->inv_gamma = shr( st->inv_gamma, sub( Q1, exp_res ) ); /* Q14 */ + move16(); + E_LPC_lsp_unweight( st->lsp_old_fx, st->lsp_old_fx, st->lsf_old_fx, st->inv_gamma, M ); + st->envWeighted = 0; + move16(); + } + + IF( GE_32( st->total_brate, HQ_48k ) ) + { + st->enablePlcWaveadjust = 1; + move16(); + } + ELSE + { + st->enablePlcWaveadjust = 0; + move16(); + } + + test(); + test(); + if ( ( GT_32( last_total_brate, HQ_32k ) || EQ_16( st->last_codec_mode, MODE1 ) ) && ( st->element_mode == EVS_MONO ) ) + { + st->glr_reset = 1; + move16(); + } + + return; +} diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c deleted file mode 100644 index 4533af002..000000000 --- a/lib_enc/core_enc_updt.c +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * core_encode_update() - * - * Common updates of buffers - *-------------------------------------------------------------------*/ - -void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ -) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - Word16 n; - - /* Update Input Signal Buffers */ - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - - Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); - Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); - - IF( !st->tcxonly ) - { - n = add( st->L_frame, shr( st->L_frame, 2 ) ); - Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); - } - - IF( hTcxEnc != NULL ) - { - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) - { - Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); - Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) - Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e) - st->hTcxEnc->exp_buf_speech_ltp = max_e; - move16(); - } - } - - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) ); - IF( hTcxEnc != NULL ) - { - Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); - - IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - st->hTcxEnc->kernel_switch_corr_past = 0; - st->hTcxEnc->kernel_type[0] = MDCT_IV; - st->hTcxEnc->kernel_symmetry_past = 0; - st->hTcxEnc->enc_ste_pre_corr_past = 0; - - move16(); - move16(); - move16(); - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || ( st->element_mode > EVS_MONO ) ) ) ) - { - /* reset LP memories */ - set16_fx( st->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // 2.56 scaling - } - return; -} diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index 125f0cd52..305c2a92f 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -211,3 +211,77 @@ void core_encode_update_cng_fx( return; } + +/*-------------------------------------------------------------------* + * core_encode_update() + * + * Common updates of buffers + *-------------------------------------------------------------------*/ + +void core_encode_update_ivas_fx( + Encoder_State *st /* i/o: Encoder state structure */ +) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + Word16 n; + + /* Update Input Signal Buffers */ + n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); + + Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); + Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); + + IF( !st->tcxonly ) + { + n = add( st->L_frame, shr( st->L_frame, 2 ) ); + Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); + } + + IF( hTcxEnc != NULL ) + { + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) + { + Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); + Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) + Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e) + st->hTcxEnc->exp_buf_speech_ltp = max_e; + move16(); + } + } + + n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); + Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) ); + IF( hTcxEnc != NULL ) + { + Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); + + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->hTcxEnc->kernel_switch_corr_past = 0; + st->hTcxEnc->kernel_type[0] = MDCT_IV; + st->hTcxEnc->kernel_symmetry_past = 0; + st->hTcxEnc->enc_ste_pre_corr_past = 0; + + move16(); + move16(); + move16(); + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || ( st->element_mode > EVS_MONO ) ) ) ) + { + /* reset LP memories */ + set16_fx( st->mem_MA_fx, 0, M ); + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // 2.56 scaling + } + return; +} diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c deleted file mode 100644 index 08789dbde..000000000 --- a/lib_enc/core_switching_enc.c +++ /dev/null @@ -1,603 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "ivas_prot_fx.h" - -void core_switching_pre_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ -) -{ - Word16 Sample_Delay_HP, Sample_Delay_LP; - Word16 tmp16; - Word16 tmp; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - /* Mode switching */ - test(); - test(); - test(); - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) ) - { - IF( hLPDmem != NULL ) - { - st_fx->mem_deemph_fx = hLPDmem->syn[M]; - move16(); - Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); - } - - if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - st_fx->igf = 0; - move16(); - } - - IF( hBWE_TD != NULL ) - { - IF( st_fx->last_core != ACELP_CORE ) - { - /* reset BWE memories */ - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - } - - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - test(); - IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) - { - if ( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = HQ_CORE; - move16(); - } - IF( hHQ_core != NULL ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - test(); - /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ - IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - test(); - IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) - { - Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); - - st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); - move16(); - } - - st_fx->use_acelp_preq = 0; - move16(); - } - - test(); - test(); - test(); - if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) - { - /* very first frame is HQ_CORE */ - st_fx->last_core = HQ_CORE; - move16(); - } - - test(); - test(); - IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */ - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - - IF( hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) - { - IF( hSC_VBR != NULL ) - { - hSC_VBR->last_last_ppp_mode = 0; - move16(); - hSC_VBR->last_ppp_mode = 0; - move16(); - hSC_VBR->last_nelp_mode = 0; - move16(); - } - } - - test(); - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st_fx->act_count = 3; - move16(); - st_fx->uv_count = 0; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) || - ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - } - - st_fx->mem_deemph_fx = 0; - move16(); - /* Reset ACELP parameters */ - IF( hLPDmem != NULL ) - { - move16(); - hLPDmem->syn[M] = 0; - move16(); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - /* set16_fx( st_fx->dispMem, 0, 8 ); */ - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); - } - st_fx->Nb_ACELP_frames = 0; - move16(); - - set16_fx( st_fx->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - init_gp_clip_fx( st_fx->clip_var_fx ); - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = add( NB_SUBFR, 1 ); - - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - tmp16 = NB_SUBFR; - move16(); - } - - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - - /* Reset old ACELP buffers */ - test(); - IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) - { - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - } - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - - /* reset BWE memories */ - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - test(); - test(); - test(); - IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) - { - /* Reset the ACELP core in case of TCX->ACELP core switching */ - st_fx->Nb_ACELP_frames = 0; - move16(); - - IF( hLPDmem != NULL ) - { - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - init_gp_clip_fx( st_fx->clip_var_fx ); - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - } - - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = shr( st_fx->L_frame, 6 ); - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - - /* Reset old TD BWE buffers */ - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* reset BWE memories */ - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */ - } - } - test(); - test(); - test(); - IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL ) - { - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || - ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ) - { - /* we are switching to SWB BWE - reset SWB BWE buffers */ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); - IF( ( st_fx->element_mode > EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 - hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; - move16(); - Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - ELSE - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k - hBWE_FD->prev_Q_input_lp = q_old_inp_16k; - move16(); - Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - - tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); - Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); -#ifdef FIX_ISSUE_1230 - hBWE_FD->Q_new_input_hp = 0; - move16(); -#endif - - IF( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - hBWE_FD->EnergyLF_fx = 0; - hBWE_FD->EnergyLF_exp = 0; - move32(); - move16(); - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); /*8.0 in Q0 */ - st_fx->EnergyLT_fx_exp = 30; - move16(); /* Set to a High Exponent so it is 1^-30 */ - } - /*---------------------------------------------------------------------* - * band-width switching from WB -> SWB/FB - *---------------------------------------------------------------------*/ - IF( st_fx->element_mode > EVS_MONO ) - { - IF( st_fx->bwidth_sw_cnt == 0 ) - { - test(); - IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - } - } - ELSE - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) - { - st_fx->bwidth_sw_cnt = 0; - move16(); - } - } - } - - return; -} - -/*---------------------------------------------------------------------* - * core_switching_post_enc() - * - * Postprocessing for ACELP/HQ core switching - *---------------------------------------------------------------------*/ - -void core_switching_post_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ - Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ - Word16 Q_new ) -{ - IF( EQ_16( st->core, HQ_CORE ) ) - { - st->use_acelp_preq = 0; - move16(); - test(); - test(); - IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ - { - /* Memory scaling to keep everything in common q */ - Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - st->hLPDmem->mem_w0 = shl( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - move16(); - st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); - move16(); - - acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); - } - - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - st->hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - st->hBWE_FD->q_mem_deemph_old_syn = 0; - move16(); - } - ELSE - { - IF( st->hBWE_TD == NULL ) - { - return; - } - - test(); - /* reset SWB TBE buffers */ - IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) ) - { - wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); - - IF( NE_16( st->last_extl, WB_BWE ) ) - { - set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - } - - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); - set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); - set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - - IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && - ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) ) - { - set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - - InitSWBencBufferStates_fx( st->hBWE_TD, NULL ); - swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); - set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); - } - ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) ) - { - set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - } - ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) - { - TBEreset_enc_fx( st, st->bwidth ); - } - - test(); - test(); - test(); - test(); - /* Interp_3_2 CNG buffers reset */ - IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) ) - { - set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->fb_tbe_demph_fx = 0; - move16(); - fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q ); - } - /* Fade towards init value for non HQ_CORE */ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ - move32(); - st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ - move32(); - } - } - - return; -} diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index da1139d15..6fa341a7b 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -8,8 +8,9 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /* Function prototypes */ +#include "prot_fx_enc.h" /* Function prototypes */ /*---------------------------------------------------------------------* @@ -672,3 +673,559 @@ void core_switching_hq_prepare_enc_fx( } return; } + +void core_switching_pre_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */ + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ + const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */ + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ + const Word16 active_cnt, /* i : active frame counter */ + const Word16 last_element_mode /* i : last_element_mode */ +) +{ + Word16 Sample_Delay_HP, Sample_Delay_LP; + Word16 tmp16; + Word16 tmp; + SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; + LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; + HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; + TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; + TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; + FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; + + /* Mode switching */ + test(); + test(); + test(); + IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) ) + { + IF( hLPDmem != NULL ) + { + st_fx->mem_deemph_fx = hLPDmem->syn[M]; + move16(); + Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); + } + + if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + st_fx->igf = 0; + move16(); + } + + IF( hBWE_TD != NULL ) + { + IF( st_fx->last_core != ACELP_CORE ) + { + /* reset BWE memories */ + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + move32(); + } + + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + test(); + IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) + { + if ( st_fx->element_mode == EVS_MONO ) + { + st_fx->last_core = HQ_CORE; + move16(); + } + IF( hHQ_core != NULL ) + { + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); + hHQ_core->last_max_pos_pulse = 0; + move16(); + + hHQ_core->mode_count = 0; + move16(); + hHQ_core->mode_count1 = 0; + move16(); + + set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + move16(); + hHQ_core->prev_stab_hfe2 = 0; + move16(); + } + test(); + /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ + IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); + } + } + + test(); + IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) + { + Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); + + st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); + move16(); + } + + st_fx->use_acelp_preq = 0; + move16(); + } + + test(); + test(); + test(); + if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) + { + /* very first frame is HQ_CORE */ + st_fx->last_core = HQ_CORE; + move16(); + } + + test(); + test(); + IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */ + { + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); + hHQ_core->last_max_pos_pulse = 0; + move16(); + + hHQ_core->mode_count = 0; + move16(); + hHQ_core->mode_count1 = 0; + move16(); + + set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + move16(); + hHQ_core->prev_stab_hfe2 = 0; + move16(); + + IF( hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); + } + } + + /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores + within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ + test(); + test(); + IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) + { + IF( hSC_VBR != NULL ) + { + hSC_VBR->last_last_ppp_mode = 0; + move16(); + hSC_VBR->last_ppp_mode = 0; + move16(); + hSC_VBR->last_nelp_mode = 0; + move16(); + } + } + + test(); + test(); + test(); + IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) + { + st_fx->act_count = 3; + move16(); + st_fx->uv_count = 0; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) || + ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) ) + { + IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + { + Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); + } + ELSE + { + Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); + } + + st_fx->mem_deemph_fx = 0; + move16(); + /* Reset ACELP parameters */ + IF( hLPDmem != NULL ) + { + move16(); + hLPDmem->syn[M] = 0; + move16(); + set16_fx( hLPDmem->mem_syn2, 0, M ); + set16_fx( hLPDmem->mem_syn, 0, M ); + set16_fx( hLPDmem->mem_syn1_fx, 0, M ); + hLPDmem->q_mem_syn = Q15; + move16(); + hLPDmem->mem_w0 = 0; + move16(); + hLPDmem->tilt_code = 0; + move16(); + hLPDmem->gc_threshold = 0; + move32(); + /* set16_fx( st_fx->dispMem, 0, 8 ); */ + set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); + hLPDmem->dm_fx.prev_state = 0; + move16(); + hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); + } + st_fx->Nb_ACELP_frames = 0; + move16(); + + set16_fx( st_fx->mem_MA_fx, 0, M ); + Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); + init_gp_clip_fx( st_fx->clip_var_fx ); + st_fx->last_coder_type = GENERIC; + move16(); + + tmp16 = add( NB_SUBFR, 1 ); + + if ( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + tmp16 = NB_SUBFR; + move16(); + } + + Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); + + /* Reset old ACELP buffers */ + test(); + IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) + { + set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); + } + IF( hBWE_TD != NULL ) + { + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + + /* reset BWE memories */ + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + IF( hBWE_FD != NULL ) + { + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + } + test(); + test(); + test(); + IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) + { + /* Reset the ACELP core in case of TCX->ACELP core switching */ + st_fx->Nb_ACELP_frames = 0; + move16(); + + IF( hLPDmem != NULL ) + { + hLPDmem->mem_w0 = 0; + move16(); + hLPDmem->tilt_code = 0; + move16(); + hLPDmem->gc_threshold = 0; + move32(); + init_gp_clip_fx( st_fx->clip_var_fx ); + set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); + hLPDmem->dm_fx.prev_state = 0; + move16(); + hLPDmem->dm_fx.prev_gain_code = 0; + move32(); + } + + st_fx->last_coder_type = GENERIC; + move16(); + + tmp16 = shr( st_fx->L_frame, 6 ); + Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); + + /* Reset old TD BWE buffers */ + IF( hBWE_TD != NULL ) + { + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + + /* reset BWE memories */ + IF( hBWE_FD != NULL ) + { + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */ + } + } + test(); + test(); + test(); + IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL ) + { + test(); + IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) + { + hBWE_FD->prev_mode = NORMAL; + move16(); + hBWE_FD->modeCount = 0; + move16(); + } + + hBWE_FD->prev_L_swb_norm1 = 8; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || + ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ) + { + /* we are switching to SWB BWE - reset SWB BWE buffers */ + + IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); + IF( ( st_fx->element_mode > EVS_MONO ) ) + { + IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + } + Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); + } + IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) + { + Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp + } + ELSE + { + Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 + hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; + move16(); + Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + } + ELSE + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); + IF( GT_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + } + Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); + } + IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) + { + Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp + } + ELSE + { + Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k + hBWE_FD->prev_Q_input_lp = q_old_inp_16k; + move16(); + Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + } + + tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); + Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); +#ifdef FIX_ISSUE_1230 + hBWE_FD->Q_new_input_hp = 0; + move16(); +#endif + + IF( NE_16( st_fx->last_extl, WB_BWE ) ) + { + hBWE_FD->prev_mode = NORMAL; + move16(); + hBWE_FD->modeCount = 0; + move16(); + } + hBWE_FD->EnergyLF_fx = 0; + hBWE_FD->EnergyLF_exp = 0; + move32(); + move16(); + hBWE_FD->prev_L_swb_norm1 = 8; + move16(); /*8.0 in Q0 */ + st_fx->EnergyLT_fx_exp = 30; + move16(); /* Set to a High Exponent so it is 1^-30 */ + } + /*---------------------------------------------------------------------* + * band-width switching from WB -> SWB/FB + *---------------------------------------------------------------------*/ + IF( st_fx->element_mode > EVS_MONO ) + { + IF( st_fx->bwidth_sw_cnt == 0 ) + { + test(); + IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) + { + st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); + move16(); + } + } + ELSE + { + st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); + move16(); + IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) + { + st_fx->bwidth_sw_cnt = 0; + move16(); + } + } + } + + return; +} + +/*---------------------------------------------------------------------* + * core_switching_post_enc() + * + * Postprocessing for ACELP/HQ core switching + *---------------------------------------------------------------------*/ + +void core_switching_post_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ + Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ + Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ + Word16 Q_new ) +{ + IF( EQ_16( st->core, HQ_CORE ) ) + { + st->use_acelp_preq = 0; + move16(); + test(); + test(); + IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ + { + /* Memory scaling to keep everything in common q */ + Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + st->hLPDmem->mem_w0 = shl( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + move16(); + st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); + move16(); + + acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); + } + + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + st->hBWE_FD->mem_deemph_old_syn_fx = 0; + move16(); + st->hBWE_FD->q_mem_deemph_old_syn = 0; + move16(); + } + ELSE + { + IF( st->hBWE_TD == NULL ) + { + return; + } + + test(); + /* reset SWB TBE buffers */ + IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) ) + { + wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); + + IF( NE_16( st->last_extl, WB_BWE ) ) + { + set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); + set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); + } + + set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); + set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); + set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 ); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + + IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && + ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) ) + { + set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); + + InitSWBencBufferStates_fx( st->hBWE_TD, NULL ); + swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) ); + + set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); + set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); + } + ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) ) + { + set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); + set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; + move16(); + } + ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) + { + TBEreset_enc_fx( st, st->bwidth ); + } + + test(); + test(); + test(); + test(); + /* Interp_3_2 CNG buffers reset */ + IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) ) + { + set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + st->hBWE_TD->fb_tbe_demph_fx = 0; + move16(); + fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q ); + } + /* Fade towards init value for non HQ_CORE */ + IF( st->hHQ_core != NULL ) + { + st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ + move32(); + st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ + move32(); + } + } + + return; +} diff --git a/lib_enc/corr_xh.c b/lib_enc/corr_xh.c deleted file mode 100644 index 9fd3cb8a2..000000000 --- a/lib_enc/corr_xh.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "wmc_auto.h" diff --git a/lib_enc/decision_matrix_enc.c b/lib_enc/decision_matrix_enc.c deleted file mode 100644 index 5e0c266ca..000000000 --- a/lib_enc/decision_matrix_enc.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "prot_fx_enc.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/detect_transient.c b/lib_enc/detect_transient.c deleted file mode 100644 index c2bbde080..000000000 --- a/lib_enc/detect_transient.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/diffcod.c b/lib_enc/diffcod.c deleted file mode 100644 index 9f6bb4283..000000000 --- a/lib_enc/diffcod.c +++ /dev/null @@ -1,149 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*--------------------------------------------------------------------------*/ -/* Function diffcod() */ -/* */ -/* Differential coding for indices of quantized norms */ -/*--------------------------------------------------------------------------*/ - -void diffcod( - const int16_t N, /* i : number of sub-vectors */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx /* o : differential code */ -) -{ - int16_t i, k, r; - - for ( i = N - 1; i > 0; i-- ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k < ( -15 ) ) - { - y[r] = y[i] + 15; - } - } - - for ( i = 1; i < N; i++ ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k > 16 ) - { - k = 16; - y[i] = y[r] + 16; - } - difidx[r] = k + 15; - } - - return; -} - - -/*-------------------------------------------------------------------------- - * diffcod_lrmdct() - * - * Differential coding for indices of quantized norms - *--------------------------------------------------------------------------*/ - -void diffcod_lrmdct( - const int16_t N, /* i : number of sub-vectors */ - const int16_t be_ref, /* i : band energy reference */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx, /* o : differential code */ - const int16_t is_transient /* i : transient flag */ -) -{ - int16_t i, m, r; - int16_t k; - int16_t thr_l, thr_h; - - if ( is_transient ) - { - thr_l = -15; - thr_h = 16; - } - else - { - thr_l = -32; - thr_h = 31; - } - - difidx[0] = y[0] - be_ref; - if ( difidx[0] > thr_h ) - { - difidx[0] = thr_h; - y[0] = be_ref + thr_h; - } - - if ( difidx[0] < thr_l ) - { - difidx[0] = thr_l; - y[0] = be_ref + thr_l; - } - - m = N - 1; - for ( i = m; i > 0; i-- ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k < thr_l ) - { - y[r] = y[i] - thr_l; - } - } - - for ( i = 1; i < N; i++ ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k > thr_h ) - { - k = thr_h; - y[i] = y[r] + thr_h; - } - difidx[i] = k; - } - - return; -} diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c deleted file mode 100644 index 726508b0c..000000000 --- a/lib_enc/dtx.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_acelp.c b/lib_enc/enc_acelp.c deleted file mode 100644 index bf5688ef1..000000000 --- a/lib_enc/enc_acelp.c +++ /dev/null @@ -1,91 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" - - -/* - * acelp_2pulse_search - * - * Parameters: - * nb_pos_ix I: nb of pos for pulse 1 (1..8) - * track_x I: track of pulse 1 - * track_y I: track of pulse 2 - * ps I/O: correlation of all fixed pulses - * alp I/O: energy of all fixed pulses - * ix O: position of pulse 1 - * iy O: position of pulse 2 - * dn I: corr. between target and h[] - * dn2 I: vector of selected positions - * cor_x I: corr. of pulse 1 with fixed pulses - * cor_y I: corr. of pulse 2 with fixed pulses - * rrixiy I: corr. of pulse 1 with pulse 2 - * - * Function: - * Find the best positions of 2 pulses in a subframe - * - * Returns: - * void - */ - - -/* - * E_ACELP_1pulse_search - * - * Parameters: - * track_x I: track of pulse 1 - * track_y I: track of pulse 2 - * ps I/O: correlation of all fixed pulses - * alp I/O: energy of all fixed pulses - * ix O: position of pulse 1 - * dn I: corr. between target and h[] - * cor_x I: corr. of pulse 1 with fixed pulses - * cor_y I: corr. of pulse 2 with fixed pulses - * - * Function: - * Find the best positions of 1 pulse in a subframe - * - * Returns: - * void - */ diff --git a/lib_enc/enc_acelp_tcx_main.c b/lib_enc/enc_acelp_tcx_main.c deleted file mode 100644 index d029c2fa8..000000000 --- a/lib_enc/enc_acelp_tcx_main.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_acelpx.c b/lib_enc/enc_acelpx.c deleted file mode 100644 index f6e2b0379..000000000 --- a/lib_enc/enc_acelpx.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_amr_wb.c b/lib_enc/enc_amr_wb.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_enc/enc_amr_wb.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_gain.c b/lib_enc/enc_gain.c deleted file mode 100644 index 491d5d2f3..000000000 --- a/lib_enc/enc_gain.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_gen_voic.c b/lib_enc/enc_gen_voic.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_enc/enc_gen_voic.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c deleted file mode 100644 index 554521732..000000000 --- a/lib_enc/enc_prm.c +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - - -/*-------------------------------------------------------------------* - * writeTCXMode_fx() - * - * write TCX mode - *--------------------------------------------------------------------*/ - -void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ -) -{ - UWord16 index; - Word16 idx, start_idx; - Word16 nBits; - - IF( st->tcxonly ) - { - push_next_indice( hBstr, (UWord16) EQ_16( st->core, TCX_10_CORE ), 1 ); - - test(); - IF( EQ_16( st->clas, UNVOICED_CLAS ) ) - { - index = 0; - move16(); - } - ELSE IF( EQ_16( st->clas, VOICED_TRANSITION ) || EQ_16( st->clas, UNVOICED_TRANSITION ) ) - { - index = 1; - move16(); - } - ELSE IF( EQ_16( st->clas, VOICED_CLAS ) ) - { - index = 2; - move16(); - } - ELSE - { - index = 3; - move16(); - } - - push_next_indice( hBstr, index, 2 ); - - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) - { - push_next_indice( hBstr, st->vad_flag, 1 ); - } - } - ELSE - { - IF( EQ_16( st->core, ACELP_CORE ) ) - { - /* write the RF signaling information */ - IF( EQ_16( st->rf_mode, 1 ) ) - { - /* find the section in the ACELP signaling table corresponding to bitrate */ - idx = 0; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) /* total bitrate is kept at 13.2kbps */ - { - idx = add( idx, 1 ); - } - - /* retrieve the number of bits for signaling */ - idx = add( idx, 1 ); /* Q0 */ - nBits = extract_l( acelp_sig_tbl[idx] ); /* Q0 */ - - /* retrieve the signaling index */ - idx = add( idx, 1 ); - start_idx = idx; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) - { - idx = add( idx, 1 ); - } - push_next_indice( hBstr, sub( idx, start_idx ), nBits ); - push_next_indice( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/ - *nbits_start = 3; - move16(); - } - ELSE - { - push_next_indice( hBstr, st->coder_type, 3 ); - } - } - ELSE - { - IF( EQ_16( st->mdct_sw, MODE1 ) ) - { - /* 2 bits instead of 3 as TCX is already signaled */ - push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); - } - ELSE - { - IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) - { - push_next_indice( hBstr, 1, 1 ); /* TCX */ - push_next_indice( hBstr, 0, 1 ); /* not HQ_CORE */ - push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); - } - ELSE - { - /*write the RF signaling information*/ - IF( EQ_16( st->rf_mode, 1 ) ) - { - /* find the section in the ACELP signaling table corresponding to bitrate */ - idx = 0; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) - { - idx = add( idx, 1 ); - } - - /* retrieve the number of bits for signaling */ - idx = add( idx, 1 ); - nBits = extract_l( acelp_sig_tbl[idx] ); - - test(); - test(); - IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) || EQ_16( st->hTcxCfg->coder_type, GENERIC ) || EQ_16( st->hTcxCfg->coder_type, TRANSITION ) ) - { - st->sharpFlag = 1; - move16(); - } - ELSE - { - st->sharpFlag = 0; - move16(); - } - - /* retrieve the signaling index */ - idx = add( idx, 1 ); - start_idx = idx; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) - { - idx = add( idx, 1 ); - } - push_next_indice( hBstr, sub( idx, start_idx ), nBits ); - push_next_indice( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/ - *nbits_start = 3; - move16(); - } - ELSE - { - push_next_indice( hBstr, add( ACELP_MODE_MAX, st->hTcxCfg->coder_type ), 3 ); - } - } - } - } - } - - return; -} - - -/*-------------------------------------------------------------------* - * writeTCXWindowing_fx() - * - * write TCX transform type - *-------------------------------------------------------------------*/ - -void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ -) -{ - - IF( EQ_16( overlap_mode, MIN_OVERLAP ) ) - { - push_next_indice( hBstr, 2, 2 ); - } - ELSE IF( EQ_16( overlap_mode, HALF_OVERLAP ) ) - { - push_next_indice( hBstr, 3, 2 ); - } - ELSE - { - push_next_indice( hBstr, 0, 1 ); - } - - return; -} diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index d394fa2d3..da2ea5863 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -11,7 +11,7 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -//#include "prot_fx.h" +#include "prot.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -1512,3 +1512,190 @@ void writeTCXparam_fx( return; } + +/*-------------------------------------------------------------------* + * writeTCXMode_fx() + * + * write TCX mode + *--------------------------------------------------------------------*/ + +void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ +) +{ + UWord16 index; + Word16 idx, start_idx; + Word16 nBits; + + IF( st->tcxonly ) + { + push_next_indice( hBstr, (UWord16) EQ_16( st->core, TCX_10_CORE ), 1 ); + + test(); + IF( EQ_16( st->clas, UNVOICED_CLAS ) ) + { + index = 0; + move16(); + } + ELSE IF( EQ_16( st->clas, VOICED_TRANSITION ) || EQ_16( st->clas, UNVOICED_TRANSITION ) ) + { + index = 1; + move16(); + } + ELSE IF( EQ_16( st->clas, VOICED_CLAS ) ) + { + index = 2; + move16(); + } + ELSE + { + index = 3; + move16(); + } + + push_next_indice( hBstr, index, 2 ); + + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) + { + push_next_indice( hBstr, st->vad_flag, 1 ); + } + } + ELSE + { + IF( EQ_16( st->core, ACELP_CORE ) ) + { + /* write the RF signaling information */ + IF( EQ_16( st->rf_mode, 1 ) ) + { + /* find the section in the ACELP signaling table corresponding to bitrate */ + idx = 0; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) /* total bitrate is kept at 13.2kbps */ + { + idx = add( idx, 1 ); + } + + /* retrieve the number of bits for signaling */ + idx = add( idx, 1 ); /* Q0 */ + nBits = extract_l( acelp_sig_tbl[idx] ); /* Q0 */ + + /* retrieve the signaling index */ + idx = add( idx, 1 ); + start_idx = idx; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) + { + idx = add( idx, 1 ); + } + push_next_indice( hBstr, sub( idx, start_idx ), nBits ); + push_next_indice( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/ + *nbits_start = 3; + move16(); + } + ELSE + { + push_next_indice( hBstr, st->coder_type, 3 ); + } + } + ELSE + { + IF( EQ_16( st->mdct_sw, MODE1 ) ) + { + /* 2 bits instead of 3 as TCX is already signaled */ + push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); + } + ELSE + { + IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) + { + push_next_indice( hBstr, 1, 1 ); /* TCX */ + push_next_indice( hBstr, 0, 1 ); /* not HQ_CORE */ + push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); + } + ELSE + { + /*write the RF signaling information*/ + IF( EQ_16( st->rf_mode, 1 ) ) + { + /* find the section in the ACELP signaling table corresponding to bitrate */ + idx = 0; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) + { + idx = add( idx, 1 ); + } + + /* retrieve the number of bits for signaling */ + idx = add( idx, 1 ); + nBits = extract_l( acelp_sig_tbl[idx] ); + + test(); + test(); + IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) || EQ_16( st->hTcxCfg->coder_type, GENERIC ) || EQ_16( st->hTcxCfg->coder_type, TRANSITION ) ) + { + st->sharpFlag = 1; + move16(); + } + ELSE + { + st->sharpFlag = 0; + move16(); + } + + /* retrieve the signaling index */ + idx = add( idx, 1 ); + start_idx = idx; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) + { + idx = add( idx, 1 ); + } + push_next_indice( hBstr, sub( idx, start_idx ), nBits ); + push_next_indice( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/ + *nbits_start = 3; + move16(); + } + ELSE + { + push_next_indice( hBstr, add( ACELP_MODE_MAX, st->hTcxCfg->coder_type ), 3 ); + } + } + } + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * writeTCXWindowing_fx() + * + * write TCX transform type + *-------------------------------------------------------------------*/ + +void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ +) +{ + + IF( EQ_16( overlap_mode, MIN_OVERLAP ) ) + { + push_next_indice( hBstr, 2, 2 ); + } + ELSE IF( EQ_16( overlap_mode, HALF_OVERLAP ) ) + { + push_next_indice( hBstr, 3, 2 ); + } + ELSE + { + push_next_indice( hBstr, 0, 1 ); + } + + return; +} diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c deleted file mode 100644 index 3b1b81730..000000000 --- a/lib_enc/fd_cng_enc.c +++ /dev/null @@ -1,1172 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" -#include "stat_enc.h" -#include "wmc_auto.h" - -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * initFdCngEnc() - * - * Initialize FD_CNG - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * deleteFdCngEnc() - * - * Delete the instance of type FD_CNG - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * resetFdCngEnc() - * - * Reset the instance of type FD_CNG - *-------------------------------------------------------------------*/ -/*-------------------------------------------------------------------* - * perform_noise_estimation_enc() - * - * Perform noise estimation - *-------------------------------------------------------------------*/ -void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ - Word16 band_energies_exp, - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ - const Word32 input_Fs, /* i : input sampling rate Q0*/ - CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */ -) -{ - Word16 i, j, s, s1, s2; - Word16 numBands; - Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */ - move16(); - Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */ - move16(); - Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */ - move16(); - assert( numSlots == 16 ); - - Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625 - move32(); - Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */ - Word32 *ptr_per_fx = periodog; - Word64 periodog_64; - Word16 periodog_exp[PERIODOGLEN]; - Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */ - move16(); - Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */ - move16(); - Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */ - move16(); - - Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9 - Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx; - Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */ - - Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx; - Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx; - - Word32 scaleEB_fx = 0; - move32(); - Word32 tmp; - - test(); - IF( hCPE != NULL && hCPE->hStereoDft != NULL ) - { - // band_res_dft = ( (float) input_Fs ) / hCPE->hStereoDft->NFFT; - // chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; - // chan_width_bins = chan_width_f / band_res_dft; - - ///* Scaling of Energy buffer to get energy per sample, same scaling as for band_energies, 3 is to compensate for the 1/3 scaling in calculate_energy_buffer */ - // scaleEB = 3 * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); - - ///* Scale with number of bins in one band */ - // scaleEB = scaleEB / chan_width_bins; - - SWITCH( input_Fs ) - { - case 8000: - scaleEB_fx = 251648; // Q35 - move32(); - BREAK; - case 16000: - scaleEB_fx = 62912; // Q35 - move32(); - BREAK; - case 32000: - scaleEB_fx = 15728; // Q35 - move32(); - BREAK; - case 48000: - scaleEB_fx = 6991; // Q35 - move32(); - BREAK; - default: - assert( 0 && "invalid sample rate" ); - } - } - ELSE - { - scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33 - scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35 - } - - /* preemphasis compensation and grouping of per bin energies into msPeriodog */ - FOR( i = 0; i < nFFTpart; i++ ) - { - tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); - msPeriodog_fx[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); - move32(); - } - - /* exponent for fft part of msPeriodog */ - hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); - move16(); - - Word16 max_exp = -31; - move16(); - i = 0; - move16(); - /* Adjust to the desired time resolution by averaging the periodograms over the time slots */ - FOR( j = numCoreBands; j < regularStopBand; j++ ) - { - periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx ); - Word16 scale = W_norm( periodog_64 ); - *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) ); - move32(); - periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) ); - move16(); - max_exp = s_max( max_exp, periodog_exp[i] ); - - ptr_per_fx++; - i++; - } - /* exponent for cldfb part of msPeriodog */ - // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); - // move16(); - - numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ - FOR( i = 0; i < numBands; i++ ) - { - - periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) ); - - move16(); - } - hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp; - move16(); - IF( numBands > 0 ) - { - ///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ - bandcombinepow( - periodog, - hFdCngEnc->hFdCngCom->exp_cldfb_periodog, - numBands, - hFdCngEnc->hFdCngCom->CLDFBpart, - nCLDFBpart, - hFdCngEnc->hFdCngCom->CLDFBpsize_inv, - &msPeriodog_fx[nFFTpart], - &hFdCngEnc->msPeriodog_fx_exp_cldfb ); - - ///* find common exponent for fft part and cldfb part of msperiodog */ - s1 = getScaleFactor32( msPeriodog_fx, nFFTpart ); - s2 = getScaleFactor32( &msPeriodog_fx[nFFTpart], nCLDFBpart ); - - s = s_max( sub( hFdCngEnc->msPeriodog_fx_exp_fft, s1 ), sub( hFdCngEnc->msPeriodog_fx_exp_cldfb, s2 ) ); - s1 = sub( s, hFdCngEnc->msPeriodog_fx_exp_fft ); - s2 = sub( s, hFdCngEnc->msPeriodog_fx_exp_cldfb ); - - hFdCngEnc->msPeriodog_fx_exp_fft = s; - move16(); - hFdCngEnc->msPeriodog_fx_exp_cldfb = s; - move16(); - - FOR( i = 0; i < nFFTpart; i++ ) - { - msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ - move32(); - } - - FOR( i = 0; i < nCLDFBpart; i++ ) - { - msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ - move32(); - } - } - /* exponent for entire msPeriodog vector */ - hFdCngEnc->msPeriodog_fx_exp = hFdCngEnc->msPeriodog_fx_exp_fft; - move16(); - - /* Compress MS inputs */ - // compress_range_flt( msPeriodog, msLogPeriodog, npart ); - compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, msLogPeriodog_fx, npart ); - - - /* Call the minimum statistics routine for noise estimation */ - - minimum_statistics_fx( npart, nFFTpart, psize, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, - hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom, - ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode ); - - /* Expand MS outputs */ - expand_range( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); - - return; -} - - -/*-------------------------------------------------------------------* - * FdCng_encodeSID() - * - * Generate a bitstream out of the partition levels - *-------------------------------------------------------------------*/ -void FdCng_encodeSID_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -) -{ - Word16 N; - HANDLE_FD_CNG_ENC hFdCngEnc = st->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - Word32 *invTrfMatrix_fx, *E_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 v_fx[32], gain_fx, e_fx, temp; - Word16 w_fx[32], indices[32], exp[32]; - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; - Word16 v_e, gain_q_offset, preemph_fac; - Word16 i, index; - - gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; - move16(); - - if ( st->element_mode == EVS_MONO ) - { - gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; - move16(); - } - - preemph_fac = st->preemph_fac; // Q15 - move16(); - - /* Init */ - N = hFdCngEnc->npartDec; - move16(); - - E_fx = hFdCngEnc->msNoiseEst_fx; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - - set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN ); - - /* Convert to LOG */ - e_fx = 0; - move32(); - FOR( i = 0; i < N; i++ ) - { - IF( E_fx[i] == 0 ) - { - /* 10 * log(1e-4) = 10 * (-4) = -40 */ - v_fx[i] = -41943040; // -40.0 in Q20 - move32(); - } - ELSE - { - v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], hFdCngEnc->msNoiseEst_fx_exp ) ); // Q20 = 26+25-31 - move32(); - } - e_fx = L_add( e_fx, v_fx[i] ); // Q20 - } - - /* Normalize MSVQ input */ - gain_fx = 0; - move32(); - FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ ) - { - gain_fx = L_add( gain_fx, v_fx[i] ); // Q20 - } - - /*gain /= (float) ( N_GAIN_MAX - N_GAIN_MIN );*/ - gain_fx = Mpy_32_32( gain_fx, 165191050 /* 1/13 in Q31*/ ); // Q20 - - FOR( i = 0; i < N; i++ ) - { - v_fx[i] = L_sub( v_fx[i], gain_fx ); // Q20 - move32(); - } - - v_e = 11; // Q20 - move16(); - - /* MSVQ encoder */ - set_val_Word16( w_fx, ONE_IN_Q8, N ); - - IF( st->element_mode != EVS_MONO ) - { - /* DCT domain compressed/truncated indices used for first stage */ - /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched - in FDCNG band domain - */ - IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) - { - /* truncated DCT21 analysis */ - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 - - dctT2_N_apply_matrix_fx( v_fx /*Q20*/, dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); // Q20 - - /* truncated IDCT21 extension to 24 bands */ - extend_dctN_input_fx( v_fx, dct_target_fx, N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); // Q20 - - Copy32( tot_sig_ext_fx, v_fx, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ // Q20 - } - - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 - - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices ); - - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v_fx, NULL, 7 ); - - v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); - } - ELSE - { /* EVS_MONO tables */ - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 0, NULL, indices ); - - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v_fx, NULL, 7 ); - - v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); - } - - /* Compute gain */ - gain_fx = 0; - move32(); - FOR( i = 0; i < N; i++ ) - { - gain_fx = L_add( gain_fx, v_fx[i] ); // Q = 31 - v_e - } - - e_fx = L_shl( e_fx, sub( 11, v_e ) ); // Q = 31 - v_e - gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e - gain_fx = L_shl( gain_fx, sub( v_e, 8 ) ); // Q23 - - /* Apply bitrate-dependant scale */ - IF( st->element_mode > EVS_MONO ) - { - apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - } - ELSE - { - apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); - } - - /* Quantize gain */ - temp = Madd_32_32( L_shl( gain_q_offset, 22 ), gain_fx, 1610612736 /*1.5 in Q30*/ ); // Q22 - index = extract_l( L_shr( L_add( temp, ONE_IN_Q21 ), 22 ) ); // Q0 - - if ( index < 0 ) - { - index = 0; - move16(); - } - - if ( GT_16( index, 127 ) ) - { - index = 127; - move16(); - } - - gain_fx = L_shl( L_mult0( sub( index, gain_q_offset ), 21845 /*1.5 in Q15*/ ), sub( 16, v_e ) ); // Q = 31-v_e - - /* Apply gain and undo log */ - FOR( i = 0; i < N; i++ ) - { - temp = Mpy_32_32( L_add( v_fx[i], gain_fx ), 214748365 /* 0.1 in Q31*/ ); // Q = 31-v_e - hFdCngCom->sidNoiseEst[i] = BASOP_Util_fPow( 10, 31, temp, v_e, &exp[i] ); - move32(); - } - - maximum_s( exp, N, &hFdCngCom->sidNoiseEstExp ); - - FOR( i = 0; i < N; i++ ) - { - hFdCngCom->sidNoiseEst[i] = L_shr( hFdCngCom->sidNoiseEst[i], sub( hFdCngCom->sidNoiseEstExp, exp[i] ) ); // exp = hFdCngCom->sidNoiseEstExp - move32(); - } - - /* NB last band energy compensation */ - IF( hFdCngCom->CngBandwidth == NB ) - { - hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) - move32(); - } - - test(); - IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) - move32(); - } - - /* Write bitstream */ - IF( EQ_16( st->codec_mode, MODE2 ) ) - { - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_next_indice( hBstr, indices[i], bits_37bits[i] ); - } - - push_next_indice( hBstr, index, 7 ); - } - ELSE - { - Word16 is_frame_len_16k = 0; - move16(); - if ( EQ_16( st->L_frame, L_FRAME16k ) ) - { - is_frame_len_16k = 1; - move16(); - } - push_indice( hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( hBstr, IND_ACELP_16KHZ, is_frame_len_16k, 1 ); - - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); - } - - push_indice( hBstr, IND_ENERGY, index, 7 ); - } - - /* Interpolate the bin/band-wise levels from the partition levels */ - scalebands( hFdCngCom->sidNoiseEst, hFdCngEnc->partDec, hFdCngEnc->npartDec, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, preemph_fac ); - - return; -} - - -/*-------------------------------------------------------------------* - * stereoFdCngCoherence() - * - * compute coherence of channels for use in FD-CNG - *-------------------------------------------------------------------*/ -void stereoFdCngCoherence_fx( - Encoder_State **sts, /* i/o: core encoder structures */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Word16 fft_buf_fx[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/ - Word16 fft_exp ) -{ - const Word16 *pt_fftL, *pt_fftR; - Word16 i_subfr, i; - Word32 cr, ci, eL, eR; - Word16 cr_exp, ci_exp, eL_exp, eR_exp; - Word32 *mem; - Word16 *mem_exp; - - IF( NE_16( last_element_mode, IVAS_CPE_MDCT ) ) - { - set32_fx( sts[0]->hFdCngEnc->mem_coherence_fx, EPSILON_FX, 4 ); - set16_fx( sts[0]->hFdCngEnc->mem_coherence_exp, 0, 4 ); - } - test(); - test(); - IF( EQ_32( sts[0]->core_brate, -1 ) || EQ_32( sts[1]->core_brate, -1 ) ) - { - /* case: at least one channel has triggered VAD -> ACTIVE FRAME */ - IF( EQ_32( sts[0]->core_brate, -1 ) ) - { - sts[1]->total_brate = sts[0]->total_brate; /* Q0 */ - move32(); - sts[1]->active_cnt = sts[0]->active_cnt; /* Q0 */ - move16(); - if ( GE_32( sts[1]->active_cnt, CNG_TYPE_HO ) ) - { - sts[1]->last_total_brate_cng = -1; - move16(); - } - } - IF( EQ_32( sts[1]->core_brate, -1 ) ) - { - sts[0]->total_brate = sts[1]->total_brate; /* Q0 */ - move32(); - sts[0]->active_cnt = sts[1]->active_cnt; /* Q0 */ - move16(); - if ( GE_16( sts[0]->active_cnt, CNG_TYPE_HO ) ) - { - sts[0]->last_total_brate_cng = -1; - move16(); - } - } - sts[0]->core_brate = -1; - move32(); - sts[1]->core_brate = -1; - move32(); - sts[0]->hDtxEnc->cnt_SID = 0; - move16(); - sts[1]->hDtxEnc->cnt_SID = 0; - move16(); - } - ELSE IF( LE_32( sts[0]->core_brate, SID_2k40 ) && LE_32( sts[1]->core_brate, SID_2k40 ) ) - { - /* case: no VAD for both channels -> INACTIVE FRAME */ - reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); - - reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); - - /* synchronize SID sending for variable SID rate */ - IF( EQ_32( sts[0]->core_brate, sts[1]->core_brate ) ) - { - sts[0]->core_brate = SID_2k40; - move32(); - sts[1]->core_brate = SID_2k40; - move32(); - } - - /* synchronize SID counters */ - sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID ); /* Q0 */ - sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID; /* Q0 */ - move16(); - move16(); - } - - pt_fftL = fft_buf_fx[0]; - pt_fftR = fft_buf_fx[1]; - mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */ - mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp; - FOR( i_subfr = 0; i_subfr < 2; i_subfr++ ) - { - cr = ci = eL = eR = EPSILON_FX; - move32(); - move32(); - move32(); - move32(); - cr_exp = ci_exp = eL_exp = eR_exp = 0; - move16(); - move16(); - move16(); - move16(); - - cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ - eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ - eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ - - FOR( i = 1; i < L_FFT / 2; i++ ) - { - cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ - ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ - eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ - eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ - } - test(); - test(); - IF( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) - { - mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */ - move32(); - mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */ - move32(); - mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */ - move32(); - mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */ - move32(); - } - - pt_fftL += L_FFT; - pt_fftR += L_FFT; - } - - Word16 sqr_inp, temp, sqr_out, sqr_inp_exp; - Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */ - sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp ); - sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) ); - sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp ); - sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = shl_sat( sqr_out, sqr_inp_exp ); // Q15 expected. - move16(); - return; -} - -/*-------------------------------------------------------------------* - * FdCngEncodeMDCTStereoSID() - * - * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX - *-------------------------------------------------------------------*/ - -void FdCngEncodeMDCTStereoSID_fx( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -) -{ - ENC_CORE_HANDLE sts[CPE_CHANNELS]; - Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; - Word16 gain_idx[CPE_CHANNELS]; - Word16 N, stages, ch, p, coh_idx; - Word32 *lr_in_ptr_fx[CPE_CHANNELS]; - Word16 lr_in_ptr_e[CPE_CHANNELS]; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word16 ms_ptr_e; - Word32 *lr_out_ptr_fx[CPE_CHANNELS]; - Word16 lr_out_ptr_e[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 E_fx[CPE_CHANNELS]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 weights_fx[NPART]; - Word32 side_energy_fx; - Word16 Qside_energy; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; /*24*18*/ - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN], dct_target_fx[CPE_CHANNELS][FDCNG_VQ_DCT_MAXTRUNC]; /* 24 +2*18*/ - Word16 tmp, tmp_e; - Word16 no_side_flag; - Word16 is_inp_ms; - Word16 size_value, temp_e, gb, shift; - Word32 tmp32, t1, t2; - - is_inp_ms = 0; - move16(); - IF( EQ_16( hCPE->hCoreCoder[0]->cng_sba_flag, 1 ) ) - { - is_inp_ms = 1; - move16(); - } - - /* set pointers and initialize */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; /* exp(sts[ch]->hFdCngEnc->msNoiseEst_fx_exp) */ - lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; - lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; /* exp(sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp) */ - lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; - } - N = sts[0]->hFdCngEnc->npartDec; /* Q0 */ - move16(); - set16_fx( weights_fx, ONE_IN_Q8, NPART ); - - /* apply log and save energy of original left and right channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - // E[ch] = 0.0f; - E_fx[ch] = 0; - move32(); - FOR( p = 0; p < N; p++ ) - { - IF( lr_in_ptr_fx[ch][p] ) - { - t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] ); // Q25 - t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 - } - ELSE - { - t2 = 0; - move32(); - } - ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 - move32(); - E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 4 ) ); // Q19 - move32(); - } - } - ms_ptr_e = Q31 - Q23; - move16(); - - /* M/S transform on log envelopes */ - IF( is_inp_ms == 0 ) - { - convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); // ms_ptr_e = Q23; - } - - gb = find_guarded_bits_fx( N ); - side_energy_fx = sum2_f_32_fx( ms_ptr_fx[1], N, gb ); - Qside_energy = sub( sub( shl( sub( 31, ms_ptr_e ), 1 ), 31 ), gb ); - - /* do not transmit side shape if initial noise shapes are very similar */ - IF( LE_32( side_energy_fx, L_shl( 214748365, sub( Qside_energy, Q31 ) ) ) ) - { - no_side_flag = 1; - move16(); - } - ELSE - { - no_side_flag = 0; - move16(); - } - - /* Quantize noise shapes */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - /* Normalize MSVQ input */ - gain_fx[ch] = 0; - move32(); - FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) - { - tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 /* 0.07 in Q31*/ ); // Q23 - gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23 - move32(); - } - - FOR( p = 0; p < N; p++ ) - { - ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q23 - move32(); - } - } - - /* always split channel targetloop */ - - /* extend fdcng envelope from length 21 to a 24 length fdncg domain envelope signal */ - /* High quality cosine smooth basis extension used to not introduce noise in stage#1 DCT24 analysis and subsequent VQ-steps */ - IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) - { - size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ - size_value = shr( size_value, sub( 15, temp_e ) ); - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, size_value ); // Q31 /*WB: create truncated IDCT21 matrix */ - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - /* run DCT_N N==21 , truncated at 18/21 ~= 86% , i.e use a bit better better quality in extrapolation , than subsequent DCT24 analysis which is truncated at 75%*/ - /* truncated DCT 21 analysis */ - dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[ch], dct_target_fx[ch], FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); - /* extrapolate extend fdcng envelope signal in the fdncg ienvelope/"time" domain using DCT21 basis vectors, - estimated DCT21 coeffs scaling extended basis vectors are used to create extrapolated length 24 input target envelope signal */ - /* this DCT21 extension does not introduce DCT24 coefficient noise for the subsequent dct24 target analysis, and later in IDCT24 synthesis */ - - /* truncated IDCT 21 extension synthesis */ - extend_dctN_input_fx( ms_ptr_fx[ch], dct_target_fx[ch], N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx /* DCT_N basis vectors */, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ - - Copy32( tot_sig_ext_fx, ms_ptr_fx[ch], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ */ - } - } - - size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ - size_value = shr( size_value, sub( 15, temp_e ) ); - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, size_value ); /*always create/set up IDCT24 matrix in RAM */ - - /* end split */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - /* MSVQ */ - IF( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - move16(); - } - ELSE - { - stages = FD_CNG_stages_37bits; - move16(); - } - - /* DCT24 domain compressed/truncated indices used for first stage */ - /* mid channel quantization using stages 1 through 6 */ - /* & side channel quantization using stages 1 through 4 */ - - { - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[ch], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, stages, weights_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[ch] ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices[ch], 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); - } - } - shift = find_guarded_bits_fx( N ); - ms_ptr_e = sub( 31, sub( 20, shift ) ); - - IF( no_side_flag ) - { - set32_fx( ms_ptr_fx[1], 0, N ); - } - - /* undo M/S */ - IF( is_inp_ms == 0 ) - { - convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); - } - - /* Compute gain against original left and right channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - gain_fx[ch] = 0; - move32(); - - tmp_e = 15; - move16(); - tmp = Inv16( N, &tmp_e ); - FOR( p = 0; p < N; p++ ) - { - gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) ); // Q23 - move32(); - } - gain_fx[ch] = L_sub( L_shl( Mpy_32_16_1( E_fx[ch], shl( tmp, tmp_e ) ), Q23 - Q19 ), L_shl( gain_fx[ch], sub( ms_ptr_e, 8 ) ) ); // Q23 - move32(); - - apply_scale( &gain_fx[ch], sts[ch]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[ch]->element_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - - /* quantize gain */ - gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 ); // Q23 - move16(); - gain_idx[ch] = s_max( 0, s_min( 127, gain_idx[ch] ) ); - move16(); - - gain_fx[ch] = Mpy_32_16_1( L_shl( sub( gain_idx[ch], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 ); // Q23 - move32(); - } - - /* restore channel noise envelopes */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - - tmp_e = 0; - move16(); - Word32 pow; - - Word16 e_lr_out[NPART]; - - FOR( p = 0; p < N; p++ ) - { - pow = L_shl( gain_fx[ch], 8 - ms_ptr_e ); - pow = L_add( ms_ptr_fx[ch][p], pow ); - pow = Mpy_32_32( pow, 214748365 ); /*pow = 0.1*/ - lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); - move32(); - tmp_e = s_max( tmp_e, e_lr_out[p] ); - } - - FOR( p = 0; p < N; p++ ) - { - lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], e_lr_out[p] - tmp_e ); - move32(); - } - lr_out_ptr_e[ch] = tmp_e; - move32(); - - sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; - move16(); - - /* scale bands and get scalefactors */ - scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); - - sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; - } - - /* quantize channel coherence */ - coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); - coh_idx = max( 0, min( coh_idx, 15 ) ); - - /* ---- Write SID bitstream ---- */ - - - /* noise shapes and channel gains */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - sts[ch]->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; - - /* side info */ - push_indice( sts[ch]->hBstr, IND_SID_TYPE, coh_idx, 4 ); - push_indice( sts[ch]->hBstr, IND_SID_TYPE, no_side_flag, 1 ); - } - ELSE - { - stages = FD_CNG_stages_37bits; - /* side info */ - push_indice( sts[ch]->hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( sts[ch]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); - push_indice( sts[ch]->hBstr, IND_ACELP_16KHZ, sts[0]->L_frame == L_FRAME16k ? 1 : 0, 1 ); - } - - FOR( Word16 i = 0; i < stages; i++ ) - { - push_indice( sts[ch]->hBstr, IND_LSF, indices[ch][i], bits_37bits[i] ); - } - push_indice( sts[ch]->hBstr, IND_ENERGY, gain_idx[ch], 7 ); - } - - /* pad with zeros to reach common SID frame size */ - push_indice( sts[1]->hBstr, IND_ENERGY, 0, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); - - return; -} - -/*-------------------------------------------------------------------* - * FdCngEncodeDiracMDCTStereoSID() - * - * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX - * together with Dirac - *-------------------------------------------------------------------*/ - -void FdCngEncodeDiracMDCTStereoSID_fx( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -) -{ - ENC_CORE_HANDLE sts[CPE_CHANNELS]; - Word32 *lr_in_ptr_fx[CPE_CHANNELS]; - Word16 lr_in_ptr_e[CPE_CHANNELS]; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word16 ms_ptr_e; - Word32 *lr_out_ptr_fx[CPE_CHANNELS]; - Word16 lr_out_ptr_e[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 E_fx[CPE_CHANNELS]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 weights_fx[NPART]; - Word16 N[CPE_CHANNELS]; - Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; - Word16 gain_idx[CPE_CHANNELS]; - Word16 ch, p; - Word16 tmp, tmp_e, shift; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - Word32 t1, t2, tmp32; - /* set pointers and initialize */ - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - N[ch] = sts[ch]->hFdCngEnc->npartDec; - lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; - lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; - lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; - lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; - move16(); - } - set16_fx( weights_fx, ONE_IN_Q8, NPART ); - - /* apply log and save energy of original left and right channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - // E[ch] = 0.0f; - E_fx[ch] = 0; - move32(); - FOR( p = 0; p < N[ch]; p++ ) - { - t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] + EPSILLON_FX ); // Q25 - t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 - ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 - move32(); - E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 5 ) ); // Q18 - move32(); - } - } - ms_ptr_e = Q31 - Q23; - move16(); - - /* M/S transform on log envelopes */ - convertToMS_fx( N[0], ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); - E_fx[0] = 0; - move32(); - FOR( p = 0; p < N[0]; p++ ) - { - E_fx[0] = L_add( E_fx[0], L_shr( ms_ptr_fx[0][p], 5 ) ); // Q18 - move32(); - } - - /* Quantize M noise shape */ - /* Normalize MSVQ input */ - gain_fx[0] = 0; - move16(); - FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) - { - tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 /* 0.07 in Q31 */ ); // Q23 - gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23 - move32(); - } - - FOR( p = 0; p < N[0]; p++ ) - { - ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] ); // Q23 - move32(); - } - - - /* MSVQ */ - /* DCT domain compressed/truncated indices used for first stage */ - /* mid quantization using stages #1 through 6 */ - scale_sig32( ms_ptr_fx[0], N[0], -6 ); - ms_ptr_e = add( ms_ptr_e, 6 ); - move16(); - IF( EQ_16( N[0], FDCNG_VQ_MAX_LEN_WB ) ) - { - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N[0], FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); - /* truncated DCT 21 analysis */ - dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[0], dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N[0], invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); - /* truncated IDCT21 extension to 24 synthesis */ - - extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ - - Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/ - } - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); - - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[0], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, weights_fx, N[0], FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[0] ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); - shift = find_guarded_bits_fx( N[0] ); - ms_ptr_e = sub( 31, sub( 20, shift ) ); - scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ - - /* set S to zero */ - set32_fx( ms_ptr_fx[1], 0, NPART ); - - /* compute M gain */ - gain_fx[0] = 0; - move32(); - tmp_e = 15; - move16(); - tmp = Inv16( N[0], &tmp_e ); - FOR( p = 0; p < N[0]; p++ ) - { - gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) ); // Q23 - move32(); - } - gain_fx[0] = L_sub( L_shl( Mpy_32_16_1( E_fx[0], shl( tmp, tmp_e ) ), Q23 - Q18 ), L_shl( gain_fx[0], ms_ptr_e - 8 ) ); // Q23 - move32(); - - apply_scale( &gain_fx[0], sts[0]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[0]->hDtxEnc->last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - - /* quantize gain */ - gain_idx[0] = extract_l( Mpy_32_32_r( L_add( gain_fx[0], 251658240 ), 384 ) ); - move16(); - gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) ); - move16(); - - gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 /* 0.66 in Q15 */ ); // Q23 - move32(); - gain_fx[1] = gain_fx[0]; // Q23 - move32(); - - /* undo M/S */ - convertToMS_fx( NPART, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); - - /* restore channel noise envelopes */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - - Word32 pow; - Word16 e_lr_out[NPART]; - tmp_e = -MAX_16; - FOR( p = 0; p < N[ch]; p++ ) - { - pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ - pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */ - pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/ - lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); - tmp_e = s_max( tmp_e, e_lr_out[p] ); - } - - FOR( p = 0; p < N[ch]; p++ ) - { - lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], sub( e_lr_out[p], tmp_e ) ); // Q(31 - tmp_e) - } - - sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; - move16(); - lr_out_ptr_e[ch] = tmp_e; - move16(); - - /* NB last band energy compensation */ - IF( hFdCngCom->CngBandwidth == NB ) - { - lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE ); // Q(31 - tmp_e) - move32(); - } - ELSE IF( hFdCngCom->CngBandwidth == SWB && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE ); // Q(31 - tmp_e) - move32(); - } - /* scale bands and get scalefactors */ - scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N[ch], hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; - move16(); - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); - sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; - } - sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = 0; - move16(); - sts[1]->hFdCngEnc->hFdCngCom->coherence_fx = 0; - move16(); - - /* ---- Write SID bitstream ---- */ - - /* side info */ - push_indice( sts[0]->hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( sts[0]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); - IF( EQ_16( sts[0]->L_frame, L_FRAME16k ) ) - { - push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 1, 1 ); - } - ELSE - { - push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 0, 1 ); - } - - /* noise shapes and channel gains */ - FOR( Word16 i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_indice( sts[0]->hBstr, IND_LSF, indices[0][i], bits_37bits[i] ); - } - push_indice( sts[0]->hBstr, IND_ENERGY, gain_idx[0], 7 ); - - return; -} diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 93a954ae8..50f479d8d 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -14,6 +14,7 @@ #include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" +#include "ivas_prot_fx.h" #include "basop_util.h" #include "rom_basop_util.h" @@ -2267,3 +2268,1102 @@ Word16 cng_energy_ivas_fx( } return enr; } + +void perform_noise_estimation_enc_ivas_fx( + Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ + Word16 band_energies_exp, + Word32 *enerBuffer, /* enerBuffer_exp */ + Word16 enerBuffer_exp, + HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ + const Word32 input_Fs, /* i : input sampling rate Q0*/ + CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */ +) +{ + Word16 i, j, s, s1, s2; + Word16 numBands; + Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */ + move16(); + Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */ + move16(); + Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */ + move16(); + assert( numSlots == 16 ); + + Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625 + move32(); + Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */ + Word32 *ptr_per_fx = periodog; + Word64 periodog_64; + Word16 periodog_exp[PERIODOGLEN]; + Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */ + move16(); + Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */ + move16(); + Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */ + move16(); + + Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9 + Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx; + Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */ + + Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx; + Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx; + + Word32 scaleEB_fx = 0; + move32(); + Word32 tmp; + + test(); + IF( hCPE != NULL && hCPE->hStereoDft != NULL ) + { + // band_res_dft = ( (float) input_Fs ) / hCPE->hStereoDft->NFFT; + // chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; + // chan_width_bins = chan_width_f / band_res_dft; + + ///* Scaling of Energy buffer to get energy per sample, same scaling as for band_energies, 3 is to compensate for the 1/3 scaling in calculate_energy_buffer */ + // scaleEB = 3 * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); + + ///* Scale with number of bins in one band */ + // scaleEB = scaleEB / chan_width_bins; + + SWITCH( input_Fs ) + { + case 8000: + scaleEB_fx = 251648; // Q35 + move32(); + BREAK; + case 16000: + scaleEB_fx = 62912; // Q35 + move32(); + BREAK; + case 32000: + scaleEB_fx = 15728; // Q35 + move32(); + BREAK; + case 48000: + scaleEB_fx = 6991; // Q35 + move32(); + BREAK; + default: + assert( 0 && "invalid sample rate" ); + } + } + ELSE + { + scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33 + scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35 + } + + /* preemphasis compensation and grouping of per bin energies into msPeriodog */ + FOR( i = 0; i < nFFTpart; i++ ) + { + tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); + msPeriodog_fx[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); + move32(); + } + + /* exponent for fft part of msPeriodog */ + hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); + move16(); + + Word16 max_exp = -31; + move16(); + i = 0; + move16(); + /* Adjust to the desired time resolution by averaging the periodograms over the time slots */ + FOR( j = numCoreBands; j < regularStopBand; j++ ) + { + periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx ); + Word16 scale = W_norm( periodog_64 ); + *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) ); + move32(); + periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) ); + move16(); + max_exp = s_max( max_exp, periodog_exp[i] ); + + ptr_per_fx++; + i++; + } + /* exponent for cldfb part of msPeriodog */ + // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); + // move16(); + + numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ + FOR( i = 0; i < numBands; i++ ) + { + + periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) ); + + move16(); + } + hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp; + move16(); + IF( numBands > 0 ) + { + ///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ + bandcombinepow( + periodog, + hFdCngEnc->hFdCngCom->exp_cldfb_periodog, + numBands, + hFdCngEnc->hFdCngCom->CLDFBpart, + nCLDFBpart, + hFdCngEnc->hFdCngCom->CLDFBpsize_inv, + &msPeriodog_fx[nFFTpart], + &hFdCngEnc->msPeriodog_fx_exp_cldfb ); + + ///* find common exponent for fft part and cldfb part of msperiodog */ + s1 = getScaleFactor32( msPeriodog_fx, nFFTpart ); + s2 = getScaleFactor32( &msPeriodog_fx[nFFTpart], nCLDFBpart ); + + s = s_max( sub( hFdCngEnc->msPeriodog_fx_exp_fft, s1 ), sub( hFdCngEnc->msPeriodog_fx_exp_cldfb, s2 ) ); + s1 = sub( s, hFdCngEnc->msPeriodog_fx_exp_fft ); + s2 = sub( s, hFdCngEnc->msPeriodog_fx_exp_cldfb ); + + hFdCngEnc->msPeriodog_fx_exp_fft = s; + move16(); + hFdCngEnc->msPeriodog_fx_exp_cldfb = s; + move16(); + + FOR( i = 0; i < nFFTpart; i++ ) + { + msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ + move32(); + } + + FOR( i = 0; i < nCLDFBpart; i++ ) + { + msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ + move32(); + } + } + /* exponent for entire msPeriodog vector */ + hFdCngEnc->msPeriodog_fx_exp = hFdCngEnc->msPeriodog_fx_exp_fft; + move16(); + + /* Compress MS inputs */ + // compress_range_flt( msPeriodog, msLogPeriodog, npart ); + compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, msLogPeriodog_fx, npart ); + + + /* Call the minimum statistics routine for noise estimation */ + + minimum_statistics_fx( npart, nFFTpart, psize, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, + hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom, + ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode ); + + /* Expand MS outputs */ + expand_range( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); + + return; +} + + +/*-------------------------------------------------------------------* + * FdCng_encodeSID() + * + * Generate a bitstream out of the partition levels + *-------------------------------------------------------------------*/ +void FdCng_encodeSID_ivas_fx( + Encoder_State *st /* i/o: encoder state structure */ +) +{ + Word16 N; + HANDLE_FD_CNG_ENC hFdCngEnc = st->hFdCngEnc; + HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; + BSTR_ENC_HANDLE hBstr = st->hBstr; + + Word32 *invTrfMatrix_fx, *E_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word32 v_fx[32], gain_fx, e_fx, temp; + Word16 w_fx[32], indices[32], exp[32]; + Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; + Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; + Word16 v_e, gain_q_offset, preemph_fac; + Word16 i, index; + + gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; + move16(); + + if ( st->element_mode == EVS_MONO ) + { + gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; + move16(); + } + + preemph_fac = st->preemph_fac; // Q15 + move16(); + + /* Init */ + N = hFdCngEnc->npartDec; + move16(); + + E_fx = hFdCngEnc->msNoiseEst_fx; + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + + set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN ); + + /* Convert to LOG */ + e_fx = 0; + move32(); + FOR( i = 0; i < N; i++ ) + { + IF( E_fx[i] == 0 ) + { + /* 10 * log(1e-4) = 10 * (-4) = -40 */ + v_fx[i] = -41943040; // -40.0 in Q20 + move32(); + } + ELSE + { + v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], hFdCngEnc->msNoiseEst_fx_exp ) ); // Q20 = 26+25-31 + move32(); + } + e_fx = L_add( e_fx, v_fx[i] ); // Q20 + } + + /* Normalize MSVQ input */ + gain_fx = 0; + move32(); + FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ ) + { + gain_fx = L_add( gain_fx, v_fx[i] ); // Q20 + } + + /*gain /= (float) ( N_GAIN_MAX - N_GAIN_MIN );*/ + gain_fx = Mpy_32_32( gain_fx, 165191050 /* 1/13 in Q31*/ ); // Q20 + + FOR( i = 0; i < N; i++ ) + { + v_fx[i] = L_sub( v_fx[i], gain_fx ); // Q20 + move32(); + } + + v_e = 11; // Q20 + move16(); + + /* MSVQ encoder */ + set_val_Word16( w_fx, ONE_IN_Q8, N ); + + IF( st->element_mode != EVS_MONO ) + { + /* DCT domain compressed/truncated indices used for first stage */ + /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched + in FDCNG band domain + */ + IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) + { + /* truncated DCT21 analysis */ + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 + + dctT2_N_apply_matrix_fx( v_fx /*Q20*/, dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); // Q20 + + /* truncated IDCT21 extension to 24 bands */ + extend_dctN_input_fx( v_fx, dct_target_fx, N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); // Q20 + + Copy32( tot_sig_ext_fx, v_fx, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ // Q20 + } + + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 + + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices ); + + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v_fx, NULL, 7 ); + + v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); + } + ELSE + { /* EVS_MONO tables */ + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 0, NULL, indices ); + + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v_fx, NULL, 7 ); + + v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); + } + + /* Compute gain */ + gain_fx = 0; + move32(); + FOR( i = 0; i < N; i++ ) + { + gain_fx = L_add( gain_fx, v_fx[i] ); // Q = 31 - v_e + } + + e_fx = L_shl( e_fx, sub( 11, v_e ) ); // Q = 31 - v_e + gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e + gain_fx = L_shl( gain_fx, sub( v_e, 8 ) ); // Q23 + + /* Apply bitrate-dependant scale */ + IF( st->element_mode > EVS_MONO ) + { + apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + } + ELSE + { + apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); + } + + /* Quantize gain */ + temp = Madd_32_32( L_shl( gain_q_offset, 22 ), gain_fx, 1610612736 /*1.5 in Q30*/ ); // Q22 + index = extract_l( L_shr( L_add( temp, ONE_IN_Q21 ), 22 ) ); // Q0 + + if ( index < 0 ) + { + index = 0; + move16(); + } + + if ( GT_16( index, 127 ) ) + { + index = 127; + move16(); + } + + gain_fx = L_shl( L_mult0( sub( index, gain_q_offset ), 21845 /*1.5 in Q15*/ ), sub( 16, v_e ) ); // Q = 31-v_e + + /* Apply gain and undo log */ + FOR( i = 0; i < N; i++ ) + { + temp = Mpy_32_32( L_add( v_fx[i], gain_fx ), 214748365 /* 0.1 in Q31*/ ); // Q = 31-v_e + hFdCngCom->sidNoiseEst[i] = BASOP_Util_fPow( 10, 31, temp, v_e, &exp[i] ); + move32(); + } + + maximum_s( exp, N, &hFdCngCom->sidNoiseEstExp ); + + FOR( i = 0; i < N; i++ ) + { + hFdCngCom->sidNoiseEst[i] = L_shr( hFdCngCom->sidNoiseEst[i], sub( hFdCngCom->sidNoiseEstExp, exp[i] ) ); // exp = hFdCngCom->sidNoiseEstExp + move32(); + } + + /* NB last band energy compensation */ + IF( hFdCngCom->CngBandwidth == NB ) + { + hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) + move32(); + } + + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) + move32(); + } + + /* Write bitstream */ + IF( EQ_16( st->codec_mode, MODE2 ) ) + { + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + push_next_indice( hBstr, indices[i], bits_37bits[i] ); + } + + push_next_indice( hBstr, index, 7 ); + } + ELSE + { + Word16 is_frame_len_16k = 0; + move16(); + if ( EQ_16( st->L_frame, L_FRAME16k ) ) + { + is_frame_len_16k = 1; + move16(); + } + push_indice( hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( hBstr, IND_BWIDTH, st->bwidth, 2 ); + push_indice( hBstr, IND_ACELP_16KHZ, is_frame_len_16k, 1 ); + + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); + } + + push_indice( hBstr, IND_ENERGY, index, 7 ); + } + + /* Interpolate the bin/band-wise levels from the partition levels */ + scalebands( hFdCngCom->sidNoiseEst, hFdCngEnc->partDec, hFdCngEnc->npartDec, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, preemph_fac ); + + return; +} + + +/*-------------------------------------------------------------------* + * stereoFdCngCoherence() + * + * compute coherence of channels for use in FD-CNG + *-------------------------------------------------------------------*/ +void stereoFdCngCoherence_fx( + Encoder_State **sts, /* i/o: core encoder structures */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Word16 fft_buf_fx[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/ + Word16 fft_exp ) +{ + const Word16 *pt_fftL, *pt_fftR; + Word16 i_subfr, i; + Word32 cr, ci, eL, eR; + Word16 cr_exp, ci_exp, eL_exp, eR_exp; + Word32 *mem; + Word16 *mem_exp; + + IF( NE_16( last_element_mode, IVAS_CPE_MDCT ) ) + { + set32_fx( sts[0]->hFdCngEnc->mem_coherence_fx, EPSILON_FX, 4 ); + set16_fx( sts[0]->hFdCngEnc->mem_coherence_exp, 0, 4 ); + } + test(); + test(); + IF( EQ_32( sts[0]->core_brate, -1 ) || EQ_32( sts[1]->core_brate, -1 ) ) + { + /* case: at least one channel has triggered VAD -> ACTIVE FRAME */ + IF( EQ_32( sts[0]->core_brate, -1 ) ) + { + sts[1]->total_brate = sts[0]->total_brate; /* Q0 */ + move32(); + sts[1]->active_cnt = sts[0]->active_cnt; /* Q0 */ + move16(); + if ( GE_32( sts[1]->active_cnt, CNG_TYPE_HO ) ) + { + sts[1]->last_total_brate_cng = -1; + move16(); + } + } + IF( EQ_32( sts[1]->core_brate, -1 ) ) + { + sts[0]->total_brate = sts[1]->total_brate; /* Q0 */ + move32(); + sts[0]->active_cnt = sts[1]->active_cnt; /* Q0 */ + move16(); + if ( GE_16( sts[0]->active_cnt, CNG_TYPE_HO ) ) + { + sts[0]->last_total_brate_cng = -1; + move16(); + } + } + sts[0]->core_brate = -1; + move32(); + sts[1]->core_brate = -1; + move32(); + sts[0]->hDtxEnc->cnt_SID = 0; + move16(); + sts[1]->hDtxEnc->cnt_SID = 0; + move16(); + } + ELSE IF( LE_32( sts[0]->core_brate, SID_2k40 ) && LE_32( sts[1]->core_brate, SID_2k40 ) ) + { + /* case: no VAD for both channels -> INACTIVE FRAME */ + reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); + + reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); + + /* synchronize SID sending for variable SID rate */ + IF( EQ_32( sts[0]->core_brate, sts[1]->core_brate ) ) + { + sts[0]->core_brate = SID_2k40; + move32(); + sts[1]->core_brate = SID_2k40; + move32(); + } + + /* synchronize SID counters */ + sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID ); /* Q0 */ + sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID; /* Q0 */ + move16(); + move16(); + } + + pt_fftL = fft_buf_fx[0]; + pt_fftR = fft_buf_fx[1]; + mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */ + mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp; + FOR( i_subfr = 0; i_subfr < 2; i_subfr++ ) + { + cr = ci = eL = eR = EPSILON_FX; + move32(); + move32(); + move32(); + move32(); + cr_exp = ci_exp = eL_exp = eR_exp = 0; + move16(); + move16(); + move16(); + move16(); + + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + + FOR( i = 1; i < L_FFT / 2; i++ ) + { + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + } + test(); + test(); + IF( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) + { + mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */ + move32(); + mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */ + move32(); + mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */ + move32(); + mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */ + move32(); + } + + pt_fftL += L_FFT; + pt_fftR += L_FFT; + } + + Word16 sqr_inp, temp, sqr_out, sqr_inp_exp; + Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */ + sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp ); + sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) ); + sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp ); + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = shl_sat( sqr_out, sqr_inp_exp ); // Q15 expected. + move16(); + return; +} + +/*-------------------------------------------------------------------* + * FdCngEncodeMDCTStereoSID() + * + * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX + *-------------------------------------------------------------------*/ + +void FdCngEncodeMDCTStereoSID_fx( + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ +) +{ + ENC_CORE_HANDLE sts[CPE_CHANNELS]; + Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; + Word16 gain_idx[CPE_CHANNELS]; + Word16 N, stages, ch, p, coh_idx; + Word32 *lr_in_ptr_fx[CPE_CHANNELS]; + Word16 lr_in_ptr_e[CPE_CHANNELS]; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word16 ms_ptr_e; + Word32 *lr_out_ptr_fx[CPE_CHANNELS]; + Word16 lr_out_ptr_e[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 E_fx[CPE_CHANNELS]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 weights_fx[NPART]; + Word32 side_energy_fx; + Word16 Qside_energy; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; /*24*18*/ + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN], dct_target_fx[CPE_CHANNELS][FDCNG_VQ_DCT_MAXTRUNC]; /* 24 +2*18*/ + Word16 tmp, tmp_e; + Word16 no_side_flag; + Word16 is_inp_ms; + Word16 size_value, temp_e, gb, shift; + Word32 tmp32, t1, t2; + + is_inp_ms = 0; + move16(); + IF( EQ_16( hCPE->hCoreCoder[0]->cng_sba_flag, 1 ) ) + { + is_inp_ms = 1; + move16(); + } + + /* set pointers and initialize */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; /* exp(sts[ch]->hFdCngEnc->msNoiseEst_fx_exp) */ + lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; + lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; /* exp(sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp) */ + lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; + } + N = sts[0]->hFdCngEnc->npartDec; /* Q0 */ + move16(); + set16_fx( weights_fx, ONE_IN_Q8, NPART ); + + /* apply log and save energy of original left and right channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + // E[ch] = 0.0f; + E_fx[ch] = 0; + move32(); + FOR( p = 0; p < N; p++ ) + { + IF( lr_in_ptr_fx[ch][p] ) + { + t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] ); // Q25 + t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 + } + ELSE + { + t2 = 0; + move32(); + } + ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 + move32(); + E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 4 ) ); // Q19 + move32(); + } + } + ms_ptr_e = Q31 - Q23; + move16(); + + /* M/S transform on log envelopes */ + IF( is_inp_ms == 0 ) + { + convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); // ms_ptr_e = Q23; + } + + gb = find_guarded_bits_fx( N ); + side_energy_fx = sum2_f_32_fx( ms_ptr_fx[1], N, gb ); + Qside_energy = sub( sub( shl( sub( 31, ms_ptr_e ), 1 ), 31 ), gb ); + + /* do not transmit side shape if initial noise shapes are very similar */ + IF( LE_32( side_energy_fx, L_shl( 214748365, sub( Qside_energy, Q31 ) ) ) ) + { + no_side_flag = 1; + move16(); + } + ELSE + { + no_side_flag = 0; + move16(); + } + + /* Quantize noise shapes */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + /* Normalize MSVQ input */ + gain_fx[ch] = 0; + move32(); + FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) + { + tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 /* 0.07 in Q31*/ ); // Q23 + gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23 + move32(); + } + + FOR( p = 0; p < N; p++ ) + { + ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q23 + move32(); + } + } + + /* always split channel targetloop */ + + /* extend fdcng envelope from length 21 to a 24 length fdncg domain envelope signal */ + /* High quality cosine smooth basis extension used to not introduce noise in stage#1 DCT24 analysis and subsequent VQ-steps */ + IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) + { + size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ + size_value = shr( size_value, sub( 15, temp_e ) ); + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, size_value ); // Q31 /*WB: create truncated IDCT21 matrix */ + for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + /* run DCT_N N==21 , truncated at 18/21 ~= 86% , i.e use a bit better better quality in extrapolation , than subsequent DCT24 analysis which is truncated at 75%*/ + /* truncated DCT 21 analysis */ + dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[ch], dct_target_fx[ch], FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); + /* extrapolate extend fdcng envelope signal in the fdncg ienvelope/"time" domain using DCT21 basis vectors, + estimated DCT21 coeffs scaling extended basis vectors are used to create extrapolated length 24 input target envelope signal */ + /* this DCT21 extension does not introduce DCT24 coefficient noise for the subsequent dct24 target analysis, and later in IDCT24 synthesis */ + + /* truncated IDCT 21 extension synthesis */ + extend_dctN_input_fx( ms_ptr_fx[ch], dct_target_fx[ch], N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx /* DCT_N basis vectors */, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ + + Copy32( tot_sig_ext_fx, ms_ptr_fx[ch], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ */ + } + } + + size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ + size_value = shr( size_value, sub( 15, temp_e ) ); + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, size_value ); /*always create/set up IDCT24 matrix in RAM */ + + /* end split */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + /* MSVQ */ + IF( ch ) + { + stages = FD_CNG_JOINT_stages_25bits; + move16(); + } + ELSE + { + stages = FD_CNG_stages_37bits; + move16(); + } + + /* DCT24 domain compressed/truncated indices used for first stage */ + /* mid channel quantization using stages 1 through 6 */ + /* & side channel quantization using stages 1 through 4 */ + + { + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[ch], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, stages, weights_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[ch] ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices[ch], 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); + } + } + shift = find_guarded_bits_fx( N ); + ms_ptr_e = sub( 31, sub( 20, shift ) ); + + IF( no_side_flag ) + { + set32_fx( ms_ptr_fx[1], 0, N ); + } + + /* undo M/S */ + IF( is_inp_ms == 0 ) + { + convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); + } + + /* Compute gain against original left and right channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + gain_fx[ch] = 0; + move32(); + + tmp_e = 15; + move16(); + tmp = Inv16( N, &tmp_e ); + FOR( p = 0; p < N; p++ ) + { + gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) ); // Q23 + move32(); + } + gain_fx[ch] = L_sub( L_shl( Mpy_32_16_1( E_fx[ch], shl( tmp, tmp_e ) ), Q23 - Q19 ), L_shl( gain_fx[ch], sub( ms_ptr_e, 8 ) ) ); // Q23 + move32(); + + apply_scale( &gain_fx[ch], sts[ch]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[ch]->element_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + + /* quantize gain */ + gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 ); // Q23 + move16(); + gain_idx[ch] = s_max( 0, s_min( 127, gain_idx[ch] ) ); + move16(); + + gain_fx[ch] = Mpy_32_16_1( L_shl( sub( gain_idx[ch], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 ); // Q23 + move32(); + } + + /* restore channel noise envelopes */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; + HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; + + tmp_e = 0; + move16(); + Word32 pow; + + Word16 e_lr_out[NPART]; + + FOR( p = 0; p < N; p++ ) + { + pow = L_shl( gain_fx[ch], 8 - ms_ptr_e ); + pow = L_add( ms_ptr_fx[ch][p], pow ); + pow = Mpy_32_32( pow, 214748365 ); /*pow = 0.1*/ + lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); + move32(); + tmp_e = s_max( tmp_e, e_lr_out[p] ); + } + + FOR( p = 0; p < N; p++ ) + { + lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], e_lr_out[p] - tmp_e ); + move32(); + } + lr_out_ptr_e[ch] = tmp_e; + move32(); + + sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; + move16(); + + /* scale bands and get scalefactors */ + scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); + + sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; + } + + /* quantize channel coherence */ + coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); + coh_idx = max( 0, min( coh_idx, 15 ) ); + + /* ---- Write SID bitstream ---- */ + + + /* noise shapes and channel gains */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + IF( ch ) + { + stages = FD_CNG_JOINT_stages_25bits; + sts[ch]->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; + + /* side info */ + push_indice( sts[ch]->hBstr, IND_SID_TYPE, coh_idx, 4 ); + push_indice( sts[ch]->hBstr, IND_SID_TYPE, no_side_flag, 1 ); + } + ELSE + { + stages = FD_CNG_stages_37bits; + /* side info */ + push_indice( sts[ch]->hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( sts[ch]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); + push_indice( sts[ch]->hBstr, IND_ACELP_16KHZ, sts[0]->L_frame == L_FRAME16k ? 1 : 0, 1 ); + } + + FOR( Word16 i = 0; i < stages; i++ ) + { + push_indice( sts[ch]->hBstr, IND_LSF, indices[ch][i], bits_37bits[i] ); + } + push_indice( sts[ch]->hBstr, IND_ENERGY, gain_idx[ch], 7 ); + } + + /* pad with zeros to reach common SID frame size */ + push_indice( sts[1]->hBstr, IND_ENERGY, 0, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); + + return; +} + +/*-------------------------------------------------------------------* + * FdCngEncodeDiracMDCTStereoSID() + * + * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX + * together with Dirac + *-------------------------------------------------------------------*/ + +void FdCngEncodeDiracMDCTStereoSID_fx( + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ +) +{ + ENC_CORE_HANDLE sts[CPE_CHANNELS]; + Word32 *lr_in_ptr_fx[CPE_CHANNELS]; + Word16 lr_in_ptr_e[CPE_CHANNELS]; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word16 ms_ptr_e; + Word32 *lr_out_ptr_fx[CPE_CHANNELS]; + Word16 lr_out_ptr_e[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 E_fx[CPE_CHANNELS]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 weights_fx[NPART]; + Word16 N[CPE_CHANNELS]; + Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; + Word16 gain_idx[CPE_CHANNELS]; + Word16 ch, p; + Word16 tmp, tmp_e, shift; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; + Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + Word32 t1, t2, tmp32; + /* set pointers and initialize */ + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + N[ch] = sts[ch]->hFdCngEnc->npartDec; + lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; + lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; + lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; + lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; + move16(); + } + set16_fx( weights_fx, ONE_IN_Q8, NPART ); + + /* apply log and save energy of original left and right channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + // E[ch] = 0.0f; + E_fx[ch] = 0; + move32(); + FOR( p = 0; p < N[ch]; p++ ) + { + t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] + EPSILLON_FX ); // Q25 + t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 + ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 + move32(); + E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 5 ) ); // Q18 + move32(); + } + } + ms_ptr_e = Q31 - Q23; + move16(); + + /* M/S transform on log envelopes */ + convertToMS_fx( N[0], ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); + E_fx[0] = 0; + move32(); + FOR( p = 0; p < N[0]; p++ ) + { + E_fx[0] = L_add( E_fx[0], L_shr( ms_ptr_fx[0][p], 5 ) ); // Q18 + move32(); + } + + /* Quantize M noise shape */ + /* Normalize MSVQ input */ + gain_fx[0] = 0; + move16(); + FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) + { + tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 /* 0.07 in Q31 */ ); // Q23 + gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23 + move32(); + } + + FOR( p = 0; p < N[0]; p++ ) + { + ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] ); // Q23 + move32(); + } + + + /* MSVQ */ + /* DCT domain compressed/truncated indices used for first stage */ + /* mid quantization using stages #1 through 6 */ + scale_sig32( ms_ptr_fx[0], N[0], -6 ); + ms_ptr_e = add( ms_ptr_e, 6 ); + move16(); + IF( EQ_16( N[0], FDCNG_VQ_MAX_LEN_WB ) ) + { + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N[0], FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); + /* truncated DCT 21 analysis */ + dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[0], dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N[0], invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); + /* truncated IDCT21 extension to 24 synthesis */ + + extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ + + Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/ + } + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); + + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[0], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, weights_fx, N[0], FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[0] ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); + shift = find_guarded_bits_fx( N[0] ); + ms_ptr_e = sub( 31, sub( 20, shift ) ); + scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ + + /* set S to zero */ + set32_fx( ms_ptr_fx[1], 0, NPART ); + + /* compute M gain */ + gain_fx[0] = 0; + move32(); + tmp_e = 15; + move16(); + tmp = Inv16( N[0], &tmp_e ); + FOR( p = 0; p < N[0]; p++ ) + { + gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) ); // Q23 + move32(); + } + gain_fx[0] = L_sub( L_shl( Mpy_32_16_1( E_fx[0], shl( tmp, tmp_e ) ), Q23 - Q18 ), L_shl( gain_fx[0], ms_ptr_e - 8 ) ); // Q23 + move32(); + + apply_scale( &gain_fx[0], sts[0]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[0]->hDtxEnc->last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + + /* quantize gain */ + gain_idx[0] = extract_l( Mpy_32_32_r( L_add( gain_fx[0], 251658240 ), 384 ) ); + move16(); + gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) ); + move16(); + + gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 /* 0.66 in Q15 */ ); // Q23 + move32(); + gain_fx[1] = gain_fx[0]; // Q23 + move32(); + + /* undo M/S */ + convertToMS_fx( NPART, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); + + /* restore channel noise envelopes */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; + HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; + + Word32 pow; + Word16 e_lr_out[NPART]; + tmp_e = -MAX_16; + FOR( p = 0; p < N[ch]; p++ ) + { + pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ + pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */ + pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/ + lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); + tmp_e = s_max( tmp_e, e_lr_out[p] ); + } + + FOR( p = 0; p < N[ch]; p++ ) + { + lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], sub( e_lr_out[p], tmp_e ) ); // Q(31 - tmp_e) + } + + sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; + move16(); + lr_out_ptr_e[ch] = tmp_e; + move16(); + + /* NB last band energy compensation */ + IF( hFdCngCom->CngBandwidth == NB ) + { + lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE ); // Q(31 - tmp_e) + move32(); + } + ELSE IF( hFdCngCom->CngBandwidth == SWB && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE ); // Q(31 - tmp_e) + move32(); + } + /* scale bands and get scalefactors */ + scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N[ch], hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; + move16(); + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); + sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; + } + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = 0; + move16(); + sts[1]->hFdCngEnc->hFdCngCom->coherence_fx = 0; + move16(); + + /* ---- Write SID bitstream ---- */ + + /* side info */ + push_indice( sts[0]->hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( sts[0]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); + IF( EQ_16( sts[0]->L_frame, L_FRAME16k ) ) + { + push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 1, 1 ); + } + ELSE + { + push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 0, 1 ); + } + + /* noise shapes and channel gains */ + FOR( Word16 i = 0; i < FD_CNG_stages_37bits; i++ ) + { + push_indice( sts[0]->hBstr, IND_LSF, indices[0][i], bits_37bits[i] ); + } + push_indice( sts[0]->hBstr, IND_ENERGY, gain_idx[0], 7 ); + + return; +} diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c deleted file mode 100644 index efd1b44d2..000000000 --- a/lib_enc/find_tilt.c +++ /dev/null @@ -1,303 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ - - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * find_tilt() - * - * Find LF/HF energy ratio - *-------------------------------------------------------------------*/ -void find_tilt_ivas_fx( - const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ - const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ - const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/ - const Word16 q_bckr, /* i : Q of bckr Q0*/ - Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ - const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ - const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ - const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/ - const Word16 q_lf_E, /* i : Q of lf_E */ - const Word16 corr_shift, /* i : normalized correlation correction Q15*/ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 max_band, /* i : maximum critical band */ - Word32 hp_E[], /* o : energy in HF Q_new*/ - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16 */ - Word16 Opt_vbr_mode ) -{ - Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp; - const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E; - Word16 tmp, freq, f0, f1, f2, mean_voi, bin; - Word16 i, nb_bands; - Word16 e_tmp, m_tmp; - Word16 m_Fs, e_Fs; - Word16 m_cnt, e_cnt; - Word16 m_hpE, e_hpE; - Word64 sum; - Word16 inv_bands, q_lp_E; - Word32 Le_min_scaled, Ltmp2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - move32(); - move32(); - /*-----------------------------------------------------------------* - * Initializations - *-----------------------------------------------------------------*/ - - IF( ( bwidth != NB ) ) - { - /* WB processing */ - bin = BIN4_FX; - move16(); /* First useful frequency bin ~ 50 Hz */ - pt_bands = fr_bands; /* Q_new */ - tmp_E = lf_E; /* Q_new - 2 */ - pt_bckr = bckr; /* Q_new */ - nb_bands = 10; - inv_bands = 3277 /* 1/10 in Q15 */; - move16(); - move16(); - } - ELSE - { - /* NB processing */ - bin = 3 * BIN4_FX; /* First useful frequency bin ~ 150 Hz */ - pt_bands = fr_bands + 1; /* Exlcude 1st critical band */ - tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */ - pt_bckr = bckr + 1; /* Exlcude 1st critical band */ - nb_bands = 9; - inv_bands = 3641; /* 1/9 in Q15 */ - move16(); - move16(); /* Nb. of "low" frequency bands taken into account in NB processing */ - } - - /*-----------------------------------------------------------------* - * Find spectrum tilt - *-----------------------------------------------------------------*/ - - pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */ - hf_bands = fr_bands; - - /* bckr + voicing */ - /*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */ - sum = 0; - move64(); - FOR( i = 0; i < nb_bands; i++ ) - { - sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16 - } - lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr - /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ - hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr - if ( hp_bckr == 0 ) /* Avoid division by zero. */ - { - hp_bckr = L_deposit_l( 1 ); - } - Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp ); - Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ ); - Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) ); - *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16 - move32(); - - test(); - IF( EQ_16( codec_mode, MODE2 ) || EQ_16( Opt_vbr_mode, 1 ) ) - { - /*lp_bckr *= FACT;*/ - /*hp_bckr *= FACT;*/ - lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new */ - hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */ - } - /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ - Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 - Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 - Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 - mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 - - /*f0 = INT_FS_FX / pitch[2];*/ - e_tmp = norm_s( pitch[2] ); - m_tmp = shl( pitch[2], e_tmp ); - - m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */ - e_Fs = sub( 15, e_tmp ); - f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */ - - Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands=q_bckr - - FOR( i = 0; i < 2; i++ ) - { - /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ - Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands - Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands - - Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31 - if ( Opt_vbr_mode == 0 ) - { - Ltmp2 = L_max( Ltmp, Le_min_scaled ); // q_fr_bands - } - hp_E[i] = L_max( Ltmp2, 1 ); // to prevent division by zero - move32(); - - test(); - IF( GT_16( mean_voi, TH_COR_FX ) && LT_16( pitch[2], TH_PIT_FX ) ) /* High-pitched voiced frames */ - { - freq = bin; // Q4 - move16(); /* 1st useful frequency bin */ - m_cnt = 0; - move16(); - sum = 0; - move64(); - - f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */ - f2 = f0; - move16(); - WHILE( LE_16( freq, 20320 /* 1270.0f in Q4 */ ) ) /* End frequency of 10th critical band */ - { - FOR( ; freq <= f1; freq += BIN4_FX ) - { - /* include only bins sufficiently close to harmonics */ - tmp = sub( freq, f2 ); - IF( L_mac0( -TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) - { - sum = W_mac_32_16( sum, *pt_E, 1 ); // q_lf_E+1 - m_cnt = add( m_cnt, 1 ); - } - pt_E++; - } - f1 = add_o( f1, f0, &Overflow ); - f2 = add_o( f2, f0, &Overflow ); - } - /*lp_E = lp_E / (float)cnt - lp_bckr;*/ - e_tmp = sub( W_norm( sum ), 1 ); - m_tmp = extract_h( W_extract_h( W_shl( sum, e_tmp ) ) ); // q_lf_E+1+e_tmp-32-16 - e_tmp = sub( add( q_lf_E, e_tmp ), 47 ); - - e_cnt = norm_s( m_cnt ); - m_cnt = shl( m_cnt, e_cnt ); // e_cnt - - m_tmp = div_s( m_tmp, m_cnt ); // Q15+e_tmp-e_cnt - e_tmp = add( Q15, sub( e_tmp, e_cnt ) ); - sum = W_shl( m_tmp, sub( add( q_bckr, 1 ), e_tmp ) ); // q_bckr+1 - sum = W_msu_32_16( sum, lp_bckr, 1 ); // q_bckr+1 - q_lp_E = W_norm( sum ); - lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32 - q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 ); - - pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */ - } - ELSE /* Other than high-pitched voiced frames */ - { - /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */ - sum = 0; - move64(); - FOR( Word16 j = 0; j < nb_bands; j++ ) - { - sum = W_mac_32_16( sum, pt_bands[j], inv_bands ); // q_fr_bands+16 - } - sum = W_mac_32_16( sum, lp_bckr, -ONE_IN_Q15 ); // q_fr_bands+16 - lp_E = W_round48_L( sum ); // q_fr_bands=q_bckr - q_lp_E = q_bckr; // q_fr_bands=q_bckr - move16(); - } - test(); - IF( Opt_vbr_mode == 0 && GT_32( L_shl_sat( Le_min_scaled, sub( q_lp_E, q_bckr ) ), lp_E ) ) - { - lp_E = E_MIN_FXQ31; - q_lp_E = Q31; - move32(); - move16(); - } - if ( Opt_vbr_mode != 0 ) - { - lp_E = L_max( lp_E, 0 ); // q_lp_E - } - /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */ - - if ( lp_E == 0 ) - { - ee[i] = 0; - move32(); - } - test(); - IF( lp_E != 0 ) - { - e_tmp = sub( norm_l( lp_E ), 1 ); - m_tmp = extract_h( L_shl( lp_E, e_tmp ) ); // e_tmp+q_lp_E-16 - e_hpE = norm_l( hp_E[i] ); - m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 - m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) - e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ - move32(); - } - - IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ - { - Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ - IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ - { - Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ - ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ - move32(); /* x8 */ - } - ELSE - { - ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ ); - move32(); /* 6/8 */ - } - } - - pt_bands += NB_BANDS; /* Update for next half-frame */ - hf_bands += NB_BANDS; - } - - return; -} diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 44ad404e3..ea71b09bc 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -240,3 +240,255 @@ void find_tilt_fx( return; } + +/*-------------------------------------------------------------------* + * find_tilt() + * + * Find LF/HF energy ratio + *-------------------------------------------------------------------*/ +void find_tilt_ivas_fx( + const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ + const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ + const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/ + const Word16 q_bckr, /* i : Q of bckr Q0*/ + Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ + const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ + const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ + const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/ + const Word16 q_lf_E, /* i : Q of lf_E */ + const Word16 corr_shift, /* i : normalized correlation correction Q15*/ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 max_band, /* i : maximum critical band */ + Word32 hp_E[], /* o : energy in HF Q_new*/ + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16 */ + Word16 Opt_vbr_mode ) +{ + Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp; + const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E; + Word16 tmp, freq, f0, f1, f2, mean_voi, bin; + Word16 i, nb_bands; + Word16 e_tmp, m_tmp; + Word16 m_Fs, e_Fs; + Word16 m_cnt, e_cnt; + Word16 m_hpE, e_hpE; + Word64 sum; + Word16 inv_bands, q_lp_E; + Word32 Le_min_scaled, Ltmp2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + move32(); + move32(); + /*-----------------------------------------------------------------* + * Initializations + *-----------------------------------------------------------------*/ + + IF( ( bwidth != NB ) ) + { + /* WB processing */ + bin = BIN4_FX; + move16(); /* First useful frequency bin ~ 50 Hz */ + pt_bands = fr_bands; /* Q_new */ + tmp_E = lf_E; /* Q_new - 2 */ + pt_bckr = bckr; /* Q_new */ + nb_bands = 10; + inv_bands = 3277 /* 1/10 in Q15 */; + move16(); + move16(); + } + ELSE + { + /* NB processing */ + bin = 3 * BIN4_FX; /* First useful frequency bin ~ 150 Hz */ + pt_bands = fr_bands + 1; /* Exlcude 1st critical band */ + tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */ + pt_bckr = bckr + 1; /* Exlcude 1st critical band */ + nb_bands = 9; + inv_bands = 3641; /* 1/9 in Q15 */ + move16(); + move16(); /* Nb. of "low" frequency bands taken into account in NB processing */ + } + + /*-----------------------------------------------------------------* + * Find spectrum tilt + *-----------------------------------------------------------------*/ + + pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */ + hf_bands = fr_bands; + + /* bckr + voicing */ + /*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */ + sum = 0; + move64(); + FOR( i = 0; i < nb_bands; i++ ) + { + sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16 + } + lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr + /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ + hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr + if ( hp_bckr == 0 ) /* Avoid division by zero. */ + { + hp_bckr = L_deposit_l( 1 ); + } + Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp ); + Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ ); + Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) ); + *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16 + move32(); + + test(); + IF( EQ_16( codec_mode, MODE2 ) || EQ_16( Opt_vbr_mode, 1 ) ) + { + /*lp_bckr *= FACT;*/ + /*hp_bckr *= FACT;*/ + lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new */ + hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */ + } + /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ + Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 + mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 + + /*f0 = INT_FS_FX / pitch[2];*/ + e_tmp = norm_s( pitch[2] ); + m_tmp = shl( pitch[2], e_tmp ); + + m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */ + e_Fs = sub( 15, e_tmp ); + f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */ + + Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands=q_bckr + + FOR( i = 0; i < 2; i++ ) + { + /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ + Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands + Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands + + Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31 + if ( Opt_vbr_mode == 0 ) + { + Ltmp2 = L_max( Ltmp, Le_min_scaled ); // q_fr_bands + } + hp_E[i] = L_max( Ltmp2, 1 ); // to prevent division by zero + move32(); + + test(); + IF( GT_16( mean_voi, TH_COR_FX ) && LT_16( pitch[2], TH_PIT_FX ) ) /* High-pitched voiced frames */ + { + freq = bin; // Q4 + move16(); /* 1st useful frequency bin */ + m_cnt = 0; + move16(); + sum = 0; + move64(); + + f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */ + f2 = f0; + move16(); + WHILE( LE_16( freq, 20320 /* 1270.0f in Q4 */ ) ) /* End frequency of 10th critical band */ + { + FOR( ; freq <= f1; freq += BIN4_FX ) + { + /* include only bins sufficiently close to harmonics */ + tmp = sub( freq, f2 ); + IF( L_mac0( -TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) + { + sum = W_mac_32_16( sum, *pt_E, 1 ); // q_lf_E+1 + m_cnt = add( m_cnt, 1 ); + } + pt_E++; + } + f1 = add_o( f1, f0, &Overflow ); + f2 = add_o( f2, f0, &Overflow ); + } + /*lp_E = lp_E / (float)cnt - lp_bckr;*/ + e_tmp = sub( W_norm( sum ), 1 ); + m_tmp = extract_h( W_extract_h( W_shl( sum, e_tmp ) ) ); // q_lf_E+1+e_tmp-32-16 + e_tmp = sub( add( q_lf_E, e_tmp ), 47 ); + + e_cnt = norm_s( m_cnt ); + m_cnt = shl( m_cnt, e_cnt ); // e_cnt + + m_tmp = div_s( m_tmp, m_cnt ); // Q15+e_tmp-e_cnt + e_tmp = add( Q15, sub( e_tmp, e_cnt ) ); + sum = W_shl( m_tmp, sub( add( q_bckr, 1 ), e_tmp ) ); // q_bckr+1 + sum = W_msu_32_16( sum, lp_bckr, 1 ); // q_bckr+1 + q_lp_E = W_norm( sum ); + lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32 + q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 ); + + pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */ + } + ELSE /* Other than high-pitched voiced frames */ + { + /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */ + sum = 0; + move64(); + FOR( Word16 j = 0; j < nb_bands; j++ ) + { + sum = W_mac_32_16( sum, pt_bands[j], inv_bands ); // q_fr_bands+16 + } + sum = W_mac_32_16( sum, lp_bckr, -ONE_IN_Q15 ); // q_fr_bands+16 + lp_E = W_round48_L( sum ); // q_fr_bands=q_bckr + q_lp_E = q_bckr; // q_fr_bands=q_bckr + move16(); + } + test(); + IF( Opt_vbr_mode == 0 && GT_32( L_shl_sat( Le_min_scaled, sub( q_lp_E, q_bckr ) ), lp_E ) ) + { + lp_E = E_MIN_FXQ31; + q_lp_E = Q31; + move32(); + move16(); + } + if ( Opt_vbr_mode != 0 ) + { + lp_E = L_max( lp_E, 0 ); // q_lp_E + } + /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */ + + if ( lp_E == 0 ) + { + ee[i] = 0; + move32(); + } + test(); + IF( lp_E != 0 ) + { + e_tmp = sub( norm_l( lp_E ), 1 ); + m_tmp = extract_h( L_shl( lp_E, e_tmp ) ); // e_tmp+q_lp_E-16 + e_hpE = norm_l( hp_E[i] ); + m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 + m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) + e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + move32(); + } + + IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ + { + Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ + IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ + { + Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ + ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ + move32(); /* x8 */ + } + ELSE + { + ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ ); + move32(); /* 6/8 */ + } + } + + pt_bands += NB_BANDS; /* Update for next half-frame */ + hf_bands += NB_BANDS; + } + + return; +} diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c deleted file mode 100644 index c6ae02a76..000000000 --- a/lib_enc/find_uv.c +++ /dev/null @@ -1,660 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define L_ENR ( NB_SSF + 2 ) - -/*-------------------------------------------------------------------* - * find_ener_decrease() - * - * Find maximum energy ratio between short sub-subframes in case - * energy is trailing off after a spike - *-------------------------------------------------------------------*/ - -/*! r: maximum energy ratio */ -static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ - const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ - const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ -) -{ - Word16 i, j, end, flag; - Word16 wtmp0, wtmp1; - Word32 maxEnr, minEnr; - Word16 dE2, exp0, exp1; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - dE2 = 0; - move16(); - - j = add( ind_deltaMax, 2 ); /* Q0 */ - move16(); - end = add( j, L_ENR ); - move16(); - maxEnr = L_add( pt_enr_ssf[j], 0 ); - j = add( j, 1 ); - flag = 0; - move16(); - FOR( i = j; i < end; i++ ) - { - test(); - IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) ) - { - maxEnr = pt_enr_ssf[i]; /* Qx */ - j = add( j, 1 ); - } - ELSE - { - flag = 1; - move16(); - } - } - - minEnr = L_add( maxEnr, 0 ); - FOR( i = j; i < end; i++ ) - { - minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */ - } - - - minEnr = L_add_sat( minEnr, 100000 ); - exp0 = norm_l( minEnr ); - wtmp0 = extract_h( L_shl( minEnr, exp0 ) ); - exp1 = sub( norm_l( maxEnr ), 1 ); - wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); - wtmp1 = div_s( wtmp1, wtmp0 ); - dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ - - return dE2; -} - -/*-------------------------------------------------------------------* - * find_uv() - * - * Decision about coder type - *-------------------------------------------------------------------*/ -Word16 find_uv_ivas_fx( /* o : coding type */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF q_hp_E*/ - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 last_core_orig, /* i : original last core Q0*/ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const Word16 Q_new, - const Word16 q_hp_E ) -{ - Word16 coder_type, i; - Word32 mean_ee, dE1, fac_32; - const Word16 *pt_speech; - Word32 L_tmp, enr_ssf[2 * NB_SSF + 2 * NB_SSF + 2], E_min_th; - Word16 dE2; - Word16 ind_deltaMax, tmp_offset_flag; - Word32 Ltmp0, *pt_enr_ssf, *pt_enr_ssf1, dE2_th; - Word16 exp0, exp1; - Word16 wtmp0, wtmp1; - Word16 fac, mean_voi3, dE3; - Word16 relE_thres; - Word16 mean_voi3_offset; - Word16 voicing_m, dpit1, dpit2, dpit3; - Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE; - NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - Word16 Last_Resort; - Word16 vadnoise; - - IF( hSC_VBR != NULL ) - { - Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ - move16(); - vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */ - move16(); - } - ELSE - { - Last_Resort = 0; - move16(); - vadnoise = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Detect sudden energy increases to catch voice and music - * temporal events (dE1) - * - * - Find maximum energy per short subblocks. - * Two subblock sets are used shifted by half the subblock length - * - Find maximum energy ratio between adjacent subblocks - *-----------------------------------------------------------------*/ - - /* Find maximum energy per short subblocks */ - pt_speech = speech - SSF; - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) - { - emaximum_fx( Q_new, pt_speech, SSF, pt_enr_ssf ); - pt_speech += ( SSF / 2 ); - pt_enr_ssf++; - } - - dE1 = 0; - move16(); - ind_deltaMax = 0; - move16(); - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - pt_enr_ssf1 = pt_enr_ssf + 2; - - /* Test on energy increase between adjacent sub-subframes */ - exp1 = 0; - move16(); - FOR( i = 0; i < 2 * NB_SSF; i++ ) - { - /*fac = *pt_enr_ssf1 / (*pt_enr_ssf + 1);*/ - Ltmp0 = L_max( *pt_enr_ssf, 1 ); - exp0 = norm_l( Ltmp0 ); - wtmp0 = extract_h( L_shl( Ltmp0, exp0 ) ); - exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); - wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); - fac = div_s( wtmp1, wtmp0 ); - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ - - if ( GT_32( fac_32, dE1 ) ) - { - ind_deltaMax = i; - move16(); - } - - dE1 = L_max( dE1, fac_32 ); /* Q13 */ - - pt_enr_ssf++; - pt_enr_ssf1++; - } - - IF( hStereoClassif != NULL ) - { - IF( st_fx->idchan == 0 ) - { - hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */ - move32(); - hStereoClassif->dE1_ch1_e = 31 - Q13; - move16(); - } - ELSE - { - hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */ - move32(); - hStereoClassif->dE1_ch2_e = 31 - Q13; - move16(); - } - } - - if ( dE1X != NULL ) - { - *dE1X = dE1; /* Q13 */ - move32(); - } - - /*-----------------------------------------------------------------* - * Average spectral tilt - * Average voicing (normalized correlation) - *-----------------------------------------------------------------*/ - - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ - mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ - mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ - - /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ - Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ - Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ - mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ - /*-----------------------------------------------------------------* - * Total frame energy difference (dE3) - *-----------------------------------------------------------------*/ - - dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ - - /*-----------------------------------------------------------------* - * Energy decrease after spike (dE2) - *-----------------------------------------------------------------*/ - - /* set different thresholds and conditions for NB and WB input */ - dE2_th = 30 << 10; - move32(); - nb_cond = 1; - move16(); /* no additional condition for WB input */ - IF( st_fx->input_bwidth == NB ) - { - dE2_th = 21 << 10; - move32(); - if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ - { - nb_cond = 0; - move16(); - } - } - - /* calcualte maximum energy decrease */ - dE2 = 0; - move16(); /* Test on energy decrease after an energy spike */ - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - - test(); - IF( GT_32( dE1, 30 << 13 ) && nb_cond ) /*>30 Q13*/ - { - IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) ) - { - st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */ - move16(); - Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */ - } - ELSE - { - st_fx->old_ind_deltaMax = -1; - move16(); - dE2 = find_ener_decrease_fx( ind_deltaMax, pt_enr_ssf ); /*Q10*/ - - if ( GT_32( dE2, dE2_th ) ) - { - st_fx->spike_hyst = 0; - move16(); - } - } - } - ELSE - { - IF( st_fx->old_ind_deltaMax >= 0 ) - { - Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */ - dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */ - - if ( GT_32( dE2, dE2_th ) ) - { - st_fx->spike_hyst = 1; - move16(); - } - } - - st_fx->old_ind_deltaMax = -1; - move16(); - } - - /*-----------------------------------------------------------------* - * Detection of voiced offsets (tmp_offset_flag) - *-----------------------------------------------------------------*/ - - tmp_offset_flag = 1; - move16(); - - IF( st_fx->input_bwidth != NB ) - { - ee0_th = 154; /*2.4 in Q6 */ - move16(); - voi_th = 24248; /*0.74f Q15 */ - move16(); - } - ELSE - { - ee0_th = 627; /*9.8f Q6 */ - move16(); - voi_th = 24904; /*0.76f Q15*/ - move16(); - } - - E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); - - test(); - test(); - test(); - IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ - ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ - { - tmp_offset_flag = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Decision about UC - *-----------------------------------------------------------------*/ - - /* SC-VBR - set additional parameters and thresholds for SC-VBR */ - mean_voi3_offset = 0; - move16(); - flag_low_relE = 0; - move16(); - ee1_th = 608; /*9.5 Q6*/ - move16(); - test(); - test(); - IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */ - { - ee1_th = 544; /*8.5f Q6*/ - move16(); - - /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ - IF( st_fx->input_bwidth != NB ) - { - /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24 - IF( Last_Resort == 0 ) - { - /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24 - } - relE_thres = round_fx( L_tmp ); - } - ELSE - { - - /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24 - relE_thres = round_fx( L_tmp ); - } - relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ - - /* SC-VBR = set flag on low relative energy */ - if ( LT_16( relE, relE_thres ) ) - { - flag_low_relE = 1; - move16(); - } - - /* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */ - test(); - if ( st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */ - { - mean_voi3_offset = 1638; /*0.05f Q15*/ - move16(); - } - } - - /* make decision whether frame is unvoiced */ - coder_type = GENERIC; - move16(); - IF( st_fx->input_bwidth == NB ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ - { - coder_type = UNVOICED; - move16(); - } - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ - { - coder_type = UNVOICED; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Decision about VC - *-----------------------------------------------------------------*/ - if ( st_fx->Opt_SC_VBR ) - { - hSC_VBR->set_ppp_generic = 0; - } - move16(); - - test(); - test(); - IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) ) - { - dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); /* Q6 */ - dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); /* Q6 */ - dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); /* Q6 */ - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ - ( LT_16( dpit1, 3 << 6 ) ) && - ( LT_16( dpit2, 3 << 6 ) ) && - ( LT_16( dpit3, 3 << 6 ) ) ) - { - coder_type = VOICED; - move16(); - } - ELSE IF( st_fx->Opt_SC_VBR && st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 64 /* 1.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ - ( LT_16( dpit1, 5 << 6 ) ) && - ( LT_16( dpit2, 5 << 6 ) ) && - ( LT_16( dpit3, 5 << 6 ) ) ) - { - hSC_VBR->set_ppp_generic = 1; - move16(); - coder_type = VOICED; - move16(); - } - } - - /* set VOICED mode for frames with very stable pitch and high correlation - and avoid to switch to AUDIO/MUSIC later */ - voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ ); /* Q15 */ - test(); - test(); - test(); - test(); - test(); - IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) && - GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) ) - { - coder_type = VOICED; - move16(); - *flag_spitch = 1; - move16(); /*to avoid switch to AUDIO/MUSIC later*/ - } - } - - /*-----------------------------------------------------------------* - * Channel-aware mode - set RF mode and total bitrate - *-----------------------------------------------------------------*/ - - st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */ - move16(); - - IF( EQ_16( coder_type, GENERIC ) ) - { - test(); - test(); - test(); - test(); - IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */ - ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */ - ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */ - - { - st_fx->rf_mode = 0; - move16(); - /* Current frame cannot be compressed to pack the partial redundancy;*/ - - IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) - { - core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); - } - } - } - - /*-----------------------------------------------------------------* - * UNCLR classifier - *-----------------------------------------------------------------*/ - - IF( hStereoClassif != NULL ) - { - test(); - test(); - test(); - test(); - test(); - IF( st_fx->element_mode > EVS_MONO && ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, UNVOICED ) || coder_type == INACTIVE || st_fx->localVAD == 0 ) && LT_16( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], MAX_UV_CNT ) ) - { - hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = add( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], 1 ); - move16(); - } - ELSE - { - hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = 0; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Updates - *-----------------------------------------------------------------*/ - - /* update spike hysteresis parameters */ - test(); - if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) ) - { - st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */ - move16(); - } - - /* reset spike hysteresis */ - test(); - test(); - test(); - if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && - ( GT_16( dE3, 5 << 8 ) || /* energy increases */ - ( GT_16( relE, -3328 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* normalized correlation is high */ - { - st_fx->spike_hyst = -1; - move16(); - } - - /* update tilt parameters */ - st_fx->ee_old_fx = ee[1]; - move32(); /*Q6*/ - st_fx->old_dE1_fx = dE1; - move32(); /*Q13*/ - - /* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */ - st_fx->coder_type_raw = coder_type; /* Q0 */ - move16(); - - return coder_type; -} -/*-------------------------------------------------------------------* - * find_uv() - * - * Decision about coder type - *-------------------------------------------------------------------*/ diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 3f4c8abc7..200e538e4 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -618,3 +618,542 @@ Word16 find_uv_fx( /* o : coding type */ return coder_type; } + +/*-------------------------------------------------------------------* + * find_uv() + * + * Decision about coder type + *-------------------------------------------------------------------*/ +Word16 find_uv_ivas_fx( /* o : coding type */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF q_hp_E*/ + Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ + const Word16 last_core_orig, /* i : original last core Q0*/ + STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ + const Word16 Q_new, + const Word16 q_hp_E ) +{ + Word16 coder_type, i; + Word32 mean_ee, dE1, fac_32; + const Word16 *pt_speech; + Word32 L_tmp, enr_ssf[2 * NB_SSF + 2 * NB_SSF + 2], E_min_th; + Word16 dE2; + Word16 ind_deltaMax, tmp_offset_flag; + Word32 Ltmp0, *pt_enr_ssf, *pt_enr_ssf1, dE2_th; + Word16 exp0, exp1; + Word16 wtmp0, wtmp1; + Word16 fac, mean_voi3, dE3; + Word16 relE_thres; + Word16 mean_voi3_offset; + Word16 voicing_m, dpit1, dpit2, dpit3; + Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE; + NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; + SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + Word16 Last_Resort; + Word16 vadnoise; + + IF( hSC_VBR != NULL ) + { + Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ + move16(); + vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */ + move16(); + } + ELSE + { + Last_Resort = 0; + move16(); + vadnoise = 0; + move16(); + } + + /*-----------------------------------------------------------------* + * Detect sudden energy increases to catch voice and music + * temporal events (dE1) + * + * - Find maximum energy per short subblocks. + * Two subblock sets are used shifted by half the subblock length + * - Find maximum energy ratio between adjacent subblocks + *-----------------------------------------------------------------*/ + + /* Find maximum energy per short subblocks */ + pt_speech = speech - SSF; + pt_enr_ssf = enr_ssf + 2 * NB_SSF; + FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) + { + emaximum_fx( Q_new, pt_speech, SSF, pt_enr_ssf ); + pt_speech += ( SSF / 2 ); + pt_enr_ssf++; + } + + dE1 = 0; + move16(); + ind_deltaMax = 0; + move16(); + pt_enr_ssf = enr_ssf + 2 * NB_SSF; + pt_enr_ssf1 = pt_enr_ssf + 2; + + /* Test on energy increase between adjacent sub-subframes */ + exp1 = 0; + move16(); + FOR( i = 0; i < 2 * NB_SSF; i++ ) + { + /*fac = *pt_enr_ssf1 / (*pt_enr_ssf + 1);*/ + Ltmp0 = L_max( *pt_enr_ssf, 1 ); + exp0 = norm_l( Ltmp0 ); + wtmp0 = extract_h( L_shl( Ltmp0, exp0 ) ); + exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); + wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); + fac = div_s( wtmp1, wtmp0 ); + fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ + + if ( GT_32( fac_32, dE1 ) ) + { + ind_deltaMax = i; + move16(); + } + + dE1 = L_max( dE1, fac_32 ); /* Q13 */ + + pt_enr_ssf++; + pt_enr_ssf1++; + } + + IF( hStereoClassif != NULL ) + { + IF( st_fx->idchan == 0 ) + { + hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */ + move32(); + hStereoClassif->dE1_ch1_e = 31 - Q13; + move16(); + } + ELSE + { + hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */ + move32(); + hStereoClassif->dE1_ch2_e = 31 - Q13; + move16(); + } + } + + if ( dE1X != NULL ) + { + *dE1X = dE1; /* Q13 */ + move32(); + } + + /*-----------------------------------------------------------------* + * Average spectral tilt + * Average voicing (normalized correlation) + *-----------------------------------------------------------------*/ + + /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ + mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ + mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ + + /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ + Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ + Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ + mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ + /*-----------------------------------------------------------------* + * Total frame energy difference (dE3) + *-----------------------------------------------------------------*/ + + dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ + + /*-----------------------------------------------------------------* + * Energy decrease after spike (dE2) + *-----------------------------------------------------------------*/ + + /* set different thresholds and conditions for NB and WB input */ + dE2_th = 30 << 10; + move32(); + nb_cond = 1; + move16(); /* no additional condition for WB input */ + IF( st_fx->input_bwidth == NB ) + { + dE2_th = 21 << 10; + move32(); + if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + { + nb_cond = 0; + move16(); + } + } + + /* calcualte maximum energy decrease */ + dE2 = 0; + move16(); /* Test on energy decrease after an energy spike */ + pt_enr_ssf = enr_ssf + 2 * NB_SSF; + + test(); + IF( GT_32( dE1, 30 << 13 ) && nb_cond ) /*>30 Q13*/ + { + IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) ) + { + st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */ + move16(); + Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */ + } + ELSE + { + st_fx->old_ind_deltaMax = -1; + move16(); + dE2 = find_ener_decrease_fx( ind_deltaMax, pt_enr_ssf ); /*Q10*/ + + if ( GT_32( dE2, dE2_th ) ) + { + st_fx->spike_hyst = 0; + move16(); + } + } + } + ELSE + { + IF( st_fx->old_ind_deltaMax >= 0 ) + { + Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */ + dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */ + + if ( GT_32( dE2, dE2_th ) ) + { + st_fx->spike_hyst = 1; + move16(); + } + } + + st_fx->old_ind_deltaMax = -1; + move16(); + } + + /*-----------------------------------------------------------------* + * Detection of voiced offsets (tmp_offset_flag) + *-----------------------------------------------------------------*/ + + tmp_offset_flag = 1; + move16(); + + IF( st_fx->input_bwidth != NB ) + { + ee0_th = 154; /*2.4 in Q6 */ + move16(); + voi_th = 24248; /*0.74f Q15 */ + move16(); + } + ELSE + { + ee0_th = 627; /*9.8f Q6 */ + move16(); + voi_th = 24904; /*0.76f Q15*/ + move16(); + } + + E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); + + test(); + test(); + test(); + IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ + ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ + ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ + { + tmp_offset_flag = 0; + move16(); + } + + /*-----------------------------------------------------------------* + * Decision about UC + *-----------------------------------------------------------------*/ + + /* SC-VBR - set additional parameters and thresholds for SC-VBR */ + mean_voi3_offset = 0; + move16(); + flag_low_relE = 0; + move16(); + ee1_th = 608; /*9.5 Q6*/ + move16(); + test(); + test(); + IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */ + { + ee1_th = 544; /*8.5f Q6*/ + move16(); + + /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ + IF( st_fx->input_bwidth != NB ) + { + /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24 + IF( Last_Resort == 0 ) + { + /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24 + } + relE_thres = round_fx( L_tmp ); + } + ELSE + { + + /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ + L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24 + relE_thres = round_fx( L_tmp ); + } + relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ + + /* SC-VBR = set flag on low relative energy */ + if ( LT_16( relE, relE_thres ) ) + { + flag_low_relE = 1; + move16(); + } + + /* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */ + test(); + if ( st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */ + { + mean_voi3_offset = 1638; /*0.05f Q15*/ + move16(); + } + } + + /* make decision whether frame is unvoiced */ + coder_type = GENERIC; + move16(); + IF( st_fx->input_bwidth == NB ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ + { + coder_type = UNVOICED; + move16(); + } + } + ELSE + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + { + coder_type = UNVOICED; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Decision about VC + *-----------------------------------------------------------------*/ + if ( st_fx->Opt_SC_VBR ) + { + hSC_VBR->set_ppp_generic = 0; + } + move16(); + + test(); + test(); + IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) ) + { + dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); /* Q6 */ + dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); /* Q6 */ + dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); /* Q6 */ + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */ + ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ + ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ + ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ + ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ + ( LT_16( dpit1, 3 << 6 ) ) && + ( LT_16( dpit2, 3 << 6 ) ) && + ( LT_16( dpit3, 3 << 6 ) ) ) + { + coder_type = VOICED; + move16(); + } + ELSE IF( st_fx->Opt_SC_VBR && st_fx->input_bwidth == NB && LT_16( vadnoise, 20 << 8 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */ + ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ + ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ + ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ + ( GT_32( mean_ee, 64 /* 1.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ + ( LT_16( dpit1, 5 << 6 ) ) && + ( LT_16( dpit2, 5 << 6 ) ) && + ( LT_16( dpit3, 5 << 6 ) ) ) + { + hSC_VBR->set_ppp_generic = 1; + move16(); + coder_type = VOICED; + move16(); + } + } + + /* set VOICED mode for frames with very stable pitch and high correlation + and avoid to switch to AUDIO/MUSIC later */ + voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ ); /* Q15 */ + test(); + test(); + test(); + test(); + test(); + IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) && + GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) ) + { + coder_type = VOICED; + move16(); + *flag_spitch = 1; + move16(); /*to avoid switch to AUDIO/MUSIC later*/ + } + } + + /*-----------------------------------------------------------------* + * Channel-aware mode - set RF mode and total bitrate + *-----------------------------------------------------------------*/ + + st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */ + move16(); + + IF( EQ_16( coder_type, GENERIC ) ) + { + test(); + test(); + test(); + test(); + IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ + ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ + ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */ + ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */ + ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */ + + { + st_fx->rf_mode = 0; + move16(); + /* Current frame cannot be compressed to pack the partial redundancy;*/ + + IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) + { + core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); + } + } + } + + /*-----------------------------------------------------------------* + * UNCLR classifier + *-----------------------------------------------------------------*/ + + IF( hStereoClassif != NULL ) + { + test(); + test(); + test(); + test(); + test(); + IF( st_fx->element_mode > EVS_MONO && ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, UNVOICED ) || coder_type == INACTIVE || st_fx->localVAD == 0 ) && LT_16( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], MAX_UV_CNT ) ) + { + hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = add( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], 1 ); + move16(); + } + ELSE + { + hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = 0; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Updates + *-----------------------------------------------------------------*/ + + /* update spike hysteresis parameters */ + test(); + if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) ) + { + st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */ + move16(); + } + + /* reset spike hysteresis */ + test(); + test(); + test(); + if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && + ( GT_16( dE3, 5 << 8 ) || /* energy increases */ + ( GT_16( relE, -3328 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* normalized correlation is high */ + { + st_fx->spike_hyst = -1; + move16(); + } + + /* update tilt parameters */ + st_fx->ee_old_fx = ee[1]; + move32(); /*Q6*/ + st_fx->old_dE1_fx = dE1; + move32(); /*Q13*/ + + /* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */ + st_fx->coder_type_raw = coder_type; /* Q0 */ + move16(); + + return coder_type; +} diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c deleted file mode 100644 index 89b77d351..000000000 --- a/lib_enc/find_wsp.c +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" -/*-------------------------------------------------------------------* - * ivas_find_wsp_fx() - * - * Compute weighted speech used in open-loop pitch search - *-------------------------------------------------------------------*/ -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, - /* i : A(z) filter coefficients */ // Q12 - Word16 *Aw_fx, - /* o : weighted A(z) filter coefficients */ // Q12 - const Word16 *speech_fx, - /* i : pointer to the denoised speech frame */ // Q_new - const Word16 tilt_fact, - /* i : tilt factor */ // Q15 - Word16 *wsp_fx, - /* o : poitnter to the weighted speech frame */ // Q_new - Word16 *mem_wsp_fx, - /* i/o: W(Z) denominator memory */ // Q_new - const Word16 gamma, - /* i : weighting factor */ // Q15 - const Word16 L_look /* i : look-ahead Q0*/ -) -{ - Word16 *p_Aw_fx, tmp_fx; - Word16 i_subfr; - - - /*-----------------------------------------------------------------* - * Compute weighted A(z) unquantized for subframes - *-----------------------------------------------------------------*/ - weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M ); - - /*-----------------------------------------------------------------* - * Compute weighted speech for all subframes - *-----------------------------------------------------------------*/ - p_Aw_fx = Aw_fx; - FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr ) - { - Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 ); - p_Aw_fx += ( M + 1 ); - } - p_Aw_fx -= ( M + 1 ); - - /*-----------------------------------------------------------------* - * Weighted speech computation is extended on look-ahead - *-----------------------------------------------------------------*/ - - deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx ); - Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 ); - tmp_fx = *mem_wsp_fx; - deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); - return; -} diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index 7468c3dc7..d08922a2a 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -6,7 +6,7 @@ #include #include "options.h" #include "cnst.h" -//#include "prot_fx.h" +#include "prot.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -78,3 +78,60 @@ void find_wsp_fx( deemph_fx( &wsp[L_frame], preemph_fac, lookahead, &wtmp ); } } + +/*-------------------------------------------------------------------* + * ivas_find_wsp_fx() + * + * Compute weighted speech used in open-loop pitch search + *-------------------------------------------------------------------*/ +void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, + /* i : A(z) filter coefficients */ // Q12 + Word16 *Aw_fx, + /* o : weighted A(z) filter coefficients */ // Q12 + const Word16 *speech_fx, + /* i : pointer to the denoised speech frame */ // Q_new + const Word16 tilt_fact, + /* i : tilt factor */ // Q15 + Word16 *wsp_fx, + /* o : poitnter to the weighted speech frame */ // Q_new + Word16 *mem_wsp_fx, + /* i/o: W(Z) denominator memory */ // Q_new + const Word16 gamma, + /* i : weighting factor */ // Q15 + const Word16 L_look /* i : look-ahead Q0*/ +) +{ + Word16 *p_Aw_fx, tmp_fx; + Word16 i_subfr; + + + /*-----------------------------------------------------------------* + * Compute weighted A(z) unquantized for subframes + *-----------------------------------------------------------------*/ + weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M ); + + /*-----------------------------------------------------------------* + * Compute weighted speech for all subframes + *-----------------------------------------------------------------*/ + p_Aw_fx = Aw_fx; + FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr ) + { + Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 ); + p_Aw_fx += ( M + 1 ); + } + p_Aw_fx -= ( M + 1 ); + + /*-----------------------------------------------------------------* + * Weighted speech computation is extended on look-ahead + *-----------------------------------------------------------------*/ + + deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx ); + Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 ); + tmp_fx = *mem_wsp_fx; + deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); + return; +} diff --git a/lib_enc/frame_spec_dif_cor_rate.c b/lib_enc/frame_spec_dif_cor_rate.c deleted file mode 100644 index 9185f37bd..000000000 --- a/lib_enc/frame_spec_dif_cor_rate.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * frame_spec_dif_cor_rate() - * - * - *-------------------------------------------------------------------*/ diff --git a/lib_enc/gain_enc.c b/lib_enc/gain_enc.c deleted file mode 100644 index 276e20738..000000000 --- a/lib_enc/gain_enc.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define RANGE 64 - -/*---------------------------------------------------------------------* - * Es_pred_enc() - * - * Calculation and quantization of average predicted innovation energy to be - *---------------------------------------------------------------------*/ diff --git a/lib_enc/gs_enc.c b/lib_enc/gs_enc.c deleted file mode 100644 index 900c381bf..000000000 --- a/lib_enc/gs_enc.c +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * GSC_enc_init() - * - * Initialize GSC encoder state structure - *-------------------------------------------------------------------*/ diff --git a/lib_enc/guided_plc_enc.c b/lib_enc/guided_plc_enc.c deleted file mode 100644 index 6c0e9022d..000000000 --- a/lib_enc/guided_plc_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "stat_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/hf_cod_amrwb.c b/lib_enc/hf_cod_amrwb.c deleted file mode 100644 index 7ea6e47a5..000000000 --- a/lib_enc/hf_cod_amrwb.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/hq_classifier_enc.c b/lib_enc/hq_classifier_enc.c deleted file mode 100644 index 634f42971..000000000 --- a/lib_enc/hq_classifier_enc.c +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -/*-----------------------------------------------------------------* - * Local constants - *-----------------------------------------------------------------*/ - -/*-----------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------*/ diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c deleted file mode 100644 index 24579e74e..000000000 --- a/lib_enc/hq_core_enc.c +++ /dev/null @@ -1,410 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -#include "prot_fx.h" -#include "prot_fx_enc.h" - -/*-------------------------------------------------------------------------- - * hq_core_enc() - * - * HQ core encoder - *--------------------------------------------------------------------------*/ - -void hq_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *audio_fx, /* i : input audio signal Q0 */ - const Word16 input_frame_orig, /* i : frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ -) -{ - Word16 i, is_transient, num_bits, extra_unused; - - Word32 t_audio_fx[L_FRAME48k_EXT]; - Word16 wtda_audio_fx16[2 * L_FRAME48k]; - Word32 wtda_audio_fx32[2 * L_FRAME48k]; - Word16 two_frames_buffer[2 * L_FRAME48k]; - Word16 tmp; - Word16 Aq_old_fx[M + 1]; - Word16 output_fx[L_FRAME48k]; - Word16 Q_audio; - Word16 out_q = 0, old_q = 0; - move16(); - move16(); - Word16 inner_frame, input_frame, L_frame; - Word16 L_spec, overlap, nz, tcx_offset; - Word16 left_overlap, right_overlap; - BSTR_ENC_HANDLE hBstr = st->hBstr; - Word16 q = 0; - Word16 exp; - move16(); - - push_wmops( "hq_core_enc" ); - - set16_fx( wtda_audio_fx16, 0, 2 * L_FRAME48k ); - set32_fx( wtda_audio_fx32, 0, 2 * L_FRAME48k ); - st->Nb_ACELP_frames = 0; - move16(); - set_zero_fx( t_audio_fx, L_FRAME48k_EXT ); - /* set input_frame length */ - input_frame = input_frame_orig; /* Q0 */ - - /* Sanity check, it should never happen at the encoder side (no BFI) */ - IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) - { - st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; - move16(); - } - ELSE - { - st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - - /*-------------------------------------------------------------------------- - * Preprocessing in the first HQ frame after ACELP frame - * Find the number of bits for PVQ coding - * Write signaling information - *--------------------------------------------------------------------------*/ - - num_bits = BASOP_Util_Divide3232_Scale( st->total_brate, FRAMES_PER_SEC, &exp ); /* Q15-exp */ - num_bits = shr( num_bits, sub( 15, exp ) ); /* Q0 */ - extra_unused = 0; - move16(); - - /*-------------------------------------------------------------------------- - * Detect signal transition - *--------------------------------------------------------------------------*/ - - is_transient = detect_transient_fx( audio_fx, input_frame, 0, st ); /* Q0 */ - move16(); - - test(); - test(); - IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) - { - /*-------------------------------------------------------------------------- - * IVAS switching frame - *--------------------------------------------------------------------------*/ - - L_spec = input_frame; - left_overlap = -1; - right_overlap = -1; - move16(); - move16(); - move16(); - - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio_fx16, 1, 1 ); - - q = 0; - move16(); - Q_audio = sub( Q16, q ); - TCX_MDCT( wtda_audio_fx16, t_audio_fx, &Q_audio, left_overlap, sub( L_spec, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); - Q_audio = sub( Q31, Q_audio ); -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ -#else - Copy_Scale_sig_16_32_DEPREC( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ -#endif - inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ - L_spec = l_spec_ext_tbl[st->bwidth]; /* Q0 */ - is_transient = 0; - move16(); - move16(); - move16(); - } - ELSE - { - /*-------------------------------------------------------------------------- - * Windowing and time-domain aliasing - * DCT transform - *--------------------------------------------------------------------------*/ - Q_audio = 0; - move16(); - Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); /* Q0 */ - Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); /* Q0 */ - st->q_old_inp = 0; - move16(); - st->q_inp = 0; - move16(); - Copy( st->old_input_signal_fx, two_frames_buffer, input_frame ); /* Q0 */ - Copy( audio_fx, two_frames_buffer + input_frame, input_frame ); /* Q0 */ - - wtda_fx( two_frames_buffer + input_frame, &Q_audio, wtda_audio_fx32, NULL, 0, - st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, input_frame ); - - test(); - IF( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) - { - /* Preprocessing in the first HQ frame after ACELP frame */ - core_switching_hq_prepare_enc_fx( st, &num_bits, input_frame, wtda_audio_fx32, two_frames_buffer + input_frame ); - - /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - IF( GT_16( num_bits, ACELP_48k_BITS ) ) - { - extra_unused = sub( num_bits, ACELP_48k_BITS ); - num_bits = ACELP_48k_BITS; - move16(); - } - } - - Word16 tmp_q = Q_audio; - move16(); - direct_transform_fx( wtda_audio_fx32, t_audio_fx, is_transient, input_frame, &Q_audio, st->element_mode ); - scale_sig32( wtda_audio_fx32, L_FRAME48k_EXT, sub( Q_audio, tmp_q ) ); /* Q_audio */ - - /* scale coefficients to their nominal level (8kHz) */ - IF( NE_16( input_frame, NORM_MDCT_FACTOR ) ) - { - UWord16 lsb; - tmp = mult_r( input_frame, 410 / 2 ); /* 1/8000 in Q15 */ - Word16 ener_match_fx = hq_nominal_scaling[tmp]; - move16(); - FOR( i = 0; i < input_frame; i++ ) - { - /*t_audio_q[i] *= ener_match; */ - Mpy_32_16_ss( t_audio_fx[i], ener_match_fx, &t_audio_fx[i], &lsb ); /* Q12 */ - move16(); - } - } - - /* limit encoded band-width according to the command-line OR BWD limitation */ - inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ - L_spec = l_spec_tbl[st->bwidth]; /* Q0 */ - - move16(); - move16(); - - - IF( GT_16( input_frame, inner_frame ) ) - { - IF( EQ_16( is_transient, 1 ) ) - { - FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) - { - tmp = shr( inner_frame, 2 ); - Copy32( t_audio_fx + i_mult2( i, shr( input_frame, 2 ) ), t_audio_fx + i_mult2( i, tmp ), tmp ); /* Q_audio */ - } - } - - set32_fx( t_audio_fx + inner_frame, 0, sub( input_frame, inner_frame ) ); - } - } - - - /* subtract signaling bits */ - num_bits = sub( num_bits, hBstr->nb_bits_tot ); /* Q0 */ - - /*-------------------------------------------------------------------------- - * High-band gain control in case of BWS - *--------------------------------------------------------------------------*/ - - IF( st->bwidth_sw_cnt > 0 ) - { - Word32 L_tmp; - tmp = BASOP_Util_Divide1616_Scale( 3, BWS_TRAN_PERIOD, &exp ); /* Q15-exp */ - shr( tmp, exp ); - L_tmp = L_deposit_h( tmp ); /* Q31-exp */ - IF( is_transient ) - { - FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) - { - v_multc_fixed( t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), L_tmp, t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), sub( shr( inner_frame, 2 ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ) ); // Q_audio + Q31 - Q31 -> Q_audio - } - } - ELSE - { - v_multc_fixed( t_audio_fx + L_FRAME16k, L_tmp, t_audio_fx + L_FRAME16k, L_spec - L_FRAME16k ); // Q_audio + Q31 - Q31 -> Q_audio - } - } - - /*-------------------------------------------------------------------------- - * Classify whether to put extra bits for FER mitigation - *--------------------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) && GT_32( st->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) - { - IF( Voicing_flag > 0 ) - { - push_indice( hBstr, IND_HQ_VOICING_FLAG, 1, 1 ); - num_bits = sub( num_bits, 1 ); - } - ELSE - { - push_indice( hBstr, IND_HQ_VOICING_FLAG, 0, 1 ); - num_bits = sub( num_bits, 1 ); - } - } - - /*-------------------------------------------------------------------------- - * Transform-domain encoding - *--------------------------------------------------------------------------*/ - - scale_sig32( t_audio_fx, L_FRAME48k_EXT, sub( Q12, Q_audio ) ); - scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q12, Q_audio ) ); - Q_audio = 12; - move16(); - IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) - { - - hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); - } - ELSE - { - /* HQ high rate encoder */ - hq_hr_enc_ivas_fx( st, t_audio_fx, L_spec, &num_bits, is_transient, vad_hover_flag ); - } - - /* write all unused bits to the bitstream */ - num_bits = add( num_bits, extra_unused ); - - WHILE( GT_16( num_bits, 16 ) ) - { - push_indice( hBstr, IND_UNUSED, 0, 16 ); - num_bits = sub( num_bits, 16 ); - } - - IF( num_bits != 0 ) - { - push_indice( hBstr, IND_UNUSED, 0, num_bits ); - } - - test(); - test(); - IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) - { - overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */ - move16(); - - nz = NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ); - move16(); - L_frame = sub( st->L_frame + st->hTcxCfg->tcx_offset, st->hTcxCfg->lfacNext ); - tcx_offset = st->hTcxCfg->lfacNext; - move16(); - - set16_fx( Aq_old_fx, 0, M + 1 ); /* Dummy filter */ - Aq_old_fx[0] = 1; - move16(); - - /* Code taken from InternalTCXDecoder() */ - Copy_Scale_sig_32_16( wtda_audio_fx32, wtda_audio_fx16, 2 * L_FRAME48k, negate( Q_audio ) ); // Q0 - TCX_MDCT_Inverse( t_audio_fx, sub( sub( 31, Q_audio ), 15 ), wtda_audio_fx16, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); - - - /* Window current frame */ - Word16 tcx_offset_tmp; - - IF( tcx_offset < 0 ) - { - tcx_offset_tmp = negate( tcx_offset ); - } - ELSE - { - tcx_offset_tmp = 0; - move16(); - } - tcx_windowing_synthesis_current_frame( wtda_audio_fx16, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old_fx, st->hTcxCfg->tcx_mdct_window_trans, shr( st->L_frame, 1 ), tcx_offset_tmp, st->last_core, 0, 0 ); - - - /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ - Copy( wtda_audio_fx16 + sub( L_frame, nz ), st->hTcxEnc->old_out_fx, nz + overlap ); /* Q0 */ - set16_fx( st->hTcxEnc->old_out_fx + add( nz, overlap ), 0, nz ); - - tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out_fx + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP ); - - FOR( i = 0; i < nz / 2; i++ ) - { - // This implementation is diffrent in float code need to revisit to check its correctness. - st->hTcxEnc->old_out_fx[nz + overlap + i] = mult( wtda_audio_fx16[L_frame - 1 - i], st->hTcxCfg->tcx_aldo_window_1_trunc[i].v.re ); // Q0 + Q15 - Q15 -> Q0; - st->hTcxEnc->old_out_fx[nz / 2 + ( nz + overlap + i )] = mult( wtda_audio_fx16[nz / 2 + ( L_frame - 1 - i )], st->hTcxCfg->tcx_aldo_window_1_trunc[nz / 2 - 1 - i].v.im ); // Q0 + Q15 - Q15 -> Q0; - move16(); - move16(); - } - - Copy( wtda_audio_fx16 + sub( shr( overlap, 1 ), tcx_offset ), output_fx, st->L_frame ); /* Q0 */ - } - ELSE - { - Word16 tmp_q = Q_audio; - move16(); - Word32 ener_match_fx = SQRT2_FIXED; - move32(); - FOR( i = 0; i < input_frame; i++ ) - { - t_audio_fx[i] = Mpy_32_32( t_audio_fx[i], ener_match_fx ); /* Q12 - 1 -> Q11 */ - move32(); - } - - Q_audio = sub( Q_audio, 1 ); - scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, tmp_q ) ); /* Q_audio */ - Inverse_Transform( t_audio_fx, &Q_audio, wtda_audio_fx32, is_transient, L_FRAME16k, inner_frame, st->element_mode ); - - - out_q = Q_audio; - move16(); - window_ola_fx( wtda_audio_fx32, output_fx, &out_q, st->hTcxEnc->old_out_fx, &old_q, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); - - Scale_sig( output_fx, L_FRAME16k, negate( out_q ) ); /* Q0 */ - Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( old_q ) ); /* Q0 */ - st->hTcxEnc->Q_old_out = 0; - move16(); - } - - IF( st->element_mode > EVS_MONO ) - { - /* Store LB synthesis in case of switch to ACELP */ - Copy( output_fx, st->hLPDmem->old_exc, L_FRAME16k ); - st->hLPDmem->q_lpd_old_exc = 0; - move16(); - } - pop_wmops(); - - return; -} diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 6dc7bb5b9..11583ea11 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -7,6 +7,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ +#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -388,3 +389,361 @@ void HQ_core_enc_init_fx( return; } + +void hq_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *audio_fx, /* i : input audio signal Q0 */ + const Word16 input_frame_orig, /* i : frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ +) +{ + Word16 i, is_transient, num_bits, extra_unused; + + Word32 t_audio_fx[L_FRAME48k_EXT]; + Word16 wtda_audio_fx16[2 * L_FRAME48k]; + Word32 wtda_audio_fx32[2 * L_FRAME48k]; + Word16 two_frames_buffer[2 * L_FRAME48k]; + Word16 tmp; + Word16 Aq_old_fx[M + 1]; + Word16 output_fx[L_FRAME48k]; + Word16 Q_audio; + Word16 out_q = 0, old_q = 0; + move16(); + move16(); + Word16 inner_frame, input_frame, L_frame; + Word16 L_spec, overlap, nz, tcx_offset; + Word16 left_overlap, right_overlap; + BSTR_ENC_HANDLE hBstr = st->hBstr; + Word16 q = 0; + Word16 exp; + move16(); + + push_wmops( "hq_core_enc" ); + + set16_fx( wtda_audio_fx16, 0, 2 * L_FRAME48k ); + set32_fx( wtda_audio_fx32, 0, 2 * L_FRAME48k ); + st->Nb_ACELP_frames = 0; + move16(); + set_zero_fx( t_audio_fx, L_FRAME48k_EXT ); + /* set input_frame length */ + input_frame = input_frame_orig; /* Q0 */ + + /* Sanity check, it should never happen at the encoder side (no BFI) */ + IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) + { + st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; + move16(); + } + ELSE + { + st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + + /*-------------------------------------------------------------------------- + * Preprocessing in the first HQ frame after ACELP frame + * Find the number of bits for PVQ coding + * Write signaling information + *--------------------------------------------------------------------------*/ + + num_bits = BASOP_Util_Divide3232_Scale( st->total_brate, FRAMES_PER_SEC, &exp ); /* Q15-exp */ + num_bits = shr( num_bits, sub( 15, exp ) ); /* Q0 */ + extra_unused = 0; + move16(); + + /*-------------------------------------------------------------------------- + * Detect signal transition + *--------------------------------------------------------------------------*/ + + is_transient = detect_transient_fx( audio_fx, input_frame, 0, st ); /* Q0 */ + move16(); + + test(); + test(); + IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) + { + /*-------------------------------------------------------------------------- + * IVAS switching frame + *--------------------------------------------------------------------------*/ + + L_spec = input_frame; + left_overlap = -1; + right_overlap = -1; + move16(); + move16(); + move16(); + + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio_fx16, 1, 1 ); + + q = 0; + move16(); + Q_audio = sub( Q16, q ); + TCX_MDCT( wtda_audio_fx16, t_audio_fx, &Q_audio, left_overlap, sub( L_spec, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); + Q_audio = sub( Q31, Q_audio ); +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ +#else + Copy_Scale_sig_16_32_DEPREC( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ +#endif + inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ + L_spec = l_spec_ext_tbl[st->bwidth]; /* Q0 */ + is_transient = 0; + move16(); + move16(); + move16(); + } + ELSE + { + /*-------------------------------------------------------------------------- + * Windowing and time-domain aliasing + * DCT transform + *--------------------------------------------------------------------------*/ + Q_audio = 0; + move16(); + Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); /* Q0 */ + Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); /* Q0 */ + st->q_old_inp = 0; + move16(); + st->q_inp = 0; + move16(); + Copy( st->old_input_signal_fx, two_frames_buffer, input_frame ); /* Q0 */ + Copy( audio_fx, two_frames_buffer + input_frame, input_frame ); /* Q0 */ + + wtda_fx( two_frames_buffer + input_frame, &Q_audio, wtda_audio_fx32, NULL, 0, + st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, input_frame ); + + test(); + IF( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) + { + /* Preprocessing in the first HQ frame after ACELP frame */ + core_switching_hq_prepare_enc_fx( st, &num_bits, input_frame, wtda_audio_fx32, two_frames_buffer + input_frame ); + + /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ + IF( GT_16( num_bits, ACELP_48k_BITS ) ) + { + extra_unused = sub( num_bits, ACELP_48k_BITS ); + num_bits = ACELP_48k_BITS; + move16(); + } + } + + Word16 tmp_q = Q_audio; + move16(); + direct_transform_fx( wtda_audio_fx32, t_audio_fx, is_transient, input_frame, &Q_audio, st->element_mode ); + scale_sig32( wtda_audio_fx32, L_FRAME48k_EXT, sub( Q_audio, tmp_q ) ); /* Q_audio */ + + /* scale coefficients to their nominal level (8kHz) */ + IF( NE_16( input_frame, NORM_MDCT_FACTOR ) ) + { + UWord16 lsb; + tmp = mult_r( input_frame, 410 / 2 ); /* 1/8000 in Q15 */ + Word16 ener_match_fx = hq_nominal_scaling[tmp]; + move16(); + FOR( i = 0; i < input_frame; i++ ) + { + /*t_audio_q[i] *= ener_match; */ + Mpy_32_16_ss( t_audio_fx[i], ener_match_fx, &t_audio_fx[i], &lsb ); /* Q12 */ + move16(); + } + } + + /* limit encoded band-width according to the command-line OR BWD limitation */ + inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ + L_spec = l_spec_tbl[st->bwidth]; /* Q0 */ + + move16(); + move16(); + + + IF( GT_16( input_frame, inner_frame ) ) + { + IF( EQ_16( is_transient, 1 ) ) + { + FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) + { + tmp = shr( inner_frame, 2 ); + Copy32( t_audio_fx + i_mult2( i, shr( input_frame, 2 ) ), t_audio_fx + i_mult2( i, tmp ), tmp ); /* Q_audio */ + } + } + + set32_fx( t_audio_fx + inner_frame, 0, sub( input_frame, inner_frame ) ); + } + } + + + /* subtract signaling bits */ + num_bits = sub( num_bits, hBstr->nb_bits_tot ); /* Q0 */ + + /*-------------------------------------------------------------------------- + * High-band gain control in case of BWS + *--------------------------------------------------------------------------*/ + + IF( st->bwidth_sw_cnt > 0 ) + { + Word32 L_tmp; + tmp = BASOP_Util_Divide1616_Scale( 3, BWS_TRAN_PERIOD, &exp ); /* Q15-exp */ + shr( tmp, exp ); + L_tmp = L_deposit_h( tmp ); /* Q31-exp */ + IF( is_transient ) + { + FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) + { + v_multc_fixed( t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), L_tmp, t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), sub( shr( inner_frame, 2 ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ) ); // Q_audio + Q31 - Q31 -> Q_audio + } + } + ELSE + { + v_multc_fixed( t_audio_fx + L_FRAME16k, L_tmp, t_audio_fx + L_FRAME16k, L_spec - L_FRAME16k ); // Q_audio + Q31 - Q31 -> Q_audio + } + } + + /*-------------------------------------------------------------------------- + * Classify whether to put extra bits for FER mitigation + *--------------------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) && GT_32( st->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) + { + IF( Voicing_flag > 0 ) + { + push_indice( hBstr, IND_HQ_VOICING_FLAG, 1, 1 ); + num_bits = sub( num_bits, 1 ); + } + ELSE + { + push_indice( hBstr, IND_HQ_VOICING_FLAG, 0, 1 ); + num_bits = sub( num_bits, 1 ); + } + } + + /*-------------------------------------------------------------------------- + * Transform-domain encoding + *--------------------------------------------------------------------------*/ + + scale_sig32( t_audio_fx, L_FRAME48k_EXT, sub( Q12, Q_audio ) ); + scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q12, Q_audio ) ); + Q_audio = 12; + move16(); + IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) + { + + hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); + } + ELSE + { + /* HQ high rate encoder */ + hq_hr_enc_ivas_fx( st, t_audio_fx, L_spec, &num_bits, is_transient, vad_hover_flag ); + } + + /* write all unused bits to the bitstream */ + num_bits = add( num_bits, extra_unused ); + + WHILE( GT_16( num_bits, 16 ) ) + { + push_indice( hBstr, IND_UNUSED, 0, 16 ); + num_bits = sub( num_bits, 16 ); + } + + IF( num_bits != 0 ) + { + push_indice( hBstr, IND_UNUSED, 0, num_bits ); + } + + test(); + test(); + IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) + { + overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */ + move16(); + + nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS ); + move16(); + L_frame = sub( st->L_frame + st->hTcxCfg->tcx_offset, st->hTcxCfg->lfacNext ); + tcx_offset = st->hTcxCfg->lfacNext; + move16(); + + set16_fx( Aq_old_fx, 0, M + 1 ); /* Dummy filter */ + Aq_old_fx[0] = 1; + move16(); + + /* Code taken from InternalTCXDecoder() */ + Copy_Scale_sig_32_16( wtda_audio_fx32, wtda_audio_fx16, 2 * L_FRAME48k, negate( Q_audio ) ); // Q0 + TCX_MDCT_Inverse( t_audio_fx, sub( sub( 31, Q_audio ), 15 ), wtda_audio_fx16, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); + + + /* Window current frame */ + Word16 tcx_offset_tmp; + + IF( tcx_offset < 0 ) + { + tcx_offset_tmp = negate( tcx_offset ); + } + ELSE + { + tcx_offset_tmp = 0; + move16(); + } + tcx_windowing_synthesis_current_frame( wtda_audio_fx16, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old_fx, st->hTcxCfg->tcx_mdct_window_trans, shr( st->L_frame, 1 ), tcx_offset_tmp, st->last_core, 0, 0 ); + + + /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ + Copy( wtda_audio_fx16 + sub( L_frame, nz ), st->hTcxEnc->old_out_fx, nz + overlap ); /* Q0 */ + set16_fx( st->hTcxEnc->old_out_fx + add( nz, overlap ), 0, nz ); + + tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out_fx + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP ); + + FOR( i = 0; i < nz / 2; i++ ) + { + // This implementation is diffrent in float code need to revisit to check its correctness. + st->hTcxEnc->old_out_fx[nz + overlap + i] = mult( wtda_audio_fx16[L_frame - 1 - i], st->hTcxCfg->tcx_aldo_window_1_trunc[i].v.re ); // Q0 + Q15 - Q15 -> Q0; + st->hTcxEnc->old_out_fx[nz / 2 + ( nz + overlap + i )] = mult( wtda_audio_fx16[nz / 2 + ( L_frame - 1 - i )], st->hTcxCfg->tcx_aldo_window_1_trunc[nz / 2 - 1 - i].v.im ); // Q0 + Q15 - Q15 -> Q0; + move16(); + move16(); + } + + Copy( wtda_audio_fx16 + sub( shr( overlap, 1 ), tcx_offset ), output_fx, st->L_frame ); /* Q0 */ + } + ELSE + { + Word16 tmp_q = Q_audio; + move16(); + Word32 ener_match_fx = SQRT2_FIXED; + move32(); + FOR( i = 0; i < input_frame; i++ ) + { + t_audio_fx[i] = Mpy_32_32( t_audio_fx[i], ener_match_fx ); /* Q12 - 1 -> Q11 */ + move32(); + } + + Q_audio = sub( Q_audio, 1 ); + scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, tmp_q ) ); /* Q_audio */ + Inverse_Transform( t_audio_fx, &Q_audio, wtda_audio_fx32, is_transient, L_FRAME16k, inner_frame, st->element_mode ); + + + out_q = Q_audio; + move16(); + window_ola_fx( wtda_audio_fx32, output_fx, &out_q, st->hTcxEnc->old_out_fx, &old_q, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); + + Scale_sig( output_fx, L_FRAME16k, negate( out_q ) ); /* Q0 */ + Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( old_q ) ); /* Q0 */ + st->hTcxEnc->Q_old_out = 0; + move16(); + } + + IF( st->element_mode > EVS_MONO ) + { + /* Store LB synthesis in case of switch to ACELP */ + Copy( output_fx, st->hLPDmem->old_exc, L_FRAME16k ); + st->hLPDmem->q_lpd_old_exc = 0; + move16(); + } + pop_wmops(); + + return; +} diff --git a/lib_enc/hq_env_enc.c b/lib_enc/hq_env_enc.c deleted file mode 100644 index e8859676c..000000000 --- a/lib_enc/hq_env_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c deleted file mode 100644 index 42f661f6e..000000000 --- a/lib_enc/hq_hr_enc.c +++ /dev/null @@ -1,280 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_prot_fx.h" -#include "prot_fx_enc.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*--------------------------------------------------------------------------* - * hq_hr_enc() - * - * HQ high rate encoding routine - *--------------------------------------------------------------------------*/ - -void hq_hr_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *t_audio_fx, /* i/o: transform-domain coefficients Q12*/ - const Word16 length, /* i : length of spectrum Q0*/ - Word16 *num_bits, /* i/o: number of available bits Q0*/ - const Word16 is_transient, /* i : transient flag Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ -) -{ - Word16 nb_sfm; - Word16 sum, hcode_l; - Word16 difidx[NB_SFM]; - Word16 normqlg2[NB_SFM], ynrm[NB_SFM]; - Word16 nf_idx; - Word16 bits; - Word16 LCmode; - Word16 shape_bits, num_sfm, numnrmibits; - Word16 hqswb_clas; - Word16 num_env_bands; - Word16 Npeaks, start_norm; - Word16 difidx_org[NB_SFM]; - Word16 R[NB_SFM]; - Word16 peaks[HVQ_MAX_PEAKS]; - Word16 sfmsize[NB_SFM], sfm_start[NB_SFM], sfm_end[NB_SFM]; - Word16 npulses[NB_SFM], maxpulse[NB_SFM]; - Word16 Rsubband[NB_SFM]; /* Q3 */ - Word32 t_audio_q_fx[L_SPEC48k_EXT]; - Word16 noise_level_fx[HVQ_BWE_NOISE_BANDS]; - Word16 hq_generic_offset; - Word16 hq_generic_exc_clas = 0; - move16(); - Word16 core_sfm; - Word16 har_freq_est1 = 0, har_freq_est2 = 0; - move16(); - move16(); - Word16 flag_dis = 1; - move16(); - const Word16 *subband_search_offset; - Word16 wBands[2]; - Word16 b_delta_env; - HQ_ENC_HANDLE hHQ_core = st->hHQ_core; - BSTR_ENC_HANDLE hBstr = st->hBstr; - Word16 att_fx; - Word16 t_audio_norm[L_FRAME48k_EXT]; - Word16 t_audio_q_norm[L_FRAME48k_EXT]; - Word32 nf_gains_fx[HVQ_NF_GROUPS], pe_gains_fx[HVQ_NF_GROUPS]; - Word16 hq_generic_fenv_fx[HQ_FB_FENV]; - /*------------------------------------------------------------------* - * Initializations - *------------------------------------------------------------------*/ - - Npeaks = 0; - move16(); - set16_fx( npulses, 0, NB_SFM ); - set16_fx( maxpulse, 0, NB_SFM ); - set16_fx( difidx_org, 0, NB_SFM ); - set32_fx( t_audio_q_fx, 0, L_FRAME48k ); - set32_fx( nf_gains_fx, 0, HVQ_NF_GROUPS ); - set32_fx( pe_gains_fx, 0, HVQ_NF_GROUPS ); - /*------------------------------------------------------------------* - * Classification - *------------------------------------------------------------------*/ - bits = hq_classifier_enc_ivas_fx( st, length, t_audio_fx, is_transient, &Npeaks, peaks, pe_gains_fx, nf_gains_fx, &hqswb_clas ); /* Q0 */ - *num_bits = sub( *num_bits, bits ); - move16(); - - /*------------------------------------------------------------------* - * Set quantization parameters - *------------------------------------------------------------------*/ - - hq_configure_fx( length, hqswb_clas, st->core_brate, &num_sfm, &nb_sfm, &start_norm, &num_env_bands, &numnrmibits, &hq_generic_offset, sfmsize, sfm_start, sfm_end ); - - /*------------------------------------------------------------------* - * Transient frame handling - *------------------------------------------------------------------*/ - /* Interleave MLT coefficients of 4 sub-vectors in case of transient frame */ - IF( is_transient ) - { - interleave_spectrum_ivas_fx( t_audio_fx, length ); - } - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); - v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ - } - - /*------------------------------------------------------------------* - * Scalar quantization of norms - * Encode norm indices - *------------------------------------------------------------------*/ - - /* calculate and quantize norms */ - calc_norm_ivas_fx( t_audio_fx, ynrm, normqlg2, start_norm, num_env_bands, sfmsize, sfm_start ); - /* create differential code of quantized norm indices */ - diff_envelope_coding_fx( is_transient, num_env_bands, start_norm, ynrm, normqlg2, difidx ); - - /* Find norm coding mode and calculate number of bits */ - hcode_l = encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient ); /* Q0 */ - - *num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) ); - move16(); - /* Encode norm indices */ - encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 1, NORMAL_HQ_CORE, is_transient ); - - /*------------------------------------------------------------------* - * HQ GENERIC BWE encoding - *------------------------------------------------------------------*/ - - test(); - IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) - { - hq_generic_hf_encoding_fx( t_audio_fx, hq_generic_fenv_fx, hq_generic_offset, st, &hq_generic_exc_clas, length ); - - IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) ) - { - *num_bits = add( *num_bits, 1 ); /* conditional 1 bit saving for representing FD3 BWE excitation class */ - move16(); - } - map_hq_generic_fenv_norm_fx( hqswb_clas, hq_generic_fenv_fx, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset ); - } - - /*------------------------------------------------------------------* - * Bit allocation - *------------------------------------------------------------------*/ - - ivas_hq_bit_allocation_fx( st->core_brate, length, hqswb_clas, num_bits, normqlg2, nb_sfm, sfmsize, noise_level_fx, R, Rsubband, &sum, &core_sfm, num_env_bands ); - - /*------------------------------------------------------------------* - * Normalize coefficients with quantized norms - *------------------------------------------------------------------*/ - IF( NE_16( hqswb_clas, HQ_HVQ ) ) - { - test(); - IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) - { - b_delta_env = calc_nor_delta_hf_ivas_fx( hBstr, t_audio_fx, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm ); /* Q0 */ - sum = sub( sum, b_delta_env ); - } - normalizecoefs_fx( t_audio_fx, ynrm, nb_sfm, sfm_start, sfm_end, t_audio_norm ); - } - Word16 Q_audio = 12, Q_shift; - move16(); - /*------------------------------------------------------------------* - * Quantize/code spectral fine structure using PVQ or HVQ - *------------------------------------------------------------------*/ - IF( EQ_16( hqswb_clas, HQ_HVQ ) ) - { - sum = hvq_enc_ivas_fx( st, st->core_brate, *num_bits, Npeaks, ynrm, R, peaks, nf_gains_fx, noise_level_fx, pe_gains_fx, t_audio_fx, t_audio_q_fx ); - *num_bits = sub( *num_bits, sum ); - move16(); - } - ELSE - { - shape_bits = pvq_core_enc_ivas_fx( hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R, npulses, maxpulse, HQ_CORE ); /* Q0 */ - *num_bits = add( *num_bits, sub( sum, shape_bits ) ); - move16(); - } - - test(); - IF( EQ_16( hqswb_clas, HQ_HVQ ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - subband_search_offset = subband_search_offsets_13p2kbps_Har; /* Q0 */ - wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; /* Q0 */ - wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; /* Q0 */ - move16(); - move16(); - IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - Q_shift = sub( SWB_BWE_LR_Qs, Q_audio ); - FOR( Word16 i = 0; i < 300; i++ ) - { - t_audio_q_fx[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */ - move32(); - } - } - har_est_fx( t_audio_q_fx, 300, &har_freq_est1, &har_freq_est2, &flag_dis, &hHQ_core->prev_frm_hfe2, subband_search_offset, wBands, &hHQ_core->prev_stab_hfe2 ); - - hHQ_core->prev_frm_hfe2 = har_freq_est2; - move16(); - } - - /* reset LR-HQ memories */ - hHQ_core->prev_frm_hfe2 = 0; /*reset*/ - hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - nf_idx = 0; - move16(); - test(); - test(); - test(); - IF( NE_16( is_transient, 1 ) && NE_16( hqswb_clas, HQ_HVQ ) && !( EQ_16( length, L_FRAME16k ) && LE_32( st->core_brate, HQ_32k ) ) ) - { - test(); - IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) - { - nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */ - push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); - } - ELSE - { - nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */ - push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); - } - } - - - /* updates */ - hHQ_core->prev_hqswb_clas = hqswb_clas; /* Q0 */ - move16(); - /* Prepare synthesis for LB generation in case of switch to ACELP */ - IF( NE_16( hqswb_clas, HQ_HVQ ) ) - { - apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx ); - scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12 - } - - IF( is_transient ) - { - ivas_de_interleave_spectrum_fx( t_audio_q_fx, length ); - } - - MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length ); - - return; -} diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index f73a926dc..4d4742cc1 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -5,9 +5,11 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ //#include "prot_fx.h" /* Function prototypes */ -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ +#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ /*--------------------------------------------------------------------------* * hq_hr_enc_fx() @@ -264,3 +266,231 @@ void hq_hr_enc_fx( return; } + +void hq_hr_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *t_audio_fx, /* i/o: transform-domain coefficients Q12*/ + const Word16 length, /* i : length of spectrum Q0*/ + Word16 *num_bits, /* i/o: number of available bits Q0*/ + const Word16 is_transient, /* i : transient flag Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ +) +{ + Word16 nb_sfm; + Word16 sum, hcode_l; + Word16 difidx[NB_SFM]; + Word16 normqlg2[NB_SFM], ynrm[NB_SFM]; + Word16 nf_idx; + Word16 bits; + Word16 LCmode; + Word16 shape_bits, num_sfm, numnrmibits; + Word16 hqswb_clas; + Word16 num_env_bands; + Word16 Npeaks, start_norm; + Word16 difidx_org[NB_SFM]; + Word16 R[NB_SFM]; + Word16 peaks[HVQ_MAX_PEAKS]; + Word16 sfmsize[NB_SFM], sfm_start[NB_SFM], sfm_end[NB_SFM]; + Word16 npulses[NB_SFM], maxpulse[NB_SFM]; + Word16 Rsubband[NB_SFM]; /* Q3 */ + Word32 t_audio_q_fx[L_SPEC48k_EXT]; + Word16 noise_level_fx[HVQ_BWE_NOISE_BANDS]; + Word16 hq_generic_offset; + Word16 hq_generic_exc_clas = 0; + move16(); + Word16 core_sfm; + Word16 har_freq_est1 = 0, har_freq_est2 = 0; + move16(); + move16(); + Word16 flag_dis = 1; + move16(); + const Word16 *subband_search_offset; + Word16 wBands[2]; + Word16 b_delta_env; + HQ_ENC_HANDLE hHQ_core = st->hHQ_core; + BSTR_ENC_HANDLE hBstr = st->hBstr; + Word16 att_fx; + Word16 t_audio_norm[L_FRAME48k_EXT]; + Word16 t_audio_q_norm[L_FRAME48k_EXT]; + Word32 nf_gains_fx[HVQ_NF_GROUPS], pe_gains_fx[HVQ_NF_GROUPS]; + Word16 hq_generic_fenv_fx[HQ_FB_FENV]; + /*------------------------------------------------------------------* + * Initializations + *------------------------------------------------------------------*/ + + Npeaks = 0; + move16(); + set16_fx( npulses, 0, NB_SFM ); + set16_fx( maxpulse, 0, NB_SFM ); + set16_fx( difidx_org, 0, NB_SFM ); + set32_fx( t_audio_q_fx, 0, L_FRAME48k ); + set32_fx( nf_gains_fx, 0, HVQ_NF_GROUPS ); + set32_fx( pe_gains_fx, 0, HVQ_NF_GROUPS ); + /*------------------------------------------------------------------* + * Classification + *------------------------------------------------------------------*/ + bits = hq_classifier_enc_ivas_fx( st, length, t_audio_fx, is_transient, &Npeaks, peaks, pe_gains_fx, nf_gains_fx, &hqswb_clas ); /* Q0 */ + *num_bits = sub( *num_bits, bits ); + move16(); + + /*------------------------------------------------------------------* + * Set quantization parameters + *------------------------------------------------------------------*/ + + hq_configure_fx( length, hqswb_clas, st->core_brate, &num_sfm, &nb_sfm, &start_norm, &num_env_bands, &numnrmibits, &hq_generic_offset, sfmsize, sfm_start, sfm_end ); + + /*------------------------------------------------------------------* + * Transient frame handling + *------------------------------------------------------------------*/ + /* Interleave MLT coefficients of 4 sub-vectors in case of transient frame */ + IF( is_transient ) + { + interleave_spectrum_ivas_fx( t_audio_fx, length ); + } + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); + v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ + } + + /*------------------------------------------------------------------* + * Scalar quantization of norms + * Encode norm indices + *------------------------------------------------------------------*/ + + /* calculate and quantize norms */ + calc_norm_ivas_fx( t_audio_fx, ynrm, normqlg2, start_norm, num_env_bands, sfmsize, sfm_start ); + /* create differential code of quantized norm indices */ + diff_envelope_coding_fx( is_transient, num_env_bands, start_norm, ynrm, normqlg2, difidx ); + + /* Find norm coding mode and calculate number of bits */ + hcode_l = encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient ); /* Q0 */ + + *num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) ); + move16(); + /* Encode norm indices */ + encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 1, NORMAL_HQ_CORE, is_transient ); + + /*------------------------------------------------------------------* + * HQ GENERIC BWE encoding + *------------------------------------------------------------------*/ + + test(); + IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) + { + hq_generic_hf_encoding_fx( t_audio_fx, hq_generic_fenv_fx, hq_generic_offset, st, &hq_generic_exc_clas, length ); + + IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) ) + { + *num_bits = add( *num_bits, 1 ); /* conditional 1 bit saving for representing FD3 BWE excitation class */ + move16(); + } + map_hq_generic_fenv_norm_fx( hqswb_clas, hq_generic_fenv_fx, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset ); + } + + /*------------------------------------------------------------------* + * Bit allocation + *------------------------------------------------------------------*/ + + ivas_hq_bit_allocation_fx( st->core_brate, length, hqswb_clas, num_bits, normqlg2, nb_sfm, sfmsize, noise_level_fx, R, Rsubband, &sum, &core_sfm, num_env_bands ); + + /*------------------------------------------------------------------* + * Normalize coefficients with quantized norms + *------------------------------------------------------------------*/ + IF( NE_16( hqswb_clas, HQ_HVQ ) ) + { + test(); + IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) + { + b_delta_env = calc_nor_delta_hf_ivas_fx( hBstr, t_audio_fx, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm ); /* Q0 */ + sum = sub( sum, b_delta_env ); + } + normalizecoefs_fx( t_audio_fx, ynrm, nb_sfm, sfm_start, sfm_end, t_audio_norm ); + } + Word16 Q_audio = 12, Q_shift; + move16(); + /*------------------------------------------------------------------* + * Quantize/code spectral fine structure using PVQ or HVQ + *------------------------------------------------------------------*/ + IF( EQ_16( hqswb_clas, HQ_HVQ ) ) + { + sum = hvq_enc_ivas_fx( st, st->core_brate, *num_bits, Npeaks, ynrm, R, peaks, nf_gains_fx, noise_level_fx, pe_gains_fx, t_audio_fx, t_audio_q_fx ); + *num_bits = sub( *num_bits, sum ); + move16(); + } + ELSE + { + shape_bits = pvq_core_enc_ivas_fx( hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R, npulses, maxpulse, HQ_CORE ); /* Q0 */ + *num_bits = add( *num_bits, sub( sum, shape_bits ) ); + move16(); + } + + test(); + IF( EQ_16( hqswb_clas, HQ_HVQ ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) + { + subband_search_offset = subband_search_offsets_13p2kbps_Har; /* Q0 */ + wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; /* Q0 */ + wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; /* Q0 */ + move16(); + move16(); + IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) + { + Q_shift = sub( SWB_BWE_LR_Qs, Q_audio ); + FOR( Word16 i = 0; i < 300; i++ ) + { + t_audio_q_fx[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */ + move32(); + } + } + har_est_fx( t_audio_q_fx, 300, &har_freq_est1, &har_freq_est2, &flag_dis, &hHQ_core->prev_frm_hfe2, subband_search_offset, wBands, &hHQ_core->prev_stab_hfe2 ); + + hHQ_core->prev_frm_hfe2 = har_freq_est2; + move16(); + } + + /* reset LR-HQ memories */ + hHQ_core->prev_frm_hfe2 = 0; /*reset*/ + hHQ_core->prev_stab_hfe2 = 0; + move16(); + move16(); + nf_idx = 0; + move16(); + test(); + test(); + test(); + IF( NE_16( is_transient, 1 ) && NE_16( hqswb_clas, HQ_HVQ ) && !( EQ_16( length, L_FRAME16k ) && LE_32( st->core_brate, HQ_32k ) ) ) + { + test(); + IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) + { + nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */ + push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); + } + ELSE + { + nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */ + push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); + } + } + + + /* updates */ + hHQ_core->prev_hqswb_clas = hqswb_clas; /* Q0 */ + move16(); + /* Prepare synthesis for LB generation in case of switch to ACELP */ + IF( NE_16( hqswb_clas, HQ_HVQ ) ) + { + apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx ); + scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12 + } + + IF( is_transient ) + { + ivas_de_interleave_spectrum_fx( t_audio_q_fx, length ); + } + + MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length ); + + return; +} diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c deleted file mode 100644 index d0941db74..000000000 --- a/lib_enc/hq_lr_enc.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "stl.h" -#include "basop_util.h" -#include "wmc_auto.h" diff --git a/lib_enc/hvq_enc.c b/lib_enc/hvq_enc.c deleted file mode 100644 index adf7751a1..000000000 --- a/lib_enc/hvq_enc.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c deleted file mode 100644 index 1d4964ab8..000000000 --- a/lib_enc/init_enc.c +++ /dev/null @@ -1,1215 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "prot.h" -#include "ivas_prot.h" -#include "prot_fx.h" -#include "ivas_cnst.h" -#include "wmc_auto.h" -#include "ivas_prot_fx.h" -#include "prot_fx_enc.h" -ivas_error init_encoder_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID, /* i : interval for SID update */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ -) -{ - Word16 i; - ivas_error error; - Word32 igf_brate; - - error = IVAS_ERR_OK; - move32(); - - /*-----------------------------------------------------------------* - * General parameters - *-----------------------------------------------------------------*/ - - IF( st->Opt_AMR_WB ) - { - st->last_core = AMR_WB_CORE; - } - ELSE - { - st->last_core = -1; - } - move16(); - - st->L_frame = L_FRAME; - move16(); - st->last_coder_type = GENERIC; - move16(); - st->coder_type = GENERIC; - move16(); - st->last_total_brate = st->total_brate; - move32(); - st->last_bits_frame_nominal = -1; - move16(); - st->last_total_brate_cng = -1; - move16(); - st->last_core_brate = st->total_brate; - move32(); - st->dtx_sce_sba = 0; - move16(); - st->extl = -1; - move16(); - st->last_extl = -1; - move16(); - st->last_L_frame = L_FRAME; - move16(); - st->rate_switching_reset = 0; - move16(); - st->rate_switching_reset_16kHz = 0; - move16(); - st->clas = UNVOICED_CLAS; - move16(); - st->low_rate_mode = 0; - move16(); - st->ini_frame = 0; - move16(); - st->inactive_coder_type_flag = 0; - move16(); - st->sba_br_sw_while_no_data = 0; - move16(); - - st->coder_type_raw = VOICED; - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - - st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); - move16(); - - st->is_ism_format = 0; - move16(); - - IF( NE_16( ism_mode, ISM_MODE_NONE ) ) - { - st->is_ism_format = 1; - move16(); - } - - /*-----------------------------------------------------------------* - * Bitstream - *-----------------------------------------------------------------*/ - - IF( !vad_only_flag ) - { - IF( ( st->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); - } - - /* set pointer to the buffer of indices */ - st->hBstr->ind_list = st_ivas->ind_list; - st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st->hBstr->nb_ind_tot = 0; - move16(); - st->hBstr->nb_bits_tot = 0; - move16(); - st->hBstr->st_ivas = st_ivas; - } - ELSE - { - st->hBstr = NULL; - } - - /*-----------------------------------------------------------------* - * Pre-processing and ACELP core parameters - *-----------------------------------------------------------------*/ - - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); - - st->next_force_safety_net = 0; - move16(); - - st->pstreaklen = 0; - move16(); - st->streaklimit_fx = MAX_WORD16; - move16(); - set16_fx( st->mem_MA_fx, 0, M ); - - init_gp_clip_fx( st->clip_var_fx ); - pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); - set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); - st->exp_old_wsp = 0; - move16(); - set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage. - st->Q_old_wsp2 = 0; - move16(); - - st->mem_preemph_fx = 0; - move16(); - st->mem_preemph16k_fx = 0; - move16(); - st->mem_preemph_enc = 0; - move16(); - st->exp_mem_preemph_enc = 0; - move16(); - -#if 1 // TODO: Float Initializations. To be removed later - st->active_cnt = 0; - move16(); -#endif - - st->pst_mem_deemp_err_fx = 0; - move16(); - st->pst_lp_ener_fx = 0; - move16(); - - /* AVQ pre-quantizer memory */ - st->mem_preemp_preQ_fx = 0; - move16(); - st->mem_deemp_preQ_fx = 0; - move16(); - st->last_nq_preQ = 0; - move16(); - st->last_code_preq = 0; - move16(); - st->use_acelp_preq = 0; - move16(); - st->last_harm_flag_acelp = 0; - move16(); - - /* (Decimated) Weighted Speech Memory */ - st->mem_wsp_enc = 0; - move16(); - st->mem_wsp_fx = 0; - move16(); - st->mem_wsp_q = 0; - move16(); - set16_fx( st->mem_decim2_fx, 0, 3 ); - set32_fx( st->Bin_E_fx, 0, L_FFT ); - st->q_Bin_E = Q31; - move16(); - st->ee_old_fx = 640; /* 10.0f in Q6 */ - move16(); - st->Nb_ACELP_frames = 0; - move16(); - st->audio_frame_cnt = AUDIO_COUNTER_INI; /* Initialization of the audio frame counter mildly into the audio mode */ - move16(); - - /* adaptive lag window memory */ - st->old_pitch_la = 0; - move16(); - - st->prev_Q_new = 0; - move16(); - - IF( EQ_32( st->input_Fs, 8000 ) ) - { - st->min_band = 1; - move16(); - st->max_band = 16; - move16(); - } - ELSE - { - st->min_band = 0; - move16(); - st->max_band = 19; - move16(); - } - - IF( st->Opt_AMR_WB ) - { - Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); - E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); - } - - Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); - Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); - Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); - Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); - - st->stab_fac_fx = 0; - move16(); - - /* Bass post-filter memories - encoder side of MODE2 */ - st->bpf_off = 0; - move16(); - st->pst_mem_deemp_err_fx = 0; - move16(); - st->pst_lp_ener_fx = 0; - move16(); - - /* TC coder type */ - st->tc_cnt = 0; - move16(); - - /* find_uv() parameters */ - st->old_dE1_fx = 0; - move16(); - st->old_ind_deltaMax = 0; - move16(); - set32_fx( st->old_enr_ssf_fx, 0, shl( NB_SSF, 1 ) ); - st->spike_hyst = -1; - move16(); - - /* stereo switching memories */ - st->mem_preemph_DFT_fx = 0; - move16(); - set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) ); - st->mem_preemph16k_DFT_fx = 0; - move16(); - set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) ); - - st->sharpFlag = 0; - move16(); - - /* Stationary noise UV modification */ - st->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ - move16(); - st->uv_count = 0; - move16(); - st->act_count = 3; - move16(); - Copy( st->lsp_old_fx, st->lspold_s_fx, M ); - st->noimix_seed = RANDOM_INITSEED; - move16(); - st->min_alpha_fx = 32767; - move16(); - st->exc_pe_fx = 0; - move16(); - st->Q_stat_noise = 15; - move16(); - /* FEC */ - st->last_clas = UNVOICED_CLAS; - move16(); - st->prev_fmerit = 0; - move16(); - st->fmerit_dt = 0; - move16(); - st->Last_pulse_pos = 0; - move16(); - - FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) - { - st->old_pitch_buf_fx[i] = L_SUBFR_Q6; - move16(); - } - - /* mode1 core switching */ - st->old_Es_pred_fx = 0; - move16(); - set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); - st->old_Aq_12_8_fx[0] = ONE_IN_Q12; - move16(); - - /* stable short pitch detection */ - st->voicing0_sm_fx = 0; - move16(); - st->voicing_sm_fx = 0; - move16(); - st->LF_EnergyRatio_sm_fx = 1; - move16(); - st->predecision_flag = 0; - move16(); - st->diff_sm_fx = 0; - move32(); - st->energy_sm_fx = 0; - move32(); - - set16_fx( st->pitch, L_SUBFR, 3 ); - set16_fx( st->voicing_fx, 0, 3 ); - - /*-----------------------------------------------------------------* - * General signal buffers - *-----------------------------------------------------------------*/ - - IF( !vad_only_flag ) - { - IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); - } - - st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx; - st->mem_decim_fx = st->hSignalBuf->mem_decim_fx; - st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx; - st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx; - st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; - st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; - st->buf_synth = st->hSignalBuf->buf_synth; - st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; - st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; - - set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); - st->q_Bin_E_old = Q31; - move16(); - set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc = 0; - move16(); - set16_fx( st->hSignalBuf->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); - st->exp_buf_wspeech_enc = 0; - move16(); - /* initializations */ -#ifndef MSAN_FIX - set32_fx( st->Bin_E_old_fx, 0, shr( L_FFT, 2 ) ); -#else - set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); -#endif - st->q_Bin_E_old = Q31; - move16(); - set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM ); - set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); - st->exp_old_inp_16k = 0; - st->exp_old_inp_12k8 = 0; - move16(); - move16(); - - st->input_buff_fx = st->hSignalBuf->input_buff; - st->input_buff32_fx = st->hSignalBuf->input_buff32; - set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); - st->q_inp = Q15; - move16(); - st->q_old_inp = Q15; - move16(); - set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); - st->q_inp32 = Q31; - move16(); - st->old_input_signal_fx = st->input_buff_fx; - /* st->input_Fs / FRAMES_PER_SEC */ - Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - - IF( st->element_mode == EVS_MONO ) - { - st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); - st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); - } - ELSE - { - st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC - st->input_fx = st->input_buff_fx + frame_length; - } -#if 1 // TODO: To be removed later -#endif - } - ELSE - { - st->hSignalBuf = NULL; - st->Bin_E_old_fx = NULL; - st->mem_decim_fx = NULL; - st->mem_decim16k_fx = NULL; - st->old_inp_12k8_fx = NULL; - st->old_inp_16k_fx = NULL; - st->buf_speech_enc_pe = NULL; - st->buf_synth = NULL; - st->buf_speech_enc = NULL; - st->buf_wspeech_enc = NULL; - st->input_buff_fx = NULL; -#if 1 -#endif - } - - /*-----------------------------------------------------------------* - * Noise estimator - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) - { - IF( ( st->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ); - } - - noise_est_init_ivas_fx( st->hNoiseEst ); - } - ELSE - { - st->hNoiseEst = NULL; - } - - /*-----------------------------------------------------------------* - * VAD - *-----------------------------------------------------------------*/ - - st->vad_flag = 1; - move16(); - st->localVAD = 0; - move16(); - - IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) && ( !vad_only_flag ) ) - { - IF( ( st->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); - } - - wb_vad_init_ivas_fx( st->hVAD ); - } - ELSE - { - st->hVAD = NULL; - } - st->Pos_relE_cnt = 20; - move16(); - - /* CLDFB-based VAD */ - IF( st->element_mode == EVS_MONO ) - { - /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */ - /* - if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); - } - */ - st->hVAD_CLDFB = &st->vad_st; - - vad_init_fx( st->hVAD_CLDFB ); - } - ELSE - { - st->hVAD_CLDFB = NULL; - } - - /*-----------------------------------------------------------------* - * Speech/music classifier - *-----------------------------------------------------------------*/ - - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) - { - IF( ( st->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); - } - - speech_music_clas_init_ivas_fx( st->hSpMusClas ); - st->sp_aud_decision0 = 0; - move16(); - st->sp_aud_decision1 = 0; - move16(); - st->sp_aud_decision2 = 0; - move16(); - } - ELSE - { - st->hSpMusClas = NULL; - } - - - /*-----------------------------------------------------------------* - * WB, SWB and FB bandwidth detector - *-----------------------------------------------------------------*/ - - st->lt_mean_NB_fx = 0; - move16(); - st->lt_mean_WB_fx = 0; - move16(); - st->lt_mean_SWB_fx = 0; - move16(); - st->count_WB = BWD_COUNT_MAX; - move16(); - st->count_SWB = BWD_COUNT_MAX; - move16(); - st->count_FB = BWD_COUNT_MAX; - move16(); - st->bwidth = st->max_bwidth; - move16(); - st->last_input_bwidth = st->bwidth; - move16(); - st->last_bwidth = st->bwidth; - move16(); - st->last_bwidth_cng = st->bwidth; - move16(); - st->bwidth_sw_cnt = 0; - move16(); - - - /*-----------------------------------------------------------------* - * DTX - *-----------------------------------------------------------------*/ - - st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ - move16(); - st->lp_noise_fx = 0; - move16(); - st->flag_noisy_speech_snr = 0; - move16(); - st->fd_cng_reset_flag = 0; - move16(); - st->cng_type = -1; - move16(); - st->bckr_tilt_lt = 0; - move16(); - st->active_cnt = 0; - move16(); - - test(); - test(); - test(); - test(); - IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); - } - dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); - } - ELSE - { - st->hDtxEnc = NULL; - } - - /*-----------------------------------------------------------------* - * No other handles needed to be allocated for front-VAD structure - *-----------------------------------------------------------------*/ - - IF( vad_only_flag ) - { - st->hTdCngEnc = NULL; - st->cldfbAnaEnc = NULL; - st->hFdCngEnc = NULL; - st->hSC_VBR = NULL; - st->hAmrwb_IO = NULL; - st->hLPDmem = NULL; - st->hGSCEnc = NULL; - st->hBWE_TD = NULL; - st->cldfbSynTd = NULL; - st->hBWE_FD = NULL; - st->hHQ_core = NULL; - st->hRF = NULL; - st->hTECEnc = NULL; - st->hTcxEnc = NULL; - st->hTcxCfg = NULL; - st->hIGFEnc = NULL; - st->hPlcExt = NULL; - st->hTranDet = NULL; - - st->element_mode = IVAS_SCE; - move16(); - st->idchan = 100; /* indicates hCoreCoderVAD */ - move16(); - st->core = -1; - move16(); - st->rf_mode = 0; - move16(); - - return error; - } - - /*-----------------------------------------------------------------* - * LP-CNG - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) - { - IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); - } - - td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } - ELSE - { - st->hTdCngEnc = NULL; - } - - /*-----------------------------------------------------------------* - * CLDFB & resampling tools parameters - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - st->cldfbAnaEnc = NULL; - } - - st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move32(); - st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move16(); - - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ - - test(); - IF( st->Opt_SC_VBR || st->element_mode == EVS_MONO ) - { - IF( ( st->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); - } - - sc_vbr_enc_init_fx( st->hSC_VBR ); - } - ELSE - { - st->hSC_VBR = NULL; - } - - st->last_Opt_SC_VBR = 0; - move16(); - - - /*-----------------------------------------------------------------* - * AMR-WB IO initialization - *-----------------------------------------------------------------*/ - - test(); - IF( st->Opt_AMR_WB || st->element_mode == EVS_MONO ) - { - IF( ( st->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); - } - - amr_wb_enc_init_fx( st->hAmrwb_IO ); - } - ELSE - { - st->hAmrwb_IO = NULL; - } - - /*-----------------------------------------------------------------* - * ACELP LPDmem - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); - } - - LPDmem_enc_init_ivas_fx( st->hLPDmem ); - } - ELSE - { - st->hLPDmem = NULL; - } - - /*-----------------------------------------------------------------* - * parameters for AC coder type (GSC) - *-----------------------------------------------------------------*/ - - st->GSC_noisy_speech = 0; - move16(); - st->GSC_IVAS_mode = 0; - move16(); - - test(); - test(); - IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); - } - - GSC_enc_init_fx( st->hGSCEnc ); - } - ELSE - { - st->hGSCEnc = NULL; - } - - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); - } - - IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) - { - return error; - } - - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); - } - ELSE - { - st->hBWE_TD = NULL; - st->cldfbSynTd = NULL; - } - - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); - } - - fd_bwe_enc_init_fx( st->hBWE_FD ); -#ifdef MSAN_FIX - st->Q_old_wtda = 0; - move16(); -#endif - } - ELSE - { - st->hBWE_FD = NULL; - } - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) - { - IF( ( st->hHQ_core = (HQ_ENC_HANDLE) malloc( sizeof( HQ_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); - } - - HQ_core_enc_init_fx( st->hHQ_core ); - } - ELSE - { - st->hHQ_core = NULL; - } - - /* init memory for detect_transient(), used by HQ core and swb_bwe_enc */ - st->old_hpfilt_in_fx = 0; - move16(); - st->old_hpfilt_out_fx = 0; - move16(); - st->EnergyLT_fx = 0; - move32(); - st->Energy_Old_fx = 0; - move32(); - st->TransientHangOver = 0; - move16(); - st->EnergyLT_fx_exp = 30; - move16(); - st->last_enerBuffer_exp = 0; - move16(); - - /*-----------------------------------------------------------------* - * Channel-aware mode - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( !st->Opt_RF_ON || ( NE_16( st->bwidth, WB ) && NE_16( st->bwidth, SWB ) ) || NE_32( st->total_brate, ACELP_13k20 ) ) - { - st->rf_mode = 0; - move16(); - } - ELSE - { - st->rf_mode = st->Opt_RF_ON; - move16(); - } - - st->rf_mode_last = st->rf_mode; - move16(); - - test(); - IF( st->Opt_RF_ON || st->element_mode == EVS_MONO ) - { - IF( ( st->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for RF\n" ) ); - } - - /* initialize RF indice buffers */ - reset_rf_indices_fx( st ); - } - ELSE - { - st->hRF = NULL; - } - - /*-----------------------------------------------------------------* - * Temporal Envelope Coding - *-----------------------------------------------------------------*/ - - IF( st->element_mode == EVS_MONO ) - { - IF( ( st->hTECEnc = (TEC_ENC_HANDLE) malloc( sizeof( TEC_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); - } - } - ELSE - { - st->hTECEnc = NULL; - } - /* note: initialization done later in init_coder_ace_plus() */ - - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ - - // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel - test(); - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); - } - set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); - st->hTcxEnc->spectrum_long_e = 0; - move16(); - /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; - st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; - move32(); - move32(); - st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; - move16(); - move16(); -#if 1 - // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); - // st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long; - // st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX; - // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); -#endif - - set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); - st->hTcxEnc->Q_old_out = 0; - move16(); - - /* MDCT selector */ - MDCT_selector_reset_fx( st->hTcxEnc ); - - /* MDCT classifier */ - MDCT_classifier_reset_fx( st->hTcxEnc ); - - IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); - } - } - ELSE - { - st->hTcxEnc = NULL; - st->hTcxCfg = NULL; - } - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - - igf_brate = st->total_brate; - move32(); - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) ) - { - igf_brate = L_sub( st->total_brate, i_mult( ISM_NB_BITS_METADATA_NOMINAL, FRAMES_PER_SEC ) ); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_FORMAT ) ) ) ) - { - /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */ - IF( EQ_32( element_brate, IVAS_13k2 ) ) - { - igf_brate = ACELP_9k60; - } - ELSE IF( EQ_32( element_brate, IVAS_16k4 ) ) - { - igf_brate = ACELP_13k20; - } - ELSE IF( EQ_32( element_brate, IVAS_24k4 ) ) - { - igf_brate = ACELP_16k40; - } - ELSE IF( EQ_32( element_brate, IVAS_32k ) ) - { - igf_brate = ACELP_24k40; - } - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - igf_brate = element_brate; - } - move32(); - test(); - IF( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) - { - st->igf = getIgfPresent_fx( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode ); - } - ELSE - { - st->igf = 0; - } - move16(); - - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) - { - IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); - } - } - ELSE - { - st->hIGFEnc = NULL; - } - - /*-----------------------------------------------------------------* - * Mode 2 initialization - *-----------------------------------------------------------------*/ - - st->last_sr_core = L_mult0( st->last_L_frame, FRAMES_PER_SEC ); - move32(); - - - /* PLC encoder */ - IF( st->element_mode == EVS_MONO ) - { - IF( ( st->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hPlcExt\n" ) ); - } - } - ELSE - { - st->hPlcExt = NULL; - } - - /* Init Mode 2 core coder */ - st->last_totalNoise_fx = 0; - move16(); - set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); - st->totalNoise_increase_len = 0; - move16(); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - } - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); -#ifdef MSAN_FIX - st->prevEnergyHF_fx = 0; - move32(); -#endif - - /* Initialize TCX */ - - /* Initialize Signal Buffers */ - Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); - st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); - move16(); - shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); - Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); - /* Initialize ACELP */ -#endif -#ifdef FIX_920_IGF_INIT_ERROR - init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); -#else - init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 ); -#endif - - IF( st->hLPDmem != NULL ) - { - st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; - move16(); - } - /*-----------------------------------------------------------------* - * FD-CNG encoder - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - createFdCngEnc_fx( &st->hFdCngEnc ); - initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); - /* initialization for IVAS modes happens in first frame pre-processing */ - IF( st->element_mode == EVS_MONO ) - { - Word32 total_brate; - - test(); - IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - total_brate = ACELP_9k60; - move32(); - } - ELSE - { - total_brate = st->total_brate; - move32(); - } - - configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, total_brate ); - } - } - ELSE - { - st->hFdCngEnc = NULL; - } - - /*-----------------------------------------------------------------* - * Transient detector - *-----------------------------------------------------------------*/ - - IF( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); - } - Word16 temp; - Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); - frame_length = shr( frame_length, sub( 15, temp ) ); - - IF( GT_16( st->element_mode, EVS_MONO ) ) - { - InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); - } - ELSE - { - InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); - } - - /*-----------------------------------------------------------------* - * IVAS parameters - *-----------------------------------------------------------------*/ - - st->tdm_LRTD_flag = 0; - move16(); - st->cng_sba_flag = 0; - move16(); - st->bits_frame_channel = 0; - move16(); - st->side_bits_frame_channel = 0; - move16(); - st->Q_syn2 = 0; - move16(); - st->Q_syn = 0; - move16(); - set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); - set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); - st->Q_old = 15; - move16(); - st->old_wsp_max = 0; - move16(); - st->old_wsp_shift = 0; - move16(); - st->sharpFlag = 0; - move16(); - - return error; -} - - -/*-----------------------------------------------------------------------* - * destroy_cldfb_encoder() - * - * Free memory which was allocated in init_encoder() - *-----------------------------------------------------------------------*/ - -void destroy_cldfb_encoder_fx( - Encoder_State *st /* i/o: Encoder static variables structure */ -) -{ - deleteCldfb_ivas_fx( &st->cldfbSynTd ); - deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); - - deleteFdCngEnc_fx( &st->hFdCngEnc ); - - return; -} diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 58706279e..ca8b70ca2 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -10,8 +10,10 @@ #include "stl.h" #include "ivas_cnst.h" #include "ivas_error.h" +#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* @@ -1062,3 +1064,1171 @@ void destroy_encoder_fx( return; } + +ivas_error init_encoder_ivas_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ + const Word16 interval_SID, /* i : interval for SID update */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ +) +{ + Word16 i; + ivas_error error; + Word32 igf_brate; + + error = IVAS_ERR_OK; + move32(); + + /*-----------------------------------------------------------------* + * General parameters + *-----------------------------------------------------------------*/ + + IF( st->Opt_AMR_WB ) + { + st->last_core = AMR_WB_CORE; + } + ELSE + { + st->last_core = -1; + } + move16(); + + st->L_frame = L_FRAME; + move16(); + st->last_coder_type = GENERIC; + move16(); + st->coder_type = GENERIC; + move16(); + st->last_total_brate = st->total_brate; + move32(); + st->last_bits_frame_nominal = -1; + move16(); + st->last_total_brate_cng = -1; + move16(); + st->last_core_brate = st->total_brate; + move32(); + st->dtx_sce_sba = 0; + move16(); + st->extl = -1; + move16(); + st->last_extl = -1; + move16(); + st->last_L_frame = L_FRAME; + move16(); + st->rate_switching_reset = 0; + move16(); + st->rate_switching_reset_16kHz = 0; + move16(); + st->clas = UNVOICED_CLAS; + move16(); + st->low_rate_mode = 0; + move16(); + st->ini_frame = 0; + move16(); + st->inactive_coder_type_flag = 0; + move16(); + st->sba_br_sw_while_no_data = 0; + move16(); + + st->coder_type_raw = VOICED; + move16(); + st->last_coder_type_raw = st->coder_type_raw; + move16(); + + st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); + move16(); + + st->is_ism_format = 0; + move16(); + + IF( NE_16( ism_mode, ISM_MODE_NONE ) ) + { + st->is_ism_format = 1; + move16(); + } + + /*-----------------------------------------------------------------* + * Bitstream + *-----------------------------------------------------------------*/ + + IF( !vad_only_flag ) + { + IF( ( st->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); + } + + /* set pointer to the buffer of indices */ + st->hBstr->ind_list = st_ivas->ind_list; + st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; + st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; + st->hBstr->nb_ind_tot = 0; + move16(); + st->hBstr->nb_bits_tot = 0; + move16(); + st->hBstr->st_ivas = st_ivas; + } + ELSE + { + st->hBstr = NULL; + } + + /*-----------------------------------------------------------------* + * Pre-processing and ACELP core parameters + *-----------------------------------------------------------------*/ + + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); + + st->next_force_safety_net = 0; + move16(); + + st->pstreaklen = 0; + move16(); + st->streaklimit_fx = MAX_WORD16; + move16(); + set16_fx( st->mem_MA_fx, 0, M ); + + init_gp_clip_fx( st->clip_var_fx ); + pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); + set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); + st->exp_old_wsp = 0; + move16(); + set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage. + st->Q_old_wsp2 = 0; + move16(); + + st->mem_preemph_fx = 0; + move16(); + st->mem_preemph16k_fx = 0; + move16(); + st->mem_preemph_enc = 0; + move16(); + st->exp_mem_preemph_enc = 0; + move16(); + +#if 1 // TODO: Float Initializations. To be removed later + st->active_cnt = 0; + move16(); +#endif + + st->pst_mem_deemp_err_fx = 0; + move16(); + st->pst_lp_ener_fx = 0; + move16(); + + /* AVQ pre-quantizer memory */ + st->mem_preemp_preQ_fx = 0; + move16(); + st->mem_deemp_preQ_fx = 0; + move16(); + st->last_nq_preQ = 0; + move16(); + st->last_code_preq = 0; + move16(); + st->use_acelp_preq = 0; + move16(); + st->last_harm_flag_acelp = 0; + move16(); + + /* (Decimated) Weighted Speech Memory */ + st->mem_wsp_enc = 0; + move16(); + st->mem_wsp_fx = 0; + move16(); + st->mem_wsp_q = 0; + move16(); + set16_fx( st->mem_decim2_fx, 0, 3 ); + set32_fx( st->Bin_E_fx, 0, L_FFT ); + st->q_Bin_E = Q31; + move16(); + st->ee_old_fx = 640; /* 10.0f in Q6 */ + move16(); + st->Nb_ACELP_frames = 0; + move16(); + st->audio_frame_cnt = AUDIO_COUNTER_INI; /* Initialization of the audio frame counter mildly into the audio mode */ + move16(); + + /* adaptive lag window memory */ + st->old_pitch_la = 0; + move16(); + + st->prev_Q_new = 0; + move16(); + + IF( EQ_32( st->input_Fs, 8000 ) ) + { + st->min_band = 1; + move16(); + st->max_band = 16; + move16(); + } + ELSE + { + st->min_band = 0; + move16(); + st->max_band = 19; + move16(); + } + + IF( st->Opt_AMR_WB ) + { + Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); + E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); + } + ELSE + { + Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); + } + + Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); + Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); + Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); + + st->stab_fac_fx = 0; + move16(); + + /* Bass post-filter memories - encoder side of MODE2 */ + st->bpf_off = 0; + move16(); + st->pst_mem_deemp_err_fx = 0; + move16(); + st->pst_lp_ener_fx = 0; + move16(); + + /* TC coder type */ + st->tc_cnt = 0; + move16(); + + /* find_uv() parameters */ + st->old_dE1_fx = 0; + move16(); + st->old_ind_deltaMax = 0; + move16(); + set32_fx( st->old_enr_ssf_fx, 0, shl( NB_SSF, 1 ) ); + st->spike_hyst = -1; + move16(); + + /* stereo switching memories */ + st->mem_preemph_DFT_fx = 0; + move16(); + set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) ); + st->mem_preemph16k_DFT_fx = 0; + move16(); + set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) ); + + st->sharpFlag = 0; + move16(); + + /* Stationary noise UV modification */ + st->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ + move16(); + st->uv_count = 0; + move16(); + st->act_count = 3; + move16(); + Copy( st->lsp_old_fx, st->lspold_s_fx, M ); + st->noimix_seed = RANDOM_INITSEED; + move16(); + st->min_alpha_fx = 32767; + move16(); + st->exc_pe_fx = 0; + move16(); + st->Q_stat_noise = 15; + move16(); + /* FEC */ + st->last_clas = UNVOICED_CLAS; + move16(); + st->prev_fmerit = 0; + move16(); + st->fmerit_dt = 0; + move16(); + st->Last_pulse_pos = 0; + move16(); + + FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) + { + st->old_pitch_buf_fx[i] = L_SUBFR_Q6; + move16(); + } + + /* mode1 core switching */ + st->old_Es_pred_fx = 0; + move16(); + set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); + st->old_Aq_12_8_fx[0] = ONE_IN_Q12; + move16(); + + /* stable short pitch detection */ + st->voicing0_sm_fx = 0; + move16(); + st->voicing_sm_fx = 0; + move16(); + st->LF_EnergyRatio_sm_fx = 1; + move16(); + st->predecision_flag = 0; + move16(); + st->diff_sm_fx = 0; + move32(); + st->energy_sm_fx = 0; + move32(); + + set16_fx( st->pitch, L_SUBFR, 3 ); + set16_fx( st->voicing_fx, 0, 3 ); + + /*-----------------------------------------------------------------* + * General signal buffers + *-----------------------------------------------------------------*/ + + IF( !vad_only_flag ) + { + IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); + } + + st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx; + st->mem_decim_fx = st->hSignalBuf->mem_decim_fx; + st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx; + st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx; + st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; + st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; + st->buf_synth = st->hSignalBuf->buf_synth; + st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; + st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; + + set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); + st->q_Bin_E_old = Q31; + move16(); + set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc = 0; + move16(); + set16_fx( st->hSignalBuf->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + st->exp_buf_wspeech_enc = 0; + move16(); + /* initializations */ +#ifndef MSAN_FIX + set32_fx( st->Bin_E_old_fx, 0, shr( L_FFT, 2 ) ); +#else + set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); +#endif + st->q_Bin_E_old = Q31; + move16(); + set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM ); + set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); + st->exp_old_inp_16k = 0; + st->exp_old_inp_12k8 = 0; + move16(); + move16(); + + st->input_buff_fx = st->hSignalBuf->input_buff; + st->input_buff32_fx = st->hSignalBuf->input_buff32; + set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); + st->q_inp = Q15; + move16(); + st->q_old_inp = Q15; + move16(); + set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); + st->q_inp32 = Q31; + move16(); + st->old_input_signal_fx = st->input_buff_fx; + /* st->input_Fs / FRAMES_PER_SEC */ + Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + + IF( st->element_mode == EVS_MONO ) + { + st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); + st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + } + ELSE + { + st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC + st->input_fx = st->input_buff_fx + frame_length; + } +#if 1 // TODO: To be removed later +#endif + } + ELSE + { + st->hSignalBuf = NULL; + st->Bin_E_old_fx = NULL; + st->mem_decim_fx = NULL; + st->mem_decim16k_fx = NULL; + st->old_inp_12k8_fx = NULL; + st->old_inp_16k_fx = NULL; + st->buf_speech_enc_pe = NULL; + st->buf_synth = NULL; + st->buf_speech_enc = NULL; + st->buf_wspeech_enc = NULL; + st->input_buff_fx = NULL; +#if 1 +#endif + } + + /*-----------------------------------------------------------------* + * Noise estimator + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) + { + IF( ( st->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ); + } + + noise_est_init_ivas_fx( st->hNoiseEst ); + } + ELSE + { + st->hNoiseEst = NULL; + } + + /*-----------------------------------------------------------------* + * VAD + *-----------------------------------------------------------------*/ + + st->vad_flag = 1; + move16(); + st->localVAD = 0; + move16(); + + IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) && ( !vad_only_flag ) ) + { + IF( ( st->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); + } + + wb_vad_init_ivas_fx( st->hVAD ); + } + ELSE + { + st->hVAD = NULL; + } + st->Pos_relE_cnt = 20; + move16(); + + /* CLDFB-based VAD */ + IF( st->element_mode == EVS_MONO ) + { + /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */ + /* + if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); + } + */ + st->hVAD_CLDFB = &st->vad_st; + + vad_init_fx( st->hVAD_CLDFB ); + } + ELSE + { + st->hVAD_CLDFB = NULL; + } + + /*-----------------------------------------------------------------* + * Speech/music classifier + *-----------------------------------------------------------------*/ + + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) + { + IF( ( st->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); + } + + speech_music_clas_init_ivas_fx( st->hSpMusClas ); + st->sp_aud_decision0 = 0; + move16(); + st->sp_aud_decision1 = 0; + move16(); + st->sp_aud_decision2 = 0; + move16(); + } + ELSE + { + st->hSpMusClas = NULL; + } + + + /*-----------------------------------------------------------------* + * WB, SWB and FB bandwidth detector + *-----------------------------------------------------------------*/ + + st->lt_mean_NB_fx = 0; + move16(); + st->lt_mean_WB_fx = 0; + move16(); + st->lt_mean_SWB_fx = 0; + move16(); + st->count_WB = BWD_COUNT_MAX; + move16(); + st->count_SWB = BWD_COUNT_MAX; + move16(); + st->count_FB = BWD_COUNT_MAX; + move16(); + st->bwidth = st->max_bwidth; + move16(); + st->last_input_bwidth = st->bwidth; + move16(); + st->last_bwidth = st->bwidth; + move16(); + st->last_bwidth_cng = st->bwidth; + move16(); + st->bwidth_sw_cnt = 0; + move16(); + + + /*-----------------------------------------------------------------* + * DTX + *-----------------------------------------------------------------*/ + + st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ + move16(); + st->lp_noise_fx = 0; + move16(); + st->flag_noisy_speech_snr = 0; + move16(); + st->fd_cng_reset_flag = 0; + move16(); + st->cng_type = -1; + move16(); + st->bckr_tilt_lt = 0; + move16(); + st->active_cnt = 0; + move16(); + + test(); + test(); + test(); + test(); + IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) + { + IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); + } + dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); + } + ELSE + { + st->hDtxEnc = NULL; + } + + /*-----------------------------------------------------------------* + * No other handles needed to be allocated for front-VAD structure + *-----------------------------------------------------------------*/ + + IF( vad_only_flag ) + { + st->hTdCngEnc = NULL; + st->cldfbAnaEnc = NULL; + st->hFdCngEnc = NULL; + st->hSC_VBR = NULL; + st->hAmrwb_IO = NULL; + st->hLPDmem = NULL; + st->hGSCEnc = NULL; + st->hBWE_TD = NULL; + st->cldfbSynTd = NULL; + st->hBWE_FD = NULL; + st->hHQ_core = NULL; + st->hRF = NULL; + st->hTECEnc = NULL; + st->hTcxEnc = NULL; + st->hTcxCfg = NULL; + st->hIGFEnc = NULL; + st->hPlcExt = NULL; + st->hTranDet = NULL; + + st->element_mode = IVAS_SCE; + move16(); + st->idchan = 100; /* indicates hCoreCoderVAD */ + move16(); + st->core = -1; + move16(); + st->rf_mode = 0; + move16(); + + return error; + } + + /*-----------------------------------------------------------------* + * LP-CNG + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + test(); + test(); + IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) + { + IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); + } + + td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + } + ELSE + { + st->hTdCngEnc = NULL; + } + + /*-----------------------------------------------------------------* + * CLDFB & resampling tools parameters + *-----------------------------------------------------------------*/ + test(); + test(); + test(); + IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) + { + IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + st->cldfbAnaEnc = NULL; + } + + st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move32(); + st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move16(); + + /*-----------------------------------------------------------------* + * SC-VBR parameters + *-----------------------------------------------------------------*/ + + test(); + IF( st->Opt_SC_VBR || st->element_mode == EVS_MONO ) + { + IF( ( st->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); + } + + sc_vbr_enc_init_fx( st->hSC_VBR ); + } + ELSE + { + st->hSC_VBR = NULL; + } + + st->last_Opt_SC_VBR = 0; + move16(); + + + /*-----------------------------------------------------------------* + * AMR-WB IO initialization + *-----------------------------------------------------------------*/ + + test(); + IF( st->Opt_AMR_WB || st->element_mode == EVS_MONO ) + { + IF( ( st->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); + } + + amr_wb_enc_init_fx( st->hAmrwb_IO ); + } + ELSE + { + st->hAmrwb_IO = NULL; + } + + /*-----------------------------------------------------------------* + * ACELP LPDmem + *-----------------------------------------------------------------*/ + + test(); + test(); + IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); + } + + LPDmem_enc_init_ivas_fx( st->hLPDmem ); + } + ELSE + { + st->hLPDmem = NULL; + } + + /*-----------------------------------------------------------------* + * parameters for AC coder type (GSC) + *-----------------------------------------------------------------*/ + + st->GSC_noisy_speech = 0; + move16(); + st->GSC_IVAS_mode = 0; + move16(); + + test(); + test(); + IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); + } + + GSC_enc_init_fx( st->hGSCEnc ); + } + ELSE + { + st->hGSCEnc = NULL; + } + + /*-----------------------------------------------------------------* + * TBE parameters + *-----------------------------------------------------------------*/ + + test(); + IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); + } + + IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + { + return error; + } + + InitSWBencBuffer_ivas_fx( st ); + ResetSHBbuffer_Enc_fx( st ); + } + ELSE + { + st->hBWE_TD = NULL; + st->cldfbSynTd = NULL; + } + + /*-----------------------------------------------------------------* + * SWB BWE parameters + *-----------------------------------------------------------------*/ + + test(); + IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); + } + + fd_bwe_enc_init_fx( st->hBWE_FD ); +#ifdef MSAN_FIX + st->Q_old_wtda = 0; + move16(); +#endif + } + ELSE + { + st->hBWE_FD = NULL; + } + + /*-----------------------------------------------------------------* + * HQ core parameters + *-----------------------------------------------------------------*/ + + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) + { + IF( ( st->hHQ_core = (HQ_ENC_HANDLE) malloc( sizeof( HQ_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); + } + + HQ_core_enc_init_fx( st->hHQ_core ); + } + ELSE + { + st->hHQ_core = NULL; + } + + /* init memory for detect_transient(), used by HQ core and swb_bwe_enc */ + st->old_hpfilt_in_fx = 0; + move16(); + st->old_hpfilt_out_fx = 0; + move16(); + st->EnergyLT_fx = 0; + move32(); + st->Energy_Old_fx = 0; + move32(); + st->TransientHangOver = 0; + move16(); + st->EnergyLT_fx_exp = 30; + move16(); + st->last_enerBuffer_exp = 0; + move16(); + + /*-----------------------------------------------------------------* + * Channel-aware mode + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( !st->Opt_RF_ON || ( NE_16( st->bwidth, WB ) && NE_16( st->bwidth, SWB ) ) || NE_32( st->total_brate, ACELP_13k20 ) ) + { + st->rf_mode = 0; + move16(); + } + ELSE + { + st->rf_mode = st->Opt_RF_ON; + move16(); + } + + st->rf_mode_last = st->rf_mode; + move16(); + + test(); + IF( st->Opt_RF_ON || st->element_mode == EVS_MONO ) + { + IF( ( st->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for RF\n" ) ); + } + + /* initialize RF indice buffers */ + reset_rf_indices_fx( st ); + } + ELSE + { + st->hRF = NULL; + } + + /*-----------------------------------------------------------------* + * Temporal Envelope Coding + *-----------------------------------------------------------------*/ + + IF( st->element_mode == EVS_MONO ) + { + IF( ( st->hTECEnc = (TEC_ENC_HANDLE) malloc( sizeof( TEC_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); + } + } + ELSE + { + st->hTECEnc = NULL; + } + /* note: initialization done later in init_coder_ace_plus() */ + + /*-----------------------------------------------------------------* + * TCX core + *-----------------------------------------------------------------*/ + + // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel + test(); + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); + } + set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); + st->hTcxEnc->spectrum_long_e = 0; + move16(); + /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ + st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; + st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + move32(); + move32(); + st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; + move16(); + move16(); +#if 1 + // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); + // st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long; + // st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX; + // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); +#endif + + set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); + st->hTcxEnc->Q_old_out = 0; + move16(); + + /* MDCT selector */ + MDCT_selector_reset_fx( st->hTcxEnc ); + + /* MDCT classifier */ + MDCT_classifier_reset_fx( st->hTcxEnc ); + + IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); + } + } + ELSE + { + st->hTcxEnc = NULL; + st->hTcxCfg = NULL; + } + + /*-----------------------------------------------------------------* + * IGF + *-----------------------------------------------------------------*/ + + igf_brate = st->total_brate; + move32(); + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) ) + { + igf_brate = L_sub( st->total_brate, i_mult( ISM_NB_BITS_METADATA_NOMINAL, FRAMES_PER_SEC ) ); + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_FORMAT ) ) ) ) + { + /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */ + IF( EQ_32( element_brate, IVAS_13k2 ) ) + { + igf_brate = ACELP_9k60; + } + ELSE IF( EQ_32( element_brate, IVAS_16k4 ) ) + { + igf_brate = ACELP_13k20; + } + ELSE IF( EQ_32( element_brate, IVAS_24k4 ) ) + { + igf_brate = ACELP_16k40; + } + ELSE IF( EQ_32( element_brate, IVAS_32k ) ) + { + igf_brate = ACELP_24k40; + } + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + igf_brate = element_brate; + } + move32(); + test(); + IF( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) + { + st->igf = getIgfPresent_fx( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode ); + } + ELSE + { + st->igf = 0; + } + move16(); + + test(); + test(); + test(); + IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) + { + IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); + } + } + ELSE + { + st->hIGFEnc = NULL; + } + + /*-----------------------------------------------------------------* + * Mode 2 initialization + *-----------------------------------------------------------------*/ + + st->last_sr_core = L_mult0( st->last_L_frame, FRAMES_PER_SEC ); + move32(); + + + /* PLC encoder */ + IF( st->element_mode == EVS_MONO ) + { + IF( ( st->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hPlcExt\n" ) ); + } + } + ELSE + { + st->hPlcExt = NULL; + } + + /* Init Mode 2 core coder */ + st->last_totalNoise_fx = 0; + move16(); + set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); + st->totalNoise_increase_len = 0; + move16(); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + IF( hTcxEnc != NULL ) + { + hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + } + st->currEnergyHF_fx = 0; + move32(); + st->currEnergyHF_e_fx = 0; + move16(); +#ifdef MSAN_FIX + st->prevEnergyHF_fx = 0; + move32(); +#endif + + /* Initialize TCX */ + + /* Initialize Signal Buffers */ + Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); + /* Initialize ACELP */ +#endif +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); +#else + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 ); +#endif + + IF( st->hLPDmem != NULL ) + { + st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; + move16(); + } + /*-----------------------------------------------------------------* + * FD-CNG encoder + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + test(); + IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) + { + createFdCngEnc_fx( &st->hFdCngEnc ); + initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); + /* initialization for IVAS modes happens in first frame pre-processing */ + IF( st->element_mode == EVS_MONO ) + { + Word32 total_brate; + + test(); + IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) + { + total_brate = ACELP_9k60; + move32(); + } + ELSE + { + total_brate = st->total_brate; + move32(); + } + + configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, total_brate ); + } + } + ELSE + { + st->hFdCngEnc = NULL; + } + + /*-----------------------------------------------------------------* + * Transient detector + *-----------------------------------------------------------------*/ + + IF( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); + } + Word16 temp; + Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); + frame_length = shr( frame_length, sub( 15, temp ) ); + + IF( GT_16( st->element_mode, EVS_MONO ) ) + { + InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); + } + ELSE + { + InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); + } + + /*-----------------------------------------------------------------* + * IVAS parameters + *-----------------------------------------------------------------*/ + + st->tdm_LRTD_flag = 0; + move16(); + st->cng_sba_flag = 0; + move16(); + st->bits_frame_channel = 0; + move16(); + st->side_bits_frame_channel = 0; + move16(); + st->Q_syn2 = 0; + move16(); + st->Q_syn = 0; + move16(); + set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); + set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); + st->Q_old = 15; + move16(); + st->old_wsp_max = 0; + move16(); + st->old_wsp_shift = 0; + move16(); + st->sharpFlag = 0; + move16(); + + return error; +} + + +/*-----------------------------------------------------------------------* + * destroy_cldfb_encoder() + * + * Free memory which was allocated in init_encoder() + *-----------------------------------------------------------------------*/ + +void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: Encoder static variables structure */ +) +{ + deleteCldfb_ivas_fx( &st->cldfbSynTd ); + deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); + + deleteFdCngEnc_fx( &st->hFdCngEnc ); + + return; +} diff --git a/lib_enc/inov_enc.c b/lib_enc/inov_enc.c deleted file mode 100644 index 08f1e768f..000000000 --- a/lib_enc/inov_enc.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * inov_encode() - * - * Encode the algebraic innovation - *---------------------------------------------------------------------*/ diff --git a/lib_enc/isf_enc_amr_wb.c b/lib_enc/isf_enc_amr_wb.c deleted file mode 100644 index 7bb7c56fe..000000000 --- a/lib_enc/isf_enc_amr_wb.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index 0dd0f5aa1..eb82aa78a 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -35,6 +35,7 @@ #include "options.h" #include "ivas_cnst.h" #include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" @@ -174,7 +175,7 @@ static Word16 ivas_arith_encode_array_fx( pCum_freq = pArith->cum_freq[0]; /* Q0 */ } - ari_start_encoding_14bits( &as ); + ari_start_encoding_14bits_ivas_fx( &as ); FOR( i = 0; i < in_len; i++ ) { diff --git a/lib_enc/lead_indexing.c b/lib_enc/lead_indexing.c deleted file mode 100644 index 3a6a477b9..000000000 --- a/lib_enc/lead_indexing.c +++ /dev/null @@ -1,208 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - -static int16_t fcb_encode_pos( const int16_t pos_vector[], const int16_t pulse_num, const int16_t pos_num ); - - -/*-------------------------------------------------------------------* - * re8_compute_base_index: - * - * Compute base index for RE8 - *-------------------------------------------------------------------*/ - -void re8_compute_base_index( - const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */ - const int16_t ka, /* i : Identifier of the absolute leader related to x */ - uint16_t *I /* o : index */ -) -{ - int16_t i, j, k1, m; - int16_t setor_8p[8], setor_8p_temp[8]; - int16_t sign_8p; - int16_t code_index, code_level, code_area; - uint16_t offset; - const int16_t *a1, *a2; - - a1 = vals_a[ka]; - a2 = vals_q[ka]; - - /* the sign process */ - - sign_8p = 0; - m = 0; - code_index = 0; - k1 = a2[0]; - - if ( ( a2[1] == 2 ) && ( a1[0] ^ 1 ) && ( ka != 5 ) ) - { - for ( i = 0; i < 8; i++ ) - { - if ( x[i] != 0 ) - { - sign_8p = sign_8p * 2; - setor_8p_temp[m] = i; - m++; - } - if ( x[i] < 0 ) - { - sign_8p += 1; - } - } - - code_index = fcb_encode_pos( setor_8p_temp, 8, m ); - code_index = ( code_index << k1 ) + sign_8p; - - offset = Is[ka]; - - - *I = offset + code_index; - } - else - { - for ( i = 0; i < 8; i++ ) - { - setor_8p[i] = (int16_t) abs( x[i] ); - - if ( x[i] < 0 ) - { - sign_8p = sign_8p * 2 + 1; - m++; - } - if ( x[i] > 0 ) - { - sign_8p = sign_8p * 2; - m++; - } - } - - if ( k1 != m ) - { - sign_8p = sign_8p >> 1; - } - - /* code level by level */ - - code_level = a2[1]; - code_area = 8; - - if ( a2[2] != 1 ) - { - for ( j = 0; j < code_level - 1; j++ ) - { - m = 0; - - for ( i = 0; i < code_area; i++ ) - { - if ( setor_8p[i] != a1[j] ) - { - setor_8p_temp[m] = i; - setor_8p[m] = setor_8p[i]; - m++; - } - } - code_index *= select_table22[m][code_area]; - - code_index += fcb_encode_pos( setor_8p_temp, code_area, m ); - - code_area = m; - } - } - else - { - for ( i = 0; i < code_area; i++ ) - { - if ( setor_8p[i] == a1[1] ) - { - code_index += i; - } - } - } - - code_index = ( code_index << k1 ) + sign_8p; - - offset = Is[ka]; - - *I = offset + code_index; - } - - return; -} - -/*-------------------------------------------------------------------* - * fcb_encode_pos: - * - * Base function to compute base index for RE8 - *-------------------------------------------------------------------*/ - -/*! r: Code index */ -static int16_t fcb_encode_pos( - const int16_t pos_vector[], /* i : Position vectort */ - const int16_t pulse_num, /* i : Pulse number */ - const int16_t pos_num /* i : Position number */ -) -{ - int16_t i, j; - int16_t code_index; - int16_t temp, temp1; - const int16_t *select_table23; - - temp = pulse_num - 1; - - select_table23 = select_table22[pos_num]; - - code_index = select_table23[pulse_num] - select_table23[pulse_num - pos_vector[0]]; - - for ( i = 0, j = 1; i < pos_num - 1; i++, j++ ) - { - temp1 = pos_num - j; - - select_table23 = select_table22[temp1]; - - code_index += select_table23[temp - pos_vector[i]] - select_table23[pulse_num - pos_vector[j]]; - } - - return code_index; -} diff --git a/lib_enc/long_enr.c b/lib_enc/long_enr.c deleted file mode 100644 index 31ab8f019..000000000 --- a/lib_enc/long_enr.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * long_enr() - * - * Compute relative energy, long-term average total noise energy and total active speech energy - *-------------------------------------------------------------------*/ diff --git a/lib_enc/lp_exc_e.c b/lib_enc/lp_exc_e.c deleted file mode 100644 index 5c3581f4f..000000000 --- a/lib_enc/lp_exc_e.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c deleted file mode 100644 index 3ac84b28e..000000000 --- a/lib_enc/lsf_enc.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "basop_proto_func.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/ltd_stable.c b/lib_enc/ltd_stable.c deleted file mode 100644 index 0e2004abf..000000000 --- a/lib_enc/ltd_stable.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/mdct_classifier.c b/lib_enc/mdct_classifier.c deleted file mode 100644 index 047f02355..000000000 --- a/lib_enc/mdct_classifier.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include -#include "ivas_prot_fx.h" diff --git a/lib_enc/mdct_selector.c b/lib_enc/mdct_selector.c deleted file mode 100644 index 952043e3a..000000000 --- a/lib_enc/mdct_selector.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/mslvq_enc.c b/lib_enc/mslvq_enc.c deleted file mode 100644 index a49d435c3..000000000 --- a/lib_enc/mslvq_enc.c +++ /dev/null @@ -1,308 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "ivas_prot.h" - -/*-----------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------*/ - -Word32 quantize_data_ivas_fx( Word16 *data, const Word16 *w_in, Word16 *qin, Word16 *cv_out, Word16 *idx_lead, Word16 *idx_scale, const Word16 *sigma, const Word16 *inv_sigma, const Word16 *scales, const Word16 *no_lead ); - -/*-----------------------------------------------------------------* - * mslvq() - * - * Encodes the LSF residual - *-----------------------------------------------------------------*/ - -Word32 mslvq_ivas_16( - Word16 *pTmp, /* i : M-dimensional input vector */ - Word16 *quant, /* o : quantized vector */ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w, /* i : weights for LSF quantization */ - const Word16 mode, /* i : number indicating the coding type (V/UV/G...)*/ - const Word16 mode_glb, /* i : LVQ coding mode */ - const Word16 pred_flag /* i : prediction flag (0: safety net, 1,2 - predictive )*/ - /*Retunr dist in q 22*/ -) -{ - Word32 dist, L_tmp; - const Word16 *p_scales, *p_sigma, *p_inv_sigma; - Word16 i, tmp, tmp1; - Word16 p_no_lead[MAX_NO_SCALES * 2]; - dist = L_deposit_l( 0 ); - IF( pred_flag == 0 ) - { - p_sigma = sigma_MSLVQ_fx[mode]; - /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; - p_scales = scales_ivas_fx[mode_glb]; - - tmp = no_lead_idx[mode_glb][0]; - move16(); - tmp1 = no_lead_idx[mode_glb][1]; - move16(); - test(); - if ( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) - { - tmp = add( tmp, DELTA_LEADER ); - } - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) leaders_short[tmp][i]; - move16(); - p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; - move16(); - } - } - ELSE - { - IF( GE_16( pred_flag, 5 ) ) - { - /* assert( pred_flag >= 12 && pred_flag <= 15 ); */ - /* pred_flag is here the number of bits for MSLVQ */ - - p_sigma = &modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; - - /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = &inv_modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; - IF( mode_glb == 0 ) - { - p_scales = &scales_BWE_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; - - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) no_lead_BWE[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; - move16(); - } - } - ELSE - { - p_scales = &scales_BWE_3b_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) no_lead_BWE_3b[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; - move16(); - } - } - } - ELSE - { - p_sigma = sigma_p_fx[mode]; - - /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_p_fx[mode]; - - p_scales = scales_p_ivas_fx[mode_glb]; - - tmp = no_lead_p_idx[mode_glb][0]; - move16(); - tmp1 = no_lead_p_idx[mode_glb][1]; - move16(); - - test(); - IF( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) - { - tmp = add( tmp, DELTA_LEADER ); - } - - test(); - IF( EQ_16( tmp, LIMIT_LEADER ) && ( tmp1 == 0 ) ) - { - tmp = add( tmp, DELTA_LEADER ); - tmp1 = add( tmp1, DELTA_LEADER ); - } - - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) leaders_short[tmp][i]; - move16(); - p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; - move16(); - } - } - } - - /* first subvector */ - dist = quantize_data_ivas_fx( pTmp, w, quant, cv_out, idx_lead, idx_scale, - p_sigma, p_inv_sigma, p_scales, p_no_lead ); - - IF( LT_16( pred_flag, 5 ) ) - { - /* second subvector */ - L_tmp = quantize_data_ivas_fx( pTmp + LATTICE_DIM, w + LATTICE_DIM, quant + LATTICE_DIM, cv_out + LATTICE_DIM, &idx_lead[1], &idx_scale[1], p_sigma + LATTICE_DIM, p_inv_sigma + LATTICE_DIM, p_scales + MAX_NO_SCALES, p_no_lead + MAX_NO_SCALES ); - - dist = L_add( dist, L_tmp ); - } - - return dist; -} - -/*-----------------------------------------------------------------* - * mslvq_cng() - * - * Encodes the LSF residual in SID frames - *-----------------------------------------------------------------*/ - -/*-----------------------------------------------------------------* - * prepare_data() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * calculate_min_dist() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * quantize_data() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * index_lvq() - * - * sorts in descending order and computes indices in the sorted vector - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * encode_comb() - * - * creates an index for the lattice codevector - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * index_leaders() - * - * gives the index in a class of leaders without considering the sign yet - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * find_pos() - * - * Finds the positions in vector c for which the vector components are equal to 'arg'. - * It returns the number of such positions and their values in the array 'p'. - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * encode_sign_pc1() - * - * Creates an index for signs of the significant codevector components - * Gives the index of the signs - binary representation where negative sign stands for 1 - * and positive sign stands for 1. - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * take_out_val() - * - * removes the value val from the vector v - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * c2idx() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * index_lvq_SHB() - * - *-----------------------------------------------------------------*/ - - -UWord32 index_lvq_SHB_fx( - const Word16 idx_lead, - const Word16 idx_scale, - const Word16 nbits, - Word16 *lat_cv, - const Word16 mode ) -{ - UWord16 i; - const Word8 *p_no_lead; - UWord32 index; - - IF( mode == 0 ) - { - p_no_lead = &no_lead_BWE[( nbits - mslvq_SHB_min_bits[0] ) * 3]; - } - ELSE - { - p_no_lead = &no_lead_BWE_3b[( nbits - mslvq_SHB_min_bits[1] ) * 3]; - } - - index = 0; - move32(); - IF( GT_16( idx_lead, -1 ) ) - { - index = 1; - move32(); - FOR( i = 0; i < idx_scale; i++ ) - { - index = index + table_no_cv[p_no_lead[i]]; - move32(); - } - - IF( idx_lead > 0 ) - { - index = index + table_no_cv[idx_lead]; - move32(); - } - - index = index + encode_comb_fx( lat_cv, idx_lead ); - move32(); - } - - return index; -} diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index b6445443b..d8a78c525 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -1140,3 +1140,180 @@ Word16 c2idx_fx( /* o: index */ return tmp; } } + +/*-----------------------------------------------------------------* + * mslvq() + * + * Encodes the LSF residual + *-----------------------------------------------------------------*/ + +Word32 mslvq_ivas_16( + Word16 *pTmp, /* i : M-dimensional input vector */ + Word16 *quant, /* o : quantized vector */ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w, /* i : weights for LSF quantization */ + const Word16 mode, /* i : number indicating the coding type (V/UV/G...)*/ + const Word16 mode_glb, /* i : LVQ coding mode */ + const Word16 pred_flag /* i : prediction flag (0: safety net, 1,2 - predictive )*/ + /*Retunr dist in q 22*/ +) +{ + Word32 dist, L_tmp; + const Word16 *p_scales, *p_sigma, *p_inv_sigma; + Word16 i, tmp, tmp1; + Word16 p_no_lead[MAX_NO_SCALES * 2]; + dist = L_deposit_l( 0 ); + IF( pred_flag == 0 ) + { + p_sigma = sigma_MSLVQ_fx[mode]; + /* inverse sigma is precomputed to save complexity */ + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; + p_scales = scales_ivas_fx[mode_glb]; + + tmp = no_lead_idx[mode_glb][0]; + move16(); + tmp1 = no_lead_idx[mode_glb][1]; + move16(); + test(); + if ( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) + { + tmp = add( tmp, DELTA_LEADER ); + } + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) leaders_short[tmp][i]; + move16(); + p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; + move16(); + } + } + ELSE + { + IF( GE_16( pred_flag, 5 ) ) + { + /* assert( pred_flag >= 12 && pred_flag <= 15 ); */ + /* pred_flag is here the number of bits for MSLVQ */ + + p_sigma = &modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; + + /* inverse sigma is precomputed to save complexity */ + p_inv_sigma = &inv_modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; + IF( mode_glb == 0 ) + { + p_scales = &scales_BWE_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; + + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) no_lead_BWE[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; + move16(); + } + } + ELSE + { + p_scales = &scales_BWE_3b_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) no_lead_BWE_3b[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; + move16(); + } + } + } + ELSE + { + p_sigma = sigma_p_fx[mode]; + + /* inverse sigma is precomputed to save complexity */ + p_inv_sigma = inv_sigma_p_fx[mode]; + + p_scales = scales_p_ivas_fx[mode_glb]; + + tmp = no_lead_p_idx[mode_glb][0]; + move16(); + tmp1 = no_lead_p_idx[mode_glb][1]; + move16(); + + test(); + IF( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) + { + tmp = add( tmp, DELTA_LEADER ); + } + + test(); + IF( EQ_16( tmp, LIMIT_LEADER ) && ( tmp1 == 0 ) ) + { + tmp = add( tmp, DELTA_LEADER ); + tmp1 = add( tmp1, DELTA_LEADER ); + } + + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) leaders_short[tmp][i]; + move16(); + p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; + move16(); + } + } + } + + /* first subvector */ + dist = quantize_data_ivas_fx( pTmp, w, quant, cv_out, idx_lead, idx_scale, + p_sigma, p_inv_sigma, p_scales, p_no_lead ); + + IF( LT_16( pred_flag, 5 ) ) + { + /* second subvector */ + L_tmp = quantize_data_ivas_fx( pTmp + LATTICE_DIM, w + LATTICE_DIM, quant + LATTICE_DIM, cv_out + LATTICE_DIM, &idx_lead[1], &idx_scale[1], p_sigma + LATTICE_DIM, p_inv_sigma + LATTICE_DIM, p_scales + MAX_NO_SCALES, p_no_lead + MAX_NO_SCALES ); + + dist = L_add( dist, L_tmp ); + } + + return dist; +} + + +UWord32 index_lvq_SHB_fx( + const Word16 idx_lead, + const Word16 idx_scale, + const Word16 nbits, + Word16 *lat_cv, + const Word16 mode ) +{ + UWord16 i; + const Word8 *p_no_lead; + UWord32 index; + + IF( mode == 0 ) + { + p_no_lead = &no_lead_BWE[( nbits - mslvq_SHB_min_bits[0] ) * 3]; + } + ELSE + { + p_no_lead = &no_lead_BWE_3b[( nbits - mslvq_SHB_min_bits[1] ) * 3]; + } + + index = 0; + move32(); + IF( GT_16( idx_lead, -1 ) ) + { + index = 1; + move32(); + FOR( i = 0; i < idx_scale; i++ ) + { + index = index + table_no_cv[p_no_lead[i]]; + move32(); + } + + IF( idx_lead > 0 ) + { + index = index + table_no_cv[idx_lead]; + move32(); + } + + index = index + encode_comb_fx( lat_cv, idx_lead ); + move32(); + } + + return index; +} diff --git a/lib_enc/multi_harm.c b/lib_enc/multi_harm.c deleted file mode 100644 index 5c3581f4f..000000000 --- a/lib_enc/multi_harm.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/nelp_enc.c b/lib_enc/nelp_enc.c deleted file mode 100644 index 7ea6e47a5..000000000 --- a/lib_enc/nelp_enc.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c deleted file mode 100644 index 5bde0f450..000000000 --- a/lib_enc/pit_enc.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/pitch_ol.c b/lib_enc/pitch_ol.c deleted file mode 100644 index 0853fd9fd..000000000 --- a/lib_enc/pitch_ol.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c deleted file mode 100644 index dc77e0dfa..000000000 --- a/lib_enc/pitch_ol2.c +++ /dev/null @@ -1,274 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define MAX_DELTA 16 /* half-length of the delta search */ -#define COR_BUF_LEN ( L_INTERPOL1 * 2 + MAX_DELTA * 2 + 1 ) -/*-------------------------------------------------------------------* - * pitch_ol2() - * - * Open-loop pitch precision improvement with 1/4 resolution - * The pitch is searched in the interval 0 ) - { - ratio = 0; - move16(); - } - ELSE - { - ratio = s_max( sub( energy1_16, energy0_16 ), 0 ); /*Q7 */ - } - /*ratio *= max(voicing,0);*/ - tmp = s_max( voicing_m, 0 ); - ratio = mult_r( ratio, tmp ); /*Q7*/ - /**LF_EnergyRatio_sm = (15*(*LF_EnergyRatio_sm) + ratio)/16;*/ - L_tmp = L_mult( ratio, 2048 ); - L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); - *LF_EnergyRatio_sm = round_fx( L_tmp ); - move16(); - test(); - if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) - { - *predecision_flag = 1; - move16(); - } - - if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) ) - { - *predecision_flag = 0; - move16(); - } - - /* short pitch candidate detection */ - Tp = pitch[1]; - move16(); - cor_max = 0; - move16(); - pt_wsp = wsp + 3 * L_SUBFR; - pit_min = PIT_MIN_DOUBLEEXTEND; - move16(); - pit_min_up = PIT_MIN; - move16(); - FOR( T = pit_min; T <= pit_min_up; T++ ) - { - energy1 = Dot_product( pt_wsp, pt_wsp - T, L_SUBFR ); - test(); - IF( ( GT_32( energy1, cor_max ) ) || ( EQ_16( T, pit_min ) ) ) - { - cor_max = L_add( energy1, 0 ); - Tp = T; - move16(); - } - } - energy0 = Dot_product12( pt_wsp, pt_wsp, L_SUBFR, &exp1 ); - exp1 = sub( exp1, shl( Q_new, 1 ) ); - energy1 = Dot_product12( pt_wsp - Tp, pt_wsp - Tp, L_SUBFR, &exp2 ); - exp2 = sub( exp2, shl( Q_new, 1 ) ); - /* cor_max *= inv_sqrt( energy0*energy1 );*/ - L_tmp = Mult_32_32( energy0, energy1 ); - exp = norm_l( L_tmp ); - L_tmp1 = L_shl( L_tmp, exp ); - - exp = sub( sub( 31, exp ), ( sub( sub( 31, exp1 ), exp2 ) ) ); - move16(); - L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ - cor_max = Mult_32_32( cor_max, L_tmp1 ); - exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); - cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ - /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ - *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); - move16(); - - /* final short pitch detection */ - test(); - test(); - test(); - *flag_spitch = 0; - move16(); - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } - - return; -} diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 5d68216c9..7ca13171e 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -404,3 +404,227 @@ void StableHighPitchDetect_fx( return; } + + +/*-------------------------------------------------------------------* + * pitch_ol2() + * + * Open-loop pitch precision improvement with 1/4 resolution + * The pitch is searched in the interval 0 ) + { + ratio = 0; + move16(); + } + ELSE + { + ratio = s_max( sub( energy1_16, energy0_16 ), 0 ); /*Q7 */ + } + /*ratio *= max(voicing,0);*/ + tmp = s_max( voicing_m, 0 ); + ratio = mult_r( ratio, tmp ); /*Q7*/ + /**LF_EnergyRatio_sm = (15*(*LF_EnergyRatio_sm) + ratio)/16;*/ + L_tmp = L_mult( ratio, 2048 ); + L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); + *LF_EnergyRatio_sm = round_fx( L_tmp ); + move16(); + test(); + if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) + { + *predecision_flag = 1; + move16(); + } + + if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) ) + { + *predecision_flag = 0; + move16(); + } + + /* short pitch candidate detection */ + Tp = pitch[1]; + move16(); + cor_max = 0; + move16(); + pt_wsp = wsp + 3 * L_SUBFR; + pit_min = PIT_MIN_DOUBLEEXTEND; + move16(); + pit_min_up = PIT_MIN; + move16(); + FOR( T = pit_min; T <= pit_min_up; T++ ) + { + energy1 = Dot_product( pt_wsp, pt_wsp - T, L_SUBFR ); + test(); + IF( ( GT_32( energy1, cor_max ) ) || ( EQ_16( T, pit_min ) ) ) + { + cor_max = L_add( energy1, 0 ); + Tp = T; + move16(); + } + } + energy0 = Dot_product12( pt_wsp, pt_wsp, L_SUBFR, &exp1 ); + exp1 = sub( exp1, shl( Q_new, 1 ) ); + energy1 = Dot_product12( pt_wsp - Tp, pt_wsp - Tp, L_SUBFR, &exp2 ); + exp2 = sub( exp2, shl( Q_new, 1 ) ); + /* cor_max *= inv_sqrt( energy0*energy1 );*/ + L_tmp = Mult_32_32( energy0, energy1 ); + exp = norm_l( L_tmp ); + L_tmp1 = L_shl( L_tmp, exp ); + + exp = sub( sub( 31, exp ), ( sub( sub( 31, exp1 ), exp2 ) ) ); + move16(); + L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ + cor_max = Mult_32_32( cor_max, L_tmp1 ); + exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); + cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ + /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ + *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); + move16(); + + /* final short pitch detection */ + test(); + test(); + test(); + *flag_spitch = 0; + move16(); + IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && + ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) + { + *flag_spitch = 1; + move16(); + pitch[0] = Tp; + move16(); + pitch[1] = Tp; + move16(); + pitch[2] = Tp; + move16(); + } + + return; +} diff --git a/lib_enc/plc_enc_ext.c b/lib_enc/plc_enc_ext.c deleted file mode 100644 index 17c76dee6..000000000 --- a/lib_enc/plc_enc_ext.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "stat_enc.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c deleted file mode 100644 index b7ff1d2b6..000000000 --- a/lib_enc/setmodeindex.c +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*--------------------------------------------------------------------------- - - function name: SetModeIndex - description: function for configuring the codec between frames - currently bitrate and bandwidth only - must not be called while a frame is encoded - hence mutexes must be used in MT environments - - format: BANDWIDTH*16 + BITRATE (mode index) - - ---------------------------------------------------------------------------*/ - -void SetModeIndex_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ -) -{ - Word16 ini_frame_loc = st->ini_frame; // Q0 - move16(); - - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) - { - st->ini_frame = 0; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - /* Reconfigure the core coder */ - IF( ( NE_32( last_total_brate, st->total_brate ) ) || - ( NE_16( st->last_bwidth, st->bwidth ) ) || - ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || - ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || - ( NE_16( st->rf_mode_last, st->rf_mode ) ) || - ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) - { - core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); - } - - st->ini_frame = ini_frame_loc; // Q0 - move16(); - - return; -} diff --git a/lib_enc/setmodeindex_fx.c b/lib_enc/setmodeindex_fx.c index fc3025f51..012c5757f 100644 --- a/lib_enc/setmodeindex_fx.c +++ b/lib_enc/setmodeindex_fx.c @@ -55,3 +55,48 @@ void SetModeIndex_fx( return; } + + +void SetModeIndex_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ +) +{ + Word16 ini_frame_loc = st->ini_frame; // Q0 + move16(); + + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) + { + st->ini_frame = 0; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + /* Reconfigure the core coder */ + IF( ( NE_32( last_total_brate, st->total_brate ) ) || + ( NE_16( st->last_bwidth, st->bwidth ) ) || + ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || + ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || + ( NE_16( st->rf_mode_last, st->rf_mode ) ) || + ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) + { + core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); + } + + st->ini_frame = ini_frame_loc; // Q0 + move16(); + + return; +} -- GitLab From ffd9acccfccfb915b783e0c8fcc4ac9649181786 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 11:54:54 +0530 Subject: [PATCH 238/329] Restore cod_tcx_fx.c fix and LTV crash fix for +10dB files --- lib_enc/cod_tcx_fx.c | 127 +++++++++++++++++++++++++++++++++++++------ lib_enc/gs_enc_fx.c | 4 +- 2 files changed, 112 insertions(+), 19 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index bf20608b0..0ed7535f1 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5384,8 +5384,11 @@ void TNSAnalysisStereo_fx( TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; + move32(); + Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; + move16(); + Word16 sum_e = 0; move16(); - individual_decision[0] = 0; move16(); individual_decision[1] = 0; @@ -5520,7 +5523,9 @@ void TNSAnalysisStereo_fx( test(); IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; + Word32 maxPredGain_fx = -ONE_IN_Q31; + move32(); + Word16 maxPredGain_e = 0; move16(); sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; @@ -5538,30 +5543,74 @@ void TNSAnalysisStereo_fx( * both filters for the decision */ - meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 - maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 - + meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = meanPredictionGain_fx; + maxPredictionGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } + Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); + if ( flag_1 < 0 ) + { + flag_1 = 0; + move16(); + } test(); test(); test(); - IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && - GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && + flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + move32(); + move32(); + pFilter[0]->predictionGain_e = pFilter[1]->predictionGain_e = meanPredictionGain_e; /* more TNS filter sync at 48kbps */ + move16(); move16(); + pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ + move16(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); + if ( flag < 0 ) + { + flag = 0; move16(); } test(); - IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && + IF( flag && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredGain_fx = meanPredictionGain_fx; + maxPredGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -5764,10 +5813,16 @@ void TNSAnalysisStereo_fx( move16(); } } + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -5787,7 +5842,15 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } @@ -5825,7 +5888,9 @@ void TNSAnalysisStereo_fx( IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 + Word32 maxPredGain_fx = -ONE_IN_Q31; // Q31 + move32(); + Word16 maxPredGain_e = 0; move16(); sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; @@ -5836,9 +5901,23 @@ void TNSAnalysisStereo_fx( pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); + IF ( flag < 0 ) + { + maxPredGain_fx = pFilter->predictionGain32; + move32(); + maxPredGain_e = pFilter->predictionGain_e; + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); - IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -5910,9 +5989,15 @@ void TNSAnalysisStereo_fx( sts[ch]->hTcxEnc->fUseTns[k] = 0; } move16(); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -5927,7 +6012,15 @@ void TNSAnalysisStereo_fx( move16(); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 7ae8fb42e..a804c1311 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -679,9 +679,9 @@ void encod_audio_ivas_fx( *--------------------------------------------------------------------------------------*/ edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); - scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); + Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); - scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); + Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); Q_exc = Q_new; move16(); /*--------------------------------------------------------------------------------------* -- GitLab From 7a7515d693a14f7af64802c8cbe1b8496b1cd808 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 11:57:37 +0530 Subject: [PATCH 239/329] Clang formatting changes --- lib_enc/cod_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 0ed7535f1..93c1dc58d 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5903,7 +5903,7 @@ void TNSAnalysisStereo_fx( // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF ( flag < 0 ) + IF( flag < 0 ) { maxPredGain_fx = pFilter->predictionGain32; move32(); -- GitLab From defa4937cc74af9928015fd67aa64d8aabcedbdd Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 13:42:55 +0530 Subject: [PATCH 240/329] Optimization of stereo decode path 32kHz @32kbps --- lib_com/fft_fx.c | 334 ++++++++++++++++++++++++++++ lib_com/hp50_fx.c | 66 ++++++ lib_com/modif_fs.c | 94 ++++++++ lib_com/mslvq_com_fx.c | 50 +++++ lib_com/options.h | 1 + lib_com/scale_mem_fx.c | 13 ++ lib_com/trans_inv_fx.c | 31 ++- lib_dec/acelp_core_dec_ivas_fx.c | 18 +- lib_dec/ivas_stereo_cng_dec.c | 19 +- lib_dec/ivas_stereo_dft_dec_fx.c | 167 ++++++++++++-- lib_dec/ivas_stereo_switching_dec.c | 38 +++- lib_dec/ivas_stereo_td_dec.c | 24 +- 12 files changed, 833 insertions(+), 22 deletions(-) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 1b095e346..acadbb06b 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -4727,6 +4727,16 @@ static void fft_len16( cmplx t[4]; cmplx y[16]; +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[0]; // Qx + move64(); + s[1] = x[4]; // Qx + move64(); + s[2] = x[8]; // Qx + move64(); + s[3] = x[12]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[0], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[4], SCALEFACTOR16 ); // Qx @@ -4735,6 +4745,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[12], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4754,6 +4765,16 @@ static void fft_len16( y[3] = CL_add( t[1], t[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[1]; // Qx + move64(); + s[1] = x[5]; // Qx + move64(); + s[2] = x[9]; // Qx + move64(); + s[3] = x[13]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[1], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[5], SCALEFACTOR16 ); // Qx @@ -4762,6 +4783,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[13], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4781,6 +4803,16 @@ static void fft_len16( y[7] = CL_add( t[1], t[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[2]; // Qx + move64(); + s[1] = x[6]; // Qx + move64(); + s[2] = x[10]; // Qx + move64(); + s[3] = x[14]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[2], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[6], SCALEFACTOR16 ); // Qx @@ -4789,6 +4821,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[14], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4810,6 +4843,16 @@ static void fft_len16( y[11] = CL_add( t[1], t[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[3]; // Qx + move64(); + s[1] = x[7]; // Qx + move64(); + s[2] = x[11]; // Qx + move64(); + s[3] = x[15]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[3], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[7], SCALEFACTOR16 ); // Qx @@ -4818,6 +4861,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[15], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4978,6 +5022,18 @@ static void fft_len20_fx( cmplx tt[4]; cmplx y[20]; +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[0]; // Qx + move64(); + xx[1] = x[16]; // Qx + move64(); + xx[2] = x[12]; // Qx + move64(); + xx[3] = x[8]; // Qx + move64(); + xx[4] = x[4]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[0], SCALEFACTOR20 ); // Qx move64(); xx[1] = CL_shr( x[16], SCALEFACTOR20 ); // Qx @@ -4988,6 +5044,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[4], SCALEFACTOR20 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5023,6 +5080,18 @@ static void fft_len20_fx( y[12] = CL_msu_j( s[2], s[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[5]; + move64(); + xx[1] = x[1]; + move64(); + xx[2] = x[17]; + move64(); + xx[3] = x[13]; + move64(); + xx[4] = x[9]; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[5], SCALEFACTOR20 ); move64(); xx[1] = CL_shr( x[1], SCALEFACTOR20 ); @@ -5033,6 +5102,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[9], SCALEFACTOR20 ); move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5068,6 +5138,18 @@ static void fft_len20_fx( y[13] = CL_msu_j( s[2], s[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[10]; + move64(); + xx[1] = x[6]; + move64(); + xx[2] = x[2]; + move64(); + xx[3] = x[18]; + move64(); + xx[4] = x[14]; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[10], SCALEFACTOR20 ); move64(); xx[1] = CL_shr( x[6], SCALEFACTOR20 ); @@ -5078,6 +5160,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[14], SCALEFACTOR20 ); move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5113,6 +5196,18 @@ static void fft_len20_fx( y[14] = CL_msu_j( s[2], s[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[15]; + move64(); + xx[1] = x[11]; + move64(); + xx[2] = x[7]; + move64(); + xx[3] = x[3]; + move64(); + xx[4] = x[19]; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[15], SCALEFACTOR20 ); move64(); xx[1] = CL_shr( x[11], SCALEFACTOR20 ); @@ -5123,6 +5218,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[19], SCALEFACTOR20 ); move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -6501,6 +6597,239 @@ static void fft_lenN( cmplx s[8]; cmplx y[8]; +#ifdef OPT_STEREO_32KBPS_V1 + y[1] = xx[1 * dim1]; + move64(); + y[2] = xx[2 * dim1]; + move64(); + y[3] = xx[3 * dim1]; + move64(); + y[4] = xx[4 * dim1]; + move64(); + y[5] = xx[5 * dim1]; + move64(); + y[6] = xx[6 * dim1]; + move64(); + y[7] = xx[7 * dim1]; + move64(); + + test(); + test(); + IF( EQ_16( dim1, 8 ) || EQ_16( dim1, 16 ) || EQ_16( dim1, 32 ) ) + { + FOR( i = 0; i < dim1; i++ ) + { + { + y[0] = xx[i]; + move64(); + }; + IF( i > 0 ) + { + { + y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + } + + t[0] = CL_add( y[0], y[4] ); + move64(); + t[1] = CL_sub( y[0], y[4] ); + move64(); + t[2] = CL_add( y[1], y[5] ); + move64(); + t[3] = CL_sub( y[1], y[5] ); + move64(); + t[4] = CL_add( y[2], y[6] ); + move64(); + t[5] = CL_sub( y[2], y[6] ); + move64(); + t[6] = CL_add( y[3], y[7] ); + move64(); + t[7] = CL_sub( y[3], y[7] ); + move64(); + + s[0] = CL_add( t[0], t[4] ); + move64(); + s[2] = CL_sub( t[0], t[4] ); + move64(); + s[4] = CL_mac_j( t[1], t[5] ); + move64(); + s[5] = CL_msu_j( t[1], t[5] ); + move64(); + s[1] = CL_add( t[2], t[6] ); + move64(); + s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); + move64(); + + t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); + move64(); + t[1] = CL_sub( t[3], t[7] ); + move64(); + + s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx + move64(); + s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx + move64(); + s[7] = CL_conjugate( s[7] ); + move64(); + + x[i] = CL_add( s[0], s[1] ); + move64(); + x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); + move64(); + x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); + move64(); + x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); + move64(); + x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); + move64(); + x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); + move64(); + x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); + move64(); + x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); + move64(); + } + } + ELSE + { + FOR( i = 0; i < dim1; i++ ) + { + { + y[0] = xx[i]; + move64(); + }; + IF( i > 0 ) + { + { + y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + } + + t[0] = CL_add( y[0], y[4] ); + move64(); + t[1] = CL_sub( y[0], y[4] ); + move64(); + t[2] = CL_add( y[1], y[5] ); + move64(); + t[3] = CL_sub( y[1], y[5] ); + move64(); + t[4] = CL_add( y[2], y[6] ); + move64(); + t[5] = CL_sub( y[2], y[6] ); + move64(); + t[6] = CL_add( y[3], y[7] ); + move64(); + t[7] = CL_sub( y[3], y[7] ); + move64(); + + s[0] = CL_add( t[0], t[4] ); + move64(); + s[2] = CL_sub( t[0], t[4] ); + move64(); + s[4] = CL_mac_j( t[1], t[5] ); + move64(); + s[5] = CL_msu_j( t[1], t[5] ); + move64(); + s[1] = CL_add( t[2], t[6] ); + move64(); + s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); + move64(); + + t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); + move64(); + t[1] = CL_sub( t[3], t[7] ); + move64(); + + s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx + move64(); + s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx + move64(); + s[7] = CL_conjugate( s[7] ); + move64(); + + x[i] = CL_add( s[0], s[1] ); + move64(); + x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); + move64(); + x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); + move64(); + x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); + move64(); + x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); + move64(); + x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); + move64(); + x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); + move64(); + x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); + move64(); + } + } +#else /* OPT_STEREO_32KBPS_V1 */ test(); test(); test(); @@ -6781,6 +7110,7 @@ static void fft_lenN( move64(); } } +#endif /* OPT_STEREO_32KBPS_V1 */ BREAK; } @@ -7173,7 +7503,11 @@ void rfft_fx( move32(); x[( length - ( i << 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 /*0.5.Q15*/ ); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_add( t2, t4 ), -16384 /*0.5.Q15*/ ); +#else /* OPT_STEREO_32KBPS_V1 */ x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 /*0.5.Q15*/ ); +#endif /* OPT_STEREO_32KBPS_V1 */ move32(); } diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 84bbf8b3c..d13835f4c 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -469,8 +469,14 @@ void hp20_fx_32( { Word16 i; Word32 a1_fx, a2_fx, b1_fx, b2_fx; +#ifdef OPT_STEREO_32KBPS_V1 + Word16 Qy1, Qy2, Qmin; + Word64 y0_fx64, y1_fx64, y2_fx64; + Word32 x0, x1, x2; +#else /* OPT_STEREO_32KBPS_V1 */ Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; +#endif /* OPT_STEREO_32KBPS_V1 */ IF( EQ_32( Fs, 8000 ) ) { @@ -521,15 +527,64 @@ void hp20_fx_32( move32(); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + y1_fx64 = W_add( W_deposit32_l( mem_fx[0] ), W_deposit32_h( mem_fx[1] ) ); + y2_fx64 = W_add( W_deposit32_l( mem_fx[2] ), W_deposit32_h( mem_fx[3] ) ); + + x0 = mem_fx[4]; + move32(); + x1 = mem_fx[5]; + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Qprev_y1 = extract_l( mem_fx[4] ); Qprev_y2 = extract_l( mem_fx[5] ); y1_fx64 = W_deposit32_l( mem_fx[0] ); y2_fx64 = W_deposit32_l( mem_fx[1] ); x0_fx64 = W_deposit32_l( mem_fx[2] ); x1_fx64 = W_deposit32_l( mem_fx[3] ); +#endif /* OPT_STEREO_32KBPS_V1 */ FOR( i = 0; i < lg; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + x2 = x1; + move32(); + x1 = x0; + move32(); + x0 = signal_fx[i]; + move32(); + + Qy1 = W_norm( y1_fx64 ); + if ( y1_fx64 == 0 ) + { + Qy1 = 62; + move16(); + } + + Qy2 = W_norm( y2_fx64 ); + if ( y2_fx64 == 0 ) + { + Qy2 = 62; + move16(); + } + + Qmin = s_min( Qy1, Qy2 ); + + Qmin = sub( Qmin, 34 ); + + y0_fx64 = W_mac_32_32( W_mult_32_32( W_shl_sat_l( y1_fx64, Qmin ), a1_fx ), W_shl_sat_l( y2_fx64, Qmin ), a2_fx ); // Qmin + Q29 + Q30 + 1 + + Word64 temp = W_mac_32_32( W_mac_32_32( W_mult_32_32( x2, b2_fx ), x1, b1_fx ), x0, b2_fx ); // Q30 + Word64 y0_fx = W_shr( y0_fx64, add( Qmin, Q30 ) ); // Q30 + y0_fx64 = W_add( temp, y0_fx ); // Q30 + signal_fx[i] = W_shl_sat_l( y0_fx64, -Q30 ); + move32(); + + y2_fx64 = y1_fx64; + move64(); + y1_fx64 = y0_fx64; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ x2_fx64 = x1_fx64; move64(); x1_fx64 = x0_fx64; @@ -611,8 +666,17 @@ void hp20_fx_32( move64(); move16(); move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifdef OPT_STEREO_32KBPS_V1 + mem_fx[0] = W_extract_l( y1_fx64 ); + mem_fx[1] = W_extract_h( y1_fx64 ); + mem_fx[2] = W_extract_l( y2_fx64 ); + mem_fx[3] = W_extract_h( y2_fx64 ); + mem_fx[4] = x0; + mem_fx[5] = x1; +#else /* OPT_STEREO_32KBPS_V1 */ Qy1 = W_norm( y1_fx64 ); test(); IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) ) @@ -635,6 +699,8 @@ void hp20_fx_32( mem_fx[3] = W_extract_l( x1_fx64 ); mem_fx[4] = Qprev_y1; mem_fx[5] = Qprev_y2; +#endif /* OPT_STEREO_32KBPS_V1 */ + move32(); move32(); move32(); diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 4af93522d..1b2836252 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -115,6 +115,22 @@ void Decimate_allpass_steep_fx32( /* upper allpass filter chain */ FOR( k = 0; k < N / 2; k++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx + move32(); + mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx + move32(); + + temp[1] = Madd_32_16( mem[1], temp[0], AP1_STEEP_FX[1] ); // Qx + move32(); + mem[1] = Msub_32_16( temp[0], temp[1], AP1_STEEP_FX[1] ); // Qx + move32(); + + out[k] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx move32(); mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx @@ -129,17 +145,31 @@ void Decimate_allpass_steep_fx32( move32(); mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } /* lower allpass filter chain */ +#ifdef OPT_STEREO_32KBPS_V1 + temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx move32(); /*if ( fabs( temp[n] ) < 1e-12 ) @@ -148,26 +178,48 @@ void Decimate_allpass_steep_fx32( }*/ mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifdef OPT_STEREO_32KBPS_V1 + temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); + + mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); FOR( k = 1; k < N / 2; k++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx move32(); /*if ( fabs( temp[n] ) < 1e-12 ) @@ -176,12 +228,20 @@ void Decimate_allpass_steep_fx32( }*/ mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifdef OPT_STEREO_32KBPS_V1 + temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); + mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); } @@ -211,12 +271,21 @@ void interpolate_3_over_2_allpass_32( FOR( i = 0; i < len; i++ ) { /* Upper branch */ +#ifdef OPT_STEREO_32KBPS_V1 + Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx + move32(); + Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx + move32(); + mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx move32(); Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx move32(); mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ mem[1] = Vu[0]; // Qx move32(); @@ -226,12 +295,21 @@ void interpolate_3_over_2_allpass_32( move32(); /* Middle branch */ +#ifdef OPT_STEREO_32KBPS_V1 + Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx + move32(); + Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx + move32(); + mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx move32(); Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx move32(); mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ mem[4] = Vm[0]; // Qx move32(); @@ -241,12 +319,21 @@ void interpolate_3_over_2_allpass_32( move32(); /* Lower branch */ +#ifdef OPT_STEREO_32KBPS_V1 + Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx + move32(); + Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx + move32(); + mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx move32(); Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx move32(); mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ mem[0] = input[i]; // Qx move32(); @@ -265,10 +352,17 @@ void interpolate_3_over_2_allpass_32( { mem_temp = out1_buff[2 * i]; move32(); +#ifdef OPT_STEREO_32KBPS_V1 + out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx + // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 + out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 ); + // 0.614152f in Q15 -> 20125 +#else /* OPT_STEREO_32KBPS_V1 */ out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) ); // 0.614152f in Q15 -> 20125 +#endif /* OPT_STEREO_32KBPS_V1 */ mem[10] = mem[11]; // Qx move32(); mem[11] = mem[12]; // Qx diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 14c9b6d97..d97830a5f 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -122,9 +122,33 @@ void init_lvq_fx( ) { Word16 i, j; +#ifdef OPT_STEREO_32KBPS_V1 + Word16 k; +#endif /* OPT_STEREO_32KBPS_V1 */ /* safety-net mode */ FOR( i = 0; i < MAX_NO_MODES; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) ) + { + if ( ( no_lead_fx[i][j] <= 0 ) ) + { + j = MAX_NO_SCALES; + } + } + no_scales[i][0] = k; + move16(); + + FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) ) + { + if ( no_lead_fx[i][j] <= 0 ) + { + j = MAX_NO_SCALES << 1; + } + } + no_scales[i][1] = k; + move16(); +#else /* OPT_STEREO_32KBPS_V1 */ j = 0; move16(); test(); @@ -143,10 +167,35 @@ void init_lvq_fx( } no_scales[i][1] = sub( j, MAX_NO_SCALES ); move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ } /* predictive mode */ FOR( i = 0; i < MAX_NO_MODES_p; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) ) + { + + if ( ( no_lead_p_fx[i][j] <= 0 ) ) + { + j = MAX_NO_SCALES; + } + } + no_scales_p[i][0] = k; + move16(); + + FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) ) + { + + if ( ( no_lead_p_fx[i][j] <= 0 ) ) + { + j = MAX_NO_SCALES << 1; + } + } + + no_scales_p[i][1] = k; + move16(); +#else /* OPT_STEREO_32KBPS_V1 */ j = 0; move16(); WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_p_fx[i][j] > 0 ) ) @@ -165,6 +214,7 @@ void init_lvq_fx( } no_scales_p[i][1] = sub( j, MAX_NO_SCALES ); move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ } /* index offsets for each truncation */ init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p ); diff --git a/lib_com/options.h b/lib_com/options.h index b24ac8267..d3570004d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,4 +172,5 @@ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ +//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #endif diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 002821050..2ce2ffd12 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -307,8 +307,15 @@ void scale_sig32( /* saturation can occur here */ x[i] = L_shl( x[i], exp0 ); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + if ( 0 == exp0 ) + { + i = lg; + } +#endif /* OPT_STEREO_32KBPS_V1 */ } } + void scale_sig32_r( Word32 x[], /* i/o: signal to scale Qx */ const Word16 lg, /* i : size of x[] Q0 */ @@ -322,6 +329,12 @@ void scale_sig32_r( /* saturation can occur here */ x[i] = L_shl_r( x[i], exp0 ); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + if ( 0 == exp0 ) + { + i = lg; + } +#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index fbe0f0d6d..0033e2c9e 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -84,7 +84,9 @@ void preecho_sb_fx( UWord16 tmp_u16; Word32 mean_prev_hb_fx_loc, mean_prev_nc_fx_loc, mean_prev_fx_loc; /* */ Word16 q16p1, qmemp1, qtmp; - +#ifdef OPT_STEREO_32KBPS_V1 + Word16 shift_q = sub( 15, q_sig32 ); +#endif /* OPT_STEREO_32KBPS_V1 */ q16p1 = add( q_sig16, 1 ); qmemp1 = q16p1; @@ -137,6 +139,18 @@ void preecho_sb_fx( /* len3xLp20 = framelength/2-(short)((float)framelength*N_ZERO_MDCT/FRAME_SIZE_MS); in float*/ fxptr1 = imdct_mem_fx; +#ifdef OPT_STEREO_32KBPS_V1 + FOR( i = 0; i < len3xLp20; i++ ) + { + *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[len3xLp20 - 1 - i], shift_q ) ) ); /*Q-1*/ + move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ + } + FOR( i = 0; i < framelength >> 1; i++ ) + { + *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], shift_q ) ) ); /*Q-1*/ + move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ + } +#else /* OPT_STEREO_32KBPS_V1 */ fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; /*q_sig32*/ FOR( i = 0; i < len3xLp20; i++ ) { @@ -148,7 +162,10 @@ void preecho_sb_fx( *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], sub( 15, q_sig32 ) ) ) ); /*Q-1*/ move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } +#endif /* OPT_STEREO_32KBPS_V1 */ + qmemp1 = 0; /*already in q-1*/ + move16(); subframelength = shr( framelength, LOG2_NUMSF ); /*Q0*/ subsubframelength = shr( subframelength, log2_num_subsubframes ); /*Q0*/ @@ -391,6 +408,17 @@ void preecho_sb_fx( move16(); FOR( i = 1; i <= NUMSF; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + max_es_hb_fx = L_max( max_es_hb_fx, es_mdct_hb_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ + + max_es_fx = L_max( max_es_fx, es_mdct_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ + + if ( GE_32( es_mdct_fx[i], max_es_fx ) ) /* '=' to handle the first window*/ + { + maxind = i; + move16(); + } +#else /* OPT_STEREO_32KBPS_V1 */ IF( GE_32( es_mdct_hb_fx[i], max_es_hb_fx ) ) /* '=' to handle the first window*/ { max_es_hb_fx = L_add( es_mdct_hb_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */ @@ -402,6 +430,7 @@ void preecho_sb_fx( maxind = i; move16(); } +#endif /* OPT_STEREO_32KBPS_V1 */ } cnt2 = cnt5 = 0; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 6e56bc154..5c16bc3e9 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1908,7 +1908,11 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag } - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) +#endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); move16(); #ifndef MSAN_FIX @@ -1989,7 +1993,11 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); #ifndef MSAN_FIX @@ -2096,7 +2104,11 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index c8985d7cd..b3bddae59 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1450,7 +1450,11 @@ void stereo_cna_update_params_fx( { IF( EQ_16( hCPE->nchan_out, 1 ) ) { +#ifdef OPT_STEREO_32KBPS_V1 + c_LR_fx = MAX_32; +#else /* OPT_STEREO_32KBPS_V1 */ c_LR_fx = MAX_WORD16; +#endif /* OPT_STEREO_32KBPS_V1 */ move32(); c_ILD_fx = 0; move32(); @@ -1512,8 +1516,12 @@ void stereo_cna_update_params_fx( dotLR_fx = Mpy_32_32( W_extract_l( dotLR_fx ), energy_xy_fx ); /* dotLR_fx_q + ((31 - temp_res_q) - 31)) */ dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) ); dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) ); /* Q31 */ - /* estimate L/R correlation factor and ILD in time domain */ + /* estimate L/R correlation factor and ILD in time domain */ +#ifdef OPT_STEREO_32KBPS_V1 + c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ +#else /* OPT_STEREO_32KBPS_V1 */ c_LR_fx = extract_h( W_extract_l( dotLR_fx ) ); /* Q15 */ +#endif /* OPT_STEREO_32KBPS_V1 */ temp_res_q = 0; move16(); @@ -1552,15 +1560,24 @@ void stereo_cna_update_params_fx( /* update of long-term ILD and LR correlation factors for stereo CNA */ IF( !hFdCngDec->first_cna_noise_updated ) { +#ifdef OPT_STEREO_32KBPS_V1 + hFdCngDec->cna_LR_LT_fx = extract_h( c_LR_fx ); +#else /* OPT_STEREO_32KBPS_V1 */ hFdCngDec->cna_LR_LT_fx = extract_l( c_LR_fx ); +#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_l( c_ILD_fx ); move16(); } ELSE { +#ifdef OPT_STEREO_32KBPS_V1 + hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), + Mpy_32_32( ONE_IN_Q31 - STEREO_CNA_LR_CORR_LT_FILT_FX, c_LR_fx ) ) ); /* Q31 */ +#else /* OPT_STEREO_32KBPS_V1 */ hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), extract_l( c_LR_fx ) ) ) ); /* Q31 */ +#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_ILD_LT_FILT_FX, hFdCngDec->cna_ILD_LT_fx ), diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index ca4cfdb69..7c1c892aa 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1519,8 +1519,10 @@ void stereo_dft_dec_fx( HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; Word16 *cna_seed = &( hFdCngCom->seed ); Word32 DFT_W, DFT_Y; +#ifndef OPT_STEREO_32KBPS_V1 Word16 q_samp_ratio = Q15; move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */ @@ -1528,8 +1530,12 @@ void stereo_dft_dec_fx( * Initialization *-----------------------------------------------------------------*/ +#ifdef OPT_STEREO_32KBPS_V1 + samp_ratio = divide3232( st0->sr_core, st0->output_Fs ); // Q15 +#else /* OPT_STEREO_32KBPS_V1 */ samp_ratio = (Word16) BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); +#endif /* OPT_STEREO_32KBPS_V1 */ stop = shr( STEREO_DFT32MS_N_32k, 1 ); @@ -2102,10 +2108,17 @@ void stereo_dft_dec_fx( /*Nyquist Freq.*/ IF( EQ_16( hStereoDft->band_limits[b], shr( hStereoDft->NFFT, 1 ) ) ) { +#ifdef OPT_STEREO_32KBPS_V1 + DFT_L[1] = Madd_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ + move32(); + DFT_R[1] = Msub_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ DFT_L[1] = L_add( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ move32(); DFT_R[1] = L_sub( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ DFT_L[1] = Mpy_32_16_1( DFT_L[1], INV_SQRT2_FX_Q15 ); /* qDFT */ move32(); DFT_R[1] = Mpy_32_16_1( DFT_R[1], INV_SQRT2_FX_Q15 ); /* qDFT */ @@ -2238,27 +2251,52 @@ void stereo_dft_dec_fx( q_cna_level = sub( Q31, add( q_cna_level, Q16 ) ); /* generate comfort noise from gaussian noise and add to the decoded DFT spectrum */ +#ifdef OPT_STEREO_32KBPS_V1 + Word16 shift = sub( q_cna_level, hStereoDft->q_dft ); +#endif /* OPT_STEREO_32KBPS_V1 */ N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */ +#ifdef OPT_STEREO_32KBPS_V1 + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ +#else /* OPT_STEREO_32KBPS_V1 */ + l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ +#endif /* OPT_STEREO_32KBPS_V1 */ + DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */ move32(); +#ifdef OPT_STEREO_32KBPS_V1 + l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ +#else /* OPT_STEREO_32KBPS_V1 */ l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ +#endif /* OPT_STEREO_32KBPS_V1 */ move32(); N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ +#ifdef OPT_STEREO_32KBPS_V1 + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ + move32(); + l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ + l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ + DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ move32(); l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } } @@ -2346,8 +2384,12 @@ static void stereo_dft_compute_td_stefi_params_fx( return; } +#ifdef OPT_STEREO_32KBPS_V1 + bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); +#else /* OPT_STEREO_32KBPS_V1 */ bin0 = extract_l( L_shr_r( Mpy_32_16_1( (Word32) hStereoDft->NFFT, samp_ratio ), 1 ) ); /* Q0 */ bin0 = shl( bin0, Q3 ); +#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; /* Q0 */ move16(); @@ -2512,14 +2554,18 @@ static void stereo_dft_dequantize_ipd_fx( *-------------------------------------------------------------------------*/ void stereo_dft_generate_res_pred_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word16 samp_ratio, /* i : sampling ratio Q13*/ - Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ - Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ - Word32 *pPredGain, /* i : residual prediction gains Q31*/ - const Word16 k, /* i : subframe index Q0*/ - Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ - Word16 *stop, /* o : last FD stereo filling bin Q0*/ - const Word16 bfi /* i : BFI flag Q0*/ +#ifdef OPT_STEREO_32KBPS_V1 + const Word16 samp_ratio, /* i : sampling ratio Q15*/ +#else /* OPT_STEREO_32KBPS_V1 */ + const Word16 samp_ratio, /* i : sampling ratio Q13*/ +#endif /* OPT_STEREO_32KBPS_V1 */ + Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ + Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ + Word32 *pPredGain, /* i : residual prediction gains Q31*/ + const Word16 k, /* i : subframe index Q0*/ + Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ + Word16 *stop, /* o : last FD stereo filling bin Q0*/ + const Word16 bfi /* i : BFI flag Q0*/ ) { /* general variables */ @@ -2529,7 +2575,10 @@ void stereo_dft_generate_res_pred_fx( Word16 lb_stefi_start_band; /* variables for enhanced stereo filling */ - Word16 norm_fac, q_norm_fac, lim_norm_fac; + Word16 norm_fac, q_norm_fac; +#ifndef OPT_STEREO_32KBPS_V1 + Word16 lim_norm_fac; +#endif /* OPT_STEREO_32KBPS_V1 */ Word16 q_sqrt; Word16 alpha; // gain_limit; @@ -2543,8 +2592,12 @@ void stereo_dft_generate_res_pred_fx( Word32 pred_gain_avg; Word32 g2; Word16 nbands_respred; +#ifdef OPT_STEREO_32KBPS_V1 + Word16 q_new, diff; +#else /* OPT_STEREO_32KBPS_V1 */ q_norm_fac = 0; move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ push_wmops( "gen_respred" ); /* smoothing and limiting parameters */ @@ -2566,8 +2619,12 @@ void stereo_dft_generate_res_pred_fx( /* In ACELP mode the downmix signal is not available in bandwidth extension area. * * Therefore, the downmix energy in the corresponding subbands is estimated. */ +#ifdef OPT_STEREO_32KBPS_V1 + bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); +#else /* OPT_STEREO_32KBPS_V1 */ bin0 = (Word16) ( L_shr( L_add( L_mult0( hStereoDft->NFFT, samp_ratio ), ONE_IN_Q12 ), Q12 + 1 ) ); /* Q0 */ move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; move16(); @@ -2611,37 +2668,78 @@ void stereo_dft_generate_res_pred_fx( /* calculate band energies (low band only in case of ACELP) */ FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), + pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ + rev_nrg_64bit = W_mac_32_32( W_mac_32_32( rev_nrg_64bit, ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), + ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ +#else /* OPT_STEREO_32KBPS_V1 */ dmx_nrg_64bit = W_add( dmx_nrg_64bit, W_add( W_mult0_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), W_mult0_32_32( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ rev_nrg_64bit = W_add( rev_nrg_64bit, W_add( W_mult0_32_32( ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), W_mult0_32_32( ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ +#endif /* OPT_STEREO_32KBPS_V1 */ } + +#ifdef OPT_STEREO_32KBPS_V1 + q_new = add( shl( hStereoDft->q_dft, 1 ), 1 ); + q_shift = W_norm( dmx_nrg_64bit ); + dmx_nrg = W_shl_sat_l( dmx_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) + dmx_nrg_q = add( q_new, sub( q_shift, 32 ) ); + q_shift = W_norm( rev_nrg_64bit ); + rev_nrg = W_shl_sat_l( rev_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) + rev_nrg_q = add( q_new, sub( q_shift, 32 ) ); + move16(); +#else /* OPT_STEREO_32KBPS_V1 */ q_shift = W_norm( dmx_nrg_64bit ); dmx_nrg = W_extract_l( W_shl( dmx_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) dmx_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); q_shift = W_norm( rev_nrg_64bit ); rev_nrg = W_extract_l( W_shl( rev_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) rev_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); +#endif /* OPT_STEREO_32KBPS_V1 */ /* Reach a common Q for dmx_nrg and rev_nrg */ q_com = s_min( dmx_nrg_q, rev_nrg_q ); dmx_nrg = L_shl( dmx_nrg, sub( q_com, dmx_nrg_q ) ); /* q_com */ rev_nrg = L_shl( rev_nrg, sub( q_com, rev_nrg_q ) ); /* q_com */ + +#ifdef OPT_STEREO_32KBPS_V1 + diff = sub( hStereoDft->q_smoothed_nrg, q_com ); + IF( diff < 0 ) +#else /* OPT_STEREO_32KBPS_V1 */ IF( LT_16( hStereoDft->q_smoothed_nrg, q_com ) ) +#endif /* OPT_STEREO_32KBPS_V1 */ { +#ifdef OPT_STEREO_32KBPS_V1 + rev_nrg = L_shl( rev_nrg, shl( diff, 1 ) ); + dmx_nrg = L_shl( dmx_nrg, shl( diff, 1 ) ); +#else /* OPT_STEREO_32KBPS_V1 */ rev_nrg = L_shr( rev_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); dmx_nrg = L_shr( dmx_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); +#endif /* OPT_STEREO_32KBPS_V1 */ q_com = hStereoDft->q_smoothed_nrg; move16(); } +#ifdef OPT_STEREO_32KBPS_V1 + ELSE +#else /* OPT_STEREO_32KBPS_V1 */ ELSE IF( GT_16( hStereoDft->q_smoothed_nrg, q_com ) ) +#endif /* OPT_STEREO_32KBPS_V1 */ { +#ifdef OPT_STEREO_32KBPS_V1 + hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ + move32(); + hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ q_smoothed_nrg_local[b] = q_com; move16(); } @@ -2651,9 +2749,38 @@ void stereo_dft_generate_res_pred_fx( hStereoDft->smooth_dmx_nrg_fx[b] = Madd_32_16( Mpy_32_16_1( hStereoDft->smooth_dmx_nrg_fx[b], alpha ), dmx_nrg, sub( (Word16) ( 0x7FFF ), alpha ) ); /* hStereoDft->q_smoothed_nrg */ move32(); +#ifdef OPT_STEREO_32KBPS_V1 + // Compute norm_fac in Q14 + norm_fac = MAX_16; + move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ /* normalization factor */ IF( hStereoDft->smooth_res_nrg_fx[b] != 0 ) { +#ifdef OPT_STEREO_32KBPS_V1 + norm_fac = 0; + move16(); + IF( hStereoDft->smooth_dmx_nrg_fx[b] != 0 ) + { + Word16 quo, quo_e; + Word32 prod; + + norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */ + norm_fac = Sqrt16( norm_fac, &q_norm_fac ); + + quo = BASOP_Util_Divide1616_Scale( 32767, norm_fac, &quo_e ); /* q_norm_fac */ + quo_e = sub( quo_e, q_norm_fac ); + quo = shl_sat( quo, sub( quo_e, 1 ) ); // Q14 + quo = s_max( 13107 /*0.8 in Q14 */, quo ); + quo = s_min( quo, 20480 /* 1.25 in Q14*/ ); + + prod = L_mult( norm_fac, quo ); // exp:q_norm_fac+1 + // Bring to Q30 + prod = L_shl_sat( prod, q_norm_fac ); + + norm_fac = extract_h( prod ); + } +#else /* OPT_STEREO_32KBPS_V1 */ norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */ norm_fac = Sqrt16( norm_fac, &q_norm_fac ); IF( norm_fac != 0 ) @@ -2709,7 +2836,9 @@ void stereo_dft_generate_res_pred_fx( } } } +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifndef OPT_STEREO_32KBPS_V1 ELSE { norm_fac = MAX_16; @@ -2717,13 +2846,21 @@ void stereo_dft_generate_res_pred_fx( q_norm_fac = Q1; move16(); } +#endif /* OPT_STEREO_32KBPS_V1 */ FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */ + move32(); + DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), 1 ); /* q_dft */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), q_norm_fac ); /* q_dft */ move32(); DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), q_norm_fac ); /* q_dft */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index c6466183b..c8a59cd6a 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -2343,15 +2343,20 @@ static Word32 ncross_corr_self_fx( { Word64 c_c_fx; Word32 c_c_fx_return; + Word64 energy_x_fx, energy_y_fx; +#ifndef OPT_STEREO_32KBPS_V1 Word16 c_c_fx_q; - Word64 energy_xy_fx, energy_x_fx, energy_y_fx; + Word64 energy_xy_fx; +#endif /* OPT_STEREO_32KBPS_V1 */ UWord16 j; Word32 *signal_a_fx, *signal_b_fx; Word32 temp_x, temp_y; Word16 headroom_left_x, headroom_left_y; +#ifndef OPT_STEREO_32KBPS_V1 Word16 x_inv_q, y_inv_q; Word16 x_q, y_q; Word16 res_q; +#endif /* OPT_STEREO_32KBPS_V1 */ c_c_fx = 0; move64(); energy_x_fx = 0; @@ -2362,13 +2367,43 @@ static Word32 ncross_corr_self_fx( signal_b_fx = &signal_fx[y]; /* Q11 */ FOR( j = 0; j < corr_len; j += subsampling ) { +#ifdef OPT_STEREO_32KBPS_V1 + c_c_fx = W_mac_32_32( c_c_fx, signal_a_fx[j], signal_b_fx[j] ); /* 2 * Q11 + 1*/ + energy_x_fx = W_mac_32_32( energy_x_fx, signal_a_fx[j], signal_a_fx[j] ); /* 2 * Q11+ 1 */ + energy_y_fx = W_mac_32_32( energy_y_fx, signal_b_fx[j], signal_b_fx[j] ); /* 2 * Q11+ 1 */ +#else /* OPT_STEREO_32KBPS_V1 */ c_c_fx = W_add( c_c_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ energy_x_fx = W_add( energy_x_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_a_fx[j] ) ) ); /* 2 * Q11 */ energy_y_fx = W_add( energy_y_fx, W_mult0_32_32( ( signal_b_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ +#endif /* OPT_STEREO_32KBPS_V1 */ } headroom_left_x = W_norm( energy_x_fx ); headroom_left_y = W_norm( energy_y_fx ); +#ifdef OPT_STEREO_32KBPS_V1 + temp_x = W_extract_h( W_shl( energy_x_fx, headroom_left_x ) ); // Q23 + headroom_left_x -32 + temp_y = W_extract_h( W_shl( energy_y_fx, headroom_left_y ) ); // Q23 + headroom_left_y -32 + Word64 prod = W_mult0_32_32( temp_x, temp_y ); // Q(headroom_left_x + headroom_left_y - 18) + Word16 q_prod = W_norm( prod ); + Word32 energy = W_extract_h( W_shl( prod, q_prod ) ); // Q(headroom_left_x + headroom_left_y + q_prod - 18) - 32 + q_prod = sub( 81, add( add( headroom_left_x, headroom_left_y ), q_prod ) ); + energy = Sqrt32( energy, &q_prod ); + + IF( LT_32( energy, L_shl_sat( 1, sub( 31, q_prod ) ) ) ) + { + c_c_fx_return = W_shl_sat_l( c_c_fx, 31 - ( 2 * OUTPUT_Q + 1 ) ); // Q31 + } + ELSE + { + // Maximize c_c_fx + Word16 q_cc = W_norm( c_c_fx ); + Word32 num = W_extract_h( W_shl( c_c_fx, q_cc ) ); // Q(23 + q_cc - 32) -> e(40 - q_cc) + Word16 quo_e; + num = BASOP_Util_Divide3232_Scale_cadence( num, energy, &quo_e ); + quo_e = add( sub( sub( 40, q_cc ), q_prod ), quo_e ); + c_c_fx_return = L_shl_sat( num, quo_e ); // Q31 + } +#else /* OPT_STEREO_32KBPS_V1 */ IF( LT_16( headroom_left_x, 32 ) ) { energy_x_fx = W_shr( energy_x_fx, sub( 32, headroom_left_x ) ); /* 2 * Q11 - (32 -headroom_left_x) */ @@ -2440,6 +2475,7 @@ static Word32 ncross_corr_self_fx( c_c_fx_return = W_extract_l( c_c_fx ); /* Q31 */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ return c_c_fx_return; } diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index c975da8d6..e31c9f6bc 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -384,7 +384,7 @@ void tdm_upmix_plain_fx( const Word32 PCh_2_L_fx[], /* i : primary channel Qx*/ const Word32 SCh_2_R_fx[], /* i : secondary channel Qx*/ const Word32 LR_ratio_fx, /* i : mixing ratio Q31*/ - const Word32 inv_den_LR_ratio_fx, /* i : inverse mixing ration Q31*/ + const Word32 inv_den_LR_ratio_fx, /* i : inverse mixing ration Q30*/ const Word16 start_index, /* i : start index Q0*/ const Word16 end_index, /* i : end index Q0*/ const Word16 plus_minus_flag /* i : plus/minus flag Q0*/ @@ -396,16 +396,37 @@ void tdm_upmix_plain_fx( { FOR( i = start_index; i < end_index; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + Word32 temp_left = Madd_32_32( SCh_2_R_fx[i], L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Left_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_left, inv_den_LR_ratio_fx ), -30 ); /* Qx */ + move32(); + Word32 temp_right = Msub_32_32( PCh_2_L_fx[i], L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx ), -30 ); /* Qx */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Word32 temp_left = L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ move32(); Word32 temp_right = L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] ); /* Qx */ Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } } ELSE { +#ifdef OPT_STEREO_32KBPS_V1 + Word32 inv_den_LR_ratio_fx_neg = L_negate( inv_den_LR_ratio_fx ); + FOR( i = start_index; i < end_index; i++ ) + { + Word32 temp_left = Msub_32_32( SCh_2_R_fx[i], L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Left_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_left, inv_den_LR_ratio_fx_neg ), -30 ); /* Qx */ + move32(); + Word32 temp_right = Msub_32_32( PCh_2_L_fx[i], L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx_neg ), -30 ); /* Qx */ + move32(); + } +#else /* OPT_STEREO_32KBPS_V1 */ FOR( i = start_index; i < end_index; i++ ) { Word32 temp_left = L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ @@ -415,6 +436,7 @@ void tdm_upmix_plain_fx( Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ move32(); } +#endif /* OPT_STEREO_32KBPS_V1 */ } return; -- GitLab From bb55862d3bbd4d106b2f10e9ff6deb35595b32f1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 20:41:36 +0530 Subject: [PATCH 241/329] Duplicate lib_dec files cleanup --- Workspace_msvc/lib_dec.vcxproj | 14 - Workspace_msvc/lib_dec.vcxproj.filters | 42 - lib_dec/FEC_HQ_core.c | 136 -- lib_dec/FEC_HQ_core_fx.c | 92 + lib_dec/ari_dec.c | 338 ---- lib_dec/ari_dec_fx.c | 289 +++ lib_dec/arith_coder_dec.c | 250 --- lib_dec/arith_coder_dec_fx.c | 208 ++ lib_dec/bass_psfilter.c | 317 --- lib_dec/bass_psfilter_fx.c | 244 +++ lib_dec/core_dec_init.c | 84 - lib_dec/core_dec_init_fx.c | 26 + lib_dec/core_switching_dec.c | 1076 ---------- lib_dec/core_switching_dec_fx.c | 1009 ++++++++++ lib_dec/dec_prm.c | 328 ---- lib_dec/dec_prm_fx.c | 270 +++ lib_dec/dec_tcx.c | 508 ----- lib_dec/dec_tcx_fx.c | 447 +++++ lib_dec/fd_cng_dec.c | 1393 ------------- lib_dec/fd_cng_dec_fx.c | 1280 ++++++++++++ lib_dec/init_dec.c | 76 - lib_dec/init_dec_fx.c | 15 + lib_dec/ivas_mc_param_dec.c | 33 + lib_dec/ivas_mc_param_dec_fx.c | 34 - lib_dec/swb_bwe_dec.c | 681 ------- lib_dec/swb_bwe_dec_fx.c | 369 ++++ lib_dec/swb_tbe_dec.c | 2478 ------------------------ lib_dec/swb_tbe_dec_fx.c | 2034 ++++++++++++++++++- lib_dec/tonalMDCTconcealment.c | 436 ----- lib_dec/tonalMDCTconcealment_fx.c | 391 ++++ 30 files changed, 6701 insertions(+), 8197 deletions(-) delete mode 100644 lib_dec/FEC_HQ_core.c delete mode 100644 lib_dec/ari_dec.c delete mode 100644 lib_dec/arith_coder_dec.c delete mode 100644 lib_dec/bass_psfilter.c delete mode 100644 lib_dec/core_dec_init.c delete mode 100644 lib_dec/core_switching_dec.c delete mode 100644 lib_dec/dec_prm.c delete mode 100644 lib_dec/dec_tcx.c delete mode 100644 lib_dec/fd_cng_dec.c delete mode 100644 lib_dec/init_dec.c delete mode 100644 lib_dec/ivas_mc_param_dec_fx.c delete mode 100644 lib_dec/swb_bwe_dec.c delete mode 100644 lib_dec/swb_tbe_dec.c delete mode 100644 lib_dec/tonalMDCTconcealment.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 3d447fe21..b3a847791 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -145,22 +145,17 @@ - - - false - - @@ -176,9 +171,7 @@ - - @@ -191,12 +184,10 @@ - - @@ -216,7 +207,6 @@ - @@ -246,7 +236,6 @@ - @@ -310,18 +299,15 @@ - - - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index cc7594415..c4e148b89 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -8,9 +8,6 @@ decoder_evs_c - - decoder_evs_c - decoder_evs_c @@ -137,9 +134,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -275,36 +269,24 @@ decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c @@ -320,15 +302,9 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -365,9 +341,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -380,9 +353,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -437,9 +407,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -515,15 +482,9 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -542,9 +503,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c deleted file mode 100644 index 6a119b365..000000000 --- a/lib_dec/FEC_HQ_core.c +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_dec.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - - -void save_synthesis_hq_fec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 output_fx[], /* i : decoded synthesis */ - const Word16 output_frame, /* i : decoded synthesis */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ -) -{ - Word16 post_hq_delay; - - SWITCH( st->element_mode ) - { - case EVS_MONO: - post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS ); - BREAK; - case IVAS_SCE: - post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - BREAK; - case IVAS_CPE_DFT: - test(); - IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) - { - post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - } - ELSE - { - post_hq_delay = 0; - move16(); - } - BREAK; - default: - post_hq_delay = 0; - move16(); - BREAK; - } - - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) - { - Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); - FOR( Word16 i = 0; i < output_frame; i++ ) - { - st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16 - move16(); - } - - IF( st->element_mode == EVS_MONO ) - { - /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill - this buffer are not available for all cases, the impact on the output is limited */ - - set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay ); - IF( GE_16( output_frame, L_FRAME16k ) ) - { - Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - } - ELSE - { - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - - IF( st->core != ACELP_CORE ) - { - IF( GE_16( output_frame, L_FRAME16k ) ) - { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - ELSE - { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - } - } - ELSE - { - IF( st->core != ACELP_CORE ) - { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay ); - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - } - } - return; -} diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index f88927ee5..09bc652be 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -1961,6 +1961,98 @@ static void Next_good_after_burst_erasures_fx( return; } + +void save_synthesis_hq_fec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 output_fx[], /* i : decoded synthesis */ + const Word16 output_frame, /* i : decoded synthesis */ + CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ +) +{ + Word16 post_hq_delay; + + SWITCH( st->element_mode ) + { + case EVS_MONO: + post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS ); + BREAK; + case IVAS_SCE: + post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); + BREAK; + case IVAS_CPE_DFT: + test(); + IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) + { + post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); + } + ELSE + { + post_hq_delay = 0; + move16(); + } + BREAK; + default: + post_hq_delay = 0; + move16(); + BREAK; + } + + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) + { + Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); + FOR( Word16 i = 0; i < output_frame; i++ ) + { + st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16 + move16(); + } + + IF( st->element_mode == EVS_MONO ) + { + /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill + this buffer are not available for all cases, the impact on the output is limited */ + + set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay ); + IF( GE_16( output_frame, L_FRAME16k ) ) + { + Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + } + ELSE + { + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + + IF( st->core != ACELP_CORE ) + { + IF( GE_16( output_frame, L_FRAME16k ) ) + { + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + ELSE + { + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + } + } + ELSE + { + IF( st->core != ACELP_CORE ) + { + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + } + } + return; +} + + #ifdef ADD_IVAS_HQ_CODE_FEC /*-------------------------------------------------------------------------- * save_synthesis_hq_fec() diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c deleted file mode 100644 index b45cb5d9c..000000000 --- a/lib_dec/ari_dec.c +++ /dev/null @@ -1,338 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "stat_com.h" -#include "basop_util.h" -#include "wmc_auto.h" - - -/*--------------------------------------------------------------- - * Ari decode 14 bits routines - -------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - * ari_start_decoding_14bits_ivas() - * - * Start ArCo decoding - *-------------------------------------------------------------*/ - - -Word16 ari_start_decoding_14bits_prm_ivas_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ) -{ - Word32 val; - Word16 i; - const Word16 *p; - - val = 0; - move32(); - p = ptr + bp; - - FOR( i = 0; i < cbitsnew; i++ ) - { - val = L_or( L_shl( val, 1 ), *( p + i ) ); - } - s->low = 0; - move32(); - s->high = ari_q4new; - move32(); - s->value = val; - move32(); - - return add( bp, i ); -} - - -Word16 ari_decode_14bits_pow_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - UWord16 base ) -{ - UWord16 symbol; - Word32 low, high; - UWord32 range, value, cum; - Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */ - Word16 lowlim, highlim, testval; - Word16 k; - - highlim = 0; - low = s->low; - high = L_add( s->high, 1 ); - value = s->value; - lowlim = 0; - symbol = 0; - move16(); - move32(); - move32(); - move16(); - move16(); - - range = (UWord32) W_sub( high, low ); - move32(); - - /* the value read from bitstream */ - assert( value >= (UWord32) low ); - cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); - move32(); - - /* search for the interval where "cum" fits */ - IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */ - { - pows[0] = testval = base; - move16(); - move16(); - /* increase exponent until it is smaller than "cum" */ - FOR( k = 1; k < 12; k++ ) - { - highlim = testval; - move16(); - pows[k] = mult_r( pows[k - 1], pows[k - 1] ); - move16(); - testval = mult_r( pows[k], base ); - IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ - { - lowlim = testval; - move16(); - k = sub( k, 1 ); - symbol = (UWord16) L_shl( 1, k ); - BREAK; - } - } - assert( k < 12 ); /* maximum 2^10-1*/ - /* narrow the range down */ - FOR( k--; k > 0; k-- ) - { - testval = mult_r( highlim, pows[k] ); - IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) - { - lowlim = testval; - move16(); - symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) ); - } - ELSE - { - highlim = testval; - move16(); - } - } - highlim = shr( highlim, 1 ); - lowlim = shr( lowlim, 1 ); - } - ELSE /* trivial case, above pow-1, that is, first symbol */ - { - symbol = 0; - lowlim = extract_l( L_shr( base, 1 ) ); - highlim = 16384; - move16(); - move16(); - } - - - high = L_add( low, mul_sbc_14bits( range, highlim ) ); - - low = L_add( low, mul_sbc_14bits( range, lowlim ) ); - - /*ptr init for ptr*/ - FOR( ; bp < bits; ) - { - IF( GT_32( high, ari_q2new ) ) - { - IF( GE_32( low, ari_q2new ) ) - { - value = (UWord32) W_sub( value, ari_q2new ); - low = L_sub( low, ari_q2new ); - high = L_sub( high, ari_q2new ); - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) - { - value = (UWord32) W_sub( value, ari_q1new ); - low = L_sub( low, ari_q1new ); - high = L_sub( high, ari_q1new ); - } - ELSE - { - BREAK; - } - } - } - low = L_add( low, low ); - high = L_add( high, high ); - - assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); - - value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); - } - - test(); - test(); - test(); - IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) ) - { - /* This should not happen except of bit errors. */ - s->high = s->low = 0; - move32(); - move32(); - *res = 0; - move16(); - return -1; - } - - s->low = low; - s->high = L_sub( high, 1 ); - s->value = value; - move32(); - move32(); - move32(); - - *res = symbol; - move16(); - return bp; -} - -Word16 ari_decode_14bits_sign_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ) -{ - Word16 symbol; - Word32 low, high; - UWord32 range, value, cum; - - low = s->low; - high = L_add( s->high, 1 ); - value = s->value; - move32(); - move32(); - - range = (UWord32) W_sub( high, low ); - - IF( LT_16( bp, bits ) ) - { - assert( value >= (UWord32) low ); - cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); - IF( GT_64( W_shl( range, 13 ), cum ) ) - { - symbol = 2; - move16(); - high = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); - } - ELSE - { - symbol = 1; - move16(); - low = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); - } - - /*ptr init for ptr*/ - FOR( ; bp < bits; ) - { - IF( GT_32( high, ari_q2new ) ) - { - IF( GE_32( low, ari_q2new ) ) - { - value = (UWord32) W_sub( value, ari_q2new ); - low = L_sub( low, ari_q2new ); - high = L_sub( high, ari_q2new ); - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) - { - value = (UWord32) W_sub( value, ari_q1new ); - low = L_sub( low, ari_q1new ); - high = L_sub( high, ari_q1new ); - } - ELSE - { - BREAK; - } - } - } - low = L_add( low, low ); - high = L_add( high, high ); - - assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); - - value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); - } - } - ELSE - { - cum = (UWord32) W_sub( value, low ); - range = (UWord32) W_shr( range, 1 ); - IF( GT_64( range, cum ) ) - { - symbol = 2; - move16(); - high = L_add( low, range ); - } - ELSE - { - symbol = 1; - move16(); - low = L_add( low, range ); - } - } - - s->low = low; - s->high = L_sub( high, 1 ); - s->value = value; - move32(); - move32(); - move32(); - - *res = symbol; - move16(); - - return bp; -} diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index 3681568f2..524f9d121 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -551,3 +551,292 @@ Word16 ari_decode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, Word16 *r { return ari_decode_14bits_notbl_fx( ptr, bp, bits, res, s, 0, ari_lookup_sign_fx ); } + +/*--------------------------------------------------------------- + * ari_start_decoding_14bits_ivas() + * + * Start ArCo decoding + *-------------------------------------------------------------*/ + + +Word16 ari_start_decoding_14bits_prm_ivas_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ) +{ + Word32 val; + Word16 i; + const Word16 *p; + + val = 0; + move32(); + p = ptr + bp; + + FOR( i = 0; i < cbitsnew; i++ ) + { + val = L_or( L_shl( val, 1 ), *( p + i ) ); + } + s->low = 0; + move32(); + s->high = ari_q4new; + move32(); + s->value = val; + move32(); + + return add( bp, i ); +} + + +Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ) +{ + UWord16 symbol; + Word32 low, high; + UWord32 range, value, cum; + Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */ + Word16 lowlim, highlim, testval; + Word16 k; + + highlim = 0; + low = s->low; + high = L_add( s->high, 1 ); + value = s->value; + lowlim = 0; + symbol = 0; + move16(); + move32(); + move32(); + move16(); + move16(); + + range = (UWord32) W_sub( high, low ); + move32(); + + /* the value read from bitstream */ + assert( value >= (UWord32) low ); + cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); + move32(); + + /* search for the interval where "cum" fits */ + IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */ + { + pows[0] = testval = base; + move16(); + move16(); + /* increase exponent until it is smaller than "cum" */ + FOR( k = 1; k < 12; k++ ) + { + highlim = testval; + move16(); + pows[k] = mult_r( pows[k - 1], pows[k - 1] ); + move16(); + testval = mult_r( pows[k], base ); + IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ + { + lowlim = testval; + move16(); + k = sub( k, 1 ); + symbol = (UWord16) L_shl( 1, k ); + BREAK; + } + } + assert( k < 12 ); /* maximum 2^10-1*/ + /* narrow the range down */ + FOR( k--; k > 0; k-- ) + { + testval = mult_r( highlim, pows[k] ); + IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) + { + lowlim = testval; + move16(); + symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) ); + } + ELSE + { + highlim = testval; + move16(); + } + } + highlim = shr( highlim, 1 ); + lowlim = shr( lowlim, 1 ); + } + ELSE /* trivial case, above pow-1, that is, first symbol */ + { + symbol = 0; + lowlim = extract_l( L_shr( base, 1 ) ); + highlim = 16384; + move16(); + move16(); + } + + + high = L_add( low, mul_sbc_14bits( range, highlim ) ); + + low = L_add( low, mul_sbc_14bits( range, lowlim ) ); + + /*ptr init for ptr*/ + FOR( ; bp < bits; ) + { + IF( GT_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = (UWord32) W_sub( value, ari_q2new ); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + value = (UWord32) W_sub( value, ari_q1new ); + low = L_sub( low, ari_q1new ); + high = L_sub( high, ari_q1new ); + } + ELSE + { + BREAK; + } + } + } + low = L_add( low, low ); + high = L_add( high, high ); + + assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); + + value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); + } + + test(); + test(); + test(); + IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) ) + { + /* This should not happen except of bit errors. */ + s->high = s->low = 0; + move32(); + move32(); + *res = 0; + move16(); + return -1; + } + + s->low = low; + s->high = L_sub( high, 1 ); + s->value = value; + move32(); + move32(); + move32(); + + *res = symbol; + move16(); + return bp; +} + +Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ) +{ + Word16 symbol; + Word32 low, high; + UWord32 range, value, cum; + + low = s->low; + high = L_add( s->high, 1 ); + value = s->value; + move32(); + move32(); + + range = (UWord32) W_sub( high, low ); + + IF( LT_16( bp, bits ) ) + { + assert( value >= (UWord32) low ); + cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); + IF( GT_64( W_shl( range, 13 ), cum ) ) + { + symbol = 2; + move16(); + high = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); + } + ELSE + { + symbol = 1; + move16(); + low = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); + } + + /*ptr init for ptr*/ + FOR( ; bp < bits; ) + { + IF( GT_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = (UWord32) W_sub( value, ari_q2new ); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + value = (UWord32) W_sub( value, ari_q1new ); + low = L_sub( low, ari_q1new ); + high = L_sub( high, ari_q1new ); + } + ELSE + { + BREAK; + } + } + } + low = L_add( low, low ); + high = L_add( high, high ); + + assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); + + value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); + } + } + ELSE + { + cum = (UWord32) W_sub( value, low ); + range = (UWord32) W_shr( range, 1 ); + IF( GT_64( range, cum ) ) + { + symbol = 2; + move16(); + high = L_add( low, range ); + } + ELSE + { + symbol = 1; + move16(); + low = L_add( low, range ); + } + } + + s->low = low; + s->high = L_sub( high, 1 ); + s->value = value; + move32(); + move32(); + move32(); + + *res = symbol; + move16(); + + return bp; +} + diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c deleted file mode 100644 index 93bd8877c..000000000 --- a/lib_dec/arith_coder_dec.c +++ /dev/null @@ -1,250 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------* - * tcx_arith_decode() - * - * - *-------------------------------------------------------*/ - -/*! r: number of bits consumed */ - -static Word16 tcx_arith_decode_ivas_fx( - const Word16 L_frame, /* i : number of spectral lines */ - const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */ - Word16 envelope_e, /* i : scaled envelope exponent (Q0) */ - const Word16 target_bits, /* i : target bit budget */ - Word16 prm[], /* i : bitstream parameters */ - Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */ - Word16 *q_spectrum_e /* o : spectrum exponent */ -) -{ - Word16 bp, k, q; - Word16 s; - Tastat as; - UWord16 exp_k; - Word16 tmp; - - bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as ); - - tmp = sub( envelope_e, 1 ); - - FOR( k = 0; k < L_frame; k++ ) - { - IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */ - { - set32_fx( q_spectrum, 0, L_frame ); - return -1; - } - ELSE - { - exp_k = expfp_evs_fx( negate( envelope[k] ), tmp ); - } - - /* decode line magnitude */ - bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k ); - - IF( q ) - { - /* line is non-zero, decode sign */ - bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as ); - q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) ); - move32(); - q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20) - move32(); - } - ELSE - { - /* line is zero, no sign needed */ - q_spectrum[k] = 0; - move32(); - } - - IF( LE_32( as.high, as.low ) ) - { - if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */ - { - bp = -1; - move16(); - } - BREAK; /* no bits left, so exit loop */ - } - } - *q_spectrum_e = SPEC_EXP_DEC; - move16(); - - set32_fx( q_spectrum + k, 0, sub( L_frame, k ) ); - - return bp; -} - -/*-------------------------------------------------------* - * tcx_arith_decode_envelope() - * - * - *-------------------------------------------------------*/ - -void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ -) -{ - Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ - Word16 *envelope; /* scaled envelope (Q15-e) */ - Word16 envelope_e; - Word16 L_spec_core; - TCX_CONFIG_HANDLE hTcxCfg; - TCX_DEC_HANDLE hTcxDec; - Word16 gamma_w, gamma_uw; - Word16 hm_bits; - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || - ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) || - ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) || - ( target_bits <= 0 ) ) - { - /* this could happen in case of bit errors */ - st->BER_detect = 1; - move16(); - L_spec = N_MAX_ARI; - move16(); - *signaling_bits = 0; - move16(); - *arith_bits = 0; - move16(); - set32_fx( q_spectrum, 0, L_frame ); - - return; - } - - hTcxCfg = st->hTcxCfg; - hTcxDec = st->hTcxDec; - *signaling_bits = 0; - move16(); - - assert( hTcxDec->enableTcxLpc ); - gamma_w = MAX16B; - move16(); - gamma_uw = st->inv_gamma; - move16(); - -#define WMC_TOOL_SKIP - tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); -#undef WMC_TOOL_SKIP - - IF( use_hm != 0 ) - { - IF( prm_hm[0] != 0 ) - { - tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits ); - - IF( hm_bits < 0 ) - { - st->BER_detect = 1; - move16(); - *signaling_bits = 0; - move16(); - *arith_bits = 0; - move16(); - set32_fx( q_spectrum, 0, L_frame ); - - return; - } - } - ELSE - { - hm_bits = 1; - move16(); - } - *signaling_bits = add( *signaling_bits, hm_bits ); - move16(); - } - - L_spec_core = L_spec; - move16(); - IF( st->igf ) - { - L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine ); - } - - envelope = (Word16 *) env; - tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); - - *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e ); - move16(); - - /* safety check in case of bit errors */ - IF( *arith_bits < 0 ) - { - st->BER_detect = 1; - move16(); - set32_fx( q_spectrum, 0, L_frame ); - } - - set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) ); - - return; -} diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 4a18f64f9..6df1eb268 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -8,6 +8,9 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" +#include "basop_util.h" +#include "basop_proto_func.h" +#include "prot.h" /* Returns: number of bits consumed */ static Word16 tcx_arith_decode_fx( @@ -213,3 +216,208 @@ void tcx_arith_decode_envelope_fx( set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) ); } + +/*-------------------------------------------------------* + * tcx_arith_decode() + * + * + *-------------------------------------------------------*/ + +/*! r: number of bits consumed */ + +static Word16 tcx_arith_decode_ivas_fx( + const Word16 L_frame, /* i : number of spectral lines */ + const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */ + Word16 envelope_e, /* i : scaled envelope exponent (Q0) */ + const Word16 target_bits, /* i : target bit budget */ + Word16 prm[], /* i : bitstream parameters */ + Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */ + Word16 *q_spectrum_e /* o : spectrum exponent */ +) +{ + Word16 bp, k, q; + Word16 s; + Tastat as; + UWord16 exp_k; + Word16 tmp; + + bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as ); + + tmp = sub( envelope_e, 1 ); + + FOR( k = 0; k < L_frame; k++ ) + { + IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */ + { + set32_fx( q_spectrum, 0, L_frame ); + return -1; + } + ELSE + { + exp_k = expfp_evs_fx( negate( envelope[k] ), tmp ); + } + + /* decode line magnitude */ + bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k ); + + IF( q ) + { + /* line is non-zero, decode sign */ + bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as ); + q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) ); + move32(); + q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20) + move32(); + } + ELSE + { + /* line is zero, no sign needed */ + q_spectrum[k] = 0; + move32(); + } + + IF( LE_32( as.high, as.low ) ) + { + if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */ + { + bp = -1; + move16(); + } + BREAK; /* no bits left, so exit loop */ + } + } + *q_spectrum_e = SPEC_EXP_DEC; + move16(); + + set32_fx( q_spectrum + k, 0, sub( L_frame, k ) ); + + return bp; +} + +/*-------------------------------------------------------* + * tcx_arith_decode_envelope() + * + * + *-------------------------------------------------------*/ + +void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ +) +{ + Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ + Word16 *envelope; /* scaled envelope (Q15-e) */ + Word16 envelope_e; + Word16 L_spec_core; + TCX_CONFIG_HANDLE hTcxCfg; + TCX_DEC_HANDLE hTcxDec; + Word16 gamma_w, gamma_uw; + Word16 hm_bits; + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || + ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) || + ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) || + ( target_bits <= 0 ) ) + { + /* this could happen in case of bit errors */ + st->BER_detect = 1; + move16(); + L_spec = N_MAX_ARI; + move16(); + *signaling_bits = 0; + move16(); + *arith_bits = 0; + move16(); + set32_fx( q_spectrum, 0, L_frame ); + + return; + } + + hTcxCfg = st->hTcxCfg; + hTcxDec = st->hTcxDec; + *signaling_bits = 0; + move16(); + + assert( hTcxDec->enableTcxLpc ); + gamma_w = MAX16B; + move16(); + gamma_uw = st->inv_gamma; + move16(); + +#define WMC_TOOL_SKIP + tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); +#undef WMC_TOOL_SKIP + + IF( use_hm != 0 ) + { + IF( prm_hm[0] != 0 ) + { + tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits ); + + IF( hm_bits < 0 ) + { + st->BER_detect = 1; + move16(); + *signaling_bits = 0; + move16(); + *arith_bits = 0; + move16(); + set32_fx( q_spectrum, 0, L_frame ); + + return; + } + } + ELSE + { + hm_bits = 1; + move16(); + } + *signaling_bits = add( *signaling_bits, hm_bits ); + move16(); + } + + L_spec_core = L_spec; + move16(); + IF( st->igf ) + { + L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine ); + } + + envelope = (Word16 *) env; + tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); + + *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e ); + move16(); + + /* safety check in case of bit errors */ + IF( *arith_bits < 0 ) + { + st->BER_detect = 1; + move16(); + set32_fx( q_spectrum, 0, L_frame ); + } + + set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) ); + + return; +} + diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c deleted file mode 100644 index 478a81474..000000000 --- a/lib_dec/bass_psfilter.c +++ /dev/null @@ -1,317 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "prot_fx.h" -#include "ivas_prot.h" -#include "cnst.h" -#include "stat_dec.h" -#include "rom_com.h" -#include -#include "wmc_auto.h" -#include "ivas_prot_fx.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - -#define NBPSF_L_EXTRA 120 -#define BPF_STOP_STOPBAND_16 16 -#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ -#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ -#define C_PC_DEC_FX 6583 /*in Q8*/ - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * bass_psfilter() - * - * Perform low-frequency postfiltering - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * Pit_track() - * - * Perform pitch tracking and test pitch/2 to avoid continuous pitch doubling - *---------------------------------------------------------------------*/ - -/*! r: Pitch */ - - -/*---------------------------------------------------------------------* - * addBassPostFilter() - * - * Add BPF component in cldfb domain - *---------------------------------------------------------------------*/ - - -void addBassPostFilter_ivas_fx( - const Word32 *harm_timeIn_fx, // Qx - const Word16 samplesToProcess, - Word32 **rAnalysis_fx, // Qx - 5 - Word32 **iAnalysis_fx, // Qx - 5 - HANDLE_CLDFB_FILTER_BANK cldfb ) -{ - Word32 *tmp_R_fx[CLDFB_NO_COL_MAX]; - Word32 *tmp_I_fx[CLDFB_NO_COL_MAX]; - Word32 cldfbBufferReal_fx[CLDFB_NO_COL_MAX][20]; - Word32 cldfbBufferImag_fx[CLDFB_NO_COL_MAX][20]; - Word16 i, b; - Word16 maxBand; - const Word32 *weights_fx; - Word16 nCol = cldfb->no_col; - move16(); - Word16 nColToProcess = nCol; - move16(); - Word16 nChan = cldfb->no_channels; - move16(); - IF( GT_16( samplesToProcess, -1 ) ) - { - nColToProcess = idiv1616( sub( add( samplesToProcess, cldfb->no_channels ), 1 ), cldfb->no_channels ); - move16(); - } - - assert( nCol == 16 ); - - weights_fx = bpf_weights_16_ivas_fx_32; - - IF( GT_16( nChan, BPF_STOP_STOPBAND_16 ) ) - { - maxBand = BPF_STOP_STOPBAND_16; - move16(); - } - ELSE - { - maxBand = nChan; - move16(); - } - - FOR( i = 0; i < nColToProcess; i++ ) - { - tmp_R_fx[i] = cldfbBufferReal_fx[i]; - tmp_I_fx[i] = cldfbBufferImag_fx[i]; - } - - cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb ); - - /* now do the subtraction */ - FOR( i = 0; i < nColToProcess; i++ ) - { - /* loop over low frequency bands */ - FOR( b = 0; b < maxBand; b++ ) - { - rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6 - move32(); - iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6 - move32(); - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * res_bpf_adapt_ivas_fx() - * - * Analyze BPF output and decide if it should be applied on DFT stereo - * residual signal - *---------------------------------------------------------------------*/ - -/*! r: Decision to enable or disable BPF on DFT stereo residual */ -Word16 res_bpf_adapt_ivas_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ - const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ - Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer Q12 */ - Word16 q_res ) -{ - Word32 error_nrg; - Word32 tmp; - Word32 res_hb_nrg; - Word16 bpf_error_ratio; - Word16 res_bpf_flag; - Word16 i; - Word16 i_start; - Word16 i_end; - Word16 bw_inv; - Word64 W_tmp; - - IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) ) - { - i_start = 39; - move16(); - i_end = 64; - move16(); - bw_inv = 1311; - move16(); /* 1/(64 - 39) in Q15 */ - } - ELSE - { - i_start = 28; - move16(); - i_end = 40; - move16(); - bw_inv = 2720; - move16(); /* 1/(40 - 28) in Q15*/ - } - - /* Measure energy of high frequency band in MDCT domain */ - res_hb_nrg = L_deposit_l( 0 ); - W_tmp = W_deposit32_l( 0 ); - FOR( i = i_start; i < i_end; i++ ) - { - W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) ); - } - - res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 - res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 - res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) ); - hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg; - move32(); - - /* Measure energy of discontinuities at subframe boundaries */ - error_nrg = 0; - move32(); - FOR( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k ) - { - tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx ); - error_nrg = Madd_32_32( error_nrg, tmp, tmp ); - hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )]; - move32(); - } - error_nrg = L_shl( error_nrg, 1 ); // Q0 - error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */ - /* Form decision variable and apply limit */ - IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ) - { - Word16 temp; - bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp ); - bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) ); - } - ELSE - { - bpf_error_ratio = ONE_IN_Q14; // Q13 - move16(); - } - bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); - hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; - move16(); - - res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 ); - move16(); - - return res_bpf_flag; -} - -void bpf_pitch_coherence_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */ -) -{ - Word16 nb_subfr; - Word32 pc, pcn1, pcn2, pcn3; - Word32 scaled_inv_L_frame; // Q8 + Q23 - - SWITCH( st->L_frame ) - { - case 80: - scaled_inv_L_frame = 26843545; // 1/80 in Q31 - move32(); - BREAK; - case 160: - scaled_inv_L_frame = 13421773; // 1/160 in Q31 - move32(); - BREAK; - case 256: - scaled_inv_L_frame = 8388608; // 1/256 in Q31 - move32(); - BREAK; - case 320: - scaled_inv_L_frame = 6710886; // 1/320 in Q31 - move32(); - BREAK; - case 512: - scaled_inv_L_frame = 4194304; // 1/512 in Q31 - move32(); - BREAK; - case 640: - scaled_inv_L_frame = 3355443; // 1/640 in Q31 - move32(); - BREAK; - case 960: - scaled_inv_L_frame = 2236962; // 1/80 in Q31 - move32(); - BREAK; - default: - scaled_inv_L_frame = 0; - move32(); - } - - nb_subfr = shr( st->L_frame, 6 ); - test(); - IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) ) - { - pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) ); - pc = Mpy_32_32( pc, scaled_inv_L_frame ); - pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12 - - pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); - pc = Mpy_32_32( pc, scaled_inv_L_frame ); - pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12 - - pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); - pc = Mpy_32_32( pc, scaled_inv_L_frame ); - pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12 - - IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) ) - { - st->hBPF->psf_att_fx = 13107; //.4 in Q15 - move16(); /*Q15*/ - set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); - } - } - - return; -} diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index c11e30c93..7d2be2c52 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -6,6 +6,7 @@ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /* Function prototypes */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "rom_dec.h" /* Static table prototypes */ @@ -17,6 +18,9 @@ #define NBPSF_L_EXTRA 120 #define BPF_STOP_STOPBAND_16 16 +#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ +#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ +#define C_PC_DEC_FX 6583 /*in Q8*/ /*---------------------------------------------------------------------* * Local function prototypes @@ -889,6 +893,246 @@ void addBassPostFilter_fx( return; } +/*---------------------------------------------------------------------* + * addBassPostFilter() + * + * Add BPF component in cldfb domain + *---------------------------------------------------------------------*/ + + +void addBassPostFilter_ivas_fx( + const Word32 *harm_timeIn_fx, // Qx + const Word16 samplesToProcess, + Word32 **rAnalysis_fx, // Qx - 5 + Word32 **iAnalysis_fx, // Qx - 5 + HANDLE_CLDFB_FILTER_BANK cldfb ) +{ + Word32 *tmp_R_fx[CLDFB_NO_COL_MAX]; + Word32 *tmp_I_fx[CLDFB_NO_COL_MAX]; + Word32 cldfbBufferReal_fx[CLDFB_NO_COL_MAX][20]; + Word32 cldfbBufferImag_fx[CLDFB_NO_COL_MAX][20]; + Word16 i, b; + Word16 maxBand; + const Word32 *weights_fx; + Word16 nCol = cldfb->no_col; + move16(); + Word16 nColToProcess = nCol; + move16(); + Word16 nChan = cldfb->no_channels; + move16(); + IF( GT_16( samplesToProcess, -1 ) ) + { + nColToProcess = idiv1616( sub( add( samplesToProcess, cldfb->no_channels ), 1 ), cldfb->no_channels ); + move16(); + } + + assert( nCol == 16 ); + + weights_fx = bpf_weights_16_ivas_fx_32; + + IF( GT_16( nChan, BPF_STOP_STOPBAND_16 ) ) + { + maxBand = BPF_STOP_STOPBAND_16; + move16(); + } + ELSE + { + maxBand = nChan; + move16(); + } + + FOR( i = 0; i < nColToProcess; i++ ) + { + tmp_R_fx[i] = cldfbBufferReal_fx[i]; + tmp_I_fx[i] = cldfbBufferImag_fx[i]; + } + + cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb ); + + /* now do the subtraction */ + FOR( i = 0; i < nColToProcess; i++ ) + { + /* loop over low frequency bands */ + FOR( b = 0; b < maxBand; b++ ) + { + rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6 + move32(); + iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6 + move32(); + } + } + + return; +} + + +/*---------------------------------------------------------------------* + * res_bpf_adapt_ivas_fx() + * + * Analyze BPF output and decide if it should be applied on DFT stereo + * residual signal + *---------------------------------------------------------------------*/ + +/*! r: Decision to enable or disable BPF on DFT stereo residual */ +Word16 res_bpf_adapt_ivas_fx( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ + const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ + Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer Q12 */ + Word16 q_res ) +{ + Word32 error_nrg; + Word32 tmp; + Word32 res_hb_nrg; + Word16 bpf_error_ratio; + Word16 res_bpf_flag; + Word16 i; + Word16 i_start; + Word16 i_end; + Word16 bw_inv; + Word64 W_tmp; + + IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) ) + { + i_start = 39; + move16(); + i_end = 64; + move16(); + bw_inv = 1311; + move16(); /* 1/(64 - 39) in Q15 */ + } + ELSE + { + i_start = 28; + move16(); + i_end = 40; + move16(); + bw_inv = 2720; + move16(); /* 1/(40 - 28) in Q15*/ + } + + /* Measure energy of high frequency band in MDCT domain */ + res_hb_nrg = L_deposit_l( 0 ); + W_tmp = W_deposit32_l( 0 ); + FOR( i = i_start; i < i_end; i++ ) + { + W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) ); + } + + res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 + res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 + res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) ); + hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg; + move32(); + + /* Measure energy of discontinuities at subframe boundaries */ + error_nrg = 0; + move32(); + FOR( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k ) + { + tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx ); + error_nrg = Madd_32_32( error_nrg, tmp, tmp ); + hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )]; + move32(); + } + error_nrg = L_shl( error_nrg, 1 ); // Q0 + error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */ + /* Form decision variable and apply limit */ + IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ) + { + Word16 temp; + bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp ); + bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) ); + } + ELSE + { + bpf_error_ratio = ONE_IN_Q14; // Q13 + move16(); + } + bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); + hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; + move16(); + + res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 ); + move16(); + + return res_bpf_flag; +} + +void bpf_pitch_coherence_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */ +) +{ + Word16 nb_subfr; + Word32 pc, pcn1, pcn2, pcn3; + Word32 scaled_inv_L_frame; // Q8 + Q23 + + SWITCH( st->L_frame ) + { + case 80: + scaled_inv_L_frame = 26843545; // 1/80 in Q31 + move32(); + BREAK; + case 160: + scaled_inv_L_frame = 13421773; // 1/160 in Q31 + move32(); + BREAK; + case 256: + scaled_inv_L_frame = 8388608; // 1/256 in Q31 + move32(); + BREAK; + case 320: + scaled_inv_L_frame = 6710886; // 1/320 in Q31 + move32(); + BREAK; + case 512: + scaled_inv_L_frame = 4194304; // 1/512 in Q31 + move32(); + BREAK; + case 640: + scaled_inv_L_frame = 3355443; // 1/640 in Q31 + move32(); + BREAK; + case 960: + scaled_inv_L_frame = 2236962; // 1/80 in Q31 + move32(); + BREAK; + default: + scaled_inv_L_frame = 0; + move32(); + } + + nb_subfr = shr( st->L_frame, 6 ); + test(); + IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) ) + { + pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12 + + pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12 + + pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12 + + IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) ) + { + st->hBPF->psf_att_fx = 13107; //.4 in Q15 + move16(); /*Q15*/ + set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); + } + } + + return; +} + + #ifdef ADD_BPF_ADAPT /*---------------------------------------------------------------------* * res_bpf_adapt() diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c deleted file mode 100644 index 37c397bbf..000000000 --- a/lib_dec/core_dec_init.c +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "stat_com.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -/*-----------------------------------------------------------------------* - * open_decoder_LPD() - * - * Initialization of state variables - *-----------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------* - * tcxltp_dec_init() - * - * Initialization TCX-LTP handle - *-----------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------* - * reset_tcx_overl_buf() - * - * Reset TCX core overlap buffers - *-----------------------------------------------------------------------*/ - -void reset_tcx_overl_buf_fx( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ -) -{ - set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_old_syn_Overl = 0; - move16(); - set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_syn_Overl_TDAC = 0; - move16(); - set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_syn_Overl = 0; - move16(); - set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_syn_Overl_TDACFB = 0; - move16(); - return; -} - -/*-----------------------------------------------------------------------* - * acelp_plc_mdct_transition() - * - * Prepare MDCT OLA memories in TCX/HQ after ACELP PLC - *-----------------------------------------------------------------------*/ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 671dbfd2c..f649772b2 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -2191,3 +2191,29 @@ void open_decoder_LPD_ivas_fx( return; } + +/*-----------------------------------------------------------------------* + * reset_tcx_overl_buf() + * + * Reset TCX core overlap buffers + *-----------------------------------------------------------------------*/ + +void reset_tcx_overl_buf_fx( + TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ +) +{ + set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_old_syn_Overl = 0; + move16(); + set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_Overl_TDAC = 0; + move16(); + set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_Overl = 0; + move16(); + set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_Overl_TDACFB = 0; + move16(); + return; +} + diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c deleted file mode 100644 index aa04a70cb..000000000 --- a/lib_dec/core_switching_dec.c +++ /dev/null @@ -1,1076 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_cnst.h" -#include "wmc_auto.h" - -#include "ivas_prot_fx.h" -#include "debug.h" -/*---------------------------------------------------------------------* - * Local prototypes - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * core_switching_pre_dec() - * - * Preprocessing/preparation for ACELP/HQ core switching - *---------------------------------------------------------------------*/ -ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ) -{ - Word32 tmp_fx; /*Q-12*/ - Word16 i, oldLenClasBuff, newLenClasBuff; - ivas_error error; - Word16 exp = 25; - move16(); - error = IVAS_ERR_OK; - move32(); - - /* Codec mode switching */ - test(); - test(); - test(); - IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) - { - st->mem_deemph_fx = st->syn[M]; - move16(); - set16_fx( st->agc_mem_fx, 0, 2 ); - Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */ - - Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ - - st->bpf_off = 1; - move16(); - IF( st->hPFstat != NULL ) - { - Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ - Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ - Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ - set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ - } - IF( st->hBPF != NULL ) - { - st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ - st->hBPF->pst_mem_deemp_err_fx = 0; - move16(); - move16(); - } - st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); // Q(23+1-16)->Q8 - move16(); - - /* reset old HB synthesis buffer */ - IF( EQ_16( st->last_L_frame, L_FRAME ) ) - { - st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); - } - ELSE - { - st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); - } - move16(); - set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - - test(); - IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) - { -#ifdef MSAN_FIX - st->hBWE_TD->prev_hb_synth_fx_exp = 31; - move16(); -#endif // MSAN_FIX - /* reset BWE memories */ - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* reset upd_cnt */ - st->upd_cnt = MAX_UPD_CNT; - move16(); - - st->igf = 0; - move16(); - - test(); - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st->hBWE_zero ); -#ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - - IF( st->hHQ_core != NULL ) - { - set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - - st->hHQ_core->last_max_pos_pulse = 0; - move16(); - - IF( GT_32( st->output_Fs, 16000 ) ) - { - set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - /* pre-echo */ - st->hHQ_core->pastpre = 0; - move16(); - } - - /* reset the GSC pre echo energy threshold in case of switching */ - if ( st->hGSCDec != NULL ) - { - st->hGSCDec->Last_frame_ener_fx = MAX_32; - move32(); - } - - test(); - IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) - { - IF( st->element_mode == EVS_MONO ) - { - st->last_core = HQ_CORE; - move16(); - - Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 - } - - IF( st->hHQ_core != NULL ) - { - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - st->hHQ_core->prev_frm_hfe2 = 0; - st->hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - } - } - - IF( st->prev_bfi != 0 ) - { - Word16 delay_comp; - - /*switch off Hq Voicing as it was not updated in MODE2*/ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->oldHqVoicing = 0; - st->hHQ_core->HqVoicing = 0; - move16(); - move16(); - } - - delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - /*TODO To be tested:control not entering the block*/ - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) - { - /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ - assert( 0 ); - Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; - Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; - Word32 syn_Overl_fx[320]; - Word32 fer_samples_fx[960]; - Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); - Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); - - - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) - { - set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer_fx[i] = realBufferTmp_fx[i]; - imagBuffer_fx[i] = imagBufferTmp_fx[i]; - } - - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) ) - { - return error; - } - - cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna ); - cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/ - - /* CLDFB synthesis of the combined signal */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) ) - { - return error; - } - - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, st->cldfbSyn ); - cldfb_restore_memory_ivas_fx( st->cldfbSyn ); - Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); - Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); - } - - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) - { - lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); - /*Set to zero the remaining part*/ - set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); - } - } - - st->use_acelp_preq = 0; - st->reset_mem_AR = 0; - move16(); - move16(); - } - - /*FEC*/ - IF( LE_16( st->L_frame, L_FRAME16k ) ) - { - test(); - IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) - { - IF( NE_16( st->L_frame, st->last_L_frame ) ) - { - IF( GT_16( st->L_frame, st->last_L_frame ) ) - { - oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) ); - newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - } - ELSE - { - oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) ); - } - lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); - } - } - ELSE - { - set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) ) - { - st->last_ppp_mode_dec = 0; - st->last_nelp_mode_dec = 0; - move16(); - move16(); - } - - /* Handle state reset of stat_noise_uv_mod memory */ - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st->act_count = 3; - st->uv_count = 0; - move16(); - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && - NE_32( st->core_brate, SID_2k40 ) && ( st->core_brate != FRAME_NO_DATA ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) - { - test(); - if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - st->hPFstat->reset = 1; - move16(); - } - - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ - Copy( TRWB2_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( TRWB2_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( TRWB2_Ave_fx, st->lsf_adaptive_mean_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ - Copy( TRWB_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( TRWB_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( TRWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) - { - /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ - set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); - set16_fx( st->agc_mem_fx, 0, 2 ); - } - st->mem_deemph_fx = 0; - move16(); - IF( !st->last_con_tcx ) - { - set16_fx( st->mem_syn2_fx, 0, M ); - } - set16_fx( st->mem_syn1_fx, 0, M ); - if ( st->hBWE_TD != NULL ) - { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* Reset ACELP parameters */ - set16_fx( st->mem_MA_fx, 0, M ); - - IF( EQ_32( st->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - } - - st->tilt_code_fx = 0; - st->gc_threshold_fx = 0; - st->dm_fx.prev_gain_code = 0; - st->dm_fx.prev_state = 0; - move16(); - move32(); - move32(); - move16(); - set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); - - st->last_coder_type = GENERIC; - move16(); - - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ - st->lp_gainp_fx = 0; - move16(); - st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ - move16(); - st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ - move16(); - - st->last_voice_factor_fx = 0; - st->Last_GSC_noisy_speech_flag = 0; - move16(); - move16(); - - /* reset CLDFB memories */ - cldfb_reset_memory_fx( st->cldfbAna ); - cldfb_reset_memory_fx( st->cldfbBPF ); - cldfb_reset_memory_fx( st->cldfbSyn ); - - /* reset TBE memories */ - test(); - test(); - IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) - { - set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); - } - ELSE IF( LT_16( st->L_frame, L_FRAME16k ) ) - { - /* resample from 16kHz to 12.8kHZ */ - synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); - } - - IF( st->hBWE_TD != NULL ) - { - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - } - - test(); - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st->hBWE_zero ); -#ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - - test(); - test(); - test(); - IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) - { - IF( st->hBWE_TD != NULL ) - { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - } - - st->tilt_code_fx = 0; - st->gc_threshold_fx = 0; - st->dm_fx.prev_gain_code = 0; - st->dm_fx.prev_state = 0; - move16(); - move32(); - move32(); - move16(); - set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); - st->last_coder_type = GENERIC; - move16(); - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ - - st->lp_gainp_fx = 0; - move16(); - st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ - move16(); - st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ - move16(); - - st->last_voice_factor_fx = 0; - st->Last_GSC_noisy_speech_flag = 0; - move16(); - move16(); - - test(); - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st->hBWE_zero ); -#ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - - test(); - test(); - test(); - IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) - { - /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ - Word16 offset; - offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Word32 *old_synthFB_fx; - IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); - } -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 -#else - Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 -#endif - Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); - st->cldfbAna->Q_cldfb_state = Q10; - move16(); - IF( old_synthFB_fx ) - free( old_synthFB_fx ); - } - } - - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) - { - set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - st->hHQ_core->prev_frm_hfe2 = 0; - st->hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - IF( GT_32( st->output_Fs, 16000 ) ) - { - set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - IF( st->element_mode != EVS_MONO ) - { - /* Estimate mem_env_delta to reinit env_stab */ - tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ - - st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ - move16(); - test(); - IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) - { - set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); - set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); - } - - st->hHQ_core->no_att_hangover = 0; - move16(); - st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/ - move32(); - set16_fx( st->hHQ_core->old_is_transient, 0, 3 ); - set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 ); - st->hHQ_core->prev_R = 0; - move16(); - set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); - st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; - st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/ - move16(); - move16(); - set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS ); - } - ELSE - { - set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); - } - } - - /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 ); - move16(); - IF( st->hHQ_core->pastpre < 0 ) - { - reset_preecho_dec_fx( st->hHQ_core ); - } - } - test(); - IF( st->core_brate == FRAME_NO_DATA ) - { - st->VAD = 0; - st->m_frame_type = ZERO_FRAME; - } - ELSE IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) ) - { - st->VAD = 0; - st->m_frame_type = SID_FRAME; - } - ELSE - { - st->VAD = 1; - st->m_frame_type = ACTIVE_FRAME; - } - - move16(); - move16(); - /*switch on CNA on active frames*/ - IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) - { - st->flag_cna = 1; - move16(); - } - ELSE IF( st->VAD || ( EQ_16( st->cng_type, FD_CNG ) && EQ_16( st->L_frame, L_FRAME16k ) ) ) - { - st->flag_cna = 0; - move16(); - } - } - - if ( EQ_16( st->core, AMR_WB_CORE ) ) - { - st->cng_type = LP_CNG; - move16(); - } - - /* Reconfigure CNG */ - test(); - test(); - test(); - test(); - IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || ( st->ini_frame == 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) - { - /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ - IF( NE_16( st->core, AMR_WB_CORE ) ) - { - test(); - IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode ); - } - ELSE - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); - } - } - ELSE - { - configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); - - if ( st->VAD ) - { - st->hFdCngDec->hFdCngCom->CngBitrate = st->total_brate; - move32(); - } - } - test(); - test(); - IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) - { - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); - } - - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); - - test(); - IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) - { - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); - - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) - { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); - move32(); - } - } - ELSE - { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) - { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); - move32(); - } - } - } - } - } - - return error; -} -/*---------------------------------------------------------------------* - * core_switching_hq_prepare_dec() - * - * Preprocessing in the first HQ frame after ACELP frame - * Modify bit allocation for HQ core by removing ACELP subframe budget - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * bandwidth_switching_detect() - * - * Classification for band-width switching - *---------------------------------------------------------------------*/ - -void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -) -{ - test(); - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = 0; - st_fx->bws_cnt1 = 0; - move16(); - move16(); - move16(); - - return; - } - /* update band-width switching counter */ - test(); - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) && ( st_fx->last_low_rate_mode == 0 ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); - move16(); - } - ELSE IF( st_fx->bws_cnt1 > 0 ) - { - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, SWB ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - } - } - - /* update band-width switching counter */ - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); - move16(); - } - ELSE IF( st_fx->bws_cnt > 0 ) - { - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * bw_switching_pre_proc() - * - * Band-width switching pre-processing - *---------------------------------------------------------------------*/ -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out /* i : number of output channels */, - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ) -{ - Word16 i; - Word32 syn_dct_fx[L_FRAME]; - - - Flag Overflow = 0; - move32(); - - IF( st->element_mode > EVS_MONO ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) - { - /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; - Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); - st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 - move16(); - } - - return; - } - - - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) - { - /*----------------------------------------------------------------------* - * Calculate tilt of the ACELP core synthesis - *----------------------------------------------------------------------*/ - - st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame ); - move16(); - /*-------------------------------------------------------------------------------* - * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis - *-------------------------------------------------------------------------------*/ - edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q ); - Word64 W_tmp = 0; - move64(); - Word32 tmp; - Word16 shift; - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); - tmp = L_shr( tmp, 8 ); - - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - W_tmp = 0; - move64(); - FOR( ; i < L_FRAME; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32 - tmp = L_shr( tmp, 7 ); // divide by 128 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - } - ELSE - { - IF( st->hHQ_core->old_is_transient[0] ) - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < 32; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < 64; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = Q_audio; - move16(); - } - ELSE - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < L_FRAME; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) - { - - st->prev_ener_shb_fx = 0; - move16(); - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->prev_SWB_fenv_fx, 0, SWB_FENV ); - } - } - ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) - { - st->attenu_fx = 3277; // 0.1f in Q15 - move16(); - } - - test(); - test(); - test(); - test(); - test(); - if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) - { - st->prev_fractive = 0; - move16(); - } - - return; -} -/*---------------------------------------------------------------------* - * core_switch_lb_upsamp() - * - * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * smoothTransitionDtxToTcx() - * - * apply smoothing to the transition part for inactive to active transitions in DTX - *---------------------------------------------------------------------*/ - -#define TRANSITION_SMOOTHING_LEN_16k 15 -#define TRANSITION_SMOOTHING_LEN_32k 31 -#define TRANSITION_SMOOTHING_LEN_48k 47 diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d654b3af4..caef9485b 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2435,3 +2435,1012 @@ static void smoothTransitionDtxToTcx_fx( return; } + + +/*---------------------------------------------------------------------* + * core_switching_pre_dec() + * + * Preprocessing/preparation for ACELP/HQ core switching + *---------------------------------------------------------------------*/ +ivas_error core_switching_pre_dec_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 ) +{ + Word32 tmp_fx; /*Q-12*/ + Word16 i, oldLenClasBuff, newLenClasBuff; + ivas_error error; + Word16 exp = 25; + move16(); + error = IVAS_ERR_OK; + move32(); + + /* Codec mode switching */ + test(); + test(); + test(); + IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) + { + st->mem_deemph_fx = st->syn[M]; + move16(); + set16_fx( st->agc_mem_fx, 0, 2 ); + Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */ + + Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ + + st->bpf_off = 1; + move16(); + IF( st->hPFstat != NULL ) + { + Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ + Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ + Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ + set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ + } + IF( st->hBPF != NULL ) + { + st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ + st->hBPF->pst_mem_deemp_err_fx = 0; + move16(); + move16(); + } + st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); // Q(23+1-16)->Q8 + move16(); + + /* reset old HB synthesis buffer */ + IF( EQ_16( st->last_L_frame, L_FRAME ) ) + { + st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); + } + ELSE + { + st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + } + move16(); + set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); + + test(); + IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) + { +#ifdef MSAN_FIX + st->hBWE_TD->prev_hb_synth_fx_exp = 31; + move16(); +#endif // MSAN_FIX + /* reset BWE memories */ + set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + + /* reset upd_cnt */ + st->upd_cnt = MAX_UPD_CNT; + move16(); + + st->igf = 0; + move16(); + + test(); + IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + + IF( st->hHQ_core != NULL ) + { + set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); + set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); + + set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + + st->hHQ_core->last_max_pos_pulse = 0; + move16(); + + IF( GT_32( st->output_Fs, 16000 ) ) + { + set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); + } + + /* pre-echo */ + st->hHQ_core->pastpre = 0; + move16(); + } + + /* reset the GSC pre echo energy threshold in case of switching */ + if ( st->hGSCDec != NULL ) + { + st->hGSCDec->Last_frame_ener_fx = MAX_32; + move32(); + } + + test(); + IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) + { + IF( st->element_mode == EVS_MONO ) + { + st->last_core = HQ_CORE; + move16(); + + Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 + } + + IF( st->hHQ_core != NULL ) + { + set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + st->hHQ_core->last_max_pos_pulse = 0; + move16(); + + set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + st->hHQ_core->prev_frm_hfe2 = 0; + st->hHQ_core->prev_stab_hfe2 = 0; + move16(); + move16(); + } + } + + IF( st->prev_bfi != 0 ) + { + Word16 delay_comp; + + /*switch off Hq Voicing as it was not updated in MODE2*/ + IF( st->hHQ_core != NULL ) + { + st->hHQ_core->oldHqVoicing = 0; + st->hHQ_core->HqVoicing = 0; + move16(); + move16(); + } + + delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + /*TODO To be tested:control not entering the block*/ + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ + assert( 0 ); + Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; + Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; + Word32 syn_Overl_fx[320]; + Word32 fer_samples_fx[960]; + Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); + Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); + + + FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) + { + set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + realBuffer_fx[i] = realBufferTmp_fx[i]; + imagBuffer_fx[i] = imagBufferTmp_fx[i]; + } + + /* CLDFB analysis of the synthesis at internal sampling rate */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) ) + { + return error; + } + + cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna ); + cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/ + + /* CLDFB synthesis of the combined signal */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) ) + { + return error; + } + + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, st->cldfbSyn ); + cldfb_restore_memory_ivas_fx( st->cldfbSyn ); + Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); + Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); + } + + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); + /*Set to zero the remaining part*/ + set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); + } + } + + st->use_acelp_preq = 0; + st->reset_mem_AR = 0; + move16(); + move16(); + } + + /*FEC*/ + IF( LE_16( st->L_frame, L_FRAME16k ) ) + { + test(); + IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) + { + IF( NE_16( st->L_frame, st->last_L_frame ) ) + { + IF( GT_16( st->L_frame, st->last_L_frame ) ) + { + oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) ); + newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + } + ELSE + { + oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) ); + } + lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); + } + } + ELSE + { + set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); + } + } + + /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores + within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ + test(); + test(); + IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) ) + { + st->last_ppp_mode_dec = 0; + st->last_nelp_mode_dec = 0; + move16(); + move16(); + } + + /* Handle state reset of stat_noise_uv_mod memory */ + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) + { + st->act_count = 3; + st->uv_count = 0; + move16(); + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && + NE_32( st->core_brate, SID_2k40 ) && ( st->core_brate != FRAME_NO_DATA ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) + { + test(); + if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + st->hPFstat->reset = 1; + move16(); + } + + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ + Copy( TRWB2_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( TRWB2_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( TRWB2_Ave_fx, st->lsf_adaptive_mean_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k ); + } + ELSE + { + Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ + Copy( TRWB_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( TRWB_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( TRWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); + } + + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) + { + /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ + set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); + set16_fx( st->agc_mem_fx, 0, 2 ); + } + st->mem_deemph_fx = 0; + move16(); + IF( !st->last_con_tcx ) + { + set16_fx( st->mem_syn2_fx, 0, M ); + } + set16_fx( st->mem_syn1_fx, 0, M ); + if ( st->hBWE_TD != NULL ) + { + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + + /* Reset ACELP parameters */ + set16_fx( st->mem_MA_fx, 0, M ); + + IF( EQ_32( st->sr_core, INT_FS_16k ) ) + { + Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); + } + ELSE + { + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + } + + st->tilt_code_fx = 0; + st->gc_threshold_fx = 0; + st->dm_fx.prev_gain_code = 0; + st->dm_fx.prev_state = 0; + move16(); + move32(); + move32(); + move16(); + set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); + + st->last_coder_type = GENERIC; + move16(); + + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + st->lp_gainp_fx = 0; + move16(); + st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ + move16(); + st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ + move16(); + + st->last_voice_factor_fx = 0; + st->Last_GSC_noisy_speech_flag = 0; + move16(); + move16(); + + /* reset CLDFB memories */ + cldfb_reset_memory_fx( st->cldfbAna ); + cldfb_reset_memory_fx( st->cldfbBPF ); + cldfb_reset_memory_fx( st->cldfbSyn ); + + /* reset TBE memories */ + test(); + test(); + IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) + { + set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); + } + ELSE IF( LT_16( st->L_frame, L_FRAME16k ) ) + { + /* resample from 16kHz to 12.8kHZ */ + synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); + } + + IF( st->hBWE_TD != NULL ) + { + set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + } + + test(); + IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + } + + test(); + test(); + test(); + IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) + { + IF( st->hBWE_TD != NULL ) + { + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + } + + st->tilt_code_fx = 0; + st->gc_threshold_fx = 0; + st->dm_fx.prev_gain_code = 0; + st->dm_fx.prev_state = 0; + move16(); + move32(); + move32(); + move16(); + set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); + st->last_coder_type = GENERIC; + move16(); + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + + st->lp_gainp_fx = 0; + move16(); + st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ + move16(); + st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ + move16(); + + st->last_voice_factor_fx = 0; + st->Last_GSC_noisy_speech_flag = 0; + move16(); + move16(); + + test(); + IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + + test(); + test(); + test(); + IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) + { + /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ + Word16 offset; + offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Word32 *old_synthFB_fx; + IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); + } +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 +#else + Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 +#endif + Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); + st->cldfbAna->Q_cldfb_state = Q10; + move16(); + IF( old_synthFB_fx ) + free( old_synthFB_fx ); + } + } + + test(); + test(); + test(); + test(); + IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) + { + set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); + set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); + + set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + st->hHQ_core->last_max_pos_pulse = 0; + move16(); + + set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + st->hHQ_core->prev_frm_hfe2 = 0; + st->hHQ_core->prev_stab_hfe2 = 0; + move16(); + move16(); + IF( GT_32( st->output_Fs, 16000 ) ) + { + set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); + } + + IF( st->element_mode != EVS_MONO ) + { + /* Estimate mem_env_delta to reinit env_stab */ + tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ + + st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ + move16(); + test(); + IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) + { + set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); + set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); + set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); + } + + st->hHQ_core->no_att_hangover = 0; + move16(); + st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/ + move32(); + set16_fx( st->hHQ_core->old_is_transient, 0, 3 ); + set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 ); + st->hHQ_core->prev_R = 0; + move16(); + set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); + st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; + st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/ + move16(); + move16(); + set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS ); + } + ELSE + { + set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); + set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); + } + } + + /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ + IF( st->hHQ_core != NULL ) + { + st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 ); + move16(); + IF( st->hHQ_core->pastpre < 0 ) + { + reset_preecho_dec_fx( st->hHQ_core ); + } + } + test(); + IF( st->core_brate == FRAME_NO_DATA ) + { + st->VAD = 0; + st->m_frame_type = ZERO_FRAME; + } + ELSE IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) ) + { + st->VAD = 0; + st->m_frame_type = SID_FRAME; + } + ELSE + { + st->VAD = 1; + st->m_frame_type = ACTIVE_FRAME; + } + + move16(); + move16(); + /*switch on CNA on active frames*/ + IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ + { + test(); + test(); + test(); + test(); + test(); + test(); + IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) + { + st->flag_cna = 1; + move16(); + } + ELSE IF( st->VAD || ( EQ_16( st->cng_type, FD_CNG ) && EQ_16( st->L_frame, L_FRAME16k ) ) ) + { + st->flag_cna = 0; + move16(); + } + } + + if ( EQ_16( st->core, AMR_WB_CORE ) ) + { + st->cng_type = LP_CNG; + move16(); + } + + /* Reconfigure CNG */ + test(); + test(); + test(); + test(); + IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || ( st->ini_frame == 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) + { + /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ + IF( NE_16( st->core, AMR_WB_CORE ) ) + { + test(); + IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) + { + configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode ); + } + ELSE + { + configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); + } + } + ELSE + { + configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); + + if ( st->VAD ) + { + st->hFdCngDec->hFdCngCom->CngBitrate = st->total_brate; + move32(); + } + } + test(); + test(); + IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) + { + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); + } + + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + + test(); + IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) + { + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); + + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); + move32(); + } + } + ELSE + { + FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); + move32(); + } + } + } + } + } + + return error; +} +/*---------------------------------------------------------------------* + * core_switching_hq_prepare_dec() + * + * Preprocessing in the first HQ frame after ACELP frame + * Modify bit allocation for HQ core by removing ACELP subframe budget + *---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * bandwidth_switching_detect() + * + * Classification for band-width switching + *---------------------------------------------------------------------*/ + +void bandwidth_switching_detect_ivas_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +) +{ + test(); + test(); + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ + st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; + st_fx->bws_cnt1 = 0; + move16(); + move16(); + move16(); + + return; + } + /* update band-width switching counter */ + test(); + test(); + test(); + test(); + IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) + { + st_fx->bws_cnt1 = 0; + move16(); + } + ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) && ( st_fx->last_low_rate_mode == 0 ) ) + { + st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); + move16(); + } + ELSE IF( st_fx->bws_cnt1 > 0 ) + { + IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt = 0; + move16(); + } + + IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt1 = 0; + move16(); + } + ELSE + { + IF( EQ_16( st_fx->bwidth, SWB ) ) + { + st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt1 = 0; + move16(); + } + } + } + + /* update band-width switching counter */ + test(); + test(); + test(); + IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) + { + st_fx->bws_cnt = 0; + move16(); + } + ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) ) + { + st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); + move16(); + } + ELSE IF( st_fx->bws_cnt > 0 ) + { + IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt1 = 0; + move16(); + } + + IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt = 0; + move16(); + } + ELSE + { + IF( EQ_16( st_fx->bwidth, WB ) ) + { + st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt = 0; + move16(); + } + } + } + + return; +} + + +/*---------------------------------------------------------------------* + * bw_switching_pre_proc() + * + * Band-width switching pre-processing + *---------------------------------------------------------------------*/ +void ivas_bw_switching_pre_proc_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out /* i : number of output channels */, + Word32 *old_syn_12k8_16k_fx, + Word16 Q, + Word16 Q_audio ) +{ + Word16 i; + Word32 syn_dct_fx[L_FRAME]; + + + Flag Overflow = 0; + move32(); + + IF( st->element_mode > EVS_MONO ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) + { + /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ + Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; + Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); + st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 + move16(); + } + + return; + } + + + test(); + test(); + IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) + { + /*----------------------------------------------------------------------* + * Calculate tilt of the ACELP core synthesis + *----------------------------------------------------------------------*/ + + st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame ); + move16(); + /*-------------------------------------------------------------------------------* + * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis + *-------------------------------------------------------------------------------*/ + edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q ); + Word64 W_tmp = 0; + move64(); + Word32 tmp; + Word16 shift; + FOR( i = 0; i < L_FRAME / 2; i++ ) + { + W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); + } + shift = W_norm( W_tmp ); + W_tmp = W_shl( W_tmp, shift ); + tmp = W_extract_h( W_tmp ); + tmp = L_shr( tmp, 8 ); + + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); + move16(); + W_tmp = 0; + move64(); + FOR( ; i < L_FRAME; i++ ) + { + W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); + } + shift = W_norm( W_tmp ); + W_tmp = W_shl( W_tmp, shift ); + tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32 + tmp = L_shr( tmp, 7 ); // divide by 128 + tmp = getSqrtWord32( tmp ); + st->enerLH_fx = tmp; + move32(); + st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); + move16(); + } + ELSE + { + IF( st->hHQ_core->old_is_transient[0] ) + { + Word32 tmp, L_tmp = 0; + move32(); + FOR( i = 0; i < 32; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = Q_audio; + move16(); + + L_tmp = 0; + move32(); + FOR( ; i < 64; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLH_fx = tmp; + move32(); + st->enerLH_fx_Q = Q_audio; + move16(); + } + ELSE + { + Word32 tmp, L_tmp = 0; + move32(); + FOR( i = 0; i < L_FRAME / 2; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = Q_audio; + move16(); + + L_tmp = 0; + move32(); + FOR( ; i < L_FRAME; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = Q_audio; + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) + { + + st->prev_ener_shb_fx = 0; + move16(); + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->prev_SWB_fenv_fx, 0, SWB_FENV ); + } + } + ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) + { + st->attenu_fx = 3277; // 0.1f in Q15 + move16(); + } + + test(); + test(); + test(); + test(); + test(); + if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) + { + st->prev_fractive = 0; + move16(); + } + + return; +} \ No newline at end of file diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c deleted file mode 100644 index 7b4567f7a..000000000 --- a/lib_dec/dec_prm.c +++ /dev/null @@ -1,328 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * getTCXMode_ivas() - * - * get TCX mode - *--------------------------------------------------------------------*/ -void getTCXMode_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -) -{ - UWord16 ind; - - IF( st->tcxonly ) - { - /* get core */ - ind = get_next_indice_fx( st0, 1 ); /* Store decoder memory of last_core */ - st->core = add( ind, TCX_20_CORE ); - move16(); - /* get class */ - ind = get_next_indice_fx( st0, 2 ); - - st->clas_dec = ONSET; - move16(); - IF( ind == 0 ) - { - st->clas_dec = UNVOICED_CLAS; - move16(); - } - ELSE IF( EQ_16( ind, 1 ) ) - { - IF( GE_16( st->last_good, VOICED_TRANSITION ) ) - { - st->clas_dec = VOICED_TRANSITION; - move16(); - } - ELSE - { - st->clas_dec = UNVOICED_TRANSITION; - move16(); - } - } - ELSE IF( EQ_16( ind, 2 ) ) - { - st->clas_dec = VOICED_CLAS; - move16(); - } - - st->coder_type = INACTIVE; - move16(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) - { - st->VAD = get_next_indice_fx( st0, 1 ); - move16(); - } - ELSE - { - st->VAD = 0; - move16(); - } - } - ELSE - { - IF( EQ_16( st->mdct_sw, MODE1 ) ) - { - /* 2 bits instead of 3 as TCX is already signaled */ - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = get_next_indice_fx( st0, 2 ); - move16(); - st->coder_type = st->hTcxCfg->coder_type; - move16(); - } - ELSE - { - IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) - { - IF( get_next_indice_1_fx( st0 ) ) - { - ind = get_next_indice_fx( st0, 3 ); - assert( !( ind & 4 ) || !"HQ_CORE encountered in dec_prm_ivas" ); - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = ind; - move16(); - st->coder_type = st->hTcxCfg->coder_type; - move16(); - } - ELSE /* ACELP */ - { - st->core = ACELP_CORE; - move16(); - st->coder_type = get_next_indice_fx( st0, 2 ); - move16(); - } - } - ELSE - { - IF( EQ_16( st->rf_flag, 1 ) ) - { - IF( !st->use_partial_copy ) - { - ind = get_next_indice_fx( st0, 1 ); - IF( ind == 0 ) - { - st->core = ACELP_CORE; - move16(); - } - ELSE - { - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = st->coder_type; - move16(); - } - } - } - ELSE - { - ind = get_next_indice_fx( st, 3 ); - IF( LT_16( ind, ACELP_MODE_MAX ) ) - { - st->core = ACELP_CORE; - move16(); - st->coder_type = ind; - move16(); - } - ELSE - { - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = sub( ind, ACELP_MODE_MAX ); - move16(); - st->coder_type = st->hTcxCfg->coder_type; - move16(); - } - } - } - } - - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - test(); - IF( st->igf && EQ_16( st->core, ACELP_CORE ) ) - { - st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ); - move16(); - } - - IF( st->rf_flag ) - { - st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */ - move16(); - } - } - - /* Inactive frame detection on non-DTX mode */ - IF( EQ_16( st->coder_type, INACTIVE ) ) - { - st->VAD = 0; - move16(); - } - ELSE - { - st->VAD = 1; - move16(); - } - } - - /*Core extended mode mapping for correct PLC classification*/ - st->core_ext_mode = st->coder_type; - move16(); - if ( EQ_16( st->coder_type, INACTIVE ) ) - { - st->core_ext_mode = UNVOICED; - move16(); - } - - return; -} - -/*-------------------------------------------------------------------* - * getTCXWindowing_ivas() - * - * get TCX transform type for each subframe - *--------------------------------------------------------------------*/ -void getTCXWindowing_ivas_fx( - const Word16 core, /* i : current core */ - const Word16 last_core, /* i : last frame core */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ -) -{ - Word16 overlap_code; - - /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */ - test(); - test(); - test(); - IF( EQ_16( last_core, ACELP_CORE ) || EQ_16( last_core, AMR_WB_CORE ) ) - { - hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP; - move16(); - } - ELSE IF( EQ_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, ALDO_WINDOW ) ) - { - hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP; - move16(); - } - ELSE IF( NE_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) - { - hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; - move16(); - } - ELSE - { - hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - - /* Set the current overlap mode based on the current frame type and coded overlap mode */ - hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - - IF( NE_16( core, ACELP_CORE ) ) - { - overlap_code = 0; - move16(); - IF( get_next_indice_fx( st0, 1 ) ) - { - overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); - } - - assert( MIN_OVERLAP == 2 && HALF_OVERLAP == 3 ); - hTcxCfg->tcx_curr_overlap_mode = overlap_code; - move16(); - /*TCX10 : always symmetric windows*/ - test(); - test(); - test(); - IF( EQ_16( core, TCX_20_CORE ) && ( overlap_code == 0 ) && NE_16( last_core, ACELP_CORE ) && NE_16( last_core, AMR_WB_CORE ) ) - { - hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - } - } - - test(); - IF( NE_16( element_mode, EVS_MONO ) && EQ_16( core, TCX_10_CORE ) ) - { - /* also read last overlap */ - overlap_code = 0; - move16(); - - IF( get_next_indice_fx( st0, 1 ) ) - { - overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); - } - - hTcxCfg->tcx_last_overlap_mode = overlap_code; - move16(); - } - - return; -} - -/*-------------------------------------------------------------------* - * getLPCparam_ivas() - * - * get LPC parameters - *--------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * Function dec_prm_ivas() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * - * SQ is used for TCX modes - * - * decode parameters according to selected mode * - *-----------------------------------------------------------------*/ diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 73edd3b3b..77fd7d421 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -1742,3 +1742,273 @@ void dec_prm_fx( return; } + + +/*-------------------------------------------------------------------* + * getTCXMode_ivas() + * + * get TCX mode + *--------------------------------------------------------------------*/ +void getTCXMode_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Decoder_State *st0, /* i : bitstream */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +) +{ + UWord16 ind; + + IF( st->tcxonly ) + { + /* get core */ + ind = get_next_indice_fx( st0, 1 ); /* Store decoder memory of last_core */ + st->core = add( ind, TCX_20_CORE ); + move16(); + /* get class */ + ind = get_next_indice_fx( st0, 2 ); + + st->clas_dec = ONSET; + move16(); + IF( ind == 0 ) + { + st->clas_dec = UNVOICED_CLAS; + move16(); + } + ELSE IF( EQ_16( ind, 1 ) ) + { + IF( GE_16( st->last_good, VOICED_TRANSITION ) ) + { + st->clas_dec = VOICED_TRANSITION; + move16(); + } + ELSE + { + st->clas_dec = UNVOICED_TRANSITION; + move16(); + } + } + ELSE IF( EQ_16( ind, 2 ) ) + { + st->clas_dec = VOICED_CLAS; + move16(); + } + + st->coder_type = INACTIVE; + move16(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) + { + st->VAD = get_next_indice_fx( st0, 1 ); + move16(); + } + ELSE + { + st->VAD = 0; + move16(); + } + } + ELSE + { + IF( EQ_16( st->mdct_sw, MODE1 ) ) + { + /* 2 bits instead of 3 as TCX is already signaled */ + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = get_next_indice_fx( st0, 2 ); + move16(); + st->coder_type = st->hTcxCfg->coder_type; + move16(); + } + ELSE + { + IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) + { + IF( get_next_indice_1_fx( st0 ) ) + { + ind = get_next_indice_fx( st0, 3 ); + assert( !( ind & 4 ) || !"HQ_CORE encountered in dec_prm_ivas" ); + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = ind; + move16(); + st->coder_type = st->hTcxCfg->coder_type; + move16(); + } + ELSE /* ACELP */ + { + st->core = ACELP_CORE; + move16(); + st->coder_type = get_next_indice_fx( st0, 2 ); + move16(); + } + } + ELSE + { + IF( EQ_16( st->rf_flag, 1 ) ) + { + IF( !st->use_partial_copy ) + { + ind = get_next_indice_fx( st0, 1 ); + IF( ind == 0 ) + { + st->core = ACELP_CORE; + move16(); + } + ELSE + { + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = st->coder_type; + move16(); + } + } + } + ELSE + { + ind = get_next_indice_fx( st, 3 ); + IF( LT_16( ind, ACELP_MODE_MAX ) ) + { + st->core = ACELP_CORE; + move16(); + st->coder_type = ind; + move16(); + } + ELSE + { + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = sub( ind, ACELP_MODE_MAX ); + move16(); + st->coder_type = st->hTcxCfg->coder_type; + move16(); + } + } + } + } + + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + test(); + IF( st->igf && EQ_16( st->core, ACELP_CORE ) ) + { + st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ); + move16(); + } + + IF( st->rf_flag ) + { + st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */ + move16(); + } + } + + /* Inactive frame detection on non-DTX mode */ + IF( EQ_16( st->coder_type, INACTIVE ) ) + { + st->VAD = 0; + move16(); + } + ELSE + { + st->VAD = 1; + move16(); + } + } + + /*Core extended mode mapping for correct PLC classification*/ + st->core_ext_mode = st->coder_type; + move16(); + if ( EQ_16( st->coder_type, INACTIVE ) ) + { + st->core_ext_mode = UNVOICED; + move16(); + } + + return; +} + +/*-------------------------------------------------------------------* + * getTCXWindowing_ivas() + * + * get TCX transform type for each subframe + *--------------------------------------------------------------------*/ +void getTCXWindowing_ivas_fx( + const Word16 core, /* i : current core */ + const Word16 last_core, /* i : last frame core */ + const Word16 element_mode, /* i : element mode */ + TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ + Decoder_State *st0 /* i : bitstream */ +) +{ + Word16 overlap_code; + + /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */ + test(); + test(); + test(); + IF( EQ_16( last_core, ACELP_CORE ) || EQ_16( last_core, AMR_WB_CORE ) ) + { + hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP; + move16(); + } + ELSE IF( EQ_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, ALDO_WINDOW ) ) + { + hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP; + move16(); + } + ELSE IF( NE_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) + { + hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; + move16(); + } + ELSE + { + hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + + /* Set the current overlap mode based on the current frame type and coded overlap mode */ + hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + + IF( NE_16( core, ACELP_CORE ) ) + { + overlap_code = 0; + move16(); + IF( get_next_indice_fx( st0, 1 ) ) + { + overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); + } + + assert( MIN_OVERLAP == 2 && HALF_OVERLAP == 3 ); + hTcxCfg->tcx_curr_overlap_mode = overlap_code; + move16(); + /*TCX10 : always symmetric windows*/ + test(); + test(); + test(); + IF( EQ_16( core, TCX_20_CORE ) && ( overlap_code == 0 ) && NE_16( last_core, ACELP_CORE ) && NE_16( last_core, AMR_WB_CORE ) ) + { + hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + } + } + + test(); + IF( NE_16( element_mode, EVS_MONO ) && EQ_16( core, TCX_10_CORE ) ) + { + /* also read last overlap */ + overlap_code = 0; + move16(); + + IF( get_next_indice_fx( st0, 1 ) ) + { + overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); + } + + hTcxCfg->tcx_last_overlap_mode = overlap_code; + move16(); + } + + return; +} + diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c deleted file mode 100644 index aca84d9d9..000000000 --- a/lib_dec/dec_tcx.c +++ /dev/null @@ -1,508 +0,0 @@ - -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "prot.h" -#include "ivas_prot.h" -#include "prot_fx.h" -#include -#include "options.h" -#include -#include "stat_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "ivas_rom_com.h" -#include "ivas_prot_fx.h" -#include "debug.h" - -/*-------------------------------------------------------------------* - * decoder_tcx_post() - * - * - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * decoder_tcx_tns() - * - * TCX: TNS application - *-------------------------------------------------------------------*/ - -void decoder_tcx_tns_fx( - Decoder_State *st, /* i/o: coder memory state */ - const Word16 L_frame_glob, /* i : frame length */ - const Word16 L_spec, - const Word16 L_frame, - const Word16 L_frameTCX, - Word32 x_fx[N_MAX], // Qx - const Word16 fUseTns, /* i : flag that is set if TNS data is present */ - STnsData *tnsData, - const Word16 bfi, /* i : Bad frame indicator */ - const Word16 frame_cnt, /* i : frame counter in the super frame */ - const Word16 whitenedDomain, - Word16 *length ) -{ - Word16 index, isTCX5, L, tmp; - TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - - index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ - move16(); - - isTCX5 = 0; - move16(); - L = L_frameTCX; - move16(); - tmp = L; - move16(); - - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) - { - test(); - test(); - IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) - { - /* fix sub-window overlap */ - hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - - test(); - test(); - test(); - IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) - { - L = L_spec; - move16(); - tmp = L; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) || - ( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) || - ( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) && - NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) ) - { - isTCX5 = 1; - move16(); - - tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); - } - } - - /*-----------------------------------------------------------* - * Temporal Noise Shaping Synthesis * - *-----------------------------------------------------------*/ - - - test(); - test(); - test(); - IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) - { - /* Apply TNS to get the reconstructed signal */ - SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); - - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) - { - tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx ); - } - - ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 ); - - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) - { - test(); - IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ - { - tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); - tmp = L_frameTCX; - move16(); - } - ELSE - { - tcx5TnsUngrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); - } - } - } - test(); - IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) ) - { - tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); - } - - /* restore index */ - test(); - test(); - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) - { - /* restore sub-window overlap */ - hTcxCfg->tcx_last_overlap_mode = index; - move16(); - } - - if ( length != NULL ) - { - *length = tmp; - move16(); - } - - return; -} - - -void decoder_tcx_imdct_fx( - Decoder_State *st, /* i/o: coder memory state */ - const Word16 L_frame_glob, /* i : frame length */ - const Word16 L_frameTCX_glob, - const Word16 L_spec, - const Word16 tcx_offset, - const Word16 tcx_offsetFB, - const Word16 L_frame, - const Word16 L_frameTCX, - const Word16 left_rect, - Word32 x_fx[N_MAX], // Q(11) - Word16 q_x, - Word16 xn_buf_fx[], // Q(-2) - Word16 q_win, - const UWord16 kernelType, /* i : TCX transform kernel type */ - const Word16 fUseTns, /* i : flag that is set if TNS data is present */ - Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ - Word16 synthFB_fx[], // Q(-2) - const Word16 bfi, /* i : Bad frame indicator */ - const Word16 frame_cnt, /* i : frame counter in the super frame */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -) -{ - Word16 j, L, overlap, curr_order, startLine, endLine, isTCX5; - Word16 overlapFB; - Word32 x_tmp_fx[L_FRAME_PLUS]; - Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 }; - Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; - Word16 acelp_zir_fx[L_FRAME_MAX / 2]; - Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; - Word16 index, proc = 0; - TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; - TCX_DEC_HANDLE hTcxDec = st->hTcxDec; - TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - Word16 predictionGain_fx; - Word16 A_itf_fx[ITF_MAX_FILTER_ORDER + 1]; // q_a_itf - Word16 q_a_itf = 15; - Word16 x_e = sub( 31, q_x ); - move16(); - Word16 shift_q = sub( q_x, q_win ); - - /*-----------------------------------------------------------------* - * Initializations - *-----------------------------------------------------------------*/ - - /* Init lengths */ - overlap = hTcxCfg->tcx_mdct_window_length; - move16(); - overlapFB = hTcxCfg->tcx_mdct_window_lengthFB; - move16(); - - index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ - move16(); - test(); - test(); - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly != 0 ) && ( frame_cnt != 0 ) && ( bfi == 0 ) && ( st->last_core != ACELP_CORE ) ) - { - /* fix sub-window overlap */ - hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - - IF( st->igf != 0 ) - { - proc = st->hIGFDec->flatteningTrigger; - move16(); - - test(); - IF( proc && fUseTns != 0 ) - { - proc = 0; - move16(); - } - - IF( proc ) - { - - startLine = st->hIGFDec->infoIGFStartLine; - move16(); - endLine = st->hIGFDec->infoIGFStopLine; - move16(); - curr_order = 0; - move16(); - predictionGain_fx = 0; - move16(); - L = L_frameTCX; - move16(); - isTCX5 = 0; - move16(); - - /* interleave again for ITF */ - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly ) - { - test(); - test(); - test(); - IF( ( hTcxCfg->fIsTNSAllowed && ( fUseTns != 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) - { - L = L_spec; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) || - ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) || - ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && - ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) ) - { - isTCX5 = 1; - move16(); - - tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); - } - } - - FOR( j = startLine; j < endLine; j++ ) - { - IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) - { - x_itf_fx[j - IGF_START_MN] = x_fx[j]; // q_x - move32(); - x_fx[j] = st->hIGFDec->virtualSpec_fx[j - IGF_START_MN]; - move32(); - } - } - - ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) ); - - ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order ); - - FOR( j = startLine; j < endLine; j++ ) - { - IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) - { - x_fx[j] = x_itf_fx[j - IGF_START_MN]; // q_x - move32(); - } - } - - /* deinterleave */ - IF( NE_16( isTCX5, 0 ) ) - { - tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); - } - } - } - - /*-----------------------------------------------------------* - * Prepare OLA buffer after waveadjustment. * - * Compute inverse MDCT of x[]. * - *-----------------------------------------------------------*/ - - - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); - set32_fx( x_tmp_fx, 0, L_FRAME_PLUS ); - Copy32( x_fx, x_tmp_fx, copy_len ); // q_x - Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x - } - ELSE IF( ( st->element_mode == EVS_MONO ) ) - { - Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - } - ELSE - { - Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) ); - Copy32( x_fx, x_tmp_fx, copy_len ); // q_x - Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x - } - - IF( ( st->igf != 0 ) ) - { - set32_fx( xn_bufFB_fx + st->hIGFDec->infoIGFStartLine, 0, L_frameTCX - st->hIGFDec->infoIGFStartLine ); - } - - test(); - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) - { - - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, - hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); - } - - /* Generate additional comfort noise to mask potential coding artefacts */ - test(); - test(); - test(); - IF( ( st->flag_cna != 0 ) && NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->cna_dirac_flag == 0 ) ) - { - generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom ); - FOR( Word16 ind = 0; ind < L_frame; ind++ ) - { - x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x - } - } - - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) - { - Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); - } - - FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) - { - xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x - move16(); - } - - Word16 ratio_e; - Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9) - ratio = shr( ratio, sub( 6, ratio_e ) ); - - IF( st->element_mode != EVS_MONO ) - { - IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, - hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); - } - ELSE - { - - IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); - } - FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) - { - xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x - } - - IF( ( bfi == 0 ) ) - { - Word16 res_m, res_e = 0; - move16(); - st->second_last_tns_active = st->last_tns_active; - move16(); - st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns; - move16(); - hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; - move32(); - hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; - move32(); - res_m = BASOP_Util_Divide1616_Scale( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max, &res_e ); - st->old_fpitch = L_add( L_shl( hTcxLtpDec->tcxltp_pitch_int, 16 ), L_shl( res_m, add( res_e, 1 ) ) ); - - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - // Using sat as a single instruction shifts and extracts - st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8 - move32(); - } - - IF( GT_16( st->element_mode, EVS_MONO ) ) - { - res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e ); - st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); - move32(); - } - ELSE - { - res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e ); - st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); - move32(); - } - } - - /* Update old_syn_overl */ - IF( hTcxCfg->last_aldo == 0 ) - { - Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) - FOR( Word16 ind = 0; ind < overlapFB; ind++ ) - { - hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x - } - } - - /* Output */ - Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) - FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) - { - synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x - } - - - return; -} - -/*-------------------------------------------------------------------* - * init_tcx_info() - * - * Initialize lengths for TCX processing, update IGF subframe info - *-------------------------------------------------------------------*/ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a0556437d..4d97367ef 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4856,3 +4856,450 @@ void decoder_tcx_noiseshaping_igf_fx( return; } + + +/*-------------------------------------------------------------------* + * decoder_tcx_tns() + * + * TCX: TNS application + *-------------------------------------------------------------------*/ + +void decoder_tcx_tns_fx( + Decoder_State *st, /* i/o: coder memory state */ + const Word16 L_frame_glob, /* i : frame length */ + const Word16 L_spec, + const Word16 L_frame, + const Word16 L_frameTCX, + Word32 x_fx[N_MAX], // Qx + const Word16 fUseTns, /* i : flag that is set if TNS data is present */ + STnsData *tnsData, + const Word16 bfi, /* i : Bad frame indicator */ + const Word16 frame_cnt, /* i : frame counter in the super frame */ + const Word16 whitenedDomain, + Word16 *length ) +{ + Word16 index, isTCX5, L, tmp; + TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; + + index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ + move16(); + + isTCX5 = 0; + move16(); + L = L_frameTCX; + move16(); + tmp = L; + move16(); + + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) + { + test(); + test(); + IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) + { + /* fix sub-window overlap */ + hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + + test(); + test(); + test(); + IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) + { + L = L_spec; + move16(); + tmp = L; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) || + ( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) || + ( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) && + NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) ) + { + isTCX5 = 1; + move16(); + + tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); + } + } + + /*-----------------------------------------------------------* + * Temporal Noise Shaping Synthesis * + *-----------------------------------------------------------*/ + + + test(); + test(); + test(); + IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) + { + /* Apply TNS to get the reconstructed signal */ + SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); + + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + { + tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx ); + } + + ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 ); + + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + { + test(); + IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + { + tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); + tmp = L_frameTCX; + move16(); + } + ELSE + { + tcx5TnsUngrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); + } + } + } + test(); + IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) ) + { + tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); + } + + /* restore index */ + test(); + test(); + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) + { + /* restore sub-window overlap */ + hTcxCfg->tcx_last_overlap_mode = index; + move16(); + } + + if ( length != NULL ) + { + *length = tmp; + move16(); + } + + return; +} + + +void decoder_tcx_imdct_fx( + Decoder_State *st, /* i/o: coder memory state */ + const Word16 L_frame_glob, /* i : frame length */ + const Word16 L_frameTCX_glob, + const Word16 L_spec, + const Word16 tcx_offset, + const Word16 tcx_offsetFB, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 left_rect, + Word32 x_fx[N_MAX], // Q(11) + Word16 q_x, + Word16 xn_buf_fx[], // Q(-2) + Word16 q_win, + const UWord16 kernelType, /* i : TCX transform kernel type */ + const Word16 fUseTns, /* i : flag that is set if TNS data is present */ + Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ + Word16 synthFB_fx[], // Q(-2) + const Word16 bfi, /* i : Bad frame indicator */ + const Word16 frame_cnt, /* i : frame counter in the super frame */ + const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ +) +{ + Word16 j, L, overlap, curr_order, startLine, endLine, isTCX5; + Word16 overlapFB; + Word32 x_tmp_fx[L_FRAME_PLUS]; + Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 }; + Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; + Word16 acelp_zir_fx[L_FRAME_MAX / 2]; + Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; + Word16 index, proc = 0; + TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; + TCX_DEC_HANDLE hTcxDec = st->hTcxDec; + TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; + Word16 predictionGain_fx; + Word16 A_itf_fx[ITF_MAX_FILTER_ORDER + 1]; // q_a_itf + Word16 q_a_itf = 15; + Word16 x_e = sub( 31, q_x ); + move16(); + Word16 shift_q = sub( q_x, q_win ); + + /*-----------------------------------------------------------------* + * Initializations + *-----------------------------------------------------------------*/ + + /* Init lengths */ + overlap = hTcxCfg->tcx_mdct_window_length; + move16(); + overlapFB = hTcxCfg->tcx_mdct_window_lengthFB; + move16(); + + index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ + move16(); + test(); + test(); + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly != 0 ) && ( frame_cnt != 0 ) && ( bfi == 0 ) && ( st->last_core != ACELP_CORE ) ) + { + /* fix sub-window overlap */ + hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + + IF( st->igf != 0 ) + { + proc = st->hIGFDec->flatteningTrigger; + move16(); + + test(); + IF( proc && fUseTns != 0 ) + { + proc = 0; + move16(); + } + + IF( proc ) + { + + startLine = st->hIGFDec->infoIGFStartLine; + move16(); + endLine = st->hIGFDec->infoIGFStopLine; + move16(); + curr_order = 0; + move16(); + predictionGain_fx = 0; + move16(); + L = L_frameTCX; + move16(); + isTCX5 = 0; + move16(); + + /* interleave again for ITF */ + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly ) + { + test(); + test(); + test(); + IF( ( hTcxCfg->fIsTNSAllowed && ( fUseTns != 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) + { + L = L_spec; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) || + ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) || + ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && + ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) ) + { + isTCX5 = 1; + move16(); + + tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); + } + } + + FOR( j = startLine; j < endLine; j++ ) + { + IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) + { + x_itf_fx[j - IGF_START_MN] = x_fx[j]; // q_x + move32(); + x_fx[j] = st->hIGFDec->virtualSpec_fx[j - IGF_START_MN]; + move32(); + } + } + + ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) ); + + ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order ); + + FOR( j = startLine; j < endLine; j++ ) + { + IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) + { + x_fx[j] = x_itf_fx[j - IGF_START_MN]; // q_x + move32(); + } + } + + /* deinterleave */ + IF( NE_16( isTCX5, 0 ) ) + { + tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); + } + } + } + + /*-----------------------------------------------------------* + * Prepare OLA buffer after waveadjustment. * + * Compute inverse MDCT of x[]. * + *-----------------------------------------------------------*/ + + + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); + set32_fx( x_tmp_fx, 0, L_FRAME_PLUS ); + Copy32( x_fx, x_tmp_fx, copy_len ); // q_x + Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x + } + ELSE IF( ( st->element_mode == EVS_MONO ) ) + { + Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x + } + ELSE + { + Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) ); + Copy32( x_fx, x_tmp_fx, copy_len ); // q_x + Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x + } + + IF( ( st->igf != 0 ) ) + { + set32_fx( xn_bufFB_fx + st->hIGFDec->infoIGFStartLine, 0, L_frameTCX - st->hIGFDec->infoIGFStartLine ); + } + + test(); + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) + { + + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, + hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); + } + + /* Generate additional comfort noise to mask potential coding artefacts */ + test(); + test(); + test(); + IF( ( st->flag_cna != 0 ) && NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->cna_dirac_flag == 0 ) ) + { + generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom ); + FOR( Word16 ind = 0; ind < L_frame; ind++ ) + { + x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x + } + } + + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) + { + Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x + + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); + } + + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) + { + xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x + move16(); + } + + Word16 ratio_e; + Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9) + ratio = shr( ratio, sub( 6, ratio_e ) ); + + IF( st->element_mode != EVS_MONO ) + { + IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, + hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + } + ELSE + { + + IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + } + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) + { + xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x + } + + IF( ( bfi == 0 ) ) + { + Word16 res_m, res_e = 0; + move16(); + st->second_last_tns_active = st->last_tns_active; + move16(); + st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns; + move16(); + hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; + move32(); + hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; + move32(); + res_m = BASOP_Util_Divide1616_Scale( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max, &res_e ); + st->old_fpitch = L_add( L_shl( hTcxLtpDec->tcxltp_pitch_int, 16 ), L_shl( res_m, add( res_e, 1 ) ) ); + + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + // Using sat as a single instruction shifts and extracts + st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8 + move32(); + } + + IF( GT_16( st->element_mode, EVS_MONO ) ) + { + res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e ); + st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + move32(); + } + ELSE + { + res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e ); + st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + move32(); + } + } + + /* Update old_syn_overl */ + IF( hTcxCfg->last_aldo == 0 ) + { + Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) + FOR( Word16 ind = 0; ind < overlapFB; ind++ ) + { + hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x + } + } + + /* Output */ + Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) + FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) + { + synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x + } + + + return; +} + diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c deleted file mode 100644 index dd3adb247..000000000 --- a/lib_dec/fd_cng_dec.c +++ /dev/null @@ -1,1393 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_rom_dec.h" -#include "ivas_rom_com_fx.h" -#include "prot_fx.h" -#include "ivas_prot_fx.h" -#include "basop_util.h" -#include "rom_basop_util.h" - -/*------------------------------------------------------------------- - * Local constants - *-------------------------------------------------------------------*/ - -#define DELTA_MASKING_NOISE_Q15 0 -#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ -#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ -#define LOG_10_BASE_2 1783446566 /* Q29 */ -#define GAIN_Q_OFFSET_IVAS_FX 45 -#define LOG_10_BASE_2_BY_10_Q31 713378606 -#define TWO_BY_THREE_Q31 1431655765 -#define ONE_BY_FRAMES_PER_SEC_Q15 656 -#define NB_LAST_BAND_SCALE_Q31 1717986918 -#define SWB_13k2_LAST_BAND_SCALE_Q31 1717986918 - -/*------------------------------------------------------------------- - * Local fucntions declarations - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * createFdCngDec() - * - * Create an instance of type FD_CNG - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * initFdCngDec() - * - * Initialize an instance of type FD_CNG - *-------------------------------------------------------------------*/ -void configureFdCngDec_ivas_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, /*Q0*/ - const Word32 total_brate, /*Q0*/ - const Word16 L_frame, /*Q0*/ - const Word16 last_L_frame, /*Q0*/ - const Word16 element_mode /*Q0*/ ) -{ - Word16 j, stopBandFR; - HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom; - - hsCom->CngBandwidth = bwidth; /*Q0*/ - move16(); - if ( EQ_16( hsCom->CngBandwidth, FB ) ) - { - hsCom->CngBandwidth = SWB; - move16(); - } - test(); - IF( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) ) - { - hsCom->CngBitrate = total_brate; /*Q0*/ - move32(); - } - ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) ) - { - /* set minimum active CBR bitrate IF CngBitrate is uninitialized */ - IF( element_mode > EVS_MONO ) - { - hsCom->CngBitrate = IVAS_13k2; - move32(); - } - ELSE - { - hsCom->CngBitrate = ACELP_7k20; - move32(); - } - } - - /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */ - /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */ - if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) - { - hsCom->CngBitrate = IVAS_48k; - move32(); - } - hsCom->numSlots = 16; - move32(); - - /* NB configuration */ - IF( EQ_16( bwidth, NB ) ) - { - hsCom->FdCngSetup = FdCngSetup_nb; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 16; - move16(); - } - - /* WB configuration */ - ELSE IF( EQ_16( bwidth, WB ) ) - { - /* FFT 6.4kHz, no CLDFB */ - test(); - test(); - IF( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) ) - { - hsCom->FdCngSetup = FdCngSetup_wb1; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 16; - move16(); - } - /* FFT 6.4kHz, CLDFB 8.0kHz */ - ELSE IF( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) ) - { - hsCom->FdCngSetup = FdCngSetup_wb2; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 20; - move16(); - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - hsCom->FdCngSetup = FdCngSetup_wb2; - hsCom->numCoreBands = 20; - move16(); - hsCom->regularStopBand = 20; - move16(); - hsCom->FdCngSetup.fftlen = 640; - move16(); - hsCom->FdCngSetup.stopFFTbin = 256; - move16(); - } - } - /* FFT 8.0kHz, no CLDFB */ - ELSE - { - hsCom->FdCngSetup = FdCngSetup_wb3; - hsCom->numCoreBands = 20; - move16(); - hsCom->regularStopBand = 20; - move16(); - } - } - - /* SWB/FB configuration */ - ELSE - { - /* FFT 6.4kHz, CLDFB 14kHz */ - IF( EQ_16( L_frame, L_FRAME ) ) - { - hsCom->FdCngSetup = FdCngSetup_swb1; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 35; - move16(); - } - /* FFT 8.0kHz, CLDFB 16kHz */ - ELSE - { - hsCom->FdCngSetup = FdCngSetup_swb2; - hsCom->numCoreBands = 20; - move16(); - hsCom->regularStopBand = 40; - move16(); - test(); - if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - hsCom->regularStopBand = 35; - move16(); - } - } - } - - - hsCom->fftlen = hsCom->FdCngSetup.fftlen; - move16(); - hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin; - move16(); - - /* Configure the SID quantizer and the Comfort Noise Generator */ - - hsCom->startBand = 2; - move16(); - hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/ - initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 ); - - IF( EQ_16( hsCom->stopFFTbin, 160 ) ) - { - hsCom->nFFTpart = 17; - move16(); - } - ELSE IF( EQ_16( hsCom->stopFFTbin, 256 ) ) - { - hsCom->nFFTpart = 20; - move16(); - } - ELSE - { - hsCom->nFFTpart = 21; - move16(); - } - hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /*Q0*/ - move16(); - FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) - { - hsCom->CLDFBpart[j] = sub( hsCom->part[( j + hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); /*Q0*/ - move16(); - hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )]; - move16(); - } - - stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/); - move16(); - if ( GT_16( stopBandFR, hsCom->stopFFTbin ) ) - { - stopBandFR = hsCom->stopFFTbin; /*Q0*/ - move16(); - } - - initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR ); - - hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/ - move16(); - - BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); - BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); - - SWITCH( hsCom->fftlen ) - { - case 512: - hsCom->olapWinAna_fx = olapWinAna512_fx; /*Q30*/ - hsCom->fftSineTab_fx = NULL; - hsCom->olapWinSyn_fx = olapWinSyn256_fx; /*Q15*/ - hsCom->fftlenShift = 8; - move16(); - hsCom->fftlenFac = 32767 /*1.0 Q15*/; - move16(); - BREAK; - case 640: - hsCom->olapWinAna_fx = olapWinAna640_fx; /*Q30*/ - hsCom->fftSineTab_fx = fftSineTab640_fx; /*Q15*/ - hsCom->olapWinSyn_fx = olapWinSyn320_fx; /*Q15*/ - hsCom->fftlenShift = 9; - move16(); - hsCom->fftlenFac = 20480 /*0.625 Q15*/; - move16(); - BREAK; - default: - assert( !"Unsupported FFT length for FD-based CNG" ); - BREAK; - } - BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); - BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); - hsCom->frameSize = shr( hsCom->fftlen, 1 ); - - return; -} - -/*------------------------------------------------------------------- - * deleteFdCngDec() - * - * Delete the instance of type FD_CNG - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * ApplyFdCng() - * - * Apply the CLDFB-based CNG at the decoder - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * FdCng_decodeSID() - * - * Decode the FD-CNG bitstream - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * FdCng_decodeSID_ivas_fx() - * - * Decode the FD-CNG bitstream - *-------------------------------------------------------------------*/ - -void FdCng_decodeSID_ivas_fx( - Decoder_State *st /* i/o: decoder state structure */ -) -{ - Word16 N; - Word32 *sidNoiseEst; - Word32 gain; - Word16 i, index; - Word32 v[32]; - Word16 indices[32]; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word16 tmp16; - - IF( st->element_mode == EVS_MONO ) - { - tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; - move16(); - } - ELSE - { - tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; - move16(); - } - - const Word16 gain_q_offset = tmp16; /* Q0 */ - move16(); - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ - - hFdCngCom = ( st->hFdCngDec )->hFdCngCom; - - sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q16*/ - - N = hFdCngCom->npart; /*Q0*/ - move16(); - gain = 0; - move32(); - hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); - move16(); - - /* Read bitstream */ - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/ - move16(); - } - - index = get_next_indice_fx( st, 7 ); - - /* MSVQ decoder */ - - IF( st->element_mode != EVS_MONO ) - { - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); - } - ELSE - { /* Legacy EVS_MONO MSVQ tables */ - msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); - } - - - /* Decode gain */ - // gain = ((float)index - gain_q_offset) / 1.5f; - gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15 - - /* Apply gain and undo log */ - Word16 res_exp[NPART]; - Word16 max_res_exp = 0; - move16(); - FOR( i = 0; i < N; i++ ) - { - sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/ - move32(); - if ( LT_16( max_res_exp, res_exp[i] ) ) - { - max_res_exp = res_exp[i]; - move16(); - } - } - - FOR( i = 0; i < N; i++ ) - { - sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); /*Q31 - max_res_exp*/ - move32(); - } - - hFdCngCom->sidNoiseEstExp = max_res_exp; - move16(); - - /* NB last band energy compensation */ - - IF( hFdCngCom->CngBandwidth == NB ) - { - sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ - move32(); - } - - test(); - IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ - move32(); - } - - scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac ); - - return; -} - -/*------------------------------------------------------------------- - * noisy_speech_detection() - * - * - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * generate_comfort_noise_dec() - * - * Generate the comfort noise based on the target noise level - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * generate_masking_noise() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * generate_masking_noise_ivas_fx() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_masking_noise_ivas_fx( - Word32 *timeDomainBuffer, /* i/o: time-domain signal Q31 - *exp_out*/ - Word16 *exp_out, /* o : time-domain signal exp */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 length, /* i : frame size Q0*/ - const Word16 core, /* i : core Q0*/ - const Word16 return_noise, /* i : noise is returned instead of added Q0*/ - const Word16 secondary, /* i : flag to indicate secondary noise generation Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels Q0*/ -) -{ - Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel; - Word32 *ptr_level_fx = cngNoiseLevel_fx; - Word32 *fftBuffer_fx = hFdCngCom->fftBuffer; - Word16 i; - Word32 maskingNoise_fx[L_FRAME16k]; - Word32 *ptr_r_fx; - Word32 *ptr_i_fx; - Word16 startBand; - Word16 *seed = &( hFdCngCom->seed ); - Word32 scale_fx; - Word16 shift; - scale_fx = 0x40000000; // 1.0 in Q30 - move32(); - startBand = hFdCngCom->startBand; /*Q0*/ - move16(); - shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) - { - shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); /*Q0*/ - } - scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); /*hFdCngCom->cngNoiseLevelExp*/ - hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift ); - move16(); - - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - *exp_out = Q15; - move16(); - IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) - { - IF( NE_16( core, AMR_WB_CORE ) ) - { - /* Compute additional CN level */ - FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ ) - { - test(); - test(); - if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && - GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && - LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) - { - BREAK; - } - } - - scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */ - } - ELSE - { - /* Compute additional CN level */ - FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ ) - { - if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) - { - BREAK; - } - } - - IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) ) - { - scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */ - } - ELSE - { - scale_fx = 0; - move32(); - } - } - - /* Exclude clean speech */ - scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); // Q30 - - /* Generate Gaussian random noise in real and imaginary parts of the FFT bins - Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ - IF( startBand == 0 ) - { - rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 - ptr_r_fx = fftBuffer_fx + 2; /*Q31 - hFdCngCom->fftBuffer_exp*/ - Word16 exp1; - exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 ); - Word32 mpy1; - mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); /*Q31 - exp1*/ - mpy1 = L_shl( mpy1, exp1 ); // Q31 - fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15 - ptr_level_fx++; - } - ELSE - { - fftBuffer_fx[0] = 0; - move32(); - set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) ); - ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ - } - ptr_i_fx = ptr_r_fx + 1; - FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ ) - { - /* Real part in FFT bins */ - rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 - Word16 exp2; - exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 ); - Word32 mpy2; - mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); /*Q31 - exp2*/ - ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 - move32(); - ptr_r_fx += 2; - - /* Imaginary part in FFT bins */ - rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15 - ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15 - ptr_i_fx += 2; - } - - /* Remaining FFT bins are set to zero */ - set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); - /* Nyquist frequency is discarded */ - fftBuffer_fx[1] = 0; - move32(); - } - ELSE - { - /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */ - generate_masking_noise_update_seed_fx( hFdCngCom ); - - set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen ); - } - - /* Perform STFT synthesis */ - IF( secondary ) - { - SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); - } - ELSE - { - SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); - } - *exp_out = sub( *exp_out, Q9 ); - move16(); - - /* Add some comfort noise on top of decoded signal */ - IF( return_noise ) - { - Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ - } - ELSE - { - v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ - } - - return; -} - -/*------------------------------------------------------------------- - * generate_masking_noise_update_seed() - * - * Update seed for scenarios where generate_masking_noise() is - * not called based on signal statistics - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * generate_stereo_masking_noise_fx() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_stereo_masking_noise_fx( - Word16 *syn, /* i/o: time-domain signal Q_syn*/ - Word16 Q_syn, - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/ - const Word16 fadeOut, /* i : only fade out of previous state Q0*/ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels Q0*/ -) -{ - HANDLE_FD_CNG_COM hFdCngCom; - Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/; - Word32 Np_fx[L_FRAME16k]; - Word32 Ns_fx[L_FRAME16k]; - Word32 N1_fx[L_FRAME16k]; - Word32 N2_fx[L_FRAME16k]; - Word16 N1_fx_exp, N2_fx_exp; - Word16 i; - - IF( st->idchan == 0 ) - { - hFdCngCom = st->hFdCngDec->hFdCngCom; -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ -#else - Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ -#endif - Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ - - set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); - set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); - - IF( !fadeOut ) - { -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ -#else - Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ -#endif - generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 - /* Generate masking noise for secondary channel */ - IF( flag_sec_CNA ) - { - generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6 - gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); /*Q30*/ - scale_fx = ONE_IN_Q30; - move32(); - IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) ) - { - Word16 exp_gamma; - exp_gamma = 0; - move16(); - Word16 divisor1; - divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma - gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30 - Word16 exp_gamma1, exp_gamma2, exp_gamma3; - exp_gamma1 = Q1; - exp_gamma2 = Q1; - exp_gamma3 = Q1; - move16(); - move16(); - move16(); - gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); /*Q31 - exp_gamma1*/ - Word32 temp; - temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 - gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1 - gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30 - Word32 divisor2; - divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3 - scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30 - } - ELSE - { - gamma_fx = 0; - move16(); - } - - FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) - { - Np_fx[i] = L_add( Np_fx[i], - Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6 - move32(); - Word32 add2; - add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - if ( hStereoCng->c_PS_LT_fx < 0 ) - { - add2 = L_negate( add2 ); /*Q6*/ - } - Ns_fx[i] = L_add( Ns_fx[i], add2 ); /*Q6*/ - move32(); - } - FOR( ; i < hFdCngCom->frameSize; i++ ) - { - Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - move32(); - Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - move32(); - IF( hStereoCng->c_PS_LT_fx < 0 ) - { - Ns_fx[i] = L_negate( Ns_fx[i] ); - move32(); - } - } - /* Below code to be converted */ - Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21 - FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) - { - hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, - L_add( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), - Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), - Q14 ); // Q_olap - move16(); - hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, - L_sub( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), - Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), - Q14 ); // Q_olap - move16(); - } - } - ELSE - { - FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) - { - Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 - move32(); - } - Copy32( &N1_fx[( hFdCngCom->frameSize / 2 )], &Np_fx[( hFdCngCom->frameSize / 2 )], shr( hFdCngCom->frameSize, 1 ) ); /*Q6*/ - scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21 - FOR( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ), Q6 ); // Q_olap - move16(); - } - } - - Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); /*st->Q_syn*/ - } - ELSE - { - set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) ); - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) ); - } - IF( flag_sec_CNA ) - { - Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6 - hStereoCng->enableSecCNA = 1; - move16(); - } - ELSE - { - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize ); - } - - /* add masking noise */ - FOR( i = 0; i < hFdCngCom->frameSize; i++ ) - { - syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn - move16(); - } - } - ELSE IF( hStereoCng->enableSecCNA ) - { - Word16 SP_ratio_fx; - SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis Q15*/ - Word16 prevSP_ratio_fx; - prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis Q15*/ - move16(); - /* scale and add masking noise */ - FOR( i = 0; i < shr( *hStereoCng->frameSize, 2 ); i++ ) - { - Word16 s; - Word16 scale_fx_tmp; - scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15 - scale_fx_tmp = shl( scale_fx_tmp, s ); - syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ - move16(); - } - FOR( ; i < *hStereoCng->frameSize / 2; i++ ) - { - syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ - move16(); - } - FOR( ; i < *hStereoCng->frameSize; i++ ) - { - syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ - move16(); - } - hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /*Q15*/ - move16(); - } - - return; -} -void generate_masking_noise_lb_dirac_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - Word32 *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA Q11*/ - const Word16 nCldfbTs, /* i : number of CLDFB slots that will be rendered Q0*/ - const Word16 cna_flag /* i : CNA flag for LB and HB Q0*/ -) -{ - Word16 i; - Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ - Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/ - Word32 *ptr_r; - Word32 *ptr_i; - Word32 *ptr_level; - Word16 *seed = &( hFdCngCom->seed ); - Word32 scale; - Word16 n_samples_out, n_samples_start, n_samples_out_loop; - - push_wmops( "fd_cng_dirac" ); - - /* Init */ - scale = 0; - move32(); - n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs ); - n_samples_start = 0; - move16(); - Word16 exp_out = Q11; - move16(); - /*LB CLDFB - CNA from STFT*/ - IF( cna_flag ) - { - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) - { - /* Compute additional CN level */ - FOR( i = 0; i < 15; i++ ) - { - test(); - test(); - if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && - GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && - LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) - { - BREAK; - } - } - - scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */ - scale = Mpy_32_16_1( scale, hFdCngCom->likelihood_noisy_speech ); /* Q30 */ - } - } - - /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ - test(); - IF( cna_flag && tdBuffer != NULL ) - { - WHILE( n_samples_out > 0 ) - { - n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out ); - IF( scale != 0 ) - { - /*Generate LF comfort noise only at first slot, for the whole frame*/ - ptr_level = cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ - - /* Generate Gaussian random noise in real and imaginary parts of the FFT bins - Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ - IF( EQ_16( hFdCngCom->startBand, 0 ) ) - { - rand_gauss_fx( &fftBuffer[0], seed, exp_out ); - ptr_r = fftBuffer + 2; /*hFdCngCom->fftBuffer_exp*/ - - Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); - Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT Q31 - exp2*/ - sqr = L_shl( sqr, exp2 ); /*Q31*/ - fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT Q31 - hFdCngCom->fftBuffer_exp*/ - move32(); - ptr_level++; - } - ELSE - { - fftBuffer[0] = 0; - move32(); - set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) ); - ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); /*hFdCngCom->fftBuffer_exp*/ - } - ptr_i = ptr_r + 1; /*hFdCngCom->fftBuffer_exp*/ - - FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) - { - rand_gauss_fx( ptr_r, seed, exp_out ); - Word16 exp2 = hFdCngCom->cngNoiseLevelExp; - Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); /*Q31 - exp2*/ - ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ - move32(); - ptr_r += 2; - - /* Imaginary part in FFT bins */ - rand_gauss_fx( ptr_i, seed, exp_out ); - ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ - move32(); - ptr_i += 2; - } - /* Remaining FFT bins are set to zero */ - set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); - /* Nyquist frequency is discarded */ - fftBuffer[1] = 0; - move32(); - - /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); - scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 - } - - ELSE - { - /* very low level case - update random seeds */ - generate_masking_noise_update_seed_fx( hFdCngCom ); - - set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); - /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); - } - hFdCngCom->fftBuffer_exp = 31 - 11; - move16(); - n_samples_out = sub( n_samples_out, hFdCngCom->frameSize ); - n_samples_start = add( n_samples_start, hFdCngCom->frameSize ); - } - } - - pop_wmops(); - - return; -} -void generate_masking_noise_dirac_ivas_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA q_input*/ - Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer q_cldfb*/ - Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer q_cldfb*/ - const Word16 slot_index, /* i : CLDFB slot index Q0*/ - const Word16 cna_flag, /* i : CNA flag for LB and HB Q0*/ - const Word16 fd_cng_flag, /* i : FD-CNG flag for HB Q0*/ - Word16 q_input, - Word16 *q_cldfb ) -{ - Word16 i; - Word32 *ptr_level_fx; - Word16 *seed = &( hFdCngCom->seed ); - Word32 scale_fx; - Word16 q_scale, q_shift, q_ptr_level; - - push_wmops( "fd_cng_dirac" ); - - /* Init */ - scale_fx = 0; - move32(); - - /* Resample CLDFB memories if necessary*/ - IF( NE_16( i_mult( h_cldfb->no_channels, h_cldfb->no_col ), hFdCngCom->frameSize ) ) - { - resampleCldfb_ivas_fx( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC ); - } - - set32_fx( Cldfb_RealBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); - - /*LB CLDFB - CNA from STFT*/ - IF( cna_flag != 0 ) - { - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - IF( hFdCngCom->likelihood_noisy_speech > 0 ) - { - /* Compute additional CN level */ - FOR( i = 0; i < 15; i++ ) - { - test(); - test(); - if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && - ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) && - ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) ) - { - BREAK; - } - } - - scale_fx = L_shr( L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ), Q3 ); /* Q27 */ - scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); - } - } - /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ - IF( cna_flag && tdBuffer_fx != NULL ) - { - *q_cldfb = q_input; - move16(); - IF( scale_fx != 0 ) - { - /* LF CLDFB*/ - cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); - } - ELSE - { - /* LB ana CLDFB*/ - cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); - } - } - - /*HF CLDFB - CNA and/or FD-CNG*/ - if ( fd_cng_flag ) - { - scale_fx = L_add( scale_fx, ONE_IN_Q27 ); // 1 in Q27 - } - IF( scale_fx != 0 ) - { - q_scale = 27; - move16(); - q_shift = norm_l( scale_fx ); - scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ - q_scale = add( q_scale, q_shift ); - scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34 - q_scale = sub( add( q_scale, 2 * Q8 ), 31 ); - ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/ - q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp ); - - FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) - { - Word32 num; - Word16 exp, q_num; - q_shift = norm_l( scale_fx ); - scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ - q_scale = add( q_scale, q_shift ); - num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/ - q_num = sub( add( q_scale, q_ptr_level ), 31 ); - exp = sub( 31, q_num ); - num = Sqrt32( num, &exp ); /*Q31 - exp*/ - /* Real part in CLDFB band */ - rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb ); - Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp ); - move32(); - /* Imaginary part in CLDFB band */ - rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb ); - Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp ); - move32(); - - ptr_level_fx++; - } - } - - pop_wmops(); - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeMDCTStereoSID() - * - * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream - * - *-------------------------------------------------------------------*/ - -void FdCngDecodeMDCTStereoSID_fx( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word32 *lr_ptr_fx[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 indices[FD_CNG_stages_37bits]; - Word16 N, i, ch, p, stages; - Word16 is_out_ms; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word16 shift, exp_diff, max_exp_idx; - Word16 exp_arr[NPART]; - Word32 tmp32, tmp32_arr[NPART]; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 - - is_out_ms = 0; - move16(); - if ( hCPE->hCoreCoder[0]->cng_sba_flag ) - { - is_out_ms = 1; - move16(); - } - - N = 0; /* to avoid compilation warning */ - move16(); - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ - lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q18*/ - } - - /* decode noise shapes and gains */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; - move16(); - hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /*Q0*/ - move16(); - - IF( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - move16(); - } - ELSE - { - stages = FD_CNG_stages_37bits; - move16(); - } - - /* read bitstream */ - FOR( i = 0; i < stages; i++ ) - { - indices[i] = get_next_indice_fx( sts[ch], bits_37bits[i] ); /*Q0*/ - move16(); - } - { - gain_fx[ch] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[ch], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 - move32(); - } - - /* MSVQ decoder */ - shift = find_guarded_bits_fx( N ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); // Q20 - shift - - Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20 - } - - dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) ); - - IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) - { - set32_fx( ms_ptr_fx[1], 0, NPART ); - } - - IF( EQ_16( is_out_ms, 0 ) ) - { - inverseMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); - } - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - max_exp_idx = 0; - move16(); - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - FOR( p = 0; p < N; p++ ) - { - tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 - tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ - move32(); - if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) - { - max_exp_idx = p; /*Q0*/ - move16(); - } - } - - // Bringing in same exponent - FOR( p = 0; p < N; p++ ) - { - lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q31 - exp_arr[max_exp_idx]*/ - move32(); - } - - hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; - move16(); - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - - test(); - IF( EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); - move16(); - FOR( p = 0; p < N; p++ ) - { - IF( GT_16( exp_diff, 0 ) ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ - move32(); - } - ELSE - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ - move32(); - } - } - IF( LT_16( exp_diff, 0 ) ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); - move16(); - } - } - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeDiracMDCTStereoSID_fx() - * - * Decode FD-CNG parameters for CNG in 2TC DirAC mode from the bitstream - *-------------------------------------------------------------------*/ - -void FdCngDecodeDiracMDCTStereoSID_fx( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word32 *lr_ptr_fx[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 indices[FD_CNG_stages_37bits]; - Word16 N, i, ch, p; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word16 shift, exp_diff, max_exp_idx; - Word16 exp_arr[NPART]; - Word32 tmp32, tmp32_arr[NPART]; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ - lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q20*/ - ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; /*Q18*/ - } - - /* decode noise shapes and gains */ - hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; /*Q0*/ - move16(); - - /* read bitstream */ - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - indices[i] = get_next_indice_fx( sts[0], bits_37bits[i] ); /*Q0*/ - move16(); - } - gain_fx[0] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[0], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 - move32(); - - gain_fx[1] = gain_fx[0]; /*Q20*/ - move32(); - - /* MSVQ decoder */ - shift = find_guarded_bits_fx( N ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); // Q20 - shift - - Scale_sig32( ms_ptr_fx[0], N, shift ); // Q20 - - Copy32( ms_ptr_fx[0], ms_ptr_fx[1], N ); /*Q20*/ - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - max_exp_idx = 0; - move16(); - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - - FOR( p = 0; p < N; p++ ) - { - tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 - tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ - move32(); - if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) - { - max_exp_idx = p; /*Q0*/ - move16(); - } - } - - // Bringing in same exponent - FOR( p = 0; p < N; p++ ) - { - lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q20*/ - move32(); - } - - hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; /*Q0*/ - move16(); - - /* NB last band energy compensation */ - test(); - IF( hFdCngCom->CngBandwidth == NB ) - { - lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], NB_LAST_BAND_SCALE_Q31 ); /*Q20*/ - move32(); - } - ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); /*Q20*/ - move32(); - } - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0; - move16(); - sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0; - move16(); - - IF( EQ_16( hCPE->nchan_out, 1 ) ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); - FOR( p = 0; p < N; p++ ) - { - IF( exp_diff > 0 ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ - move32(); - } - ELSE - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ - move32(); - } - } - IF( exp_diff < 0 ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); - move16(); - } - } - - return; -} diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 8a902448f..f788144fa 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -24,6 +24,14 @@ #define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */ #define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */ #define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ +#define DELTA_MASKING_NOISE_Q15 0 +#define LOG_10_BASE_2 1783446566 /* Q29 */ +#define GAIN_Q_OFFSET_IVAS_FX 45 +#define LOG_10_BASE_2_BY_10_Q31 713378606 +#define TWO_BY_THREE_Q31 1431655765 +#define ONE_BY_FRAMES_PER_SEC_Q15 656 +#define NB_LAST_BAND_SCALE_Q31 1717986918 +#define SWB_13k2_LAST_BAND_SCALE_Q31 1717986918 /******************************** * External tables * @@ -5025,6 +5033,1278 @@ void generate_masking_noise_mdct_ivas_fx( return; } + +/*------------------------------------------------------------------- + * initFdCngDec() + * + * Initialize an instance of type FD_CNG + *-------------------------------------------------------------------*/ +void configureFdCngDec_ivas_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, /*Q0*/ + const Word32 total_brate, /*Q0*/ + const Word16 L_frame, /*Q0*/ + const Word16 last_L_frame, /*Q0*/ + const Word16 element_mode /*Q0*/ ) +{ + Word16 j, stopBandFR; + HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom; + + hsCom->CngBandwidth = bwidth; /*Q0*/ + move16(); + if ( EQ_16( hsCom->CngBandwidth, FB ) ) + { + hsCom->CngBandwidth = SWB; + move16(); + } + test(); + IF( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) ) + { + hsCom->CngBitrate = total_brate; /*Q0*/ + move32(); + } + ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) ) + { + /* set minimum active CBR bitrate IF CngBitrate is uninitialized */ + IF( element_mode > EVS_MONO ) + { + hsCom->CngBitrate = IVAS_13k2; + move32(); + } + ELSE + { + hsCom->CngBitrate = ACELP_7k20; + move32(); + } + } + + /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */ + /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */ + if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) + { + hsCom->CngBitrate = IVAS_48k; + move32(); + } + hsCom->numSlots = 16; + move32(); + + /* NB configuration */ + IF( EQ_16( bwidth, NB ) ) + { + hsCom->FdCngSetup = FdCngSetup_nb; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 16; + move16(); + } + + /* WB configuration */ + ELSE IF( EQ_16( bwidth, WB ) ) + { + /* FFT 6.4kHz, no CLDFB */ + test(); + test(); + IF( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) ) + { + hsCom->FdCngSetup = FdCngSetup_wb1; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 16; + move16(); + } + /* FFT 6.4kHz, CLDFB 8.0kHz */ + ELSE IF( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) ) + { + hsCom->FdCngSetup = FdCngSetup_wb2; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 20; + move16(); + IF( EQ_16( L_frame, L_FRAME16k ) ) + { + hsCom->FdCngSetup = FdCngSetup_wb2; + hsCom->numCoreBands = 20; + move16(); + hsCom->regularStopBand = 20; + move16(); + hsCom->FdCngSetup.fftlen = 640; + move16(); + hsCom->FdCngSetup.stopFFTbin = 256; + move16(); + } + } + /* FFT 8.0kHz, no CLDFB */ + ELSE + { + hsCom->FdCngSetup = FdCngSetup_wb3; + hsCom->numCoreBands = 20; + move16(); + hsCom->regularStopBand = 20; + move16(); + } + } + + /* SWB/FB configuration */ + ELSE + { + /* FFT 6.4kHz, CLDFB 14kHz */ + IF( EQ_16( L_frame, L_FRAME ) ) + { + hsCom->FdCngSetup = FdCngSetup_swb1; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 35; + move16(); + } + /* FFT 8.0kHz, CLDFB 16kHz */ + ELSE + { + hsCom->FdCngSetup = FdCngSetup_swb2; + hsCom->numCoreBands = 20; + move16(); + hsCom->regularStopBand = 40; + move16(); + test(); + if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) + { + hsCom->regularStopBand = 35; + move16(); + } + } + } + + + hsCom->fftlen = hsCom->FdCngSetup.fftlen; + move16(); + hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin; + move16(); + + /* Configure the SID quantizer and the Comfort Noise Generator */ + + hsCom->startBand = 2; + move16(); + hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/ + initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 ); + + IF( EQ_16( hsCom->stopFFTbin, 160 ) ) + { + hsCom->nFFTpart = 17; + move16(); + } + ELSE IF( EQ_16( hsCom->stopFFTbin, 256 ) ) + { + hsCom->nFFTpart = 20; + move16(); + } + ELSE + { + hsCom->nFFTpart = 21; + move16(); + } + hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /*Q0*/ + move16(); + FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) + { + hsCom->CLDFBpart[j] = sub( hsCom->part[( j + hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); /*Q0*/ + move16(); + hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )]; + move16(); + } + + stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/); + move16(); + if ( GT_16( stopBandFR, hsCom->stopFFTbin ) ) + { + stopBandFR = hsCom->stopFFTbin; /*Q0*/ + move16(); + } + + initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR ); + + hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/ + move16(); + + BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); + BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); + + SWITCH( hsCom->fftlen ) + { + case 512: + hsCom->olapWinAna_fx = olapWinAna512_fx; /*Q30*/ + hsCom->fftSineTab_fx = NULL; + hsCom->olapWinSyn_fx = olapWinSyn256_fx; /*Q15*/ + hsCom->fftlenShift = 8; + move16(); + hsCom->fftlenFac = 32767 /*1.0 Q15*/; + move16(); + BREAK; + case 640: + hsCom->olapWinAna_fx = olapWinAna640_fx; /*Q30*/ + hsCom->fftSineTab_fx = fftSineTab640_fx; /*Q15*/ + hsCom->olapWinSyn_fx = olapWinSyn320_fx; /*Q15*/ + hsCom->fftlenShift = 9; + move16(); + hsCom->fftlenFac = 20480 /*0.625 Q15*/; + move16(); + BREAK; + default: + assert( !"Unsupported FFT length for FD-based CNG" ); + BREAK; + } + BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); + BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); + hsCom->frameSize = shr( hsCom->fftlen, 1 ); + + return; +} + +/*------------------------------------------------------------------- + * FdCng_decodeSID_ivas_fx() + * + * Decode the FD-CNG bitstream + *-------------------------------------------------------------------*/ + +void FdCng_decodeSID_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +) +{ + Word16 N; + Word32 *sidNoiseEst; + Word32 gain; + Word16 i, index; + Word32 v[32]; + Word16 indices[32]; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 tmp16; + + IF( st->element_mode == EVS_MONO ) + { + tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; + move16(); + } + ELSE + { + tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; + move16(); + } + + const Word16 gain_q_offset = tmp16; /* Q0 */ + move16(); + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ + + hFdCngCom = ( st->hFdCngDec )->hFdCngCom; + + sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q16*/ + + N = hFdCngCom->npart; /*Q0*/ + move16(); + gain = 0; + move32(); + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); + move16(); + + /* Read bitstream */ + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/ + move16(); + } + + index = get_next_indice_fx( st, 7 ); + + /* MSVQ decoder */ + + IF( st->element_mode != EVS_MONO ) + { + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); + } + ELSE + { /* Legacy EVS_MONO MSVQ tables */ + msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); + } + + + /* Decode gain */ + // gain = ((float)index - gain_q_offset) / 1.5f; + gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15 + + /* Apply gain and undo log */ + Word16 res_exp[NPART]; + Word16 max_res_exp = 0; + move16(); + FOR( i = 0; i < N; i++ ) + { + sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/ + move32(); + if ( LT_16( max_res_exp, res_exp[i] ) ) + { + max_res_exp = res_exp[i]; + move16(); + } + } + + FOR( i = 0; i < N; i++ ) + { + sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); /*Q31 - max_res_exp*/ + move32(); + } + + hFdCngCom->sidNoiseEstExp = max_res_exp; + move16(); + + /* NB last band energy compensation */ + + IF( hFdCngCom->CngBandwidth == NB ) + { + sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ + move32(); + } + + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ + move32(); + } + + scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac ); + + return; +} + +/*------------------------------------------------------------------- + * generate_masking_noise_ivas_fx() + * + * Generate additional comfort noise (kind of noise filling) + *-------------------------------------------------------------------*/ + +void generate_masking_noise_ivas_fx( + Word32 *timeDomainBuffer, /* i/o: time-domain signal Q31 - *exp_out*/ + Word16 *exp_out, /* o : time-domain signal exp */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 length, /* i : frame size Q0*/ + const Word16 core, /* i : core Q0*/ + const Word16 return_noise, /* i : noise is returned instead of added Q0*/ + const Word16 secondary, /* i : flag to indicate secondary noise generation Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels Q0*/ +) +{ + Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel; + Word32 *ptr_level_fx = cngNoiseLevel_fx; + Word32 *fftBuffer_fx = hFdCngCom->fftBuffer; + Word16 i; + Word32 maskingNoise_fx[L_FRAME16k]; + Word32 *ptr_r_fx; + Word32 *ptr_i_fx; + Word16 startBand; + Word16 *seed = &( hFdCngCom->seed ); + Word32 scale_fx; + Word16 shift; + scale_fx = 0x40000000; // 1.0 in Q30 + move32(); + startBand = hFdCngCom->startBand; /*Q0*/ + move16(); + shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); /*Q0*/ + } + scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); /*hFdCngCom->cngNoiseLevelExp*/ + hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift ); + move16(); + + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ + *exp_out = Q15; + move16(); + IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) + { + IF( NE_16( core, AMR_WB_CORE ) ) + { + /* Compute additional CN level */ + FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ ) + { + test(); + test(); + if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) + { + BREAK; + } + } + + scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */ + } + ELSE + { + /* Compute additional CN level */ + FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ ) + { + if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) + { + BREAK; + } + } + + IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) ) + { + scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */ + } + ELSE + { + scale_fx = 0; + move32(); + } + } + + /* Exclude clean speech */ + scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); // Q30 + + /* Generate Gaussian random noise in real and imaginary parts of the FFT bins + Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ + IF( startBand == 0 ) + { + rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 + ptr_r_fx = fftBuffer_fx + 2; /*Q31 - hFdCngCom->fftBuffer_exp*/ + Word16 exp1; + exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 ); + Word32 mpy1; + mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); /*Q31 - exp1*/ + mpy1 = L_shl( mpy1, exp1 ); // Q31 + fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15 + ptr_level_fx++; + } + ELSE + { + fftBuffer_fx[0] = 0; + move32(); + set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) ); + ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ + } + ptr_i_fx = ptr_r_fx + 1; + FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ ) + { + /* Real part in FFT bins */ + rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 + Word16 exp2; + exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 ); + Word32 mpy2; + mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); /*Q31 - exp2*/ + ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 + move32(); + ptr_r_fx += 2; + + /* Imaginary part in FFT bins */ + rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15 + ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15 + ptr_i_fx += 2; + } + + /* Remaining FFT bins are set to zero */ + set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); + /* Nyquist frequency is discarded */ + fftBuffer_fx[1] = 0; + move32(); + } + ELSE + { + /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */ + generate_masking_noise_update_seed_fx( hFdCngCom ); + + set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen ); + } + + /* Perform STFT synthesis */ + IF( secondary ) + { + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + } + ELSE + { + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + } + *exp_out = sub( *exp_out, Q9 ); + move16(); + + /* Add some comfort noise on top of decoded signal */ + IF( return_noise ) + { + Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ + } + ELSE + { + v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ + } + + return; +} + +/*------------------------------------------------------------------- + * generate_stereo_masking_noise_fx() + * + * Generate additional comfort noise (kind of noise filling) + *-------------------------------------------------------------------*/ + +void generate_stereo_masking_noise_fx( + Word16 *syn, /* i/o: time-domain signal Q_syn*/ + Word16 Q_syn, + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/ + const Word16 fadeOut, /* i : only fade out of previous state Q0*/ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels Q0*/ +) +{ + HANDLE_FD_CNG_COM hFdCngCom; + Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/; + Word32 Np_fx[L_FRAME16k]; + Word32 Ns_fx[L_FRAME16k]; + Word32 N1_fx[L_FRAME16k]; + Word32 N2_fx[L_FRAME16k]; + Word16 N1_fx_exp, N2_fx_exp; + Word16 i; + + IF( st->idchan == 0 ) + { + hFdCngCom = st->hFdCngDec->hFdCngCom; +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ +#else + Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ +#endif + Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ + + set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); + set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); + + IF( !fadeOut ) + { +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ +#else + Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ +#endif + generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 + /* Generate masking noise for secondary channel */ + IF( flag_sec_CNA ) + { + generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6 + gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); /*Q30*/ + scale_fx = ONE_IN_Q30; + move32(); + IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) ) + { + Word16 exp_gamma; + exp_gamma = 0; + move16(); + Word16 divisor1; + divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma + gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30 + Word16 exp_gamma1, exp_gamma2, exp_gamma3; + exp_gamma1 = Q1; + exp_gamma2 = Q1; + exp_gamma3 = Q1; + move16(); + move16(); + move16(); + gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); /*Q31 - exp_gamma1*/ + Word32 temp; + temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 + gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1 + gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30 + Word32 divisor2; + divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3 + scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30 + } + ELSE + { + gamma_fx = 0; + move16(); + } + + FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) + { + Np_fx[i] = L_add( Np_fx[i], + Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6 + move32(); + Word32 add2; + add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + if ( hStereoCng->c_PS_LT_fx < 0 ) + { + add2 = L_negate( add2 ); /*Q6*/ + } + Ns_fx[i] = L_add( Ns_fx[i], add2 ); /*Q6*/ + move32(); + } + FOR( ; i < hFdCngCom->frameSize; i++ ) + { + Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); + Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); + IF( hStereoCng->c_PS_LT_fx < 0 ) + { + Ns_fx[i] = L_negate( Ns_fx[i] ); + move32(); + } + } + /* Below code to be converted */ + Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21 + FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) + { + hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, + L_add( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), + Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), + Q14 ); // Q_olap + move16(); + hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, + L_sub( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), + Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), + Q14 ); // Q_olap + move16(); + } + } + ELSE + { + FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) + { + Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 + move32(); + } + Copy32( &N1_fx[( hFdCngCom->frameSize / 2 )], &Np_fx[( hFdCngCom->frameSize / 2 )], shr( hFdCngCom->frameSize, 1 ) ); /*Q6*/ + scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21 + FOR( i = 0; i < hFdCngCom->frameSize; i++ ) + { + hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ), Q6 ); // Q_olap + move16(); + } + } + + Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); /*st->Q_syn*/ + } + ELSE + { + set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) ); + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) ); + } + IF( flag_sec_CNA ) + { + Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6 + hStereoCng->enableSecCNA = 1; + move16(); + } + ELSE + { + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize ); + } + + /* add masking noise */ + FOR( i = 0; i < hFdCngCom->frameSize; i++ ) + { + syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn + move16(); + } + } + ELSE IF( hStereoCng->enableSecCNA ) + { + Word16 SP_ratio_fx; + SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis Q15*/ + Word16 prevSP_ratio_fx; + prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis Q15*/ + move16(); + /* scale and add masking noise */ + FOR( i = 0; i < shr( *hStereoCng->frameSize, 2 ); i++ ) + { + Word16 s; + Word16 scale_fx_tmp; + scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15 + scale_fx_tmp = shl( scale_fx_tmp, s ); + syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ + move16(); + } + FOR( ; i < *hStereoCng->frameSize / 2; i++ ) + { + syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ + move16(); + } + FOR( ; i < *hStereoCng->frameSize; i++ ) + { + syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ + move16(); + } + hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /*Q15*/ + move16(); + } + + return; +} +void generate_masking_noise_lb_dirac_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + Word32 *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA Q11*/ + const Word16 nCldfbTs, /* i : number of CLDFB slots that will be rendered Q0*/ + const Word16 cna_flag /* i : CNA flag for LB and HB Q0*/ +) +{ + Word16 i; + Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ + Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/ + Word32 *ptr_r; + Word32 *ptr_i; + Word32 *ptr_level; + Word16 *seed = &( hFdCngCom->seed ); + Word32 scale; + Word16 n_samples_out, n_samples_start, n_samples_out_loop; + + push_wmops( "fd_cng_dirac" ); + + /* Init */ + scale = 0; + move32(); + n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs ); + n_samples_start = 0; + move16(); + Word16 exp_out = Q11; + move16(); + /*LB CLDFB - CNA from STFT*/ + IF( cna_flag ) + { + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ + IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) + { + /* Compute additional CN level */ + FOR( i = 0; i < 15; i++ ) + { + test(); + test(); + if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) + { + BREAK; + } + } + + scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */ + scale = Mpy_32_16_1( scale, hFdCngCom->likelihood_noisy_speech ); /* Q30 */ + } + } + + /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ + test(); + IF( cna_flag && tdBuffer != NULL ) + { + WHILE( n_samples_out > 0 ) + { + n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out ); + IF( scale != 0 ) + { + /*Generate LF comfort noise only at first slot, for the whole frame*/ + ptr_level = cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ + + /* Generate Gaussian random noise in real and imaginary parts of the FFT bins + Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ + IF( EQ_16( hFdCngCom->startBand, 0 ) ) + { + rand_gauss_fx( &fftBuffer[0], seed, exp_out ); + ptr_r = fftBuffer + 2; /*hFdCngCom->fftBuffer_exp*/ + + Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); + Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT Q31 - exp2*/ + sqr = L_shl( sqr, exp2 ); /*Q31*/ + fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT Q31 - hFdCngCom->fftBuffer_exp*/ + move32(); + ptr_level++; + } + ELSE + { + fftBuffer[0] = 0; + move32(); + set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) ); + ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); /*hFdCngCom->fftBuffer_exp*/ + } + ptr_i = ptr_r + 1; /*hFdCngCom->fftBuffer_exp*/ + + FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) + { + rand_gauss_fx( ptr_r, seed, exp_out ); + Word16 exp2 = hFdCngCom->cngNoiseLevelExp; + Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); /*Q31 - exp2*/ + ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ + move32(); + ptr_r += 2; + + /* Imaginary part in FFT bins */ + rand_gauss_fx( ptr_i, seed, exp_out ); + ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ + move32(); + ptr_i += 2; + } + /* Remaining FFT bins are set to zero */ + set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); + /* Nyquist frequency is discarded */ + fftBuffer[1] = 0; + move32(); + + /* Perform STFT synthesis */ + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 + } + + ELSE + { + /* very low level case - update random seeds */ + generate_masking_noise_update_seed_fx( hFdCngCom ); + + set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); + /* Perform STFT synthesis */ + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + } + hFdCngCom->fftBuffer_exp = 31 - 11; + move16(); + n_samples_out = sub( n_samples_out, hFdCngCom->frameSize ); + n_samples_start = add( n_samples_start, hFdCngCom->frameSize ); + } + } + + pop_wmops(); + + return; +} +void generate_masking_noise_dirac_ivas_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA q_input*/ + Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer q_cldfb*/ + Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer q_cldfb*/ + const Word16 slot_index, /* i : CLDFB slot index Q0*/ + const Word16 cna_flag, /* i : CNA flag for LB and HB Q0*/ + const Word16 fd_cng_flag, /* i : FD-CNG flag for HB Q0*/ + Word16 q_input, + Word16 *q_cldfb ) +{ + Word16 i; + Word32 *ptr_level_fx; + Word16 *seed = &( hFdCngCom->seed ); + Word32 scale_fx; + Word16 q_scale, q_shift, q_ptr_level; + + push_wmops( "fd_cng_dirac" ); + + /* Init */ + scale_fx = 0; + move32(); + + /* Resample CLDFB memories if necessary*/ + IF( NE_16( i_mult( h_cldfb->no_channels, h_cldfb->no_col ), hFdCngCom->frameSize ) ) + { + resampleCldfb_ivas_fx( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC ); + } + + set32_fx( Cldfb_RealBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); + + /*LB CLDFB - CNA from STFT*/ + IF( cna_flag != 0 ) + { + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ + IF( hFdCngCom->likelihood_noisy_speech > 0 ) + { + /* Compute additional CN level */ + FOR( i = 0; i < 15; i++ ) + { + test(); + test(); + if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && + ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) && + ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) ) + { + BREAK; + } + } + + scale_fx = L_shr( L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ), Q3 ); /* Q27 */ + scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); + } + } + /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ + IF( cna_flag && tdBuffer_fx != NULL ) + { + *q_cldfb = q_input; + move16(); + IF( scale_fx != 0 ) + { + /* LF CLDFB*/ + cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); + } + ELSE + { + /* LB ana CLDFB*/ + cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); + } + } + + /*HF CLDFB - CNA and/or FD-CNG*/ + if ( fd_cng_flag ) + { + scale_fx = L_add( scale_fx, ONE_IN_Q27 ); // 1 in Q27 + } + IF( scale_fx != 0 ) + { + q_scale = 27; + move16(); + q_shift = norm_l( scale_fx ); + scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ + q_scale = add( q_scale, q_shift ); + scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34 + q_scale = sub( add( q_scale, 2 * Q8 ), 31 ); + ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/ + q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp ); + + FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) + { + Word32 num; + Word16 exp, q_num; + q_shift = norm_l( scale_fx ); + scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ + q_scale = add( q_scale, q_shift ); + num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/ + q_num = sub( add( q_scale, q_ptr_level ), 31 ); + exp = sub( 31, q_num ); + num = Sqrt32( num, &exp ); /*Q31 - exp*/ + /* Real part in CLDFB band */ + rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb ); + Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp ); + move32(); + /* Imaginary part in CLDFB band */ + rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb ); + Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp ); + move32(); + + ptr_level_fx++; + } + } + + pop_wmops(); + + return; +} + + +/*------------------------------------------------------------------- + * FdCngDecodeMDCTStereoSID() + * + * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream + * + *-------------------------------------------------------------------*/ + +void FdCngDecodeMDCTStereoSID_fx( + CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ +) +{ + DEC_CORE_HANDLE sts[CPE_CHANNELS]; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word32 *lr_ptr_fx[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 indices[FD_CNG_stages_37bits]; + Word16 N, i, ch, p, stages; + Word16 is_out_ms; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 shift, exp_diff, max_exp_idx; + Word16 exp_arr[NPART]; + Word32 tmp32, tmp32_arr[NPART]; + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 + + is_out_ms = 0; + move16(); + if ( hCPE->hCoreCoder[0]->cng_sba_flag ) + { + is_out_ms = 1; + move16(); + } + + N = 0; /* to avoid compilation warning */ + move16(); + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ + lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q18*/ + } + + /* decode noise shapes and gains */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; + N = hFdCngCom->npart; + move16(); + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /*Q0*/ + move16(); + + IF( ch ) + { + stages = FD_CNG_JOINT_stages_25bits; + move16(); + } + ELSE + { + stages = FD_CNG_stages_37bits; + move16(); + } + + /* read bitstream */ + FOR( i = 0; i < stages; i++ ) + { + indices[i] = get_next_indice_fx( sts[ch], bits_37bits[i] ); /*Q0*/ + move16(); + } + { + gain_fx[ch] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[ch], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 + move32(); + } + + /* MSVQ decoder */ + shift = find_guarded_bits_fx( N ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); // Q20 - shift + + Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20 + } + + dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) ); + + IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) + { + set32_fx( ms_ptr_fx[1], 0, NPART ); + } + + IF( EQ_16( is_out_ms, 0 ) ) + { + inverseMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); + } + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + max_exp_idx = 0; + move16(); + hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; + FOR( p = 0; p < N; p++ ) + { + tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 + tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ + move32(); + if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) + { + max_exp_idx = p; /*Q0*/ + move16(); + } + } + + // Bringing in same exponent + FOR( p = 0; p < N; p++ ) + { + lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q31 - exp_arr[max_exp_idx]*/ + move32(); + } + + hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; + move16(); + + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); + } + + test(); + IF( EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) ) + { + /* create proper M noise shape in channel zero after gains have been applied */ + exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); + move16(); + FOR( p = 0; p < N; p++ ) + { + IF( GT_16( exp_diff, 0 ) ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ + move32(); + } + ELSE + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ + move32(); + } + } + IF( LT_16( exp_diff, 0 ) ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); + move16(); + } + } + + return; +} + + +/*------------------------------------------------------------------- + * FdCngDecodeDiracMDCTStereoSID_fx() + * + * Decode FD-CNG parameters for CNG in 2TC DirAC mode from the bitstream + *-------------------------------------------------------------------*/ + +void FdCngDecodeDiracMDCTStereoSID_fx( + CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ +) +{ + DEC_CORE_HANDLE sts[CPE_CHANNELS]; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word32 *lr_ptr_fx[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 indices[FD_CNG_stages_37bits]; + Word16 N, i, ch, p; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 shift, exp_diff, max_exp_idx; + Word16 exp_arr[NPART]; + Word32 tmp32, tmp32_arr[NPART]; + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ + lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q20*/ + ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; /*Q18*/ + } + + /* decode noise shapes and gains */ + hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom; + N = hFdCngCom->npart; /*Q0*/ + move16(); + + /* read bitstream */ + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + indices[i] = get_next_indice_fx( sts[0], bits_37bits[i] ); /*Q0*/ + move16(); + } + gain_fx[0] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[0], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 + move32(); + + gain_fx[1] = gain_fx[0]; /*Q20*/ + move32(); + + /* MSVQ decoder */ + shift = find_guarded_bits_fx( N ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); // Q20 - shift + + Scale_sig32( ms_ptr_fx[0], N, shift ); // Q20 + + Copy32( ms_ptr_fx[0], ms_ptr_fx[1], N ); /*Q20*/ + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + max_exp_idx = 0; + move16(); + hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; + + FOR( p = 0; p < N; p++ ) + { + tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 + tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ + move32(); + if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) + { + max_exp_idx = p; /*Q0*/ + move16(); + } + } + + // Bringing in same exponent + FOR( p = 0; p < N; p++ ) + { + lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q20*/ + move32(); + } + + hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; /*Q0*/ + move16(); + + /* NB last band energy compensation */ + test(); + IF( hFdCngCom->CngBandwidth == NB ) + { + lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], NB_LAST_BAND_SCALE_Q31 ); /*Q20*/ + move32(); + } + ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); /*Q20*/ + move32(); + } + + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); + } + sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0; + move16(); + sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0; + move16(); + + IF( EQ_16( hCPE->nchan_out, 1 ) ) + { + /* create proper M noise shape in channel zero after gains have been applied */ + exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); + FOR( p = 0; p < N; p++ ) + { + IF( exp_diff > 0 ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ + move32(); + } + ELSE + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ + move32(); + } + } + IF( exp_diff < 0 ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); + move16(); + } + } + + return; +} + + #ifdef IVAS_CODE_CNG /*------------------------------------------------------------------- diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c deleted file mode 100644 index 2b8091305..000000000 --- a/lib_dec/init_dec.c +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*----------------------------------------------------------------------* - * init_decoder() - * - * Initialization of static variables for the decoder - *----------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------* - * reset_preecho_dec() - * - * Initialization of static variables for pre-echo - *----------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------* - * destroy_cldfb_decoder_flt() - * - * Free memory which was allocated in init_decoder() - *----------------------------------------------------------------------*/ -void destroy_cldfb_decoder_ivas_fx( - Decoder_State *st /* o : Decoder static variables structure */ -) -{ - /* CLDFB BPF & resampling tools */ - deleteCldfb_ivas_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ - deleteCldfb_ivas_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ - deleteCldfb_ivas_fx( &st->cldfbSyn ); /* delete synthesis at output sampling rate */ - deleteCldfb_ivas_fx( &st->cldfbSynHB ); - - deleteFdCngDec_fx( &st->hFdCngDec ); - - return; -} diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index a96774113..caa164df9 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1822,3 +1822,18 @@ void destroy_cldfb_decoder_fx( return; } + +void destroy_cldfb_decoder_ivas_fx( + Decoder_State *st /* o : Decoder static variables structure */ +) +{ + /* CLDFB BPF & resampling tools */ + deleteCldfb_ivas_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ + deleteCldfb_ivas_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ + deleteCldfb_ivas_fx( &st->cldfbSyn ); /* delete synthesis at output sampling rate */ + deleteCldfb_ivas_fx( &st->cldfbSynHB ); + + deleteFdCngDec_fx( &st->hFdCngDec ); + + return; +} diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 459dcc4d4..5a948bdfa 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -3787,3 +3787,36 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( return; } + +Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( + Decoder_Struct *st_ivas /* i : Parametric MC handle */ +) +{ + Word16 num_cldfb_syntheses; + + num_cldfb_syntheses = 0; + move16(); + + /* sanity check*/ + IF( st_ivas->hParamMC == NULL ) + { + assert( 0 && "ParamMC handle does not exist!\n" ); + } + + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + num_cldfb_syntheses = 2; + move16(); + } + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + num_cldfb_syntheses = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + } + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) + { + num_cldfb_syntheses = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + } + + return num_cldfb_syntheses; +} diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c deleted file mode 100644 index 0d9ee2710..000000000 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "ivas_prot_fx.h" - -Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( - Decoder_Struct *st_ivas /* i : Parametric MC handle */ -) -{ - Word16 num_cldfb_syntheses; - - num_cldfb_syntheses = 0; - move16(); - - /* sanity check*/ - IF( st_ivas->hParamMC == NULL ) - { - assert( 0 && "ParamMC handle does not exist!\n" ); - } - - test(); - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - num_cldfb_syntheses = 2; - move16(); - } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - num_cldfb_syntheses = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) - { - num_cldfb_syntheses = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); - } - - return num_cldfb_syntheses; -} diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c deleted file mode 100644 index 6b80108a8..000000000 --- a/lib_dec/swb_bwe_dec.c +++ /dev/null @@ -1,681 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" - - -static Word16 para_pred_bws_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *signal_wb_fx, /* i : wideband frequency signal Q_syn */ - Word16 *SWB_fenv_fx, /* o : frequency-domain BWE envelope Q1 */ - Word16 Q_syn ) -{ - Word16 i, j, k; - Word16 mode; - Word16 tmp, tmp_den, tmp_num; - Word32 L_tmp, L_tmp_max; - Word16 exp; - Word16 *input_hi_fx; - Word32 *mea; - Word16 peak_fx, mag_fx; - Word32 mean_fx[7], peak_32_fx; - Word32 avrg1_fx, avrg2_fx, min_fx; - Word16 att_fx; - Word16 coder_type = st_fx->coder_type; - move16(); - - mode = NORMAL; - move16(); - - k = 0; - move16(); - input_hi_fx = &signal_wb_fx[SHARP_WIDTH]; /*Q_syn*/ - FOR( i = 0; i < 7; i++ ) - { - peak_fx = 0; - move16(); - mean_fx[i] = 0; - move16(); - FOR( j = 0; j < SHARP_WIDTH; j++ ) - { - mag_fx = abs_s( *input_hi_fx ); /*Q_syn*/ - peak_fx = s_max( peak_fx, mag_fx ); /*Q_syn*/ - mean_fx[i] = L_add( mean_fx[i], L_deposit_l( mag_fx ) ); /*Q_syn*/ - move32(); - input_hi_fx++; - } - - IF( LT_16( Q_syn, 11 ) ) - { - tmp = 1; - move16(); - } - ELSE - { - tmp = 0; - move16(); - if ( GT_16( shr( peak_fx, 3 ), shl( 1, Q_syn ) ) ) - { - tmp = 1; - move16(); - } - } - IF( tmp > 0 ) - { - L_tmp = L_msu0( Mult_32_16( L_shl( mean_fx[i], 10 ) /*Q_syn + 10*/, 18432 /*4.5f Q12*/ ), peak_fx /*Q_syn*/, 4544 /*35.5 (SHARP_WIDTH + 3.5f)Q7*/ ); - if ( L_tmp < 0 ) - { - k = add( k, 1 ); - } - } - } - - avrg1_fx = L_deposit_l( 0 ); - avrg2_fx = L_deposit_l( 0 ); - FOR( i = 1; i < 4; i++ ) - { - avrg1_fx = L_add( avrg1_fx, mean_fx[i] ); /*Q_syn*/ - avrg2_fx = L_add( avrg2_fx, mean_fx[i + 3] ); /*Q_syn*/ - } - avrg1_fx = Mult_32_16( avrg1_fx, 10923 /* 1/3 -> Q15 -> 10923 */ ); /*Q_syn + Q15 - 15*/ - avrg2_fx = Mult_32_16( avrg2_fx, 10923 /* 1/3 -> Q15 -> 10923 */ ); /*Q_syn + Q15 - 15*/ - - min_fx = L_add( 2147483647, 0 ); /*2^31 */ - peak_32_fx = L_deposit_l( 0 ); - FOR( i = 4; i < 7; i++ ) - { - IF( GT_32( mean_fx[i], L_shl( avrg2_fx, 1 ) ) ) - { - exp = norm_l( mean_fx[i] ); - IF( LT_16( exp, 16 ) ) - { - tmp_den = extract_l( L_shr( mean_fx[i], sub( 16, exp ) ) ); /*Qsyn - 16 + exp */ - tmp_num = extract_l( L_shr( avrg2_fx, sub( 15, exp ) ) ); /*Qsyn - 16 + exp */ - } - ELSE - { - tmp_den = extract_l( mean_fx[i] ); - tmp_num = extract_l( L_shl( avrg2_fx, 1 ) ); - } - - tmp_den = div_s( 1, tmp_den ); - - tmp = i_mult( tmp_num, tmp_den ); /*Q15 */ - - mean_fx[i] = Mult_32_16( mean_fx[i], tmp ); /*Q_syn + Q15 - 15*/ - move32(); - } - min_fx = L_min( min_fx, mean_fx[i] ); - peak_32_fx = L_max( peak_32_fx, mean_fx[i] ); - } - - IF( GT_16( st_fx->tilt_wb_fx, 16384 /*8 in Q11*/ ) ) - { - IF( GT_16( st_fx->tilt_wb_fx, 30720 /*15.0f in Q11*/ ) ) - { - min_fx = peak_32_fx; - move32(); - } - ELSE - { - tmp = extract_l( L_shr( L_mult0( st_fx->tilt_wb_fx, 17476 ), 14 ) ); /*Q15 */ - min_fx = Mult_32_16( peak_32_fx, tmp ); - } - } - - test(); - IF( peak_32_fx == 0 || min_fx == 0 ) - { - set16_fx( SWB_fenv_fx, 0, SWB_FENV ); - } - ELSE - { - exp = norm_l( peak_32_fx ); - IF( LT_16( exp, 16 ) ) - { - tmp_den = extract_l( L_shr( peak_32_fx, sub( 16, exp ) ) ); /*Qsyn - 16 + exp */ - tmp = div_s( 16384, tmp_den ); /*Q15+14 - (Qsyn - 16 + exp) */ - tmp_num = extract_l( L_shr( min_fx, sub( 16, exp ) ) ); /*Qsyn - 16 + exp */ - tmp = extract_l( L_shr( L_mult0( tmp_num, tmp ), 14 ) ); /*Q15 */ - } - ELSE - { - tmp_den = extract_l( peak_32_fx ); /*Qsyn */ - exp = norm_s( tmp_den ); - tmp = div_s( shl( 1, sub( 14, exp ) ), tmp_den ); /*Q 29-exp - Qsyn */ - tmp_num = extract_l( min_fx ); /*Qsyn */ - tmp = extract_l( L_shr( L_mult0( tmp_num, tmp ), sub( 14, exp ) ) ); /*Q15 */ - } - - j = 0; - move16(); - mea = &mean_fx[4]; - L_tmp_max = L_shl( 32767, add( Q_syn, 5 ) ); - FOR( i = 0; i < SWB_FENV; i++ ) - { - if ( EQ_16( j, 5 ) ) - { - mea++; - j = 0; - move16(); - } - j = add( j, 1 ); - L_tmp = L_min( Mult_32_16( *mea, tmp ), L_tmp_max ); - SWB_fenv_fx[i] = extract_l( L_shr( L_tmp, add( Q_syn, 5 ) ) ); - move16(); - } - } - - j = 0; - move16(); - FOR( i = SWB_FENV / 2; i < SWB_FENV; i++ ) - { - tmp = sub( 32767, i_mult( j, 2341 ) ); - SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], tmp ); - move16(); - j = add( j, 1 ); - } - - IF( GT_32( avrg1_fx, L_shl( avrg2_fx, 3 ) ) ) - { - FOR( i = 0; i < SWB_FENV; i++ ) - { - SWB_fenv_fx[i] = shr( SWB_fenv_fx[i], 1 ); - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->last_codec_mode, MODE1 ) && - ( GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLH_fx, 1 ), st_fx->prev_enerLH_fx ) ) && - ( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLL_fx, 1 ), st_fx->prev_enerLL_fx ) ) ) - { - FOR( i = 0; i < SWB_FENV; i++ ) - { - test(); - IF( NE_16( st_fx->prev_coder_type, coder_type ) && GT_16( mult_r( SWB_fenv_fx[i], 16384 /*1/2.0f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i] ) ) - { - SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 3277 /*0.1f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i], 29491 /*0.9f in Q15*/ ) ); - move16(); - } - ELSE - { - SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], st_fx->attenu_fx ), st_fx->prev_SWB_fenv_fx[i], sub( 32767 /*1.0f in Q15*/, st_fx->attenu_fx ) ) ); - move16(); - } - } - - IF( LT_16( st_fx->attenu_fx, 29491 /*0.9f in Q15*/ ) ) - { - st_fx->attenu_fx = add( st_fx->attenu_fx, 1638 /*0.05f in Q15*/ ); - move16(); - } - } - ELSE - { - test(); - test(); - test(); - test(); - IF( NE_32( st_fx->core_brate, st_fx->last_core_brate ) || ( GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLH_fx, 1 ), st_fx->prev_enerLH_fx ) ) || - ( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLL_fx, 1 ), st_fx->prev_enerLL_fx ) ) ) - { - FOR( i = 0; i < SWB_FENV; i++ ) - { - if ( GT_16( mult_r( SWB_fenv_fx[i], 16384 /*0.5f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i] ) ) - { - SWB_fenv_fx[i] = st_fx->prev_SWB_fenv_fx[i]; - move16(); - } - } - } - - FOR( i = 0; i < SWB_FENV; i++ ) - { - SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 29491 /*0.9f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i], 3277 /*0.1f in Q15*/ ) ); - move16(); - } - st_fx->attenu_fx = 3277; /*Q15*/ - move16(); - } - - if ( GT_16( k, 3 ) ) - { - mode = HARMONIC; - move16(); - } - - - att_fx = i_mult( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 819 ); /*15 */ - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - FOR( i = 0; i < 4; i++ ) - { - SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], att_fx ); - move16(); /*Q1 */ - } - } - - FOR( i = 4; i < SWB_FENV; i++ ) - { - SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], att_fx ); - move16(); /*Q1 */ - } - - return mode; -} - - -/*-------------------------------------------------------------------* - * WB_BWE_gain_deq() - * - * Decoding of WB parameters - *-------------------------------------------------------------------*/ - - -Word16 swb_bwe_dec_fx32( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ - Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ - Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ - Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - Word16 output_frame /* i : frame length */ -) -{ - Word16 L; - Word16 mode; - Word16 idxGain; - Word16 i, j, l_subfr; - Word16 fb_band_begin; - Word16 frica_flag = 0; - move16(); - Word16 ener_adjust_quan_fx; - Word16 fb_ener_adjust_fx = 0; - move16(); - Word16 scl, new_input_fx_exp, ysynth_frame_size; - Word16 Q_syn, Q_syn_hb, tmp, tmp2, q_tmp, Qsynth_fx16; - - Word16 ysynth_fx[L_FRAME48k]; - Word16 SWB_fenv_fx[SWB_FENV]; - Word16 SWB_tenv_fx[SWB_TENV]; - Word16 synth_fx16[L_FRAME48k]; - Word16 hb_synth_fx16[L_FRAME48k]; - - Word32 L_tmp; - Word32 yerror_fx[L_FRAME48k]; - Word32 ysynth_fx32[L_FRAME48k]; - Word32 SWB_tenv_tmp_fx[SWB_TENV]; - Word32 wtda_synth_fx[2 * L_FRAME48k]; - - FD_BWE_DEC_HANDLE hBWE_FD; - hBWE_FD = st_fx->hBWE_FD; - - /*---------------------------------------------------------------------* - * SWB BWE decoding - *---------------------------------------------------------------------*/ - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - /* todo - wtda() does not support L_FRAME length; thus temporarily resample the signal */ - /* todo - delay output[] by 1.25ms ? */ - L_lerp_fx_q11( output_fx, ysynth_fx32, L_FRAME16k, st_fx->L_frame ); - - /* windowing of the ACELP core synthesis */ - wtda_fx32( ysynth_fx32, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, /*st_fx->L_frame*/ L_FRAME16k ); - - /* DCT of the ACELP core synthesis */ - new_input_fx_exp = 11; - move16(); - direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, /*st_fx->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); - ysynth_frame_size = L_FRAME16k; - move16(); - } - ELSE - { - /* windowing of the ACELP core synthesis */ - wtda_fx32( synth_fx, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, output_frame ); - - /* DCT of the ACELP core synthesis */ - new_input_fx_exp = 11; - move16(); - direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); - ysynth_frame_size = output_frame; - move16(); - } - - /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ - scl = sub( 16 + 11, new_input_fx_exp ); - /* Possible to Upscale? */ - IF( scl > 0 ) - { - /* Yes */ - /* Calc Room to Upscale */ - Q_syn = sub( Find_Max_Norm32( ysynth_fx32, ysynth_frame_size ), 3 ); - /* Stay within MAX_Q_NEW_INPUT */ - scl = s_min( Q_syn, scl ); - } - /*Don't upscale if already in 15 bits*/ - IF( GT_16( scl, 15 ) ) - { - FOR( i = 0; i < ysynth_frame_size; i++ ) - { - ysynth_fx[i] = extract_l( ysynth_fx32[i] ); - move16(); - } - Q_syn = new_input_fx_exp; - move16(); - } - ELSE - { - Copy_Scale_sig32_16( ysynth_fx32, ysynth_fx, ysynth_frame_size, scl ); - Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); - } - - IF( !st_fx->bfi ) - { - IF( st_fx->bws_cnt > 0 ) - { - /* estimate parameters */ - mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn ); - } - ELSE - { - /* de-quantization */ - mode = swb_bwe_gain_deq_fx( st_fx, ACELP_CORE, SWB_tenv_fx, SWB_fenv_fx, 0, -1 ); - } - - L = SWB_FENV; - move16(); - if ( EQ_16( mode, TRANSIENT ) ) - { - L = SWB_FENV_TRANS; - move16(); - } - - L_tmp = 0; - move32(); - FOR( i = 0; i < L; i++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( SWB_fenv_fx[i] ) ); - } - q_tmp = norm_s( L ); - tmp = div_s( shl( 1, sub( 14, q_tmp ) ), L ); /*Q(29-q_tmp) */ - L_tmp = Mpy_32_16_1( L_tmp, tmp ); /*Q(1+29-q_tmp+1-16)->Q(15-q_tmp) */ - st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, add( q_tmp, 2 ) ) ); /*Q1 */ - move16(); - } - ELSE - { - /* SHB FEC */ - - IF( NE_16( hBWE_FD->prev_mode, TRANSIENT ) ) - { - mode = hBWE_FD->prev_mode; - move16(); - } - ELSE - { - mode = NORMAL; - move16(); - } - - Copy( st_fx->prev_SWB_fenv_fx, SWB_fenv_fx, SWB_FENV ); - } - - /* reconstruction of MDCT spectrum of the error signal */ - set32_fx( yerror_fx, 0, output_frame ); - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); - } - ELSE - { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); - } - - test(); - IF( EQ_16( hBWE_FD->prev_frica_flag, 1 ) && frica_flag == 0 ) - { - FOR( i = 0; i < L_SUBFR; i++ ) - { - tmp = sub( 32767, extract_l( L_mult0( i, 512 ) ) ); /*Q15 */ - hBWE_FD->mem_imdct_fx[i] = mult_r( hBWE_FD->mem_imdct_fx[i], tmp ); - move16(); - } - - FOR( ; i < output_frame; i++ ) - { - hBWE_FD->mem_imdct_fx[i] = 0; - move16(); - } - } - - /* decode information */ - IF( EQ_16( st_fx->extl, FB_BWE ) ) - { - IF( !st_fx->bfi ) - { - idxGain = (Word16) get_next_indice_fx( st_fx, NUM_BITS_FB_FRAMEGAIN ); - fb_ener_adjust_fx = usdequant_fx( idxGain, FB_GAIN_QLOW_FX, FB_GAIN_QDELTA_FX ); /*Q15 */ - } - ELSE IF( st_fx->bfi ) - { - fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx; - move16(); - } - - st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx; - move16(); - IF( EQ_16( mode, TRANSIENT ) ) - { - ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 ); - } - ELSE - { - IF( SWB_fenv_fx[7] != 0 ) - { - tmp = div_s( 1, SWB_fenv_fx[7] ); - ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); - } - ELSE - { - ener_adjust_quan_fx = 0; - move16(); - } - } - - fb_band_begin = FB_BAND_BEGIN; - move16(); - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - fb_band_begin = FB_BAND_BEGIN_12k8; - move16(); - } - - j = 0; - move16(); - FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ ) - { - tmp = sub( 32767, i_mult( j, 1024 ) ); - tmp = mult_r( tmp, ener_adjust_quan_fx ); /*Q13*/ - - tmp2 = i_mult( j, 256 ); /*Q13*/ - tmp2 = mult_r( tmp2, fb_ener_adjust_fx ); /*Q13*/ - - tmp = add( tmp, tmp2 ); /*Q13*/ - yerror_fx[i] = L_shl( Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], tmp ), 2 ); /*15+Q_syn */ - move32(); - j = add( j, 1 ); - } - FOR( ; i < FB_BAND_END; i++ ) - { - yerror_fx[i] = Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], fb_ener_adjust_fx ); /*15+Q_syn */ - move32(); - } - } - - /* iDCT of the error signal */ - Q_syn_hb = add( Q_syn, 15 ); - Inverse_Transform( yerror_fx, &Q_syn_hb, wtda_synth_fx, 0, output_frame, -1, st_fx->element_mode ); - - /* inverse windowing of the error signal */ - window_ola_fx( wtda_synth_fx, hb_synth_fx16, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); - l_subfr = mult( output_frame, 8192 ); - - test(); - IF( EQ_16( mode, TRANSIENT ) ) - { - FOR( i = 0; i < SWB_TENV; i++ ) - { - SWB_tenv_tmp_fx[i] = L_mult0( SWB_tenv_fx[i] /*Q0*/, 26214 /*0.8f Q15*/ ); // Q15 - move32(); - } - - /* time envelope shaping when the current frame is TRANSIENT frame */ - time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); - - Q_syn_hb = sub( Q_syn_hb, 3 ); - - hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3]; - move16(); - } - ELSE IF( EQ_16( frica_flag, 1 ) && hBWE_FD->prev_frica_flag == 0 ) - { - Qsynth_fx16 = Find_Max_Norm32( synth_fx, output_frame ); - Qsynth_fx16 = sub( Qsynth_fx16, shr( add( sub( 15, norm_s( l_subfr ) ), 1 ), 1 ) ); - Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); - Qsynth_fx16 = add( 11 - 16, Qsynth_fx16 ); - - /* IVAS_fmToDo: synth[] is @internal_Fs!!! */ - time_reduce_pre_echo_fx( synth_fx16, hb_synth_fx16, hBWE_FD->prev_td_energy_fx, l_subfr, Qsynth_fx16, Q_syn_hb ); - } - ELSE - { - tmp = i_mult2( 3, l_subfr ); - L_tmp = L_deposit_l( 0 ); - - FOR( i = 0; i < l_subfr; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, hb_synth_fx16[add( tmp, i )], hb_synth_fx16[add( tmp, i )] ); /*(2*Q_syn_hb) */ - } - - L_tmp = Mult_32_16( L_tmp, div_s( 1, l_subfr ) ); /*(2*Q_syn_hb) */ - hBWE_FD->prev_td_energy_fx = 0; - move16(); - - IF( L_tmp != 0 ) - { - q_tmp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, q_tmp ) ); - q_tmp = sub( q_tmp, sub( 30, shl( Q_syn_hb, 1 ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &q_tmp ); /*Q(31-exp) */ - hBWE_FD->prev_td_energy_fx = round_fx( L_shl( L_tmp, sub( q_tmp, 15 ) ) ); /*Q0 */ - move16(); - } - } - - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - Qsynth_fx16 = add( 16 - 11, Q_syn_hb ); - Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); - - /* add HB synth from hf_synth() */ - v_add_16( hb_synth_fx16, synth_fx16, hb_synth_fx16, output_frame ); - } - - hBWE_FD->prev_mode = mode; - move16(); - hBWE_FD->prev_frica_flag = frica_flag; - move16(); - - FOR( i = 0; i < output_frame; i++ ) - { - hb_synth_fx[i] = L_deposit_l( hb_synth_fx16[i] ); // Q_syn_hb - move32(); - } - - return Q_syn_hb; -} - - -void fd_bwe_dec_init_fx( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -) -{ - set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->prev_Energy_fx = 0; - move16(); - hBWE_FD->prev_L_swb_norm = 8; - move16(); - hBWE_FD->Seed = 21211; - move16(); - hBWE_FD->prev_frica_flag = 0; - move16(); - set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); - hBWE_FD->prev_td_energy_fx = 0; - move16(); - hBWE_FD->prev_weight_fx = 0; - move16(); - hBWE_FD->prev_flag = 0; - move16(); - hBWE_FD->prev_Energy_wb_fx = 0; - move32(); - hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - - return; -} diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 9552bbf2f..23c4c3e8a 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1266,3 +1266,372 @@ void fd_bwe_dec_init( return; } + +/*-------------------------------------------------------------------* + * WB_BWE_gain_deq() + * + * Decoding of WB parameters + *-------------------------------------------------------------------*/ + + +Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ +) +{ + Word16 L; + Word16 mode; + Word16 idxGain; + Word16 i, j, l_subfr; + Word16 fb_band_begin; + Word16 frica_flag = 0; + move16(); + Word16 ener_adjust_quan_fx; + Word16 fb_ener_adjust_fx = 0; + move16(); + Word16 scl, new_input_fx_exp, ysynth_frame_size; + Word16 Q_syn, Q_syn_hb, tmp, tmp2, q_tmp, Qsynth_fx16; + + Word16 ysynth_fx[L_FRAME48k]; + Word16 SWB_fenv_fx[SWB_FENV]; + Word16 SWB_tenv_fx[SWB_TENV]; + Word16 synth_fx16[L_FRAME48k]; + Word16 hb_synth_fx16[L_FRAME48k]; + + Word32 L_tmp; + Word32 yerror_fx[L_FRAME48k]; + Word32 ysynth_fx32[L_FRAME48k]; + Word32 SWB_tenv_tmp_fx[SWB_TENV]; + Word32 wtda_synth_fx[2 * L_FRAME48k]; + + FD_BWE_DEC_HANDLE hBWE_FD; + hBWE_FD = st_fx->hBWE_FD; + + /*---------------------------------------------------------------------* + * SWB BWE decoding + *---------------------------------------------------------------------*/ + test(); + IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) + { + /* todo - wtda() does not support L_FRAME length; thus temporarily resample the signal */ + /* todo - delay output[] by 1.25ms ? */ + L_lerp_fx_q11( output_fx, ysynth_fx32, L_FRAME16k, st_fx->L_frame ); + + /* windowing of the ACELP core synthesis */ + wtda_fx32( ysynth_fx32, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, /*st_fx->L_frame*/ L_FRAME16k ); + + /* DCT of the ACELP core synthesis */ + new_input_fx_exp = 11; + move16(); + direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, /*st_fx->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); + ysynth_frame_size = L_FRAME16k; + move16(); + } + ELSE + { + /* windowing of the ACELP core synthesis */ + wtda_fx32( synth_fx, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, output_frame ); + + /* DCT of the ACELP core synthesis */ + new_input_fx_exp = 11; + move16(); + direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); + ysynth_frame_size = output_frame; + move16(); + } + + /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ + scl = sub( 16 + 11, new_input_fx_exp ); + /* Possible to Upscale? */ + IF( scl > 0 ) + { + /* Yes */ + /* Calc Room to Upscale */ + Q_syn = sub( Find_Max_Norm32( ysynth_fx32, ysynth_frame_size ), 3 ); + /* Stay within MAX_Q_NEW_INPUT */ + scl = s_min( Q_syn, scl ); + } + /*Don't upscale if already in 15 bits*/ + IF( GT_16( scl, 15 ) ) + { + FOR( i = 0; i < ysynth_frame_size; i++ ) + { + ysynth_fx[i] = extract_l( ysynth_fx32[i] ); + move16(); + } + Q_syn = new_input_fx_exp; + move16(); + } + ELSE + { + Copy_Scale_sig32_16( ysynth_fx32, ysynth_fx, ysynth_frame_size, scl ); + Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); + } + + IF( !st_fx->bfi ) + { + IF( st_fx->bws_cnt > 0 ) + { + /* estimate parameters */ + mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn ); + } + ELSE + { + /* de-quantization */ + mode = swb_bwe_gain_deq_fx( st_fx, ACELP_CORE, SWB_tenv_fx, SWB_fenv_fx, 0, -1 ); + } + + L = SWB_FENV; + move16(); + if ( EQ_16( mode, TRANSIENT ) ) + { + L = SWB_FENV_TRANS; + move16(); + } + + L_tmp = 0; + move32(); + FOR( i = 0; i < L; i++ ) + { + L_tmp = L_add( L_tmp, L_deposit_l( SWB_fenv_fx[i] ) ); + } + q_tmp = norm_s( L ); + tmp = div_s( shl( 1, sub( 14, q_tmp ) ), L ); /*Q(29-q_tmp) */ + L_tmp = Mpy_32_16_1( L_tmp, tmp ); /*Q(1+29-q_tmp+1-16)->Q(15-q_tmp) */ + st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, add( q_tmp, 2 ) ) ); /*Q1 */ + move16(); + } + ELSE + { + /* SHB FEC */ + + IF( NE_16( hBWE_FD->prev_mode, TRANSIENT ) ) + { + mode = hBWE_FD->prev_mode; + move16(); + } + ELSE + { + mode = NORMAL; + move16(); + } + + Copy( st_fx->prev_SWB_fenv_fx, SWB_fenv_fx, SWB_FENV ); + } + + /* reconstruction of MDCT spectrum of the error signal */ + set32_fx( yerror_fx, 0, output_frame ); + + IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + { + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); + } + ELSE + { + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); + } + + test(); + IF( EQ_16( hBWE_FD->prev_frica_flag, 1 ) && frica_flag == 0 ) + { + FOR( i = 0; i < L_SUBFR; i++ ) + { + tmp = sub( 32767, extract_l( L_mult0( i, 512 ) ) ); /*Q15 */ + hBWE_FD->mem_imdct_fx[i] = mult_r( hBWE_FD->mem_imdct_fx[i], tmp ); + move16(); + } + + FOR( ; i < output_frame; i++ ) + { + hBWE_FD->mem_imdct_fx[i] = 0; + move16(); + } + } + + /* decode information */ + IF( EQ_16( st_fx->extl, FB_BWE ) ) + { + IF( !st_fx->bfi ) + { + idxGain = (Word16) get_next_indice_fx( st_fx, NUM_BITS_FB_FRAMEGAIN ); + fb_ener_adjust_fx = usdequant_fx( idxGain, FB_GAIN_QLOW_FX, FB_GAIN_QDELTA_FX ); /*Q15 */ + } + ELSE IF( st_fx->bfi ) + { + fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx; + move16(); + } + + st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx; + move16(); + IF( EQ_16( mode, TRANSIENT ) ) + { + ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 ); + } + ELSE + { + IF( SWB_fenv_fx[7] != 0 ) + { + tmp = div_s( 1, SWB_fenv_fx[7] ); + ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); + } + ELSE + { + ener_adjust_quan_fx = 0; + move16(); + } + } + + fb_band_begin = FB_BAND_BEGIN; + move16(); + if ( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + fb_band_begin = FB_BAND_BEGIN_12k8; + move16(); + } + + j = 0; + move16(); + FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ ) + { + tmp = sub( 32767, i_mult( j, 1024 ) ); + tmp = mult_r( tmp, ener_adjust_quan_fx ); /*Q13*/ + + tmp2 = i_mult( j, 256 ); /*Q13*/ + tmp2 = mult_r( tmp2, fb_ener_adjust_fx ); /*Q13*/ + + tmp = add( tmp, tmp2 ); /*Q13*/ + yerror_fx[i] = L_shl( Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], tmp ), 2 ); /*15+Q_syn */ + move32(); + j = add( j, 1 ); + } + FOR( ; i < FB_BAND_END; i++ ) + { + yerror_fx[i] = Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], fb_ener_adjust_fx ); /*15+Q_syn */ + move32(); + } + } + + /* iDCT of the error signal */ + Q_syn_hb = add( Q_syn, 15 ); + Inverse_Transform( yerror_fx, &Q_syn_hb, wtda_synth_fx, 0, output_frame, -1, st_fx->element_mode ); + + /* inverse windowing of the error signal */ + window_ola_fx( wtda_synth_fx, hb_synth_fx16, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); + l_subfr = mult( output_frame, 8192 ); + + test(); + IF( EQ_16( mode, TRANSIENT ) ) + { + FOR( i = 0; i < SWB_TENV; i++ ) + { + SWB_tenv_tmp_fx[i] = L_mult0( SWB_tenv_fx[i] /*Q0*/, 26214 /*0.8f Q15*/ ); // Q15 + move32(); + } + + /* time envelope shaping when the current frame is TRANSIENT frame */ + time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); + + Q_syn_hb = sub( Q_syn_hb, 3 ); + + hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3]; + move16(); + } + ELSE IF( EQ_16( frica_flag, 1 ) && hBWE_FD->prev_frica_flag == 0 ) + { + Qsynth_fx16 = Find_Max_Norm32( synth_fx, output_frame ); + Qsynth_fx16 = sub( Qsynth_fx16, shr( add( sub( 15, norm_s( l_subfr ) ), 1 ), 1 ) ); + Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); + Qsynth_fx16 = add( 11 - 16, Qsynth_fx16 ); + + /* IVAS_fmToDo: synth[] is @internal_Fs!!! */ + time_reduce_pre_echo_fx( synth_fx16, hb_synth_fx16, hBWE_FD->prev_td_energy_fx, l_subfr, Qsynth_fx16, Q_syn_hb ); + } + ELSE + { + tmp = i_mult2( 3, l_subfr ); + L_tmp = L_deposit_l( 0 ); + + FOR( i = 0; i < l_subfr; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, hb_synth_fx16[add( tmp, i )], hb_synth_fx16[add( tmp, i )] ); /*(2*Q_syn_hb) */ + } + + L_tmp = Mult_32_16( L_tmp, div_s( 1, l_subfr ) ); /*(2*Q_syn_hb) */ + hBWE_FD->prev_td_energy_fx = 0; + move16(); + + IF( L_tmp != 0 ) + { + q_tmp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, q_tmp ) ); + q_tmp = sub( q_tmp, sub( 30, shl( Q_syn_hb, 1 ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &q_tmp ); /*Q(31-exp) */ + hBWE_FD->prev_td_energy_fx = round_fx( L_shl( L_tmp, sub( q_tmp, 15 ) ) ); /*Q0 */ + move16(); + } + } + + test(); + IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) + { + Qsynth_fx16 = add( 16 - 11, Q_syn_hb ); + Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); + + /* add HB synth from hf_synth() */ + v_add_16( hb_synth_fx16, synth_fx16, hb_synth_fx16, output_frame ); + } + + hBWE_FD->prev_mode = mode; + move16(); + hBWE_FD->prev_frica_flag = frica_flag; + move16(); + + FOR( i = 0; i < output_frame; i++ ) + { + hb_synth_fx[i] = L_deposit_l( hb_synth_fx16[i] ); // Q_syn_hb + move32(); + } + + return Q_syn_hb; +} + + +void fd_bwe_dec_init_fx( + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ +) +{ + set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); + hBWE_FD->prev_mode = NORMAL; + move16(); + hBWE_FD->prev_Energy_fx = 0; + move16(); + hBWE_FD->prev_L_swb_norm = 8; + move16(); + hBWE_FD->Seed = 21211; + move16(); + hBWE_FD->prev_frica_flag = 0; + move16(); + set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); + hBWE_FD->prev_td_energy_fx = 0; + move16(); + hBWE_FD->prev_weight_fx = 0; + move16(); + hBWE_FD->prev_flag = 0; + move16(); + hBWE_FD->prev_Energy_wb_fx = 0; + move32(); + hBWE_FD->mem_deemph_old_syn_fx = 0; + move16(); + + return; +} + diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c deleted file mode 100644 index 80dfad505..000000000 --- a/lib_dec/swb_tbe_dec.c +++ /dev/null @@ -1,2478 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" - -/*-----------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------*/ - - -void find_max_mem_dec_m3( - Decoder_State *st, - Word16 *n_mem3 ); - -/*-------------------------------------------------------------------* - * ResetSHBbuffer_Dec() - * - * - *-------------------------------------------------------------------*/ - -static void calc_tilt_bwe_fx_loc( - const Word32 *sp_fx, /* i : input signal : Q11 */ - Word32 *tilt_fx, /* o : signal tilt : tilt_fx_q */ - Word16 *tilt_fx_q, /* o : signal tilt */ - const Word16 N /* i : signal length : Q0 */ -) -{ - Word16 i; - Word64 r0_fx, r1_fx; - - r0_fx = EPSILON_FX_SMALL; - move64(); - FOR( i = 0; i < N; i++ ) - { - r0_fx = W_add( r0_fx, W_shr( W_mult_32_32( sp_fx[i], sp_fx[i] ), 1 ) ); /*Q11*2 - 1*/ - } - r1_fx = W_deposit32_l( abs( L_sub( sp_fx[1], sp_fx[0] ) ) ); /*Q11*/ - FOR( i = 2; i < N; i++ ) - { - IF( W_mult_32_32( L_sub( sp_fx[i], sp_fx[i - 1] ) /*Q11*/, L_sub( sp_fx[i - 1], sp_fx[i - 2] ) /*Q11*/ ) /*Q11 * 2 - 1*/ < 0 ) - { - r1_fx = W_add( r1_fx, W_deposit32_l( abs( L_sub( sp_fx[i], sp_fx[i - 1] ) ) ) ); /*Q11*/ - } - } - Word16 headroom_left_r0 = W_norm( r0_fx ); - Word16 headroom_left_r1 = W_norm( r1_fx ); - Word16 r0_q = 0, r1_q = 0; - move16(); - move16(); - IF( LT_16( headroom_left_r0, 32 ) ) - { - r0_fx = W_shr( r0_fx, sub( 32, headroom_left_r0 ) ); - r0_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_r0 ) ) ); - } - ELSE - { - r0_q = 31 - ( 2 * OUTPUT_Q ); - move16(); - } - - IF( LT_16( headroom_left_r1, 32 ) ) - { - r1_fx = W_shr( r1_fx, sub( 32, headroom_left_r1 ) ); - r1_q = sub( OUTPUT_Q, sub( 32, headroom_left_r1 ) ); - } - ELSE - { - r1_q = OUTPUT_Q; - move16(); - } - Word32 temp_r0_inv = ISqrt32( W_extract_l( r0_fx ), &r0_q ); - Word32 res = Mpy_32_32( W_extract_l( r1_fx ), temp_r0_inv ); - // Word16 res_q = r1_q + ( r0_q < 0 ? ( 31 + ( -1 * r0_q ) ) : r0_q ) - 31; - Word16 res_q; - IF( r0_q < 0 ) - { - res_q = add( r1_q, sub( add( 31, -r0_q ), 31 ) ); - } - ELSE - { - res_q = add( r1_q, sub( r0_q, 31 ) ); - } - Word16 norm_res = norm_l( res ); - IF( norm_res > 0 ) - { - *tilt_fx = L_shl_sat( res, norm_res ); - move32(); - *tilt_fx_q = add( res_q, norm_res ); - move16(); - } - ELSE - { - *tilt_fx = res; - move32(); - *tilt_fx_q = res_q; - move16(); - } - return; -} - -/*-------------------------------------------------------------------* - * swb_tbe_dec() - * - * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module - *-------------------------------------------------------------------*/ -static void rescale_genSHB_mem_dec( - Decoder_State *st_fx, - Word16 sf /*Q0*/ -) -{ - Word16 i; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st_fx->hBWE_TD; - - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); - move16(); - } - - FOR( i = 0; i < 7; i++ ) - { - hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] = shl( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i], sf ); - move16(); - } - - /* -- Apply memory scaling for 13.2 and 16.4k bps using sf ----*/ - IF( LT_32( st_fx->total_brate, ACELP_24k40 ) ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->state_lpc_syn_fx[i] = shl_sat( hBWE_TD->state_lpc_syn_fx[i], sf ); - move16(); - } - - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - hBWE_TD->state_syn_shbexc_fx[i] = shl_sat( hBWE_TD->state_syn_shbexc_fx[i], sf ); - move16(); - } - } - - hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf ); - move32(); - - hBWE_TD->tbe_demph_fx = shl_r( hBWE_TD->tbe_demph_fx, sf ); - move16(); - hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf ); - move16(); -} - -static void gradientGainShape( - Decoder_State *st_fx, - Word16 *GainShape_fx, /*Q15*/ - Word32 *GainFrame_fx /* Q18 */ ) -{ - Word16 i, j, tmp; - Word16 GainShapeTemp[NUM_SHB_SUBFR / 4]; - Word16 GainGrad0[3]; - Word16 GainGrad1[3]; - Word16 GainGradFEC[4]; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st_fx->hBWE_TD; - - - /* the previous frame gainshape gradient and the gainshape gradient pattern for the current frame */ - FOR( j = 0; j < 3; j++ ) - { - GainGrad0[j] = sub( shr( st_fx->GainShape_Delay[j + 1], 1 ), shr( st_fx->GainShape_Delay[j], 1 ) ); - move16(); /* Q14 */ - GainGrad1[j] = sub( shr( st_fx->GainShape_Delay[j + 5], 1 ), shr( st_fx->GainShape_Delay[j + 4], 1 ) ); - move16(); /* Q14 */ - GainGradFEC[j + 1] = add( mult_r( GainGrad0[j], 13107 /*0.4f in Q15*/ ), mult_r( GainGrad1[j], 19660 /*0.6f in Q15*/ ) ); - move16(); /* Q14 */ - } - - /* gradient for the first gainshape */ - test(); - test(); - test(); - IF( ( ( GT_16( shr( GainGrad1[2], 1 ), GainGrad1[1] ) ) && ( GT_16( shr( GainGrad1[1], 1 ), GainGrad1[0] ) ) ) || - ( ( LT_16( shr( GainGrad1[2], 1 ), GainGrad1[1] ) ) && ( LT_16( shr( GainGrad1[1], 1 ), GainGrad1[0] ) ) ) ) - { - GainGradFEC[0] = add( mult_r( GainGrad1[1], 3277 /*0.1f in Q15*/ ), mult_r( GainGrad1[2], 29490 /*0.9f in Q15*/ ) ); - move16(); /* Q14 */ - } - ELSE - { - GainGradFEC[0] = add( mult_r( GainGrad1[0], 6553 /*0.2f in Q15*/ ), mult_r( GainGrad1[1], 9830 /*0.3f in Q15*/ ) ); - move16(); - GainGradFEC[0] = add( GainGradFEC[0], mult_r( GainGrad1[2], 16384 /*0.5f in Q15*/ ) ); - move16(); /* Q14 */ - } - - /* get the first gainshape template */ - test(); - test(); - IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && ( GainGradFEC[0] > 0 ) ) - { - GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), GainGradFEC[0] ); - move16(); - } - ELSE IF( GainGradFEC[0] > 0 ) - { - GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), mult_r( GainGradFEC[0], 16384 /*0.5f in Q15*/ ) ); - move16(); /* Q14 */ - } - ELSE - { - GainShapeTemp[0] = shr( st_fx->GainShape_Delay[7], 1 ); - move16(); /* Q14 */ - } - - /*Get the second the third and the fourth gainshape template*/ - - tmp = shr( GainGrad1[2], 3 ); /* GainGrad1[2]/8 */ - tmp = mult_r( tmp, 26214 ); /* 0.8 in Q15 tmp*(8/10) */ - - test(); - IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] > 0 ) ) - { - FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) - { - GainShapeTemp[i] = add( GainShapeTemp[i - 1], mult_r( GainGradFEC[i], 26214 /*0.8f in Q15*/ ) ); - move16(); /* GainShapeTemp[i-1] + 0.8* GainShapeTemp[i] */ - GainShapeTemp[i] = s_max( GainShapeTemp[i], 328 /*0.01f Q15*/ ); - move16(); - } - } - ELSE - { - test(); - IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] < 0 ) ) - { - FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) - { - GainShapeTemp[i] = add( GainShapeTemp[i - 1], mult_r( GainGradFEC[i], 6553 /*0.2f in Q15*/ ) ); - move16(); /* GainShapeTemp[i-1] + 0.8* GainShapeTemp[i] */ - GainShapeTemp[i] = s_max( GainShapeTemp[i], 328 /*0.01f Q15*/ ); - move16(); /* Q14 */ - } - } - ELSE - { - FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) - { - GainShapeTemp[i] = add( GainShapeTemp[i - 1], GainGradFEC[i] ); - move16(); - GainShapeTemp[i] = s_max( GainShapeTemp[i], 328 /*0.01f Q15*/ ); - move16(); - } - } - } - - /* Get the gainshape and gain frame for the current frame*/ - test(); - test(); - test(); - IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && EQ_16( st_fx->nbLostCmpt, 1 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - tmp = mult_r( GainShapeTemp[i], 19660 /*0.6f Q15*/ ); /* GainShapeTemp[i]*0.6 */ - - IF( GT_16( 8192, tmp ) ) - { - GainShape_fx[i * 4 + j] = shl( tmp, 2 ); /*Q15*/ - move16(); /* (GainShapeTemp[i]*0.6)>>1 */ - } - ELSE - { - GainShape_fx[i * 4 + j] = 32767; /*Q15*/ - move16(); /* Clipping here to avoid the a huge change of the code due to gain shape change */ - } - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 ); - move16(); - } - ELSE IF( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - IF( LT_16( GainShapeTemp[i], 16384 ) ) - { - GainShape_fx[i * 4 + j] = shl( GainShapeTemp[i], 1 ); /*Q15*/ - move16(); - } - ELSE - { - GainShape_fx[i * 4 + j] = 32767; // 1.0f in Q15 - move16(); - } - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 /*0.95f in Q15*/ ); /*Q15*/ - move16(); - } - ELSE IF( GT_16( st_fx->nbLostCmpt, 1 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - GainShape_fx[i * 4 + j] = GainShapeTemp[i]; /*Q15*/ - move16(); - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 16384 /*0.5f in Q15*/ ); /*Q15*/ - move16(); - } - ELSE - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - IF( LT_16( GainShapeTemp[i], 16384 ) ) - { - GainShape_fx[i * 4 + j] = shl( GainShapeTemp[i], 1 ); /*Q15*/ - move16(); - } - ELSE - { - GainShape_fx[i * 4 + j] = 32767; /*Q15*/ - move16(); - } - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 27852 /*0.85f in Q15*/ ); /*Q15*/ - move16(); - } - - *GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, hBWE_TD->GainAttn_fx ); /* Q18 */ - move32(); -} - -static void find_max_mem_dec( - Decoder_State *st_fx, - Word16 *n_mem, - Word16 *n_mem2, - Word16 *n_mem3 ) -{ - Word16 i; - Word16 n_mem_32; - Word16 max = 0; - move16(); - Word32 Lmax = 0; - move32(); - Word16 tempQ15, max2 = 0; - move16(); - Word16 max3; - Word32 tempQ32, Lmax3; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st_fx->hBWE_TD; - - /* old BWE exc max */ - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - tempQ15 = abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ); - max = s_max( max, tempQ15 ); - } - - /* decimate all-pass steep memory */ - FOR( i = 0; i < 7; i++ ) - { - tempQ15 = abs_s( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] ); - max = s_max( max, tempQ15 ); - } - - /* -- keep norm of state_lpc_syn_fx, state_syn_shbexc_fx, - and mem_stp_swb_fx separately for 24.4 and 32kbps ----*/ - /* findMaxMem2() inside tbe com */ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tempQ15 = abs_s( hBWE_TD->state_lpc_syn_fx[i] ); - max2 = s_max( max2, tempQ15 ); - } - - /* findMaxMem2() inside tbe com */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - tempQ15 = abs_s( hBWE_TD->state_syn_shbexc_fx[i] ); - max2 = s_max( max2, tempQ15 ); - } - - /* findMaxMem2() inside tbe com */ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tempQ15 = abs_s( hBWE_TD->mem_stp_swb_fx[i] ); - max2 = s_max( max2, tempQ15 ); - } - - /* for total_brate > 16.4kbps, use n_mem2; else account for the max2 for n_mem calculation */ - *n_mem2 = norm_s( max2 ); - move16(); - if ( max2 == 0 ) - { - *n_mem2 = 15; - move16(); - } - - if ( LT_32( st_fx->total_brate, ACELP_24k40 ) ) - { - max = s_max( max, max2 ); - } - - /* de-emph and pre-emph memory */ - tempQ15 = abs_s( hBWE_TD->tbe_demph_fx ); - max = s_max( max, tempQ15 ); - - tempQ15 = abs_s( hBWE_TD->tbe_premph_fx ); - max = s_max( max, tempQ15 ); - - IF( EQ_16( st_fx->extl, FB_TBE ) ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tempQ15 = abs_s( hBWE_TD->fb_state_lpc_syn_fx[i] ); - max = s_max( max, tempQ15 ); - } - /* FB de-emph memory */ - tempQ15 = abs_s( hBWE_TD->fb_tbe_demph_fx ); - max = s_max( max, tempQ15 ); - } - /* estimate the norm for 16-bit memories */ - *n_mem = norm_s( max ); - move16(); - if ( max == 0 ) - { - *n_mem = 15; - move16(); - } - - /* estimate the norm for 32-bit memories */ - Lmax = L_abs( hBWE_TD->mem_csfilt_fx[0] ); /* only element [0] is used in env. shaping */ - - n_mem_32 = norm_l( Lmax ); - if ( Lmax == 0 ) - { - n_mem_32 = 31; - move16(); - } - - tempQ15 = sub( s_min( *n_mem, n_mem_32 ), 1 ); - *n_mem = s_max( tempQ15, 0 ); - move16(); - - /* --------------------------------------------------------------*/ - /* Find headroom for synthesis stage associated with these memories: - 1. st_fx->syn_overlap_fx - 2. st_fx->genSHBsynth_state_lsyn_filt_shb_local - 3. st_fx->genSHBsynth_Hilbert_Mem_fx (32-bit) */ - max3 = 0; - move16(); - /* find max in prev overlapSyn */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - tempQ15 = abs_s( hBWE_TD->syn_overlap_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ - FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) - { - tempQ15 = abs_s( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - /* find max in prev int_3_over_2_tbemem_dec_fx */ - IF( EQ_32( st_fx->output_Fs, 48000 ) ) - { - FOR( i = 0; i < INTERP_3_2_MEM_LEN; i++ ) - { - tempQ15 = abs_s( hBWE_TD->int_3_over_2_tbemem_dec_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - } - IF( EQ_32( st_fx->output_Fs, 16000 ) ) - { - FOR( i = 0; i < ( 2 * ALLPASSSECTIONS_STEEP + 1 ); i++ ) - { - tempQ15 = abs_s( hBWE_TD->mem_resamp_HB_32k_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - } - /* estimate the norm for 16-bit memories */ - *n_mem3 = norm_s( max3 ); - move16(); - if ( max3 == 0 ) - { - *n_mem3 = 15; - move16(); - } - - Lmax3 = 0; - move32(); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - /* find max in prev genSHBsynth_Hilbert_Mem_fx */ - FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) - { - tempQ32 = L_abs( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] ); - Lmax3 = L_max( Lmax3, tempQ32 ); - } - } - - /* estimate the norm for 32-bit memories */ - n_mem_32 = norm_l( Lmax3 ); - if ( Lmax3 == 0 ) - { - n_mem_32 = 31; - move16(); - } - - tempQ15 = sub( s_min( *n_mem3, n_mem_32 ), 2 ); /* very important leave at least 2 bit head room - because of the Hilber transform and Q14 coeffs */ - *n_mem3 = s_max( tempQ15, 0 ); - move16(); - /* --------------------------------------------------------------*/ -} - -void find_max_mem_dec_m3( - Decoder_State *st, - Word16 *n_mem3 ) -{ - Word16 i; - // Word16 n_mem_32; - Word16 tempQ15; - Word16 max3; - // Word32 tempQ32, Lmax3; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st->hBWE_TD; - - /* --------------------------------------------------------------*/ - /* Find headroom for synthesis stage associated with these memories: - 1. st->syn_overlap_fx*/ - max3 = 0; - move16(); - /* find max in prev overlapSyn */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - tempQ15 = abs_s( hBWE_TD->syn_overlap_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ - - /* estimate the norm for 16-bit memories */ - *n_mem3 = norm_s( max3 ); - move16(); - if ( max3 == 0 ) - { - *n_mem3 = 15; - move16(); - } -} - -/*-------------------------------------------------------------------* - * ivas_swb_tbe_dec_fx() - * - * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module - *-------------------------------------------------------------------*/ -void ivas_swb_tbe_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ - Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ - Word16 *Q_white_exc ) -{ - Word16 i, j, cnt, n; - Word16 stemp; - TD_BWE_DEC_HANDLE hBWE_TD; - Word32 shaped_shb_excitation_fx_32[L_FRAME16k + L_SHB_LAHEAD]; - Word16 bwe_exc_extended_16[L_FRAME32k + NL_BUFF_OFFSET]; - Word16 shaped_shb_excitation_fx[L_FRAME16k + L_SHB_LAHEAD]; - Word16 lsf_shb_fx[LPC_SHB_ORDER], lpc_shb_fx[LPC_SHB_ORDER + 1], GainShape_fx[NUM_SHB_SUBFR]; // Q12,Q12,Q15 - Word32 GainFrame_fx; // Q18 - Word32 error_fx[L_FRAME32k]; - Word16 ener_fx; - Word32 L_ener; - Word16 is_fractive; - Word32 prev_pow_fx, curr_pow_fx, Lscale; - Word16 scale_fx; - Word16 max_val, temp_fx, shaped_shb_excitation_frac[L_FRAME16k + L_SHB_LAHEAD]; - Word32 curr_frame_pow_fx; - Word16 curr_frame_pow_exp; - Word32 L_prev_ener_shb; - Word16 vf_modified_fx[NB_SUBFR16k]; - Word16 f_fx, inc_fx; - Word32 GainFrame_prevfrm_fx; - Word32 tilt_swb_fec_32_fx; - Word16 tilt_swb_fec_fx_q; - Word16 tilt_swb_fec_fx; - Word32 prev_ener_ratio_fx = 0; /* initialize just to avoid compiler warning */ - Word16 lsp_shb_1_fx[LPC_SHB_ORDER], lsp_shb_2_fx[LPC_SHB_ORDER], lsp_temp_fx[LPC_SHB_ORDER]; - Word16 lpc_shb_sf_fx[4 * ( LPC_SHB_ORDER + 1 )]; - const Word16 *ptr_lsp_interp_coef_fx; - Word32 shb_ener_sf_32; - Word16 shb_res_gshape_fx[NB_SUBFR16k]; - Word16 mixFactors_fx; - Word16 vind; - Word16 shb_res_dummy_fx[L_FRAME16k]; - Word16 shaped_shb_excitationTemp_fx[L_FRAME16k]; - Word32 ener_tmp_fx[NUM_SHB_SUBGAINS]; - Word16 GainShape_tmp_fx[NUM_SHB_SUBGAINS]; - Word16 pitch_fx; - Word16 l_subframe; - Word16 formant_fac_fx; - Word16 synth_scale_fx; - Word16 lsf_diff_fx[LPC_SHB_ORDER], w_fx[LPC_SHB_ORDER]; - Word16 refl_fx[M]; - Word16 tilt_para_fx; - Word16 *nlExc16k_fx, *mixExc16k_fx; - Word16 MSFlag; - Word16 feedback_fx; - Word16 GainShape_tilt_fx; - - // scaling - Word16 exp, tmp; - Word16 tmp1, tmp2; - Word16 mean_vf; - Word32 Lmax, L_tmp; - Word16 frac; - Word32 L_tmp1, L_tmp2; - Word16 Q_bwe_exc; - Word16 Q_bwe_exc_fb; - Word16 Q_shb; - Word16 n_mem, n_mem2, n_mem3, Qx, sc; - Word16 expa, expb; - Word16 fraca, fracb; - Word16 exp_ener, inv_ener; - - hBWE_TD = st->hBWE_TD; - - /* initializations */ - GainFrame_fx = 0; - move32(); - mixFactors_fx = 0; - move16(); - shb_ener_sf_32 = 0; - move32(); - set16_fx( shaped_shb_excitationTemp_fx, 0, L_FRAME16k ); - if ( st->hTdCngDec != NULL ) - { - st->hTdCngDec->shb_dtx_count = 0; - move16(); - } - is_fractive = 0; - move16(); - - IF( hStereoICBWE != NULL ) - { - nlExc16k_fx = hStereoICBWE->nlExc16k_fx; - mixExc16k_fx = hStereoICBWE->mixExc16k_fx; - MSFlag = hStereoICBWE->MSFlag; - move16(); - } - ELSE - { - nlExc16k_fx = NULL; - mixExc16k_fx = NULL; - MSFlag = 0; - move16(); - } - - /* find tilt */ - calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); - tilt_swb_fec_fx = round_fx_sat( L_shl_sat( tilt_swb_fec_32_fx, sub( 11 + 16, tilt_swb_fec_fx_q ) ) ); - test(); - if ( st->bfi && st->clas_dec != UNVOICED_CLAS ) - { - tilt_swb_fec_fx = hBWE_TD->tilt_swb_fec_fx; - move16(); - } - - /* WB/SWB bandwidth switching */ - test(); - test(); - IF( ( GT_16( st->tilt_wb_fx, 10240 /*5 in Q11*/ ) && ( EQ_16( st->clas_dec, UNVOICED_CLAS ) ) ) || GT_16( st->tilt_wb_fx, 20480 /*10 in Q11*/ ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( st->prev_fractive == 0 ) && - ( LT_32( st->prev_enerLH_fx, L_shl( st->enerLH_fx, 1 ) ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) && LT_32( st->prev_enerLL_fx, L_shl( st->enerLL_fx, 1 ) ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) ) || - ( EQ_16( st->prev_fractive, 1 ) && - GT_32( L_shr( st->prev_enerLH_fx, 2 ), Mult_32_16( st->enerLH_fx, 24576 ) ) ) /* 24576 in Q13*/ - || ( GT_32( L_shr( st->enerLL_fx, 1 ), Mult_32_16( st->enerLH_fx, 24576 ) ) && /*24576 = 1.5 in Q14*/ - LT_16( st->tilt_wb_fx, 20480 ) ) /* 20480 = 10 in Q11*/ - ) - { - is_fractive = 0; - } - ELSE - { - is_fractive = 1; - } - move16(); - } - - /* WB/SWB bandwidth switching */ - IF( st->bws_cnt > 0 ) - { - f_fx = 1489; /*1.0f / 22.0f in Q15*/ - move16(); - inc_fx = 1489; /*1.0f / 22.0f in Q15*/ - move16(); - - IF( EQ_16( is_fractive, 1 ) ) - { - Copy( lsf_tab_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); - } - ELSE - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ - move16(); - f_fx = add( f_fx, inc_fx ); /*Q15*/ - } - } - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && !( ( L_sub( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) < 0 ) && L_sub( st->prev_enerLH_fx, ( L_shr( st->enerLH_fx, 1 ) > 0 ) ) ) ) || st->last_core != ACELP_CORE || ( ( st->last_core == ACELP_CORE ) && GT_32( abs( L_sub( st->last_core_brate, st->core_brate ) ), 3600 ) ) || EQ_16( s_xor( is_fractive, st->prev_fractive ), 1 ) ) - { - set16_fx( GainShape_fx, 11587, NUM_SHB_SUBFR ); /*0.3536f in Q15*/ - } - ELSE - { - if ( GT_16( hBWE_TD->prev_GainShape_fx, 11587 ) ) /*0.3536f in Q15*/ - { - hBWE_TD->prev_GainShape_fx = 11587; /*0.3536f in Q15*/ - move16(); - } - set16_fx( GainShape_fx, hBWE_TD->prev_GainShape_fx, NUM_SHB_SUBFR ); - } - - Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); - set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, NB_SUBFR16k ); /* Q14 */ - } - ELSE - { - test(); - IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) - { - f_fx = 1489; /*Q15*/ - move16(); - inc_fx = 1489; /*Q15*/ - move16(); - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ - move16(); - f_fx = add( f_fx, inc_fx ); - } - } - - IF( !st->bfi ) - { - IF( st->use_partial_copy ) - { - IF( NE_16( st->last_extl, SWB_TBE ) ) - { - hBWE_TD->GainFrame_prevfrm_fx = 0; - move32(); - f_fx = 1489 /*0.045454f Q15*/; - move16(); - inc_fx = 1489 /*0.045454f Q15*/; - move16(); - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ - move16(); - f_fx = add( f_fx, inc_fx ); /*Q15*/ - } - } - Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); - set16_fx( GainShape_fx, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR ); - - IF( EQ_16( st->rf_frame_type, RF_NELP ) ) - { - /* Frame gain */ - - GainFrame_fx = L_mac( SHB_GAIN_QLOW_FX, st->rf_indx_tbeGainFr, SHB_GAIN_QDELTA_FX ); - L_tmp = Mult_32_16( GainFrame_fx, 27213 ); /*Q16*/ /* 3.321928 in Q13 */ - - frac = L_Extract_lc( L_tmp, &exp ); - L_tmp = Pow2( 30, frac ); - GainFrame_fx = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/ - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) && !st->prev_use_partial_copy && EQ_16( st->prev_coder_type, UNVOICED ) && NE_32( GainFrame_fx, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st->next_coder_type, GENERIC ) && EQ_16( st->last_extl, SWB_TBE ) ) - { - GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6553 /*0.2f in Q15*/ ) ); - } - } - ELSE - { - temp_fx = 0; - move16(); - /* Frame gain */ - SWITCH( st->rf_indx_tbeGainFr ) - { - case 0: - GainFrame_fx = 131072; /* 0.5f in Q18 */ - move32(); - if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - case 1: - GainFrame_fx = 524288; /* 2.0f in Q18 */ - move32(); - test(); - if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - case 2: - GainFrame_fx = 1048576; /* 4.0f in Q18 */ - move32(); - test(); - if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - case 3: - GainFrame_fx = 2097152; /* 8.0f in Q18 */ - move32(); - test(); - if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - default: - fprintf( stderr, "RF SWB-TBE gain bits not supported." ); - } - - IF( EQ_16( st->last_extl, SWB_TBE ) ) - { - GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp_fx ), Mult_32_16( GainFrame_fx, sub( 32767, temp_fx ) ) ); - /*Q18*/ - } - - IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) ) - { - if ( !st->prev_use_partial_copy && EQ_16( st->last_coder_type, VOICED ) && EQ_16( st->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame_fx, 2097152 /*8.0f in Q18*/ ) && LT_32( GainFrame_fx, 3059606 /*11.67f in Q18*/ ) ) - { - GainFrame_fx = Mult_32_16( GainFrame_fx, 9830 /*0.3f in Q15*/ ); // Q18 - } - } - } - } - ELSE - { - /* de-quantization */ - ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, - &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); - if ( hStereoICBWE != NULL ) - { - hStereoICBWE->MSFlag = MSFlag; - move16(); - } - } - } - ELSE - { - Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); - test(); - IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) - { - gradientGainShape( st, GainShape_fx, &GainFrame_fx ); - } - ELSE - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] ); - move16(); - } - } - IF( GT_16( tilt_swb_fec_fx, ( 8 << 11 ) ) ) /* tilt_swb_fec_fx in Q11 */ - { - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 19661 /*0.6f Q15*/ ); - } - ELSE IF( EQ_16( st->nbLostCmpt, 2 ) ) - { - GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 11469 /*0.35f Q15*/ ); - } - ELSE - { - GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 6554 /*0.2f Q15*/ ); - } - GainFrame_fx = Mult_32_16( GainFrame_fx, st->cummulative_damping ); - } - ELSE - { - GainFrame_fx = hBWE_TD->GainFrame_prevfrm_fx; - move32(); /* gain locking */ - } - } - - IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) - { - test(); - IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) - { - L_tmp = L_mult( extract_l( hBWE_TD->prev2_shb_ener_sf_fx ), extract_l( hBWE_TD->prev3_shb_ener_sf_fx ) ); /*Q1*/ - tmp = round_fx( root_a_fx( L_tmp, 1, &exp ) ); /* Q = 15-exp */ - tmp1 = extract_l( hBWE_TD->prev1_shb_ener_sf_fx ); /*Q0*/ - i = sub( norm_s( tmp1 ), 1 ); - tmp1 = shl( tmp1, i ); /* Qi */ - IF( tmp == 0 ) - { - tmp = 32767 /*1.0f Q15*/; - move16(); /*Q15*/ - } - ELSE - { - scale_fx = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */ - scale_fx = s_max( scale_fx, 0 ); - tmp = shl_sat( scale_fx, sub( sub( 15, exp ), i ) ); /*Q15*/ - } - scale_fx = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */ - test(); - IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || - GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) - { - shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, scale_fx ); - - if ( GT_16( st->nbLostCmpt, 1 ) ) - { - shb_ener_sf_32 = L_shr( shb_ener_sf_32, 1 ); - } - } - ELSE - { - L_tmp = L_mult( scale_fx, scale_fx ); /* Q29 */ - shb_ener_sf_32 = L_shl( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, round_fx( L_tmp ) ), 2 ); - } - } - ELSE - { - test(); - IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || - GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) - { - shb_ener_sf_32 = L_shr( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ), 1 ); - } - ELSE - { - shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ); - } - } - } - - shb_ener_sf_32 = L_max( shb_ener_sf_32, 1l /*1.0f Q0*/ ); - mixFactors_fx = hBWE_TD->prev_mixFactors_fx; - move16(); - - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, 5 ); /* Q14 */ - } - ELSE - { - set16_fx( shb_res_gshape_fx, 16384 /*1.0f Q14*/, 5 ); /* Q14 */ - } - } - } - - /* get the gainshape delay */ - Copy( &st->GainShape_Delay[4], &st->GainShape_Delay[0], NUM_SHB_SUBFR / 4 ); - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - st->GainShape_Delay[i + 4] = GainShape_fx[i * 4]; /*Q15*/ - move16(); - } - - L_tmp = L_mult( voice_factors_fx[0], 8192 ); - L_tmp = L_mac( L_tmp, voice_factors_fx[1], 8192 ); - L_tmp = L_mac( L_tmp, voice_factors_fx[2], 8192 ); - mean_vf = mac_r( L_tmp, voice_factors_fx[3], 8192 ); - - Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k ); - - test(); - IF( EQ_16( st->coder_type, VOICED ) || GT_16( mean_vf, 13107 /*0.4f Q15*/ ) ) - { - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mult( voice_factors_fx[i], 26214 /*0.8f Q15*/ ); - vf_modified_fx[i] = mac_r( L_tmp, voice_factors_fx[i - 1], 6554 /*0.2f Q15*/ ); - move16(); - } - - IF( st->L_frame != L_FRAME ) - { - L_tmp = L_mult( voice_factors_fx[4], 26214 /*0.8f Q15*/ ); - vf_modified_fx[4] = mac_r( L_tmp, voice_factors_fx[3], 6554 /*0.2f Q15*/ ); - move16(); - } - } - - test(); - IF( st->use_partial_copy && st->nelp_mode_dec ) - { - set16_fx( vf_modified_fx, 0, NB_SUBFR16k ); - } - - /* SHB LSF from current frame; and convert to LSP for interpolation */ - E_LPC_lsf_lsp_conversion( lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER ); - - test(); - IF( EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) - { - /* SHB LSP values from prev. frame for interpolation */ - Copy( hBWE_TD->swb_lsp_prev_interp_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); - } - ELSE - { - /* Use current frame's LSPs; in effect no interpolation */ - Copy( lsp_shb_2_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); - } - - test(); - test(); - test(); - IF( ( st->bws_cnt == 0 ) && ( st->bws_cnt1 == 0 ) && ( st->prev_use_partial_copy == 0 ) && ( st->use_partial_copy == 0 ) ) - { - lsf_diff_fx[0] = 16384; - move16(); /*Q15*/ - lsf_diff_fx[LPC_SHB_ORDER - 1] = 16384; - move16(); /*Q15*/ - FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) - { - lsf_diff_fx[i] = sub( lsf_shb_fx[i], lsf_shb_fx[i - 1] ); - move16(); - } - - a2rc_fx( hBWE_TD->cur_sub_Aq_fx + 1, refl_fx, M ); - tmp = add( 16384, shr( refl_fx[0], 1 ) ); /*Q14*/ - tmp1 = mult( 27425, tmp ); - tmp1 = mult( tmp1, tmp ); /*Q10*/ - tmp2 = shr( mult( 31715, tmp ), 2 ); /*Q10*/ - tilt_para_fx = add( sub( tmp1, tmp2 ), 1335 ); /*Q10*/ - - test(); - IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) - { - FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) - { - hBWE_TD->prev_lsf_diff_fx[i - 1] = shr( lsf_diff_fx[i], 1 ); - move16(); - } - } - - IF( LE_32( st->extl_brate, FB_TBE_1k8 ) ) - { - test(); - test(); - test(); - test(); - test(); - IF( !( GT_16( hBWE_TD->prev_tilt_para_fx, 5120 ) && ( EQ_16( st->coder_type, TRANSITION ) || LT_16( tilt_para_fx, 1024 ) ) ) && - !( ( ( LT_16( hBWE_TD->prev_tilt_para_fx, 3072 ) && GE_16( st->prev_coder_type, VOICED ) ) ) && GT_16( tilt_para_fx, 5120 ) ) ) - { - FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) - { - IF( LT_16( lsf_diff_fx[i], hBWE_TD->prev_lsf_diff_fx[i - 1] ) ) - { - tmp = mult( 26214, lsf_diff_fx[i] ); - - test(); - IF( ( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ - { - st->BER_detect = 1; - move16(); - tmp = 0; - move16(); - } - ELSE - { - tmp = div_s( tmp, hBWE_TD->prev_lsf_diff_fx[i - 1] ); - } - - tmp = s_max( tmp, 16384 ); - w_fx[i] = s_min( tmp, 32767 ); - move16(); - } - ELSE - { - tmp = mult( 26214, hBWE_TD->prev_lsf_diff_fx[i - 1] ); - - test(); - IF( ( lsf_diff_fx[i] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ - { - st->BER_detect = 1; - move16(); - tmp = 0; - move16(); - } - ELSE - { - tmp = div_s( tmp, lsf_diff_fx[i] ); - } - - tmp = s_max( tmp, 16384 ); - w_fx[i] = s_min( tmp, 32767 ); - move16(); - } - } - w_fx[0] = w_fx[1]; - move16(); - w_fx[LPC_SHB_ORDER - 1] = w_fx[LPC_SHB_ORDER - 2]; - move16(); - - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tmp1 = mult( lsp_shb_1_fx[i], sub( 32767, w_fx[i] ) ); - tmp2 = mult( lsp_shb_2_fx[i], w_fx[i] ); - lsp_temp_fx[i] = add( tmp1, tmp2 ); - move16(); - } - } - ELSE - { - Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); - } - - /* convert from lsp to lsf */ - lsp2lsf_fx( lsp_temp_fx, lsf_shb_fx, LPC_SHB_ORDER, 1 ); - } - - Copy( lsf_diff_fx + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 ); - hBWE_TD->prev_tilt_para_fx = tilt_para_fx; - move16(); - } - ELSE - { - Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); - } - - IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) - { - /* SHB LSP interpolation */ - ptr_lsp_interp_coef_fx = interpol_frac_shb; /*Q15*/ - FOR( j = 0; j < 4; j++ ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - L_tmp = L_mult( lsp_shb_1_fx[i], ( *ptr_lsp_interp_coef_fx ) ); - lsp_temp_fx[i] = mac_r( L_tmp, lsp_shb_2_fx[i], ( *( ptr_lsp_interp_coef_fx + 1 ) ) ); - move16(); - } - ptr_lsp_interp_coef_fx += 2; - - tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) ); - /* convert LSPs to LP coefficients */ - E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER ); -#ifndef FIX_1100_REMOVE_LPC_RESCALING - /* Bring the LPCs to Q12 */ - Copy_Scale_sig( lpc_shb_sf_fx + tmp, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_sf_fx[tmp] ), 2 ) ); - lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this - move16(); -#endif - } - } - - /* Save the SWB LSP values from current frame for interpolation */ - Copy( lsp_shb_2_fx, hBWE_TD->swb_lsp_prev_interp_fx, LPC_SHB_ORDER ); - - /* save the shb_ener and mixFactor values */ - hBWE_TD->prev3_shb_ener_sf_fx = hBWE_TD->prev2_shb_ener_sf_fx; - move32(); - hBWE_TD->prev2_shb_ener_sf_fx = hBWE_TD->prev1_shb_ener_sf_fx; - move32(); - hBWE_TD->prev1_shb_ener_sf_fx = shb_ener_sf_32; - move32(); - hBWE_TD->prev_res_shb_gshape_fx = shb_res_gshape_fx[4]; - move16(); - hBWE_TD->prev_mixFactors_fx = mixFactors_fx; - move16(); - - /* SWB CNG/DTX - update memories */ - IF( st->hTdCngDec != NULL ) - { - Copy( st->hTdCngDec->lsp_shb_prev_fx, st->hTdCngDec->lsp_shb_prev_prev_fx, LPC_SHB_ORDER ); - Copy( lsf_shb_fx, st->hTdCngDec->lsp_shb_prev_fx, LPC_SHB_ORDER ); - } - - /* convert LSPs back into LP coeffs */ - E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_fx, LPC_SHB_ORDER ); - Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Q12 */ - lpc_shb_fx[0] = ONE_IN_Q12; - move16(); - - test(); - IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1 - vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ - /* i: mixFactors_fx in Q15 */ - /* o: vind in Q0 */ - } - ELSE - { - vind = shl( mixFactors_fx, 3 - 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*8*/ - /* i: mixFactors_fx in Q15 */ - /* o: vind in Q0 */ - } - - /* Determine formant PF strength */ - formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); - /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */ - IF( GT_32( st->total_brate, ACELP_32k ) ) - { - FOR( j = 0; j < 4; j++ ) - { - Copy( lpc_shb_fx, &lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )], LPC_SHB_ORDER + 1 ); - } - } - - /* From low band excitation, generate highband excitation */ - - /* -------- start of memory rescaling -------- */ - /* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */ - Lmax = 0; - move32(); - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) - { - Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) ); - } - Q_bwe_exc = norm_l( Lmax ); - if ( Lmax == 0 ) - { - Q_bwe_exc = 31; - move16(); - } - Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); - find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ - - tmp = add( st->prev_Q_bwe_exc, n_mem ); - if ( GT_16( Q_bwe_exc, tmp ) ) - { - Q_bwe_exc = tmp; - move16(); - } - - /* rescale the memories if Q_bwe_exc is different from previous frame */ - sc = sub( Q_bwe_exc, st->prev_Q_bwe_exc ); - IF( sc != 0 ) - { - rescale_genSHB_mem_dec( st, sc ); - } - - /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ - sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); - - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) - { - bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) ); - move16(); - } - - /* state_syn_shbexc_fx is kept at (st_fx->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */ - - /* save the previous Q factor (32-bit) of the buffer */ - st->prev_Q_bwe_exc = Q_bwe_exc; - move16(); - - Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ - - /* -------- end of rescaling memories -------- */ - - Q_bwe_exc_fb = st->prev_Q_bwe_exc_fb; - move16(); - - Q_shb = 0; - move16(); - - Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); - GenShapedSHBExcitation_ivas_dec_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, - hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - st->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl, - &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_32, - shb_res_gshape_fx, shb_res_dummy_fx, &vind, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st->prev_Q_bwe_syn, st->total_brate, st->prev_bfi, - st->element_mode, st->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st->extl_brate, MSFlag, - NULL, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL ); - - *Q_white_exc = Q_bwe_exc_fb; - move16(); - IF( EQ_16( st->extl, FB_TBE ) ) - { - st->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; - move16(); - } - ELSE - { - /*Indirectly a memory reset of FB memories for next frame such that rescaling of memories would lead to 0 due to such high prev. Q value. - 51 because of 31 + 20(shift of Q_bwe_exc_fb before de-emphasis)*/ - st->prev_Q_bwe_exc_fb = 51; - move16(); - } - - /* rescale the TBE post proc memory */ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st->prev_Q_bwe_syn ) ); - move16(); - } - /* fill-in missing SHB excitation */ - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) - { - Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, shaped_shb_excitation_fx, L_SHB_LAHEAD ); - } - - IF( hStereoICBWE != NULL ) - { - Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); - } - - test(); - IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - FOR( i = 0; i < L_FRAME16k; i += L_SUBFR16k ) - { - /* TD BWE post-processing */ - PostShortTerm_ivas_dec_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, - hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); - } - - Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ - - tmp = sub( shl( Q_bwe_exc, 1 ), 31 + 16 ); - prev_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ - curr_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ - FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) - { - prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /*2*Q_bwe_exc*/ - curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ - } - - if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) - { - curr_pow_fx = L_shr( curr_pow_fx, 2 ); /* Q(2*Q_bwe_exc) */ - } - - Lscale = root_a_over_b_fx( curr_pow_fx, - shl( Q_bwe_exc, 1 ), - prev_pow_fx, - shl( Q_bwe_exc, 1 ), - &exp ); - - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ - move16(); - } - IF( exp < 0 ) - { - Lscale = L_shl( Lscale, exp ); - exp = 0; - move16(); - } - FOR( ; i < L_SHB_LAHEAD + 10; i++ ) - { - temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ - temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); - Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ - move16(); - } - } - ELSE - { - /* reset the PF memories if the PF is not running */ - set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - } - - /* Update SHB excitation */ - Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ - l_subframe = L_FRAME16k / NUM_SHB_SUBGAINS; - move16(); - L_ener = EPSILON_FX_SMALL; - move32(); - - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - L_tmp = 0; - move32(); - ener_tmp_fx[i] = EPSILON_FX_SMALL; - move32(); - - Word64 tmp64 = 0; - move64(); - FOR( j = 0; j < l_subframe; j++ ) - { - tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )], shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )] ); /* 2*Q_bwe_exc */ - } - L_tmp = W_sat_l( tmp64 ); - - L_tmp = Mult_32_16( L_tmp, 410 /*0.0125 Q15*/ ); /* 2*Q_bwe_exc: ener_tmp_fx in (2*Q_bwe_exc) */ - IF( L_tmp != 0 ) - { - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - exp = sub( exp, sub( 30, i_mult( 2, Q_bwe_exc ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - ener_tmp_fx[i] = L_shl_sat( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ - move32(); - L_ener = L_add_sat( L_ener, L_shr( ener_tmp_fx[i], 2 ) ); /* 2*Q_bwe_exc */ - } - } - ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ - /* WB/SWB bandwidth switching */ - IF( st->bws_cnt > 0 ) - { - IF( is_fractive == 0 ) - { - IF( GT_16( st->tilt_wb_fx, 2048 ) ) /*assuming st->tilt_wb_fx in Q11*/ - { - st->tilt_wb_fx = 2048; - move16(); - } - ELSE IF( LT_16( st->tilt_wb_fx, 1024 ) ) - { - st->tilt_wb_fx = 1024; - move16(); - } - test(); - if ( EQ_16( st->prev_fractive, 1 ) && GT_16( st->tilt_wb_fx, 1024 ) ) - { - st->tilt_wb_fx = 1024; - move16(); - } - } - ELSE - { - IF( GT_16( st->tilt_wb_fx, 8192 ) ) - { - IF( st->prev_fractive == 0 ) - { - st->tilt_wb_fx = 8192; - move16(); - } - ELSE - { - st->tilt_wb_fx = 16384; - move16(); - } - } - ELSE - { - st->tilt_wb_fx = shl( st->tilt_wb_fx, 2 ); - move16(); - } - } - - IF( ener_fx != 0 ) - { - L_tmp = L_shl( L_mult0( ener_fx, st->tilt_wb_fx ), sub( st->Q_syn2, 13 ) ); /* 2+11 +st->Q_syn2 -13 = st->Q_syn2*/ - exp_ener = norm_s( ener_fx ); - tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ - inv_ener = shr( div_s( 16384, tmp ), 1 ); /*Q(15+14-2-exp-1) = 26 - exp*/ - - test(); - IF( GT_32( L_tmp, st->enerLH_fx ) ) /*st->Q_syn2*/ - { - st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ - move16(); - /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ - } - ELSE IF( LT_32( L_tmp, Mult_32_16( st->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) ) - { - st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ - move16(); - /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ - } - L_tmp = L_mult0( st->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ - GainFrame_prevfrm_fx = L_shr( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ - } - ELSE - { - GainFrame_prevfrm_fx = 0; - move32(); - } - - IF( EQ_16( is_fractive, 1 ) ) - { - GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 10 ); - } - ELSE - { - GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 8 ); - } - - test(); - IF( EQ_16( ( is_fractive & st->prev_fractive ), 1 ) && GT_32( GainFrame_fx, GainFrame_prevfrm_fx ) ) - { - GainFrame_fx = L_add( Mult_32_16( GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); /* 18 +15 -15 = 18*/ - } - ELSE - { - test(); - test(); - test(); - test(); - IF( ( LT_32( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st->prev_enerLL_fx, 1 ), st->enerLL_fx ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) && ( s_xor( is_fractive, st->prev_fractive ) == 0 ) ) - { - GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( GainFrame_prevfrm_fx, 1 ) ); - } - ELSE - { - test(); - IF( ( is_fractive == 0 ) && EQ_16( st->prev_fractive, 1 ) ) - { - L_tmp1 = L_shl( Mult_32_16( GainFrame_fx, 3277 ), 13 ); /* 31 */ - L_tmp = L_sub( 2147483647, L_tmp1 ); /* 31 */ - GainFrame_fx = L_add( Mult_32_32( GainFrame_fx, L_tmp ), Mult_32_32( GainFrame_prevfrm_fx, L_tmp1 ) ); /* 18 */ - } - ELSE - { - GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( L_min( GainFrame_prevfrm_fx, GainFrame_fx ), 1 ) ); /* 18 */ - } - } - } - - GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( sub( N_WS2N_FRAMES, st->bws_cnt ), 819 ) ); /*Q18*/ - } - ELSE - { - IF( st->bws_cnt1 > 0 ) - { - GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( st->bws_cnt1, 819 ) ); /*Q18*/ - } - IF( GE_16( st->nbLostCmpt, 1 ) ) - { - ener_fx = s_max( 1, ener_fx ); - exp_ener = norm_s( ener_fx ); - tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ - inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/ - prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */ - } - - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->clas_dec != UNVOICED_CLAS ) && NE_16( st->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) && - ( ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st->enerLL_fx, 1 ), st->prev_enerLL_fx ) ) || ( GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st->enerLH_fx, 1 ), st->prev_enerLH_fx ) ) ) ) - { - IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) ) /*18*/ - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 13107 ), Mult_32_16( GainFrame_fx, 19661 ) ); /*18*/ - } - ELSE IF( GT_32( L_shr( prev_ener_ratio_fx, 1 ), GainFrame_fx ) ) - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); - } - ELSE - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); - } - - test(); - IF( GT_16( tilt_swb_fec_fx, hBWE_TD->tilt_swb_fec_fx ) && ( hBWE_TD->tilt_swb_fec_fx > 0 ) ) - { - exp = norm_s( hBWE_TD->tilt_swb_fec_fx ); - tmp = shl( hBWE_TD->tilt_swb_fec_fx, exp ); /*Q(11+exp)*/ - tmp = div_s( 16384, tmp ); /*Q(15+14-11-exp)*/ - tmp = extract_h( L_shl( L_mult0( tmp, st->tilt_wb_fx ), sub( exp, 1 ) ) ); /*18 -exp +11 + exp -1 -16 =12; */ - GainFrame_fx = L_shl( Mult_32_16( GainFrame_fx, s_min( tmp, 20480 ) ), 3 ); /*Q18 = 18 +12 -15 +3 */ - } - } - ELSE IF( ( ( st->clas_dec != UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 4096 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && - ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) ) - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); - } - } - ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) - { - test(); - IF( GT_16( tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) ) - { - GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6554 /*0.2f in Q15*/ ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 /*4.0f in Q12*/ ), 3 ) ); /*Q18*/ - } - ELSE - { - GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 16384 ), Mult_32_16( GainFrame_fx, 16384 ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 ), 3 ) ); /*Q18*/ - } - } - ELSE IF( GT_32( prev_ener_ratio_fx, GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) - { - test(); - IF( GT_16( tilt_swb_fec_fx, 20480 ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 ) ) - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 16384 /*0.5f in Q15*/ ), Mult_32_16( GainFrame_fx, 16384 /*0.5f in Q15*/ ) ); /* Q18 */ - } - ELSE - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 /*0.2f in Q15*/ ), Mult_32_16( GainFrame_fx, 26214 /*0.8f in Q15*/ ) ); /* Q18 */ - } - } - } - } - - st->prev_fractive = is_fractive; - move16(); - - /* Adjust the subframe and frame gain of the synthesized shb signal */ - /* Scale the shaped excitation */ - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - L_tmp = L_mult( pitch_buf_fx[0], 8192 ); - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 8192 ); /* pitch_buf in Q6 x 0.25 in Q15 */ - } - pitch_fx = round_fx( L_tmp ); /* Q6 */ - } - ELSE - { - L_tmp = L_mult( pitch_buf_fx[0], 6554 ); - FOR( i = 1; i < NB_SUBFR16k; i++ ) - { - L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 6554 ); /* pitch_buf in Q6 x 0.2 in Q15 */ - } - pitch_fx = round_fx( L_tmp ); /* Q6 */ - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( GE_32( st->extl_brate, SWB_TBE_2k8 ) && EQ_16( st->prev_coder_type, st->coder_type ) && NE_16( st->coder_type, UNVOICED ) ) || ( LT_32( st->extl_brate, SWB_TBE_2k8 ) && ( EQ_16( st->prev_coder_type, st->coder_type ) || ( EQ_16( st->prev_coder_type, VOICED ) && EQ_16( st->coder_type, GENERIC ) ) || ( EQ_16( st->prev_coder_type, GENERIC ) && EQ_16( st->coder_type, VOICED ) ) ) ) ) && GT_16( pitch_fx, 4480 /*70 in Q6*/ ) && LT_16( st->extl, FB_TBE ) && NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - GainShape_tmp_fx[i] = GainShape_fx[i * 4]; /* Q15 */ - move16(); - } - - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - L_tmp1 = Mult_32_16( ener_tmp_fx[i], GainShape_tmp_fx[i] ); /* (2*Q_bwe_exc) */ - L_tmp2 = Mult_32_16( hBWE_TD->prev_ener_fx, hBWE_TD->prev_GainShape_fx ); /* (2*st->prev_ener_fx_Q) */ - tmp = sub( shl( Q_bwe_exc, 1 ), shl( st->prev_ener_fx_Q, 1 ) ); - L_tmp2 = L_shl_sat( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ - IF( GT_32( L_tmp1, L_tmp2 ) ) - { - L_tmp = L_tmp2; - move32(); - if ( L_tmp2 < 0 ) - { - L_tmp = L_negate( L_tmp2 ); - } - - expb = norm_l( L_tmp ); - fracb = round_fx_sat( L_shl_sat( L_tmp, expb ) ); - expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */ - - expa = norm_l( ener_tmp_fx[i] ); - fraca = extract_h( L_shl( ener_tmp_fx[i], expa ) ); - expa = sub( 30, expa ); - - scale_fx = shr( sub( fraca, fracb ), 15 ); - fracb = shl( fracb, scale_fx ); - expb = sub( expb, scale_fx ); - - tmp = div_s( fracb, fraca ); - exp = sub( sub( expb, expa ), 1 ); - tmp = shl( tmp, exp ); - GainShape_tmp_fx[i] = add( tmp, shr( GainShape_tmp_fx[i], 1 ) ); /* Q15 */ - move16(); - } - - hBWE_TD->prev_ener_fx = ener_tmp_fx[i]; - move32(); - hBWE_TD->prev_GainShape_fx = GainShape_tmp_fx[i]; - move16(); - st->prev_ener_fx_Q = Q_bwe_exc; - move16(); - } - - FOR( i = 0; i < NUM_SHB_SUBFR; i++ ) - { - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); - } - GainShape_fx[i] = GainShape_tmp_fx[idx]; - move16(); - } - } - ELSE - { - st->prev_ener_fx_Q = Q_bwe_exc; - move16(); - } - st->prev_Q_bwe_syn = Q_bwe_exc; - move16(); - - - /* Gain shape smoothing after quantization */ - test(); - IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - GainShape_tmp_fx[i] = GainShape_fx[i * NUM_SHB_SUBGAINS]; - move16(); - } - - lls_interp_n_fx( GainShape_tmp_fx, NUM_SHB_SUBGAINS, &GainShape_tilt_fx, &temp_fx, 1 ); - - test(); - IF( GE_16( vind, 6 ) && LT_16( abs_s( GainShape_tilt_fx ), 3932 ) ) - { - feedback_fx = 9830; - move16(); - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - GainShape_fx[i] = add_sat( mult( sub( 32767, feedback_fx ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), mult( feedback_fx, GainShape_tmp_fx[i] ) ); - move16(); - } - - FOR( i = NUM_SHB_SUBFR - 1; i > 0; i-- ) - { - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); - } - GainShape_fx[i] = GainShape_fx[idx]; - move16(); - } - } - } - - /* fil-in missing memory */ - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) - { - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - Word16 intermediate = mult( shaped_shb_excitation_fx[i], subwin_shb_fx[L_SHB_LAHEAD - i] ); - Word32 intermediate_32 = Mpy_32_16_1( Mpy_32_16_1( GainFrame_fx, window_shb_fx[L_SHB_LAHEAD - 1 - i] ), intermediate ); - hBWE_TD->syn_overlap_fx[i] = round_fx( L_shl_sat( intermediate_32, sub( 16, ( add( Q_bwe_exc, 18 - 15 ) ) ) ) ); - move16(); - } - } - - Word16 n_mem3_new = 0; - move16(); - find_max_mem_dec_m3( st, &n_mem3_new ); - - ScaleShapedSHB_fx( SHB_OVERLAP_LEN, - shaped_shb_excitation_fx, /* i/o: Q_bwe_exc */ - hBWE_TD->syn_overlap_fx, - GainShape_fx, /* Q15 */ - GainFrame_fx, /* Q18 */ - window_shb_fx, - subwin_shb_fx, - &Q_bwe_exc, &Qx, n_mem3_new, st->prev_Q_bwe_syn2 ); - - IF( hStereoICBWE != NULL ) - { - Copy_Scale_sig_16_32_DEPREC( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); - Copy( GainShape_fx, hStereoICBWE->gshapeRef_fx, NUM_SHB_SUBFR ); - hStereoICBWE->gFrameRef_fx = GainFrame_fx; - move32(); - - Copy( shaped_shb_excitation_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); - } - - max_val = 0; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - max_val = s_max( max_val, abs_s( shaped_shb_excitation_fx[i] ) ); /* Q0 */ - } - IF( max_val == 0 ) - { - curr_frame_pow_fx = 0; - move32(); - n = 0; - move16(); - } - ELSE - { - n = norm_s( max_val ); - max_val = 0; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shaped_shb_excitation_frac[i] = shl_sat( shaped_shb_excitation_fx[i], n ); /*Q_bwe_exc+n*/ - move16(); - } - - curr_frame_pow_fx = 0; - move32(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - L_tmp = L_mult0( shaped_shb_excitation_frac[i], shaped_shb_excitation_frac[i] ); /*2*(Q_bwe_exc+n)*/ - curr_frame_pow_fx = L_add( curr_frame_pow_fx, L_shr( L_tmp, 9 ) ); /*2*(Q_bwe_exc+n)-9*/ - } - } - curr_frame_pow_exp = sub( shl( add( Q_bwe_exc, n ), 1 ), 9 ); - tmp = sub( st->prev_frame_pow_exp, curr_frame_pow_exp ); - IF( tmp > 0 ) /* shifting prev */ - { - IF( GT_16( tmp, 32 ) ) - { - st->prev_frame_pow_exp = add( curr_frame_pow_exp, 32 ); - move16(); - tmp = 32; - move16(); - } - hBWE_TD->prev_swb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, tmp ); - move32(); - st->prev_frame_pow_exp = curr_frame_pow_exp; - move16(); - } - ELSE /* shifting curr */ - { - IF( LT_16( tmp, -32 ) ) - { - curr_frame_pow_exp = sub( st->prev_frame_pow_exp, 32 ); - tmp = -32; - move16(); - } - curr_frame_pow_fx = L_shr( curr_frame_pow_fx, -tmp ); - curr_frame_pow_exp = st->prev_frame_pow_exp; - move16(); - } - test(); - test(); - IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) ) - { - test(); - test(); - IF( ( GT_32( L_shr( curr_frame_pow_fx, 1 ), hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) && - ( GT_32( hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16( st->prev_coder_type, UNVOICED ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - scale_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ - - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ - } - ELSE - { - scale_fx = temp_fx = 32767; - move16(); /*Q15*/ - move16(); /*Q15*/ - } - - FOR( j = 0; j < 8; j++ ) - { - GainShape_fx[2 * j] = mult_r( GainShape_fx[2 * j], scale_fx ); - move16(); - GainShape_fx[2 * j + 1] = mult_r( GainShape_fx[2 * j + 1], scale_fx ); - move16(); - FOR( i = 0; i < L_FRAME16k / 8; i++ ) - { - shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )] = mult_r( shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )], scale_fx ); - move16(); - } - - IF( temp_fx > 0 ) - { - /* scale_fx <= temp_fx, due to scale_fx = sqrt( st->prev_swb_bwe_frame_pow_fx/curr_frame_pow_fx ), temp_fx = sqrt( scale_fx, 1.f/8.f ) - and curr_frame_pow_fx > st->prev_swb_bwe_frame_pow_fx -> scale_fx <= 1.0, sqrt(scale_fx, 1.f/8.f) >= scale_fx */ - IF( LT_16( scale_fx, temp_fx ) ) - { - scale_fx = div_s( scale_fx, temp_fx ); - } - ELSE - { - scale_fx = 32767; - move16(); - } - } - ELSE - { - scale_fx = 0; - move16(); - } - } - } - - /* adjust the FEC frame energy */ - IF( st->bfi ) - { - scale_fx = temp_fx = 4096; - move16(); /*Q12*/ - move16(); - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) && - NE_16( st->prev_coder_type, UNVOICED ) && - ( st->last_good != UNVOICED_CLAS ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); /*31 - exp*/ - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && EQ_16( st->nbLostCmpt, 1 ) && - ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && - ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - scale_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - } - ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && - ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && - ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/ - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - } - - FOR( j = 0; j < 8; j++ ) - { - GainShape_fx[2 * j] = shl_sat( mult_r( GainShape_fx[2 * j], scale_fx ), 3 ); - move16(); /* 15 +12 +3-15 =15*/ - GainShape_fx[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx ), 3 ); - move16(); - FOR( i = 0; i < 40; i++ ) - { - shaped_shb_excitation_fx[i + j * L_FRAME16k / 8] = shl( mult_r( shaped_shb_excitation_fx[i + j * L_FRAME16k / 8], scale_fx ), 3 ); - move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/ - } - - IF( temp_fx > 0 ) - { - IF( LT_16( scale_fx, temp_fx ) ) - { - scale_fx = shr( div_s( scale_fx, temp_fx ), 3 ); - } - ELSE - { - tmp1 = sub( norm_s( scale_fx ), 1 ); - tmp2 = norm_s( temp_fx ); - scale_fx = div_s( shl( scale_fx, tmp1 ), shl( temp_fx, tmp2 ) ); - scale_fx = shr( scale_fx, add( sub( tmp1, tmp2 ), 3 ) ); - } - } - ELSE - { - scale_fx = 0; - move16(); - } - } - } - - hBWE_TD->prev_swb_bwe_frame_pow_fx = curr_frame_pow_fx; - move32(); - st->prev_frame_pow_exp = curr_frame_pow_exp; - move16(); - - Word64 prev_ener_shb64 = 0; - move64(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - prev_ener_shb64 = W_mac0_16_16( prev_ener_shb64, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* Q0 */ - } - L_prev_ener_shb = W_sat_l( prev_ener_shb64 ); - - L_prev_ener_shb = Mult_32_16( L_prev_ener_shb, 26214 ); /* 2*Q_bwe_exc_mod+8; 26214=(1/L_FRAME16k) in Q23 */ - st->prev_ener_shb_fx = 0; - move16(); - IF( L_prev_ener_shb != 0 ) - { - exp = norm_l( L_prev_ener_shb ); - tmp = extract_h( L_shl( L_prev_ener_shb, exp ) ); - exp = sub( exp, sub( 30, ( add( i_mult( 2, Q_bwe_exc ), 8 ) ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ - move16(); - } - - IF( st->hBWE_FD != NULL ) - { - L_tmp = Mult_32_16( curr_frame_pow_fx, 26214 ); /* curr_frame_pow_exp+8; 26214=(1/L_FRAME16k) in Q23 */ - tmp = 0; - move16(); - IF( L_tmp != 0 ) - { - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - exp = sub( exp, sub( 30, add( curr_frame_pow_exp, 8 ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ - } - set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ - } - - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shaped_shb_excitation_fx_32[i] = L_shl( shaped_shb_excitation_fx[i], sub( Q11, Q_bwe_exc ) ); - move32(); - } - - /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ - GenSHBSynth_fx_32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); - Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); - Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); - - /* resample SHB synthesis (if needed) and scale down */ - synth_scale_fx = 32767; - move16(); /* 1.0 in Q15 */ - if ( EQ_16( st->codec_mode, MODE1 ) ) - { - synth_scale_fx = 29491; - move16(); /* 0.9 in Q15 */ - } - - IF( EQ_32( st->output_Fs, 48000 ) ) - { - IF( EQ_16( st->extl, FB_TBE ) ) - { - tmp = norm_l( GainFrame_fx ); - if ( GainFrame_fx == 0 ) - { - tmp = 31; - move16(); - } - L_tmp = L_shl( GainFrame_fx, tmp ); /* 18 + tmp */ - - tmp1 = 0; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); - } - L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ - White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ - move16(); - tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); - } - - *Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */ - move16(); - tmp = norm_s( tmp1 ); - if ( tmp1 == 0 ) - { - tmp = 15; - move16(); - } - - FOR( i = 0; i < L_FRAME16k; i++ ) - { - White_exc16k_fx[i] = shl( White_exc16k_fx[i], sub( tmp, 1 ) ); - move16(); - } - *Q_white_exc = sub( add( *Q_white_exc, tmp ), 1 ); - move16(); - } - - IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ - { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); - move32(); - } - } - interpolate_3_over_2_allpass_32( error_fx, L_FRAME32k, synth_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); - } - ELSE IF( EQ_32( st->output_Fs, 32000 ) ) - { - IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ - { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - synth_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); - move32(); /*Qx*/ - } - } - ELSE - { - Copy32( error_fx, synth_fx, L_FRAME32k ); - } - } - ELSE IF( EQ_32( st->output_Fs, 16000 ) ) - { - IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ - { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); - move32(); - } - } - - Decimate_allpass_steep_fx32( error_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, synth_fx ); - } - - - /* Update previous frame parameters for FEC */ - Copy( lsf_shb_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; - move32(); /*Q18*/ - hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; - move16(); - - if ( !st->bfi ) - { - hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ - move16(); - } - } - ELSE - { - IF( !st->bfi ) - { - hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; - move32(); /*Q18*/ - hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; - move16(); - hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ - move16(); - } - } - - hBWE_TD->prev_ener_fx = ener_tmp_fx[NUM_SHB_SUBGAINS - 1]; - move32(); - hBWE_TD->prev_GainShape_fx = GainShape_fx[NUM_SHB_SUBFR - 1]; - move16(); - st->prev_Q_bwe_syn2 = Q_bwe_exc; - move16(); - st->prev_Qx = Q_bwe_exc; - move16(); - - return; -} -/*-------------------------------------------------------------------* - * Dequant_lower_LSF() - * - * Dequantized the lower LSFs - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * Map_higher_LSF() - * - * Map the higher LSFs from the lower LSFs - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * Map_higher_LSF() - * - * Map the higher LSFs from the lower LSFs - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * dequantizeSHBparams() - * - * Dequantize super highband spectral envolope, temporal gains and frame gain - *-------------------------------------------------------------------*/ - - -void GenTransition_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 element_mode, /* i : element mode : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 rf_flag, /* i : RF flag : Q0 */ - const Word32 total_brate, /* i : total bitrate : Q0 */ - const Word16 prev_Qx ) -{ - Word16 i, length; - - Word32 syn_overlap_32k_fx[2 * SHB_OVERLAP_LEN]; - - /* set targeted length of transition signal */ - length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); - - /* upsample overlap snippet */ - Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, SHB_OVERLAP_LEN, syn_overlap_32k_fx ); - - /* perFORm spectral flip and downmix with overlap snippet to match HB synth */ - test(); - test(); - test(); - test(); - IF( ( ( element_mode == EVS_MONO ) && ( rf_flag || EQ_32( total_brate, ACELP_9k60 ) ) ) || ( ( element_mode > EVS_MONO ) && EQ_16( L_frame, L_FRAME ) ) ) - { - flip_and_downmix_generic_fx_32( syn_overlap_32k_fx, syn_overlap_32k_fx, 2 * SHB_OVERLAP_LEN, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + HILBERT_ORDER1, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), &( hBWE_TD->syn_dm_phase ) ); - } - ELSE - { - FOR( i = 0; i < 2 * SHB_OVERLAP_LEN; i++ ) - { - IF( i % 2 == 0 ) - { - syn_overlap_32k_fx[i] = L_negate( syn_overlap_32k_fx[i] ); - } - ELSE - { - syn_overlap_32k_fx[i] = syn_overlap_32k_fx[i]; - } - move32(); - } - } - - /* cross fade of overlap snippet and mirrored HB synth from previous frame */ - FOR( i = 0; i < 2 * L_SHB_LAHEAD; i++ ) - { - outputHB_fx[i] = L_add_sat( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_32k_fx[i] ), Mpy_32_16_1( syn_overlap_32k_fx[i], window_shb_32k_fx[2 * L_SHB_LAHEAD - 1 - i] ) ); - move32(); - } - - /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ - FOR( ; i < length; i++ ) - { - outputHB_fx[i] = L_shl( hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i], sub( Q11, prev_Qx ) ); - move32(); - } - - IF( EQ_32( output_Fs, 48000 ) ) - { - interpolate_3_over_2_allpass_32( outputHB_fx, length, outputHB_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); - } - ELSE IF( EQ_32( output_Fs, 16000 ) ) - { - Decimate_allpass_steep_fx32( outputHB_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, outputHB_fx ); - } - - return; -} -void GenTransition_WB_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ -) -{ - Word16 i, length; - Word32 speech_buf_16k1_fx[SHB_OVERLAP_LEN], speech_buf_16k2_fx[2 * SHB_OVERLAP_LEN]; - Word32 upsampled_synth_fx[L_FRAME48k]; - - /* set targeted length of transition signal */ - length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); - - /* upsample overlap snippet */ - Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->state_lsyn_filt_shb_fx_32, SHB_OVERLAP_LEN / 2, speech_buf_16k1_fx ); - Interpolate_allpass_steep_32( speech_buf_16k1_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, SHB_OVERLAP_LEN, speech_buf_16k2_fx ); - - /* perform spectral flip and downmix with overlap snippet to match HB synth */ - FOR( i = 0; i < SHB_OVERLAP_LEN; i++ ) - { - IF( i % 2 == 0 ) - { - speech_buf_16k2_fx[i] = L_negate( speech_buf_16k2_fx[i] ); - move32(); - } - ELSE - { - speech_buf_16k2_fx[i] = speech_buf_16k2_fx[i]; - move32(); - } - } - - /* cross fade of overlap snippet and mirrored HB synth from previous frame */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - outputHB_fx[i] = L_add( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_fx[i] ), Mpy_32_16_1( speech_buf_16k2_fx[i], window_shb_fx[L_SHB_LAHEAD - 1 - i] ) ); - move32(); - outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); - move32(); - } - - /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ - FOR( ; i < length; i++ ) - { - outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i]; - move32(); - outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); - move32(); - } - - /* upsampling if necessary */ - IF( EQ_32( output_Fs, 32000 ) ) - { - Interpolate_allpass_steep_32( outputHB_fx, hBWE_TD->mem_resamp_HB_fx_32, L_FRAME16k, upsampled_synth_fx ); - Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME32k ); - } - ELSE IF( EQ_32( output_Fs, 48000 ) ) - { - interpolate_3_over_1_allpass_32( outputHB_fx, L_FRAME16k, upsampled_synth_fx, hBWE_TD->mem_resamp_HB_fx_32 ); - Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME48k ); - } - - return; -} - -/*-------------------------------------------------------------------* - * td_bwe_dec_init() - * - * Initialize TD BWE state structure at the decoder - *-------------------------------------------------------------------*/ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 28ac01671..a37ebf9d9 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -7,6 +7,7 @@ #include "options.h" #include "rom_com.h" #include "prot_fx.h" +#include "prot.h" #include "rom_dec.h" #include "stl.h" @@ -31,6 +32,11 @@ Word16 dotp_loc( const Word16 n /* i : vector length */ ); +void find_max_mem_dec_m3( + Decoder_State *st, + Word16 *n_mem3 ); + + /* gain shape concealment code */ static void gradientGainShape( Decoder_State *st_fx, Word16 *GainShape, Word32 *GainFrame ); @@ -3695,12 +3701,12 @@ static void gradientGainShape( IF( GT_16( 8192, tmp ) ) { - GainShape[add( i * 4, j )] = shl( tmp, 2 ); + GainShape[i * 4 + j] = shl( tmp, 2 ); move16(); /* (GainShapeTemp[i]*0.6)>>1 */ } ELSE { - GainShape[add( i * 4, j )] = 32767; + GainShape[i * 4 + j] = 32767; move16(); /* Clipping here to avoid the a huge change of the code due to gain shape change */ } } @@ -3716,12 +3722,12 @@ static void gradientGainShape( { IF( LT_16( GainShapeTemp[i], 16384 ) ) { - GainShape[add( i * 4, j )] = shl( GainShapeTemp[i], 1 ); + GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 ); move16(); } ELSE { - GainShape[add( i * 4, j )] = 32767; + GainShape[i * 4 + j] = 32767; move16(); } } @@ -3750,12 +3756,12 @@ static void gradientGainShape( { IF( LT_16( GainShapeTemp[i], 16384 ) ) { - GainShape[add( i * 4, j )] = shl( GainShapeTemp[i], 1 ); + GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 ); move16(); } ELSE { - GainShape[add( i * 4, j )] = 32767; + GainShape[i * 4 + j] = 32767; move16(); } } @@ -5300,3 +5306,2019 @@ void td_bwe_dec_init_fx( return; } + +/*-------------------------------------------------------------------* + * ResetSHBbuffer_Dec() + * + * + *-------------------------------------------------------------------*/ + +static void calc_tilt_bwe_fx_loc( + const Word32 *sp_fx, /* i : input signal : Q11 */ + Word32 *tilt_fx, /* o : signal tilt : tilt_fx_q */ + Word16 *tilt_fx_q, /* o : signal tilt */ + const Word16 N /* i : signal length : Q0 */ +) +{ + Word16 i; + Word64 r0_fx, r1_fx; + + r0_fx = EPSILON_FX_SMALL; + move64(); + FOR( i = 0; i < N; i++ ) + { + r0_fx = W_add( r0_fx, W_shr( W_mult_32_32( sp_fx[i], sp_fx[i] ), 1 ) ); /*Q11*2 - 1*/ + } + r1_fx = W_deposit32_l( abs( L_sub( sp_fx[1], sp_fx[0] ) ) ); /*Q11*/ + FOR( i = 2; i < N; i++ ) + { + IF( W_mult_32_32( L_sub( sp_fx[i], sp_fx[i - 1] ) /*Q11*/, L_sub( sp_fx[i - 1], sp_fx[i - 2] ) /*Q11*/ ) /*Q11 * 2 - 1*/ < 0 ) + { + r1_fx = W_add( r1_fx, W_deposit32_l( abs( L_sub( sp_fx[i], sp_fx[i - 1] ) ) ) ); /*Q11*/ + } + } + Word16 headroom_left_r0 = W_norm( r0_fx ); + Word16 headroom_left_r1 = W_norm( r1_fx ); + Word16 r0_q = 0, r1_q = 0; + move16(); + move16(); + IF( LT_16( headroom_left_r0, 32 ) ) + { + r0_fx = W_shr( r0_fx, sub( 32, headroom_left_r0 ) ); + r0_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_r0 ) ) ); + } + ELSE + { + r0_q = 31 - ( 2 * OUTPUT_Q ); + move16(); + } + + IF( LT_16( headroom_left_r1, 32 ) ) + { + r1_fx = W_shr( r1_fx, sub( 32, headroom_left_r1 ) ); + r1_q = sub( OUTPUT_Q, sub( 32, headroom_left_r1 ) ); + } + ELSE + { + r1_q = OUTPUT_Q; + move16(); + } + Word32 temp_r0_inv = ISqrt32( W_extract_l( r0_fx ), &r0_q ); + Word32 res = Mpy_32_32( W_extract_l( r1_fx ), temp_r0_inv ); + // Word16 res_q = r1_q + ( r0_q < 0 ? ( 31 + ( -1 * r0_q ) ) : r0_q ) - 31; + Word16 res_q; + IF( r0_q < 0 ) + { + res_q = add( r1_q, sub( add( 31, -r0_q ), 31 ) ); + } + ELSE + { + res_q = add( r1_q, sub( r0_q, 31 ) ); + } + Word16 norm_res = norm_l( res ); + IF( norm_res > 0 ) + { + *tilt_fx = L_shl_sat( res, norm_res ); + move32(); + *tilt_fx_q = add( res_q, norm_res ); + move16(); + } + ELSE + { + *tilt_fx = res; + move32(); + *tilt_fx_q = res_q; + move16(); + } + return; +} + +/*-------------------------------------------------------------------* + * swb_tbe_dec() + * + * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module + *-------------------------------------------------------------------*/ +static void rescale_genSHB_mem_dec_ivas( + Decoder_State *st_fx, + Word16 sf /*Q0*/ +) +{ + Word16 i; + TD_BWE_DEC_HANDLE hBWE_TD; + hBWE_TD = st_fx->hBWE_TD; + + FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + { + hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); + move16(); + } + + FOR( i = 0; i < 7; i++ ) + { + hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] = shl( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i], sf ); + move16(); + } + + /* -- Apply memory scaling for 13.2 and 16.4k bps using sf ----*/ + IF( LT_32( st_fx->total_brate, ACELP_24k40 ) ) + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->state_lpc_syn_fx[i] = shl_sat( hBWE_TD->state_lpc_syn_fx[i], sf ); + move16(); + } + + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + hBWE_TD->state_syn_shbexc_fx[i] = shl_sat( hBWE_TD->state_syn_shbexc_fx[i], sf ); + move16(); + } + } + + hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf ); + move32(); + + hBWE_TD->tbe_demph_fx = shl_r( hBWE_TD->tbe_demph_fx, sf ); + move16(); + hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf ); + move16(); +} + +void find_max_mem_dec_m3( + Decoder_State *st, + Word16 *n_mem3 ) +{ + Word16 i; + // Word16 n_mem_32; + Word16 tempQ15; + Word16 max3; + // Word32 tempQ32, Lmax3; + TD_BWE_DEC_HANDLE hBWE_TD; + hBWE_TD = st->hBWE_TD; + + /* --------------------------------------------------------------*/ + /* Find headroom for synthesis stage associated with these memories: + 1. st->syn_overlap_fx*/ + max3 = 0; + move16(); + /* find max in prev overlapSyn */ + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + tempQ15 = abs_s( hBWE_TD->syn_overlap_fx[i] ); + max3 = s_max( max3, tempQ15 ); + } + /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ + + /* estimate the norm for 16-bit memories */ + *n_mem3 = norm_s( max3 ); + move16(); + if ( max3 == 0 ) + { + *n_mem3 = 15; + move16(); + } +} + +/*-------------------------------------------------------------------* + * ivas_swb_tbe_dec_fx() + * + * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module + *-------------------------------------------------------------------*/ +void ivas_swb_tbe_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ + const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ + Word16 Q_exc, + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *Q_white_exc ) +{ + Word16 i, j, cnt, n; + Word16 stemp; + TD_BWE_DEC_HANDLE hBWE_TD; + Word32 shaped_shb_excitation_fx_32[L_FRAME16k + L_SHB_LAHEAD]; + Word16 bwe_exc_extended_16[L_FRAME32k + NL_BUFF_OFFSET]; + Word16 shaped_shb_excitation_fx[L_FRAME16k + L_SHB_LAHEAD]; + Word16 lsf_shb_fx[LPC_SHB_ORDER], lpc_shb_fx[LPC_SHB_ORDER + 1], GainShape_fx[NUM_SHB_SUBFR]; // Q12,Q12,Q15 + Word32 GainFrame_fx; // Q18 + Word32 error_fx[L_FRAME32k]; + Word16 ener_fx; + Word32 L_ener; + Word16 is_fractive; + Word32 prev_pow_fx, curr_pow_fx, Lscale; + Word16 scale_fx; + Word16 max_val, temp_fx, shaped_shb_excitation_frac[L_FRAME16k + L_SHB_LAHEAD]; + Word32 curr_frame_pow_fx; + Word16 curr_frame_pow_exp; + Word32 L_prev_ener_shb; + Word16 vf_modified_fx[NB_SUBFR16k]; + Word16 f_fx, inc_fx; + Word32 GainFrame_prevfrm_fx; + Word32 tilt_swb_fec_32_fx; + Word16 tilt_swb_fec_fx_q; + Word16 tilt_swb_fec_fx; + Word32 prev_ener_ratio_fx = 0; /* initialize just to avoid compiler warning */ + Word16 lsp_shb_1_fx[LPC_SHB_ORDER], lsp_shb_2_fx[LPC_SHB_ORDER], lsp_temp_fx[LPC_SHB_ORDER]; + Word16 lpc_shb_sf_fx[4 * ( LPC_SHB_ORDER + 1 )]; + const Word16 *ptr_lsp_interp_coef_fx; + Word32 shb_ener_sf_32; + Word16 shb_res_gshape_fx[NB_SUBFR16k]; + Word16 mixFactors_fx; + Word16 vind; + Word16 shb_res_dummy_fx[L_FRAME16k]; + Word16 shaped_shb_excitationTemp_fx[L_FRAME16k]; + Word32 ener_tmp_fx[NUM_SHB_SUBGAINS]; + Word16 GainShape_tmp_fx[NUM_SHB_SUBGAINS]; + Word16 pitch_fx; + Word16 l_subframe; + Word16 formant_fac_fx; + Word16 synth_scale_fx; + Word16 lsf_diff_fx[LPC_SHB_ORDER], w_fx[LPC_SHB_ORDER]; + Word16 refl_fx[M]; + Word16 tilt_para_fx; + Word16 *nlExc16k_fx, *mixExc16k_fx; + Word16 MSFlag; + Word16 feedback_fx; + Word16 GainShape_tilt_fx; + + // scaling + Word16 exp, tmp; + Word16 tmp1, tmp2; + Word16 mean_vf; + Word32 Lmax, L_tmp; + Word16 frac; + Word32 L_tmp1, L_tmp2; + Word16 Q_bwe_exc; + Word16 Q_bwe_exc_fb; + Word16 Q_shb; + Word16 n_mem, n_mem2, n_mem3, Qx, sc; + Word16 expa, expb; + Word16 fraca, fracb; + Word16 exp_ener, inv_ener; + + hBWE_TD = st->hBWE_TD; + + /* initializations */ + GainFrame_fx = 0; + move32(); + mixFactors_fx = 0; + move16(); + shb_ener_sf_32 = 0; + move32(); + set16_fx( shaped_shb_excitationTemp_fx, 0, L_FRAME16k ); + if ( st->hTdCngDec != NULL ) + { + st->hTdCngDec->shb_dtx_count = 0; + move16(); + } + is_fractive = 0; + move16(); + + IF( hStereoICBWE != NULL ) + { + nlExc16k_fx = hStereoICBWE->nlExc16k_fx; + mixExc16k_fx = hStereoICBWE->mixExc16k_fx; + MSFlag = hStereoICBWE->MSFlag; + move16(); + } + ELSE + { + nlExc16k_fx = NULL; + mixExc16k_fx = NULL; + MSFlag = 0; + move16(); + } + + /* find tilt */ + calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); + tilt_swb_fec_fx = round_fx_sat( L_shl_sat( tilt_swb_fec_32_fx, sub( 11 + 16, tilt_swb_fec_fx_q ) ) ); + test(); + if ( st->bfi && st->clas_dec != UNVOICED_CLAS ) + { + tilt_swb_fec_fx = hBWE_TD->tilt_swb_fec_fx; + move16(); + } + + /* WB/SWB bandwidth switching */ + test(); + test(); + IF( ( GT_16( st->tilt_wb_fx, 10240 /*5 in Q11*/ ) && ( EQ_16( st->clas_dec, UNVOICED_CLAS ) ) ) || GT_16( st->tilt_wb_fx, 20480 /*10 in Q11*/ ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( st->prev_fractive == 0 ) && + ( LT_32( st->prev_enerLH_fx, L_shl( st->enerLH_fx, 1 ) ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) && LT_32( st->prev_enerLL_fx, L_shl( st->enerLL_fx, 1 ) ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) ) || + ( EQ_16( st->prev_fractive, 1 ) && + GT_32( L_shr( st->prev_enerLH_fx, 2 ), Mult_32_16( st->enerLH_fx, 24576 ) ) ) /* 24576 in Q13*/ + || ( GT_32( L_shr( st->enerLL_fx, 1 ), Mult_32_16( st->enerLH_fx, 24576 ) ) && /*24576 = 1.5 in Q14*/ + LT_16( st->tilt_wb_fx, 20480 ) ) /* 20480 = 10 in Q11*/ + ) + { + is_fractive = 0; + } + ELSE + { + is_fractive = 1; + } + move16(); + } + + /* WB/SWB bandwidth switching */ + IF( st->bws_cnt > 0 ) + { + f_fx = 1489; /*1.0f / 22.0f in Q15*/ + move16(); + inc_fx = 1489; /*1.0f / 22.0f in Q15*/ + move16(); + + IF( EQ_16( is_fractive, 1 ) ) + { + Copy( lsf_tab_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); + } + ELSE + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ + move16(); + f_fx = add( f_fx, inc_fx ); /*Q15*/ + } + } + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && !( ( L_sub( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) < 0 ) && L_sub( st->prev_enerLH_fx, ( L_shr( st->enerLH_fx, 1 ) > 0 ) ) ) ) || st->last_core != ACELP_CORE || ( ( st->last_core == ACELP_CORE ) && GT_32( abs( L_sub( st->last_core_brate, st->core_brate ) ), 3600 ) ) || EQ_16( s_xor( is_fractive, st->prev_fractive ), 1 ) ) + { + set16_fx( GainShape_fx, 11587, NUM_SHB_SUBFR ); /*0.3536f in Q15*/ + } + ELSE + { + if ( GT_16( hBWE_TD->prev_GainShape_fx, 11587 ) ) /*0.3536f in Q15*/ + { + hBWE_TD->prev_GainShape_fx = 11587; /*0.3536f in Q15*/ + move16(); + } + set16_fx( GainShape_fx, hBWE_TD->prev_GainShape_fx, NUM_SHB_SUBFR ); + } + + Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); + set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, NB_SUBFR16k ); /* Q14 */ + } + ELSE + { + test(); + IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) + { + f_fx = 1489; /*Q15*/ + move16(); + inc_fx = 1489; /*Q15*/ + move16(); + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ + move16(); + f_fx = add( f_fx, inc_fx ); + } + } + + IF( !st->bfi ) + { + IF( st->use_partial_copy ) + { + IF( NE_16( st->last_extl, SWB_TBE ) ) + { + hBWE_TD->GainFrame_prevfrm_fx = 0; + move32(); + f_fx = 1489 /*0.045454f Q15*/; + move16(); + inc_fx = 1489 /*0.045454f Q15*/; + move16(); + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ + move16(); + f_fx = add( f_fx, inc_fx ); /*Q15*/ + } + } + Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); + set16_fx( GainShape_fx, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR ); + + IF( EQ_16( st->rf_frame_type, RF_NELP ) ) + { + /* Frame gain */ + + GainFrame_fx = L_mac( SHB_GAIN_QLOW_FX, st->rf_indx_tbeGainFr, SHB_GAIN_QDELTA_FX ); + L_tmp = Mult_32_16( GainFrame_fx, 27213 ); /*Q16*/ /* 3.321928 in Q13 */ + + frac = L_Extract_lc( L_tmp, &exp ); + L_tmp = Pow2( 30, frac ); + GainFrame_fx = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/ + + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) && !st->prev_use_partial_copy && EQ_16( st->prev_coder_type, UNVOICED ) && NE_32( GainFrame_fx, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st->next_coder_type, GENERIC ) && EQ_16( st->last_extl, SWB_TBE ) ) + { + GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6553 /*0.2f in Q15*/ ) ); + } + } + ELSE + { + temp_fx = 0; + move16(); + /* Frame gain */ + SWITCH( st->rf_indx_tbeGainFr ) + { + case 0: + GainFrame_fx = 131072; /* 0.5f in Q18 */ + move32(); + if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + case 1: + GainFrame_fx = 524288; /* 2.0f in Q18 */ + move32(); + test(); + if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + case 2: + GainFrame_fx = 1048576; /* 4.0f in Q18 */ + move32(); + test(); + if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + case 3: + GainFrame_fx = 2097152; /* 8.0f in Q18 */ + move32(); + test(); + if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + default: + fprintf( stderr, "RF SWB-TBE gain bits not supported." ); + } + + IF( EQ_16( st->last_extl, SWB_TBE ) ) + { + GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp_fx ), Mult_32_16( GainFrame_fx, sub( 32767, temp_fx ) ) ); + /*Q18*/ + } + + IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) ) + { + if ( !st->prev_use_partial_copy && EQ_16( st->last_coder_type, VOICED ) && EQ_16( st->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame_fx, 2097152 /*8.0f in Q18*/ ) && LT_32( GainFrame_fx, 3059606 /*11.67f in Q18*/ ) ) + { + GainFrame_fx = Mult_32_16( GainFrame_fx, 9830 /*0.3f in Q15*/ ); // Q18 + } + } + } + } + ELSE + { + /* de-quantization */ + ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, + &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); + if ( hStereoICBWE != NULL ) + { + hStereoICBWE->MSFlag = MSFlag; + move16(); + } + } + } + ELSE + { + Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); + test(); + IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) + { + gradientGainShape( st, GainShape_fx, &GainFrame_fx ); + } + ELSE + { + FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) + { + FOR( j = 0; j < 4; j++ ) + { + GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] ); + move16(); + } + } + IF( GT_16( tilt_swb_fec_fx, ( 8 << 11 ) ) ) /* tilt_swb_fec_fx in Q11 */ + { + IF( EQ_16( st->nbLostCmpt, 1 ) ) + { + GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 19661 /*0.6f Q15*/ ); + } + ELSE IF( EQ_16( st->nbLostCmpt, 2 ) ) + { + GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 11469 /*0.35f Q15*/ ); + } + ELSE + { + GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 6554 /*0.2f Q15*/ ); + } + GainFrame_fx = Mult_32_16( GainFrame_fx, st->cummulative_damping ); + } + ELSE + { + GainFrame_fx = hBWE_TD->GainFrame_prevfrm_fx; + move32(); /* gain locking */ + } + } + + IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) + { + test(); + IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) + { + L_tmp = L_mult( extract_l( hBWE_TD->prev2_shb_ener_sf_fx ), extract_l( hBWE_TD->prev3_shb_ener_sf_fx ) ); /*Q1*/ + tmp = round_fx( root_a_fx( L_tmp, 1, &exp ) ); /* Q = 15-exp */ + tmp1 = extract_l( hBWE_TD->prev1_shb_ener_sf_fx ); /*Q0*/ + i = sub( norm_s( tmp1 ), 1 ); + tmp1 = shl( tmp1, i ); /* Qi */ + IF( tmp == 0 ) + { + tmp = 32767 /*1.0f Q15*/; + move16(); /*Q15*/ + } + ELSE + { + scale_fx = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */ + scale_fx = s_max( scale_fx, 0 ); + tmp = shl_sat( scale_fx, sub( sub( 15, exp ), i ) ); /*Q15*/ + } + scale_fx = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */ + test(); + IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || + GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) + { + shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, scale_fx ); + + if ( GT_16( st->nbLostCmpt, 1 ) ) + { + shb_ener_sf_32 = L_shr( shb_ener_sf_32, 1 ); + } + } + ELSE + { + L_tmp = L_mult( scale_fx, scale_fx ); /* Q29 */ + shb_ener_sf_32 = L_shl( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, round_fx( L_tmp ) ), 2 ); + } + } + ELSE + { + test(); + IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || + GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) + { + shb_ener_sf_32 = L_shr( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ), 1 ); + } + ELSE + { + shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ); + } + } + } + + shb_ener_sf_32 = L_max( shb_ener_sf_32, 1l /*1.0f Q0*/ ); + mixFactors_fx = hBWE_TD->prev_mixFactors_fx; + move16(); + + IF( EQ_16( st->codec_mode, MODE1 ) ) + { + set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, 5 ); /* Q14 */ + } + ELSE + { + set16_fx( shb_res_gshape_fx, 16384 /*1.0f Q14*/, 5 ); /* Q14 */ + } + } + } + + /* get the gainshape delay */ + Copy( &st->GainShape_Delay[4], &st->GainShape_Delay[0], NUM_SHB_SUBFR / 4 ); + FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) + { + st->GainShape_Delay[i + 4] = GainShape_fx[i * 4]; /*Q15*/ + move16(); + } + + L_tmp = L_mult( voice_factors_fx[0], 8192 ); + L_tmp = L_mac( L_tmp, voice_factors_fx[1], 8192 ); + L_tmp = L_mac( L_tmp, voice_factors_fx[2], 8192 ); + mean_vf = mac_r( L_tmp, voice_factors_fx[3], 8192 ); + + Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k ); + + test(); + IF( EQ_16( st->coder_type, VOICED ) || GT_16( mean_vf, 13107 /*0.4f Q15*/ ) ) + { + FOR( i = 1; i < NB_SUBFR; i++ ) + { + L_tmp = L_mult( voice_factors_fx[i], 26214 /*0.8f Q15*/ ); + vf_modified_fx[i] = mac_r( L_tmp, voice_factors_fx[i - 1], 6554 /*0.2f Q15*/ ); + move16(); + } + + IF( st->L_frame != L_FRAME ) + { + L_tmp = L_mult( voice_factors_fx[4], 26214 /*0.8f Q15*/ ); + vf_modified_fx[4] = mac_r( L_tmp, voice_factors_fx[3], 6554 /*0.2f Q15*/ ); + move16(); + } + } + + test(); + IF( st->use_partial_copy && st->nelp_mode_dec ) + { + set16_fx( vf_modified_fx, 0, NB_SUBFR16k ); + } + + /* SHB LSF from current frame; and convert to LSP for interpolation */ + E_LPC_lsf_lsp_conversion( lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER ); + + test(); + IF( EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) + { + /* SHB LSP values from prev. frame for interpolation */ + Copy( hBWE_TD->swb_lsp_prev_interp_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); + } + ELSE + { + /* Use current frame's LSPs; in effect no interpolation */ + Copy( lsp_shb_2_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); + } + + test(); + test(); + test(); + IF( ( st->bws_cnt == 0 ) && ( st->bws_cnt1 == 0 ) && ( st->prev_use_partial_copy == 0 ) && ( st->use_partial_copy == 0 ) ) + { + lsf_diff_fx[0] = 16384; + move16(); /*Q15*/ + lsf_diff_fx[LPC_SHB_ORDER - 1] = 16384; + move16(); /*Q15*/ + FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) + { + lsf_diff_fx[i] = sub( lsf_shb_fx[i], lsf_shb_fx[i - 1] ); + move16(); + } + + a2rc_fx( hBWE_TD->cur_sub_Aq_fx + 1, refl_fx, M ); + tmp = add( 16384, shr( refl_fx[0], 1 ) ); /*Q14*/ + tmp1 = mult( 27425, tmp ); + tmp1 = mult( tmp1, tmp ); /*Q10*/ + tmp2 = shr( mult( 31715, tmp ), 2 ); /*Q10*/ + tilt_para_fx = add( sub( tmp1, tmp2 ), 1335 ); /*Q10*/ + + test(); + IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) + { + FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) + { + hBWE_TD->prev_lsf_diff_fx[i - 1] = shr( lsf_diff_fx[i], 1 ); + move16(); + } + } + + IF( LE_32( st->extl_brate, FB_TBE_1k8 ) ) + { + test(); + test(); + test(); + test(); + test(); + IF( !( GT_16( hBWE_TD->prev_tilt_para_fx, 5120 ) && ( EQ_16( st->coder_type, TRANSITION ) || LT_16( tilt_para_fx, 1024 ) ) ) && + !( ( ( LT_16( hBWE_TD->prev_tilt_para_fx, 3072 ) && GE_16( st->prev_coder_type, VOICED ) ) ) && GT_16( tilt_para_fx, 5120 ) ) ) + { + FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) + { + IF( LT_16( lsf_diff_fx[i], hBWE_TD->prev_lsf_diff_fx[i - 1] ) ) + { + tmp = mult( 26214, lsf_diff_fx[i] ); + + test(); + IF( ( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ + { + st->BER_detect = 1; + move16(); + tmp = 0; + move16(); + } + ELSE + { + tmp = div_s( tmp, hBWE_TD->prev_lsf_diff_fx[i - 1] ); + } + + tmp = s_max( tmp, 16384 ); + w_fx[i] = s_min( tmp, 32767 ); + move16(); + } + ELSE + { + tmp = mult( 26214, hBWE_TD->prev_lsf_diff_fx[i - 1] ); + + test(); + IF( ( lsf_diff_fx[i] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ + { + st->BER_detect = 1; + move16(); + tmp = 0; + move16(); + } + ELSE + { + tmp = div_s( tmp, lsf_diff_fx[i] ); + } + + tmp = s_max( tmp, 16384 ); + w_fx[i] = s_min( tmp, 32767 ); + move16(); + } + } + w_fx[0] = w_fx[1]; + move16(); + w_fx[LPC_SHB_ORDER - 1] = w_fx[LPC_SHB_ORDER - 2]; + move16(); + + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + tmp1 = mult( lsp_shb_1_fx[i], sub( 32767, w_fx[i] ) ); + tmp2 = mult( lsp_shb_2_fx[i], w_fx[i] ); + lsp_temp_fx[i] = add( tmp1, tmp2 ); + move16(); + } + } + ELSE + { + Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); + } + + /* convert from lsp to lsf */ + lsp2lsf_fx( lsp_temp_fx, lsf_shb_fx, LPC_SHB_ORDER, 1 ); + } + + Copy( lsf_diff_fx + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 ); + hBWE_TD->prev_tilt_para_fx = tilt_para_fx; + move16(); + } + ELSE + { + Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); + } + + IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) + { + /* SHB LSP interpolation */ + ptr_lsp_interp_coef_fx = interpol_frac_shb; /*Q15*/ + FOR( j = 0; j < 4; j++ ) + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + L_tmp = L_mult( lsp_shb_1_fx[i], ( *ptr_lsp_interp_coef_fx ) ); + lsp_temp_fx[i] = mac_r( L_tmp, lsp_shb_2_fx[i], ( *( ptr_lsp_interp_coef_fx + 1 ) ) ); + move16(); + } + ptr_lsp_interp_coef_fx += 2; + + tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) ); + /* convert LSPs to LP coefficients */ + E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER ); +#ifndef FIX_1100_REMOVE_LPC_RESCALING + /* Bring the LPCs to Q12 */ + Copy_Scale_sig( lpc_shb_sf_fx + tmp, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_sf_fx[tmp] ), 2 ) ); + lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this + move16(); +#endif + } + } + + /* Save the SWB LSP values from current frame for interpolation */ + Copy( lsp_shb_2_fx, hBWE_TD->swb_lsp_prev_interp_fx, LPC_SHB_ORDER ); + + /* save the shb_ener and mixFactor values */ + hBWE_TD->prev3_shb_ener_sf_fx = hBWE_TD->prev2_shb_ener_sf_fx; + move32(); + hBWE_TD->prev2_shb_ener_sf_fx = hBWE_TD->prev1_shb_ener_sf_fx; + move32(); + hBWE_TD->prev1_shb_ener_sf_fx = shb_ener_sf_32; + move32(); + hBWE_TD->prev_res_shb_gshape_fx = shb_res_gshape_fx[4]; + move16(); + hBWE_TD->prev_mixFactors_fx = mixFactors_fx; + move16(); + + /* SWB CNG/DTX - update memories */ + IF( st->hTdCngDec != NULL ) + { + Copy( st->hTdCngDec->lsp_shb_prev_fx, st->hTdCngDec->lsp_shb_prev_prev_fx, LPC_SHB_ORDER ); + Copy( lsf_shb_fx, st->hTdCngDec->lsp_shb_prev_fx, LPC_SHB_ORDER ); + } + + /* convert LSPs back into LP coeffs */ + E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_fx, LPC_SHB_ORDER ); + Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Q12 */ + lpc_shb_fx[0] = ONE_IN_Q12; + move16(); + + test(); + IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1 + vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ + /* i: mixFactors_fx in Q15 */ + /* o: vind in Q0 */ + } + ELSE + { + vind = shl( mixFactors_fx, 3 - 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*8*/ + /* i: mixFactors_fx in Q15 */ + /* o: vind in Q0 */ + } + + /* Determine formant PF strength */ + formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); + /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */ + IF( GT_32( st->total_brate, ACELP_32k ) ) + { + FOR( j = 0; j < 4; j++ ) + { + Copy( lpc_shb_fx, &lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )], LPC_SHB_ORDER + 1 ); + } + } + + /* From low band excitation, generate highband excitation */ + + /* -------- start of memory rescaling -------- */ + /* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */ + Lmax = 0; + move32(); + FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + { + Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) ); + } + Q_bwe_exc = norm_l( Lmax ); + if ( Lmax == 0 ) + { + Q_bwe_exc = 31; + move16(); + } + Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); + find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ + + tmp = add( st->prev_Q_bwe_exc, n_mem ); + if ( GT_16( Q_bwe_exc, tmp ) ) + { + Q_bwe_exc = tmp; + move16(); + } + + /* rescale the memories if Q_bwe_exc is different from previous frame */ + sc = sub( Q_bwe_exc, st->prev_Q_bwe_exc ); + IF( sc != 0 ) + { + rescale_genSHB_mem_dec_ivas( st, sc ); + } + + /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ + sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); + + FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + { + bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) ); + move16(); + } + + /* state_syn_shbexc_fx is kept at (st_fx->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */ + + /* save the previous Q factor (32-bit) of the buffer */ + st->prev_Q_bwe_exc = Q_bwe_exc; + move16(); + + Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ + + /* -------- end of rescaling memories -------- */ + + Q_bwe_exc_fb = st->prev_Q_bwe_exc_fb; + move16(); + + Q_shb = 0; + move16(); + + Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); + GenShapedSHBExcitation_ivas_dec_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, + hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, + st->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl, + &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_32, + shb_res_gshape_fx, shb_res_dummy_fx, &vind, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, + &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st->prev_Q_bwe_syn, st->total_brate, st->prev_bfi, + st->element_mode, st->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st->extl_brate, MSFlag, + NULL, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL ); + + *Q_white_exc = Q_bwe_exc_fb; + move16(); + IF( EQ_16( st->extl, FB_TBE ) ) + { + st->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; + move16(); + } + ELSE + { + /*Indirectly a memory reset of FB memories for next frame such that rescaling of memories would lead to 0 due to such high prev. Q value. + 51 because of 31 + 20(shift of Q_bwe_exc_fb before de-emphasis)*/ + st->prev_Q_bwe_exc_fb = 51; + move16(); + } + + /* rescale the TBE post proc memory */ + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st->prev_Q_bwe_syn ) ); + move16(); + } + /* fill-in missing SHB excitation */ + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) + { + Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, shaped_shb_excitation_fx, L_SHB_LAHEAD ); + } + + IF( hStereoICBWE != NULL ) + { + Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); + } + + test(); + IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + FOR( i = 0; i < L_FRAME16k; i += L_SUBFR16k ) + { + /* TD BWE post-processing */ + PostShortTerm_ivas_dec_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, + hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); + } + + Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ + + tmp = sub( shl( Q_bwe_exc, 1 ), 31 + 16 ); + prev_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ + curr_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ + FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) + { + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /*2*Q_bwe_exc*/ + curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ + } + + if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) + { + curr_pow_fx = L_shr( curr_pow_fx, 2 ); /* Q(2*Q_bwe_exc) */ + } + + Lscale = root_a_over_b_fx( curr_pow_fx, + shl( Q_bwe_exc, 1 ), + prev_pow_fx, + shl( Q_bwe_exc, 1 ), + &exp ); + + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + IF( exp < 0 ) + { + Lscale = L_shl( Lscale, exp ); + exp = 0; + move16(); + } + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ + temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); + Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + /* reset the PF memories if the PF is not running */ + set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; + move16(); + set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + } + + /* Update SHB excitation */ + Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ + l_subframe = L_FRAME16k / NUM_SHB_SUBGAINS; + move16(); + L_ener = EPSILON_FX_SMALL; + move32(); + + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + L_tmp = 0; + move32(); + ener_tmp_fx[i] = EPSILON_FX_SMALL; + move32(); + + Word64 tmp64 = 0; + move64(); + FOR( j = 0; j < l_subframe; j++ ) + { + tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )], shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )] ); /* 2*Q_bwe_exc */ + } + L_tmp = W_sat_l( tmp64 ); + + L_tmp = Mult_32_16( L_tmp, 410 /*0.0125 Q15*/ ); /* 2*Q_bwe_exc: ener_tmp_fx in (2*Q_bwe_exc) */ + IF( L_tmp != 0 ) + { + exp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, exp ) ); + exp = sub( exp, sub( 30, i_mult( 2, Q_bwe_exc ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + ener_tmp_fx[i] = L_shl_sat( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ + move32(); + L_ener = L_add_sat( L_ener, L_shr( ener_tmp_fx[i], 2 ) ); /* 2*Q_bwe_exc */ + } + } + ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ + /* WB/SWB bandwidth switching */ + IF( st->bws_cnt > 0 ) + { + IF( is_fractive == 0 ) + { + IF( GT_16( st->tilt_wb_fx, 2048 ) ) /*assuming st->tilt_wb_fx in Q11*/ + { + st->tilt_wb_fx = 2048; + move16(); + } + ELSE IF( LT_16( st->tilt_wb_fx, 1024 ) ) + { + st->tilt_wb_fx = 1024; + move16(); + } + test(); + if ( EQ_16( st->prev_fractive, 1 ) && GT_16( st->tilt_wb_fx, 1024 ) ) + { + st->tilt_wb_fx = 1024; + move16(); + } + } + ELSE + { + IF( GT_16( st->tilt_wb_fx, 8192 ) ) + { + IF( st->prev_fractive == 0 ) + { + st->tilt_wb_fx = 8192; + move16(); + } + ELSE + { + st->tilt_wb_fx = 16384; + move16(); + } + } + ELSE + { + st->tilt_wb_fx = shl( st->tilt_wb_fx, 2 ); + move16(); + } + } + + IF( ener_fx != 0 ) + { + L_tmp = L_shl( L_mult0( ener_fx, st->tilt_wb_fx ), sub( st->Q_syn2, 13 ) ); /* 2+11 +st->Q_syn2 -13 = st->Q_syn2*/ + exp_ener = norm_s( ener_fx ); + tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ + inv_ener = shr( div_s( 16384, tmp ), 1 ); /*Q(15+14-2-exp-1) = 26 - exp*/ + + test(); + IF( GT_32( L_tmp, st->enerLH_fx ) ) /*st->Q_syn2*/ + { + st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ + move16(); + /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ + } + ELSE IF( LT_32( L_tmp, Mult_32_16( st->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) ) + { + st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ + move16(); + /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ + } + L_tmp = L_mult0( st->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ + GainFrame_prevfrm_fx = L_shr( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ + } + ELSE + { + GainFrame_prevfrm_fx = 0; + move32(); + } + + IF( EQ_16( is_fractive, 1 ) ) + { + GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 10 ); + } + ELSE + { + GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 8 ); + } + + test(); + IF( EQ_16( ( is_fractive & st->prev_fractive ), 1 ) && GT_32( GainFrame_fx, GainFrame_prevfrm_fx ) ) + { + GainFrame_fx = L_add( Mult_32_16( GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); /* 18 +15 -15 = 18*/ + } + ELSE + { + test(); + test(); + test(); + test(); + IF( ( LT_32( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st->prev_enerLL_fx, 1 ), st->enerLL_fx ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) && ( s_xor( is_fractive, st->prev_fractive ) == 0 ) ) + { + GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( GainFrame_prevfrm_fx, 1 ) ); + } + ELSE + { + test(); + IF( ( is_fractive == 0 ) && EQ_16( st->prev_fractive, 1 ) ) + { + L_tmp1 = L_shl( Mult_32_16( GainFrame_fx, 3277 ), 13 ); /* 31 */ + L_tmp = L_sub( 2147483647, L_tmp1 ); /* 31 */ + GainFrame_fx = L_add( Mult_32_32( GainFrame_fx, L_tmp ), Mult_32_32( GainFrame_prevfrm_fx, L_tmp1 ) ); /* 18 */ + } + ELSE + { + GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( L_min( GainFrame_prevfrm_fx, GainFrame_fx ), 1 ) ); /* 18 */ + } + } + } + + GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( sub( N_WS2N_FRAMES, st->bws_cnt ), 819 ) ); /*Q18*/ + } + ELSE + { + IF( st->bws_cnt1 > 0 ) + { + GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( st->bws_cnt1, 819 ) ); /*Q18*/ + } + IF( GE_16( st->nbLostCmpt, 1 ) ) + { + ener_fx = s_max( 1, ener_fx ); + exp_ener = norm_s( ener_fx ); + tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ + inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/ + prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */ + } + + IF( EQ_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->clas_dec != UNVOICED_CLAS ) && NE_16( st->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) && + ( ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st->enerLL_fx, 1 ), st->prev_enerLL_fx ) ) || ( GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st->enerLH_fx, 1 ), st->prev_enerLH_fx ) ) ) ) + { + IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) ) /*18*/ + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 13107 ), Mult_32_16( GainFrame_fx, 19661 ) ); /*18*/ + } + ELSE IF( GT_32( L_shr( prev_ener_ratio_fx, 1 ), GainFrame_fx ) ) + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); + } + ELSE + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); + } + + test(); + IF( GT_16( tilt_swb_fec_fx, hBWE_TD->tilt_swb_fec_fx ) && ( hBWE_TD->tilt_swb_fec_fx > 0 ) ) + { + exp = norm_s( hBWE_TD->tilt_swb_fec_fx ); + tmp = shl( hBWE_TD->tilt_swb_fec_fx, exp ); /*Q(11+exp)*/ + tmp = div_s( 16384, tmp ); /*Q(15+14-11-exp)*/ + tmp = extract_h( L_shl( L_mult0( tmp, st->tilt_wb_fx ), sub( exp, 1 ) ) ); /*18 -exp +11 + exp -1 -16 =12; */ + GainFrame_fx = L_shl( Mult_32_16( GainFrame_fx, s_min( tmp, 20480 ) ), 3 ); /*Q18 = 18 +12 -15 +3 */ + } + } + ELSE IF( ( ( st->clas_dec != UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 4096 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && + ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) ) + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); + } + } + ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) + { + test(); + IF( GT_16( tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) ) + { + GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6554 /*0.2f in Q15*/ ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 /*4.0f in Q12*/ ), 3 ) ); /*Q18*/ + } + ELSE + { + GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 16384 ), Mult_32_16( GainFrame_fx, 16384 ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 ), 3 ) ); /*Q18*/ + } + } + ELSE IF( GT_32( prev_ener_ratio_fx, GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) + { + test(); + IF( GT_16( tilt_swb_fec_fx, 20480 ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 ) ) + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 16384 /*0.5f in Q15*/ ), Mult_32_16( GainFrame_fx, 16384 /*0.5f in Q15*/ ) ); /* Q18 */ + } + ELSE + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 /*0.2f in Q15*/ ), Mult_32_16( GainFrame_fx, 26214 /*0.8f in Q15*/ ) ); /* Q18 */ + } + } + } + } + + st->prev_fractive = is_fractive; + move16(); + + /* Adjust the subframe and frame gain of the synthesized shb signal */ + /* Scale the shaped excitation */ + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + L_tmp = L_mult( pitch_buf_fx[0], 8192 ); + FOR( i = 1; i < NB_SUBFR; i++ ) + { + L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 8192 ); /* pitch_buf in Q6 x 0.25 in Q15 */ + } + pitch_fx = round_fx( L_tmp ); /* Q6 */ + } + ELSE + { + L_tmp = L_mult( pitch_buf_fx[0], 6554 ); + FOR( i = 1; i < NB_SUBFR16k; i++ ) + { + L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 6554 ); /* pitch_buf in Q6 x 0.2 in Q15 */ + } + pitch_fx = round_fx( L_tmp ); /* Q6 */ + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( GE_32( st->extl_brate, SWB_TBE_2k8 ) && EQ_16( st->prev_coder_type, st->coder_type ) && NE_16( st->coder_type, UNVOICED ) ) || ( LT_32( st->extl_brate, SWB_TBE_2k8 ) && ( EQ_16( st->prev_coder_type, st->coder_type ) || ( EQ_16( st->prev_coder_type, VOICED ) && EQ_16( st->coder_type, GENERIC ) ) || ( EQ_16( st->prev_coder_type, GENERIC ) && EQ_16( st->coder_type, VOICED ) ) ) ) ) && GT_16( pitch_fx, 4480 /*70 in Q6*/ ) && LT_16( st->extl, FB_TBE ) && NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + GainShape_tmp_fx[i] = GainShape_fx[i * 4]; /* Q15 */ + move16(); + } + + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + L_tmp1 = Mult_32_16( ener_tmp_fx[i], GainShape_tmp_fx[i] ); /* (2*Q_bwe_exc) */ + L_tmp2 = Mult_32_16( hBWE_TD->prev_ener_fx, hBWE_TD->prev_GainShape_fx ); /* (2*st->prev_ener_fx_Q) */ + tmp = sub( shl( Q_bwe_exc, 1 ), shl( st->prev_ener_fx_Q, 1 ) ); + L_tmp2 = L_shl_sat( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ + IF( GT_32( L_tmp1, L_tmp2 ) ) + { + L_tmp = L_tmp2; + move32(); + if ( L_tmp2 < 0 ) + { + L_tmp = L_negate( L_tmp2 ); + } + + expb = norm_l( L_tmp ); + fracb = round_fx_sat( L_shl_sat( L_tmp, expb ) ); + expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */ + + expa = norm_l( ener_tmp_fx[i] ); + fraca = extract_h( L_shl( ener_tmp_fx[i], expa ) ); + expa = sub( 30, expa ); + + scale_fx = shr( sub( fraca, fracb ), 15 ); + fracb = shl( fracb, scale_fx ); + expb = sub( expb, scale_fx ); + + tmp = div_s( fracb, fraca ); + exp = sub( sub( expb, expa ), 1 ); + tmp = shl( tmp, exp ); + GainShape_tmp_fx[i] = add( tmp, shr( GainShape_tmp_fx[i], 1 ) ); /* Q15 */ + move16(); + } + + hBWE_TD->prev_ener_fx = ener_tmp_fx[i]; + move32(); + hBWE_TD->prev_GainShape_fx = GainShape_tmp_fx[i]; + move16(); + st->prev_ener_fx_Q = Q_bwe_exc; + move16(); + } + + FOR( i = 0; i < NUM_SHB_SUBFR; i++ ) + { + Word16 idx = 0; + move16(); + IF( i != 0 ) + { + idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + } + GainShape_fx[i] = GainShape_tmp_fx[idx]; + move16(); + } + } + ELSE + { + st->prev_ener_fx_Q = Q_bwe_exc; + move16(); + } + st->prev_Q_bwe_syn = Q_bwe_exc; + move16(); + + + /* Gain shape smoothing after quantization */ + test(); + IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + GainShape_tmp_fx[i] = GainShape_fx[i * NUM_SHB_SUBGAINS]; + move16(); + } + + lls_interp_n_fx( GainShape_tmp_fx, NUM_SHB_SUBGAINS, &GainShape_tilt_fx, &temp_fx, 1 ); + + test(); + IF( GE_16( vind, 6 ) && LT_16( abs_s( GainShape_tilt_fx ), 3932 ) ) + { + feedback_fx = 9830; + move16(); + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + GainShape_fx[i] = add_sat( mult( sub( 32767, feedback_fx ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), mult( feedback_fx, GainShape_tmp_fx[i] ) ); + move16(); + } + + FOR( i = NUM_SHB_SUBFR - 1; i > 0; i-- ) + { + Word16 idx = 0; + move16(); + IF( i != 0 ) + { + idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + } + GainShape_fx[i] = GainShape_fx[idx]; + move16(); + } + } + } + + /* fil-in missing memory */ + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) + { + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + Word16 intermediate = mult( shaped_shb_excitation_fx[i], subwin_shb_fx[L_SHB_LAHEAD - i] ); + Word32 intermediate_32 = Mpy_32_16_1( Mpy_32_16_1( GainFrame_fx, window_shb_fx[L_SHB_LAHEAD - 1 - i] ), intermediate ); + hBWE_TD->syn_overlap_fx[i] = round_fx( L_shl_sat( intermediate_32, sub( 16, ( add( Q_bwe_exc, 18 - 15 ) ) ) ) ); + move16(); + } + } + + Word16 n_mem3_new = 0; + move16(); + find_max_mem_dec_m3( st, &n_mem3_new ); + + ScaleShapedSHB_fx( SHB_OVERLAP_LEN, + shaped_shb_excitation_fx, /* i/o: Q_bwe_exc */ + hBWE_TD->syn_overlap_fx, + GainShape_fx, /* Q15 */ + GainFrame_fx, /* Q18 */ + window_shb_fx, + subwin_shb_fx, + &Q_bwe_exc, &Qx, n_mem3_new, st->prev_Q_bwe_syn2 ); + + IF( hStereoICBWE != NULL ) + { + Copy_Scale_sig_16_32_DEPREC( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); + Copy( GainShape_fx, hStereoICBWE->gshapeRef_fx, NUM_SHB_SUBFR ); + hStereoICBWE->gFrameRef_fx = GainFrame_fx; + move32(); + + Copy( shaped_shb_excitation_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); + } + + max_val = 0; + move16(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + max_val = s_max( max_val, abs_s( shaped_shb_excitation_fx[i] ) ); /* Q0 */ + } + IF( max_val == 0 ) + { + curr_frame_pow_fx = 0; + move32(); + n = 0; + move16(); + } + ELSE + { + n = norm_s( max_val ); + max_val = 0; + move16(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + shaped_shb_excitation_frac[i] = shl_sat( shaped_shb_excitation_fx[i], n ); /*Q_bwe_exc+n*/ + move16(); + } + + curr_frame_pow_fx = 0; + move32(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + L_tmp = L_mult0( shaped_shb_excitation_frac[i], shaped_shb_excitation_frac[i] ); /*2*(Q_bwe_exc+n)*/ + curr_frame_pow_fx = L_add( curr_frame_pow_fx, L_shr( L_tmp, 9 ) ); /*2*(Q_bwe_exc+n)-9*/ + } + } + curr_frame_pow_exp = sub( shl( add( Q_bwe_exc, n ), 1 ), 9 ); + tmp = sub( st->prev_frame_pow_exp, curr_frame_pow_exp ); + IF( tmp > 0 ) /* shifting prev */ + { + IF( GT_16( tmp, 32 ) ) + { + st->prev_frame_pow_exp = add( curr_frame_pow_exp, 32 ); + move16(); + tmp = 32; + move16(); + } + hBWE_TD->prev_swb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, tmp ); + move32(); + st->prev_frame_pow_exp = curr_frame_pow_exp; + move16(); + } + ELSE /* shifting curr */ + { + IF( LT_16( tmp, -32 ) ) + { + curr_frame_pow_exp = sub( st->prev_frame_pow_exp, 32 ); + tmp = -32; + move16(); + } + curr_frame_pow_fx = L_shr( curr_frame_pow_fx, -tmp ); + curr_frame_pow_exp = st->prev_frame_pow_exp; + move16(); + } + test(); + test(); + IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) ) + { + test(); + test(); + IF( ( GT_32( L_shr( curr_frame_pow_fx, 1 ), hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) && + ( GT_32( hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16( st->prev_coder_type, UNVOICED ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + scale_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ + + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ + } + ELSE + { + scale_fx = temp_fx = 32767; + move16(); /*Q15*/ + move16(); /*Q15*/ + } + + FOR( j = 0; j < 8; j++ ) + { + GainShape_fx[2 * j] = mult_r( GainShape_fx[2 * j], scale_fx ); + move16(); + GainShape_fx[2 * j + 1] = mult_r( GainShape_fx[2 * j + 1], scale_fx ); + move16(); + FOR( i = 0; i < L_FRAME16k / 8; i++ ) + { + shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )] = mult_r( shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )], scale_fx ); + move16(); + } + + IF( temp_fx > 0 ) + { + /* scale_fx <= temp_fx, due to scale_fx = sqrt( st->prev_swb_bwe_frame_pow_fx/curr_frame_pow_fx ), temp_fx = sqrt( scale_fx, 1.f/8.f ) + and curr_frame_pow_fx > st->prev_swb_bwe_frame_pow_fx -> scale_fx <= 1.0, sqrt(scale_fx, 1.f/8.f) >= scale_fx */ + IF( LT_16( scale_fx, temp_fx ) ) + { + scale_fx = div_s( scale_fx, temp_fx ); + } + ELSE + { + scale_fx = 32767; + move16(); + } + } + ELSE + { + scale_fx = 0; + move16(); + } + } + } + + /* adjust the FEC frame energy */ + IF( st->bfi ) + { + scale_fx = temp_fx = 4096; + move16(); /*Q12*/ + move16(); + IF( EQ_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) && + NE_16( st->prev_coder_type, UNVOICED ) && + ( st->last_good != UNVOICED_CLAS ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); /*31 - exp*/ + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && EQ_16( st->nbLostCmpt, 1 ) && + ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && + ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + scale_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + } + ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && + ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && + ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/ + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + } + + FOR( j = 0; j < 8; j++ ) + { + GainShape_fx[2 * j] = shl_sat( mult_r( GainShape_fx[2 * j], scale_fx ), 3 ); + move16(); /* 15 +12 +3-15 =15*/ + GainShape_fx[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx ), 3 ); + move16(); + FOR( i = 0; i < 40; i++ ) + { + shaped_shb_excitation_fx[i + j * L_FRAME16k / 8] = shl( mult_r( shaped_shb_excitation_fx[i + j * L_FRAME16k / 8], scale_fx ), 3 ); + move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/ + } + + IF( temp_fx > 0 ) + { + IF( LT_16( scale_fx, temp_fx ) ) + { + scale_fx = shr( div_s( scale_fx, temp_fx ), 3 ); + } + ELSE + { + tmp1 = sub( norm_s( scale_fx ), 1 ); + tmp2 = norm_s( temp_fx ); + scale_fx = div_s( shl( scale_fx, tmp1 ), shl( temp_fx, tmp2 ) ); + scale_fx = shr( scale_fx, add( sub( tmp1, tmp2 ), 3 ) ); + } + } + ELSE + { + scale_fx = 0; + move16(); + } + } + } + + hBWE_TD->prev_swb_bwe_frame_pow_fx = curr_frame_pow_fx; + move32(); + st->prev_frame_pow_exp = curr_frame_pow_exp; + move16(); + + Word64 prev_ener_shb64 = 0; + move64(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + prev_ener_shb64 = W_mac0_16_16( prev_ener_shb64, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* Q0 */ + } + L_prev_ener_shb = W_sat_l( prev_ener_shb64 ); + + L_prev_ener_shb = Mult_32_16( L_prev_ener_shb, 26214 ); /* 2*Q_bwe_exc_mod+8; 26214=(1/L_FRAME16k) in Q23 */ + st->prev_ener_shb_fx = 0; + move16(); + IF( L_prev_ener_shb != 0 ) + { + exp = norm_l( L_prev_ener_shb ); + tmp = extract_h( L_shl( L_prev_ener_shb, exp ) ); + exp = sub( exp, sub( 30, ( add( i_mult( 2, Q_bwe_exc ), 8 ) ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ + move16(); + } + + IF( st->hBWE_FD != NULL ) + { + L_tmp = Mult_32_16( curr_frame_pow_fx, 26214 ); /* curr_frame_pow_exp+8; 26214=(1/L_FRAME16k) in Q23 */ + tmp = 0; + move16(); + IF( L_tmp != 0 ) + { + exp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, exp ) ); + exp = sub( exp, sub( 30, add( curr_frame_pow_exp, 8 ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ + } + set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ + } + + FOR( i = 0; i < L_FRAME16k; i++ ) + { + shaped_shb_excitation_fx_32[i] = L_shl( shaped_shb_excitation_fx[i], sub( Q11, Q_bwe_exc ) ); + move32(); + } + + /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ + GenSHBSynth_fx_32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); + Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); + Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); + + /* resample SHB synthesis (if needed) and scale down */ + synth_scale_fx = 32767; + move16(); /* 1.0 in Q15 */ + if ( EQ_16( st->codec_mode, MODE1 ) ) + { + synth_scale_fx = 29491; + move16(); /* 0.9 in Q15 */ + } + + IF( EQ_32( st->output_Fs, 48000 ) ) + { + IF( EQ_16( st->extl, FB_TBE ) ) + { + tmp = norm_l( GainFrame_fx ); + if ( GainFrame_fx == 0 ) + { + tmp = 31; + move16(); + } + L_tmp = L_shl( GainFrame_fx, tmp ); /* 18 + tmp */ + + tmp1 = 0; + move16(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + Word16 idx = 0; + move16(); + IF( i != 0 ) + { + idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); + } + L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ + White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ + move16(); + tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); + } + + *Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */ + move16(); + tmp = norm_s( tmp1 ); + if ( tmp1 == 0 ) + { + tmp = 15; + move16(); + } + + FOR( i = 0; i < L_FRAME16k; i++ ) + { + White_exc16k_fx[i] = shl( White_exc16k_fx[i], sub( tmp, 1 ) ); + move16(); + } + *Q_white_exc = sub( add( *Q_white_exc, tmp ), 1 ); + move16(); + } + + IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); + move32(); + } + } + interpolate_3_over_2_allpass_32( error_fx, L_FRAME32k, synth_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); + } + ELSE IF( EQ_32( st->output_Fs, 32000 ) ) + { + IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + synth_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); + move32(); /*Qx*/ + } + } + ELSE + { + Copy32( error_fx, synth_fx, L_FRAME32k ); + } + } + ELSE IF( EQ_32( st->output_Fs, 16000 ) ) + { + IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); + move32(); + } + } + + Decimate_allpass_steep_fx32( error_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, synth_fx ); + } + + + /* Update previous frame parameters for FEC */ + Copy( lsf_shb_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); + IF( EQ_16( st->codec_mode, MODE1 ) ) + { + hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; + move32(); /*Q18*/ + hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; + move16(); + + if ( !st->bfi ) + { + hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ + move16(); + } + } + ELSE + { + IF( !st->bfi ) + { + hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; + move32(); /*Q18*/ + hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; + move16(); + hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ + move16(); + } + } + + hBWE_TD->prev_ener_fx = ener_tmp_fx[NUM_SHB_SUBGAINS - 1]; + move32(); + hBWE_TD->prev_GainShape_fx = GainShape_fx[NUM_SHB_SUBFR - 1]; + move16(); + st->prev_Q_bwe_syn2 = Q_bwe_exc; + move16(); + st->prev_Qx = Q_bwe_exc; + move16(); + + return; +} + +void GenTransition_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 element_mode, /* i : element mode : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 rf_flag, /* i : RF flag : Q0 */ + const Word32 total_brate, /* i : total bitrate : Q0 */ + const Word16 prev_Qx ) +{ + Word16 i, length; + + Word32 syn_overlap_32k_fx[2 * SHB_OVERLAP_LEN]; + + /* set targeted length of transition signal */ + length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); + + /* upsample overlap snippet */ + Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, SHB_OVERLAP_LEN, syn_overlap_32k_fx ); + + /* perFORm spectral flip and downmix with overlap snippet to match HB synth */ + test(); + test(); + test(); + test(); + IF( ( ( element_mode == EVS_MONO ) && ( rf_flag || EQ_32( total_brate, ACELP_9k60 ) ) ) || ( ( element_mode > EVS_MONO ) && EQ_16( L_frame, L_FRAME ) ) ) + { + flip_and_downmix_generic_fx_32( syn_overlap_32k_fx, syn_overlap_32k_fx, 2 * SHB_OVERLAP_LEN, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + HILBERT_ORDER1, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), &( hBWE_TD->syn_dm_phase ) ); + } + ELSE + { + FOR( i = 0; i < 2 * SHB_OVERLAP_LEN; i++ ) + { + IF( i % 2 == 0 ) + { + syn_overlap_32k_fx[i] = L_negate( syn_overlap_32k_fx[i] ); + } + ELSE + { + syn_overlap_32k_fx[i] = syn_overlap_32k_fx[i]; + } + move32(); + } + } + + /* cross fade of overlap snippet and mirrored HB synth from previous frame */ + FOR( i = 0; i < 2 * L_SHB_LAHEAD; i++ ) + { + outputHB_fx[i] = L_add_sat( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_32k_fx[i] ), Mpy_32_16_1( syn_overlap_32k_fx[i], window_shb_32k_fx[2 * L_SHB_LAHEAD - 1 - i] ) ); + move32(); + } + + /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ + FOR( ; i < length; i++ ) + { + outputHB_fx[i] = L_shl( hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i], sub( Q11, prev_Qx ) ); + move32(); + } + + IF( EQ_32( output_Fs, 48000 ) ) + { + interpolate_3_over_2_allpass_32( outputHB_fx, length, outputHB_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); + } + ELSE IF( EQ_32( output_Fs, 16000 ) ) + { + Decimate_allpass_steep_fx32( outputHB_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, outputHB_fx ); + } + + return; +} +void GenTransition_WB_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ +) +{ + Word16 i, length; + Word32 speech_buf_16k1_fx[SHB_OVERLAP_LEN], speech_buf_16k2_fx[2 * SHB_OVERLAP_LEN]; + Word32 upsampled_synth_fx[L_FRAME48k]; + + /* set targeted length of transition signal */ + length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); + + /* upsample overlap snippet */ + Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->state_lsyn_filt_shb_fx_32, SHB_OVERLAP_LEN / 2, speech_buf_16k1_fx ); + Interpolate_allpass_steep_32( speech_buf_16k1_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, SHB_OVERLAP_LEN, speech_buf_16k2_fx ); + + /* perform spectral flip and downmix with overlap snippet to match HB synth */ + FOR( i = 0; i < SHB_OVERLAP_LEN; i++ ) + { + IF( i % 2 == 0 ) + { + speech_buf_16k2_fx[i] = L_negate( speech_buf_16k2_fx[i] ); + move32(); + } + ELSE + { + speech_buf_16k2_fx[i] = speech_buf_16k2_fx[i]; + move32(); + } + } + + /* cross fade of overlap snippet and mirrored HB synth from previous frame */ + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + outputHB_fx[i] = L_add( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_fx[i] ), Mpy_32_16_1( speech_buf_16k2_fx[i], window_shb_fx[L_SHB_LAHEAD - 1 - i] ) ); + move32(); + outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); + move32(); + } + + /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ + FOR( ; i < length; i++ ) + { + outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i]; + move32(); + outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); + move32(); + } + + /* upsampling if necessary */ + IF( EQ_32( output_Fs, 32000 ) ) + { + Interpolate_allpass_steep_32( outputHB_fx, hBWE_TD->mem_resamp_HB_fx_32, L_FRAME16k, upsampled_synth_fx ); + Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME32k ); + } + ELSE IF( EQ_32( output_Fs, 48000 ) ) + { + interpolate_3_over_1_allpass_32( outputHB_fx, L_FRAME16k, upsampled_synth_fx, hBWE_TD->mem_resamp_HB_fx_32 ); + Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME48k ); + } + + return; +} diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c deleted file mode 100644 index 6a74d3b87..000000000 --- a/lib_dec/tonalMDCTconcealment.c +++ /dev/null @@ -1,436 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#define _USE_MATH_DEFINES - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" -#include "ivas_prot_fx.h" -#include "prot_fx.h" - - -/*******************************************************/ -/*-------------- public functions -------------------- */ -/*******************************************************/ - -void TonalMdctConceal_create_concealment_noise_ivas_fx( - Word32 concealment_noise[L_FRAME48k], // Q31-concealment_noise_exp - Word16 *concealment_noise_exp, - CPE_DEC_HANDLE hCPE, - const Word16 L_frameTCX, // Q0 - const Word16 L_frame, // Q0 - const Word16 idchan, // Q0 - const Word16 subframe_idx, // Q0 - const Word16 core, // Q0 - const Word16 crossfade_gain, // Q15 - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ) -{ - STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; - TonalMDCTConcealPtr hTonalMDCTConc; - Decoder_State *st; - HANDLE_FD_CNG_COM hFdCngCom; - Word16 *rnd_c, *rnd; - Word16 crossOverFreq, i, save_rnd_c, max_noise_line; - Word16 c, c_inv, inc; - Word32 noise_shape_buffer[L_FRAME48k]; - Word16 noise_shape_buffer_e[L_FRAME48k]; - Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; - move16(); - Word32 *cngNoiseLevelPtr; - Word32 last_scf; - - Word16 c_e, c_inv_e; - - push_wmops( "create_conc_noise" ); - - hStereoMdct = hCPE->hStereoMdct; - st = hCPE->hCoreCoder[idchan]; - hTonalMDCTConc = st->hTonalMDCTConc; - hFdCngCom = st->hFdCngDec->hFdCngCom; - rnd = &hStereoMdct->noise_seeds_channels[idchan]; - rnd_c = &hStereoMdct->noise_seed_common; - - /* determine start bin for IGF */ - IF( st->igf == 0 ) - { - IF( st->narrowBand == 0 ) - { - /* minimum needed for output with sampling rates lower then the - nominal sampling rate */ - crossOverFreq = s_min( L_frameTCX, L_frame ); - } - ELSE - { - crossOverFreq = L_frameTCX; - move16(); - } - } - ELSE - { - crossOverFreq = s_min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); - } - - /* for tonal mdct concealment with tonal components above the crossover frequency, conditionally raise the frequency index until which noise is generated */ - max_noise_line = crossOverFreq; - move16(); - IF( st->tonal_mdct_plc_active ) - { - max_noise_line = s_max( max_noise_line, extract_l( L_add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ) ) ); - } - - /* first lost frame is handled separately */ - IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) - { - *rnd = add( 1977, idchan ); // Q0 - move16(); - /* will be set twice when looping over two channels, but does not matter */ - *rnd_c = 1979; // Q0 - move16(); - } - - IF( GT_16( crossfade_gain, 32734 ) ) - /* Due to precision loss */ /* 0.999 in Q15*/ - { - /* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */ - FOR( i = 0; i < max_noise_line; i++ ) - { - *rnd = own_random( rnd ); - move16(); - concealment_noise[i] = *rnd; // Q31-concealment_noise_exp - move32(); - } - *concealment_noise_exp = 31; - move16(); - pop_wmops(); - - return; - } - - save_rnd_c = *rnd_c; // Q0 - move16(); - - c_e = 1; - move16(); - c_inv_e = 1; - move16(); - - c = Sqrt16( hStereoMdct->lastCoh_fx, &c_e ); // Q1 = 15 - c_e - c_inv = Sqrt16( sub( ONE_IN_Q14, hStereoMdct->lastCoh_fx ), &c_inv_e ); // Q2 = 15 - c_inv_e - - IF( NE_16( c_e, c_inv_e ) ) - { - IF( LT_16( c_e, c_inv_e ) ) - { - c = shr( c, sub( c_inv_e, c_e ) ); // Q0 - c_e = c_inv_e; - move16(); - } - ELSE - { - c_inv = shr( c_inv, sub( c_e, c_inv_e ) ); // Q0 - } - } - - /* pre-compute the noise shape for later weighting of the noise spectra */ - cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel[0]; - last_scf_e = hFdCngCom->cngNoiseLevelExp; - move16(); - - IF( GT_16( st->core, TCX_20_CORE ) ) - { - inc = 2; - } - ELSE - { - inc = 1; - } - move16(); - start_idx = idiv1616( hFdCngCom->startBand, inc ); - stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); - - FOR( i = 0; i < start_idx; i++ ) - { - noise_shape_buffer[i] = 0; - move32(); - noise_shape_buffer_e[i] = 0; - move16(); - } - FOR( ; i < stop_idx; ( i++, cngNoiseLevelPtr += inc ) ) - { - noise_shape_buffer_e[i] = hFdCngCom->cngNoiseLevelExp; - move16(); - noise_shape_buffer[i] = Sqrt32( *( cngNoiseLevelPtr ), &noise_shape_buffer_e[i] ); // Q31-noise_shape_buffer_e[i] - move32(); - noise_shape_buffer_common_exp = s_max( noise_shape_buffer_e[i], noise_shape_buffer_common_exp ); - } - - FOR( i = 0; i < stop_idx; i++ ) - { - IF( NE_16( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ) - { - - noise_shape_buffer[i] = L_shr( noise_shape_buffer[i], sub( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ); // Q31- (noise_shape_buffer_common_exp-noise_shape_buffer_e[i]) - move32(); - } - } - - last_scf = Sqrt32( *( cngNoiseLevelPtr - inc ), &last_scf_e ); // Q31-last_scf_e - - IF( LT_16( noise_shape_buffer_common_exp, last_scf_e ) ) - { - Scale_sig32( noise_shape_buffer, stop_idx, sub( noise_shape_buffer_common_exp, last_scf_e ) ); // Q31- (noise_shape_buffer_common_exp-last_scf_e) - - noise_shape_buffer_common_exp = last_scf_e; - move16(); - } - ELSE - { - last_scf = L_shl( last_scf, sub( last_scf_e, noise_shape_buffer_common_exp ) ); // Q31-(last_scf_e-noise_shape_buffer_common_exp) - } - - FOR( ; i < max_noise_line; i++ ) - { - noise_shape_buffer[i] = last_scf; // Q31 - noise_shape_buffer_common_exp - move32(); - } - - /* fill the noise vector */ - hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31; // Q31 - move32(); - hTonalMDCTConc->curr_noise_nrg_exp = 0; - move16(); - *concealment_noise_exp = add( 16, add( noise_shape_buffer_common_exp, c_e ) ); - move16(); - temp_e = hTonalMDCTConc->curr_noise_nrg_exp; - move16(); - - test(); - test(); - test(); - test(); - IF( EQ_16( noise_gen_mode, EQUAL_CORES ) || ( ( EQ_16( noise_gen_mode, TCX20_IN_0_TCX10_IN_1 ) && EQ_16( idchan, 0 ) ) || ( EQ_16( noise_gen_mode, TCX10_IN_0_TCX20_IN_1 ) && EQ_16( idchan, 1 ) ) ) ) - { - /* current channel is TCX20 -> generate noise for "full-length" spectrum */ - - FOR( i = 0; i < max_noise_line; i++ ) - { - *rnd = own_random( rnd ); // Q0 - *rnd_c = own_random( rnd_c ); - - move16(); - move16(); - - concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); // Q31 - *concealment_noise_exp - move32(); - IF( concealment_noise[i] != 0 ) - { - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e - } - hTonalMDCTConc->curr_noise_nrg_exp = temp_e; - move16(); - } - } - ELSE /* ( ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 1 ) ) */ - { - /* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */ - FOR( i = 0; i < max_noise_line; i++ ) - { - *rnd = own_random( rnd ); // Q0 - *rnd_c = own_random( rnd_c ); // Q0 - move16(); - move16(); - - concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); - move32(); - IF( concealment_noise[i] != 0 ) - { - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e - } - hTonalMDCTConc->curr_noise_nrg_exp = temp_e; - move16(); - - *rnd_c = own_random( rnd_c ); - move16(); - } - } - - IF( st->tonal_mdct_plc_active ) - { - FOR( i = crossOverFreq; i < s_max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i ) - { - concealment_noise[i] = 0; - move32(); - } - } - - /* restore common seed - - after finishing the first channel - - after a first subframe if the current channel is TCX10 */ - - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( idchan, 0 ) && ( EQ_16( core, TCX_20 ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 1 ) ) ) ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 0 ) ) ) - { - *rnd_c = save_rnd_c; - move16(); - } - - st->seed_tcx_plc = *rnd; - move16(); - - pop_wmops(); - - return; -} - - -void TonalMdctConceal_whiten_noise_shape_ivas_fx( - Decoder_State *st, - const Word16 L_frame, - const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ) -{ - Word16 inc, start_idx, stop_idx, i; - Word32 *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; - Word16 noiseLevelPtr_exp; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 whitenend_noise_shape[L_FRAME16k]; - Word16 q_wns; - Word32 scfs_int[FDNS_NPTS]; - const PsychoacousticParameters *psychParams; - - push_wmops( "apply_sns_on_noise_shape" ); - - scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground_fx[0]; - psychParams = st->hTonalMDCTConc->psychParams; - hFdCngCom = st->hFdCngDec->hFdCngCom; - -#ifdef MSAN_FIX - set32_fx( whitenend_noise_shape, 0, L_FRAME16k ); -#endif - - IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) - { - IF( GT_16( st->core, TCX_20_CORE ) ) - { - inc = 2; - move16(); - } - ELSE - { - inc = 1; - move16(); - } - } - ELSE - { - IF( GT_16( st->last_core, TCX_20_CORE ) ) - { - inc = 2; - move16(); - } - ELSE - { - inc = 1; - move16(); - } - } - start_idx = shr( hFdCngCom->startBand, sub( inc, 1 ) ); - stop_idx = shr( L_frame, sub( inc, 1 ) ); - noiseLevelPtr = hFdCngCom->cngNoiseLevel; - noiseLevelPtr_exp = hFdCngCom->cngNoiseLevelExp; - move16(); - - FOR( Word16 j = start_idx; j < stop_idx; j++ ) - { - whitenend_noise_shape[j] = L_shr( *noiseLevelPtr, 3 ); - move32(); - noiseLevelPtr += inc; - } - - IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) - { - Word32 scf[SNS_NPTS]; - - sns_compute_scf_fx( whitenend_noise_shape, psychParams, L_frame, scf, sub( sub( 31, noiseLevelPtr_exp ), 3 ) ); - - sns_interpolate_scalefactors_fx( scfs_int, scf, ENC ); - sns_interpolate_scalefactors_fx( scfs_bg, scf, DEC ); - - scfs_for_shaping = &scfs_int[0]; // Q16 - } - ELSE /* whitening_mode == ON_FIRST_GOOD_FRAME */ - { - scfs_for_shaping = &scfs_bg[0]; // Q16 - } - - IF( sum32_sat( scfs_for_shaping, FDNS_NPTS ) > 0 ) - { - q_wns = sub( sub( 31, noiseLevelPtr_exp ), 3 ); - sns_shape_spectrum_fx( whitenend_noise_shape, &q_wns, psychParams, scfs_for_shaping, Q16, L_frame, NULL ); - - IF( GT_16( add( q_wns, 1 ), sub( 31, hFdCngCom->cngNoiseLevelExp ) ) ) - { - FOR( i = 0; i < sub( stop_idx, start_idx ); i++ ) - { - hFdCngCom->cngNoiseLevel[i] = L_shr( whitenend_noise_shape[start_idx + i], sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); //(q_wns + 1) - move32(); - } - } - ELSE - { - Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, sub( stop_idx, start_idx ) ); - - scale_sig32( hFdCngCom->cngNoiseLevel + sub( stop_idx, start_idx ), sub( FFTCLDFBLEN, sub( stop_idx, start_idx ) ), sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); - - hFdCngCom->cngNoiseLevelExp = sub( Q30, q_wns ); // Exponent = 31 - (q_wns + 1) - move16(); - } - } - ELSE - { - set32_fx( hFdCngCom->cngNoiseLevel, 0, sub( stop_idx, start_idx ) ); - } - - pop_wmops(); -} diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index a4aa23e7f..3cf5f51f3 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -3200,6 +3200,397 @@ static void CalcPowerSpec( powerSpec[nSamples - 1] = L_shr( powerSpec[nSamples - 2], 1 ); move32(); } + + +/*******************************************************/ +/*-------------- public functions -------------------- */ +/*******************************************************/ + +void TonalMdctConceal_create_concealment_noise_ivas_fx( + Word32 concealment_noise[L_FRAME48k], // Q31-concealment_noise_exp + Word16 *concealment_noise_exp, + CPE_DEC_HANDLE hCPE, + const Word16 L_frameTCX, // Q0 + const Word16 L_frame, // Q0 + const Word16 idchan, // Q0 + const Word16 subframe_idx, // Q0 + const Word16 core, // Q0 + const Word16 crossfade_gain, // Q15 + const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ) +{ + STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; + TonalMDCTConcealPtr hTonalMDCTConc; + Decoder_State *st; + HANDLE_FD_CNG_COM hFdCngCom; + Word16 *rnd_c, *rnd; + Word16 crossOverFreq, i, save_rnd_c, max_noise_line; + Word16 c, c_inv, inc; + Word32 noise_shape_buffer[L_FRAME48k]; + Word16 noise_shape_buffer_e[L_FRAME48k]; + Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; + move16(); + Word32 *cngNoiseLevelPtr; + Word32 last_scf; + + Word16 c_e, c_inv_e; + + push_wmops( "create_conc_noise" ); + + hStereoMdct = hCPE->hStereoMdct; + st = hCPE->hCoreCoder[idchan]; + hTonalMDCTConc = st->hTonalMDCTConc; + hFdCngCom = st->hFdCngDec->hFdCngCom; + rnd = &hStereoMdct->noise_seeds_channels[idchan]; + rnd_c = &hStereoMdct->noise_seed_common; + + /* determine start bin for IGF */ + IF( st->igf == 0 ) + { + IF( st->narrowBand == 0 ) + { + /* minimum needed for output with sampling rates lower then the + nominal sampling rate */ + crossOverFreq = s_min( L_frameTCX, L_frame ); + } + ELSE + { + crossOverFreq = L_frameTCX; + move16(); + } + } + ELSE + { + crossOverFreq = s_min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); + } + + /* for tonal mdct concealment with tonal components above the crossover frequency, conditionally raise the frequency index until which noise is generated */ + max_noise_line = crossOverFreq; + move16(); + IF( st->tonal_mdct_plc_active ) + { + max_noise_line = s_max( max_noise_line, extract_l( L_add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ) ) ); + } + + /* first lost frame is handled separately */ + IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) + { + *rnd = add( 1977, idchan ); // Q0 + move16(); + /* will be set twice when looping over two channels, but does not matter */ + *rnd_c = 1979; // Q0 + move16(); + } + + IF( GT_16( crossfade_gain, 32734 ) ) + /* Due to precision loss */ /* 0.999 in Q15*/ + { + /* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */ + FOR( i = 0; i < max_noise_line; i++ ) + { + *rnd = own_random( rnd ); + move16(); + concealment_noise[i] = *rnd; // Q31-concealment_noise_exp + move32(); + } + *concealment_noise_exp = 31; + move16(); + pop_wmops(); + + return; + } + + save_rnd_c = *rnd_c; // Q0 + move16(); + + c_e = 1; + move16(); + c_inv_e = 1; + move16(); + + c = Sqrt16( hStereoMdct->lastCoh_fx, &c_e ); // Q1 = 15 - c_e + c_inv = Sqrt16( sub( ONE_IN_Q14, hStereoMdct->lastCoh_fx ), &c_inv_e ); // Q2 = 15 - c_inv_e + + IF( NE_16( c_e, c_inv_e ) ) + { + IF( LT_16( c_e, c_inv_e ) ) + { + c = shr( c, sub( c_inv_e, c_e ) ); // Q0 + c_e = c_inv_e; + move16(); + } + ELSE + { + c_inv = shr( c_inv, sub( c_e, c_inv_e ) ); // Q0 + } + } + + /* pre-compute the noise shape for later weighting of the noise spectra */ + cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel[0]; + last_scf_e = hFdCngCom->cngNoiseLevelExp; + move16(); + + IF( GT_16( st->core, TCX_20_CORE ) ) + { + inc = 2; + } + ELSE + { + inc = 1; + } + move16(); + start_idx = idiv1616( hFdCngCom->startBand, inc ); + stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); + + FOR( i = 0; i < start_idx; i++ ) + { + noise_shape_buffer[i] = 0; + move32(); + noise_shape_buffer_e[i] = 0; + move16(); + } + FOR( ; i < stop_idx; ( i++, cngNoiseLevelPtr += inc ) ) + { + noise_shape_buffer_e[i] = hFdCngCom->cngNoiseLevelExp; + move16(); + noise_shape_buffer[i] = Sqrt32( *( cngNoiseLevelPtr ), &noise_shape_buffer_e[i] ); // Q31-noise_shape_buffer_e[i] + move32(); + noise_shape_buffer_common_exp = s_max( noise_shape_buffer_e[i], noise_shape_buffer_common_exp ); + } + + FOR( i = 0; i < stop_idx; i++ ) + { + IF( NE_16( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ) + { + + noise_shape_buffer[i] = L_shr( noise_shape_buffer[i], sub( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ); // Q31- (noise_shape_buffer_common_exp-noise_shape_buffer_e[i]) + move32(); + } + } + + last_scf = Sqrt32( *( cngNoiseLevelPtr - inc ), &last_scf_e ); // Q31-last_scf_e + + IF( LT_16( noise_shape_buffer_common_exp, last_scf_e ) ) + { + Scale_sig32( noise_shape_buffer, stop_idx, sub( noise_shape_buffer_common_exp, last_scf_e ) ); // Q31- (noise_shape_buffer_common_exp-last_scf_e) + + noise_shape_buffer_common_exp = last_scf_e; + move16(); + } + ELSE + { + last_scf = L_shl( last_scf, sub( last_scf_e, noise_shape_buffer_common_exp ) ); // Q31-(last_scf_e-noise_shape_buffer_common_exp) + } + + FOR( ; i < max_noise_line; i++ ) + { + noise_shape_buffer[i] = last_scf; // Q31 - noise_shape_buffer_common_exp + move32(); + } + + /* fill the noise vector */ + hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31; // Q31 + move32(); + hTonalMDCTConc->curr_noise_nrg_exp = 0; + move16(); + *concealment_noise_exp = add( 16, add( noise_shape_buffer_common_exp, c_e ) ); + move16(); + temp_e = hTonalMDCTConc->curr_noise_nrg_exp; + move16(); + + test(); + test(); + test(); + test(); + IF( EQ_16( noise_gen_mode, EQUAL_CORES ) || ( ( EQ_16( noise_gen_mode, TCX20_IN_0_TCX10_IN_1 ) && EQ_16( idchan, 0 ) ) || ( EQ_16( noise_gen_mode, TCX10_IN_0_TCX20_IN_1 ) && EQ_16( idchan, 1 ) ) ) ) + { + /* current channel is TCX20 -> generate noise for "full-length" spectrum */ + + FOR( i = 0; i < max_noise_line; i++ ) + { + *rnd = own_random( rnd ); // Q0 + *rnd_c = own_random( rnd_c ); + + move16(); + move16(); + + concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); // Q31 - *concealment_noise_exp + move32(); + IF( concealment_noise[i] != 0 ) + { + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e + } + hTonalMDCTConc->curr_noise_nrg_exp = temp_e; + move16(); + } + } + ELSE /* ( ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 1 ) ) */ + { + /* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */ + FOR( i = 0; i < max_noise_line; i++ ) + { + *rnd = own_random( rnd ); // Q0 + *rnd_c = own_random( rnd_c ); // Q0 + move16(); + move16(); + + concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); + move32(); + IF( concealment_noise[i] != 0 ) + { + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e + } + hTonalMDCTConc->curr_noise_nrg_exp = temp_e; + move16(); + + *rnd_c = own_random( rnd_c ); + move16(); + } + } + + IF( st->tonal_mdct_plc_active ) + { + FOR( i = crossOverFreq; i < s_max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i ) + { + concealment_noise[i] = 0; + move32(); + } + } + + /* restore common seed + - after finishing the first channel + - after a first subframe if the current channel is TCX10 */ + + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( idchan, 0 ) && ( EQ_16( core, TCX_20 ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 1 ) ) ) ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 0 ) ) ) + { + *rnd_c = save_rnd_c; + move16(); + } + + st->seed_tcx_plc = *rnd; + move16(); + + pop_wmops(); + + return; +} + + +void TonalMdctConceal_whiten_noise_shape_ivas_fx( + Decoder_State *st, + const Word16 L_frame, + const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ) +{ + Word16 inc, start_idx, stop_idx, i; + Word32 *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; + Word16 noiseLevelPtr_exp; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 whitenend_noise_shape[L_FRAME16k]; + Word16 q_wns; + Word32 scfs_int[FDNS_NPTS]; + const PsychoacousticParameters *psychParams; + + push_wmops( "apply_sns_on_noise_shape" ); + + scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground_fx[0]; + psychParams = st->hTonalMDCTConc->psychParams; + hFdCngCom = st->hFdCngDec->hFdCngCom; + +#ifdef MSAN_FIX + set32_fx( whitenend_noise_shape, 0, L_FRAME16k ); +#endif + + IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) + { + IF( GT_16( st->core, TCX_20_CORE ) ) + { + inc = 2; + move16(); + } + ELSE + { + inc = 1; + move16(); + } + } + ELSE + { + IF( GT_16( st->last_core, TCX_20_CORE ) ) + { + inc = 2; + move16(); + } + ELSE + { + inc = 1; + move16(); + } + } + start_idx = shr( hFdCngCom->startBand, sub( inc, 1 ) ); + stop_idx = shr( L_frame, sub( inc, 1 ) ); + noiseLevelPtr = hFdCngCom->cngNoiseLevel; + noiseLevelPtr_exp = hFdCngCom->cngNoiseLevelExp; + move16(); + + FOR( Word16 j = start_idx; j < stop_idx; j++ ) + { + whitenend_noise_shape[j] = L_shr( *noiseLevelPtr, 3 ); + move32(); + noiseLevelPtr += inc; + } + + IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) + { + Word32 scf[SNS_NPTS]; + + sns_compute_scf_fx( whitenend_noise_shape, psychParams, L_frame, scf, sub( sub( 31, noiseLevelPtr_exp ), 3 ) ); + + sns_interpolate_scalefactors_fx( scfs_int, scf, ENC ); + sns_interpolate_scalefactors_fx( scfs_bg, scf, DEC ); + + scfs_for_shaping = &scfs_int[0]; // Q16 + } + ELSE /* whitening_mode == ON_FIRST_GOOD_FRAME */ + { + scfs_for_shaping = &scfs_bg[0]; // Q16 + } + + IF( sum32_sat( scfs_for_shaping, FDNS_NPTS ) > 0 ) + { + q_wns = sub( sub( 31, noiseLevelPtr_exp ), 3 ); + sns_shape_spectrum_fx( whitenend_noise_shape, &q_wns, psychParams, scfs_for_shaping, Q16, L_frame, NULL ); + + IF( GT_16( add( q_wns, 1 ), sub( 31, hFdCngCom->cngNoiseLevelExp ) ) ) + { + FOR( i = 0; i < sub( stop_idx, start_idx ); i++ ) + { + hFdCngCom->cngNoiseLevel[i] = L_shr( whitenend_noise_shape[start_idx + i], sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); //(q_wns + 1) + move32(); + } + } + ELSE + { + Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, sub( stop_idx, start_idx ) ); + + scale_sig32( hFdCngCom->cngNoiseLevel + sub( stop_idx, start_idx ), sub( FFTCLDFBLEN, sub( stop_idx, start_idx ) ), sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); + + hFdCngCom->cngNoiseLevelExp = sub( Q30, q_wns ); // Exponent = 31 - (q_wns + 1) + move16(); + } + } + ELSE + { + set32_fx( hFdCngCom->cngNoiseLevel, 0, sub( stop_idx, start_idx ) ); + } + + pop_wmops(); +} + + #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT void TonalMdctConceal_create_concealment_noise( float concealment_noise[L_FRAME48k], -- GitLab From 5424115f277ce702a36ade2f97f07029b2c543a6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 20:44:33 +0530 Subject: [PATCH 242/329] Clang formatting --- lib_dec/ari_dec_fx.c | 1 - lib_dec/arith_coder_dec_fx.c | 1 - lib_dec/bass_psfilter_fx.c | 10 +++++----- lib_dec/core_dec_init_fx.c | 1 - lib_dec/core_switching_dec_fx.c | 2 +- lib_dec/dec_prm_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/fd_cng_dec_fx.c | 8 ++++---- lib_dec/swb_bwe_dec_fx.c | 1 - 9 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index 524f9d121..3aabbdaa5 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -839,4 +839,3 @@ Word16 ari_decode_14bits_sign_ivas( return bp; } - diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 6df1eb268..e5a1220e0 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -420,4 +420,3 @@ void tcx_arith_decode_envelope_ivas_fx( return; } - diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 7d2be2c52..75cabf160 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -4,12 +4,12 @@ #include #include -#include "options.h" /* Compilation switches */ -#include "prot_fx.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ -#include "cnst.h" /* Common constants */ -#include "rom_com.h" /* Static table prototypes */ -#include "rom_dec.h" /* Static table prototypes */ +#include "cnst.h" /* Common constants */ +#include "rom_com.h" /* Static table prototypes */ +#include "rom_dec.h" /* Static table prototypes */ #include "basop_util.h" /*---------------------------------------------------------------------* diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index f649772b2..8fefa3bb2 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -2216,4 +2216,3 @@ void reset_tcx_overl_buf_fx( move16(); return; } - diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index caef9485b..52c3e3073 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -3443,4 +3443,4 @@ void ivas_bw_switching_pre_proc_fx( } return; -} \ No newline at end of file +} diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 77fd7d421..3d277807d 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -2011,4 +2011,3 @@ void getTCXWindowing_ivas_fx( return; } - diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 4d97367ef..e71157a1e 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5302,4 +5302,3 @@ void decoder_tcx_imdct_fx( return; } - diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index f788144fa..70c4760ae 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -20,10 +20,10 @@ #endif -#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ -#define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */ -#define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */ -#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ +#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ +#define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */ +#define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */ +#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ #define DELTA_MASKING_NOISE_Q15 0 #define LOG_10_BASE_2 1783446566 /* Q29 */ #define GAIN_Q_OFFSET_IVAS_FX 45 diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 23c4c3e8a..d15a97821 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1634,4 +1634,3 @@ void fd_bwe_dec_init_fx( return; } - -- GitLab From a8e2883c2491bc9327bf11f806321d6f14e29b59 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 22:29:22 +0530 Subject: [PATCH 243/329] Fix for 3GPP issue 1325: saturation occuring in tcx_encoder_memory_update_ivas_fx() Link #1325 --- lib_enc/ivas_tcx_core_enc.c | 18 ++---------------- lib_enc/tcx_utils_enc_fx.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index cecc1bf80..84bffa87c 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -570,23 +570,9 @@ void stereo_tcx_core_enc( move16(); move16(); - /* Scaling old_exc buffer to Q_new */ - IF( NE_16( Q_new, Q_exc ) ) - { - Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, Q_exc ) ); - } - coder_tcx_post_ivas_fx( st, st->hLPDmem, st->hTcxCfg, st->synth, A_q_fx, Aw_fx, st->wspeech_enc, Q_new ); - /* Upscaling old_exc buffer */ - s = norm_arr( st->hLPDmem->old_exc, L_EXC_MEM ) - 1; - Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, s ); - IF( st->hTdCngEnc != NULL ) - { - Scale_sig( st->hTdCngEnc->cng_exc2_buf, HO_HIST_SIZE * L_FFT, sub( add( shl( Q_new, 1 ), s ), Q_exc ) ); - } - Q_exc = add( shl( Q_new, 1 ), s ); // 2 * Q_new + s - st->hLPDmem->q_lpd_old_exc = Q_exc; + Q_exc = Q_new; // Q_new move16(); IF( st->enableTcxLpc ) @@ -659,7 +645,7 @@ void stereo_tcx_core_enc( ELSE { cng_params_upd_ivas_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, - st->hTdCngEnc->ho_lsp_circ_fx, Q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, + st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 5e7ca7be8..2a6f040ac 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2814,12 +2814,12 @@ void tcx_encoder_memory_update_ivas_fx( /* Emphasis of synth -> synth_pe */ tmp = synth[-( M + 1 )]; move16(); - E_UTIL_f_preemph2( Q_new - 1, synth - M, preemph, add( M, L_frame_glob ), &tmp ); + E_UTIL_f_preemph2( 0, synth - M, preemph, add( M, L_frame_glob ), &tmp ); // Q_new Copy( synth + sub( L_frame_glob, M ), LPDmem->mem_syn, M ); Copy( synth + sub( L_frame_glob, M ), LPDmem->mem_syn2, M ); Copy( synth + sub( L_frame_glob, L_SYN_MEM ), LPDmem->mem_syn_r, L_SYN_MEM ); - LPDmem->q_mem_syn = sub( shl( Q_new, 1 ), 1 ); // resultant q of synth after E_UTIL_f_preemph2 + LPDmem->q_mem_syn = Q_new; // resultant q of synth after E_UTIL_f_preemph2 move16(); test(); @@ -2828,13 +2828,27 @@ void tcx_encoder_memory_update_ivas_fx( /* Update excitation */ IF( LT_16( L_frame_glob, L_EXC_MEM ) ) { - Copy( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ) ); - Scale_sig( LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ), Q_new ); // Q_new->2*Q_new - Residu3_fx( A, synth, LPDmem->old_exc + sub( L_EXC_MEM, L_frame_glob ), L_frame_glob, 1 ); // 2*Q_new + Word16 shift = norm_arr( LPDmem->old_exc + L_frame_glob, sub( L_EXC_MEM, L_frame_glob ) ); + IF( LT_16( shift, sub( Q_new, LPDmem->q_lpd_old_exc ) ) ) + { + Copy_Scale_sig( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ), shift ); + LPDmem->q_lpd_old_exc = add( LPDmem->q_lpd_old_exc, shift ); + move16(); + Residu3_fx( A, synth, LPDmem->old_exc + sub( L_EXC_MEM, L_frame_glob ), L_frame_glob, sub( LPDmem->q_lpd_old_exc, Q_new ) ); // LPDmem->q_lpd_old_exc + } + ELSE + { + Copy_Scale_sig( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ), sub( Q_new, LPDmem->q_lpd_old_exc ) ); + Residu3_fx( A, synth, LPDmem->old_exc + sub( L_EXC_MEM, L_frame_glob ), L_frame_glob, 0 ); // Q_new + LPDmem->q_lpd_old_exc = Q_new; + move16(); + } } ELSE { - Residu3_fx( A, synth + sub( L_frame_glob, L_EXC_MEM ), LPDmem->old_exc, L_EXC_MEM, 1 ); // 2*Q_new + Residu3_fx( A, synth + sub( L_frame_glob, L_EXC_MEM ), LPDmem->old_exc, L_EXC_MEM, 0 ); // Q_new + LPDmem->q_lpd_old_exc = Q_new; + move16(); } } } -- GitLab From 1e58f1597c8d14b4bcecd1658fd3a6e0f4a99ac7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 4 Mar 2025 20:50:46 +0100 Subject: [PATCH 244/329] encapsulate changes --- lib_com/ivas_prot_fx.h | 7 ++++-- lib_com/ivas_tools.c | 14 ++++-------- lib_com/options.h | 1 + lib_enc/speech_music_classif_fx.c | 36 ++++++++++++++++++++++++++++--- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6b09b1b47..1bdc33439 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4706,6 +4706,8 @@ Word32 dot_product_cholesky_fx( const Word32 *A, /* i : Cholesky matrix A */ const Word16 N /* i : vector & matrix size */ ); + +#ifndef DOT_PROD_CHOLESKY_64BIT Word32 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x */ const Word32 *A, /* i : Cholesky matrix A */ @@ -4713,12 +4715,13 @@ Word32 dot_product_cholesky_fixed( const Word16 exp_x, const Word16 exp_A, Word16 *exp_sum ); - -Word64 dot_product_cholesky_fixed64( +#else +Word64 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x */ const Word32 *A, /* i : Cholesky matrix A */ const Word16 N /* i : vector & matrix size */ ); +#endif void v_mult_mat_fx( Word32 *y_fx, /* o : the product x*A */ diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index dc45e3f0e..d55766928 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -606,6 +606,7 @@ void v_sub32_fx( * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) *---------------------------------------------------------------------*/ +#ifndef DOT_PROD_CHOLESKY_64BIT /*! r: the dot product x'*A*A'*x */ Word32 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x Q31 - exp_x*/ @@ -642,17 +643,9 @@ Word32 dot_product_cholesky_fixed( return suma; } - -/*---------------------------------------------------------------------* - * dot_product_cholesky() - * - * Calculates dot product of type x'*A*A'*x, where x is column vector of size m, - * and A is a Cholesky decomposition of some Hermitian matrix S whose size is m*m. - * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) - *---------------------------------------------------------------------*/ - +#else /*! r: the dot product x'*A*A'*x */ -Word64 dot_product_cholesky_fixed64( +Word64 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x Q31 - exp_x*/ const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ const Word16 N /* i : vector & matrix size Q0*/ @@ -686,6 +679,7 @@ Word64 dot_product_cholesky_fixed64( return suma; } +#endif void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ diff --git a/lib_com/options.h b/lib_com/options.h index a37ccf387..5fc9a375f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,4 +169,5 @@ #define FIX_1298 /* VA: fix possible assert in gaus_enc */ #define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ +#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ #endif diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index fe6647a6c..f0fc3f304 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1683,8 +1683,16 @@ Word16 ivas_smc_gmm_fx( Word16 flag_odv; Word32 lps_fx, lpm_fx, lpn_fx; Word32 ps_fx[N_SMC_MIXTURES], pm_fx[N_SMC_MIXTURES], pn_fx[N_SMC_MIXTURES]; +#ifndef DOT_PROD_CHOLESKY_64BIT + Word32 lprob_fx; + Word16 lprob_exp = 0; +#else Word64 wprob_fx; +#endif Word32 fvm_fx[N_PCA_COEF]; +#ifndef DOT_PROD_CHOLESKY_64BIT + Word16 fvm_exp = 0; +#endif Word32 sum_PS_fx, ps_diff_fx, ps_sta_fx; Word32 dlp_fx, wrelE_fx, wdrop_fx, wght_fx; Word32 wrise_fx; @@ -2271,16 +2279,38 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 +#ifndef DOT_PROD_CHOLESKY_64BIT + fvm_exp = sub( 31, Qfact_FV ); + lprob_exp = 0; + move16(); + lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#else + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#endif move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 +#ifndef DOT_PROD_CHOLESKY_64BIT + lprob_exp = 0; + move16(); + lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#else + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#endif move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 +#ifndef DOT_PROD_CHOLESKY_64BIT + lprob_exp = 0; + move16(); + lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#else + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#endif move32(); } -- GitLab From 8fdbf84cbcff08af6e4891b170a24ec1bea7a9ed Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 5 Mar 2025 14:12:25 +1100 Subject: [PATCH 245/329] changing ci branch back to basop-ci-branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4fbe56eb..0ccb41bd9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-sr-obj-scores" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 -- GitLab From 0a6e192810ff8bd1bfa653f383dc55039487756c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 10:56:41 +0530 Subject: [PATCH 246/329] Renaming all files with "_fx" suffix --- Workspace_msvc/lib_com.vcxproj | 60 ++-- Workspace_msvc/lib_com.vcxproj.filters | 180 +++++----- Workspace_msvc/lib_dec.vcxproj | 96 ++--- Workspace_msvc/lib_dec.vcxproj.filters | 288 +++++++-------- Workspace_msvc/lib_enc.vcxproj | 110 +++--- Workspace_msvc/lib_enc.vcxproj.filters | 330 +++++++++--------- Workspace_msvc/lib_rend.vcxproj | 76 ++-- Workspace_msvc/lib_rend.vcxproj.filters | 83 +++-- lib_com/{ivas_arith.c => ivas_arith_fx.c} | 0 ...er_com.c => ivas_avq_pos_reorder_com_fx.c} | 0 ...ivas_cov_smooth.c => ivas_cov_smooth_fx.c} | 0 .../{ivas_dirac_com.c => ivas_dirac_com_fx.c} | 0 ...ommon.c => ivas_entropy_coder_common_fx.c} | 0 .../{ivas_fb_mixer.c => ivas_fb_mixer_fx.c} | 0 lib_com/{ivas_filters.c => ivas_filters_fx.c} | 0 lib_com/{ivas_ism_com.c => ivas_ism_com_fx.c} | 0 lib_com/{ivas_lfe_com.c => ivas_lfe_com_fx.c} | 0 .../{ivas_masa_com.c => ivas_masa_com_fx.c} | 0 lib_com/{ivas_mc_com.c => ivas_mc_com_fx.c} | 0 ..._mc_param_com.c => ivas_mc_param_com_fx.c} | 0 ...ivas_mcmasa_com.c => ivas_mcmasa_com-fx.c} | 0 lib_com/{ivas_mct_com.c => ivas_mct_com_fx.c} | 0 ...dct_core_com.c => ivas_mdct_core_com_fx.c} | 0 ...ivas_mdft_imdft.c => ivas_mdft_imdft_fx.c} | 0 .../{ivas_omasa_com.c => ivas_omasa_com_fx.c} | 0 .../{ivas_pca_tools.c => ivas_pca_tools_fx.c} | 0 ...metadata_com.c => ivas_qmetadata_com_fx.c} | 0 ...herical_com.c => ivas_qspherical_com_fx.c} | 0 ...ivas_sba_config.c => ivas_sba_config_fx.c} | 0 .../{ivas_spar_com.c => ivas_spar_com_fx.c} | 0 ...t_util.c => ivas_spar_com_quant_util_fx.c} | 0 ...reo_dft_com.c => ivas_stereo_dft_com_fx.c} | 0 ..._com.c => ivas_stereo_mdct_bands_com_fx.c} | 0 ...com.c => ivas_stereo_mdct_stereo_com_fx.c} | 0 ...pc_com.c => ivas_stereo_psychlpc_com_fx.c} | 0 ..._alloc.c => ivas_stereo_td_bit_alloc_fx.c} | 0 lib_com/{ivas_tools.c => ivas_tools_fx.c} | 0 ...ransient_det.c => ivas_transient_det_fx.c} | 0 ...ernal.c => ivas_binRenderer_internal_fx.c} | 0 .../{ivas_core_dec.c => ivas_core_dec_fx.c} | 0 ...fig.c => ivas_corecoder_dec_reconfig_fx.c} | 0 ...ix_dec.c => ivas_decision_matrix_dec_fx.c} | 0 .../{ivas_dirac_dec.c => ivas_dirac_dec_fx.c} | 0 ...c => ivas_dirac_output_synthesis_cov_fx.c} | 0 ...py_decoder.c => ivas_entropy_decoder_fx.c} | 0 lib_dec/{ivas_ism_dec.c => ivas_ism_dec_fx.c} | 0 ...as_ism_dtx_dec.c => ivas_ism_dtx_dec_fx.c} | 0 ...adata_dec.c => ivas_ism_metadata_dec_fx.c} | 0 ...sm_param_dec.c => ivas_ism_param_dec_fx.c} | 0 ..._ism_renderer.c => ivas_ism_renderer_fx.c} | 0 lib_dec/{ivas_jbm_dec.c => ivas_jbm_dec_fx.c} | 0 ...s_custom_dec.c => ivas_ls_custom_dec_fx.c} | 0 .../{ivas_masa_dec.c => ivas_masa_dec_fx.c} | 0 ..._mc_param_dec.c => ivas_mc_param_dec_fx.c} | 0 ...pmix_dec.c => ivas_mc_paramupmix_dec_fx.c} | 0 ...ivas_mcmasa_dec.c => ivas_mcmasa_dec_fx.c} | 0 ..._mct_core_dec.c => ivas_mct_core_dec_fx.c} | 0 lib_dec/{ivas_mct_dec.c => ivas_mct_dec_fx.c} | 0 ..._dec_mct_fx.c => ivas_mct_dec_mct_fx_fx.c} | 0 ...dct_core_dec.c => ivas_mdct_core_dec_fx.c} | 0 ...renderer.c => ivas_mono_dmx_renderer_fx.c} | 0 ...al.c => ivas_objectRenderer_internal_fx.c} | 0 .../{ivas_omasa_dec.c => ivas_omasa_dec_fx.c} | 0 .../{ivas_osba_dec.c => ivas_osba_dec_fx.c} | 0 ...rsion.c => ivas_out_setup_conversion_fx.c} | 0 ...utput_config.c => ivas_output_config_fx.c} | 0 .../{ivas_post_proc.c => ivas_post_proc_fx.c} | 0 ...metadata_dec.c => ivas_qmetadata_dec_fx.c} | 0 ...herical_dec.c => ivas_qspherical_dec_fx.c} | 0 ...ange_uni_dec.c => ivas_range_uni_dec_fx.c} | 0 lib_dec/{ivas_sba_dec.c => ivas_sba_dec_fx.c} | 0 ...nal.c => ivas_sba_rendering_internal_fx.c} | 0 ..._spar_decoder.c => ivas_spar_decoder_fx.c} | 0 ...as_spar_md_dec.c => ivas_spar_md_dec_fx.c} | 0 ...GR_dec.c => ivas_stereo_adapt_GR_dec_fx.c} | 0 ...dec_dmx.c => ivas_stereo_dft_dec_dmx_fx.c} | 0 ...eclvq_dec.c => ivas_stereo_eclvq_dec_fx.c} | 0 ...reo_esf_dec.c => ivas_stereo_esf_dec_fx.c} | 0 ...reo_ica_dec.c => ivas_stereo_ica_dec_fx.c} | 0 ...icbwe_dec.c => ivas_stereo_icbwe_dec_fx.c} | 0 ...dec.c => ivas_stereo_mdct_stereo_dec_fx.c} | 0 ...g_dec.c => ivas_stereo_switching_dec_fx.c} | 0 ...tereo_td_dec.c => ivas_stereo_td_dec_fx.c} | 0 lib_dec/{ivas_svd_dec.c => ivas_svd_dec_fx.c} | 0 ..._tcx_core_dec.c => ivas_tcx_core_dec_fx.c} | 0 ...w_rate_dec.c => ivas_td_low_rate_dec_fx.c} | 0 lib_enc/{ivas_agc_enc.c => ivas_agc_enc_fx.c} | 0 .../{ivas_core_enc.c => ivas_core_enc_fx.c} | 0 ..._front.c => ivas_core_pre_proc_front_fx.c} | 0 ...ore_pre_proc.c => ivas_core_pre_proc_fx.c} | 0 ...fig.c => ivas_corecoder_enc_reconfig_fx.c} | 0 lib_enc/{ivas_cpe_enc.c => ivas_cpe_enc_fx.c} | 0 ...ix_enc.c => ivas_decision_matrix_enc_fx.c} | 0 .../{ivas_dirac_enc.c => ivas_dirac_enc_fx.c} | 0 ...ov_handler.c => ivas_enc_cov_handler_fx.c} | 0 lib_enc/{ivas_enc.c => ivas_enc_fx.c} | 0 ...ntropy_coder.c => ivas_entropy_coder_fx.c} | 0 .../{ivas_front_vad.c => ivas_front_vad_fx.c} | 0 .../{ivas_init_enc.c => ivas_init_enc_fx.c} | 0 ...as_ism_dtx_enc.c => ivas_ism_dtx_enc_fx.c} | 0 lib_enc/{ivas_ism_enc.c => ivas_ism_enc_fx.c} | 0 ...adata_enc.c => ivas_ism_metadata_enc_fx.c} | 0 ...sm_param_enc.c => ivas_ism_param_enc_fx.c} | 0 lib_enc/{ivas_lfe_enc.c => ivas_lfe_enc_fx.c} | 0 .../{ivas_masa_enc.c => ivas_masa_enc_fx.c} | 0 ..._mc_param_enc.c => ivas_mc_param_enc_fx.c} | 0 ...pmix_enc.c => ivas_mc_paramupmix_enc_fx.c} | 0 ...ivas_mcmasa_enc.c => ivas_mcmasa_enc_fx.c} | 0 ..._mct_core_enc.c => ivas_mct_core_enc_fx.c} | 0 lib_enc/{ivas_mct_enc.c => ivas_mct_enc_fx.c} | 0 ...as_mct_enc_mct.c => ivas_mct_enc_mct_fx.c} | 0 ...dct_core_enc.c => ivas_mdct_core_enc_fx.c} | 0 .../{ivas_omasa_enc.c => ivas_omasa_enc_fx.c} | 0 .../{ivas_osba_enc.c => ivas_osba_enc_fx.c} | 0 lib_enc/{ivas_pca_enc.c => ivas_pca_enc_fx.c} | 0 ...metadata_enc.c => ivas_qmetadata_enc_fx.c} | 0 ...herical_enc.c => ivas_qspherical_enc_fx.c} | 0 ...ange_uni_enc.c => ivas_range_uni_enc_fx.c} | 0 lib_enc/{ivas_sba_enc.c => ivas_sba_enc_fx.c} | 0 lib_enc/{ivas_sce_enc.c => ivas_sce_enc_fx.c} | 0 lib_enc/{ivas_sns_enc.c => ivas_sns_enc_fx.c} | 0 ..._spar_encoder.c => ivas_spar_encoder_fx.c} | 0 ...as_spar_md_enc.c => ivas_spar_md_enc_fx.c} | 0 ...GR_enc.c => ivas_stereo_adapt_GR_enc_fx.c} | 0 ...assifier.c => ivas_stereo_classifier_fx.c} | 0 ...reo_cng_enc.c => ivas_stereo_cng_enc_fx.c} | 0 ...reo_dft_enc.c => ivas_stereo_dft_enc_fx.c} | 0 ...enc_itd.c => ivas_stereo_dft_enc_itd_fx.c} | 0 ...t_td_itd.c => ivas_stereo_dft_td_itd_fx.c} | 0 ...reo_dmx_evs.c => ivas_stereo_dmx_evs_fx.c} | 0 ...eclvq_enc.c => ivas_stereo_eclvq_enc_fx.c} | 0 ...reo_ica_enc.c => ivas_stereo_ica_enc_fx.c} | 0 ...icbwe_enc.c => ivas_stereo_icbwe_enc_fx.c} | 0 ...e_enc.c => ivas_stereo_mdct_core_enc_fx.c} | 0 ...gf_enc.c => ivas_stereo_mdct_igf_enc_fx.c} | 0 ...enc.c => ivas_stereo_mdct_stereo_enc_fx.c} | 0 ...g_enc.c => ivas_stereo_switching_enc_fx.c} | 0 ...nalysis.c => ivas_stereo_td_analysis_fx.c} | 0 ...tereo_td_enc.c => ivas_stereo_td_enc_fx.c} | 0 ..._tcx_core_enc.c => ivas_tcx_core_enc_fx.c} | 0 ...w_rate_enc.c => ivas_td_low_rate_enc_fx.c} | 0 ...ivas_allrad_dec.c => ivas_allrad_dec_fx.c} | 0 lib_rend/{ivas_crend.c => ivas_crend_fx.c} | 0 .../{ivas_dirac_ana.c => ivas_dirac_ana_fx.c} | 0 ...=> ivas_dirac_dec_binaural_functions_fx.c} | 0 ...ecorr_dec.c => ivas_dirac_decorr_dec_fx.c} | 0 ...nsets_dec.c => ivas_dirac_onsets_dec_fx.c} | 0 ...c => ivas_dirac_output_synthesis_dec_fx.c} | 0 ...ivas_dirac_rend.c => ivas_dirac_rend_fx.c} | 0 lib_rend/{ivas_efap.c => ivas_efap_fx.c} | 0 lib_rend/{ivas_hrtf.c => ivas_hrtf_fx.c} | 0 .../{ivas_limiter.c => ivas_limiter_fx.c} | 0 ...ivas_masa_merge.c => ivas_masa_merge_fx.c} | 0 ...ivas_mcmasa_ana.c => ivas_mcmasa_ana_fx.c} | 0 ...ectRenderer.c => ivas_objectRenderer_fx.c} | 0 ...Filt.c => ivas_objectRenderer_hrFilt_fx.c} | 0 ...rer_mix.c => ivas_objectRenderer_mix_fx.c} | 0 ...rer_sfx.c => ivas_objectRenderer_sfx_fx.c} | 0 ...ces.c => ivas_objectRenderer_sources_fx.c} | 0 ...rer_vec.c => ivas_objectRenderer_vec_fx.c} | 0 .../{ivas_omasa_ana.c => ivas_omasa_ana_fx.c} | 0 ...ivas_orient_trk.c => ivas_orient_trk_fx.c} | 0 ...as_reflections.c => ivas_reflections_fx.c} | 0 ...ender_config.c => ivas_render_config_fx.c} | 0 ...lay_line.c => ivas_reverb_delay_line_fx.c} | 0 ...t_filter.c => ivas_reverb_fft_filter_fx.c} | 0 ...esign.c => ivas_reverb_filter_design_fx.c} | 0 lib_rend/{ivas_reverb.c => ivas_reverb_fx.c} | 0 ...r_filter.c => ivas_reverb_iir_filter_fx.c} | 0 ..._reverb_utils.c => ivas_reverb_utils_fx.c} | 0 ...rer.c => ivas_rom_TdBinauralRenderer_fx.c} | 0 ...derer.c => ivas_rom_binauralRenderer_fx.c} | 0 ...ad.c => ivas_rom_binaural_crend_head_fx.c} | 0 .../{ivas_rom_rend.c => ivas_rom_rend_fx.c} | 0 .../{ivas_rotation.c => ivas_rotation_fx.c} | 0 ...ba_rendering.c => ivas_sba_rendering_fx.c} | 0 .../{ivas_shoebox.c => ivas_shoebox_fx.c} | 0 .../{ivas_td_decorr.c => ivas_td_decorr_fx.c} | 0 lib_rend/{ivas_vbap.c => ivas_vbap_fx.c} | 0 179 files changed, 610 insertions(+), 613 deletions(-) rename lib_com/{ivas_arith.c => ivas_arith_fx.c} (100%) rename lib_com/{ivas_avq_pos_reorder_com.c => ivas_avq_pos_reorder_com_fx.c} (100%) rename lib_com/{ivas_cov_smooth.c => ivas_cov_smooth_fx.c} (100%) rename lib_com/{ivas_dirac_com.c => ivas_dirac_com_fx.c} (100%) rename lib_com/{ivas_entropy_coder_common.c => ivas_entropy_coder_common_fx.c} (100%) rename lib_com/{ivas_fb_mixer.c => ivas_fb_mixer_fx.c} (100%) rename lib_com/{ivas_filters.c => ivas_filters_fx.c} (100%) rename lib_com/{ivas_ism_com.c => ivas_ism_com_fx.c} (100%) rename lib_com/{ivas_lfe_com.c => ivas_lfe_com_fx.c} (100%) rename lib_com/{ivas_masa_com.c => ivas_masa_com_fx.c} (100%) rename lib_com/{ivas_mc_com.c => ivas_mc_com_fx.c} (100%) rename lib_com/{ivas_mc_param_com.c => ivas_mc_param_com_fx.c} (100%) rename lib_com/{ivas_mcmasa_com.c => ivas_mcmasa_com-fx.c} (100%) rename lib_com/{ivas_mct_com.c => ivas_mct_com_fx.c} (100%) rename lib_com/{ivas_mdct_core_com.c => ivas_mdct_core_com_fx.c} (100%) rename lib_com/{ivas_mdft_imdft.c => ivas_mdft_imdft_fx.c} (100%) rename lib_com/{ivas_omasa_com.c => ivas_omasa_com_fx.c} (100%) rename lib_com/{ivas_pca_tools.c => ivas_pca_tools_fx.c} (100%) rename lib_com/{ivas_qmetadata_com.c => ivas_qmetadata_com_fx.c} (100%) rename lib_com/{ivas_qspherical_com.c => ivas_qspherical_com_fx.c} (100%) rename lib_com/{ivas_sba_config.c => ivas_sba_config_fx.c} (100%) rename lib_com/{ivas_spar_com.c => ivas_spar_com_fx.c} (100%) rename lib_com/{ivas_spar_com_quant_util.c => ivas_spar_com_quant_util_fx.c} (100%) rename lib_com/{ivas_stereo_dft_com.c => ivas_stereo_dft_com_fx.c} (100%) rename lib_com/{ivas_stereo_mdct_bands_com.c => ivas_stereo_mdct_bands_com_fx.c} (100%) rename lib_com/{ivas_stereo_mdct_stereo_com.c => ivas_stereo_mdct_stereo_com_fx.c} (100%) rename lib_com/{ivas_stereo_psychlpc_com.c => ivas_stereo_psychlpc_com_fx.c} (100%) rename lib_com/{ivas_stereo_td_bit_alloc.c => ivas_stereo_td_bit_alloc_fx.c} (100%) rename lib_com/{ivas_tools.c => ivas_tools_fx.c} (100%) rename lib_com/{ivas_transient_det.c => ivas_transient_det_fx.c} (100%) rename lib_dec/{ivas_binRenderer_internal.c => ivas_binRenderer_internal_fx.c} (100%) rename lib_dec/{ivas_core_dec.c => ivas_core_dec_fx.c} (100%) rename lib_dec/{ivas_corecoder_dec_reconfig.c => ivas_corecoder_dec_reconfig_fx.c} (100%) rename lib_dec/{ivas_decision_matrix_dec.c => ivas_decision_matrix_dec_fx.c} (100%) rename lib_dec/{ivas_dirac_dec.c => ivas_dirac_dec_fx.c} (100%) rename lib_dec/{ivas_dirac_output_synthesis_cov.c => ivas_dirac_output_synthesis_cov_fx.c} (100%) rename lib_dec/{ivas_entropy_decoder.c => ivas_entropy_decoder_fx.c} (100%) rename lib_dec/{ivas_ism_dec.c => ivas_ism_dec_fx.c} (100%) rename lib_dec/{ivas_ism_dtx_dec.c => ivas_ism_dtx_dec_fx.c} (100%) rename lib_dec/{ivas_ism_metadata_dec.c => ivas_ism_metadata_dec_fx.c} (100%) rename lib_dec/{ivas_ism_param_dec.c => ivas_ism_param_dec_fx.c} (100%) rename lib_dec/{ivas_ism_renderer.c => ivas_ism_renderer_fx.c} (100%) rename lib_dec/{ivas_jbm_dec.c => ivas_jbm_dec_fx.c} (100%) rename lib_dec/{ivas_ls_custom_dec.c => ivas_ls_custom_dec_fx.c} (100%) rename lib_dec/{ivas_masa_dec.c => ivas_masa_dec_fx.c} (100%) rename lib_dec/{ivas_mc_param_dec.c => ivas_mc_param_dec_fx.c} (100%) rename lib_dec/{ivas_mc_paramupmix_dec.c => ivas_mc_paramupmix_dec_fx.c} (100%) rename lib_dec/{ivas_mcmasa_dec.c => ivas_mcmasa_dec_fx.c} (100%) rename lib_dec/{ivas_mct_core_dec.c => ivas_mct_core_dec_fx.c} (100%) rename lib_dec/{ivas_mct_dec.c => ivas_mct_dec_fx.c} (100%) rename lib_dec/{ivas_mct_dec_mct_fx.c => ivas_mct_dec_mct_fx_fx.c} (100%) rename lib_dec/{ivas_mdct_core_dec.c => ivas_mdct_core_dec_fx.c} (100%) rename lib_dec/{ivas_mono_dmx_renderer.c => ivas_mono_dmx_renderer_fx.c} (100%) rename lib_dec/{ivas_objectRenderer_internal.c => ivas_objectRenderer_internal_fx.c} (100%) rename lib_dec/{ivas_omasa_dec.c => ivas_omasa_dec_fx.c} (100%) rename lib_dec/{ivas_osba_dec.c => ivas_osba_dec_fx.c} (100%) rename lib_dec/{ivas_out_setup_conversion.c => ivas_out_setup_conversion_fx.c} (100%) rename lib_dec/{ivas_output_config.c => ivas_output_config_fx.c} (100%) rename lib_dec/{ivas_post_proc.c => ivas_post_proc_fx.c} (100%) rename lib_dec/{ivas_qmetadata_dec.c => ivas_qmetadata_dec_fx.c} (100%) rename lib_dec/{ivas_qspherical_dec.c => ivas_qspherical_dec_fx.c} (100%) rename lib_dec/{ivas_range_uni_dec.c => ivas_range_uni_dec_fx.c} (100%) rename lib_dec/{ivas_sba_dec.c => ivas_sba_dec_fx.c} (100%) rename lib_dec/{ivas_sba_rendering_internal.c => ivas_sba_rendering_internal_fx.c} (100%) rename lib_dec/{ivas_spar_decoder.c => ivas_spar_decoder_fx.c} (100%) rename lib_dec/{ivas_spar_md_dec.c => ivas_spar_md_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_adapt_GR_dec.c => ivas_stereo_adapt_GR_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_dft_dec_dmx.c => ivas_stereo_dft_dec_dmx_fx.c} (100%) rename lib_dec/{ivas_stereo_eclvq_dec.c => ivas_stereo_eclvq_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_esf_dec.c => ivas_stereo_esf_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_ica_dec.c => ivas_stereo_ica_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_icbwe_dec.c => ivas_stereo_icbwe_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_mdct_stereo_dec.c => ivas_stereo_mdct_stereo_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_switching_dec.c => ivas_stereo_switching_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_td_dec.c => ivas_stereo_td_dec_fx.c} (100%) rename lib_dec/{ivas_svd_dec.c => ivas_svd_dec_fx.c} (100%) rename lib_dec/{ivas_tcx_core_dec.c => ivas_tcx_core_dec_fx.c} (100%) rename lib_dec/{ivas_td_low_rate_dec.c => ivas_td_low_rate_dec_fx.c} (100%) rename lib_enc/{ivas_agc_enc.c => ivas_agc_enc_fx.c} (100%) rename lib_enc/{ivas_core_enc.c => ivas_core_enc_fx.c} (100%) rename lib_enc/{ivas_core_pre_proc_front.c => ivas_core_pre_proc_front_fx.c} (100%) rename lib_enc/{ivas_core_pre_proc.c => ivas_core_pre_proc_fx.c} (100%) rename lib_enc/{ivas_corecoder_enc_reconfig.c => ivas_corecoder_enc_reconfig_fx.c} (100%) rename lib_enc/{ivas_cpe_enc.c => ivas_cpe_enc_fx.c} (100%) rename lib_enc/{ivas_decision_matrix_enc.c => ivas_decision_matrix_enc_fx.c} (100%) rename lib_enc/{ivas_dirac_enc.c => ivas_dirac_enc_fx.c} (100%) rename lib_enc/{ivas_enc_cov_handler.c => ivas_enc_cov_handler_fx.c} (100%) rename lib_enc/{ivas_enc.c => ivas_enc_fx.c} (100%) rename lib_enc/{ivas_entropy_coder.c => ivas_entropy_coder_fx.c} (100%) rename lib_enc/{ivas_front_vad.c => ivas_front_vad_fx.c} (100%) rename lib_enc/{ivas_init_enc.c => ivas_init_enc_fx.c} (100%) rename lib_enc/{ivas_ism_dtx_enc.c => ivas_ism_dtx_enc_fx.c} (100%) rename lib_enc/{ivas_ism_enc.c => ivas_ism_enc_fx.c} (100%) rename lib_enc/{ivas_ism_metadata_enc.c => ivas_ism_metadata_enc_fx.c} (100%) rename lib_enc/{ivas_ism_param_enc.c => ivas_ism_param_enc_fx.c} (100%) rename lib_enc/{ivas_lfe_enc.c => ivas_lfe_enc_fx.c} (100%) rename lib_enc/{ivas_masa_enc.c => ivas_masa_enc_fx.c} (100%) rename lib_enc/{ivas_mc_param_enc.c => ivas_mc_param_enc_fx.c} (100%) rename lib_enc/{ivas_mc_paramupmix_enc.c => ivas_mc_paramupmix_enc_fx.c} (100%) rename lib_enc/{ivas_mcmasa_enc.c => ivas_mcmasa_enc_fx.c} (100%) rename lib_enc/{ivas_mct_core_enc.c => ivas_mct_core_enc_fx.c} (100%) rename lib_enc/{ivas_mct_enc.c => ivas_mct_enc_fx.c} (100%) rename lib_enc/{ivas_mct_enc_mct.c => ivas_mct_enc_mct_fx.c} (100%) rename lib_enc/{ivas_mdct_core_enc.c => ivas_mdct_core_enc_fx.c} (100%) rename lib_enc/{ivas_omasa_enc.c => ivas_omasa_enc_fx.c} (100%) rename lib_enc/{ivas_osba_enc.c => ivas_osba_enc_fx.c} (100%) rename lib_enc/{ivas_pca_enc.c => ivas_pca_enc_fx.c} (100%) rename lib_enc/{ivas_qmetadata_enc.c => ivas_qmetadata_enc_fx.c} (100%) rename lib_enc/{ivas_qspherical_enc.c => ivas_qspherical_enc_fx.c} (100%) rename lib_enc/{ivas_range_uni_enc.c => ivas_range_uni_enc_fx.c} (100%) rename lib_enc/{ivas_sba_enc.c => ivas_sba_enc_fx.c} (100%) rename lib_enc/{ivas_sce_enc.c => ivas_sce_enc_fx.c} (100%) rename lib_enc/{ivas_sns_enc.c => ivas_sns_enc_fx.c} (100%) rename lib_enc/{ivas_spar_encoder.c => ivas_spar_encoder_fx.c} (100%) rename lib_enc/{ivas_spar_md_enc.c => ivas_spar_md_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_adapt_GR_enc.c => ivas_stereo_adapt_GR_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_classifier.c => ivas_stereo_classifier_fx.c} (100%) rename lib_enc/{ivas_stereo_cng_enc.c => ivas_stereo_cng_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_dft_enc.c => ivas_stereo_dft_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_dft_enc_itd.c => ivas_stereo_dft_enc_itd_fx.c} (100%) rename lib_enc/{ivas_stereo_dft_td_itd.c => ivas_stereo_dft_td_itd_fx.c} (100%) rename lib_enc/{ivas_stereo_dmx_evs.c => ivas_stereo_dmx_evs_fx.c} (100%) rename lib_enc/{ivas_stereo_eclvq_enc.c => ivas_stereo_eclvq_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_ica_enc.c => ivas_stereo_ica_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_icbwe_enc.c => ivas_stereo_icbwe_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_mdct_core_enc.c => ivas_stereo_mdct_core_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_mdct_igf_enc.c => ivas_stereo_mdct_igf_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_mdct_stereo_enc.c => ivas_stereo_mdct_stereo_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_switching_enc.c => ivas_stereo_switching_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_td_analysis.c => ivas_stereo_td_analysis_fx.c} (100%) rename lib_enc/{ivas_stereo_td_enc.c => ivas_stereo_td_enc_fx.c} (100%) rename lib_enc/{ivas_tcx_core_enc.c => ivas_tcx_core_enc_fx.c} (100%) rename lib_enc/{ivas_td_low_rate_enc.c => ivas_td_low_rate_enc_fx.c} (100%) rename lib_rend/{ivas_allrad_dec.c => ivas_allrad_dec_fx.c} (100%) rename lib_rend/{ivas_crend.c => ivas_crend_fx.c} (100%) rename lib_rend/{ivas_dirac_ana.c => ivas_dirac_ana_fx.c} (100%) rename lib_rend/{ivas_dirac_dec_binaural_functions.c => ivas_dirac_dec_binaural_functions_fx.c} (100%) rename lib_rend/{ivas_dirac_decorr_dec.c => ivas_dirac_decorr_dec_fx.c} (100%) rename lib_rend/{ivas_dirac_onsets_dec.c => ivas_dirac_onsets_dec_fx.c} (100%) rename lib_rend/{ivas_dirac_output_synthesis_dec.c => ivas_dirac_output_synthesis_dec_fx.c} (100%) rename lib_rend/{ivas_dirac_rend.c => ivas_dirac_rend_fx.c} (100%) rename lib_rend/{ivas_efap.c => ivas_efap_fx.c} (100%) rename lib_rend/{ivas_hrtf.c => ivas_hrtf_fx.c} (100%) rename lib_rend/{ivas_limiter.c => ivas_limiter_fx.c} (100%) rename lib_rend/{ivas_masa_merge.c => ivas_masa_merge_fx.c} (100%) rename lib_rend/{ivas_mcmasa_ana.c => ivas_mcmasa_ana_fx.c} (100%) rename lib_rend/{ivas_objectRenderer.c => ivas_objectRenderer_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_hrFilt.c => ivas_objectRenderer_hrFilt_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_mix.c => ivas_objectRenderer_mix_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_sfx.c => ivas_objectRenderer_sfx_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_sources.c => ivas_objectRenderer_sources_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_vec.c => ivas_objectRenderer_vec_fx.c} (100%) rename lib_rend/{ivas_omasa_ana.c => ivas_omasa_ana_fx.c} (100%) rename lib_rend/{ivas_orient_trk.c => ivas_orient_trk_fx.c} (100%) rename lib_rend/{ivas_reflections.c => ivas_reflections_fx.c} (100%) rename lib_rend/{ivas_render_config.c => ivas_render_config_fx.c} (100%) rename lib_rend/{ivas_reverb_delay_line.c => ivas_reverb_delay_line_fx.c} (100%) rename lib_rend/{ivas_reverb_fft_filter.c => ivas_reverb_fft_filter_fx.c} (100%) rename lib_rend/{ivas_reverb_filter_design.c => ivas_reverb_filter_design_fx.c} (100%) rename lib_rend/{ivas_reverb.c => ivas_reverb_fx.c} (100%) rename lib_rend/{ivas_reverb_iir_filter.c => ivas_reverb_iir_filter_fx.c} (100%) rename lib_rend/{ivas_reverb_utils.c => ivas_reverb_utils_fx.c} (100%) rename lib_rend/{ivas_rom_TdBinauralRenderer.c => ivas_rom_TdBinauralRenderer_fx.c} (100%) rename lib_rend/{ivas_rom_binauralRenderer.c => ivas_rom_binauralRenderer_fx.c} (100%) rename lib_rend/{ivas_rom_binaural_crend_head.c => ivas_rom_binaural_crend_head_fx.c} (100%) rename lib_rend/{ivas_rom_rend.c => ivas_rom_rend_fx.c} (100%) rename lib_rend/{ivas_rotation.c => ivas_rotation_fx.c} (100%) rename lib_rend/{ivas_sba_rendering.c => ivas_sba_rendering_fx.c} (100%) rename lib_rend/{ivas_shoebox.c => ivas_shoebox_fx.c} (100%) rename lib_rend/{ivas_td_decorr.c => ivas_td_decorr_fx.c} (100%) rename lib_rend/{ivas_vbap.c => ivas_vbap_fx.c} (100%) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index c88725ef0..8c42f19ca 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -200,42 +200,42 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - + + + + + - + - - - + + + - - - - - - + + + + + + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index c58edbff6..8f2be8853 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -1,81 +1,6 @@ - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - common_all_c @@ -469,18 +394,6 @@ common_ivas_c - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - common_ivas_c @@ -493,9 +406,6 @@ common_ivas_c - - common_ivas_c - common_all_c @@ -544,6 +454,96 @@ common_all_c + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index b3a847791..2d06d29aa 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -210,69 +210,69 @@ - - - + + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + - + - + - - - + + + - + - - - - + + + + - - - - - - + + + + + + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index c4e148b89..8a4fc4605 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -71,195 +71,51 @@ decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_all_c @@ -518,6 +374,150 @@ decoder_all_c + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 86e56d42a..86dcef905 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -215,64 +215,64 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -319,7 +319,7 @@ - + diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index 406c01b86..899097163 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -107,174 +107,9 @@ encoder_evs_c - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - encoder_ivas_c - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - encoder_all_c @@ -602,6 +437,171 @@ encoder_all_c + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index fa11b23be..1ffab139a 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -136,46 +136,46 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 01f3dfb74..47b4fee01 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -2,124 +2,124 @@ - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c @@ -143,9 +143,6 @@ rend_h - - rend_h - diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith_fx.c similarity index 100% rename from lib_com/ivas_arith.c rename to lib_com/ivas_arith_fx.c diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com_fx.c similarity index 100% rename from lib_com/ivas_avq_pos_reorder_com.c rename to lib_com/ivas_avq_pos_reorder_com_fx.c diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth_fx.c similarity index 100% rename from lib_com/ivas_cov_smooth.c rename to lib_com/ivas_cov_smooth_fx.c diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com_fx.c similarity index 100% rename from lib_com/ivas_dirac_com.c rename to lib_com/ivas_dirac_com_fx.c diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common_fx.c similarity index 100% rename from lib_com/ivas_entropy_coder_common.c rename to lib_com/ivas_entropy_coder_common_fx.c diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer_fx.c similarity index 100% rename from lib_com/ivas_fb_mixer.c rename to lib_com/ivas_fb_mixer_fx.c diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters_fx.c similarity index 100% rename from lib_com/ivas_filters.c rename to lib_com/ivas_filters_fx.c diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com_fx.c similarity index 100% rename from lib_com/ivas_ism_com.c rename to lib_com/ivas_ism_com_fx.c diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com_fx.c similarity index 100% rename from lib_com/ivas_lfe_com.c rename to lib_com/ivas_lfe_com_fx.c diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com_fx.c similarity index 100% rename from lib_com/ivas_masa_com.c rename to lib_com/ivas_masa_com_fx.c diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com_fx.c similarity index 100% rename from lib_com/ivas_mc_com.c rename to lib_com/ivas_mc_com_fx.c diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com_fx.c similarity index 100% rename from lib_com/ivas_mc_param_com.c rename to lib_com/ivas_mc_param_com_fx.c diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com-fx.c similarity index 100% rename from lib_com/ivas_mcmasa_com.c rename to lib_com/ivas_mcmasa_com-fx.c diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com_fx.c similarity index 100% rename from lib_com/ivas_mct_com.c rename to lib_com/ivas_mct_com_fx.c diff --git a/lib_com/ivas_mdct_core_com.c b/lib_com/ivas_mdct_core_com_fx.c similarity index 100% rename from lib_com/ivas_mdct_core_com.c rename to lib_com/ivas_mdct_core_com_fx.c diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft_fx.c similarity index 100% rename from lib_com/ivas_mdft_imdft.c rename to lib_com/ivas_mdft_imdft_fx.c diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com_fx.c similarity index 100% rename from lib_com/ivas_omasa_com.c rename to lib_com/ivas_omasa_com_fx.c diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools_fx.c similarity index 100% rename from lib_com/ivas_pca_tools.c rename to lib_com/ivas_pca_tools_fx.c diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com_fx.c similarity index 100% rename from lib_com/ivas_qmetadata_com.c rename to lib_com/ivas_qmetadata_com_fx.c diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com_fx.c similarity index 100% rename from lib_com/ivas_qspherical_com.c rename to lib_com/ivas_qspherical_com_fx.c diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config_fx.c similarity index 100% rename from lib_com/ivas_sba_config.c rename to lib_com/ivas_sba_config_fx.c diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com_fx.c similarity index 100% rename from lib_com/ivas_spar_com.c rename to lib_com/ivas_spar_com_fx.c diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util_fx.c similarity index 100% rename from lib_com/ivas_spar_com_quant_util.c rename to lib_com/ivas_spar_com_quant_util_fx.c diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_dft_com.c rename to lib_com/ivas_stereo_dft_com_fx.c diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_mdct_bands_com.c rename to lib_com/ivas_stereo_mdct_bands_com_fx.c diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_mdct_stereo_com.c rename to lib_com/ivas_stereo_mdct_stereo_com_fx.c diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_psychlpc_com.c rename to lib_com/ivas_stereo_psychlpc_com_fx.c diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c similarity index 100% rename from lib_com/ivas_stereo_td_bit_alloc.c rename to lib_com/ivas_stereo_td_bit_alloc_fx.c diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools_fx.c similarity index 100% rename from lib_com/ivas_tools.c rename to lib_com/ivas_tools_fx.c diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det_fx.c similarity index 100% rename from lib_com/ivas_transient_det.c rename to lib_com/ivas_transient_det_fx.c diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal_fx.c similarity index 100% rename from lib_dec/ivas_binRenderer_internal.c rename to lib_dec/ivas_binRenderer_internal_fx.c diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_core_dec.c rename to lib_dec/ivas_core_dec_fx.c diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c similarity index 100% rename from lib_dec/ivas_corecoder_dec_reconfig.c rename to lib_dec/ivas_corecoder_dec_reconfig_fx.c diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec_fx.c similarity index 100% rename from lib_dec/ivas_decision_matrix_dec.c rename to lib_dec/ivas_decision_matrix_dec_fx.c diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec_fx.c similarity index 100% rename from lib_dec/ivas_dirac_dec.c rename to lib_dec/ivas_dirac_dec_fx.c diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c similarity index 100% rename from lib_dec/ivas_dirac_output_synthesis_cov.c rename to lib_dec/ivas_dirac_output_synthesis_cov_fx.c diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder_fx.c similarity index 100% rename from lib_dec/ivas_entropy_decoder.c rename to lib_dec/ivas_entropy_decoder_fx.c diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_dec.c rename to lib_dec/ivas_ism_dec_fx.c diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_dtx_dec.c rename to lib_dec/ivas_ism_dtx_dec_fx.c diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_metadata_dec.c rename to lib_dec/ivas_ism_metadata_dec_fx.c diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_param_dec.c rename to lib_dec/ivas_ism_param_dec_fx.c diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer_fx.c similarity index 100% rename from lib_dec/ivas_ism_renderer.c rename to lib_dec/ivas_ism_renderer_fx.c diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec_fx.c similarity index 100% rename from lib_dec/ivas_jbm_dec.c rename to lib_dec/ivas_jbm_dec_fx.c diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec_fx.c similarity index 100% rename from lib_dec/ivas_ls_custom_dec.c rename to lib_dec/ivas_ls_custom_dec_fx.c diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec_fx.c similarity index 100% rename from lib_dec/ivas_masa_dec.c rename to lib_dec/ivas_masa_dec_fx.c diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec_fx.c similarity index 100% rename from lib_dec/ivas_mc_param_dec.c rename to lib_dec/ivas_mc_param_dec_fx.c diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c similarity index 100% rename from lib_dec/ivas_mc_paramupmix_dec.c rename to lib_dec/ivas_mc_paramupmix_dec_fx.c diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec_fx.c similarity index 100% rename from lib_dec/ivas_mcmasa_dec.c rename to lib_dec/ivas_mcmasa_dec_fx.c diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_mct_core_dec.c rename to lib_dec/ivas_mct_core_dec_fx.c diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec_fx.c similarity index 100% rename from lib_dec/ivas_mct_dec.c rename to lib_dec/ivas_mct_dec_fx.c diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c similarity index 100% rename from lib_dec/ivas_mct_dec_mct_fx.c rename to lib_dec/ivas_mct_dec_mct_fx_fx.c diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_mdct_core_dec.c rename to lib_dec/ivas_mdct_core_dec_fx.c diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer_fx.c similarity index 100% rename from lib_dec/ivas_mono_dmx_renderer.c rename to lib_dec/ivas_mono_dmx_renderer_fx.c diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal_fx.c similarity index 100% rename from lib_dec/ivas_objectRenderer_internal.c rename to lib_dec/ivas_objectRenderer_internal_fx.c diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec_fx.c similarity index 100% rename from lib_dec/ivas_omasa_dec.c rename to lib_dec/ivas_omasa_dec_fx.c diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec_fx.c similarity index 100% rename from lib_dec/ivas_osba_dec.c rename to lib_dec/ivas_osba_dec_fx.c diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion_fx.c similarity index 100% rename from lib_dec/ivas_out_setup_conversion.c rename to lib_dec/ivas_out_setup_conversion_fx.c diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config_fx.c similarity index 100% rename from lib_dec/ivas_output_config.c rename to lib_dec/ivas_output_config_fx.c diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc_fx.c similarity index 100% rename from lib_dec/ivas_post_proc.c rename to lib_dec/ivas_post_proc_fx.c diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec_fx.c similarity index 100% rename from lib_dec/ivas_qmetadata_dec.c rename to lib_dec/ivas_qmetadata_dec_fx.c diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec_fx.c similarity index 100% rename from lib_dec/ivas_qspherical_dec.c rename to lib_dec/ivas_qspherical_dec_fx.c diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec_fx.c similarity index 100% rename from lib_dec/ivas_range_uni_dec.c rename to lib_dec/ivas_range_uni_dec_fx.c diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec_fx.c similarity index 100% rename from lib_dec/ivas_sba_dec.c rename to lib_dec/ivas_sba_dec_fx.c diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal_fx.c similarity index 100% rename from lib_dec/ivas_sba_rendering_internal.c rename to lib_dec/ivas_sba_rendering_internal_fx.c diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder_fx.c similarity index 100% rename from lib_dec/ivas_spar_decoder.c rename to lib_dec/ivas_spar_decoder_fx.c diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec_fx.c similarity index 100% rename from lib_dec/ivas_spar_md_dec.c rename to lib_dec/ivas_spar_md_dec_fx.c diff --git a/lib_dec/ivas_stereo_adapt_GR_dec.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_adapt_GR_dec.c rename to lib_dec/ivas_stereo_adapt_GR_dec_fx.c diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c similarity index 100% rename from lib_dec/ivas_stereo_dft_dec_dmx.c rename to lib_dec/ivas_stereo_dft_dec_dmx_fx.c diff --git a/lib_dec/ivas_stereo_eclvq_dec.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_eclvq_dec.c rename to lib_dec/ivas_stereo_eclvq_dec_fx.c diff --git a/lib_dec/ivas_stereo_esf_dec.c b/lib_dec/ivas_stereo_esf_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_esf_dec.c rename to lib_dec/ivas_stereo_esf_dec_fx.c diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_ica_dec.c rename to lib_dec/ivas_stereo_ica_dec_fx.c diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_icbwe_dec.c rename to lib_dec/ivas_stereo_icbwe_dec_fx.c diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_mdct_stereo_dec.c rename to lib_dec/ivas_stereo_mdct_stereo_dec_fx.c diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_switching_dec.c rename to lib_dec/ivas_stereo_switching_dec_fx.c diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_td_dec.c rename to lib_dec/ivas_stereo_td_dec_fx.c diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec_fx.c similarity index 100% rename from lib_dec/ivas_svd_dec.c rename to lib_dec/ivas_svd_dec_fx.c diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_tcx_core_dec.c rename to lib_dec/ivas_tcx_core_dec_fx.c diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec_fx.c similarity index 100% rename from lib_dec/ivas_td_low_rate_dec.c rename to lib_dec/ivas_td_low_rate_dec_fx.c diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc_fx.c similarity index 100% rename from lib_enc/ivas_agc_enc.c rename to lib_enc/ivas_agc_enc_fx.c diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_core_enc.c rename to lib_enc/ivas_core_enc_fx.c diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front_fx.c similarity index 100% rename from lib_enc/ivas_core_pre_proc_front.c rename to lib_enc/ivas_core_pre_proc_front_fx.c diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc_fx.c similarity index 100% rename from lib_enc/ivas_core_pre_proc.c rename to lib_enc/ivas_core_pre_proc_fx.c diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c similarity index 100% rename from lib_enc/ivas_corecoder_enc_reconfig.c rename to lib_enc/ivas_corecoder_enc_reconfig_fx.c diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc_fx.c similarity index 100% rename from lib_enc/ivas_cpe_enc.c rename to lib_enc/ivas_cpe_enc_fx.c diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc_fx.c similarity index 100% rename from lib_enc/ivas_decision_matrix_enc.c rename to lib_enc/ivas_decision_matrix_enc_fx.c diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc_fx.c similarity index 100% rename from lib_enc/ivas_dirac_enc.c rename to lib_enc/ivas_dirac_enc_fx.c diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler_fx.c similarity index 100% rename from lib_enc/ivas_enc_cov_handler.c rename to lib_enc/ivas_enc_cov_handler_fx.c diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc_fx.c similarity index 100% rename from lib_enc/ivas_enc.c rename to lib_enc/ivas_enc_fx.c diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder_fx.c similarity index 100% rename from lib_enc/ivas_entropy_coder.c rename to lib_enc/ivas_entropy_coder_fx.c diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad_fx.c similarity index 100% rename from lib_enc/ivas_front_vad.c rename to lib_enc/ivas_front_vad_fx.c diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc_fx.c similarity index 100% rename from lib_enc/ivas_init_enc.c rename to lib_enc/ivas_init_enc_fx.c diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_dtx_enc.c rename to lib_enc/ivas_ism_dtx_enc_fx.c diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_enc.c rename to lib_enc/ivas_ism_enc_fx.c diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_metadata_enc.c rename to lib_enc/ivas_ism_metadata_enc_fx.c diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_param_enc.c rename to lib_enc/ivas_ism_param_enc_fx.c diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc_fx.c similarity index 100% rename from lib_enc/ivas_lfe_enc.c rename to lib_enc/ivas_lfe_enc_fx.c diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc_fx.c similarity index 100% rename from lib_enc/ivas_masa_enc.c rename to lib_enc/ivas_masa_enc_fx.c diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc_fx.c similarity index 100% rename from lib_enc/ivas_mc_param_enc.c rename to lib_enc/ivas_mc_param_enc_fx.c diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c similarity index 100% rename from lib_enc/ivas_mc_paramupmix_enc.c rename to lib_enc/ivas_mc_paramupmix_enc_fx.c diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc_fx.c similarity index 100% rename from lib_enc/ivas_mcmasa_enc.c rename to lib_enc/ivas_mcmasa_enc_fx.c diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_mct_core_enc.c rename to lib_enc/ivas_mct_core_enc_fx.c diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc_fx.c similarity index 100% rename from lib_enc/ivas_mct_enc.c rename to lib_enc/ivas_mct_enc_fx.c diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct_fx.c similarity index 100% rename from lib_enc/ivas_mct_enc_mct.c rename to lib_enc/ivas_mct_enc_mct_fx.c diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_mdct_core_enc.c rename to lib_enc/ivas_mdct_core_enc_fx.c diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc_fx.c similarity index 100% rename from lib_enc/ivas_omasa_enc.c rename to lib_enc/ivas_omasa_enc_fx.c diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc_fx.c similarity index 100% rename from lib_enc/ivas_osba_enc.c rename to lib_enc/ivas_osba_enc_fx.c diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc_fx.c similarity index 100% rename from lib_enc/ivas_pca_enc.c rename to lib_enc/ivas_pca_enc_fx.c diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc_fx.c similarity index 100% rename from lib_enc/ivas_qmetadata_enc.c rename to lib_enc/ivas_qmetadata_enc_fx.c diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc_fx.c similarity index 100% rename from lib_enc/ivas_qspherical_enc.c rename to lib_enc/ivas_qspherical_enc_fx.c diff --git a/lib_enc/ivas_range_uni_enc.c b/lib_enc/ivas_range_uni_enc_fx.c similarity index 100% rename from lib_enc/ivas_range_uni_enc.c rename to lib_enc/ivas_range_uni_enc_fx.c diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc_fx.c similarity index 100% rename from lib_enc/ivas_sba_enc.c rename to lib_enc/ivas_sba_enc_fx.c diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc_fx.c similarity index 100% rename from lib_enc/ivas_sce_enc.c rename to lib_enc/ivas_sce_enc_fx.c diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc_fx.c similarity index 100% rename from lib_enc/ivas_sns_enc.c rename to lib_enc/ivas_sns_enc_fx.c diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder_fx.c similarity index 100% rename from lib_enc/ivas_spar_encoder.c rename to lib_enc/ivas_spar_encoder_fx.c diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc_fx.c similarity index 100% rename from lib_enc/ivas_spar_md_enc.c rename to lib_enc/ivas_spar_md_enc_fx.c diff --git a/lib_enc/ivas_stereo_adapt_GR_enc.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_adapt_GR_enc.c rename to lib_enc/ivas_stereo_adapt_GR_enc_fx.c diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier_fx.c similarity index 100% rename from lib_enc/ivas_stereo_classifier.c rename to lib_enc/ivas_stereo_classifier_fx.c diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_cng_enc.c rename to lib_enc/ivas_stereo_cng_enc_fx.c diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dft_enc.c rename to lib_enc/ivas_stereo_dft_enc_fx.c diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dft_enc_itd.c rename to lib_enc/ivas_stereo_dft_enc_itd_fx.c diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dft_td_itd.c rename to lib_enc/ivas_stereo_dft_td_itd_fx.c diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dmx_evs.c rename to lib_enc/ivas_stereo_dmx_evs_fx.c diff --git a/lib_enc/ivas_stereo_eclvq_enc.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_eclvq_enc.c rename to lib_enc/ivas_stereo_eclvq_enc_fx.c diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_ica_enc.c rename to lib_enc/ivas_stereo_ica_enc_fx.c diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_icbwe_enc.c rename to lib_enc/ivas_stereo_icbwe_enc_fx.c diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_mdct_core_enc.c rename to lib_enc/ivas_stereo_mdct_core_enc_fx.c diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_mdct_igf_enc.c rename to lib_enc/ivas_stereo_mdct_igf_enc_fx.c diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_mdct_stereo_enc.c rename to lib_enc/ivas_stereo_mdct_stereo_enc_fx.c diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_switching_enc.c rename to lib_enc/ivas_stereo_switching_enc_fx.c diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis_fx.c similarity index 100% rename from lib_enc/ivas_stereo_td_analysis.c rename to lib_enc/ivas_stereo_td_analysis_fx.c diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_td_enc.c rename to lib_enc/ivas_stereo_td_enc_fx.c diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_tcx_core_enc.c rename to lib_enc/ivas_tcx_core_enc_fx.c diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc_fx.c similarity index 100% rename from lib_enc/ivas_td_low_rate_enc.c rename to lib_enc/ivas_td_low_rate_enc_fx.c diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec_fx.c similarity index 100% rename from lib_rend/ivas_allrad_dec.c rename to lib_rend/ivas_allrad_dec_fx.c diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend_fx.c similarity index 100% rename from lib_rend/ivas_crend.c rename to lib_rend/ivas_crend_fx.c diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana_fx.c similarity index 100% rename from lib_rend/ivas_dirac_ana.c rename to lib_rend/ivas_dirac_ana_fx.c diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c similarity index 100% rename from lib_rend/ivas_dirac_dec_binaural_functions.c rename to lib_rend/ivas_dirac_dec_binaural_functions_fx.c diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec_fx.c similarity index 100% rename from lib_rend/ivas_dirac_decorr_dec.c rename to lib_rend/ivas_dirac_decorr_dec_fx.c diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec_fx.c similarity index 100% rename from lib_rend/ivas_dirac_onsets_dec.c rename to lib_rend/ivas_dirac_onsets_dec_fx.c diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c similarity index 100% rename from lib_rend/ivas_dirac_output_synthesis_dec.c rename to lib_rend/ivas_dirac_output_synthesis_dec_fx.c diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend_fx.c similarity index 100% rename from lib_rend/ivas_dirac_rend.c rename to lib_rend/ivas_dirac_rend_fx.c diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap_fx.c similarity index 100% rename from lib_rend/ivas_efap.c rename to lib_rend/ivas_efap_fx.c diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf_fx.c similarity index 100% rename from lib_rend/ivas_hrtf.c rename to lib_rend/ivas_hrtf_fx.c diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter_fx.c similarity index 100% rename from lib_rend/ivas_limiter.c rename to lib_rend/ivas_limiter_fx.c diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge_fx.c similarity index 100% rename from lib_rend/ivas_masa_merge.c rename to lib_rend/ivas_masa_merge_fx.c diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana_fx.c similarity index 100% rename from lib_rend/ivas_mcmasa_ana.c rename to lib_rend/ivas_mcmasa_ana_fx.c diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer.c rename to lib_rend/ivas_objectRenderer_fx.c diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_hrFilt.c rename to lib_rend/ivas_objectRenderer_hrFilt_fx.c diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_mix.c rename to lib_rend/ivas_objectRenderer_mix_fx.c diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_sfx.c rename to lib_rend/ivas_objectRenderer_sfx_fx.c diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_sources.c rename to lib_rend/ivas_objectRenderer_sources_fx.c diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_vec.c rename to lib_rend/ivas_objectRenderer_vec_fx.c diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana_fx.c similarity index 100% rename from lib_rend/ivas_omasa_ana.c rename to lib_rend/ivas_omasa_ana_fx.c diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk_fx.c similarity index 100% rename from lib_rend/ivas_orient_trk.c rename to lib_rend/ivas_orient_trk_fx.c diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections_fx.c similarity index 100% rename from lib_rend/ivas_reflections.c rename to lib_rend/ivas_reflections_fx.c diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config_fx.c similarity index 100% rename from lib_rend/ivas_render_config.c rename to lib_rend/ivas_render_config_fx.c diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line_fx.c similarity index 100% rename from lib_rend/ivas_reverb_delay_line.c rename to lib_rend/ivas_reverb_delay_line_fx.c diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter_fx.c similarity index 100% rename from lib_rend/ivas_reverb_fft_filter.c rename to lib_rend/ivas_reverb_fft_filter_fx.c diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design_fx.c similarity index 100% rename from lib_rend/ivas_reverb_filter_design.c rename to lib_rend/ivas_reverb_filter_design_fx.c diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb_fx.c similarity index 100% rename from lib_rend/ivas_reverb.c rename to lib_rend/ivas_reverb_fx.c diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter_fx.c similarity index 100% rename from lib_rend/ivas_reverb_iir_filter.c rename to lib_rend/ivas_reverb_iir_filter_fx.c diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils_fx.c similarity index 100% rename from lib_rend/ivas_reverb_utils.c rename to lib_rend/ivas_reverb_utils_fx.c diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c similarity index 100% rename from lib_rend/ivas_rom_TdBinauralRenderer.c rename to lib_rend/ivas_rom_TdBinauralRenderer_fx.c diff --git a/lib_rend/ivas_rom_binauralRenderer.c b/lib_rend/ivas_rom_binauralRenderer_fx.c similarity index 100% rename from lib_rend/ivas_rom_binauralRenderer.c rename to lib_rend/ivas_rom_binauralRenderer_fx.c diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c similarity index 100% rename from lib_rend/ivas_rom_binaural_crend_head.c rename to lib_rend/ivas_rom_binaural_crend_head_fx.c diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend_fx.c similarity index 100% rename from lib_rend/ivas_rom_rend.c rename to lib_rend/ivas_rom_rend_fx.c diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation_fx.c similarity index 100% rename from lib_rend/ivas_rotation.c rename to lib_rend/ivas_rotation_fx.c diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering_fx.c similarity index 100% rename from lib_rend/ivas_sba_rendering.c rename to lib_rend/ivas_sba_rendering_fx.c diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox_fx.c similarity index 100% rename from lib_rend/ivas_shoebox.c rename to lib_rend/ivas_shoebox_fx.c diff --git a/lib_rend/ivas_td_decorr.c b/lib_rend/ivas_td_decorr_fx.c similarity index 100% rename from lib_rend/ivas_td_decorr.c rename to lib_rend/ivas_td_decorr_fx.c diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap_fx.c similarity index 100% rename from lib_rend/ivas_vbap.c rename to lib_rend/ivas_vbap_fx.c -- GitLab From f3a52497e1298d393cf5d34fb298caf9534183a2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 11:51:18 +0530 Subject: [PATCH 247/329] Fix for 3GPP issue 1313: Multi-frame attenuation for MDCT-stereo 48kbps with input +10dB Link #1313 --- lib_enc/ivas_mc_param_enc_fx.c | 10 +++--- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 8 ++--- lib_enc/stat_enc.h | 4 +-- lib_enc/transient_detection_fx.c | 48 ++++++++++---------------- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 859ce3a9b..36324ae0f 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -1639,8 +1639,8 @@ static void ivas_param_mc_transient_detection_fx( push_wmops( "param_mc_trn_det" ); attackRatioThreshold_fx = hTranDet->transientDetector.attackRatioThreshold; - pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; // Q0 - pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; // Q0 + pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; // Q(-1) + pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; // Q(-1) bIsAttackPresent = FALSE; move16(); @@ -1651,8 +1651,8 @@ static void ivas_param_mc_transient_detection_fx( * if we had an attack very late in the last frame, * make the current frame also a transient one... */ test(); - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-1], 31, Mpy_32_16_1( pAccSubblockNrg_fx[-1], attackRatioThreshold_fx ), ( 31 + ATTACKTHRESHOLD_E ) ), 1 ) || - EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-2], 31, Mpy_32_16_1( pAccSubblockNrg_fx[-2], attackRatioThreshold_fx ), ( 31 + ATTACKTHRESHOLD_E ) ), 1 ) ) + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-1], 32, Mpy_32_16_1( pAccSubblockNrg_fx[-1], attackRatioThreshold_fx ), ( 32 + ATTACKTHRESHOLD_E ) ), 1 ) || + EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-2], 32, Mpy_32_16_1( pAccSubblockNrg_fx[-2], attackRatioThreshold_fx ), ( 32 + ATTACKTHRESHOLD_E ) ), 1 ) ) { bIsAttackPresent = TRUE; move16(); @@ -1661,7 +1661,7 @@ static void ivas_param_mc_transient_detection_fx( } FOR( i = 0; i < NSUBBLOCKS; i++ ){ - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[i], 31, Mpy_32_16_1( pAccSubblockNrg_fx[i], attackRatioThreshold_fx ), ( 31 + ATTACKTHRESHOLD_E ) ), 1 ) ){ + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[i], 32, Mpy_32_16_1( pAccSubblockNrg_fx[i], attackRatioThreshold_fx ), ( 32 + ATTACKTHRESHOLD_E ) ), 1 ) ){ bIsAttackPresent = TRUE; move16(); attackIndex = i; diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index b43c8dfdb..2a87ea4f9 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -53,13 +53,13 @@ static void sync_tcx_mode_fx( Encoder_State **st /* i/o: Encoder state */ ) { - const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; /* Q0 */ + const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; /* Q(-1) */ move32(); - const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; /* Q0 */ + const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; /* Q(-1) */ move32(); - const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[( st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */ + const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[( st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q(-1) */ move32(); - const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[( st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */ + const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[( st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q(-1) */ move32(); test(); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 5067cb410..6292c4b33 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -138,8 +138,8 @@ typedef struct typedef struct { DelayBuffer *pDelayBuffer; /* Delay buffer. */ - Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; // IVAS Q0 - Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; // IVAS Q0 + Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; // IVAS Q(-1) + Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; // IVAS Q(-1) Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* EVS: Q7(15 - SUBBLOCK_NRG_CHANGE_E) */ /* IVAS: Q3 */ int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index d9859a1a1..82d24ceba 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -726,7 +726,7 @@ void RunTransientDetection_ivas_fx( e0_fx = dotp_fx( filteredInput_fx + /* length / 2 */ shr( length, 1 ), filteredInput_fx + /* length / 2 */ shr( length, 1 ), shr( pSubblockEnergies->pDelayBuffer->nSubblockSize, 1 ) /* pSubblockEnergies->pDelayBuffer->nSubblockSize / 2 */, &exp ); exp = sub( exp, 2 * 0 - 1 ); // Q = 2*0 + (30-exp), E = 31 - (2*0 + 30 - exp) = 1 + exp - 2*0 = exp - (2*0-1) e0_fx = BASOP_Util_Add_Mant32Exp( MIN_BLOCK_ENERGY_IVAS_FX_Q7 / 2, 31 - Q7, e0_fx, exp, &exp ); - e1_fx = BASOP_Util_Add_Mant32Exp( pSubblockEnergies->subblockNrg[pSubblockEnergies->nDelay + 4], 31 - 0, L_negate( e0_fx ), exp, &exp1 ); + e1_fx = BASOP_Util_Add_Mant32Exp( pSubblockEnergies->subblockNrg[pSubblockEnergies->nDelay + 4], 32, L_negate( e0_fx ), exp, &exp1 ); IF( BASOP_Util_Cmp_Mant32Exp( e1_fx, exp1, e0_fx, exp ) > 0 ) { pSubblockEnergies->ramp_up_flag = (UWord16) L_or( pSubblockEnergies->ramp_up_flag, 0x0001 ); @@ -1122,8 +1122,8 @@ static void InitSubblockEnergies_ivas_fx( Word16 nFrameLength, Word16 nDelay, De assert( ( pDelayBuffer != NULL ) && ( pSubblockEnergies != NULL ) && ( pDelayBuffer->nSubblockSize * NSUBBLOCKS == nFrameLength ) && ( pDelayBuffer->nSubblockSize > 0 ) ); - set32_fx( pSubblockEnergies->subblockNrg, 107 /* 107.37 in Q0 */, nMaxBuffSize ); - set32_fx( pSubblockEnergies->accSubblockNrg, 107 /* 107.37 in Q0 */, nMaxBuffSize + 1 ); + set32_fx( pSubblockEnergies->subblockNrg, 54 /* 107.37 in Q(-1) */, nMaxBuffSize ); + set32_fx( pSubblockEnergies->accSubblockNrg, 54 /* 107.37 in Q(-1) */, nMaxBuffSize + 1 ); set16_fx( pSubblockEnergies->subblockNrgChange, ONE_IN_Q3, nMaxBuffSize ); IF( nDelay != 0 ) { @@ -1495,9 +1495,9 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp Word16 *pSubblockNrgChange; Word32 *pAccSubblockTmp; Word16 nWindows; - Word16 w, k, k2, tmp; + Word16 w, k, k2; Word32 w0, w1; - Word32 accu; + Word64 accu; move16(); pDelayBuffer = pSubblockEnergies->pDelayBuffer; @@ -1522,45 +1522,35 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp IF( nWindows > 0 ) { /* Process left over samples from the previous frame. */ - accu = 107; // 107.37f in Q0 - move32(); - assert( ( SUBBLOCK_NRG_E & 1 ) == 0 ); + accu = 215; // 107.37f in Q1 + move64(); FOR( k = 0; k < nPartialDelay; k++ ) { - tmp = delayBuffer[k]; // Q0 - move16(); - accu = L_mac0( accu, tmp, tmp ); // Q0 + accu = W_mac_16_16( accu, delayBuffer[k], delayBuffer[k] ); // Q1 } /* Process new samples in the 0. subblock. */ - w = sub( nSubblockSize, nPartialDelay ); - assert( ( SUBBLOCK_NRG_E & 1 ) == 0 ); - FOR( k = 0; k < w; k++ ) + FOR( k = 0; k < ( nSubblockSize - nPartialDelay ); k++ ) { - tmp = input[k]; // Q0 - move16(); - accu = L_mac0_sat( accu, tmp, tmp ); // Q0 + accu = W_mac_16_16( accu, input[k], input[k] ); // Q1 } - pSubblockNrg[0] = accu; // Q0 + pSubblockNrg[0] = W_shl_sat_l( accu, -2 ); // Q(-1) move32(); /* Set accumulated subblock energy at this point. */ UpdatedAndStoreAccWindowNrg( pSubblockNrg[0], pAccSubblockTmp, facAccSubblockNrg, &pAccSubblockNrg[0] ); FOR( w = 1; w < nWindows; w++ ) { - accu = 107; // 107.37f in Q0 - move32(); + accu = 215; // 107.37f in Q1 + move64(); /* Process new samples in the w. subblock. */ k2 = add( k, nSubblockSize ); - assert( ( SUBBLOCK_NRG_E & 1 ) == 0 ); FOR( ; k < k2; k++ ) { - tmp = input[k]; // Q0 - move16(); - accu = L_mac0_sat( accu, tmp, tmp ); // Q0 + accu = W_mac_16_16( accu, input[k], input[k] ); // Q1 } - pSubblockNrg[w] = accu; // Q0 + pSubblockNrg[w] = W_shl_sat_l( accu, -2 ); // Q(-1) move32(); /* Set accumulated subblock energy at this point. */ UpdatedAndStoreAccWindowNrg( pSubblockNrg[w], pAccSubblockTmp, facAccSubblockNrg, &pAccSubblockNrg[w] ); @@ -1743,7 +1733,7 @@ Word16 transient_analysis_ivas_fx( /* Forward attack analysis */ FOR( i = -2; i < 7; i++ ) { - IF( BASOP_Util_Cmp_Mant32Exp( hTranDet->subblockEnergies.subblockNrg[nRelativeDelay + i], 31, Mpy_32_16_1( hTranDet->subblockEnergies.accSubblockNrg[nRelativeDelay + i], thr_fwd_fx ), ( 31 + 4 ) ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( hTranDet->subblockEnergies.subblockNrg[nRelativeDelay + i], 32, Mpy_32_16_1( hTranDet->subblockEnergies.accSubblockNrg[nRelativeDelay + i], thr_fwd_fx ), ( 32 + 4 ) ) > 0 ) { prel_force_td = s_or( prel_force_td, 0x0001 ); } @@ -1780,7 +1770,7 @@ Word16 transient_analysis_ivas_fx( /* -3 check */ test(); - IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[1 + offset], 31, Mpy_32_16_1( accSubblockNrgRev_fx[1], thr_rev_fx ), ( 31 + 4 ) ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[1 + offset], 32, Mpy_32_16_1( accSubblockNrgRev_fx[1], thr_rev_fx ), ( 32 + 4 ) ) > 0 ) { prel_force_td = s_or( prel_force_td, 0x0002 ); move16(); @@ -1788,10 +1778,10 @@ Word16 transient_analysis_ivas_fx( /* -4 check */ test(); - IF( prel_force_td == 0 && BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 31, Mpy_32_16_1( accSubblockNrgRev_fx[0], thr_rev_fx ), ( 31 + 4 ) ) > 0 ) + IF( prel_force_td == 0 && BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 32, Mpy_32_16_1( accSubblockNrgRev_fx[0], thr_rev_fx ), ( 32 + 4 ) ) > 0 ) { - IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 31, Mpy_32_16_1( accSubblockNrgRev_fx[0], add( thr_rev_fx, THR_LOW_STEP_FX ) ), ( 31 + 4 ) ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 32, Mpy_32_16_1( accSubblockNrgRev_fx[0], add( thr_rev_fx, THR_LOW_STEP_FX ) ), ( 32 + 4 ) ) > 0 ) { prel_force_td = s_or( prel_force_td, 0x0004 ); } -- GitLab From 47fe3fc529be651d476e21441652186b54d0299e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 12:31:16 +0530 Subject: [PATCH 248/329] Speech buffer scaling fix and scaling fix in ivas_core_enc --- lib_com/ivas_prot_fx.h | 3 +- lib_com/prot.h | 1 + lib_enc/core_enc_init_fx.c | 47 +++++++++++++++++---------- lib_enc/ext_sig_ana_fx.c | 11 ++++--- lib_enc/ivas_core_enc_fx.c | 14 ++++---- lib_enc/ivas_core_pre_proc_front_fx.c | 4 +-- lib_enc/ivas_core_pre_proc_fx.c | 40 ++++++++++++----------- lib_enc/stat_enc.h | 20 ++++++------ 8 files changed, 78 insertions(+), 62 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 80bdda3c2..b581dfa7e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5857,8 +5857,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new, - Word16 downscale_buf_speech_enc_pe ); + Word16 *Q_new); ivas_error ivas_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 16f4659a0..f5d69075e 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -761,6 +761,7 @@ void preemph_ivas_fx( const Word16 L, /* i : vector size Q0*/ Word32 *mem /* i/o: memory (x[-1]) Qx*/ ); + void cb_shape( const int16_t preemphFlag, /* i : flag for pre-emphasis */ const int16_t pitchFlag, /* i : flag for pitch sharpening */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 4151725af..c2b1c22e1 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -3,8 +3,8 @@ ====================================================================================*/ #include -//#include "prot_fx.h" -//#include "basop_mpy.h" +// #include "prot_fx.h" +// #include "basop_mpy.h" #include "options.h" #include "cnst.h" #include "stl.h" @@ -1375,6 +1375,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol } // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( st->exp_old_wsp, st->exp_buf_wspeech_enc ) ) ); Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); st->exp_buf_wspeech_enc = st->exp_old_wsp; move16(); @@ -1384,25 +1385,36 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol test(); IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) { - // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); - move16(); + if ( st->exp_buf_speech_enc_pe >= st->exp_old_inp_12k8 ) + { + Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ); // Scaling to common Q + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + } + else + { + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, st->exp_old_inp_12k8 ) ); // Scaling to common Q + Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + st->exp_buf_speech_enc_pe = st->exp_old_inp_12k8; + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + move16(); + } } ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) { lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); - move16(); + if ( st->exp_buf_speech_enc_pe >= st->exp_old_inp_16k ) + { + Copy_Scale_sig( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ); // Scaling to common Q + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + } + else + { + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, st->exp_old_inp_16k ) ); // Scaling to common Q + Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + st->exp_buf_speech_enc_pe = st->exp_old_inp_16k; + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + move16(); + } } st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; @@ -1416,6 +1428,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) { + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( st->exp_old_wsp, st->exp_buf_wspeech_enc ) ) ); Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); st->exp_buf_wspeech_enc = st->exp_old_wsp; diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index c437be5be..732c1ba11 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -710,8 +710,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */ - Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1 + Copy_Scale_sig(new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc)); + /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc + This is considering new_samples is in q 0 in current code*/ } /*--------------------------------------------------------------* @@ -747,10 +748,10 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); + Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); //Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same + + PREEMPH_FX(st->new_speech_enc_pe, st->preemph_fac, L_frame, &(st->mem_preemph_enc)); //using this to keep values alligned in Q-1 - Preemph_scaled( st->new_speech_enc_pe, Q_new, &( st->mem_preemph_enc ), - st->Q_max_enc, st->preemph_fac, 1, 0, 2, L_frame, st->coder_type_raw, 1 ); } /* Rescale Memory */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 6dc3d10ec..303adecfd 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -734,8 +734,8 @@ ivas_error ivas_core_enc_fx( Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda } - Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, input_frame ); - Scale_sig( new_swb_speech_buffer_fx_16, input_frame, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer + Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer /* SWB TBE encoder */ test(); @@ -759,11 +759,11 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { - Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 - Scale_sig( new_swb_speech_fx_16, input_frame, negate( q_new_swb_speech_buffer ) ); // Q0 + Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, negate( q_new_swb_speech_buffer ) ); // q_new_swb_speech_buffer -> Q0 /* SWB(FB) BWE encoder */ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); - Scale_sig( new_swb_speech_fx_16, input_frame, q_new_swb_speech_buffer ); // q_new_swb_speech_buffer + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0 -> q_new_swb_speech_buffer } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 @@ -793,8 +793,8 @@ ivas_error ivas_core_enc_fx( stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); - Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer - Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 + Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer - 16 - > q_new_swb_speech_buffer + Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 7bb67cbbd..04e518e99 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -725,7 +725,7 @@ ivas_error pre_proc_front_ivas_fx( shift = sub( norm_s( inp_max ), headroom ); Word16 Q_min; - shift = s_max( shift, -1 ); + shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max, L_Q_MEM, &Q_min ); *Q_new = s_min( shift, Q_min ); @@ -1702,7 +1702,7 @@ ivas_error pre_proc_front_ivas_fx( error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 1 ); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 718a09026..f4712a771 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -579,14 +579,28 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); - Word16 Q_old_inp_128k = *Q_new; + Word16 Q_inp_12k8 = *Q_new; + move16(); + Word16 Q_inp_16k = *Q_new; move16(); IF( !flag_16k_smc ) { error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new, 0 ); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k); + IF (GT_16(Q_inp_16k, Q_inp_12k8)) + { + Scale_sig(old_inp_16k_fx, L_INP, sub(Q_inp_12k8, Q_inp_16k)); + *Q_new = Q_inp_12k8; + } + ELSE + { + Scale_sig(old_inp_12k8_fx, L_INP_12k8, sub(Q_inp_16k, Q_inp_12k8)); + *Q_new = Q_inp_16k; + } + move16(); + IF( error != IVAS_ERR_OK ) { return error; @@ -628,7 +642,7 @@ ivas_error pre_proc_ivas_fx( IF( flag_16k_smc ) { - Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_new - 1 */ + Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */ } /*-----------------------------------------------------------------* @@ -643,14 +657,11 @@ ivas_error pre_proc_ivas_fx( /* set the pointer of the current frame for the ACELP core */ IF( EQ_16( st->L_frame, L_FRAME ) ) { - *inp_fx = inp_12k8_fx; /* Q_old_inp_128k */ - *Q_new = Q_old_inp_128k; - move16(); + *inp_fx = inp_12k8_fx; /* Q_old_inp_12k8 */ } ELSE { *inp_fx = inp_16k_fx; - Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_128k ) ); } /* Update VAD hangover frame counter in active frames */ @@ -703,9 +714,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new, - Word16 downscale_buf_speech_enc_pe /* Q0 */ -) + Word16 *Q_new) { Word16 *inp_16k_fx, *new_inp_16k_fx; Word16 delay, element_mode; @@ -1103,14 +1112,7 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; - IF( downscale_buf_speech_enc_pe ) - { - shift = negate( *Q_new ); - } - ELSE - { - shift = 0; - } + shift = negate(*Q_new); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1148,7 +1150,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - + ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6292c4b33..12cf078cf 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -113,9 +113,9 @@ typedef struct signal_buffers_enc_data_structure Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; - Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; //exp_buf_speech_enc Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -1463,10 +1463,10 @@ typedef struct enc_core_structure Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 *buf_speech_enc_pe; + Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - Word16 *buf_speech_enc; - Word16 *buf_wspeech_enc; + Word16 *buf_speech_enc; //exp_buf_speech_enc + Word16 *buf_wspeech_enc; //exp_buf_wspeech_enc Word16 exp_buf_speech_enc_pe; Word16 exp_buf_speech_enc; @@ -1640,11 +1640,11 @@ typedef struct enc_core_structure Word16 exp_mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - Word16 *speech_enc; - Word16 *speech_enc_pe; - Word16 *new_speech_enc; - Word16 *new_speech_enc_pe; - Word16 *wspeech_enc; + Word16 *speech_enc; //exp_buf_speech_enc + Word16 *speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *new_speech_enc; //exp_buf_speech_enc + Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *wspeech_enc; //exp_buf_wspeech_enc Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -- GitLab From 42806254d09551b20f527354a61fff694d80d9a9 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 12:33:58 +0530 Subject: [PATCH 249/329] Clang formatting changes --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ext_sig_ana_fx.c | 11 +++++------ lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 20 ++++++++++---------- lib_enc/stat_enc.h | 22 +++++++++++----------- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b581dfa7e..a61d6228d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5857,7 +5857,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new); + Word16 *Q_new ); ivas_error ivas_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 732c1ba11..9e6318591 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -710,9 +710,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy_Scale_sig(new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc)); - /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc - This is considering new_samples is in q 0 in current code*/ + Copy_Scale_sig( new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc ) ); + /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc + This is considering new_samples is in q 0 in current code*/ } /*--------------------------------------------------------------* @@ -748,10 +748,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); //Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same - - PREEMPH_FX(st->new_speech_enc_pe, st->preemph_fac, L_frame, &(st->mem_preemph_enc)); //using this to keep values alligned in Q-1 + Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); // Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same + PREEMPH_FX( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 } /* Rescale Memory */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 04e518e99..f963b55a4 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1702,7 +1702,7 @@ ivas_error pre_proc_front_ivas_fx( error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index f4712a771..1234a6876 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -588,19 +588,19 @@ ivas_error pre_proc_ivas_fx( error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k); - IF (GT_16(Q_inp_16k, Q_inp_12k8)) + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); + IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { - Scale_sig(old_inp_16k_fx, L_INP, sub(Q_inp_12k8, Q_inp_16k)); - *Q_new = Q_inp_12k8; + Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) ); + *Q_new = Q_inp_12k8; } ELSE { - Scale_sig(old_inp_12k8_fx, L_INP_12k8, sub(Q_inp_16k, Q_inp_12k8)); - *Q_new = Q_inp_16k; + Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_inp_16k, Q_inp_12k8 ) ); + *Q_new = Q_inp_16k; } move16(); - + IF( error != IVAS_ERR_OK ) { return error; @@ -714,7 +714,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new) + Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; Word16 delay, element_mode; @@ -1112,7 +1112,7 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; - shift = negate(*Q_new); + shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1150,7 +1150,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - + ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 12cf078cf..d9f71128d 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -113,9 +113,9 @@ typedef struct signal_buffers_enc_data_structure Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; - Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; //exp_buf_speech_enc + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -1463,10 +1463,10 @@ typedef struct enc_core_structure Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - Word16 *buf_speech_enc; //exp_buf_speech_enc - Word16 *buf_wspeech_enc; //exp_buf_wspeech_enc + Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + Word16 *buf_speech_enc; // exp_buf_speech_enc + Word16 *buf_wspeech_enc; // exp_buf_wspeech_enc Word16 exp_buf_speech_enc_pe; Word16 exp_buf_speech_enc; @@ -1640,11 +1640,11 @@ typedef struct enc_core_structure Word16 exp_mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - Word16 *speech_enc; //exp_buf_speech_enc - Word16 *speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *new_speech_enc; //exp_buf_speech_enc - Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *wspeech_enc; //exp_buf_wspeech_enc + Word16 *speech_enc; // exp_buf_speech_enc + Word16 *speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *new_speech_enc; // exp_buf_speech_enc + Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *wspeech_enc; // exp_buf_wspeech_enc Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -- GitLab From 9002a018c57848060404d8e92908c9dacfce05a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 09:17:58 +0100 Subject: [PATCH 250/329] remove unused switches --- lib_com/ivas_ism_com_fx.c | 1 - lib_com/ivas_prot.h | 1 - lib_com/options.h | 1 - lib_enc/ivas_ism_dtx_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 3 +-- lib_rend/lib_rend.c | 10 +++------- 6 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 74e9641aa..d3f18a795 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -43,7 +43,6 @@ #include "ivas_prot_fx.h" #include "prot_fx.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*-----------------------------------------------------------------------* * Local constants diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2493add28..34f11c01f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -45,7 +45,6 @@ #include "ivas_stat_com.h" #include "ivas_error_utils.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /* clang-format off */ diff --git a/lib_com/options.h b/lib_com/options.h index d3570004d..7d65c5eac 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -70,7 +70,6 @@ #define IVAS_FLOAT_FIXED #define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */ #define MSAN_FIX -#define ISM_DISABLE #define FIX_TMP_714 #define BASOP_NOGLOB_TMP_715 #define EVS_FUNC_MODIFIED diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 3439baff1..615660761 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -40,7 +40,6 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index d78281ff4..a5a1286a2 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -44,8 +44,7 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED -#include "ivas_rom_com_fx.h" + /*-----------------------------------------------------------------------* * Local constants diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a1c551405..698c652e5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -33,24 +33,20 @@ #include "options.h" #include "lib_rend.h" #include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" +#include "ivas_rom_com_fx.h" #include "ivas_rom_rend.h" #include #include #include #include "wmc_auto.h" -#include "ivas_rom_com_fx.h" -#include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "debug.h" -#define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) -#define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ -- GitLab From 65bee438bed413351f4b84df7a3fcdb6f76bbce0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 10:12:57 +0100 Subject: [PATCH 251/329] review and remove ADD_LRTD --- lib_com/est_tilt_fx.c | 35 +- lib_com/gs_bitallocation_fx.c | 925 ++++++++--------------------- lib_com/gs_bitallocation_ivas_fx.c | 144 ++--- lib_com/gs_noisefill_fx.c | 108 +--- lib_com/gs_preech_fx.c | 7 +- lib_com/options.h | 3 - lib_com/prot_fx.h | 91 ++- lib_com/syn_filt_fx.c | 18 - lib_dec/acelp_core_dec_fx.c | 123 +--- lib_dec/acelp_core_dec_ivas_fx.c | 8 +- lib_dec/core_switching_dec_fx.c | 4 - lib_dec/dec_amr_wb_fx.c | 8 +- lib_dec/dec_pit_exc_fx.c | 76 +-- lib_dec/evs_dec_fx.c | 9 +- lib_dec/gs_dec_fx.c | 335 ++--------- lib_dec/inov_dec_fx.c | 4 +- lib_dec/lsf_dec_fx.c | 5 - lib_dec/pit_dec_fx.c | 56 -- lib_dec/stat_dec.h | 37 +- lib_enc/acelp_core_enc_fx.c | 113 +--- lib_enc/cng_enc_fx.c | 4 - lib_enc/enc_pit_exc_fx.c | 5 +- lib_enc/enc_uv_fx.c | 3 +- lib_enc/evs_enc_fx.c | 7 +- lib_enc/gain_enc_fx.c | 14 - lib_enc/gs_enc_fx.c | 37 +- lib_enc/init_enc_fx.c | 5 +- lib_enc/lib_enc.c | 3 - lib_enc/lsf_enc_fx.c | 289 +++------ lib_enc/pit_enc_fx.c | 42 -- lib_enc/prot_fx_enc.h | 21 +- 31 files changed, 567 insertions(+), 1972 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 138b8c1bc..4ff9c6c11 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -40,18 +40,12 @@ Word16 est_tilt_fx( /* o : tilt of the code const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#ifdef ADD_LRTD - , - const Word16 L_subfr /* i : Sub frame length */ -#endif ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; Word32 L_tmp; Word16 tilt_code; -#ifdef ADD_LRTD - PMT( "FIX POINT NEED to be adapted for 16 kHz frame length " ) -#endif + ener1 = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp1 ) ); exp1 = sub( exp1, add( Q_exc, Q_exc ) ); L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */ @@ -117,26 +111,23 @@ Word16 est_tilt_fx( /* o : tilt of the code /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ -Word16 est_tilt_ivas_fx( /* o : tilt of the code Q15 */ - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#if 1 // def ADD_LRTD - , - const Word16 L_subfr, /* i : Sub frame length */ - const Word16 flag_tilt /* i : flag for special tilt */ -#endif + +/* o : tilt of the code Q15 */ +Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr, /* i : Sub frame length */ + const Word16 flag_tilt /* i : flag for special tilt */ ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; Word32 L_tmp; Word16 tilt_code; -#ifdef ADD_LRTD - PMT( "FIX POINT NEED to be adapted for 16 kHz frame length " ) -#endif + ener1 = extract_h( Dot_product12( exc, exc, L_subfr, &exp1 ) ); exp1 = sub( exp1, add( Q_exc, Q_exc ) ); L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */ diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 47d3679a8..e8f32c804 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -120,40 +120,7 @@ void bands_and_bit_alloc_fx( move16(); bit_new_bands = 5; move16(); -#ifdef ADD_LRTD - if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) ) - { - bit_new_bands = 7; - move16(); - } - - i = 0; - move16(); - WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) - { - IF( LE_32( core_brate, brate_intermed_tbl[i] ) ) - { - BREAK; - } - - IF( EQ_32( brate_intermed_tbl[i], ACELP_24k40 ) ) - { - BREAK; - } - - i = add( i, 1 ); - } - - if ( GT_16( element_mode, EVS_MONO ) && EQ_16( coder_type, AUDIO ) && - LE_32( core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */ - { - i = sub( i, 1 ); - } - - bit_index = i_mult2( BRATE2IDX_fx( brate_intermed_tbl[i] ), 17 ); -#else bit_index = i_mult2( BRATE2IDX_fx( core_brate ), 17 ); -#endif bit_index_mem = bit_index; move16(); @@ -189,668 +156,330 @@ void bands_and_bit_alloc_fx( move16(); } -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k ) - { - *bit -= 8; - } - - if ( coder_type == INACTIVE && core_brate <= GSC_LRES_GAINQ_LIMIT ) /* can happen only for 2nd channel inactive */ - { - *bit += GSC_LRES_NB_NITS; - } - - if ( *bit > 0 ) + IF( EQ_16( GSC_noisy_speech, 1 ) ) { - if ( GSC_IVAS_mode > 0 ) - { - SWB_bit_budget = *bit; - st_band = 5; - - set_f( bits_per_bands, 0, MBANDS_GN_BITALLOC16k ); - - /* 2- Decide the pourcentage of bits allocated to LF (between 50-75%) depending of the temporal contribution in GSC */ - bit_fracf = ( -0.125f * Diff_len + 76.0f ) / 100; - bit_fracf = check_bounds( bit_fracf, 0.50f, 0.75f ); - - /* Adjusment of the bitrate between LF and HF base on the content type */ - /* 1 = new GSC bit alloc - 2 = GSC bit alloc for tc frame - 3 = more music like (should not happen often given music is coded with dft) */ - - if ( GSC_IVAS_mode <= 3 ) - { - nb_bands_max -= 6; - } - - if ( GSC_IVAS_mode == 2 ) - { - bit_fracf += 0.1f; - nb_bands_max--; - } - - if ( GSC_IVAS_mode == 3 ) - { - bit_fracf -= 0.1f; - nb_bands_max += 3; - } - - /* First find how much we want to share between LF and HF, at low bitrate, a miminum of bits is needed in LF by limitating the number of bands*/ - /* Adjust the number of band based on the content type and bitrate */ - nb_bands_adj = 1.0f; - if ( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG ) - { - nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f; - } - else if ( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG ) - { - nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f; - } - nb_bands_max = (int16_t) ( nb_bands_max * nb_bands_adj + 0.5f ); - nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands ); - - bit_fracf *= SWB_bit_budget; - - /* Estimation of the number of bit used in HF */ - /* with only the first weigthing The number of bits in max_ener_band[st_band-1] = 17% of bit_fracf */ - mb = .17f * bit_fracf; - mp = ( 2.0f * DSR_NB_PULSE ); - if ( core_brate < GSC_L_RATE_STG && GSC_IVAS_mode == 3 ) - { - mp = 1.5f * DSR_NB_PULSE; - } - else if ( core_brate < GSC_L_RATE_STG ) - { - mp = DSR_NB_PULSE; - } - - /* We want max_ener_band[st_band] <= max_ener_band[st_band-1] and max_ener_band[nb_bands_max-1] <= max_ener_band[st_band]*/ - /* We will estimate the number of bits to allocate of HF and put the remaining bits, if any, back on LF */ - /* compute the total possible number of band to be coded */ - nb_tot_bands = (int16_t) ( ( SWB_bit_budget - bit_fracf ) / ( mp + ( mb - mp ) / 2.0f ) ); - mp = min( mp, mb ); - if ( nb_tot_bands + st_band > nb_bands_max ) - { - bit_adj = ( ( mb + mp ) / 2 ) * ( nb_tot_bands + st_band - nb_bands_max ); - bit_adj = max( 0, bit_adj ); - nb_tot_bands = nb_bands_max - st_band; - bit_fracf += bit_adj; - } - nb_tot_bands += st_band; - - /* Allocate bits to LF */ - etmp = 0.23f; - for ( j = 0; j < st_band; j++ ) - { - i = j; - max_ener_band[j] = i; - ener_vec[i] = MIN16B; - bits_per_bands[j] = etmp * bit_fracf; - etmp -= 0.015f; - } - - SWB_bit_budget -= bit_fracf; - - /* Find low energy band in HF */ - set_s( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k ); - for ( i = st_band + 2; i < nb_tot_bands - 1; i++ ) - { - if ( ener_vec[i] < ener_vec[i - 1] && ener_vec[i] < ener_vec[i + 1] ) - { - nb_pulse_per_band[i] = 1; - } - } - for ( j = st_band; j < nb_tot_bands; j++ ) - { - if ( j > 6 ) - { - i = maximum( ener_vec, nb_tot_bands, &etmp ); - } - else - { - i = j; - } - - max_ener_band[j] = i; - ener_vec[i] = MIN16B; - } - - /* Recompute the final bit distribution for HF */ - if ( nb_tot_bands > st_band ) - { - bit_fracf = DSR_NB_PULSE; - mb = ( SWB_bit_budget * 2 / ( nb_tot_bands - st_band ) ) - mp; - bit_fracf = ( mb - mp ) / ( nb_tot_bands - st_band ); - mb -= bit_fracf; - /* Do the distribution */ - for ( j = st_band; j < nb_tot_bands; j++ ) - { - if ( nb_pulse_per_band[max_ener_band[j]] > 1 ) - { - bits_per_bands[max_ener_band[j]] = mb; - } - else - { - bits_per_bands[max_ener_band[j]] = 4.5f; - } - mb -= bit_fracf; - SWB_bit_budget -= bits_per_bands[max_ener_band[j]]; - } - } - - /* Series of verification in case bit allocated != the budget */ - if ( SWB_bit_budget > 0 ) - { - i = st_band - 1; - while ( SWB_bit_budget > 0 ) - { - bits_per_bands[i]++; - SWB_bit_budget--; - i--; - if ( i == -1 ) - { - i = st_band - 1; - } - } - } + SWB_bit_budget = *bit; + move16(); + nb_bands = 5; + move16(); - nb_bands = nb_tot_bands; + st_band = nb_bands; + move16(); - sum_bit = 0; - j = 0; - for ( i = 0; i < nb_bands; i++ ) - { - if ( bits_per_bands[i] > 112 ) - { - sum_bit += bits_per_bands[i] - 112; - bits_per_bands[i] = 112; - j = i + 1; - } + set32_fx( bits_per_bands, 0, MBANDS_GN ); + /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */ + bit_fracf = L_mult( div_s( 1, nb_bands ), shl( SWB_bit_budget, 2 ) ); /* Q18 */ - /* safety check for overage bit reallocation */ - else if ( bits_per_bands[i] + sum_bit / 3 > 112 ) - { - j = i + 1; - } - } + nb_tot_bands = sub( nb_bands_max, 6 ); + nb_tot_bands = s_min( nb_tot_bands, 16 ); - if ( sum_bit != 0 ) - { - sum_bit /= ( nb_bands - j ); - for ( i = j; i < nb_bands; i++ ) - { - bits_per_bands[i] += sum_bit; - } - } + FOR( j = 0; j < 2; j++ ) + { + i = j; + move16(); + max_ener_band[j] = i; + move16(); + ener_vec[i] = 0; + move16(); } - else -#endif - IF( EQ_16( GSC_noisy_speech, 1 ) ) - { - SWB_bit_budget = *bit; - move16(); - nb_bands = 5; - move16(); -#ifdef ADD_LRTD - - fzero_val = 0.0f; - if ( element_mode > EVS_MONO ) - { - fzero_val = MIN16B_FLT; - } - - if ( coder_type == UNVOICED && element_mode > EVS_MONO ) - { - nb_bands = 3; - if ( SWB_bit_budget > 20 ) - { - nb_bands = 5; - } - } - else if ( bwidth < SWB ) - { - nb_bands = 7; - } - -#endif - - st_band = nb_bands; - move16(); + FOR( ; j < nb_bands; j++ ) + { + i = maximum_fx( ener_vec, nb_tot_bands, &etmp ); + max_ener_band[j] = i; + move16(); + ener_vec[i] = 0; + move16(); + } - set32_fx( bits_per_bands, 0, MBANDS_GN ); - /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */ - bit_fracf = L_mult( div_s( 1, nb_bands ), shl( SWB_bit_budget, 2 ) ); /* Q18 */ + set32_fx( bits_per_bands, bit_fracf, nb_bands ); + } + ELSE + { + bit_index++; + bit_tmp = sub( *bit, GSC_freq_bits[bit_index] ); + bit_index++; + nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] ); + bit_index++; - nb_tot_bands = sub( nb_bands_max, 6 ); - nb_tot_bands = s_min( nb_tot_bands, 16 ); + *pvq_len = 112; + move16(); + st_band = 7; + move16(); - FOR( j = 0; j < 2; j++ ) - { - i = j; - move16(); - max_ener_band[j] = i; - move16(); - ener_vec[i] = 0; - move16(); - } -#ifdef ADD_LRTD - if ( bwidth < SWB ) - { - if ( coder_type == UNVOICED && element_mode > EVS_MONO ) - { - nb_tot_bands = 5; - } -#endif - FOR( ; j < nb_bands; j++ ) - { - i = maximum_fx( ener_vec, nb_tot_bands, &etmp ); - max_ener_band[j] = i; - move16(); - ener_vec[i] = 0; - move16(); - } -#ifdef ADD_LRTD - } - else - { - for ( ; j < nb_bands; j++ ) - { - i = maximum( ener_vec, nb_tot_bands, &etmp ); - max_ener_band[j] = i; - ener_vec[i] = fzero_val; - } - } -#endif - set32_fx( bits_per_bands, bit_fracf, nb_bands ); - } - ELSE + IF( LE_32( core_brate, ACELP_9k60 ) ) { - bit_index++; - bit_tmp = sub( *bit, GSC_freq_bits[bit_index] ); - bit_index++; - nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] ); - bit_index++; - - *pvq_len = 112; + *pvq_len = 80; move16(); - st_band = 7; + st_band = 5; move16(); -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 ) - { - *pvq_len = 160; - st_band = 10; - nb_bands = *pvq_len / 16; - bit_tmp -= 35; - bit_new_bands = 5; - } -#endif - IF( LE_32( core_brate, ACELP_9k60 ) ) - { - *pvq_len = 80; - move16(); - st_band = 5; - move16(); - - IF( Diff_len == 0 ) - { - nb_bands_max = add( nb_bands_max, 2 ); - bit_tmp = sub( bit_tmp, 13 ); - } - } - ELSE IF( Diff_len == 0 ) + IF( Diff_len == 0 ) { nb_bands_max = add( nb_bands_max, 2 ); - bit_tmp = sub( bit_tmp, 17 ); + bit_tmp = sub( bit_tmp, 13 ); } + } - nb_bands = shr( *pvq_len, 4 ); -#ifdef ADD_LRTD - nb_bands_max = min( nb_bands_max, MBANDS_GN_BITALLOC16k ); -#endif - /*------------------------------------------------------------------------ + ELSE IF( Diff_len == 0 ) + { + nb_bands_max = add( nb_bands_max, 2 ); + bit_tmp = sub( bit_tmp, 17 ); + } + + nb_bands = shr( *pvq_len, 4 ); + + /*------------------------------------------------------------------------ * Ajustement of the maximum number of bands in function of the * dynamics of the spectrum (more or less speech like) *-----------------------------------------------------------------------*/ - test(); - test(); - test(); - test(); - IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) - { - /* Probably classification error -> concentrate bits on LF */ -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate >= ACELP_24k40 ) - { - nb_bands_max = nb_tot_bands - 2; - } - else if ( core_brate >= ACELP_16k40 ) - { - nb_bands_max = nb_bands + 2; - } - else -#endif - if ( GE_32( core_brate, ACELP_8k00 ) ) - { - nb_bands_max = add( nb_bands, 1 ); - } - else - { - nb_bands_max = nb_bands; - move16(); - } - } - ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP2 ) || - ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */ - { - nb_bands_max = sub( nb_bands_max, 2 ); - } - ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP1 ) ) /* Very low dynamic, tend to speech, code less HF */ + test(); + test(); + test(); + test(); + IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) + { + /* Probably classification error -> concentrate bits on LF */ + if ( GE_32( core_brate, ACELP_8k00 ) ) { - nb_bands_max = sub( nb_bands_max, 1 ); + nb_bands_max = add( nb_bands, 1 ); } -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k ) - { - if ( core_brate < ACELP_24k40 ) - { - nb_bands_max -= 4; - } - else if ( core_brate < ACELP_32k ) - { - if ( Diff_len > 0 || noise_lev >= NOISE_LEVEL_SP2 ) - { - nb_bands_max -= 2; - bit_new_bands *= 2; - } - } - else if ( core_brate >= ACELP_32k ) - { - bit_new_bands *= 2; - } - } - -#endif - test(); - if ( ( EQ_16( bwidth, NB ) ) && GT_16( nb_bands_max, 10 ) ) + else { - nb_bands_max = 10; + nb_bands_max = nb_bands; move16(); } + } + ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP2 ) || + ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */ + { + nb_bands_max = sub( nb_bands_max, 2 ); + } + ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP1 ) ) /* Very low dynamic, tend to speech, code less HF */ + { + nb_bands_max = sub( nb_bands_max, 1 ); + } + + test(); + if ( ( EQ_16( bwidth, NB ) ) && GT_16( nb_bands_max, 10 ) ) + { + nb_bands_max = 10; + move16(); + } - /*------------------------------------------------------------------------ + /*------------------------------------------------------------------------ * Find extra number of band to code according to bit rate availables *-----------------------------------------------------------------------*/ + test(); + WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) ) + { test(); - WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) ) - { - test(); - bit_tmp = sub( bit_tmp, bit_new_bands ); - nb_bands = add( nb_bands, 1 ); - } + bit_tmp = sub( bit_tmp, bit_new_bands ); + nb_bands = add( nb_bands, 1 ); + } - /*------------------------------------------------------------------------ + /*------------------------------------------------------------------------ * Fractional bits to distribute on the first x bands *-----------------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_32k ) - { - bit_fracf = 0; - } - else -#endif - { - bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ - } - /*------------------------------------------------------------------------ + + { + bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ + } + /*------------------------------------------------------------------------ * Complete the bit allocation per frequency band *-----------------------------------------------------------------------*/ - imax = 5; + imax = 5; + move16(); + + if ( GT_32( core_brate, ACELP_9k60 ) ) + { + imax = 7; move16(); + } + FOR( i = 0; i < imax; i++ ) + { + bits_per_bands[i] = L_add( GSC_freq_bits_fx[bit_index], bit_fracf ); + move32(); /* Q18 */ + bit_index = add( bit_index, 1 ); + } - if ( GT_32( core_brate, ACELP_9k60 ) ) - { - imax = 7; - move16(); - } - FOR( i = 0; i < imax; i++ ) + IF( Diff_len == 0 ) + { + bit_index = add( bit_index_mem, 10 ); + FOR( i = 0; i < 7; i++ ) { - bits_per_bands[i] = L_add( GSC_freq_bits_fx[bit_index], bit_fracf ); - move32(); /* Q18 */ + bits_per_bands[i] = L_add( bits_per_bands[i], GSC_freq_bits_fx[bit_index] ); + move32(); /*chk Q18 */ bit_index = add( bit_index, 1 ); } -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 ) - { - bit_index = 0; - i = imax - 1; - bits_per_bands[i] += Compl_GSC_freq_bits[bit_index]; - i++; - bit_index++; - - for ( ; i < 10; i++ ) - { - bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf; - bit_index++; - } - } -#endif - IF( Diff_len == 0 ) - { - bit_index = add( bit_index_mem, 10 ); - FOR( i = 0; i < 7; i++ ) - { - bits_per_bands[i] = L_add( bits_per_bands[i], GSC_freq_bits_fx[bit_index] ); - move32(); /*chk Q18 */ - bit_index = add( bit_index, 1 ); - } - } -#ifdef ADD_LRTD - if ( bit_fracf < 0 ) - { - for ( j = 0; j < nb_tot_bands; j++ ) - { - bits_per_bands[j] = max( bits_per_bands[j], 0 ); - } - } + } -#endif - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Complete the bit allocation per frequency band for 16kHz high brate mode *--------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_32k ) - { - for ( j = st_band; j < nb_bands; j++ ) - { - bits_per_bands[j] = bit_new_bands; - } - - bit_fracf = ( 1.0f / nb_bands ) * ( bit_tmp ); - etmp = 2.0f * bit_fracf / ( nb_bands + 1 ); - bit_fracf = etmp; - for ( j = nb_bands - 1; j >= 0; j-- ) - { - bits_per_bands[j] += etmp; - etmp += bit_fracf; - } - } - else -#endif + { + FOR( j = st_band; j < nb_bands; j++ ) { - FOR( j = st_band; j < nb_bands; j++ ) - { - bits_per_bands[j] = L_shl( bit_new_bands, 18 ); - move32(); /*chk Q18 */ - } + bits_per_bands[j] = L_shl( bit_new_bands, 18 ); + move32(); /*chk Q18 */ } + } - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Compute a maximum band (band offset) for the search on maximal energy * This is function of the spectral dynamic and the bitrate *--------------------------------------------------------------------------*/ - bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) ); + bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) ); - test(); - test(); - test(); - test(); - test(); - IF( LE_16( noise_lev, NOISE_LEVEL_SP1a ) ) - { - bandoffset = sub( bandoffset, 1 ); - } - ELSE IF( ( LE_32( core_brate, ACELP_13k20 ) && ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) ) || - ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) - { - bandoffset = add( bandoffset, 1 ); - } + test(); + test(); + test(); + test(); + test(); + IF( LE_16( noise_lev, NOISE_LEVEL_SP1a ) ) + { + bandoffset = sub( bandoffset, 1 ); + } + ELSE IF( ( LE_32( core_brate, ACELP_13k20 ) && ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) ) || + ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) + { + bandoffset = add( bandoffset, 1 ); + } - bandoffset = s_max( bandoffset, 0 ); + bandoffset = s_max( bandoffset, 0 ); - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Initiazed sorted vector * For the first x bands to be included in th final sorted vector * Sort the remaining bands in decrease energy order *--------------------------------------------------------------------------*/ - FOR( j = 0; j < nb_tot_bands; j++ ) - { - max_ener_band[j] = -10; - move16(); - } - FOR( j = 0; j < st_band; j++ ) - { - max_ener_band[j] = j; - move16(); - ener_vec[j] = -10; - move16(); - } - pos = st_band; + FOR( j = 0; j < nb_tot_bands; j++ ) + { + max_ener_band[j] = -10; move16(); - FOR( ; j < nb_bands; j++ ) + } + FOR( j = 0; j < st_band; j++ ) + { + max_ener_band[j] = j; + move16(); + ener_vec[j] = -10; + move16(); + } + pos = st_band; + move16(); + FOR( ; j < nb_bands; j++ ) + { + i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp ); + pos = s_max( pos, i ); + max_ener_band[j] = i; + move16(); + ener_vec[i] = -10; + move16(); + } + + /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */ + test(); + test(); + test(); + IF( GT_16( sub( nb_tot_bands, bandoffset ), nb_bands ) && ( GT_16( pos, 7 ) && EQ_32( core_brate, ACELP_8k00 ) ) && EQ_16( bwidth, WB ) ) + { + band = sub( nb_tot_bands, add( bandoffset, nb_bands ) ); + FOR( j = 0; j < band; j++ ) { i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp ); - pos = s_max( pos, i ); - max_ener_band[j] = i; + max_ener_band[add( nb_bands, j )] = i; move16(); ener_vec[i] = -10; move16(); + bits_per_bands[add( nb_bands, j )] = 1310720; + move32(); /*Q18 */ } + nb_bands = add( nb_bands, band ); - /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */ - test(); - test(); - test(); - IF( GT_16( sub( nb_tot_bands, bandoffset ), nb_bands ) && ( GT_16( pos, 7 ) && EQ_32( core_brate, ACELP_8k00 ) ) && EQ_16( bwidth, WB ) ) + bit_tmp = i_mult2( band, 5 ); + + IF( LE_16( band, 2 ) ) { - band = sub( nb_tot_bands, add( bandoffset, nb_bands ) ); - FOR( j = 0; j < band; j++ ) + FOR( j = sub( st_band, 1 ); j < nb_bands; j++ ) { - i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp ); - max_ener_band[add( nb_bands, j )] = i; - move16(); - ener_vec[i] = -10; - move16(); - bits_per_bands[add( nb_bands, j )] = 1310720; - move32(); /*Q18 */ + bits_per_bands[j] = L_add( bits_per_bands[j], 262144 ); /*Q18 */ + move32(); } - nb_bands = add( nb_bands, band ); - - bit_tmp = i_mult2( band, 5 ); + bit_tmp = add( bit_tmp, add( sub( nb_bands, st_band ), 1 ) ); + } - IF( LE_16( band, 2 ) ) + i = 0; + move16(); + j = 0; + move16(); + FOR( ; bit_tmp > 0; bit_tmp-- ) + { + bits_per_bands[j] = L_sub( bits_per_bands[j], 262144 ); /*Q18 */ + j = add( j, 1 ); + if ( EQ_16( j, sub( st_band, i ) ) ) { - FOR( j = sub( st_band, 1 ); j < nb_bands; j++ ) - { - bits_per_bands[j] = L_add( bits_per_bands[j], 262144 ); /*Q18 */ - move32(); - } - bit_tmp = add( bit_tmp, add( sub( nb_bands, st_band ), 1 ) ); + j = 0; + move16(); } - - i = 0; - move16(); - j = 0; - move16(); - FOR( ; bit_tmp > 0; bit_tmp-- ) + test(); + if ( j == 0 && LT_16( i, sub( st_band, 1 ) ) ) { - bits_per_bands[j] = L_sub( bits_per_bands[j], 262144 ); /*Q18 */ - j = add( j, 1 ); - if ( EQ_16( j, sub( st_band, i ) ) ) - { - j = 0; - move16(); - } - test(); - if ( j == 0 && LT_16( i, sub( st_band, 1 ) ) ) - { - i = add( i, 1 ); - } + i = add( i, 1 ); } } } - /*-------------------------------------------------------------------------- + } + /*-------------------------------------------------------------------------- * Bit sum verification for GSC inactive at very high rate * The maximum number of bits per band of length 16 is 112 * Redistribute the overage bits if needed *--------------------------------------------------------------------------*/ - sum_bit = 0; - move16(); - j = 0; - move16(); - FOR( i = 0; i < nb_bands; i++ ) - { - L_tmp = Mult_32_16( sum_bit, 10923 ); + sum_bit = 0; + move16(); + j = 0; + move16(); + FOR( i = 0; i < nb_bands; i++ ) + { + L_tmp = Mult_32_16( sum_bit, 10923 ); - IF( GT_32( bits_per_bands[i], 29360128 ) ) /* 112 in Q18 */ - { - sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) ); /* Q18 */ - bits_per_bands[i] = 29360128; - move32(); - j = add( i, 1 ); - } - ELSE IF( GT_32( L_add( bits_per_bands[i], L_tmp ), 29360128 ) ) /* Q18 */ - { - j = add( i, 1 ); - } + IF( GT_32( bits_per_bands[i], 29360128 ) ) /* 112 in Q18 */ + { + sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) ); /* Q18 */ + bits_per_bands[i] = 29360128; + move32(); + j = add( i, 1 ); } + ELSE IF( GT_32( L_add( bits_per_bands[i], L_tmp ), 29360128 ) ) /* Q18 */ + { + j = add( i, 1 ); + } + } - IF( sum_bit != 0 ) + IF( sum_bit != 0 ) + { + tmp = sub( nb_bands, j ); + sum_bit = Mult_32_16( sum_bit, div_s( 1, tmp ) ); /* Q18 */ + FOR( i = j; i < nb_bands; i++ ) { - tmp = sub( nb_bands, j ); - sum_bit = Mult_32_16( sum_bit, div_s( 1, tmp ) ); /* Q18 */ - FOR( i = j; i < nb_bands; i++ ) - { - bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit ); - move32(); /* Q18 */ - } + bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit ); + move32(); /* Q18 */ } - /*-------------------------------------------------------------------------- + } + /*-------------------------------------------------------------------------- * second step of bit sum verification, normally sum_bit == *bit *--------------------------------------------------------------------------*/ - w_sum_bit = 0; + w_sum_bit = 0; + move16(); + FOR( i = 0; i < nb_bands; i++ ) + { + out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 ); move16(); - FOR( i = 0; i < nb_bands; i++ ) - { - out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 ); - move16(); - w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ - } - tmp = shl( *bit, 3 ); -#ifdef ADD_LRTD - if ( GSC_IVAS_mode != 0 && sum_bit < *bit ) /* If we need to add bits, we are doing it on the LF */ - { - reajust_bits( bits_per_bands, 0, nb_bands, (int16_t) sum_bit, *bit ); - } - else - { - reajust_bits( bits_per_bands, nb_bands - 1, 0, (int16_t) sum_bit, *bit ); - } -#else + w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ + } + tmp = shl( *bit, 3 ); + IF( GT_16( tmp, w_sum_bit ) ) { i = sub( nb_bands, 1 ); @@ -866,88 +495,24 @@ void bands_and_bit_alloc_fx( } } } -#endif - /*-------------------------------------------------------------------------- + + /*-------------------------------------------------------------------------- * Recompute the real number/length of frequency bands to encode *--------------------------------------------------------------------------*/ - *nb_subbands = nb_bands; - move16(); - *pvq_len = shl( *nb_subbands, 4 ); + *nb_subbands = nb_bands; + move16(); + *pvq_len = shl( *nb_subbands, 4 ); - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Concatenate bands (encoder only) *--------------------------------------------------------------------------*/ - IF( exc_diff != NULL ) - { - FOR( j = 0; j < nb_bands; j++ ) - { - Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 ); - } - } -#ifdef ADD_LRTD - } - else /* *bit == 0 */ - { - set_s( bits_per_bands_s, 0, nb_tot_bands ); - *nb_subbands = 0; - *pvq_len = 0; - } -#endif - return; -} -#ifdef ADD_LRTD -/*-------------------------------------------------------------------* - * reajust_bits() - * - * - *-------------------------------------------------------------------*/ - -static void reajust_bits( - float *bits_per_bands, - const int16_t st_band, - const int16_t end_band, - const int16_t sum_bit_in, - const int16_t bit_bdgt_in ) -{ - int16_t i, amount_to_add, incr; - int16_t bit_bdgt, sum_bit; - - incr = 1; - if ( end_band < st_band ) - { - incr = -1; - } - - if ( bit_bdgt_in < sum_bit_in ) - { - amount_to_add = -1; - bit_bdgt = sum_bit_in; - sum_bit = bit_bdgt_in; - } - else - { - bit_bdgt = bit_bdgt_in; - sum_bit = sum_bit_in; - amount_to_add = 1; - } - - i = st_band; - while ( bit_bdgt > sum_bit ) + IF( exc_diff != NULL ) { - if ( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 1 ) ) + FOR( j = 0; j < nb_bands; j++ ) { - bits_per_bands[i] += amount_to_add; - sum_bit += (int16_t) abs( amount_to_add ); - } - - i += incr; - if ( i == end_band ) - { - i = st_band; + Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 ); } } return; } - -#endif diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 0ab167015..eef3d50c6 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -103,8 +103,8 @@ void bands_and_bit_alloc_ivas_fx( Word16 etmp; Word16 tmp; Word16 pos, band; - Word32 SWB_bit_budget; // Q0 -> Q18 - Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; // Q18 + Word32 SWB_bit_budget; /* Q0 -> Q18 */ + Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; /* Q18 */ Word16 w_sum_bit; Word16 fzero_val; #ifdef BASOP_NOGLOB_DECLARE_LOCAL @@ -148,7 +148,7 @@ void bands_and_bit_alloc_ivas_fx( move16(); bit_new_bands = 5; move16(); -#if 1 // def ADD_LRTD + test(); if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) ) { @@ -183,9 +183,6 @@ void bands_and_bit_alloc_ivas_fx( } bit_index = i_mult2( BRATE2IDX_fx( brate_intermed_tbl[i] ), 17 ); -#else - bit_index = i_mult2( BRATE2IDX_fx( core_brate ), 17 ); -#endif bit_index_mem = bit_index; move16(); @@ -221,7 +218,6 @@ void bands_and_bit_alloc_ivas_fx( move16(); } -#if 1 // def ADD_LRTD IF( EQ_16( L_frame, L_FRAME16k ) ) { *bit = sub( *bit, 8 ); @@ -242,18 +238,12 @@ void bands_and_bit_alloc_ivas_fx( nb_tot_bands = Find_bit_alloc_IVAS_fx( core_brate, GSC_IVAS_mode, Diff_len, nb_tot_bands, bit, max_ener_band, ener_vec, bits_per_bands ); nb_bands = nb_tot_bands; } - ELSE -#endif - IF( EQ_16( GSC_noisy_speech, 1 ) ) + ELSE IF( EQ_16( GSC_noisy_speech, 1 ) ) { SWB_bit_budget = *bit; /*Q0*/ move32(); nb_bands = 5; move16(); - -#if 1 // def ADD_LRTD - - // fzero_val = 0.0f; fzero_val = 0; move16(); @@ -281,8 +271,6 @@ void bands_and_bit_alloc_ivas_fx( move16(); } -#endif - st_band = nb_bands; move16(); @@ -298,11 +286,10 @@ void bands_and_bit_alloc_ivas_fx( move16(); max_ener_band[j] = i; move16(); - // ener_vec[i] = 0; ener_vec[i] = fzero_val; move16(); } -#if 1 // def ADD_LRTD + IF( LT_16( bwidth, SWB ) ) { test(); @@ -311,17 +298,15 @@ void bands_and_bit_alloc_ivas_fx( nb_tot_bands = 5; move16(); } -#endif + FOR( ; j < nb_bands; j++ ) { i = maximum_fx( ener_vec, nb_tot_bands, &etmp ); max_ener_band[j] = i; move16(); - // ener_vec[i] = 0; ener_vec[i] = fzero_val; move16(); } -#if 1 // def ADD_LRTD } ELSE { @@ -334,7 +319,7 @@ void bands_and_bit_alloc_ivas_fx( move16(); } } -#endif + set32_fx( bits_per_bands, bit_fracf, nb_bands ); } ELSE @@ -349,7 +334,7 @@ void bands_and_bit_alloc_ivas_fx( move16(); st_band = 7; move16(); -#if 1 // def ADD_LRTD + test(); IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) ) { @@ -362,7 +347,7 @@ void bands_and_bit_alloc_ivas_fx( bit_new_bands = 5; move16(); } -#endif + IF( LE_32( core_brate, ACELP_9k60 ) ) { *pvq_len = 80; @@ -384,9 +369,8 @@ void bands_and_bit_alloc_ivas_fx( } nb_bands = shr( *pvq_len, 4 ); -#if 1 // def ADD_LRTD nb_bands_max = s_min( nb_bands_max, MBANDS_GN_BITALLOC16k ); -#endif + /*------------------------------------------------------------------------ * Ajustement of the maximum number of bands in function of the * dynamics of the spectrum (more or less speech like) @@ -398,7 +382,6 @@ void bands_and_bit_alloc_ivas_fx( IF( coder_type == INACTIVE || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) { /* Probably classification error -> concentrate bits on LF */ -#if 1 // def ADD_LRTD IF( EQ_16( L_frame, L_FRAME16k ) && GE_32( core_brate, ACELP_24k40 ) ) { nb_bands_max = sub( nb_tot_bands, 2 ); @@ -407,9 +390,7 @@ void bands_and_bit_alloc_ivas_fx( { nb_bands_max = add( nb_bands, 2 ); } - ELSE -#endif - IF( GE_32( core_brate, ACELP_8k00 ) ) + ELSE IF( GE_32( core_brate, ACELP_8k00 ) ) { nb_bands_max = add( nb_bands, 1 ); } @@ -428,7 +409,7 @@ void bands_and_bit_alloc_ivas_fx( { nb_bands_max = sub( nb_bands_max, 1 ); } -#if 1 // def ADD_LRTD + IF( EQ_16( L_frame, L_FRAME16k ) ) { IF( LT_32( core_brate, ACELP_24k40 ) ) @@ -450,7 +431,6 @@ void bands_and_bit_alloc_ivas_fx( } } -#endif test(); if ( ( bwidth == NB ) && GT_16( nb_bands_max, 10 ) ) { @@ -472,7 +452,7 @@ void bands_and_bit_alloc_ivas_fx( /*------------------------------------------------------------------------ * Fractional bits to distribute on the first x bands *-----------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) ) { @@ -480,10 +460,10 @@ void bands_and_bit_alloc_ivas_fx( move32(); } ELSE -#endif { bit_fracf = Find_bit_frac_fx( st_band, bit_tmp ); /*Q18*/ } + /*------------------------------------------------------------------------ * Complete the bit allocation per frequency band *-----------------------------------------------------------------------*/ @@ -501,13 +481,12 @@ void bands_and_bit_alloc_ivas_fx( move32(); /* Q18 */ bit_index = add( bit_index, 1 ); } -#if 1 // def ADD_LRTD + IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) ) { bit_index = 0; move16(); i = sub( imax, 1 ); - // bits_per_bands[i] += Compl_GSC_freq_bits[bit_index]; bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( Compl_GSC_freq_bits[bit_index], Q18 ) ); /*Q18*/ move32(); i = add( i, 1 ); @@ -515,13 +494,12 @@ void bands_and_bit_alloc_ivas_fx( FOR( ; i < 10; i++ ) { - // bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf; bits_per_bands[i] = L_add( bits_per_bands[i], L_add( L_shl( Compl_GSC_freq_bits[bit_index], Q18 ), bit_fracf ) ); /*Q18*/ move32(); bit_index = add( bit_index, 1 ); } } -#endif + IF( Diff_len == 0 ) { bit_index = add( bit_index_mem, 10 ); @@ -532,7 +510,7 @@ void bands_and_bit_alloc_ivas_fx( bit_index = add( bit_index, 1 ); } } -#if 1 // def ADD_LRTD + IF( bit_fracf < 0 ) { FOR( j = 0; j < nb_tot_bands; j++ ) @@ -542,39 +520,33 @@ void bands_and_bit_alloc_ivas_fx( } } -#endif /*-------------------------------------------------------------------------- * Complete the bit allocation per frequency band for 16kHz high brate mode *--------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) ) { FOR( j = st_band; j < nb_bands; j++ ) { - // bits_per_bands[j] = bit_new_bands; bits_per_bands[j] = L_shl( bit_new_bands, Q18 ); move32(); } - // bit_fracf = (1.0f / nb_bands) * (bit_tmp); bit_fracf = L_shl( L_mult0( idiv1616( 16384, nb_bands ), bit_tmp ), 4 ); /*Q18*/ - // etmp = 2.0f * bit_fracf / (nb_bands + 1); - etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); // Q15 - // bit_fracf = etmp; - bit_fracf = L_shl( etmp, Q3 ); // Q18 + etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); /* Q15 */ + + bit_fracf = L_shl( etmp, Q3 ); /* Q18 */ + FOR( j = nb_bands - 1; j >= 0; j-- ) { - // bits_per_bands[j] = etmp; - // etmp += bit_fracf; - bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); // Q18 + bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); /* Q18 */ move32(); etmp = extract_l( L_add( etmp, L_shr( bit_fracf, Q3 ) ) ); } } ELSE -#endif { FOR( j = st_band; j < nb_bands; j++ ) { @@ -688,6 +660,7 @@ void bands_and_bit_alloc_ivas_fx( } } } + /*-------------------------------------------------------------------------- * Bit sum verification for GSC inactive at very high rate * The maximum number of bits per band of length 16 is 112 @@ -724,19 +697,20 @@ void bands_and_bit_alloc_ivas_fx( move32(); /* Q18 */ } } + /*-------------------------------------------------------------------------- * second step of bit sum verification, normally sum_bit == *bit *--------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + sum_bit = 0; move32(); FOR( i = 0; i < nb_bands; i++ ) { - // bits_per_bands[i] = (float)floor(bits_per_bands[i]); bits_per_bands[i] = L_shl( L_shr( bits_per_bands[i], Q18 ), Q18 ); move32(); sum_bit = L_add( sum_bit, L_shr( bits_per_bands[i], Q18 ) ); /*Q0*/ } + test(); IF( GSC_IVAS_mode != 0 && LT_32( sum_bit, *bit ) ) /* If we need to add bits, we are doing it on the LF */ { @@ -755,23 +729,7 @@ void bands_and_bit_alloc_ivas_fx( w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ } tmp = shl( *bit, 3 ); -#else - IF( GT_16( tmp, w_sum_bit ) ) - { - i = sub( nb_bands, 1 ); - move16(); - FOR( ; tmp > w_sum_bit; w_sum_bit += ( 1 << 3 ) ) - { - out_bits_per_bands[i] = add( out_bits_per_bands[i], 1 << 3 ); - move16(); - i = sub( i, 1 ); - IF( i == 0 ) - { - i = sub( nb_bands, 1 ); - } - } - } -#endif + /*-------------------------------------------------------------------------- * Recompute the real number/length of frequency bands to encode *--------------------------------------------------------------------------*/ @@ -790,7 +748,6 @@ void bands_and_bit_alloc_ivas_fx( Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 ); } } -#if 1 // def ADD_LRTD } ELSE /* *bit == 0 */ { @@ -800,10 +757,11 @@ void bands_and_bit_alloc_ivas_fx( *pvq_len = 0; move16(); } -#endif + return; } -#if 1 // def ADD_LRTD + + /*-------------------------------------------------------------------* * reajust_bits() * @@ -924,26 +882,28 @@ static Word32 Find_bit_frac_fx( return ( L_out ); } -static Word16 Find_bit_alloc_IVAS_fx( /*o: Number of band to encode */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/ - const Word16 nb_tot_bands_in, /* i : total number of band */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - Word16 *max_ener_band, /* i/o: Energy based sorted order */ - Word16 *ener_vec, /* i/o: Energy per band order */ - Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband Q18 */ + +/* o : Number of band to encode */ +static Word16 Find_bit_alloc_IVAS_fx( + const Word32 core_brate, /* i : core bit rate */ + const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ + const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/ + const Word16 nb_tot_bands_in, /* i : total number of band */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + Word16 *max_ener_band, /* i/o: Energy based sorted order */ + Word16 *ener_vec, /* i/o: Energy per band order */ + Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband Q18 */ ) { Word32 mp, mb, nb_bands_adj, bit_adj; Word16 nb_pulse_per_band[MBANDS_GN_BITALLOC16k]; - Word32 SWB_bit_budget; // Q0 -> Q18 + Word32 SWB_bit_budget; /* Q0 -> Q18 */ Word16 i, j, nb_bands_max, st_band, nb_tot_bands_loc, etmp; Word32 sum_bit /*Q18*/, bit_fracf /*Q18*/; Word16 d_tmp, e_div, tmp16; Word32 Ltmp, etmp_32fx; - SWB_bit_budget = *bit; // Q0 + SWB_bit_budget = *bit; /* Q0 */ st_band = 5; nb_bands_max = nb_tot_bands_in; @@ -993,12 +953,12 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number IF( EQ_16( GSC_IVAS_mode, 1 ) && LT_32( core_brate, GSC_L_RATE_STG ) ) { /* nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;*/ - nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, Q18 ) ), Q18_0_75 ); // Q18 + nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, Q18 ) ), Q18_0_75 ); /* Q18 */ } ELSE IF( NE_16( GSC_IVAS_mode, 2 ) && GT_32( core_brate, GSC_H_RATE_STG ) ) { /*nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;*/ - nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, Q18 ) ), Q18_1_2 ); // Q18 + nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, Q18 ) ), Q18_1_2 ); /* Q18 */ } /*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/ @@ -1131,7 +1091,7 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number move32(); } mb = L_sub( mb, bit_fracf ); - SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); // Q18 + SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); /* Q18 */ } } @@ -1192,17 +1152,23 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number move32(); } } + return nb_tot_bands_loc; } -static Word16 Find_norm_inv_fx( const Word32 ToDivide, Word16 *e_div ) /* Find normalized 1 / ToDivide */ + +/* Find normalized 1 / ToDivide */ +static Word16 Find_norm_inv_fx( + const Word32 ToDivide, + Word16 *e_div ) { Word16 d_tmp, e_tmp; + e_tmp = norm_l( ToDivide ); d_tmp = round_fx( L_shl( ToDivide, e_tmp ) ); d_tmp = div_s( 16384, d_tmp ); /* 1.0 in Q14, dividend is normalize so >= 16384 as required for the division */ *e_div = sub( 14, e_tmp ); move16(); + return d_tmp; } -#endif diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index d2a576dbe..2e00e4641 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -793,7 +793,6 @@ void highband_exc_dct_in_fx( { IF( exc_diffQ[i] == 0 ) { - // PMT("code below to be validated for IVAS use") /* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/ tmp = mult( shl( noisepb[0], 1 ), Random( seed_tcx ) ); /*Q15 */ tmp = shr( tmp, sub( 15, Qexc_diffQ ) ); /*qNoise_fac */ @@ -876,66 +875,7 @@ void highband_exc_dct_in_fx( /*--------------------------------------------------------------------------------------* * Apply decoded gain onto the difference signal *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( GSC_IVAS_mode >= 1 ) - { - float scale_factLF = 0.9f; - float scale_factHF = 0.9f; - - if ( GSC_IVAS_mode == 1 && GSC_noisy_speech == 0 ) - { - scale_factHF = 0.8f; - } - else if ( GSC_IVAS_mode == 2 || GSC_noisy_speech == 1 ) - { - scale_factHF = 0.71f; - } - else if ( GSC_IVAS_mode == 3 ) - { - scale_factHF = 0.9f; - } - for ( i = 0; i < pit_band_idx * 16; i++ ) - { - exc_diffQ[i] *= scale_factLF; - } - for ( ; i < L_frame; i++ ) - { - exc_diffQ[i] *= scale_factHF; - } - } - else if ( GSC_noisy_speech ) - { - float scale_fact = 0.9f; - - if ( element_mode == IVAS_CPE_TD ) - { - if ( coder_type == INACTIVE ) - { - scale_fact = 1.0f; - } - else - { - scale_fact = 0.95f; - } - } - else if ( element_mode > IVAS_SCE ) - { - scale_fact = 0.71f; - } - for ( i = 0; i < L_frame; i++ ) - { - exc_diffQ[i] *= scale_fact; - } - } - if ( GSC_noisy_speech && element_mode > IVAS_SCE && core_brate < ACELP_7k20 ) - { - for ( i = 80; i < L_frame; i++ ) - { - exc_diffQ[i] *= ( +0.0024f * (float) i + 1.192f ); - } - } -#else IF( GSC_noisy_speech ) { FOR( i = 0; i < L_frame; i++ ) @@ -944,7 +884,7 @@ void highband_exc_dct_in_fx( move16(); } } -#endif + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); IF( exc_wo_nf != NULL ) @@ -1232,7 +1172,6 @@ void highband_exc_dct_in_ivas_fx( { IF( exc_diffQ[i] == 0 ) { - // PMT("code below to be validated for IVAS use") /* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/ tmp = mult( shl( noisepb[0], 1 ), Random( seed_tcx ) ); /*Q15 */ tmp = shr( tmp, sub( 15, Qexc_diffQ ) ); /*qNoise_fac */ @@ -1313,105 +1252,86 @@ void highband_exc_dct_in_ivas_fx( } } } + /*--------------------------------------------------------------------------------------* * Apply decoded gain onto the difference signal *--------------------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + IF( GSC_IVAS_mode >= 1 ) { - // float scale_factLF = 0.9f; - Word16 scale_factLF = 29491; + Word16 scale_factLF = 29491; /* 0.9f */ move16(); - // float scale_factHF = 0.9f; - Word16 scale_factHF = 29491; + Word16 scale_factHF = 29491; /* 0.9f */ move16(); test(); test(); IF( EQ_16( GSC_IVAS_mode, 1 ) && GSC_noisy_speech == 0 ) { - // scale_factHF = 0.8f; scale_factHF = 26214; move16(); } ELSE IF( EQ_16( GSC_IVAS_mode, 2 ) || EQ_16( GSC_noisy_speech, 1 ) ) { - // scale_factHF = 0.71f; - scale_factHF = 23265; + scale_factHF = 23265; /* 0.71f */ move16(); } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) ) { - // scale_factHF = 0.9f; - scale_factHF = 29491; + scale_factHF = 29491; /* 0.9f */ move16(); } FOR( i = 0; i < pit_band_idx * 16; i++ ) { - // exc_diffQ[i] *= scale_factLF; exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factLF ); } FOR( ; i < L_frame; i++ ) { - // exc_diffQ[i] *= scale_factHF; exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factHF ); move16(); } } ELSE IF( GSC_noisy_speech ) { - // float scale_fact = 0.9f; - Word16 scale_fact = 29491; + Word16 scale_fact = 29491; /* 0.9f */ move16(); IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { IF( coder_type == INACTIVE ) { - // scale_fact = 1.0f; - scale_fact = 32767; + scale_fact = 32767; /* 1.0f */ move16(); } ELSE { - // scale_fact = 0.95f; - scale_fact = 31129; + scale_fact = 31129; /* 0.95f */ move16(); } } ELSE IF( GT_16( element_mode, IVAS_SCE ) ) { - // scale_fact = 0.71f; - scale_fact = 23265; + scale_fact = 23265; /* 0.71f */ move16(); } FOR( i = 0; i < L_frame; i++ ) { - // exc_diffQ[i] *= scale_fact; exc_diffQ[i] = mult_r( exc_diffQ[i], scale_fact ); move16(); } } + IF( GSC_noisy_speech && GT_16( element_mode, IVAS_SCE ) && LT_32( core_brate, ACELP_7k20 ) ) { FOR( i = 80; i < L_frame; i++ ) { - // exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f); + /* exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f); */ exc_diffQ[i] = mult_r( shl( exc_diffQ[i], 1 ) /*Q16*/, (Word16) L_shr( L_add( 629 * i, 312475 ) /*Q18*/, Q4 ) /*Q14*/ ); move16(); } } -#else - IF( GSC_noisy_speech ) - { - FOR( i = 0; i < L_frame; i++ ) - { - exc_diffQ[i] = mult_r( exc_diffQ[i], 29491 ); - move16(); - } - } -#endif + Word16 Q_tmp = *Q_exc; move16(); Word16 Q_old = *Q_exc; diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 9d905bcf2..2e9e5eb96 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -154,13 +154,8 @@ void pre_echo_att_fx( * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ - etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ -#ifdef ADD_LRTD - PMTE() + etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#else - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#endif *Last_frame_ener_fx = etmp_fx; move32(); /*2*Q_new+1*/ } diff --git a/lib_com/options.h b/lib_com/options.h index 7d65c5eac..f2014f019 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -67,14 +67,11 @@ #define BASOP_NOGLOB_DECLARE_LOCAL #endif -#define IVAS_FLOAT_FIXED #define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */ #define MSAN_FIX #define FIX_TMP_714 #define BASOP_NOGLOB_TMP_715 #define EVS_FUNC_MODIFIED -//#define EVS_FLOAT_ENC -#define IVAS_CNST #define REMOVE_IVAS_UNUSED_PARAMETERS_WARNING /*temporary operation on unused EVS parameters to remove warnings, these parameters will be used in IVAS */ #define MOD_BIT_ALLOC_ROM_TABLE /* Just to highlight modification in bit allocation table and to ensure these modifications doesn't affect EVS modes*/ #define SIMPLIFY_CODE_BE // Simplify synthesis loop diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 5a6e24046..6f5519f68 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4866,24 +4866,18 @@ Word16 est_tilt_fx( /* o : tilt of the code const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#ifdef ADD_LRTD - , - const Word16 L_subfr /* i : Sub frame lenght */ -#endif ); -Word16 est_tilt_ivas_fx( /* o : tilt of the code Q15 */ - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#if 1 // def ADD_LRTD - , - const Word16 L_subfr, /* i : Sub frame length */ - const Word16 flag_tilt /* i : flag for special tilt */ -#endif +/* o : tilt of the code Q15 */ +Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr, /* i : Sub frame length */ + const Word16 flag_tilt /* i : flag for special tilt */ ); Word16 Est_tilt2( /* o : tilt of the code */ @@ -7127,30 +7121,21 @@ void dec_pit_exc_fx( const Word16 nb_subfr_fx /* i : Number of subframe considered */ , Word16 *gain_buf /*Q14*/ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); void dec_pit_exc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx /* i : Number of subframe considered */ - , - Word16 *gain_buf /*Q14*/ -#if 1 // def ADD_LRTD - , + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /*Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); // pit_dec_fx.c @@ -7205,28 +7190,24 @@ Word16 pit_decode_fx( /* o : floating pitch value Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ const Word16 L_subfr /* i : subframe length */ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); -Word16 pit_decode_ivas_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ +/* o : floating pitch value */ +Word16 pit_decode_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ ); void pit_Q_dec_fx( diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 6e0f7e716..968cc8359 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -639,25 +639,7 @@ void synth_mem_updt2( { lerp( old_exc + L_EXC_MEM - last_L_frame, old_exc + L_EXC_MEM - L_frame, L_frame, last_L_frame ); } -#ifdef ADD_LRTD - IF( EQ_16( dec, DEC_IVAS ) ) - { - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - /* find scaling factor */ - PME() - en1 = 1.25f * sum2_f( mem_syn2, M ); - en2 = sum2_f( mem_syn_r + L_SYN_MEM - M, M ); - loc_rat = sqrtf( en2 ) / ( sqrtf( en1 ) + 0.01f ); - /* scale synthesis filter memory */ - FOR( i = 0; i < M; i++ ) - { - mem_syn_r[L_SYN_MEM - M + i] *= loc_rat; - } - } - } -#endif /*Resamp memory*/ /*Size of LPC syn memory*/ /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 1b2207491..903a37163 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -107,9 +107,6 @@ ivas_error acelp_core_dec_fx( Word16 uc_two_stage_flag, dec; Word16 nb_bits, indice; Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; -#ifdef ADD_LRTD - Word16 *p_tdm_Pri_pitch_buf; -#endif MUSIC_POSTFILT_HANDLE hMusicPF; BPF_DEC_HANDLE hBPF; TD_BWE_DEC_HANDLE hBWE_TD; @@ -359,9 +356,6 @@ ivas_error acelp_core_dec_fx( tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; -#ifdef ADD_LRTD - p_tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; -#endif move16(); move16(); move16(); @@ -380,9 +374,6 @@ ivas_error acelp_core_dec_fx( move16(); } tdm_Pitch_reuse_flag = 0; -#ifdef ADD_LRTD - p_tdm_Pri_pitch_buf = NULL; -#endif move16(); } /*----------------------------------------------------------------* @@ -830,86 +821,10 @@ ivas_error acelp_core_dec_fx( /*-----------------------------------------------------------------* * LSF de-quantization and interpolation *-----------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( !tdm_lp_reuse_flag ) -#endif - { - lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, - tdm_lsfQ_PCh ); - } -#ifdef ADD_LRTD - else - { - const float *pt_interp_2; -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->active_cnt != 1 ) - { - int16_t beta_index; - beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS ); - tdm_SCh_lsf_reuse( DEC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, NULL, &beta_index ); - } - else - { - mvr2r( tdm_lspQ_PCh, lsp_new, M ); - mvr2r( tdm_lsfQ_PCh, lsf_new, M ); - } -#else - mvr2r( tdm_lspQ_PCh, lsp_new, M ); - mvr2r( tdm_lsfQ_PCh, lsf_new, M ); -#endif - if ( st->rate_switching_reset ) - { - /* extrapolation in case of unstable LSF convert */ - mvr2r( lsp_new, st->lsp_old, M ); - mvr2r( lsf_new, st->lsf_old, M ); - } - - pt_interp_2 = interpol_frac_12k8; - if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) - { - pt_interp_2 = interpol_frac2; - } + lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, + tdm_lsfQ_PCh ); - if ( st->active_cnt == 1 ) - { - mvr2r( lsp_new, st->lsp_old, M ); - lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core ); - } - - /* LSP interpolation and conversion of LSPs to A(z) */ - int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 ); - /* Check LSF stability (distance between old LSFs and current LSFs) */ - st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame ); - } - - if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory from last HQ frame */ - old_exc_s = st->old_exc + L_EXC_MEM_DEC - st->L_frame; - tmpF = *old_exc_s; - st->mem_deemph = old_exc_s[st->L_frame - 1]; - preemph( old_exc_s, st->preemph_fac, L_FRAME16k, &tmpF ); - mvr2r( old_exc_s + st->L_frame - M, st->mem_syn2, M ); - residu( Aq, M, old_exc_s, old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame ); - } - if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory of old_bwe_exc */ -#ifdef CR_FIX_639_HQ_ACELP_TRANSITION - if ( st->L_frame == L_FRAME ) - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); - } - else - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); - } -#else - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); -#endif - } -#endif /*-----------------------------------------------------------------* * FEC - first good frame after lost frame(s) (possibility to correct the ACB) *-----------------------------------------------------------------*/ @@ -979,27 +894,7 @@ ivas_error acelp_core_dec_fx( test(); test(); -#ifdef ADD_LRTD - IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ - { - IF( LE_16( st_fx->coder_type, UNVOICED ) ) - { - tdm_low_rate_dec( st_fx, dct_exc_tmp, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new ); - } - ELSE /* GENERIC */ - { - decod_gen_2sbfr( st_fx, sharpFlag, Aq, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); - - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - tmp_noise = st_fx->lp_gainc_fx; - move16(); - } - } - } - else -#endif - IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) + IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) { /* SC-VBR - NELP frames */ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 @@ -1033,12 +928,7 @@ ivas_error acelp_core_dec_fx( } ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { - decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf -#ifdef ADD_LRTD - , - tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf -#endif - ); + decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf ); tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ } ELSE @@ -1676,10 +1566,7 @@ ivas_error acelp_core_dec_fx( move16(); } } -#ifdef ADD_LRTD - /* analyze pitch coherence for bass post-filter */ - bpf_pitch_coherence( st, pitch_buf ); -#endif + test(); IF( !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->bpf_off ) ) { diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 5c16bc3e9..9597a97ae 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1100,12 +1100,8 @@ ivas_error acelp_core_dec_ivas_fx( ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ - decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx -#if 1 // def ADD_LRTD - , - tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx -#endif - ); + decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, + tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } ELSE diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 52c3e3073..f984f2ce9 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1164,8 +1164,6 @@ ivas_error core_switching_post_dec_fx( error = IVAS_ERR_OK; move32(); - // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ") - /* Rescale synthesis in Q0 to avoid multiple rescaling after */ tmp = Find_Max_Norm16( synth, output_frame ); Scale_sig( synth, output_frame, tmp ); @@ -1560,8 +1558,6 @@ ivas_error core_switching_post_dec_ivas_fx( error = IVAS_ERR_OK; move32(); - // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ") - /* Rescale synthesis in Q0 to avoid multiple rescaling after */ tmp = Find_Max_Norm16( synth, output_frame ); Scale_sig( synth, output_frame, tmp ); /* Qsynth + tmp */ diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index baea98a2c..415b4584e 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -71,12 +71,8 @@ void decod_amr_wb_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR -#ifdef ADD_LRTD - , - 0, NULL -#endif - ); + *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); + /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 4e18eebce..746b66819 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -41,11 +41,6 @@ void dec_pit_exc_fx( const Word16 nb_subfr_fx /* i : Number of subframe considered */ , Word16 *gain_buf /*Q14*/ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ @@ -179,12 +174,7 @@ void dec_pit_exc_fx( /*----------------------------------------------------------------------* * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx -#ifdef ADD_LRTD - , - tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf -#endif - ); + *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx ); move16(); /*--------------------------------------------------------------* @@ -207,12 +197,7 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#ifdef ADD_LRTD - , - L_subfr_fx -#endif - ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 ); move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ @@ -225,12 +210,7 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#ifdef ADD_LRTD - , - L_subfr_fx -#endif - ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 ); move16(); } ELSE @@ -457,22 +437,18 @@ void dec_pit_exc_fx( /* _ None */ /*==========================================================================*/ void dec_pit_exc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx /* i : Number of subframe considered */ - , - Word16 *gain_buf /*Q14*/ -#if 1 // def ADD_LRTD - , + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /*Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ @@ -591,9 +567,11 @@ void dec_pit_exc_ivas_fx( set16_fx( st_fx->acelp_cfg.pitch_bits, 9, 4 ); set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, 5 ); } + /*------------------------------------------------------------------* * ACELP subframe loop *------------------------------------------------------------------*/ + p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */ pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */ pt_gain = gain_buf; /* pointer to the gain buffer */ @@ -602,12 +580,8 @@ void dec_pit_exc_ivas_fx( /*----------------------------------------------------------------------* * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx -#if 1 // def ADD_LRTD - , - tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf -#endif - ); + + *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); move16(); /*--------------------------------------------------------------* @@ -623,6 +597,7 @@ void dec_pit_exc_ivas_fx( IF( EQ_16( use_fcb, 1 ) ) { inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); + /*--------------------------------------------------------------* * Gain decoding * Estimate spectrum tilt and voicing @@ -630,18 +605,14 @@ void dec_pit_exc_ivas_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#if 1 // def ADD_LRTD - , - L_subfr_fx, 0 -#endif - ); + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ { /*inov_decode_fx(st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx);*/ inov_decode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, 0, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); + /*--------------------------------------------------------------* * Gain decoding * Estimate spectrum tilt and voicing @@ -649,12 +620,7 @@ void dec_pit_exc_ivas_fx( gain_dec_lbr_ivas_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#if 1 // def ADD_LRTD - , - L_subfr_fx, 0 -#endif - ); + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); move16(); } ELSE diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 945e149f2..5a12d1a2c 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -333,7 +333,7 @@ ivas_error evs_dec_fx( /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ - // PMT("core_switching_pre_dec_fx missign args") + IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) { return error; @@ -346,7 +346,6 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ - IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) { return error; @@ -356,12 +355,11 @@ ivas_error evs_dec_fx( } ELSE { - // PMT("HQ core missing args") - hq_core_dec_fx( st_fx, synth_fx, &Q_synth, output_frame, hq_core_type, core_switching_flag ); Qpostd = Q_synth; move16(); } + /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ @@ -382,7 +380,6 @@ ivas_error evs_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ - /// PMT("bw_switching_pre_proc_fx missing args") bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); /*---------------------------------------------------------------------* @@ -1372,7 +1369,7 @@ ivas_error evs_dec_fx( /*----------------------------------------------------------------* * Save synthesis for HQ FEC *----------------------------------------------------------------*/ - // PMT("The code below could be move to save_synthesis_hq_fec") + post_hq_delay = NS2SA_FX2( st_fx->output_Fs, POST_HQ_DELAY_NS ); IF( EQ_16( st_fx->codec_mode, MODE1 ) ) { diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 3a39f9e33..a80cfe796 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -75,12 +75,7 @@ void decod_audio_fx( /* decode GSC SWB speech flag */ test(); -#if !defined ADD_LRTD IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) ) -#else - if ( st_fx->GSC_IVAS_mode >= 1 || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20 ) || - ( st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k ) ) ) ) -#endif { st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ move16(); @@ -98,30 +93,17 @@ void decod_audio_fx( } /* set bit-allocation */ -#ifdef ADD_LRTD -#ifdef NONBE_FIX_GSC_BSTR - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#else - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif -#else #ifdef NONBE_FIX_GSC_BSTR config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif #endif /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ -#if defined ADD_LRTD - test(); - test(); - IF( st_fx->GSC_IVAS_mode >= 1 || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) ) -#else + IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) -#endif { nb_subfr = NB_SUBFR; /* Q0 */ move16(); @@ -129,25 +111,6 @@ void decod_audio_fx( move16(); hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); -#ifdef ADD_LRTD - if ( st_fx->GSC_IVAS_mode >= 1 ) - { - if ( st_fx->core_brate < GSC_L_RATE_STG && st_fx->GSC_IVAS_mode < 3 ) - { - nb_subfr = 2; - } - hGSCDec->noise_lev = NOISE_LEVEL_SP2; - - if ( st_fx->GSC_IVAS_mode == 3 ) /* Music like */ - { - hGSCDec->noise_lev = NOISE_LEVEL_SP0; - } - else if ( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */ - { - hGSCDec->noise_lev = NOISE_LEVEL_SP3; - } - } -#endif } ELSE { @@ -165,54 +128,30 @@ void decod_audio_fx( /*---------------------------------------------------------------* * Decode number of subframes *---------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( st_fx->L_frame == L_FRAME16k && ( st_fx->core_brate <= ACELP_13k20 || st_fx->coder_type == INACTIVE ) ) - { - hGSCDec->cor_strong_limit = 0; - nb_subfr = 1; - } - else -#endif + + + hGSCDec->cor_strong_limit = 1; /* Q0 */ + move16(); + nb_subfr = SWNB_SUBFR; + move16(); + + IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) { - hGSCDec->cor_strong_limit = 1; /* Q0 */ + nbits = 1; move16(); - nb_subfr = SWNB_SUBFR; + nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); - IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) + IF( s_and( nb_frame_flg, 0x1 ) == 0 ) { - nbits = 1; + nb_subfr = 2 * SWNB_SUBFR; /* Q0 */ move16(); -#ifdef ADD_LRTD - if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR ) - { - nbits = 2; - } -#endif - nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ + hGSCDec->cor_strong_limit = 0; move16(); - - IF( s_and( nb_frame_flg, 0x1 ) == 0 ) - { - nb_subfr = 2 * SWNB_SUBFR; /* Q0 */ - move16(); - hGSCDec->cor_strong_limit = 0; - move16(); - } -#ifdef ADD_LRTD - else if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR ) - { - nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */ - } - - if ( ( nb_frame_flg >> 1 ) == 1 ) - { - nb_subfr *= 2; - } -#endif } } } + /*---------------------------------------------------------------* * Decode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ @@ -282,13 +221,7 @@ void decod_audio_fx( * Decode adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ test(); -#ifdef ADD_LRTD - if ( !( st_fx->GSC_IVAS_mode > 0 && st_fx->L_frame / nb_subfr == 2 * L_SUBFR && st_fx->GSC_IVAS_mode < 3 ) && - ( ( st_fx->core_brate >= MIN_RATE_FCB || st_fx->GSC_noisy_speech ) && - ( ( nb_subfr == NB_SUBFR && st_fx->L_frame == L_FRAME ) || ( nb_subfr == NB_SUBFR16k && st_fx->L_frame == L_FRAME16k ) ) ) ) -#else IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) ) -#endif { Word16 indice; nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ @@ -303,11 +236,9 @@ void decod_audio_fx( Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } -#ifdef ADD_LRTD - dec_pit_exc_fx( st_fx, Aq, coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); -#else + dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf ); -#endif + IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); @@ -449,29 +380,12 @@ void decod_audio_fx( tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } - - test(); -#if defined ADD_LRTD - test(); - if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) -#else test(); if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) ) -#endif { tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ } -#ifdef ADD_LRTD - IF( EQ_16( st_fx->idchan, 1 ) ) - { - tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); - IF( EQ_16( st_fx->tdm_LRTD_flag, 1 ) ) - { - tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); - } - } -#endif gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); /*--------------------------------------------------------------------------------------* * iDCT transform @@ -612,26 +526,19 @@ void decod_audio_ivas_fx( } /* set bit-allocation */ -#if 1 // def ADD_LRTD #ifdef NONBE_FIX_GSC_BSTR config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif -#else - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ -#if 1 // defined ADD_LRTD + test(); test(); IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) ) -#else - IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) -#endif { nb_subfr = NB_SUBFR; /* Q0 */ move16(); @@ -639,7 +546,7 @@ void decod_audio_ivas_fx( move16(); hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); -#if 1 // def ADD_LRTD + IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) ) { test(); @@ -662,7 +569,6 @@ void decod_audio_ivas_fx( move16(); } } -#endif } ELSE { @@ -680,7 +586,7 @@ void decod_audio_ivas_fx( /*---------------------------------------------------------------* * Decode number of subframes *---------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); test(); IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || st_fx->coder_type == INACTIVE ) ) @@ -691,7 +597,6 @@ void decod_audio_ivas_fx( move16(); } ELSE -#endif { hGSCDec->cor_strong_limit = 1; /* Q0 */ move16(); @@ -702,14 +607,14 @@ void decod_audio_ivas_fx( { nbits = 1; /* Q0 */ move16(); -#if 1 // def ADD_LRTD + test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) ) { nbits = 2; /* Q0 */ move16(); } -#endif + nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); @@ -721,7 +626,6 @@ void decod_audio_ivas_fx( hGSCDec->cor_strong_limit = 0; move16(); } -#if 1 // def ADD_LRTD ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) ) { nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */ @@ -732,18 +636,17 @@ void decod_audio_ivas_fx( { nb_subfr = shl( nb_subfr, 1 ); /* Q0 */ } -#endif } } } -#if 1 + test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) ) { nb_subfr = NB_SUBFR16k; /* Q0 */ move16(); } -#endif + /*---------------------------------------------------------------* * Decode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ @@ -802,7 +705,6 @@ void decod_audio_ivas_fx( hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); - /*--------------------------------------------------------------------------------------* * Decode adaptive (pitch) excitation contribution * Reset unvaluable part of the adaptive (pitch) excitation contribution @@ -813,7 +715,6 @@ void decod_audio_ivas_fx( * Decode adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ test(); -#if 1 // def ADD_LRTD test(); test(); test(); @@ -824,9 +725,6 @@ void decod_audio_ivas_fx( IF( !( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( idiv1616( st_fx->L_frame, nb_subfr ), 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) && ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) && ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) ) -#else - IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) ) -#endif { Word16 indice; nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ @@ -841,11 +739,9 @@ void decod_audio_ivas_fx( Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } -#if 1 // def ADD_LRTD + dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); -#else - dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf ); -#endif + IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); @@ -989,17 +885,12 @@ void decod_audio_ivas_fx( test(); -#if 1 // defined ADD_LRTD test(); if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) -#else - if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) ) -#endif { tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ } -#if 1 // ydef ADD_LRTD IF( EQ_16( st_fx->idchan, 1 ) ) { tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); /* Q0 */ @@ -1008,7 +899,7 @@ void decod_audio_ivas_fx( tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); /* Q0 */ } } -#endif + Word16 Q_exc_old = st_fx->Q_exc; move16(); gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); @@ -1105,7 +996,6 @@ void gsc_dec_fx( Word16 Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; -#if 1 // def ADD_LRTD Word16 bitallocation_band[MBANDS_GN_BITALLOC16k]; Word16 bitallocation_exc[2]; Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; @@ -1113,15 +1003,6 @@ void gsc_dec_fx( Word16 exc_diffQ[L_FRAME16k]; Word16 bits_per_bands[MBANDS_GN_BITALLOC16k]; Word16 concat_out[L_FRAME16k]; -#else - Word16 bitallocation_band[MBANDS_GN]; - Word16 bitallocation_exc[2]; - Word16 Ener_per_bd_iQ[MBANDS_GN]; - Word16 max_ener_band[MBANDS_GN]; - Word16 exc_diffQ[L_FRAME]; - Word16 bits_per_bands[MBANDS_GN]; - Word16 concat_out[L_FRAME]; -#endif Word16 inpulses_fx[NB_SFM]; Word16 imaxpulse_fx[NB_SFM]; Word16 mean_gain; @@ -1145,22 +1026,7 @@ void gsc_dec_fx( *--------------------------------------------------------------------------------------*/ bit = bits_used; move16(); -#ifdef ADD_LRTD - test(); - test(); - test(); - test(); - IF( EQ_16( coder_type, INACTIVE ) && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) - { - bit = add( bit, GSC_LRES_NB_NITS ); - } - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Mbands_gn = MBANDS_GN16k; - move16(); - } -#endif set16_fx( exc_diffQ, 0, st_fx->L_frame ); /*--------------------------------------------------------------------------------------* @@ -1184,33 +1050,8 @@ void gsc_dec_fx( } ELSE { - -#ifdef ADD_LRTD - i = 0; - move16(); - While( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) - { - IF( LQ_32( st_fx->core_brate, brate_intermed_tbl[i] ) ) - { - break; - } - i = add( i, 1 ); - } - - test(); - test(); - test(); - test(); - IF( GT_16( st_fx->element_mode, EVS_MONO ) > &&EQ_16( coder_type, AUDIO ) && - LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */ - { - i--; - } - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); - -#else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */ -#endif + st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } @@ -1236,10 +1077,7 @@ void gsc_dec_fx( * reduce spectral dynamic * save spectrum *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - max_eq = 32767; - move16(); -#endif + test(); IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) ) { @@ -1270,12 +1108,6 @@ void gsc_dec_fx( max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -#ifdef ADD_LRTD - if ( bit == 0 ) - { - set16_fx( concact_out, 0, L_FRAME16k ); - } -#endif { pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ @@ -1283,17 +1115,6 @@ void gsc_dec_fx( seed_init = 0; move16(); -#ifdef ADD_LRTD - max_eq = 0.0f; - max_eq_val = 1.0f; - - if ( ( ( st_fx->core_brate < ACELP_7k20 && st_fx->GSC_noisy_speech == 1 ) || st_fx->core_brate < 6000 ) && coder_type <= UNVOICED ) - { - j = emaximum( concat_out, nb_subbands * 16, &max_eq ); - max_eq = (float) ( max_eq_val / ( fabs( concat_out[j] ) + 0.01f ) ); - max_eq = min( max_eq_val, max_eq ); - } -#endif /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { @@ -1350,34 +1171,8 @@ void gsc_dec_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - test(); - test(); - test(); - test(); - test(); - test(); - IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) - { - FOR( i = 64; i < st_fx->L_frame; i++ ) - { - PMT( "GSC FIX point to be done here" ) - exc_diffQ[i] *= max_eq; - } - } - ELSE IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) ) - { - FOR( i = 0; i < L_FRAME; i++ ) - { - PMT( "GSC FIX point to be done here" ) - exc_diffQ[i] *= max_eq; - } - } - else -#endif - { - freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); - } + + freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); } /*--------------------------------------------------------------------------------------* @@ -1432,7 +1227,6 @@ void gsc_dec_ivas_fx( Word16 *Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; -#if 1 // def ADD_LRTD Word16 bitallocation_band[MBANDS_GN_BITALLOC16k]; Word16 bitallocation_exc[2]; Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; @@ -1441,19 +1235,10 @@ void gsc_dec_ivas_fx( Word16 bits_per_bands[MBANDS_GN_BITALLOC16k]; Word16 concat_out[L_FRAME16k]; Word16 max_eq, max_eq_val; -#else - Word16 bitallocation_band[MBANDS_GN]; - Word16 bitallocation_exc[2]; - Word16 Ener_per_bd_iQ[MBANDS_GN]; - Word16 max_ener_band[MBANDS_GN]; - Word16 exc_diffQ[L_FRAME]; - Word16 bits_per_bands[MBANDS_GN]; - Word16 concat_out[L_FRAME]; -#endif Word16 inpulses_fx[NB_SFM]; Word16 imaxpulse_fx[NB_SFM]; Word16 mean_gain; - Word16 Mbands_gn = 16; + Word16 Mbands_gn = MBANDS_GN; Word16 Qexc_diffQ = Q_PVQ_OUT; Word32 L_tmp; Word16 Q_tmp; @@ -1461,8 +1246,8 @@ void gsc_dec_ivas_fx( GSC_DEC_HANDLE hGSCDec; hGSCDec = st_fx->hGSCDec; - move16(); // for Mbands_gn - move16(); // for Qexc_diffQ + move16(); /* for Mbands_gn */ + move16(); /* for Qexc_diffQ */ set16_fx( inpulses_fx, 0, NB_SFM ); set16_fx( imaxpulse_fx, 0, NB_SFM ); @@ -1471,7 +1256,7 @@ void gsc_dec_ivas_fx( *--------------------------------------------------------------------------------------*/ bit = bits_used; move16(); -#if 1 // def ADD_LRTD + test(); test(); test(); @@ -1485,7 +1270,7 @@ void gsc_dec_ivas_fx( Mbands_gn = MBANDS_GN16k; /* Q0 */ move16(); } -#endif + set16_fx( exc_diffQ, 0, st_fx->L_frame ); /*--------------------------------------------------------------------------------------* @@ -1509,8 +1294,6 @@ void gsc_dec_ivas_fx( } ELSE { - -#if 1 // def ADD_LRTD i = 0; move16(); WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) @@ -1532,9 +1315,6 @@ void gsc_dec_ivas_fx( } mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ -#else - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); -#endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } @@ -1560,17 +1340,17 @@ void gsc_dec_ivas_fx( * reduce spectral dynamic * save spectrum *--------------------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + max_eq = 32767; move16(); -#endif + test(); IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) ) { FOR( i = 0; i < st_fx->L_frame; i++ ) { L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/ - L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */ + L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /*Q10*/ hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ move16(); } @@ -1594,27 +1374,24 @@ void gsc_dec_ivas_fx( max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -#if 1 // def ADD_LRTD IF( bit == 0 ) { set16_fx( concat_out, 0, L_FRAME16k ); } -#endif - { - pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); + + pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); #ifdef MSAN_FIX - IF( nb_subbands > 0 ) - { - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ - } -#else + IF( nb_subbands > 0 ) + { Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ -#endif } +#else + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ +#endif + seed_init = 0; move16(); -#if 1 // def ADD_LRTD max_eq = 0; move16(); max_eq_val = 32767; /* 1.0f in Q15 */ @@ -1626,7 +1403,6 @@ void gsc_dec_ivas_fx( IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( coder_type, UNVOICED ) ) { j = maximum_fx( concat_out, imult1616( nb_subbands, 16 ), &max_eq ); - // max_eq = max_eq_val / (abs_s(concat_out[j]) + 328 /*0.01f*/ ); Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/; if ( LE_16( temp_max_eq, ONE_IN_Q10 ) ) { @@ -1641,7 +1417,7 @@ void gsc_dec_ivas_fx( max_eq = shl( max_eq, exp ); /* Q15 */ } } -#endif + /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { @@ -1701,7 +1477,7 @@ void gsc_dec_ivas_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); test(); test(); @@ -1710,8 +1486,6 @@ void gsc_dec_ivas_fx( { FOR( i = 64; i < st_fx->L_frame; i++ ) { - // PMT("GSC FIX point to be done here") - // exc_diffQ[i] *= max_eq; exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */ move16(); } @@ -1720,14 +1494,11 @@ void gsc_dec_ivas_fx( { FOR( i = 0; i < L_FRAME; i++ ) { - // PMT("GSC FIX point to be done here") - // exc_diffQ[i] *= max_eq; exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */ move16(); } } ELSE -#endif { freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); } @@ -1768,17 +1539,11 @@ void GSC_dec_init( move16(); move16(); -#ifdef ADD_LRTD - set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME16k ); - set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME16k ); - set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN_BITALLOC16k ); - set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN_BITALLOC16k ); -#else set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME ); set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME ); set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN ); set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN ); /*Q12*/ -#endif + hGSCDec->last_ener_fx = 0; move16(); set16_fx( hGSCDec->last_bitallocation_band, 0, 6 ); diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index ef65c4fcd..1ab1efe8f 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -113,7 +113,7 @@ void inov_decode_fx( move16(); bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0 move16(); - // PMT("CONDITION above is missing -> idchan") + FOR( i = 0; i < wordcnt; i++ ) { indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, 16 ) ); // Q0 @@ -298,7 +298,7 @@ void inov_decode_ivas_fx( move16(); bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0 move16(); - // PMT("CONDITION above is missing -> idchan") + FOR( i = 0; i < wordcnt; i++ ) { indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); // Q0 diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 50b5ec341..becf60759 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -664,12 +664,7 @@ void lsf_end_dec_fx( test(); test(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - test(); - IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) && ( st->idchan == 0 ) ) -#else IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) ) -#endif { /* this bit is used only for primary channel or mono */ coder_type = (Word16) get_next_indice_fx( st, 1 ); /* Q0 */ diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index b72c2bae1..1d3e96497 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -333,11 +333,6 @@ Word16 pit_decode_fx( /* o : floating pitch value Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ const Word16 L_subfr /* i : subframe length */ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 pitch; /*Q2*/ @@ -458,57 +453,6 @@ Word16 pit_decode_fx( /* o : floating pitch value pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } -#ifdef ADD_LRTD - ELSE IF( EQ_16( st_fx->idchan, 1 ) && ( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) ) - { - test(); - test(); - /*-------------------------------------------------------* - * Pitch decoding with reusing of primary channel information - *-------------------------------------------------------*/ - Word16 loc_T0, loc_frac, delta, pit_tmp1, pit_tmp2, isubfridx; - - delta = 4; - pit_flag = L_SUBFR; - move16(); - move16(); - isubfridx = shr( i_subfr, 6 ); - IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) - { - move16(); - move16(); - pit_tmp1 = tdm_Pri_pitch_buf[isubfridx]; /*tdm_Pri_pitch_buf in Q6 ->pit_tmp1 and 2 in Q6 too */ - pit_tmp2 = tdm_Pri_pitch_buf[shr( add( i_subfr, 1 ), 6 )]; - /*loc_T0 = (int16_t)(0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[(i_subfr + L_SUBFR) / L_SUBFR]);*/ - loc_T0 = mac_r( L_mult( 16384, pit_tmp1, 16384, pit_tmp2 ) ); - /*loc_frac = (int16_t)(((0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[(i_subfr + L_SUBFR) / L_SUBFR]) - loc_T0) * 4.0f);*/ - } - ELSE - { - /*loc_T0 = (int16_t)tdm_Pri_pitch_buf[i_subfr / L_SUBFR];*/ - loc_T0 = tdm_Pri_pitch_buf[isubfridx]; /*Q6*/ - /*loc_frac = (int16_t)((tdm_Pri_pitch_buf[i_subfr / L_SUBFR] - loc_T0) * 4.0f);*/ - } - loc_frac = shr(sub(loc_T0, shl(shr(loc_T0, 6), 6)), 4)); /* Final result in Q 2*/ - loc_T0 = shr( loc_T0, 6 ); /*Q6 -> Q0*/ - - - limit_T0_fx( L_FRAME, delta, pit_flag, *limit_flag, loc_T0, loc_frac, T0_min, T0_max ); - - IF( nBits > 0 ) - { - pit_Q_dec_fx( 0, pitch_index, nBits, delta, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - ELSE - { - *T0 = loc_T0; - *T0_frac = loc_frac; - move16(); - move16(); - } - printf( "function not tested yet\n" ); - } -#endif ELSE { /*-------------------------------------------------------* diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 3c1065c24..530cd41d0 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -529,32 +529,17 @@ typedef struct tcx_dec_structure typedef struct gsc_dec_structure { - Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill */ - - Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - // Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - - Word16 old_y_gain_fx[MBANDS_GN16k]; /* AC mode (GSC) - AR mem for low rate gain quantization */ - - Word16 noise_lev; /* AC mode (GSC) - noise level */ - // Word16 noise_lev; /* AC mode (GSC) - noise level Q0*/ - + Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill */ + Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ + Word16 old_y_gain_fx[MBANDS_GN16k]; /* AC mode (GSC) - AR mem for low rate gain quantization */ + Word16 noise_lev; /* AC mode (GSC) - noise level */ Word16 lt_ener_per_band_fx[MBANDS_GN16k]; /* Q12 */ - - Word32 Last_frame_ener_fx; /* AC mode (GSC) - last frame energy */ - - Word16 Last_GSC_spectrum_fx[L_FRAME16k]; /* AC mode (GSC) - Last good GSC spectrum */ - - Word16 Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index */ - // Word16 Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index Q0*/ - - Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ - - Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ - - Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ - // Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ - + Word32 Last_frame_ener_fx; /* AC mode (GSC) - last frame energy */ + Word16 Last_GSC_spectrum_fx[L_FRAME16k]; /* AC mode (GSC) - Last good GSC spectrum */ + Word16 Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index */ + Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ + Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ + Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ } GSC_DEC_DATA, *GSC_DEC_HANDLE; @@ -566,10 +551,8 @@ typedef struct gsc_dec_structure typedef struct WI_dec_structure { Word16 old_exc2_fx[L_EXC_MEM]; /* FEC - old excitation2 used in fast recovery */ - Word16 old_syn2_fx[L_EXC_MEM]; /* FEC - old syn speech used in fast recovery */ - } WI_DEC_DATA, *WI_DEC_HANDLE; diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index a294d12da..dcee88325 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -39,14 +39,10 @@ ivas_error acelp_core_enc_fx( Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits_fx, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new, - const Word16 shift -#ifdef ADD_LRTD - , - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif -) + const Word16 shift ) { Word16 nBits; /* reserved bits */ Word16 i; @@ -113,6 +109,8 @@ ivas_error acelp_core_enc_fx( * Initialization *------------------------------------------------------------------*/ + (void) tdm_lsfQ_PCh; + Es_pred_fx = 0; move16(); @@ -206,16 +204,14 @@ ivas_error acelp_core_enc_fx( /* TD stereo */ test(); -#ifdef ADD_LRTD IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; + tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf_fx; } ELSE -#endif { tdm_lp_reuse_flag = 0; tdm_low_rate_mode = 0; @@ -453,78 +449,8 @@ ivas_error acelp_core_enc_fx( if ( !tdm_lp_reuse_flag ) { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#else lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); -#endif } -#ifdef ADD_LRTD - else - { - const float *pt_interp_2; -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->active_cnt != 1 ) - { - int16_t beta_index; - float lsf_wgts[M]; - - /* intra_frame prediction for the LSFs */ - lsp2lsf( lsp_new, lsf_new, M, 12800 ); - - Unified_weighting( &st->Bin_E[L_FFT / 2], lsf_new, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M ); - - tdm_SCh_lsf_reuse( ENC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, lsf_wgts, &beta_index ); - - push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS ); - } -#endif - pt_interp_2 = interpol_frac_12k8; - if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) - { - pt_interp_2 = interpol_frac2; - } -#ifndef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->active_cnt == 1 ) - { - mvr2r( lsp_new, st->lsp_old, M ); - lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core ); - lsp2lsf( lsp_new, lsf_new, M, st->sr_core ); - } -#endif - /* LSP interpolation and conversion of LSPs to A(z) */ - int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 ); - - /* Check LSF stability (distance between old LSFs and current LSFs) */ - st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame ); - } - if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory from last HQ frame */ - tmpF = hLPDmem->old_exc[0]; - preemph( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF ); - mvr2r( hLPDmem->old_exc + st->L_frame - M, hLPDmem->mem_syn, M ); - residu( Aq, M, hLPDmem->old_exc, old_exc, st->L_frame ); - } - - if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory of old_bwe_exc */ -#ifdef CR_FIX_639_HQ_ACELP_TRANSITION - if ( st->L_frame == L_FRAME ) - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); - } - else - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); - } -#else - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); -#endif - } -#endif - /*---------------------------------------------------------------* * Calculation of LP residual (filtering through A[z] filter) @@ -566,26 +492,12 @@ ivas_error acelp_core_enc_fx( *------------------------------------------------------------*/ test(); test(); -#ifdef ADD_LRTD - if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */ + IF( hSC_VBR->nelp_mode ) { - if ( st->coder_type <= UNVOICED ) - { - tdm_low_rate_enc( st, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, 0 /*attack_flag*/, lsf_new, &tmp_noise ); - } - else /* GENERIC */ - { - encod_gen_2sbfr( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); - } + /* SC-VBR - NELP frames */ + encod_nelp_fx( st_fx, inp_fx, Aw_fx, Aq_fx, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf_fx, + voice_factors_fx, bwe_exc_fx, Q_new, shift ); } - else -#endif - IF( hSC_VBR->nelp_mode ) - { - /* SC-VBR - NELP frames */ - encod_nelp_fx( st_fx, inp_fx, Aw_fx, Aq_fx, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf_fx, - voice_factors_fx, bwe_exc_fx, Q_new, shift ); - } ELSE IF( EQ_16( coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ @@ -621,11 +533,8 @@ ivas_error acelp_core_enc_fx( st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#else lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); -#endif + /* recalculation of LP residual (filtering through A[z] filter) */ calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx ); diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 7188bcbad..15cc1a9e7 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -338,11 +338,7 @@ void CNG_enc_fx( } ELSE { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, NULL, Q_new ); -#else lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, Q_new ); -#endif } /* Reset CNG history if CNG frame length is changed */ test(); diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index e03db0c47..18948a93f 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -329,7 +329,7 @@ void enc_pit_exc_fx( inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); - // PMT("code to be validated") + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ @@ -811,10 +811,9 @@ void enc_pit_exc_ivas_fx( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); - // PMT("code to be validated") + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 0be344d72..2a621f1d5 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -115,10 +115,11 @@ void encod_unvoiced_fx( /*----------------------------------------------------------------* * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ - // PMT("The code below needs validation, never been tested") + /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); + /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 3005edd6e..6970597c8 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -282,12 +282,7 @@ ivas_error evs_enc_fx( IF( EQ_16( st->core, ACELP_CORE ) ) { acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag, - attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, Q_new, shift -#ifdef ADD_LRTD - , - NULL, NULL -#endif - ); + attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift ); } /*---------------------------------------------------------------------* * HQ core encoding diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 162fc41fa..f927940ae 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -2059,12 +2059,6 @@ void gain_enc_lbr_fx( move16(); /* Compute scalar product */ -#ifdef DEBUG - if ( L_subfr != L_SUBFR ) - { - PMT( "Entire function needs review to accommode for L_subfr > L_SUBFR" ); - } -#endif coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) ); move16(); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */ @@ -2272,15 +2266,11 @@ void gain_enc_lbr_fx( move16(); IF( EQ_16( nBits, 7 ) ) { -#ifdef IVAS_CODE cdbk = gp_gamma_3sfr_7b_fx; if ( clip_gain == 1 ) { size -= 28; } -#else - // PMT("gp_gamma_3sfr_7b_fx is missing") -#endif } ELSE { @@ -2375,15 +2365,11 @@ void gain_enc_lbr_fx( move16(); IF( EQ_16( nBits, 7 ) ) { -#ifdef IVAS_CODE cdbk = gp_gamma_4sfr_7b_fx; if ( clip_gain == 1 ) { size -= 25; } -#else - // PMT("gp_gamma_4sfr_7b_fx is missing") -#endif } ELSE { diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index a804c1311..8ed7e9d6c 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -785,10 +785,6 @@ void gsc_enc_fx( Word16 imaxpulse_fx[NB_SFM]; Word16 Q_tmp; Word16 seed_init; -#ifdef ADD_LRTD - Word16 max_eq_val; - Word32 max_eq; -#endif GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -896,18 +892,6 @@ void gsc_enc_fx( move16(); set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k ); -#ifdef ADD_LRTD - max_eq = 0; - max_eq_val = 1.0f; - - IF( ( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) ) || GE_16( st_fx->GSC_IVAS_mode, 1 ) ) - { - j = emaximum( concat_out, nb_subbands * 16, &max_eq ); - max_eq = max_eq_val / ( fabsf( concat_out[j] ) + 0.01f ); - max_eq = min( max_eq_val, max_eq ); - } -#endif - FOR( j = 0; j < nb_subbands; j++ ) { Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); /*Q12*/ @@ -963,26 +947,7 @@ void gsc_enc_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - test(); - test(); - test(); - IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) - { - FOR( i = 64; i < st->L_frame; i++ ) - { - exc_diffQ[i] *= max_eq; - } - } - ELSE IF( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) ) - { - FOR( i = 0; i < L_FRAME; i++ ) - { - exc_diffQ[i] *= max_eq; - } - } - else -#endif + { freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_PVQ_OUT, st_fx->L_frame ); } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index ca8b70ca2..5de4e8e92 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -35,9 +35,8 @@ ivas_error init_encoder_fx( move16(); ISM_MODE ism_mode = ISM_MODE_NONE; ivas_error error; - // PMT("ism_mode, idchan, vad_only_flag to be move to function header") - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; /*-----------------------------------------------------------------* * General signal buffers @@ -409,7 +408,7 @@ ivas_error init_encoder_fx( /*-----------------------------------------------------------------* * Noise estimator *-----------------------------------------------------------------*/ - // PMT("deal with idchan ") + test(); test(); IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index b4ca63bac..1f2fee684 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1410,9 +1410,6 @@ static ivas_error configureEncoder_fx( IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) { hIvasEnc->hCoreCoder = st_ivas->hSCE[0]->hCoreCoder[0]; /* Note: this is needed for switching in EVS mono */ - //#ifndef EVS_FLOAT_ENC - // hIvasEnc->hCoreCoder_fx = st_ivas->hSCE[0]->hCoreCoder_fx[0]; - //#endif } ELSE { diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 45a4e014a..de5e474a0 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -72,18 +72,12 @@ void lsf_enc_fx( const Word16 Nb_ACELP_frames, const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ) { Word16 nBits = 0; Word16 int_fs; Word16 force_sf = 0; Word16 fec_lsf[M], stab, i; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING - (void) tdm_low_rate_mode; -#endif #ifdef IVAS_CODE Word16 param_lpc[NPRM_LPC_NEW]; #endif @@ -191,13 +185,10 @@ void lsf_enc_fx( /*-------------------------------------------------------------------------------------* * Frame end LSF quantization *-------------------------------------------------------------------------------------*/ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, - force_sf, NULL, NULL, NULL, st_fx->coder_type_raw_fxtdm_lsfQ_PCh ); -#else + lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, force_sf, NULL, NULL, NULL, st_fx->coder_type_raw ); -#endif + /* convert quantized LSFs back to LSPs */ lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); @@ -296,11 +287,10 @@ void lsf_enc_fx( } /* LSP interpolation and conversion of LSPs to A(z) */ -#ifdef ADD_LRTD test(); IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) { - IF( EQ_16( st_fx->active_cnt_fx, 1 ) ) + IF( EQ_16( st_fx->active_cnt, 1 ) ) { Copy( lsp_mid, st_fx->lsp_old_fx, M ); lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, int_fs ); @@ -311,7 +301,6 @@ void lsf_enc_fx( int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); } ELSE -#endif { int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); } @@ -885,10 +874,6 @@ void lsf_end_enc_fx( Word16 *no_indices, Word16 *bits_param_lpc, Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif ) { Word16 i; @@ -922,10 +907,6 @@ void lsf_end_enc_fx( Word16 tmp; Word16 flag_1bit_gran; BSTR_ENC_HANDLE hBstr = st->hBstr; -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - Word16 pred3[M]; - Word16 dummy, dummy_v[5]; -#endif flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); @@ -935,11 +916,7 @@ void lsf_end_enc_fx( test(); test(); test(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) && ( st->idchan == 0 ) ) /* this bit is used only for primary channel or mono */ -#else IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) ) -#endif { IF( EQ_16( coder_type_raw, VOICED ) ) { @@ -1014,16 +991,7 @@ void lsf_end_enc_fx( pred1[i] = add( ModeMeans_fx[mode_lvq][i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) ); move16(); } -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - /* TD stereo SCh: perform intra-frame prediction with pulling-to-mean */ - if ( st->tdm_LRTD_flag == 0 && st->idchan == 1 && tdm_lsfQ_PCh != NULL ) - { - /* if secondary channel predmode is set to be > 2 */ - predmode += 3; - tdm_SCh_LSF_intra_pred( st->element_brate, tdm_lsfQ_PCh, pred3 ); - } -#endif IF( predmode == 0 ) { /* Subtract only mean */ @@ -1048,183 +1016,112 @@ void lsf_end_enc_fx( move16(); } ELSE -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - PMT( "LSF_RE_USE_SECONDARY_CHANNEL CODE IS MISSING " ) { - if ( predmode == 2 ) -#endif - { - /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in + /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ - test(); - test(); - test(); - IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) + test(); + test(); + test(); + IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) + { + /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ + st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); + move16(); + } + + IF( st->pstreaklen == 0 ) + { + /* reset the consecutive AR-predictor multiplier */ + st->streaklimit_fx = 32767; /*1.0 in Q15 */ + move16(); + } + + /* VOICED_WB@16kHz */ + test(); + IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) + { + /* Subtract mean and AR prediction */ + Copy( ModeMeans_fx[mode_lvq], pred0, M ); + /* subtract only mean */ + Vr_subt( lsf, pred0, Tmp, M ); + + FOR( i = 0; i < M; i++ ) { - /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); - move16(); + /* subtract mean and AR prediction */ + pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ); + Tmp2[i] = sub( Tmp[i], pred2[i] ); + pred2[i] = add( pred2[i], pred0[i] ); } - IF( st->pstreaklen == 0 ) + /* select safety_net or predictive */ + safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO ); + IF( EQ_16( force_sf, 1 ) ) { - /* reset the consecutive AR-predictor multiplier */ - st->streaklimit_fx = 32767; /*1.0 in Q15 */ + safety_net = 1; move16(); } - /* VOICED_WB@16kHz */ - test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) + IF( safety_net ) { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ); - Tmp2[i] = sub( Tmp[i], pred2[i] ); - pred2[i] = add( pred2[i], pred0[i] ); - } - - /* select safety_net or predictive */ - safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO ); - IF( EQ_16( force_sf, 1 ) ) - { - safety_net = 1; - move16(); - } - - IF( safety_net ) - { - /* Safety-net - BC-TCQ quantization : SN */ - Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = 0; - move16(); - } - ELSE - { - /* predictive - BC-TCQ quantization : AR */ - Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = add( st->pstreaklen, 1 ); - } + /* Safety-net - BC-TCQ quantization : SN */ + Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); + st->pstreaklen = 0; + move16(); } - /* all other frames (not VOICED@16kHz) */ ELSE { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); - Tmp2[i] = sub( lsf[i], pred2[i] ); - } - - /* safety-net */ - Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); - /* Predictive quantizer is calculated only if it can be selected */ - test(); - IF( !force_sf || GT_32( Err[0], abs_threshold ) ) - { - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, - st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); - } - test(); - test(); - /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: - if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected - or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. - or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ - IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) ) - { - safety_net = 1; - move16(); - st->pstreaklen = 0; - move16(); /* Reset the consecutive predictive frame counter */ - } - ELSE - { - safety_net = 0; - move16(); /* Increase the consecutive predictive frame counter by one */ - st->pstreaklen = add( st->pstreaklen, 1 ); - } + /* predictive - BC-TCQ quantization : AR */ + Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); + st->pstreaklen = add( st->pstreaklen, 1 ); } } -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - PMT( "LSF_RE_USE_SECONDARY_CHANNEL CODE IS MISSING " ) - else /* of "if (predmode==2)" */ + /* all other frames (not VOICED@16kHz) */ + ELSE { - mvr2r( ModeMeans[mode_lvq], pred0, M ); - - if ( predmode == 4 ) - { - mode_lvq_p = 9; /* force to Generic WB with AR*/ - } + /* Subtract mean and AR prediction */ + Copy( ModeMeans_fx[mode_lvq], pred0, M ); + /* subtract only mean */ + Vr_subt( lsf, pred0, Tmp, M ); - for ( i = 0; i < M; i++ ) + FOR( i = 0; i < M; i++ ) { /* subtract mean and AR prediction */ - pred2[i] = pred0[i] + Predictors[mode_lvq_p][i] * ( st->mem_AR[i] - pred0[i] ); - Tmp[i] = lsf[i] - pred2[i]; - Tmp2[i] = lsf[i] - pred3[i]; + pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); + Tmp2[i] = sub( lsf[i], pred2[i] ); } - /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in - case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ - if ( st->pstreaklen > ( STREAKLEN ) ) + /* safety-net */ + Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); + /* Predictive quantizer is calculated only if it can be selected */ + test(); + IF( !force_sf || GT_32( Err[0], abs_threshold ) ) { - /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit *= STREAKMULT; + Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, + st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); } - - if ( st->pstreaklen == 0 ) + test(); + test(); + /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: + if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected + or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. + or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ + IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) ) { - /* reset the adaptive scaling factor */ - st->streaklimit = 1.0f; + safety_net = 1; + move16(); + st->pstreaklen = 0; + move16(); /* Reset the consecutive predictive frame counter */ } - - /* intra pred */ - /* use G AR pred for the intra mode (as a safety mode, this is why the indexes 0/1 are interchanged)*/ - - lsf_allocate( nBits - 1, mode_lvq, 9, &stages1, &stages0, levels1, levels0, bits1, bits0 ); - - Err[0] = vq_lvq_lsf_enc( 2, 9, Tmp2, levels0, stages0, wghts, Idx0, lsf, pred3, &resq[M], &lsfq[M] ); - - if ( force_sf ) + ELSE { - safety_net = 1; /* intra-frame prediction */ - st->pstreaklen = 0; /* Reset the consecutive predictive frame counter */ - } - else - { /* try also the inter frame prediction */ - - /* AR inter-frame prediction */ - lsf_allocate( nBits - 1, mode_lvq, mode_lvq_p, &dummy, &stages1, dummy_v, levels1, dummy_v, bits1 ); - - - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp, levels1, stages1, wghts, Idx1, lsf, pred2, resq, lsfq ); - - if ( Err[0] * ( st->streaklimit ) < PREFERSFNET * Err[1] ) - { - safety_net = 1; - st->pstreaklen = 0; /* Reset the consecutive predictive frame counter */ - } - else - { - safety_net = 0; - ( st->pstreaklen )++; /* Increase the consecutive predictive frame counter by one */ - } + safety_net = 0; + move16(); /* Increase the consecutive predictive frame counter by one */ + st->pstreaklen = add( st->pstreaklen, 1 ); } } } -#endif /*--------------------------------------------------------------------------* \ + + /*--------------------------------------------------------------------------* \ * Write indices to array \ *--------------------------------------------------------------------------*/ @@ -1232,22 +1129,14 @@ void lsf_end_enc_fx( { /* write coder_type bit for VOICED@16kHz or GENERIC@16kHz */ test(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && ( st->idchan == 0 ) ) -#else IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) ) -#endif { /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/ push_indice_fx( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 ); } /* write predictor selection bit */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( GE( predmode, 2 ) ) -#else IF( EQ_16( predmode, 2 ) ) -#endif { push_indice_fx( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); } @@ -1267,11 +1156,7 @@ void lsf_end_enc_fx( { cumleft = nBits; move16(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( GE( predmode, 2 ) ) -#else IF( EQ_16( predmode, 2 ) ) -#endif { /* subtract predictor selection bit */ cumleft = sub( nBits, 1 ); @@ -1434,16 +1319,6 @@ void lsf_end_enc_fx( } ELSE { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->tdm_LRTD_flag == 0 && st->idchan == 1 && tdm_lsfQ_PCh != NULL ) - { - /* intra mode*/ - vq_dec_lvq( 0, qlsf, &indice[0], stages0, M, 9, /*mode_lvq_p,*/ levels0[stages0 - 1] ); - v_add( qlsf, pred3, qlsf, M ); - v_sub( qlsf, pred1, st->mem_MA, M ); - } - else -#endif { vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], @@ -2122,7 +1997,7 @@ static void first_VQstages( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -2312,7 +2187,7 @@ static void first_VQstages_ivas_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 80e144743..d53e2eb6e 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -268,48 +268,6 @@ Word16 pit_encode_fx( /* o : Fractional pitc pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } -#ifdef ADD_LRTD - else if ( tdm_Pitch_reuse_flag == 1 || nBits == 4 ) - { - /*-------------------------------------------------------* - * Pitch encoding with reusing primary channel information - *-------------------------------------------------------*/ - int16_t loc_T0, loc_frac; - - delta = 4; - - pit_flag = L_SUBFR; - - if ( L_subfr == 2 * L_SUBFR ) - { - loc_T0 = (int16_t) ( 0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[( i_subfr + L_SUBFR ) / L_SUBFR] ); - loc_frac = (int16_t) ( ( ( 0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[( i_subfr + L_SUBFR ) / L_SUBFR] ) - loc_T0 ) * 4.0f ); - } - else - { - loc_T0 = (int16_t) tdm_Pri_pitch_buf[i_subfr / L_SUBFR]; - loc_frac = (int16_t) ( ( tdm_Pri_pitch_buf[i_subfr / L_SUBFR] - loc_T0 ) * 4.0f ); - } - - /* pitch lag search limitation */ - limit_T0( L_FRAME, delta, pit_flag, *limit_flag, loc_T0, loc_frac, T0_min, T0_max ); - if ( nBits > 0 ) - { - /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); - if ( delta == 8 ) - { - *T0_frac = 0; - } - pit_Q_enc( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); - } - else - { - *T0 = loc_T0; - *T0_frac = loc_frac; - } - } -#endif ELSE { /*-------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2e151df8f..c3e9d1b4c 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -61,14 +61,13 @@ ivas_error acelp_core_enc_fx( Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits_fx, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new, const Word16 shift -#ifdef ADD_LRTD - , - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif + ); + void analy_lp_ivas_fx( const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ const Word16 L_frame, /* i :(q0) length of the frame */ @@ -906,10 +905,6 @@ void lsf_end_enc_fx( Word16 *no_indices, Word16 *bits_param_lpc, Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif ); void lsf_end_enc_ivas_fx( @@ -923,10 +918,10 @@ void lsf_end_enc_ivas_fx( Word16 *lpc_param, Word16 *no_indices, Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ - , + Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); + void Mode2_abs_pit_enc_fx( Word16 T0, /* i : integer pitch lag */ Word16 T0_frac, /* i : pitch fraction */ @@ -1853,9 +1848,6 @@ void lsf_enc_fx( const Word16 Nb_ACELP_frames, const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ); void lsf_enc_ivas_fx( @@ -1868,6 +1860,7 @@ void lsf_enc_ivas_fx( const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ); + void Es_pred_enc_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ Word16 *indice, /* o : indice of quantization Q0*/ -- GitLab From 7bf5394675814ab272299e098bd3bbcb7ee1920f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 10:28:15 +0100 Subject: [PATCH 252/329] remove redundant code under IVAS_CODE_CNG --- lib_com/fd_cng_com_fx.c | 5 - lib_com/prot_fx.h | 13 - lib_dec/cng_dec_fx.c | 52 +- lib_dec/dec_acelp_tcx_main_fx.c | 22 +- lib_dec/fd_cng_dec_fx.c | 814 +------------------------------- lib_enc/fd_cng_enc_fx.c | 58 +-- 6 files changed, 9 insertions(+), 955 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index f4468bd0b..e04a13fdf 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -566,11 +566,6 @@ void minimum_statistics( Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ Word16 *msPeriodogBufPtr, /* i/o: Counter */ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef IVAS_CODE_CNG - , - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ -#endif ) { Word16 i, j, k, s, s1, s2, s3; diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6f5519f68..cb7416eb3 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7588,15 +7588,6 @@ void perform_noise_estimation_dec_fx( float *power_spectrum, #endif HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef IVAS_CODE_CNG - , - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - const Word16 VAD /* i : VAD flag in the decoder */ -#endif ); void perform_noise_estimation_dec_ivas_fx( @@ -8725,10 +8716,6 @@ Word16 dec_acelp_tcx_frame_fx( Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ Word16 *voice_factors, /* o : voicing factors */ Word16 pitch_buf[] /* o : floating pitch for each subframe */ -#ifdef IVAS_CODE_CNG - , - STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ -#endif ); // dec_LPD_fx.c diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 3590dae71..e3401739e 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -1513,12 +1513,6 @@ static void shb_CNG_decod_fx( } ELSE { -#ifdef IVAS_CODE_CNG - /* de-quantization of SHB CNG parameters */ To be verified - L_tmp = L_mult( idx_ener_fx, 17615 ); /*Q13*/ - st_fx->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 147962 ), 5 ) ); /*Q8 */ - move16(); -#endif } } } @@ -1549,9 +1543,6 @@ static void shb_CNG_decod_fx( Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ -#ifdef IVAS_CODE_CNG - // mvr2r(shb_lpcCNG, st->hTdCngDec->shb_lpcCNG, LPC_SHB_ORDER + 1); -#endif /* SHB energy estimation */ wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ FOR( i = 0; i < L_FRAME32k; i++ ) @@ -1695,9 +1686,7 @@ static void shb_CNG_decod_fx( L_tmp = L_deposit_h( tmp ); /*Q31 */ tmp = sub( add( 5, exp ), add( q, exp1 ) ); L_gain_fx = Isqrt_lc( L_tmp, &tmp ); /*Q31-Qtmp */ -#ifdef IVAS_CODE_CNG - st->hTdCngDec->shb_cng_gain = ener_fx; -#endif + FOR( i = 0; i < L_FRAME16k; i++ ) { shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */ @@ -1726,11 +1715,8 @@ static void shb_CNG_decod_fx( { interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, st_fx->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); } -#ifdef IVAS_CODE_CNG - ResetSHBbuffer_Dec( st->hBWE_TD, st->extl ); -#else + ResetSHBbuffer_Dec_fx( st_fx ); -#endif return; } @@ -2037,20 +2023,6 @@ void td_cng_dec_init_fx( move16(); hTdCngDec->last_allow_cn_step = 0; move16(); -#ifdef IVAS_CODE_CNG - // mvr2r(st->lsp_old, st->lspCNG, M); - // hTdCngDec->shb_cng_ener = -6.02f; - IF( st->element_mode != EVS_MONO ) - { - // set_f(hTdCngDec->shb_lpcCNG, 0.0f, LPC_SHB_ORDER + 1); - // hTdCngDec->shb_lpcCNG[0] = 1.0f; - // hTdCngDec->shb_cng_gain = -82.0; /* a dB value approximately corresponding to shb index 0(used as index -15) */ - } - // hTdCngDec->wb_cng_ener = -6.02f; - // hTdCngDec->last_wb_cng_ener = -6.02f; - // hTdCngDec->last_shb_cng_ener = -6.02f; - // hTdCngDec->swb_cng_seed = RANDOM_INITSEED; -#endif hTdCngDec->ho_hist_ptr = -1; move16(); hTdCngDec->ho_sid_bw = L_deposit_l( 0 ); @@ -2081,26 +2053,6 @@ void td_cng_dec_init_fx( set16_fx( hTdCngDec->exc_mem_fx, 0, 24 ); set16_fx( hTdCngDec->exc_mem1_fx, 0, 30 ); set32_fx( hTdCngDec->old_env_fx, 0, NUM_ENV_CNG ); -#ifdef IVAS_CODE_CNG - // st->CNG_mode = -1; - // for (i = 0; i < LPC_SHB_ORDER; i++) - //{ - // IF (st->element_mode != EVS_MONO) - // { - // hTdCngDec->lsp_shb_prev[i] = 0.5f * ((float)(i + 1)) / ((float)(LPC_SHB_ORDER + 1)); - // } - // else - // { - // hTdCngDec->lsp_shb_prev[i] = 0.5f * ((float)i) / ((float)LPC_SHB_ORDER); - // } - // hTdCngDec->lsp_shb_prev_prev[i] = hTdCngDec->lsp_shb_prev[i]; - // } - - // hTdCngDec->shb_dtx_count = 0; - // hTdCngDec->trans_cnt = 0; - // hTdCngDec->last_shb_ener = 0.001f; - // set_f(hTdCngDec->interpol_3_2_cng_dec, 0.0f, INTERP_3_2_MEM_LEN); -#endif hTdCngDec->burst_cnt = 0; move16(); diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 7edd23549..04a41ed46 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -10,12 +10,7 @@ #include "stat_com.h" #include "prot_fx.h" #include "basop_util.h" -static void decode_frame_type_fx( Decoder_State *st -#ifdef IVAS_CODE_CNG - , - STEREO_CNG_DEC_HANDLE hStereoCng -#endif -) +static void decode_frame_type_fx( Decoder_State *st ) { Word32 L_tmp; Word16 num_bits; @@ -259,9 +254,7 @@ static void decode_frame_type_fx( Decoder_State *st IF( EQ_16( st->m_frame_type, SID_FRAME ) && NE_16( st->hFdCngDec->hFdCngCom->frame_type_previous, ACTIVE_FRAME ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, st->L_frame * 2, st->last_L_frame * 2 ); -#ifdef IVAS_CODE_CNG - lerp( hStereoCng->olapBufferSynth22, hStereoCng->olapBufferSynth22, st->L_frame * 2, st->last_L_frame * 2 ); -#endif + IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( n = 0; n < shl( st->L_frame, 1 ); n++ ) @@ -311,10 +304,6 @@ Word16 dec_acelp_tcx_frame_fx( Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q0 */ Word16 *voice_factors, /* o : voicing factors Q15 */ Word16 pitch_buf[] /* o : floating pitch for each subframe Q6 */ -#ifdef IVAS_CODE_CNG - , - STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ -#endif ) { Word16 num_bits; @@ -366,12 +355,7 @@ Word16 dec_acelp_tcx_frame_fx( Word32 total_brate = st->last_total_brate; move32(); - decode_frame_type_fx( st -#ifdef IVAS_CODE_CNG - , - hStereoCng -#endif - ); + decode_frame_type_fx( st ); st->force_lpd_reset = 0; move16(); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 70c4760ae..c509d5d10 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -279,30 +279,6 @@ void initFdCngDec_fx( hFdCngDec->smoothed_psd_exp = 0; move16(); -#ifdef IVAS_CODE_CNG - set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp, 0.0f, NPART ); - - set_f( hFdCngDec->smoothed_psd, 0.0f, L_FRAME16k ); - set_f( hFdCngDec->msPeriodog_ST, 0.0f, NPART_SHAPING ); - - hFdCngDec->ms_last_inactive_bwidth = NB; - hFdCngDec->ms_cnt_bw_up = 0; - - hFdCngDec->cna_LR_LT = 0.5f; - hFdCngDec->cna_ILD_LT = 0.0f; - hFdCngDec->first_cna_noise_updated = 0; - hFdCngDec->first_cna_noise_update_cnt = 0; - hFdCngDec->cna_nbands = 6; - mvs2s( cna_init_bands, hFdCngDec->cna_band_limits, MAX_CNA_NBANDS + 1 ); - hFdCngDec->cna_act_fact = 1.0f; - hFdCngDec->cna_rescale_fact = 0.0f; - hFdCngDec->cna_seed = 5687; - set_zero( hFdCngDec->cna_cm, STEREO_DFT_BAND_MAX ); - set_zero( hFdCngDec->cna_g_state, STEREO_DFT_BAND_MAX ); - - st->CNG_mode = -1; - mvr2r( st->lsp_old, st->lspCNG, M ); -#endif return; } /* @@ -1032,12 +1008,6 @@ Word16 ApplyFdCng_fx( hFdCngCom->psize_inv, hFdCngDec->partNoiseShape, &hFdCngDec->partNoiseShape_exp ); -#ifdef IVAS_CODE_CNG - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - Copy( hFdCngDec->hFdCngCom->sidNoiseEst, hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); - } -#endif } IF( EQ_16( st->m_frame_type, SID_FRAME ) ) @@ -1054,11 +1024,8 @@ Word16 ApplyFdCng_fx( { if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { -#ifdef IVAS_CODE_CNG - sidNoiseEst = hFdCngCom->sidNoiseEstLp; - move16(); -#endif } + /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { @@ -1136,24 +1103,7 @@ Word16 ApplyFdCng_fx( move16(); } } -#ifdef IVAS_CODE_CNG - else if ( st->element_mode == IVAS_CPE_DFT ) - { - if ( !( hFdCngCom->msFrCnt_init_counter < hFdCngCom->msFrCnt_init_thresh ) ) - { - sidNoiseEst = hFdCngCom->sidNoiseEstLp; - j = 0; - for ( k = 0; k < hFdCngCom->nFFTpart; k++ ) - { - factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape[k] + DELTA ); - for ( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = hFdCngDec->bandNoiseShape[j] * factor; - } - } - } - } -#endif + IF( EQ_16( st->codec_mode, MODE2 ) ) { /* Generate comfort noise during SID or zero frames */ @@ -1866,15 +1816,6 @@ void perform_noise_estimation_dec_fx( float *power_spectrum, #endif HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef IVAS_CODE_CNG - , - const int16_t element_mode, /* i : element mode */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t L_frame, /* i : frame length at internal Fs */ - const int16_t last_L_frame, /* i : frame length of the last frame at internal Fs */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - const int16_t VAD /* i : VAD flag in the decoder */ -#endif ) { Word16 i, tmp_r, tmp_i, fac, fftBuffer_exp; @@ -1883,10 +1824,6 @@ void perform_noise_estimation_dec_fx( Word16 *part, *psize_inv, *psize_norm; Word32 tmp, *fftBuffer, *periodog, *ptr_per, *ptr_r, *ptr_i; -#ifdef IVAS_CODE_CNG - PMT( "lots of code related to IVAS needs to be done " ) -#endif - /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ @@ -1919,238 +1856,7 @@ void perform_noise_estimation_dec_fx( AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom ); #endif fftBuffer_exp = add( fftBuffer_exp, WORD16_BITS - 1 ); -#ifdef IVAS_CODE_CNG - if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) - { - /* Calculate periodogram (squared magnitude in each FFT bin) */ - if ( startBand == 0 ) - { - ( *ptr_per ) = fftBuffer[0] * fftBuffer[0]; - ptr_per++; - ptr_r = fftBuffer + 2; - } - else - { - ptr_r = fftBuffer + 2 * startBand; - } - - ptr_i = ptr_r + 1; - - for ( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ ) - { - ( *ptr_per ) = ( *ptr_r ) * ( *ptr_r ) + ( *ptr_i ) * ( *ptr_i ); - ptr_r += 2; - ptr_i += 2; - } - - /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/ - v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand ); - - /* Combine bins of power spectrum into partitions */ - i = 0; - for ( p = 0; p < npart; p++ ) - { - - /* calculate mean over all bins in power partition */ - temp = 0; - for ( ; i <= part[p]; i++ ) - { - temp += periodog[i]; - } - msPeriodog[p] = temp * psize_inv[p]; - } - - /* compensate for the loss of variance - don't do when first noise update is not completed yet due to risk of msPeriodog[p] < 0 */ - if ( hFdCngDec->first_cna_noise_updated ) - { - i = 0; - for ( p = 0; p < npart; p++ ) - { - /* calculate variance over all bins in power partition */ - temp = 0; - for ( ; i <= part[p]; i++ ) - { - delta = periodog[i] - msPeriodog[p]; - temp += delta * delta; - } - temp *= psize_inv[p]; - - /* compensate for the loss of variance */ - msPeriodog[p] = (float) ( msPeriodog[p] + sqrt( temp ) * rand_gauss( &ftemp, &hFdCngDec->cna_seed ) ); - - if ( msPeriodog[p] < 1e-5f ) - { - msPeriodog[p] = 1e-5f; - } - } - } - - /* calculate total energy (short-term and long-term) */ - enr_tot = sum_f( msPeriodog, npart ) + EPSILON; - enr_tot0 = sum_f( msNoiseEst, npart ) + EPSILON; - - /* update short-term periodogram on larger partitions */ - for ( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ ) - { - if ( L_frame != last_L_frame || last_core_brate <= SID_2k40 ) - { - /* core Fs has changed or last frame was SID/NO_DATA -> re-initialize short-term periodogram */ - hFdCngDec->msPeriodog_ST[p] = msPeriodog[p]; - } - else - { - hFdCngDec->msPeriodog_ST[p] = (float) ( ST_PERIODOG_FACT * hFdCngDec->msPeriodog_ST[p] + ( 1 - ST_PERIODOG_FACT ) * msPeriodog[p] ); - } - } - - /* core Fs has changed -> partitions have changed -> re-calculate long-term periodogram */ - /* part L_FRAME16k L_FRAME */ - /* ... */ - /* [55] 146 146 */ - /* [56] 174 160 */ - /* [57] 210 174 */ - /* [58] 254 190 */ - /* [59] 306 210 */ - /* [60] 317 230 */ - /* [61] 253 */ - - if ( last_L_frame == L_FRAME16k && L_frame == L_FRAME ) - { - msNoiseEst[61] = msNoiseEst[58]; - msNoiseEst[60] = min( msNoiseEst[58], msNoiseEst[57] ); - msNoiseEst[59] = msNoiseEst[57]; - msNoiseEst[58] = msNoiseEst[56]; - msNoiseEst[57] = msNoiseEst[56]; - msNoiseEst[56] = min( msNoiseEst[56], msNoiseEst[55] ); - } - else if ( last_L_frame == L_FRAME && L_frame == L_FRAME16k ) - { - msNoiseEst[56] = min( msNoiseEst[56], msNoiseEst[57] ); - msNoiseEst[57] = min( msNoiseEst[58], msNoiseEst[59] ); - msNoiseEst[58] = min( msNoiseEst[60], msNoiseEst[61] ); - msNoiseEst[59] = 0.0f; - msNoiseEst[60] = 0.0f; - msNoiseEst[61] = 0.0f; - - hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; - } - - /* Smooth with IIR filter */ - if ( !hFdCngDec->first_cna_noise_updated ) - { - if ( !VAD ) - { - /* background noise update with moving average */ - alpha = 1.0f / ( hFdCngDec->first_cna_noise_update_cnt + 1 ); - for ( p = 0; p < npart; p++ ) - { - msNoiseEst[p] = ( 1 - alpha ) * msNoiseEst[p] + alpha * msPeriodog[p]; - } - - /* check, if we reached the required number of first CNA noise update frames */ - if ( hFdCngDec->first_cna_noise_update_cnt < FIRST_CNA_NOISE_UPD_FRAMES - 1 ) - { - hFdCngDec->first_cna_noise_update_cnt++; - } - else - { - hFdCngDec->first_cna_noise_updated = 1; - if ( hFdCngDec->hFdCngCom->msFrCnt_init_counter == 0 ) - { - hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; - } - } - } - else - { - hFdCngDec->first_cna_noise_update_cnt = 0; - } - } - else - { - hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; - if ( VAD ) - { - /* no updates during active frames except for significant energy drops */ - enr_ratio = enr_tot / enr_tot0; - if ( enr_ratio < 0.5f ) - { - /* total energy significantly decreases during active frames -> downward update */ - wght = lin_interp( enr_ratio, 0.0f, 0.8f, 0.5f, 0.95f, 1 ); - for ( p = 0; p < npart; p++ ) - { - if ( msPeriodog[p] < msNoiseEst[p] ) - { - msNoiseEst[p] = wght * msNoiseEst[p] + ( 1 - wght ) * msPeriodog[p]; - } - } - } - else - { - /* energy significantly decreases in one of the larger partitions during active frames -> downward update */ - for ( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ ) - { - if ( hFdCngDec->msPeriodog_ST[p] < msNoiseEst[p] ) - { - msNoiseEst[p] = (float) ( CNA_ACT_DN_FACT * msNoiseEst[p] + ( 1 - CNA_ACT_DN_FACT ) * hFdCngDec->msPeriodog_ST[p] ); - } - } - } - } - else - { - - if ( bwidth >= WB && hFdCngDec->ms_last_inactive_bwidth == NB ) - { - /* bandwidth increased -> set counter for fast initilization */ - hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; - } - hFdCngDec->ms_last_inactive_bwidth = bwidth; - /* update background noise during inactive frames */ - ptr_per = msNoiseEst; - for ( p = 0; p < npart; p++ ) - { - enr = msPeriodog[p]; - alpha = 0.95f; - /* bandwidth increased -> do fast re-initilization */ - if ( hFdCngDec->ms_cnt_bw_up > 0 && p > 55 ) - { - alpha = 1.0f / ( hFdCngDec->ms_cnt_bw_up + 1 ); - } - else if ( enr < *ptr_per && part[p] == 1 ) - { - /* faster downward update for single-bin partitions */ - alpha = 0.8f; - } - else if ( enr > 2.0f * ( *ptr_per ) ) - { - /* prevent abrupt upward updates */ - enr = 2.0f * ( *ptr_per ); - } - - /* IIR smoothing */ - *ptr_per *= alpha; - *ptr_per += ( 1 - alpha ) * enr; - ptr_per++; - } - - if ( hFdCngDec->ms_cnt_bw_up > 0 ) - { - hFdCngDec->ms_cnt_bw_up--; - } - } - } - - mvr2r( msNoiseEst, hFdCngDec->msPsd, npart ); - - /* Expand partitions into bins of power spectrum */ - scalebands( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, stopFFTbin - startBand, hFdCngDec->bandNoiseShape, 1 ); - mvr2r( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd[startBand], stopFFTbin - startBand ); - set_zero( &hFdCngDec->smoothed_psd[stopFFTbin], L_FRAME16k - stopFFTbin ); - } - else -#endif { #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT if ( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL ) @@ -2302,12 +2008,7 @@ void perform_noise_estimation_dec_fx( hFdCngDec->msNewMinFlag, hFdCngDec->msPeriodogBuf, &( hFdCngDec->msPeriodogBufPtr ), - hFdCngDec->hFdCngCom -#ifdef IVAS_CODE_CNG - , - DEC, element_mode -#endif - ); + hFdCngDec->hFdCngCom ); /* Expand MS outputs */ expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart ); @@ -2347,10 +2048,6 @@ void perform_noise_estimation_dec_ivas_fx( Word16 q_shift; Word32 max_l; Word16 norm_shift; -#ifdef IVAS_CODE_CNG - PMT( "lots of code related to IVAS needs to be done " ) -#endif - /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ @@ -6303,508 +6000,3 @@ void FdCngDecodeDiracMDCTStereoSID_fx( return; } - - -#ifdef IVAS_CODE_CNG - -/*------------------------------------------------------------------- - * generate_stereo_masking_noise() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_stereo_masking_noise( - float *syn, /* i/o: time-domain signal */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -) -{ - HANDLE_FD_CNG_COM hFdCngCom; - float gamma, scale, SP_ratio; - float Np[L_FRAME16k]; - float Ns[L_FRAME16k]; - float N1[L_FRAME16k]; - float N2[L_FRAME16k]; - int16_t i; - - if ( st->idchan == 0 ) - { - hFdCngCom = st->hFdCngDec->hFdCngCom; - mvr2r( hFdCngCom->olapBufferSynth2, Np, hFdCngCom->frameSize / 2 ); - mvr2r( hStereoCng->olapBufferSynth22, Ns, hFdCngCom->frameSize / 2 ); - set_f( &Np[hFdCngCom->frameSize / 2], 0.0f, hFdCngCom->frameSize / 2 ); - set_f( &Ns[hFdCngCom->frameSize / 2], 0.0f, hFdCngCom->frameSize / 2 ); - - if ( !fadeOut ) - { - generate_masking_noise_fx( N1, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); - /* Generate masking noise for secondary channel */ - if ( flag_sec_CNA ) - { - generate_masking_noise_fx( N2, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); - gamma = hStereoCng->c_PS_LT * hStereoCng->c_PS_LT; - scale = 1.0f; - if ( gamma < 0.9f ) - { - gamma = gamma / ( 1 - gamma ); - gamma = (float) sqrt( gamma + 1 ) - (float) sqrt( gamma ); - scale = 1.0f / (float) sqrt( 1 + gamma * gamma ); - } - else - { - gamma = 0.0f; - } - - for ( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) - { - Np[i] += scale * ( N1[i] + gamma * N2[i] ); - Ns[i] += scale * sign( hStereoCng->c_PS_LT ) * ( N1[i] - gamma * N2[i] ); - } - for ( ; i < hFdCngCom->frameSize; i++ ) - { - Np[i] = scale * ( N1[i] + gamma * N2[i] ); - Ns[i] = scale * sign( hStereoCng->c_PS_LT ) * ( N1[i] - gamma * N2[i] ); - } - scale *= (float) ( hFdCngCom->fftlen / 2 ); - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - hFdCngCom->olapBufferSynth2[i] = scale * ( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] + gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] ); - hStereoCng->olapBufferSynth22[i] = sign( hStereoCng->c_PS_LT ) * scale * ( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] - gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] ); - } - } - else - { - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - Np[i] += N1[i]; - } - mvr2r( &N1[hFdCngCom->frameSize / 2], &Np[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2 ); - scale = (float) ( hFdCngCom->fftlen / 2 ); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hFdCngCom->olapBufferSynth2[i] = scale * hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4]; - } - } - } - else - { - set_f( hFdCngCom->olapBufferSynth2, 0.0f, hFdCngCom->frameSize / 2 ); - set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize / 2 ); - } - if ( flag_sec_CNA ) - { - mvr2r( Ns, hStereoCng->maskingNoiseS, hFdCngCom->frameSize ); - hStereoCng->enableSecCNA = 1; - } - else - { - set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize ); - } - - /* add masking noise */ - v_add( Np, syn, syn, hFdCngCom->frameSize ); - } - else if ( hStereoCng->enableSecCNA ) - { - SP_ratio = hStereoTD->SP_ratio_LT; /* Use long-term SP ratio based on L/R synthesis */ - /* scale and add masking noise */ - for ( i = 0; i < *hStereoCng->frameSize / 4; i++ ) - { - scale = ( ( hStereoTD->prevSP_ratio * ( *hStereoCng->frameSize / 4 - (float) i ) + SP_ratio * (float) i ) / ( *hStereoCng->frameSize / 4 ) ); - syn[i] += scale * hStereoCng->maskingNoiseS[i]; - } - for ( ; i < *hStereoCng->frameSize / 2; i++ ) - { - syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - } - for ( ; i < *hStereoCng->frameSize; i++ ) - { - syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - } - hStereoTD->prevSP_ratio = SP_ratio; - } - - return; -} - -/*------------------------------------------------------------------- - * generate_masking_noise_hf_cldfb() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_masking_noise_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - float *Cldfb_RealBuffer, /* o : CLDFD real buffer */ - float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */ - const int16_t slot_index, /* i : CLDFB slot index */ - const int16_t cna_flag, /* i : CNA flag for LB and HB */ - const int16_t fd_cng_flag /* i : FD-CNG flag for HB */ -) -{ - int16_t i; - float *cngNoiseLevel = hFdCngCom->cngNoiseLevel; - float *fftBuffer = hFdCngCom->fftBuffer; - float *ptr_r; - float *ptr_i; - float *ptr_level; - int16_t *seed = &( hFdCngCom->seed ); - float scale; - - wmops_sub_start( "fd_cng_dirac" ); - - /* Init */ - scale = 0.f; - - /* Resample CLDFB memories if necessary*/ - if ( ( h_cldfb->no_channels * h_cldfb->no_col ) != hFdCngCom->frameSize ) - { - resampleCldfb( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC ); - } - - set_zero( Cldfb_RealBuffer, CLDFB_NO_CHANNELS_MAX ); - set_zero( Cldfb_ImagBuffer, CLDFB_NO_CHANNELS_MAX ); - - /*LB CLDFB - CNA from STFT*/ -#ifdef DEBUG_MODE_DIRAC - { - int16_t tmp_s; - tmp_s = (int16_t) ( 32768.f * 0.5f * hFdCngCom->likelihood_noisy_speech * cna_flag + 0.5f ); - dbgwrite( &tmp_s, sizeof( int16_t ), 1, hFdCngCom->frameSize / 16, "./res/ivas_dirac_likelihood_noisy.pcm" ); - } -#endif - if ( cna_flag ) - { - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - if ( hFdCngCom->likelihood_noisy_speech > DELTA_MASKING_NOISE ) - { - /* Compute additional CN level */ - for ( i = 0; i < 15; i++ ) - { - if ( ( hFdCngCom->CngBandwidth == scaleTable_cn_dirac[i].bwmode ) && - ( hFdCngCom->CngBitrate >= scaleTable_cn_dirac[i].bitrateFrom ) && - ( hFdCngCom->CngBitrate < scaleTable_cn_dirac[i].bitrateTo ) ) - { - break; - } - } - - scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale / 10.f ) - 1.f; - scale *= hFdCngCom->likelihood_noisy_speech; - } - } - - /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ - if ( cna_flag && tdBuffer != NULL ) - { - if ( scale != 0 ) - { - /*Generate LF comfort noise only at first slot, for the whole frame*/ - if ( slot_index == 0 ) - { - ptr_level = cngNoiseLevel; - - /* Generate Gaussian random noise in real and imaginary parts of the FFT bins - Amplitudes are adjusted to the estimated noise level cngNoiseLevel in each bin */ - if ( hFdCngCom->startBand == 0 ) - { - rand_gauss( &fftBuffer[0], seed ); - ptr_r = fftBuffer + 2; - fftBuffer[0] *= (float) sqrt( scale * *ptr_level ); /* DC component in FFT */ - ptr_level++; - } - else - { - fftBuffer[0] = 0.f; - set_f( fftBuffer + 2, 0.0f, 2 * ( hFdCngCom->startBand - 1 ) ); - ptr_r = fftBuffer + 2 * hFdCngCom->startBand; - } - ptr_i = ptr_r + 1; - - for ( ; ptr_level < cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; ptr_level++ ) - { - /* Real part in FFT bins */ - rand_gauss( ptr_r, seed ); - ( *ptr_r ) *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - ptr_r += 2; - /* Imaginary part in FFT bins */ - rand_gauss( ptr_i, seed ); - ( *ptr_i ) *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - ptr_i += 2; - } - - /* Remaining FFT bins are set to zero */ - set_f( fftBuffer + 2 * hFdCngCom->stopFFTbin, 0.0f, hFdCngCom->fftlen - 2 * hFdCngCom->stopFFTbin ); - /* Nyquist frequency is discarded */ - fftBuffer[1] = 0.f; - - /* Perform STFT synthesis */ - SynthesisSTFT( fftBuffer, tdBuffer, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, X, Y, -1, -1 ); - -#ifdef DEBUG_MODE_DIRAC - { - int16_t tmp[1000]; - - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - tmp[i] = (int16_t) ( tdBuffer[i] + 0.5f ); - } - dbgwrite( tmp, sizeof( int16_t ), hFdCngCom->frameSize, 1, "./res/ivas_dirac_cna_fft.pcm" ); - } -#endif - } - - /* LF CLDFB*/ - cldfbAnalysis_ts( &( tdBuffer[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, hFdCngCom->numCoreBands, h_cldfb ); - } - else - { - if ( slot_index == 0 ) - { - /* very low level case - update random seeds */ - generate_masking_noise_update_seed_fx( hFdCngCom ); - - set_f( fftBuffer, 0.f, hFdCngCom->fftlen ); - - /* Perform STFT synthesis */ - SynthesisSTFT( fftBuffer, tdBuffer, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, X, Y, -1, -1 ); - -#ifdef DEBUG_MODE_DIRAC - { - int16_t tmp[1000]; - - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - tmp[i] = (int16_t) ( tdBuffer[i] + 0.5f ); - } - dbgwrite( tmp, sizeof( int16_t ), hFdCngCom->frameSize, 1, "./res/ivas_dirac_cna_fft.pcm" ); - } -#endif - } - - /* LB ana CLDFB*/ - cldfbAnalysis_ts( &( tdBuffer[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, hFdCngCom->numCoreBands, h_cldfb ); - } - } - - /*HF CLDFB - CNA and/or FD-CNG*/ - if ( fd_cng_flag ) - { - scale += 1.f; - } - if ( scale != 0 ) - { - scale *= CLDFB_SCALING_FLT * ( h_cldfb->scale * h_cldfb->scale * 8.f ); - ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; - - for ( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) - { - /* Real part in CLDFB band */ - rand_gauss( &Cldfb_RealBuffer[i], seed ); - Cldfb_RealBuffer[i] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - /* Imaginary part in CLDFB band */ - rand_gauss( &Cldfb_ImagBuffer[i], seed ); - Cldfb_ImagBuffer[i] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - - ptr_level++; - } - } - - wmops_sub_end(); - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeMDCTStereoSID() - * - * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream - * - *-------------------------------------------------------------------*/ - -void FdCngDecodeMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - float *ms_ptr[CPE_CHANNELS]; - float *lr_ptr[CPE_CHANNELS]; - float logNoiseEst[CPE_CHANNELS][NPART]; - float gain[CPE_CHANNELS]; - int16_t indices[FD_CNG_stages_37bits]; - int16_t N, i, ch, p, stages; - int16_t is_out_ms; - - is_out_ms = 0; - if ( hCPE->hCoreCoder[0]->cng_sba_flag ) - { - is_out_ms = 1; - } - - N = 0; /* to avoid compilation warning */ - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr[ch] = &logNoiseEst[ch][0]; - lr_ptr[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; - } - - /* decode noise shapes and gains */ - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; - hFdCngCom->sid_frame_counter++; - - if ( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - } - else - { - stages = FD_CNG_stages_37bits; - } - - /* read bitstream */ - for ( i = 0; i < stages; i++ ) - { - indices[i] = get_next_indice( sts[ch], bits_37bits[i] ); - } - { - gain[ch] = ( (float) get_next_indice( sts[ch], 7 ) - GAIN_Q_OFFSET_IVAS ) / 1.5f; - } - - /* MSVQ decoder */ - msvq_dec( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, ms_ptr[ch], NULL ); - } - - if ( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) - { - set_zero( ms_ptr[1], NPART ); - } - - if ( is_out_ms == 0 ) - { - inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f ); - } - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - for ( p = 0; p < N; p++ ) - { - lr_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f ); - } - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - - if ( hCPE->nchan_out == 1 && hCPE->last_element_brate <= IVAS_SID_4k4 ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - for ( p = 0; p < N; p++ ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = 0.5f * ( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] + sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] ); - } - } - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeDiracMDCTStereoSID() - * - * Decode FD-Cng parameters for CNG in 2TC DirAC mode from the bitstream - *-------------------------------------------------------------------*/ - -void FdCngDecodeDiracMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - float *ms_ptr[CPE_CHANNELS]; - float *lr_ptr[CPE_CHANNELS]; - float logNoiseEst[CPE_CHANNELS][NPART]; - float gain[CPE_CHANNELS]; - int16_t indices[FD_CNG_stages_37bits]; - int16_t N, i, ch, p; - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr[ch] = &logNoiseEst[ch][0]; - lr_ptr[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; - ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; - } - - /* decode noise shapes and gains */ - hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; - - /* read bitstream */ - for ( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - indices[i] = get_next_indice( sts[0], bits_37bits[i] ); - } - gain[0] = ( (float) get_next_indice( sts[0], 7 ) - GAIN_Q_OFFSET_IVAS ) / 1.5f; - gain[1] = gain[0]; - - /* MSVQ decoder */ - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, ms_ptr[0], NULL ); - mvr2r( ms_ptr[0], ms_ptr[1], N ); - - /*inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f );*/ - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - for ( p = 0; p < N; p++ ) - { - lr_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f ); - } - - /* NB last band energy compensation */ - if ( hFdCngCom->CngBandwidth == NB ) - { - lr_ptr[ch][N - 1] *= NB_LAST_BAND_SCALE; - } - else if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) - { - lr_ptr[ch][N - 1] *= SWB_13k2_LAST_BAND_SCALE; - } - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - sts[0]->hFdCngDec->hFdCngCom->coherence = 0.0f; - sts[1]->hFdCngDec->hFdCngCom->coherence = 0.0f; - - if ( hCPE->nchan_out == 1 ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - for ( p = 0; p < N; p++ ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = 0.5f * ( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] + sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] ); - } - sts[0]->hFdCngDec->hFdCngCom->coherence = 0.0f; - sts[1]->hFdCngDec->hFdCngCom->coherence = 0.0f; - } - - return; -} -#endif diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 50f479d8d..97db8d2a0 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1058,19 +1058,6 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru BSTR_ENC_HANDLE hBstr = corest->hBstr; HANDLE_FD_CNG_COM st; Word16 maxC_37bits = FD_CNG_maxC_37bits, stages_37bits = FD_CNG_stages_37bits, maxN_37bits = FD_CNG_maxN_37bits; -#ifdef IVAS_CODE_CNG - float *invTrfMatrix; - float tmpRAM[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - float dct_target[FDCNG_VQ_DCT_MAXTRUNC]; - float tot_sig_ext[FDCNG_VQ_MAX_LEN]; - const float gain_q_offset = ( st->element_mode == EVS_MONO ) ? GAIN_Q_OFFSET_EVS : GAIN_Q_OFFSET_IVAS; - /* Init */ - N = hFdCngEnc->npartDec; - - invTrfMatrix = (float *) tmpRAM; /* dynamically filled */ - set_zero( v, FDCNG_VQ_MAX_LEN ); -#endif - /* Init */ st = stenc->hFdCngCom; @@ -1120,29 +1107,6 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru v16[i] = extract_h( L_sub( v[i], gain ) ); } -#ifdef IVAS_CODE_CNG - IF( st->element_mode != EVS_MONO ) - { - /* DCT domain compressed/truncated indices used for first stage */ - /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched - in FDCNG band domain - */ - if ( N == FDCNG_VQ_MAX_LEN_WB ) - { - create_IDCT_N_Matrix( invTrfMatrix, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); - /* truncated DCT21 analysis */ - dctT2_N_apply_matrix( (const float *) v, dct_target, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); - /* truncated IDCT21 extension to 24 bands */ - extend_dctN_input( v, dct_target, N, tot_sig_ext, FDCNG_VQ_MAX_LEN, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); - - mvr2r( tot_sig_ext, v, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ - } - create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); - msvq_enc_fx( cdk_37bits_ivas, NULL, NULL, v, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w, N, FD_CNG_maxN_37bits, 1, invTrfMatrix, indices ); - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); - } - ELSE -#endif { /* MSVQ encoder */ msvq_encoder( cdk_37bits, v16, levels_37bits, maxC_37bits, stages_37bits, N, maxN_37bits, indices ); @@ -1166,28 +1130,14 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru /* Apply bitrate-dependant scale */ -#ifdef IVAS_CODE_CNG - if ( st->element_mode > EVS_MONO ) - { - apply_scale( &gain, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - } - else -#endif { apply_scale( &gain, st->CngBandwidth, st->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); } -#ifdef IVAS_CODE_CNG - /* Quantize gain, Q14.23 format */ - gain = L_add( gain, L_shr( gain, 1 ) ); - gain = L_add( gain, gain_q_offset /*gain_q_offset+.5 Q23*/ ); - index = extract_l( L_shr( gain, WORD32_BITS - 1 - 8 ) ); -#else /* Quantize gain, Q14.23 format */ gain = L_add( gain, L_shr( gain, 1 ) ); gain = L_add( gain, 507510784l /*60.5 Q23*/ ); index = extract_l( L_shr( gain, WORD32_BITS - 1 - 8 ) ); -#endif if ( index < 0 ) { @@ -1200,17 +1150,11 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru index = 127; move16(); } -#ifndef IVAS_CODE_CNG + /* gain Q14.23 format */ gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); gain = L_sub( gain, 503316480l /*60.0 Q23*/ ); gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); -#else - /* gain Q14.23 format */ - gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); - gain = L_sub( gain, gain_q_offset /*60.0 Q23*/ ); - gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); -#endif /* Apply gain and undo log */ -- GitLab From b2d415f2fd3b80ac464075000c7c571f9b886706 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 15:49:55 +0530 Subject: [PATCH 253/329] Partial fix for 3GPP issue 1303: Obvious spectral discrepencies between signals decoded from fixed- and floating-point encoded bitstreams at 13.2kbps with -16LKFS FOA input sampled at 48kHz and optimizations Link #1303 --- lib_enc/cod_tcx_fx.c | 106 +++++++++++++-------------------------- lib_enc/swb_bwe_enc_fx.c | 4 +- 2 files changed, 37 insertions(+), 73 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 93c1dc58d..de9763df0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5379,13 +5379,13 @@ void TNSAnalysisStereo_fx( ) { Word16 ch, k, L_spec, L_frame, nSubframes, iFilter; - Word32 *spectrum_fx; + Word32 *spectrum_fx, sum; Encoder_State *st = NULL; TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; move32(); - Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; + Word16 maxPredictionGain_e = 0, meanPredictionGain_e; move16(); Word16 sum_e = 0; move16(); @@ -5544,31 +5544,21 @@ void TNSAnalysisStereo_fx( */ meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) + + /* maxPredictionGain = max( maxPredictionGain, meanPredictionGain );*/ + IF( GT_32( meanPredictionGain_fx, L_shl_sat( maxPredictionGain_fx, sub( maxPredictionGain_e, meanPredictionGain_e ) ) ) ) /* exp: meanPredictionGain_e */ { maxPredictionGain_fx = meanPredictionGain_fx; maxPredictionGain_e = meanPredictionGain_e; move32(); move16(); } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); - if ( flag_1 < 0 ) - { - flag_1 = 0; - move16(); - } + test(); test(); test(); - IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && - flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( GT_32( pFilter[0]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[0]->predictionGain_e ) ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && + GT_32( pFilter[1]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[1]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[1]->predictionGain_e ) ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ move32(); @@ -5578,39 +5568,29 @@ void TNSAnalysisStereo_fx( move16(); pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ move16(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); } - test(); - IF( flag && + sum_e = s_max( pFilter[0]->predictionGain_e, pFilter[1]->predictionGain_e ); + sum = L_abs( L_sub_sat( L_shl( pFilter[0]->predictionGain32, sub( pFilter[0]->predictionGain_e, sum_e ) ), L_shl( pFilter[1]->predictionGain32, sub( pFilter[1]->predictionGain_e, sum_e ) ) ) ); // sum_e + + IF( LT_32( L_shl_sat( sum, sub( sum_e, meanPredictionGain_e ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) + + /* maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); */ + IF( GT_32( meanPredictionGain_fx, L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, maxPredictionGain_e ) ) ) ) /* exp: meanPredictionGain_e */ { maxPredGain_fx = meanPredictionGain_fx; maxPredGain_e = meanPredictionGain_e; move32(); move16(); } - flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } + test(); test(); - IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( GT_32( meanPredictionGain_fx, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, meanPredictionGain_e ) ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -5813,16 +5793,13 @@ void TNSAnalysisStereo_fx( move16(); } } - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } + test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && + LT_32( L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, PRED_GAIN_E ) ), TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && + NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -5842,9 +5819,9 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) + + /* maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); */ + IF( GT_32( maxPredGain_fx, L_shl_sat( maxPredictionGain_fx, sub( maxPredictionGain_e, maxPredGain_e ) ) ) ) /* exp: maxPredGain_e */ { maxPredictionGain_fx = maxPredGain_fx; maxPredictionGain_e = maxPredGain_e; @@ -5902,22 +5879,16 @@ void TNSAnalysisStereo_fx( pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF( flag < 0 ) + IF( GT_32( pFilter->predictionGain32, L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, pFilter->predictionGain_e ) ) ) ) /* pFilter->predictionGain_e */ { maxPredGain_fx = pFilter->predictionGain32; - move32(); maxPredGain_e = pFilter->predictionGain_e; + move32(); move16(); } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } + test(); - IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( GT_32( pFilter->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters->minPredictionGain ), sub( PRED_GAIN_E, pFilter->predictionGain_e ) ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -5980,24 +5951,17 @@ void TNSAnalysisStereo_fx( } } - IF( ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[ch]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[ch]->hTcxEnc->fUseTns[k] = 0; - } + sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) + if ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) { - flag = 0; + sts[ch]->hTcxEnc->fUseTns[k] = 1; move16(); } + test(); test(); - IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && LT_32( L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, PRED_GAIN_E ) ), TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -6012,9 +5976,9 @@ void TNSAnalysisStereo_fx( move16(); } } + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) + IF( GT_32( maxPredGain_fx, L_shl_sat( maxPredictionGain_fx, sub( maxPredictionGain_e, maxPredGain_e ) ) ) ) /* maxPredGain_e */ { maxPredictionGain_fx = maxPredGain_fx; maxPredictionGain_e = maxPredGain_e; diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 01ac8383f..639ec9dca 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -3205,7 +3205,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( tmp = i_mult2( n_band, L ); FOR( i = 0; i < L; i++ ) { - WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*st_fx->Q_syn2 - 7 */ + WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp-7 */ WB_tenv_orig_fx = L_add( WB_tenv_orig_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp - 7 */ } @@ -3239,7 +3239,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( #else den = round_fx( L_shl( WB_tenv_syn_fx, expd ) ); #endif - expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) ); + expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); num = shl( num, scale ); -- GitLab From ebf10d0b6924fb45346d9e863aed1397d3871066 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:20:20 +0100 Subject: [PATCH 254/329] review and remove redundant code under IVAS_CODE --- lib_com/bits_alloc_fx.c | 3 +- lib_dec/acelp_core_dec_fx.c | 313 +---------------- lib_dec/dec_higher_acelp_fx.c | 8 +- lib_dec/evs_dec_fx.c | 4 - lib_dec/gs_dec_fx.c | 11 +- lib_dec/init_dec_fx.c | 8 - lib_dec/lsf_dec_fx.c | 2 - lib_enc/acelp_core_enc_fx.c | 1 - lib_enc/amr_wb_enc_fx.c | 10 +- lib_enc/cng_enc_fx.c | 60 +--- lib_enc/core_switching_enc_fx.c | 49 --- lib_enc/dtx_fx.c | 55 +-- lib_enc/enc_higher_acelp_fx.c | 15 - lib_enc/fd_cng_enc_fx.c | 5 - lib_enc/find_uv_fx.c | 51 +-- lib_enc/gain_enc_fx.c | 5 - lib_enc/inov_enc_fx.c | 83 +---- lib_enc/long_enr_fx.c | 60 +--- lib_enc/lsf_enc_fx.c | 32 -- lib_enc/nois_est_fx.c | 103 +----- lib_enc/pre_proc_fx.c | 22 +- lib_enc/prot_fx_enc.h | 21 +- lib_enc/speech_music_classif_fx.c | 68 +--- lib_enc/stat_enc.h | 535 +----------------------------- lib_enc/updt_enc_fx.c | 28 +- lib_enc/vad_fx.c | 12 +- 26 files changed, 61 insertions(+), 1503 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index f2a074ba5..88b276126 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -408,7 +408,7 @@ static Word16 BITS_ALLOC_adjust_acelp_fixed_cdk( return bitsused; } -/*#ifdef IVAS_CODE Below basop operators are missing */ + /*-------------------------------------------------------------------* * fcb_table() * @@ -3271,4 +3271,3 @@ Word16 set_ACELP_flag_IVAS( return 0; } } -/*#endif IVAS_CODE*/ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 903a37163..1d59d1269 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -143,66 +143,6 @@ ivas_error acelp_core_dec_fx( return error; } - -#ifdef IVAS_CODE - output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); - - /*----------------------------------------------------------------* - * stereo SID and CNG frames processing - *----------------------------------------------------------------*/ - - if ( st->core_brate <= SID_2k40 && st->element_mode == IVAS_CPE_DFT && nchan_out == 2 ) - { - if ( st->cng_type == FD_CNG ) - { - configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - - /* Only run parameter decoding in SID frames */ - if ( st->core_brate == SID_2k40 ) - { - FdCng_decodeSID_fx( st ); - } - - for ( i = 0; i < NPART; i++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i]; - } - -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - ApplyFdCng_fx( NULL, NULL, NULL, NULL, st, 0, 0 ); -#else - ApplyFdCng_fx( NULL, NULL, NULL, NULL, st, 0, 0 ); -#endif - } - else - { - configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - - /* decode CNG parameters */ - CNG_dec( st, last_element_mode, Aq, lsp_new, lsf_new, &allow_cn_step, sid_bw, q_env ); - - /* comfort noise generation */ - CNG_exc( st->core_brate, st->L_frame, &st->hTdCngDec->Enew, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->hTdCngDec->num_ho, q_env, st->hTdCngDec->lp_env, st->hTdCngDec->old_env, st->hTdCngDec->exc_mem, st->hTdCngDec->exc_mem1, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); - - mvr2r( Aq, st->Aq_cng, M + 1 ); - - /* update old LSP and LSF vector */ - mvr2r( lsf_new, st->lsf_old, M ); - mvr2r( lsp_new, st->lsp_old, M ); - } - - set_f( output, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ - set_f( synth, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ - - /* CN generation done in DFT domain */ - wmops_sub_end(); - return error; - } - - /*----------------------------------------------------------------* - * Active frames processing - *----------------------------------------------------------------*/ -#endif FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); @@ -265,13 +205,7 @@ ivas_error acelp_core_dec_fx( move32(); } } -#ifdef IVAS_CODE - if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) - { - set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2, FFTLEN ); - set_zero( hStereoCng->olapBufferSynth22, FFTLEN ); - } -#endif + st_fx->clas_dec = st_fx->last_good; move16(); enr_q_fx = 0; @@ -413,7 +347,7 @@ ivas_error acelp_core_dec_fx( Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56) } set16_fx( st_fx->mem_MA_fx, 0, M ); -#if 1 // def IVAS_CODE + dec = DEC; move16(); IF( NE_16( st_fx->element_mode, EVS_MONO ) ) @@ -424,9 +358,7 @@ ivas_error acelp_core_dec_fx( /* update synthesis filter memories */ synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); -#else - synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC ); -#endif + Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/ @@ -591,7 +523,7 @@ ivas_error acelp_core_dec_fx( { tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame ); } -#if 1 // def IVAS_CODE + /*----------------------------------------------------------------* * Decoding of GSC IVAS mode *----------------------------------------------------------------*/ @@ -611,7 +543,7 @@ ivas_error acelp_core_dec_fx( move16(); } } -#endif + /*----------------------------------------------------------------* * Decoding of inactive CNG frames *----------------------------------------------------------------*/ @@ -623,22 +555,13 @@ ivas_error acelp_core_dec_fx( { CNG_dec_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); -#ifdef IVAS_CODE - local_element_mode = st_fx->element_mode; - move16(); - IF( ( EQ_16( nchan_out, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st_fx->masa_sid_format, 1 ) ) - { - local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */ - move16(); - } -#endif + /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, &st_fx->first_CNG, &( st_fx->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho, q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1, exc3_fx, st_fx->Opt_AMR_WB, st_fx->element_mode ); -#if 1 // def IVAS_CODE + Copy( Aq_fx, st_fx->Aq_cng, M + 1 ); // Q12 -#endif } ELSE { @@ -649,32 +572,7 @@ ivas_error acelp_core_dec_fx( *sid_bw = 0; move16(); } -#ifdef IVAS_CODE - if ( st->element_mode == IVAS_CPE_DFT ) - { - assert( nchan_out == 1 ); - for ( i = 0; i < NPART; i++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i]; - } -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - ApplyFdCng_fx( syn, 0, NULL, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng_fx( syn, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif - } - if ( !read_sid_info ) - { - float noise_lvl_highest; - - noise_lvl_highest = st->hFdCngDec->hFdCngCom->cngNoiseLevel[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1]; - for ( int16_t b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest; - } - } -#endif generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -809,10 +707,6 @@ ivas_error acelp_core_dec_fx( move16(); st_fx->last_nq_preQ = 0; move16(); -#ifdef IVAS_CODE - st_fx->last_code_preq = 0; - move16(); -#endif } st_fx->use_acelp_preq = 0; @@ -1409,103 +1303,8 @@ ivas_error acelp_core_dec_fx( #endif } /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - -#ifdef IVAS_CODE - if ( !st->cna_dirac_flag ) - { - /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - if ( st->flag_cna && !( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) - { - if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 ) - { - if ( hStereoCng->flag_cna_fade ) - { - generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); - hStereoCng->flag_cna_fade = 0; - } - else - { - if ( st->element_mode != last_element_mode && st->idchan == 0 ) - { - /* Clear memory for secondary channel CNA */ - set_f( hStereoCng->olapBufferSynth22, 0.0f, st->hFdCngDec->hFdCngCom->frameSize / 2 ); - } - - generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); - } - } - else if ( st->element_mode != IVAS_CPE_DFT ) - { - if ( st->idchan == 0 ) - { - if ( st->element_mode != last_element_mode ) - { - set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0.0f, st->hFdCngDec->hFdCngCom->fftlen ); - } - generate_masking_noise_fx( syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - } - } - } - else if ( st->flag_cna && st->coder_type == AUDIO && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == TCX_20_CORE ) ) - { - if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 ) - { - generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); - hStereoCng->flag_cna_fade = 1; - } - else - { - v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4, (float) ( st->hFdCngDec->hFdCngCom->fftlen / 2 ), temp_buf, st->hFdCngDec->hFdCngCom->frameSize / 2 ); - v_add( temp_buf, syn, syn, st->hFdCngDec->hFdCngCom->frameSize / 2 ); - } - } - else - { - if ( hStereoCng != NULL ) - { - hStereoCng->flag_cna_fade = 1; - hStereoCng->enableSecCNA = 0; - } - } - - if ( st->element_mode == IVAS_CPE_TD ) - { - /*Noise estimate*/ - if ( st->idchan == 0 && ( nchan_out == 2 || ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) - { -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - ApplyFdCng_fx( syn, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng_fx( syn, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif - } - } - } -#endif } -#ifdef IVAS_CODE - if ( !st->cna_dirac_flag ) - { - if ( st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == AMR_WB_CORE ) ) - { - v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); - v_add( temp_buf, syn, syn, st->L_frame / 2 ); - } - - if ( st->flag_cna == 0 || ( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) - { - if ( st->idchan == 0 ) - { - set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0.f, st->hFdCngDec->hFdCngCom->fftlen ); - } - if ( hStereoCng != NULL && st->idchan == 0 ) - { - set_f( hStereoCng->olapBufferSynth22, 0.f, st->hFdCngDec->hFdCngCom->fftlen ); - } - } - } -#else test(); test(); test(); @@ -1522,29 +1321,6 @@ ivas_error acelp_core_dec_fx( move16(); } } -#endif - -#ifndef IVAS_CODE - test(); - test(); - test(); - test(); - test(); - IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) - { - FOR( i = 0; i < st_fx->L_frame / 2; i++ ) - { - syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) ); - move16(); - } - } - - test(); - IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) ) - { - set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen ); - } -#endif } /*----------------------------------------------------------------* @@ -1589,20 +1365,6 @@ ivas_error acelp_core_dec_fx( test(); IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { -#ifdef IVAS_CODE - float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float imagBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float *pRealSave[CLDFB_NO_COL_MAX], *pImagSave[CLDFB_NO_COL_MAX]; - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - pRealSave[i] = realBufferSave[i]; - pImagSave[i] = imagBufferSave[i]; - } - if ( st->p_bpf_noise_buf ) - { - mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame ); - } -#endif /* analysis of the synthesis at internal sampling rate */ cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); @@ -1663,40 +1425,6 @@ ivas_error acelp_core_dec_fx( /* synthesis of the combined signal */ st_fx->Q_syn2 = st_fx->Q_syn; move16(); -#ifdef IVAS_CODE - if ( save_hb_synth != NULL ) - { - /* save and then zero-out lowband */ - for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBufferSave[i][j] = realBuffer[i][j]; - imagBufferSave[i][j] = imagBuffer[i][j]; - if ( j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots ) - { - realBuffer[i][j] = 0.0f; - imagBuffer[i][j] = 0.0f; - } - } - } - - cldfbSynthesis( realBuffer, imagBuffer, save_hb_synth, -1, st->cldfbSynHB ); - - /* restore lowband */ - for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBuffer[i][j] = realBufferSave[i][j]; - imagBuffer[i][j] = imagBufferSave[i][j]; - } - } - - cldfbSynthesis( pRealSave, pImagSave, synth, -1, st->cldfbSyn ); - } - else -#endif { cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); } @@ -1708,34 +1436,7 @@ ivas_error acelp_core_dec_fx( /* save synthesis - needed in case of core switching */ Copy( synth_out, st_fx->previoussynth_fx, output_frame ); } -#ifdef IVAS_CODE - ELSE - { - int16_t nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ - - /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ - cldfbAnalysis( syn + st->L_frame - nSamples, realBuffer, imagBuffer, nSamples, st->cldfbAna ); - - /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ - addBassPostFilter( bpf_error_signal + st->L_frame - nSamples, st->bpf_off ? 0 : nSamples, realBuffer, imagBuffer, st->cldfbBPF ); - /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ - cldfbSynthesis( realBuffer, imagBuffer, synth /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); - - if ( st->p_bpf_noise_buf ) - { - mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame ); - } - - set_f( synth, 0.0f, output_frame ); - } - - /* Copy output signal */ - if ( st->element_mode > EVS_MONO ) - { - mvr2r( syn, output, st->L_frame ); - } -#endif /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index b1cb2b516..aff7e5656 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -8,7 +8,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ -#define IVAS_CODE #define IVAS_CODE_AVQ /*-----------------------------------------------------------------* * transf_cdbk_dec() @@ -36,7 +35,6 @@ void transf_cdbk_dec_fx( Flag Overflow = 0; move32(); #endif -#ifdef IVAS_CODE Word16 avq_bit_sFlag; Word16 trgtSvPos; Word16 Nsv; @@ -50,7 +48,7 @@ void transf_cdbk_dec_fx( move16(); avq_bit_sFlag = 1; } -#endif + /*--------------------------------------------------------------* * Set bit-allocation *--------------------------------------------------------------*/ @@ -112,7 +110,7 @@ void transf_cdbk_dec_fx( *gain_preQ = round_fx( L_tmp ); /* Q2*/ move16(); } -#ifdef IVAS_CODE + trgtSvPos = sub( Nsv, 1 ); test(); test(); @@ -126,7 +124,7 @@ void transf_cdbk_dec_fx( move16(); move16(); } -#endif + /*--------------------------------------------------------------* * Demultiplex and decode subvectors from bit-stream *--------------------------------------------------------------*/ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 5a12d1a2c..60e13dd8f 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -36,11 +36,7 @@ ivas_error evs_dec_fx( Word16 exp, fra; Word16 tmp_buffer_fx[L_FRAME48k]; Word16 tmp16, tmp16_2; -#ifdef IVAS_CODE Word16 synth_fx[L_FRAME48k]; -#else - Word16 synth_fx[L_FRAME48k + HQ_DELTA_MAX * HQ_DELAY_COMP]; -#endif Word16 fb_exc_fx[L_FRAME16k]; Word16 pitch_buf_fx[NB_SUBFR16k] = { 0 }; Word16 Q_fb_exc; diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index a80cfe796..385339664 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -370,11 +370,8 @@ void decod_audio_fx( tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ move16(); -#ifdef IVAS_CODE - if ( st_fx->extl_brate_fx_orig > 0 ) -#else + if ( st_fx->extl_brate > 0 ) -#endif { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ @@ -873,17 +870,13 @@ void decod_audio_ivas_fx( tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ move16(); -#if 1 // def IVAS_CODE + if ( st_fx->extl_brate_orig > 0 ) -#else - if ( st_fx->extl_brate > 0 ) -#endif { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } - test(); test(); if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index caa164df9..5d8aee302 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -20,10 +20,6 @@ ivas_error init_decoder_fx( Decoder_State *st_fx, /* o: Decoder static variables structure */ const Word16 idchan /* i : channel ID */ -#ifdef IVAS_CODE - , - const MC_MODE mc_mode /* i : MC mode */ -#endif ) { Word16 i; @@ -778,11 +774,7 @@ ivas_error init_decoder_fx( resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 1 ); test(); -#ifdef IVAS_CODE - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) // TBV Fixed point missing -#else IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) -#endif { /* Create FD_CNG instance */ diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index becf60759..d263e6dd3 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -195,7 +195,6 @@ void lsf_dec_fx( /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */ move16(); - // PMTE() /*IVAS_CODE to be completed */ } } IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) @@ -449,7 +448,6 @@ void lsf_dec_ivas_fx( /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */ move16(); - // PMTE() /*IVAS_CODE to be completed */ } } IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index dcee88325..94d7f0471 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -329,7 +329,6 @@ ivas_error acelp_core_enc_fx( { IF( hTdCngEnc != NULL ) { - /*IVAS_CODE CNG_att is missing */ enr = cng_energy_fx( st_fx->element_mode, st_fx->bwidth, hDtxEnc->CNG_mode, /*st_fx->hTdCngEnc->CNG_att*/ 0, exc_fx, st_fx->L_frame, Q_new ); // Q8 /* calculate the energy quantization index */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index d7dd47256..90bdc74a5 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -351,12 +351,7 @@ void amr_wb_enc_fx( high_lpn_flag = 0; move16(); /* Q0 flag */ - long_enr_fx( st, Etot, localVAD_HE_SAD, high_lpn_flag -#ifdef IVAS_CODE - , - NULL, 1, NULL, NULL -#endif - ); + long_enr_fx( st, Etot, localVAD_HE_SAD, high_lpn_flag ); relE = sub( Etot, st->lp_speech_fx ); /* Q8 */ IF( NE_16( st->bwidth, NB ) ) @@ -441,9 +436,6 @@ void amr_wb_enc_fx( noise_est_fx( st, old_pitch1, tmpN, epsP_h, epsP_l, Etot, relE, corr_shift, tmpE, fr_bands, &cor_map_sum, NULL, &sp_div, &Q_sp_div, &non_staX, &harm_flag, lf_E, &hNoiseEst->harm_cor_cnt, hNoiseEst->Etot_l_lp_fx, hNoiseEst->Etot_v_h2_fx, &hNoiseEst->bg_cnt, st->lgBin_E_fx, Q_new, Le_min_scaled, &sp_floor, NULL, -#ifdef IVAS_CODE - NULL, NULL, -#endif st->ini_frame ); /*----------------------------------------------------------------* diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 15cc1a9e7..179d0230b 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -727,11 +727,6 @@ void CNG_enc_fx( test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - // PMT("Code to be completed") -#ifdef IVAS_CODE - att = powf( 10.0f, hTdCngEnc->CNG_att / 20.0f ); - v_multc( res1, att, res1, st->L_frame ); -#endif } ELSE IF( NE_16( st_fx->bwidth, NB ) ) { @@ -909,9 +904,6 @@ void CNG_enc_fx( test(); IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { - // PMT("CNG IVAS_SCE and IVAS_CPE_DFT code missing") - // IVAS_CODE - // enr += hTdCngEnc->CNG_att * FAC_LOG2 / 10.0f; } ELSE IF( NE_16( st_fx->bwidth, NB ) ) { @@ -2415,14 +2407,6 @@ void swb_CNG_enc_fx( } ELSE IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_32( st_fx->core_brate, SID_2k40 ) ) { - // PMT("CNG IVAS_CPE_DFT code not implemented") -#ifdef IVAS_CODE - /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ - delete_indice( st->hBstr, IND_CNG_ENV1 ); - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( st->hBstr, IND_UNUSED, 0, 4 ); - push_indice( st->hBstr, IND_SID_BW, 1, 1 ); -#endif } } hTdCngEnc->last_vad = 0; @@ -2450,9 +2434,6 @@ static void shb_CNG_encod_fx( Word16 idx_ener_fx; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef IVAS_CODE - Word16 ener_mid_dec_thr; -#endif idx_ener_fx = 0; move16(); @@ -2484,41 +2465,15 @@ static void shb_CNG_encod_fx( { idx_ener_fx = s_max( idx_ener_fx, 0 ); } -#ifdef IVAS_CODE - /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ - if ( st->element_mode != EVS_MONO ) - { - if ( abs( idx_ener - st->hTdCngEnc->last_idx_ener ) == 1 ) - { - ener_mid_dec_thr = 0.5f * ( ( st->hTdCngEnc->last_idx_ener / 0.7f - 6.0f ) / 0.1f ) * (float) log10( 2.0f ); - ener_mid_dec_thr += 0.5f * ( ( idx_ener / 0.7f - 6.0f ) / 0.1f ) * (float) log10( 2.0f ); - - if ( fabs( st->hTdCngEnc->mov_shb_cng_ener - ener_mid_dec_thr ) / ener_mid_dec_thr < ENER_MID_DEAD_ZONE ) - { - idx_ener = st->hTdCngEnc->last_idx_ener; - } - } - } - st->hTdCngEnc->last_idx_ener = idx_ener; -#endif push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); -#ifndef IVAS_CODE - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); - hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; - move16(); - move16(); -#else delete_indice( hBstr, IND_CNG_ENV1 ); -#endif -#ifdef IVAS_CODE - if ( st->element_mode == IVAS_CPE_DFT ) + + if ( st_fx->element_mode == IVAS_CPE_DFT ) { - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); } else -#endif { push_indice_fx( hBstr, IND_UNUSED, 0, 2 ); } @@ -2633,13 +2588,7 @@ static Word16 shb_DTX_fx( allow_cn_step_fx = 1; move16(); } -#ifdef IVAS_CODE - /* Also allow step if shb energy has dropped 12 dB */ - if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( ( hTdCngEnc->mov_shb_cng_ener - log_shb_ener ) > 12.0f ) ) - { - allow_cn_step = 1; - } -#endif + IF( EQ_16( allow_cn_step_fx, 1 ) ) { hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; @@ -2759,13 +2708,10 @@ void calculate_hangover_attenuation_gain_fx( test(); IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */ { -#ifdef IVAS_CODE if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) { - *att = powf( 10.0f, ( st->hTdCngEnc->CNG_att / 160.0f ) * st->hTdCngEnc->burst_ho_cnt ); } else -#endif { offset = 5; move16(); diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 6fa341a7b..dc3062298 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -373,31 +373,6 @@ void core_switching_pre_enc_fx( st_fx->EnergyLT_fx_exp = 30; move16(); /* Set to a High Exponent so it is 1^-30 */ } - /*---------------------------------------------------------------------* - * band-width switching from WB -> SWB/FB - *---------------------------------------------------------------------*/ -#ifdef IVAS_CODE - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( st_fx->bwidth_sw_cnt_fx == 0 ) - { - IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bwidth_sw_cnt_fx = add( st_fx->bwidth_sw_cnt_fx, 1 ); - } - } - ELSE - { - st_fx->bwidth_sw_cnt_fx = add( st_fx->bwidth_sw_cnt_fx, 1 ); - - IF( EQ_16( st_fx->bwidth_sw_cnt_fx, BWS_TRAN_PERIOD ) ) - { - st_fx->bwidth_sw_cnt_fx = 0; - move16(); - } - } - } -#endif return; } @@ -483,22 +458,6 @@ void core_switching_post_enc_fx( set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); -#ifdef IVAS_CODE - set16_fx( hBWE_TD->mem_shb_res_fx, 0, MAX_LEN_MA_FILTER ); - set16_fx( hBWE_TD->old_EnvSHBres_fx, 0, L_FRAME4k ); - hBWE_TD->old_mean_EnvSHBres_fx = 0; - hBWE_TD->prev_enr_EnvSHBres_fx = 32767; /*Q15 ??? */ - hBWE_TD->prev_shb_env_tilt_fx = 0; - hBWE_TD->prev_pow_exc16kWhtnd_fx = 32767; /*Q15 ??? */ - hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 ??? */ - hBWE_TD->prev_Env_error_fx = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); -#endif swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); @@ -531,14 +490,6 @@ void core_switching_post_enc_fx( hBWE_TD->fb_tbe_demph_fx = 0; fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } - /* Fade towards init value for non HQ_CORE */ - IF( st_fx->hHQ_core != NULL ) - { -#ifdef IVAS_CODE - st_fx->hHQ_core->crest_lp = HQ_CREST_FAC_SM * ( st_fx->hHQ_core->crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * HQ_CREST_THRESHOLD; - st_fx->hHQ_core->crest_mod_lp = HQ_CREST_FAC_SM * ( st_fx->hHQ_core->crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * HQ_CREST_MOD_THRESHOLD; -#endif - } } return; diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index be4368f69..a6b9e0aa4 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -662,11 +662,7 @@ void dtx_fx( move32(); #endif -#ifdef IVAS_CODE IF( st_fx->dtx_sce_sba != 0 ) -#else - if ( 0 ) -#endif { last_br_cng_flag = 1; last_br_flag = 1; @@ -770,9 +766,8 @@ void dtx_fx( /*------------------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX is enabled *------------------------------------------------------------------------*/ -#ifdef IVAS_CODE + if ( st_fx->dtx_sce_sba == 0 ) -#endif { br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) ); @@ -836,20 +831,7 @@ void dtx_fx( st_fx->core_brate = SID_2k40; move32(); } - // PMT("dtx_sce_sba code is missing") -#ifdef IVAS_CODE - IF( ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) ) - { - st_fx->cng_type = FD_CNG; - move16(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) ) - { - st_fx->codec_mode = MODE2; - move16(); - } - } - ELSE -#endif + { test(); test(); @@ -879,7 +861,6 @@ void dtx_fx( } } -#if 1 // def IVAS_CODE /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { @@ -889,7 +870,6 @@ void dtx_fx( reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); #endif } -#endif } /*------------------------------------------------------------------------* @@ -932,32 +912,6 @@ void dtx_fx( { IF( EQ_16( st_fx->element_mode, IVAS_SCE ) ) { -#ifdef IVAS_CODE - Word16 lp_thresh, fd_thresh; - PMT( "lp_thresh scaling is to be found" ) - test(); - IF( st_fx->Opt_DTX_ON && EQ_16( st_fx->dtx_sce_sba, 1 ) ) - { - lp_thresh = 5.f; - fd_thresh = 2.f; - } - ELSE - - { - lp_thresh = 10.f; - fd_thresh = 5.f; - } - - /*More conservative selection of LP-CNG for SCE*/ - if ( st->cng_type == LP_CNG && ( st->bckr_tilt_lt > lp_thresh ) ) - { - st->cng_type = FD_CNG; - } - else if ( st->cng_type == FD_CNG && ( st->bckr_tilt_lt < fd_thresh ) && ( st->lp_noise > 2.f ) ) - { - st->cng_type = LP_CNG; - } -#endif } ELSE { @@ -1630,11 +1584,6 @@ void td_cng_enc_init_fx( move16(); move16(); -#ifdef IVAS_CODE - hTdCngEnc->CNG_att_fx = 0; - hTdCngEnc->last_idx_ener_fx = 0; -#endif - hTdCngEnc->cng_buf_cnt = 0; diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index c4c544469..a01550978 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -324,22 +324,7 @@ void transf_cdbk_enc_fx( } st_fx->last_nq_preQ = nq[7]; move16(); -#ifdef IVAS_CODE - /* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ - if ( st->element_mode > EVS_MONO && st->coder_type != INACTIVE && st->core_brate >= MIN_BRATE_AVQ_EXC && st->core_brate <= MAX_BRATE_AVQ_EXC_TD && !harm_flag_acelp && code_preQ[0] != 0 ) - { - if ( (float) abs( st->last_code_preq ) > 16.0f * (float) fabs( code_preQ[0] ) ) - { - st->mem_preemp_preQ /= 16; - } - else if ( (float) abs( st->last_code_preq ) > 8.0f * (float) fabs( code_preQ[0] ) ) - { - st->mem_preemp_preQ /= 8; - } - } - st->last_code_preq = (int16_t) code_preQ[L_SUBFR - 1]; -#endif PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); /*--------------------------------------------------------------* diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 97db8d2a0..9cb2cd8e0 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2083,12 +2083,7 @@ Word16 cng_energy_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) || EQ_16( element_mode, IVAS_CPE_TD ) ) { - // PMT(" IVAS CNG ener computing is missing") -#ifdef IVAS_CODE - enr += CNG_att * FAC_LOG2 / 10.0f; -#else (void) CNG_att; -#endif } ELSE IF( NE_16( bwidth, NB ) ) { diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 200e538e4..79dc78c6d 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -93,21 +93,14 @@ Word16 find_uv_fx( /* o : coding type */ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ -#ifdef IVAS_CODE - Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ -#endif - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ const Word16 Q_new, Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ const Word16 shift, const Word16 last_core_orig /* i : original last core Q0*/ -#ifdef IVAS_CODE - , - STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ -#endif ) { Word16 coder_type, i; @@ -202,25 +195,7 @@ Word16 find_uv_fx( /* o : coding type */ pt_enr_ssf++; pt_enr_ssf1++; } -#ifdef IVAS_CODE - IF( hStereoClassif != NULL ) - { - IF( st_fx->idchan == 0 ) - { - hStereoClassif->dE1_ch1 = dE1; - } - ELSE - { - hStereoClassif->dE1_ch2 = dE1; - } - } - if ( dE1X != NULL ) - { - *dE1X = dE1; - move32(); - } -#endif /*-----------------------------------------------------------------* * Average spectral tilt * Average voicing (normalized correlation) @@ -564,24 +539,6 @@ Word16 find_uv_fx( /* o : coding type */ } } } -#ifdef IVAS_CODE - /*-----------------------------------------------------------------* - * UNCLR classifier - *-----------------------------------------------------------------*/ - - if ( hStereoClassif != NULL ) - { - if ( st->element_mode > EVS_MONO && ( coder_type == GENERIC || coder_type == UNVOICED || coder_type == INACTIVE || st->localVAD == 0 ) && hStereoClassif->unclr_sw_enable_cnt[st->idchan] < MAX_UV_CNT ) - { - hStereoClassif->unclr_sw_enable_cnt[st->idchan]++; - } - else - { - hStereoClassif->unclr_sw_enable_cnt[st->idchan] = 0; - } - } -#endif - /*-----------------------------------------------------------------* * Updates diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index f927940ae..6af068bae 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -467,11 +467,6 @@ void gain_enc_mless_fx( qua_table = gain_qua_mless_6b_fx; if ( element_mode > EVS_MONO ) { -#ifdef IVAS_CODE - qua_table = gain_qua_mless_6b_stereo; -#else - // PMTE() -#endif } move16(); if ( EQ_16( clip_gain, 1 ) ) diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 7964df4a8..7bb13239f 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -274,83 +274,7 @@ Word16 inov_encode_fx( IF( !Opt_AMR_WB ) { IF( st_fx->acelp_cfg.fcb_mode ) - { // PMTE() -#ifdef IVAS_CODE - if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] < ACELP_FIXED_CDK_NB ) - { - int16_t wordcnt, bitcnt; - int16_t prm[8]; - - if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 ) - { - if ( L_subfr == 2 * L_SUBFR ) - { - nBits = st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; - - if ( nBits == 8 ) - { - acelp_1t64( hBstr, dn, h1, code, y2, L_subfr ); - } - else - { - acelp_fast( hBstr, nBits, dn, cn, h1, code, y2, L_subfr ); - } - } - else if ( ( st->idchan == 1 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 7 ) || ( st->idchan == 0 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) ) - { - if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) - { - acelp_1t64( hBstr, dn, h1, code, y2, L_subfr ); - } - else - { - acelp_fast( hBstr, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], dn, cn, h1, code, y2, L_SUBFR ); - } - } - else - { - E_ACELP_4t( dn, cn, h1, Rw, acelpautoc, code, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], prm, L_frame, last_L_frame, st->total_brate, i_subfr, cmpl_flag ); - - wordcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) >> 4; - bitcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15; - - for ( i = 0; i < wordcnt; i++ ) - { - push_indice( hBstr, IND_ALG_CDBK_4T64, prm[i], 16 ); - } - if ( bitcnt ) - { - push_indice( hBstr, IND_ALG_CDBK_4T64, prm[i], bitcnt ); - } - - /* Generate weighted code */ - set_f( y2, 0.0f, L_SUBFR ); - for ( i = 0; i < L_SUBFR; i++ ) - { - /* Code is sparse, so check which samples are non-zero */ - if ( code[i] != 0 ) - { - for ( k = 0; k < L_SUBFR - i; k++ ) - { - y2[i + k] += code[i] * h1[k]; - } - } - } - } - } - else - { - set_f( code, 0.0f, L_SUBFR ); - set_f( y2, 0.0f, L_SUBFR ); - } - } -#ifdef DEBUGGING - else - { - IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid mode for acelp frame!\n" ); - } -#endif -#endif + { } ELSE { @@ -656,9 +580,7 @@ Word16 inov_encode_ivas_fx( IF( !Opt_AMR_WB ) { IF( st_fx->acelp_cfg.fcb_mode ) - { // PMTE() -#if 1 - //#ifdef IVAS_CODE + { Word16 idx = 0, idx2 = 0; move16(); move16(); @@ -748,7 +670,6 @@ Word16 inov_encode_ivas_fx( { IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid mode for acelp frame!\n" ); } -#endif #endif } ELSE diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 0916b2b09..5fe465f29 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -150,18 +150,13 @@ void ivas_long_enr_fx( *-----------------------------------------------------------------*/ return; } + + void long_enr_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) */ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ Word16 high_lpn_flag /* i : sp/mus LPN flag */ -#ifdef IVAS_CODE - , - FRONT_VAD_ENC_HANDLE hFrontVad[CPE_CHANNELS], /* i/o: front-VAD handles */ - const int16_t n_chan, /* i : number of channels */ - const int16_t localVAD_HE_SAD_LR[CPE_CHANNELS], /* i : HE-SAD flag without hangover LR channels */ - const float Etot_LR[CPE_CHANNELS] /* i : total channel energy LR channels */ -#endif ) { Word16 tmp; @@ -172,58 +167,7 @@ void long_enr_fx( * Compute long term estimate of total noise energy * and total active speech energy *-----------------------------------------------------------------*/ -#ifdef IVAS_CODE - Word16 n; - if ( hFrontVad != NULL ) - { - if ( hFrontVad[0]->ini_frame < 4 ) - { - for ( n = 0; n < n_chan; n++ ) - { - hFrontVad[n]->lp_noise = hFrontVad[n]->hNoiseEst->totalNoise; - tmp = hFrontVad[n]->lp_noise + 10.0f; - - if ( hFrontVad[n]->lp_speech < tmp ) - { - hFrontVad[n]->lp_speech = tmp; - } - } - } - else - { - float smooth_prev, smooth_curr; - - if ( hFrontVad[0]->ini_frame < 150 ) - { - smooth_prev = 0.95f; - smooth_curr = 0.05f; - } - else - { - smooth_prev = 0.98f; - smooth_curr = 0.02f; - } - for ( n = 0; n < n_chan; n++ ) - { - hFrontVad[n]->lp_noise = smooth_prev * hFrontVad[n]->lp_noise + smooth_curr * hFrontVad[n]->hNoiseEst->totalNoise; - - if ( localVAD_HE_SAD_LR[n] && !high_lpn_flag ) - { - if ( ( hFrontVad[n]->lp_speech - Etot_LR[n] ) < 10.0f ) - { - hFrontVad[n]->lp_speech = 0.98f * hFrontVad[n]->lp_speech + 0.02f * Etot_LR[n]; - } - else - { - hFrontVad[n]->lp_speech = hFrontVad[n]->lp_speech - 0.05f; - } - } - } - } - } - else -#endif { IF( LT_16( st_fx->ini_frame, 4 ) ) { diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index de5e474a0..96ab40547 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -78,9 +78,6 @@ void lsf_enc_fx( Word16 int_fs; Word16 force_sf = 0; Word16 fec_lsf[M], stab, i; -#ifdef IVAS_CODE - Word16 param_lpc[NPRM_LPC_NEW]; -#endif Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -199,19 +196,6 @@ void lsf_enc_fx( Copy( lsf_new, st_fx->lsf_old_fx, M ); } /* set seed_acelp used in UC mode */ -#ifdef IVAS_CODE - test(); - IF( EQ_16( coder_type, UNVOICED ) && GT_16( st_fx->element_mode, EVS_MONO ) ) - { - st_fx->seed_acelp = 0; - move16(); - FOR( i = no_param_lpc - 1; i >= 0; i-- ) - { - /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ - st->seed_acelp = (int16_t) ( ( ( ( st->seed_acelp ) >> 1 ) + param_lpc[i] ) * 31821L + 13849L ); - } - } -#endif IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { /* return if SID frame (conversion to A(z) done in the calling function) */ @@ -3534,14 +3518,6 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef IVAS_CODE - case 1: - { - ratio = tbl_mid_voi_wb_1b_fx; - move16(); - BREAK; - } -#endif } } ELSE IF( EQ_16( coder_type, UNVOICED ) ) @@ -3559,14 +3535,6 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef IVAS_CODE - case 4: - { - ratio = tbl_mid_gen_wb_4b_fx; - move16(); - BREAK; - } -#endif case 2: { ratio = tbl_mid_gen_wb_2b_fx; diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 27a48652a..68eed3d65 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -192,11 +192,11 @@ void noise_est_init_fx( hNoiseEst->totalNoise_fx = 0; move16(); hNoiseEst->first_noise_updt = 0; - // hNoiseEst->first_noise_updt_cnt_fx = 0; IVAS_CODE ?? move16(); hNoiseEst->aEn = 6; - // hNoiseEst->aEn_inac_cnt = 0; IVAS_CODE + move16(); + hNoiseEst->aEn_inac_cnt = 0; move16(); hNoiseEst->harm_cor_cnt = 0; @@ -269,21 +269,7 @@ void noise_est_init_ivas_fx( ) { Word16 i; -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hNoiseEst->first_noise_updt = 0; - hNoiseEst->first_noise_updt_cnt = 0; - move16(); - move16(); - hNoiseEst->aEn = 6; - hNoiseEst->aEn_inac_cnt = 0; - hNoiseEst->harm_cor_cnt = 0; - hNoiseEst->bg_cnt = 0; - hNoiseEst->low_tn_track_cnt = 0; - move16(); - move16(); - move16(); - move16(); -#endif + FOR( i = 0; i < NB_BANDS; i++ ) { hNoiseEst->fr_bands1_fx[i] = 1; @@ -312,13 +298,14 @@ void noise_est_init_ivas_fx( hNoiseEst->totalNoise_fx = 0; move16(); hNoiseEst->first_noise_updt = 0; - // hNoiseEst->first_noise_updt_cnt_fx = 0; IVAS_CODE ?? + move16(); + hNoiseEst->first_noise_updt_cnt = 0; move16(); hNoiseEst->aEn = 6; - // hNoiseEst->aEn_inac_cnt = 0; IVAS_CODE move16(); - + hNoiseEst->aEn_inac_cnt = 0; + move16(); hNoiseEst->harm_cor_cnt = 0; move16(); hNoiseEst->bg_cnt = 0; @@ -890,11 +877,7 @@ void noise_est_fx( const Word32 Le_min_scaled, /*i : Minimum energy value in Q_new + Q_SCALE */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ Word16 S_map[], /* o : short-term correlation map Q7 */ -#ifdef IVAS_CODE - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ -#endif - const Word16 ini_frame /* i : Frame number (init) */ + const Word16 ini_frame /* i : Frame number (init) */ ) { Word16 alpha, alpha2, alpha2m1, alpham1; @@ -939,14 +922,8 @@ void noise_est_fx( #ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( ncharX ); #endif + /* Check if LR-VAD */ -#ifdef IVAS_CODE - IF( hFrontVad != NULL ) - { - hNoiseEst = hFrontVad->hNoiseEst; - } - ELSE -#endif { hNoiseEst = st_fx->hNoiseEst; } @@ -964,9 +941,6 @@ void noise_est_fx( move16(); /*st_fx->ener_RAT = 10.0f * (float)log10( mean(lf_E, 8));*/ -#ifdef IVAS_CODE - IF( hFrontVad == NULL ) -#endif { IF( hSpMusClas != NULL ) { @@ -1069,9 +1043,7 @@ void noise_est_fx( /*-----------------------------------------------------------------* * Multi-harmonic analysis *-----------------------------------------------------------------*/ -#ifdef IVAS_CODE - IF( hFrontVad == NULL ) -#endif + { IF( st_fx->hSpMusClas != NULL ) { @@ -1166,12 +1138,7 @@ void noise_est_fx( Ltmp2 = sum32_fx( &fr_bands[10], sub( st_fx->max_band, 9 ) ); wtmp = shl_o( 1, sub( add( Q_new, QSCALE ), 1 ), &Overflow ); -#ifdef IVAS_CODE - IF( ncharX != NULL ) - { - *ncharX = ftemp2 / ( ftemp + 1e-5f ); - } -#endif + test(); IF( L_msu( Ltmp, 100, wtmp ) < 0 || L_msu( Ltmp2, 100, wtmp ) < 0 ) { @@ -1332,9 +1299,6 @@ void noise_est_fx( move32(); /* calculation of non-stationarity measure for speech/music classification */ -#ifdef IVAS_CODE - IF( hFrontVad == NULL ) -#endif { test(); test(); @@ -1707,39 +1671,6 @@ void noise_est_fx( hNoiseEst->aEn = s_min( hNoiseEst->aEn, 6 ); hNoiseEst->aEn = s_max( hNoiseEst->aEn, 0 ); -#ifdef IVAS_CODE - /*-----------------------------------------------------------------* - * Stereo classifier - save raw aEn - *-----------------------------------------------------------------*/ - - if ( hStereoClassif != NULL ) - { - if ( ( non_sta > th_sta ) || - ( tmp_pc < TH_PC ) || - ( 0.5f * ( st->voicing[0] + st->voicing[1] ) > cor_max ) || - ( epsP[2] / epsP[16] > th_eps ) || - ( ( hNoiseEst->act_pred > 0.8f ) && ( non_sta2 > th_sta ) ) ) - { - /* active signal present - increment counter */ - hStereoClassif->aEn_raw[st->idchan] = add( hStereoClassif->aEn_raw[st->idchan], 2 ); - } - else - { - /* background noise present - decrement counter */ - hStereoClassif->aEn_raw[st->idchan] = sub( hStereoClassif->aEn_raw[st->idchan], 1 ); - } - - if ( GT_16( hStereoClassif->aEn_raw[st->idchan], 6 ) ) - { - hStereoClassif->aEn_raw[st->idchan] = 6; - } - else if ( hStereoClassif->aEn_raw[st->idchan] < 0 ) - { - hStereoClassif->aEn_raw[st->idchan] = 0; - } - } -#endif - /* Additional NNE detectors */ @@ -2192,18 +2123,6 @@ void noise_est_fx( move16(); } -#ifdef IVAS_CODE - IF( st_fx->element_mode > EVS_MONO ) - { - test(); - IF( hNoiseEst->first_noise_updt_cnt_fx > 0 && LT_16( hNoiseEst->first_noise_updt_cnt_fx, 100 ) ) - { - hNoiseEst->first_noise_updt_cnt_fx = add( hNoiseEst->first_noise_updt_cnt_fx, 1 ); - move16(); - } - } -#endif - return; } diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index bd3d4cb34..5a8f4aa7c 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -497,9 +497,6 @@ void pre_proc_fx( noise_est_fx( st, old_pitch1, tmpN, epsP_h, epsP_l, *Etot, relE, corr_shift, tmpE, fr_bands, &cor_map_sum, NULL, &sp_div, &Q_sp_div, &non_staX, &loc_harm, lf_E, &hNoiseEst->harm_cor_cnt, hNoiseEst->Etot_l_lp_fx, hNoiseEst->Etot_v_h2_fx, &hNoiseEst->bg_cnt, st->lgBin_E_fx, *Q_new, Le_min_scaled, &sp_floor, NULL, -#ifdef IVAS_CODE - NULL, NULL, -#endif st->ini_frame ); /*------------------------------------------------------------------* @@ -516,15 +513,7 @@ void pre_proc_fx( st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, -#ifdef IVAS_CODE - NULL, -#endif - corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig -#ifdef IVAS_CODE - , - NULL -#endif - ); + corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); /*----------------------------------------------------------------* * channel aware mode configuration * @@ -598,12 +587,7 @@ void pre_proc_fx( speech_music_classif_fx( st, new_inp_12k8, inp_12k8, localVAD_HE_SAD, lsp_new, cor_map_sum, epsP, PS, *Etot, old_cor, attack_flag, non_staX, relE, Q_esp, *Q_new, &high_lpn_flag, flag_spitch ); - long_enr_fx( st, *Etot, localVAD_HE_SAD, high_lpn_flag -#ifdef IVAS_CODE - , - NULL, 1, NULL, NULL -#endif - ); /* has to be after after sp_music classfier */ + long_enr_fx( st, *Etot, localVAD_HE_SAD, high_lpn_flag ); /* has to be after after sp_music classfier */ /*----------------------------------------------------------------* * Rewrite the VAD flag by VAD flag with DTX hangover for further processing) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c3e9d1b4c..0a058740b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -286,21 +286,14 @@ Word16 find_uv_fx( /* o : coding type const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ -#ifdef IVAS_CODE - Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ -#endif - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ const Word16 Q_new, Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ const Word16 shift, const Word16 last_core_orig /* i : original last core Q0*/ -#ifdef IVAS_CODE - , - STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ -#endif ); void fine_gain_quant_fx( @@ -401,11 +394,7 @@ void noise_est_fx( const Word32 Le_min_scaled, /*i : Minimum energy value in Q_new + Q_SCALE */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ Word16 S_map[], /* o : short-term correlation map Q7 */ -#ifdef IVAS_CODE - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ -#endif - const Word16 ini_frame /* i : Frame number (init) */ + const Word16 ini_frame /* i : Frame number (init) */ ); void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 295cff8a1..04f02d860 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -55,16 +55,7 @@ static void tonal_context_improv_fx( Encoder_State *st_fx, const Word32 PS[], co static void var_cor_calc_fx( const Word16 old_corr, Word16 *mold_corr, Word16 var_cor_t[], Word16 *high_stable_cor ); -static Word16 attack_det_fx( const Word16 *inp, const Word16 Qx, const Word16 last_clas, const Word16 localVAD, const Word16 coder_type, const Word32 total_brate -#ifdef IVAS_CODE - , - const Word16 element_mode, - const Word16 clas, - Word32 finc_prev[], - Word32 *lt_finc, - Word16 *last_strong_attack -#endif -); +static Word16 attack_det_fx( const Word16 *inp, const Word16 Qx, const Word16 last_clas, const Word16 localVAD, const Word16 coder_type, const Word32 total_brate ); static void order_spectrum_fx( Word16 *vec, Word16 len ); @@ -1336,12 +1327,7 @@ static void sp_mus_classif_2nd_fx( var_cor_calc_fx( st->old_corr_fx, &hSpMusClas->mold_corr_fx, hSpMusClas->var_cor_t_fx, &hSpMusClas->high_stable_cor ); /* attack detection */ - attack = attack_det_fx( inp, Qx, st->clas, st->localVAD, st->coder_type, st->total_brate -#ifdef IVAS_CODE - , - EVS_MONO, st->clas, hSpMusClas->finc_prev, &hSpMusClas->lt_finc, &hSpMusClas->last_strong_attack -#endif - ); + attack = attack_det_fx( inp, Qx, st->clas, st->localVAD, st->coder_type, st->total_brate ); test(); test(); @@ -1487,22 +1473,11 @@ static Word16 attack_det_fx( /* o : attack flag const Word16 localVAD, /* i : local VAD flag */ const Word16 coder_type, /* i : coder type */ const Word32 total_brate /* i : total bitrate */ -#ifdef IVAS_CODE - , - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 clas, /* i : signal class */ - Word32 finc_prev[], /* i/o: previous finc */ - Word32 *lt_finc, /* i/o: long-term mean finc */ - Word16 *last_strong_attack /* i/o: last strong attack flag */ -#endif ) { Word16 i, j, tmp, tmp1, attack, exp1; Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG]; Word16 att_3lsub_pos; -#ifdef IVAS_CODE - Word16 attack1; -#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -1531,10 +1506,6 @@ static Word16 attack_det_fx( /* o : attack flag } attack = maximum_32_fx( finc, ATT_NSEG, &etmp ); -#ifdef IVAS_CODE - attack1 = attack; - move16(); -#endif move16(); test(); IF( EQ_16( localVAD, 1 ) && EQ_16( coder_type, GENERIC ) ) @@ -1600,37 +1571,6 @@ static Word16 attack_det_fx( /* o : attack flag } } } -#ifdef IVAS_CODE - test(); - test(); - test(); - IF( attack == 0 && GT_16( element_mode, EVS_MONO ) && ( LT_16( clas, VOICED_TRANSITION ) || EQ_16( clas, ONSET ) ) ) - { - Copy32( finc, finc_prev, attack1 ); - - /* compute mean energy before the attack */ - etmp = L_shr( sum32_fx( finc_prev, ATT_NSEG ), 5 ); /*ATT_NSEG == 32*/ - - etmp2 = finc[attack1]; - move32(); - test(); - test(); - if ( ( LT_32( L_shl( etmp, 4 ), etmp2 ) ) || ( LT_32( L_mult0( etmp, 12 ), etmp2 ) && EQ_16( last_clas, UNVOICED_CLAS ) ) ) - { - attack = attack1; - move16(); - } - PMT( "Size of lf_finc not verified yet" ) - test(); - if ( GT_32( L_mult0( 20, *lt_finc ), etmp2 ) || *last_strong_attack ) /*lt_finc assumes same Q as etmp2, TBV!!!! */ - { - attack = 0; - move16(); - } - } - *last_strong_attack = attack; - move16(); -#endif } ELSE IF( attack > 0 ) { @@ -1647,10 +1587,6 @@ static Word16 attack_det_fx( /* o : attack flag BREAK; } } -#ifdef IVAS_CODE - *last_strong_attack = 0; - move16(); -#endif } return attack; diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6292c4b33..7421921f0 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1780,9 +1780,10 @@ typedef struct enc_core_structure Word16 is_ism_format; /* Indication whether the codec operates in ISM format */ Word16 dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ - /*----------------------------------------------------------------------------------* - * Fixed point only variables - *----------------------------------------------------------------------------------*/ + + /*----------------------------------------------------------------------------------* + * Fixed point only variables + *----------------------------------------------------------------------------------*/ Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ @@ -1813,534 +1814,6 @@ typedef struct enc_core_structure } Encoder_State, *ENC_CORE_HANDLE; -// typedef struct Encoder_State_fx -//{ -// -// /*----------------------------------------------------------------------------------* -// * Common parameters - -// *----------------------------------------------------------------------------------*/ -// /*----------------------------------------------------------------------------------* -// * Stereo/IVAS parameters -// *----------------------------------------------------------------------------------*/ -// Word16 flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ -// -// Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ -// Word16 cna_dirac_flag; /* CNA in DirAC flag */ -// Word16 cng_sba_flag; /* CNG in SBA flag */ -// Word16 idchan; /* channel ID (audio channel number) */ -// Word16 element_mode; /* element mode */ -// Word16 last_element_mode; /* element mode */ -// Word16 low_rate_mode; /* low-rate mode flag */ -// MCT_CHAN_MODE mct_chan_mode; -// Word16 GSC_IVAS_mode; -// Word16 is_ism_format; /* Indication whether the codec operates in ISM format */ -// Word16 dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ -// -// -// //#ifdef IVAS_CODE -// -// #ifdef DEBUGGING -// Word16 id_element; /* element ID */ -// #endif -// Word32 element_brate; /* element bitrate */ -// Word16 extl_orig; /* extension layer */ -// Word32 extl_brate_orig; /* extension layer bitrate */ -// /*----------------------- End of IVAS specific--------------------------------------*/ -// -// -// Word16 codec_mode; /* MODE1 or MODE2 */ -// Word16 last_codec_mode; /* Previous Codec Mode*/ -// Word16 last_codec_mode_cng; /* Codec Mode of the last inactive frame*/ -// Word16 mdct_sw_enable; /* MDCT switching enable flag */ -// Word16 mdct_sw; /* MDCT switching indicator */ -// Word16 last_enerBuffer_exp; -// Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ -// Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME) */ -// -// BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ -// -// -// LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ -// -// -// Word32 input_Fs_fx; /* input signal sampling frequency in Hz */ -// Word32 total_brate_fx; /* total bitrate in kbps of the codec */ -// Word32 last_total_brate_fx; /* total bitrate in kbps of the codec */ -// Word32 last_total_brate_cng_fx; /* total bitrate in kbps of the last inactive frame */ -// Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ -// Word32 core_brate_fx; /* core bitrate */ -// Word32 last_core_brate_fx; /* previous frame core bitrate */ -// Word16 input_frame_fx; /* Frame lenght (function of input_Fs) */ -// Word16 extl_fx; /* extension layer */ -// Word16 last_extl_fx; /* previous extension layer */ -// Word32 extl_brate_fx; /* extension layer bitrate */ -// Word16 input_bwidth_fx; /* input signal bandwidth */ -// Word16 last_input_bwidth_fx; /* input signal bandwidth in the previous frame */ -// Word16 bwidth_fx; /* encoded bandwidth NB, WB, SWB or FB */ -// Word16 max_bwidth_fx; /* maximum encoded bandwidth */ -// Word16 last_bwidth_fx; /* input signal bandwidth in the previous frame */ -// Word16 last_bwidth_cng_fx; /* input signal bandwidth in the previous inactive frame */ -// Word16 L_frame_fx; /* ACELP core internal frame length */ -// Word16 Opt_AMR_WB_fx; /* flag indicating AMR-WB IO mode */ -// Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ -// Word16 cng_type_fx; /* flag indicating LP or CLDFB based SID/CNG */ -// Word16 active_fr_cnt_fx; /* counter of active frames */ -// Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ -// Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ -// /*----------------------------------------------------------------------------------* -// * ACELP core parameters -// *----------------------------------------------------------------------------------*/ -// -// Word16 clas_fx; /* current frame clas */ -// Word16 last_clas_fx; /* previous frame signal classification */ -// Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ -// -// /*----------------------------------------------------------------------------------* -// * General signal buffers -// *----------------------------------------------------------------------------------*/ -// Word16* input_buff; -// /*Word16* input; -// Word16* old_input_signal;*/ -// -// SIGNAL_BUFFERS_ENC_HANDLE hSignalBuf; -// -// Word32* Bin_E_old_fx; /* per bin energy of old 2nd frames */ -// Word16* mem_decim_fx; /* decimation filter memory */ -// Word16* mem_decim16k_fx; /* ACELP@16kHz - decimation filter memory @16kHz */ -// Word16* old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ -// Word16* old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ -// -// Word16* buf_speech_enc_pe; -// Word16* buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ -// Word16* buf_speech_enc; -// Word16* buf_wspeech_enc; -// -// -// Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame */ -// Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame */ -// Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame */ -// Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame */ -// Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz */ -// Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz */ -// Word16 pstreaklen_fx; /* LSF quantizer */ -// Word16 streaklimit_fx; /* LSF quantizer */ -// Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ -// Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ -// Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ -// Word32 offset_scale2_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 2nd 8-dim subvector*/ -// Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/ -// Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/ -// Word16 stab_fac_fx; /* LSF stability factor */ -// Word16 mem_deemph_fx; /* deemphasis filter memory */ -// Word16 mem_preemph_fx; /* preemphasis filter memory */ -// Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ -// Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */ -// /*Word16 old_exc_fx[L_EXC_MEM];*/ /* old excitation vector */ -// Word16 old_wsp2_fx[(L_WSP_MEM - L_INTERPOL) / OPL_DECIM]; /* old decimated weighted signal vector qwsp */ -// -// /*----------------------------------------------------------------------------------* -// * Noise estimation -// *----------------------------------------------------------------------------------*/ -// -// NOISE_EST_HANDLE hNoiseEst; -// -// Word16 mem_wsp_fx; /* weighted signal vector memory */ -// Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ -// Word16 clip_var_fx[6]; -// Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) */ -// Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) */ -// Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ -// Word16 coder_type_raw_fx; -// Word16 last_coder_type_raw_fx; /* raw last_coder_type (coming from the sigal classification) */ -// Word16 last_coder_type; /*Q0 previous coding type */ -// Word16 ini_frame_fx; /* initialization frames counter */ -// Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */ -// Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ -// Word16 old_pitch; /* previous pitch for open-loop pitch search Q0 */ -// Word16 delta_pit_fx; /* open-loop pitch extrapolation correction Q0 */ -// Word32 ee_old_fx; -// Word16 min_band_fx; /* Q0 minimum critical band of useful bandwidth */ -// Word16 max_band_fx; /* Q0 maximum critical band of useful bandwidth */ -// Word16 tc_cnt_fx; /* TC frame counter */ -// Word16 audio_frame_cnt_fx; /* Counter of relative presence of audio frames */ -// Word32 old_dE1_fx; /* Maximum energy increase in previous frame */ -// Word16 old_ind_deltaMax_fx; /* Index of the sub-subframe of maximum energy in previous frame */ -// Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ -// Word16 spike_hyst_fx; /* Hysteresis to prevent UC after sharp energy spike */ -// Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ -// Word16 last_harm_flag_acelp_fx; /* harmonicity flag for ACELP @32kbps rate */ -// Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ -// Word16 old_Es_pred_fx; /* Q8 old Es_pred for core switching */ -// -// GSC_ENC_HANDLE hGSCEnc; -// -// -// Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ -// -// SP_MUS_CLAS_HANDLE hSpMusClas; -// -// Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ -// -// /* speech/music classifier improvement parameters */ -// Word16 last_vad_spa_fx; -// -// -// Word16 Last_pulse_pos_fx; /* FEC - last position of the first glotal pulse in the frame */ -// Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame */ -// Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame */ -// Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC */ -// Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ -// -// -// /*----------------------------------------------------------------------------------* -// * VAD/DTX/CNG -// *----------------------------------------------------------------------------------*/ -// -// VAD_HANDLE hVAD; -// -// VAD_CLDFB_HANDLE hVAD_CLDFB; -// Word16 lp_speech_fx; -// Word16 Opt_HE_SAD_ON_fx; -// Word16 nb_active_frames_HE_SAD_fx; -// -// -// -// -// Word16 voicing_old_fx; -// -// -// Word32 bckr_tilt_lt; -// -// -// TD_CNG_ENC_HANDLE hTdCngEnc; -// -// DTX_ENC_HANDLE hDtxEnc; -// Word16 var_SID_rate_flag_fx; /* CNG and DTX - flag for variable SID rate */ -// Word16 interval_SID_fx; /* CNG and DTX - interval of SID update, default 8 */ -// -// Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation */ -// -// Word16 uv_count; /*Q0*/ /* Stationary noise UV modification - unvoiced counter */ -// Word16 act_count; /*Q0*/ /* Stationary noise UV modification - activation counter */ -// Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain */ -// Word16 lspold_s_fx[M]; /*Q15*/ /* Stationary noise UV modification - old LSP vector */ -// Word16 noimix_seed; /*Q0*/ /* Stationary noise UV modification - mixture seed */ -// Word16 min_alpha_fx; /*Q15*/ /* Stationary noise UV modification - minimum alpha */ -// Word16 exc_pe_fx; /* Stationary noise UV modification - memory of the preemphasis filter */ -// -// Word16 last_L_frame_fx; /* ACELP@16kHz - last L_frame value */ -// Word16 mem_preemph16k_fx; /* ACELP@16kHz - preemphasis filter memory @16kHz */ -// Word16 mem_deemp_preQ_fx; /* ACELP@16kHz - prequantizer deemhasis memory */ -// Word16 mem_preemp_preQ_fx; /* ACELP@16kHz - prequantizer preemhasis memory */ -// Word16 last_nq_preQ; /* ACELP@16kHz - AVQ subquantizer number of the last sub-band of the last subframe */ -// Word16 use_acelp_preq; /* ACELP@16kHz - flag of prequantizer usage */ -// -// Word16 bpf_off_fx; -// Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /*Q6 Bass post-filter - buffer of old subframe pitch values */ -// -// -// /* stable short pitch detection */ -// Word16 voicing0_sm_fx; -// Word16 voicing_sm_fx; -// Word16 LF_EnergyRatio_sm_fx; -// Word16 predecision_flag_fx; -// Word32 diff_sm_fx; -// Word32 energy_sm_fx; -// -// Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ -// -// /*----------------------------------------------------------------------------------* -// * AMR-WB IO handle -// *----------------------------------------------------------------------------------*/ -// HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; -// -// AMRWB_IO_ENC_HANDLE hAmrwb_IO; /* AMR-WB IO encoder handle */ -// -// /*----------------------------------------------------------------------------------* -// * CLDFB analysis -// *----------------------------------------------------------------------------------*/ -// HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; -// -// HANDLE_CLDFB_FILTER_BANK cldfbSyn_Fx; -// -// /*----------------------------------------------------------------------------------* -// * FD CNG handle -// *----------------------------------------------------------------------------------*/ -// HANDLE_FD_CNG_ENC_FX hFdCngEnc_fx; -// Word16 fd_cng_reset_flag; -// Word16 last_totalNoise_fx; -// Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; -// Word16 totalNoise_increase_len_fx; -// /*----------------------------------------------------------------------------------* -// * SC-VBR parameters -// *----------------------------------------------------------------------------------*/ -// -// /*----------------------------------------------------------------------------------* -// * SC-VBR parameters -// *----------------------------------------------------------------------------------*/ -// -// SC_VBR_ENC_HANDLE hSC_VBR; -// -// /*----------------------------------------------------------------------------------* -// * HQ core parameters -// *----------------------------------------------------------------------------------*/ -// Word16 * input; -// Word16 * old_input_signal_fx; -// Word16 Q_old_wtda; -// Word16 old_hpfilt_in_fx; -// Word16 old_hpfilt_out_fx; -// Word32 EnergyLT_fx; -// Word32 Energy_Old_fx; -// Word16 TransientHangOver_fx; -// Word16 last_core_fx; -// -// HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ -// -// Word16 Nb_ACELP_frames_fx; -// -// PVQ_ENC_HANDLE hPVQ; -// -// /*----------------------------------------------------------------------------------* -// * TD BWE parameters -// *----------------------------------------------------------------------------------*/ -// -// TD_BWE_ENC_HANDLE hBWE_TD; -// -// /*----------------------------------------------------------------------------------* -// * FD BWE parameters -// *----------------------------------------------------------------------------------*/ -// -// FD_BWE_ENC_HANDLE hBWE_FD; -// -// /*----------------------------------------------------------------------------------* -// * WB, SWB and FB bandwidth detector -// *----------------------------------------------------------------------------------*/ -// -// Word16 lt_mean_NB_fx; -// Word16 lt_mean_WB_fx; -// Word16 lt_mean_SWB_fx; -// Word16 count_WB_fx; -// Word16 count_SWB_fx; -// Word16 count_FB_fx; -// -// RF_ENC_HANDLE hRF; /* RF encoder handle */ -// -// Word16 rf_mode; -// Word16 rf_target_bits_write; -// Word16 rf_mode_last; -// Word16 last_rf_mode_cng; -// Word16 Opt_RF_ON; -// Word16 rf_fec_offset; -// Word16 rf_fec_indicator; -// -// /*----------------------------------------------------------------------------------* -// * Fixed point only variables -// *----------------------------------------------------------------------------------*/ -// -// Word16 prev_Q_bwe_exc; -// Word16 prev_Q_bwe_syn; -// Word16 Q_stat_noise_ge; -// Word16 Q_stat_noise; -// Word16 Q_syn2; -// Word16 Q_syn; -// Word16 Q_max[L_Q_MEM]; -// Word16 Q_max_16k[L_Q_MEM]; -// Word16 Q_old; -// Word16 prev_Q_old; -// Word16 old_wsp_max; /* Last weigthed speech maximal value */ -// Word16 old_wsp_shift; /* Last wsp scaling */ -// Word16 prev_Q_new; -// Word16 prev_Q_shb; -// -// /*----------------------------------------------------------------------------------* -// * -// *----------------------------------------------------------------------------------*/ -// -// Word16 EnergyLT_fx_exp; -// Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; -// Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; -// Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; -// -// Word16 frame_size_index; /* 0-FRAME_SIZE_NB-1: index determining the frame size */ -// Word16 bits_frame_nominal; /* avg bits per frame on active frame */ -// Word16 bits_frame; /* total bits per frame */ -// Word16 bits_frame_core; /* bits per frame for the core */ -// Word8 narrowBand; -// -// /*ACELP config*/ -// ACELP_config acelp_cfg; /* configuration set for each frame */ -// -// ACELP_config acelp_cfg_rf; /* configuration for RF frame */ -// -// Word16 mode_index; /* Mode Index for LPD core */ -// -// /*TCX config*/ -// TCX_CONFIG_HANDLE hTcxCfg; -// /*----------------------------------------------------------------------------------* -// * TCX core encoder handle -// *----------------------------------------------------------------------------------*/ -// -// TCX_ENC_HANDLE hTcxEnc; -// -// /* cod_main.c */ -// Word16 mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ -// -// -// Word16 *speech_enc; -// Word16 *speech_enc_pe; -// Word16 *new_speech_enc; -// Word16 *new_speech_enc_pe; -// Word16 *wspeech_enc; -// Word16 *synth; -// /* Core Signal Analysis Outputs */ -// -// Word8 enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -// Word16 envWeighted; /* are is{p,f}_old_q[] weighted or not? */ -// -// Word8 acelpEnabled; /* Flag indicating if ACELP can be used */ -// Word8 tcx10Enabled; /* Flag indicating if TCX 10 can be used */ -// Word8 tcx20Enabled; /* Flag indicating if TCX 20 can be used */ -// -// -// Word16 mem_wsp_enc; /* wsp vector memory */ -// -// Word16 nb_bits_header_ace; /* number of bits for the header */ -// Word16 nb_bits_header_tcx; /* number of bits for the header */ -// -// /*Added by fcs : restrict the possible in EVS: 0 base 10 = d.c.b.a base 2*/ -// /* a = 0/1 : ACELP on/off*/ -// /* b = 0/1 : TCX20 on/off*/ -// /* c = 0/1 : TCX40 on/off*/ -// /* d = 0/1 : TCX80 on/off*/ -// Word16 restrictedMode; -// -// /* Framing */ -// Word16 nb_subfr; -// -// Word16 preemph_fac; /*Preemphasis factor*/ -// -// Word16 gamma; -// Word16 inv_gamma; -// -// TransientDetection transientDetection; -// Word16 transient_info[3]; -// -// Word16 acelpFramesCount; /* Acelp frame counter. Counts upto 50 only !!! */ -// -// Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E */ -// -// Word32 prevEnergyHF_fx; -// Word32 currEnergyHF_fx; -// Word16 currEnergyHF_e_fx; /* exponent of currEnergyHF and prevEnergyHF */ -// Word32 energyCoreLookahead_Fx; -// Word16 sf_energyCoreLookahead_Fx; -// -// /* lsf quantizer*/ -// Word16 parcorr[2]; -// Word16 parcorr_mid[2]; -// -// Word16 lpcQuantization; -// Word16 numlpc; -// Word16 encoderLookahead_enc; -// Word16 encoderPastSamples_enc; -// Word16 encoderLookahead_FB; -// -// /* pitch_ol for adaptive lag window */ -// Word16 old_pitch_la; /* past open loop pitch lag from look-ahead */ -// Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ -// -// Word32 band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor MODE2_E_MIN */ -// Word16 band_energies_exp; /* exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ -// -// Word8 tcxonly; -// -// Word16 Q_max_enc[2]; -// -// Word16 finalVAD; -// Word8 flag_noisy_speech_snr; /*encoder detector for noisy speech*/ -// Word16 Pos_relE_cnt; /* Number of frames between positive relE */ -// -// Word16 fscale; -// Word32 sr_core; -// Word32 last_sr_core; -// Word8 acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ -// -// Word16 pit_min; -// Word16 pit_fr1; -// Word16 pit_fr1b; -// Word16 pit_fr2; -// Word16 pit_max; -// Word16 pit_res_max; /* goes from 1 upto 6 (see core_enc_init.c: init_acelp()) */ -// -// /* for FAC */ -// Word16 L_frame_past; -// -// /*Adaptive BPF*/ -// Word16 bpf_gain_param; -// Word16 bpf_T[NB_SUBFR16k]; -// Word16 bpf_gainT[NB_SUBFR16k]; -// -// struct MEM_BPF -// { -// Word16 noise_buf[2 * L_FILT16k]; -// Word16 error_buf[L_FILT16k]; -// Word32 lp_error; -// Word32 lp_error_ener; -// Word16 noise_shift_old; -// } mem_bpf; -// -// -// -// Word8 glr; -// Word16 glr_idx[2]; -// Word32 gain_code[NB_SUBFR16k]; -// Word32 mean_gc[2]; -// Word16 prev_lsf4_mean; -// Word16 last_stab_fac; -// Word8 glr_reset; -// -// /*for rate switching*/ -// Word16 rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ -// Word16 rate_switching_reset_16kHz; -// -// Word16 enablePlcWaveadjust; -// Word16 Tonal_SideInfo; -// -// IGF_ENC_INSTANCE_HANDLE hIGFEnc; /* IGF encoder handle */ -// Word16 igf; -// -// Word16 seed_acelp; -// -// PLC_ENC_EVS_HANDLE hPlcExt; -// -// Word16 tec_tfa; -// TEC_ENC_HANDLE hTECEnc; /* TEC encoder handle */ -// Word16 tec_flag; -// Word16 tfa_flag; -// Word32 tfa_enr[N_TEC_TFA_SUBFR]; -// -// Word16 nTimeSlots; /* for CLDFB */ -// -// T_CldfbVadState_fx vad_st; -// -// -// Word16 pitch_fx[3]; -// Word16 voicing_fx[3]; -// Word16 sp_aud_decision0; /* 1st stage speech/music classification */ -// Word16 sp_aud_decision1; /* 1st stage speech/music classification */ -// Word16 sp_aud_decision2; /* 2nd stage speech/music classification */ -// Word16 coder_type; /* coder type */ -// Word16 vad_flag; -// Word16 sharpFlag; /* formant sharpening flag */ -// Word16 localVAD; -// -// Word16 tdm_pc; -// Word16 prev_fmerit; -// Word16 fmerit_dt; -// -// -// } Encoder_State, * ENC_CORE_HANDLE_FX; typedef struct GainItemStr { diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 77d7f538f..fb2a6215b 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -332,7 +332,7 @@ void updt_IO_switch_enc_fx( * * Common updates for MODE1 and MODE2 *-------------------------------------------------------------------*/ -#if 1 + void updt_enc_common_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 Etot, /* i : total energy */ @@ -343,27 +343,24 @@ void updt_enc_common_fx( * Updates - main main codec parameters *---------------------------------------------------------------------*/ - st->last_sr_core = st->sr_core; //## + st->last_sr_core = st->sr_core; move32(); st->last_codec_mode = st->codec_mode; move16(); - st->last_L_frame = st->L_frame; // + st->last_L_frame = st->L_frame; move16(); st->last_core = st->core; move16(); st->last_core_brate = st->core_brate; move32(); -#ifdef IVAS_CODE - st->last_bits_frame_nominal_fx = st->bits_frame_nominal; -#endif st->last_total_brate = st->total_brate; move32(); - st->last_extl = st->extl; // + st->last_extl = st->extl; move16(); - st->last_input_bwidth = st->input_bwidth; //## + st->last_input_bwidth = st->input_bwidth; move16(); - st->last_bwidth = st->bwidth; //## + st->last_bwidth = st->bwidth; move16(); st->hNoiseEst->Etot_last_fx = Etot; move16(); @@ -425,18 +422,12 @@ void updt_enc_common_fx( move16(); move16(); -#ifdef IVAS_CODE test(); test(); test(); IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) { - st->hTdCngEnc->CNG_att_fx = 0; - move16(); - - apply_scale( &st->hTdCngEnc->CNG_att, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); } -#endif } } @@ -550,17 +541,14 @@ void updt_enc_common_fx( /*---------------------------------------------------------------------* * Other updates *---------------------------------------------------------------------*/ -#ifdef IVAS_CODE + test(); IF( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL ) { - st->hTcxEnc->tcxltp_norm_corr_mem = st->hTcxEnc->tcxltp_norm_corr_past; - move16(); } -#endif return; } -#endif + void updt_enc_common_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 12ec31933..1fdcb94fa 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1296,19 +1296,9 @@ Word16 wb_vad_fx( L_tmp = L_shl( L_mult( sub( hNoiseEst->Etot_v_h2_fx, nv_ofs ), nv ), 7 ); /* Q8+Q8+1 +7 --> Q24 */ L_tmp = L_mac( L_tmp, nc, (Word16) 32767 ); /* Q8+Q15+1 = Q24 */ thr1 = mac_r( L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */ -#ifdef IVAS_CODE - IF( st->element_mode > EVS_MONO && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) - { - /* lower threshold during warmup time */ - thr1 -= 10.0f; - vad_thr = 0.f; - } -#endif + IF( GT_16( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) /* if (lp_snr > 20.0f )*/ { -#ifdef IVAS_CODE - IF( st->element_mode == EVS_MONO || GT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) -#endif { /* thr1 = thr1 + 0.3f * (lp_snr - 20.0f); */ thr1 = add( thr1, mult( 9830, sub( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) ); /* Q15*Q8+1 -16 --> Q8 */ -- GitLab From 65df1d250d03b1181a37b3149b1f67285ae5f266 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 15:57:17 +0530 Subject: [PATCH 255/329] Clang formatting changes --- lib_enc/swb_bwe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 639ec9dca..3ca3f3f3f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -3205,7 +3205,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( tmp = i_mult2( n_band, L ); FOR( i = 0; i < L; i++ ) { - WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp-7 */ + WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp-7 */ WB_tenv_orig_fx = L_add( WB_tenv_orig_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp - 7 */ } -- GitLab From e46fb7a4a262cabfb315c91d213c418e14358ec7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:27:53 +0100 Subject: [PATCH 256/329] review and remove redundant code under IVAS_CODE_SWITCHING --- lib_com/prot_fx.h | 18 +-- lib_dec/core_switching_dec_fx.c | 279 ++------------------------------ lib_dec/evs_dec_fx.c | 10 +- 3 files changed, 16 insertions(+), 291 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index cb7416eb3..0371f747a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8011,22 +8011,12 @@ ivas_error core_switching_pre_dec_fx( ); ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ -#ifdef IVAS_CODE_SWITCHING - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ -#ifdef IVAS_CODE_SWITCHING - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const Word16 nchan_out, /* i : number of output channels */ -#endif - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ); ivas_error core_switching_post_dec_ivas_fx( diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index f984f2ce9..17b3f9fbc 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -16,10 +16,6 @@ * * *---------------------------------------------------------------------*/ -#ifdef IVAS_CODE_SWITCHING -static void core_switch_lb_upsamp( Decoder_State *st, float *output ); -static void smoothTransitionDtxToTcx( float synth[], const int16_t output_frame, const int16_t delay_comp ); -#endif static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); @@ -189,30 +185,11 @@ void bw_switching_pre_proc_fx( Flag Overflow = 0; move32(); #endif -#ifdef IVAS_CODE_SWITCHING + IF( st_fx->element_mode > EVS_MONO ) { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) && - st_fx->hBWE_FD != NULL && !( LE_16( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && - !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_16( last_element_brate, IVAS_SID_4k4 ) ) ) - { - /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - calc_tilt_bwe( old_syn_12k8_16k, &st->tilt_wb, st->L_frame ); - } - - return; } -#endif + test(); test(); IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) ) @@ -321,149 +298,7 @@ void bw_switching_pre_proc_fx( return; } -#ifdef IVAS_CODE_SWITCHING - - -/*---------------------------------------------------------------------* - * core_switch_lb_upsamp() - * - * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) - *---------------------------------------------------------------------*/ - -static void core_switch_lb_upsamp( - Decoder_State *st, /* i/o: Decoder state */ - float *output /* i/o: LB synth/upsampled LB synth */ -) -{ - int16_t i; - float *realBuffer[CLDFB_OVRLP_MIN_SLOTS], *imagBuffer[CLDFB_OVRLP_MIN_SLOTS]; - float realBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; - float imagBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; - - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for ( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) - { - set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - imagBuffer[i] = imagBufferTmp[i]; - } - - /* check if the CLDFB works on the right sample rate */ - if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) - { - resampleCldfb( st->cldfbAna, st->L_frame * FRAMES_PER_SEC ); - - if ( st->cldfbBPF != NULL && st->L_frame <= L_FRAME16k ) - { - resampleCldfb( st->cldfbBPF, st->L_frame * FRAMES_PER_SEC ); - } - - if ( st->ini_frame > 0 ) - { - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; - } - } - - /* analysis of the synthesis at internal sampling rate */ - cldfbAnalysis( output, realBuffer, imagBuffer, CLDFB_OVRLP_MIN_SLOTS * st->cldfbAna->no_channels, st->cldfbAna ); - - /* analysis and add the BPF error signal */ - if ( st->p_bpf_noise_buf ) - { - addBassPostFilter( st->p_bpf_noise_buf, st->bpf_off ? 0 : CLDFB_OVRLP_MIN_SLOTS * st->cldfbBPF->no_channels, realBuffer, imagBuffer, st->cldfbBPF ); - } - - /* set output mask for upsampling */ - if ( st->bwidth == NB ) - { - /* set NB mask for upsampling */ - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - 10; - } - else if ( st->cldfbSyn->bandsToZero != st->cldfbSyn->no_channels - st->cldfbAna->no_channels ) - { - /* in case of BW switching, re-init to default */ - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; - } - - /* synthesis of the combined signal */ - cldfbSynthesis( realBuffer, imagBuffer, output, CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels, st->cldfbSyn ); - - /* save synthesis - needed in case of core switching */ - if ( st->hTcxDec != NULL ) - { - mvr2r( output, st->previoussynth, st->hTcxDec->L_frameTCX ); - } - - return; -} - -/*---------------------------------------------------------------------* - * smoothTransitionMdctStereoDtx() - * - * apply smoothing to the transition part for MDCT-Stereo DTX - *---------------------------------------------------------------------*/ - -#define TRANSITION_SMOOTHING_LEN_16k 15 -#define TRANSITION_SMOOTHING_LEN_32k 31 -#define TRANSITION_SMOOTHING_LEN_48k 47 - -static void smoothTransitionMdctStereoDtx( - float synth[], /* i/o: synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t delay_comp /* i : delay compensation in samples */ -) -{ - int16_t i, filter_len; - float w, mem, step, fade_in; - float smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; - float smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; - - filter_len = TRANSITION_SMOOTHING_LEN_16k; - if ( output_frame == L_FRAME32k ) - { - filter_len = TRANSITION_SMOOTHING_LEN_32k; - } - else if ( output_frame == L_FRAME48k ) - { - filter_len = TRANSITION_SMOOTHING_LEN_48k; - } - - /* prepare buffer */ - for ( i = 0; i < filter_len / 2; i++ ) - { - smoothing_input_buffer[i] = synth[0]; - } - mvr2r( synth, smoothing_input_buffer + filter_len / 2, 2 * delay_comp + filter_len / 2 ); - - /* apply Mean filter */ - w = 1.f / filter_len; - mem = sum_f( smoothing_input_buffer, filter_len ); - for ( i = 0; i < 2 * delay_comp; i++ ) - { - smoothing_out_buffer[i] = w * mem; - mem = mem - smoothing_input_buffer[i] + smoothing_input_buffer[i + filter_len]; - } - /* apply fades around transition */ - step = 1.f / delay_comp; - fade_in = 0.f; - for ( i = 0; i < delay_comp; i++ ) - { - synth[i] = smoothing_out_buffer[i] * fade_in + synth[i] * ( 1 - fade_in ); - fade_in += step; - } - - fade_in = 0.f; - for ( ; i < 2 * delay_comp; i++ ) - { - synth[i] = synth[i] * fade_in + smoothing_out_buffer[i] * ( 1 - fade_in ); - fade_in += step; - } - - return; -} -#endif /*---------------------------------------------------------------------* * core_switching_pre_dec_fx() * @@ -738,13 +573,7 @@ ivas_error core_switching_pre_dec_fx( test(); test(); - IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) - //#ifdef IVAS_CODE_SWITCHING - // || ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD) || - // (EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && last_element_mode == IVAS_CPE_DFT)) && EQ_16(nchan_out,2) && - // NE_16(st_fx->core_brate, SID_2k40) && NE_16(st_fx->core_brate, FRAME_NO_DATA) && (EQ_16(last_core_brate_st0, FRAME_NO_DATA) || EQ_16(last_core_brate_st0, SID_2k40))) - //#endif - ) + IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ) { test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) @@ -770,14 +599,7 @@ ivas_error core_switching_pre_dec_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } -#ifdef IVAS_CODE_SWITCHING - if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && nchan_out == 2 && st->core_brate > SID_2k40 && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) && st->hTcxDec != NULL ) - { - /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ - set_f( st->hTcxDec->old_syn_Overl, 0.0f, L_FRAME32k / 2 ); - set_f( st->hFdCngDec->hFdCngCom->olapBufferAna, 0.0f, FFTLEN ); - } -#endif + set16_fx( st_fx->agc_mem_fx, 0, 2 ); st_fx->mem_deemph_fx = 0; move16(); @@ -876,47 +698,7 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); } } -#ifdef IVAS_CODE_SWITCHING - if ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE ) ) - { - if ( st->hBWE_TD != NULL ) - { - st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; - set_f( st->hBWE_TD->old_bwe_exc, 0, PIT16k_MAX * 2 ); - } - - st->tilt_code = 0.0f; - st->gc_threshold = 0.0f; - set_f( st->dispMem, 0, 8 ); - - st->last_coder_type = GENERIC; - - fer_energy( output_frame, UNVOICED_CLAS, st->previoussynth, -1, &st->enr_old, 1 ); - st->lp_gainp = 0.0f; - st->lp_gainc = (float) sqrt( st->lp_ener ); - - st->last_voice_factor = 0; - st->Last_GSC_noisy_speech_flag = 0; - - if ( st->output_Fs >= 16000 && st->hBWE_zero != NULL ) - { - hf_synth_reset( st->hBWE_zero ); - } - if ( st->hBWE_FD != NULL ) - { - set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - - if ( nchan_out == 1 && st->element_mode == IVAS_CPE_DFT && st->element_brate <= IVAS_24k4 && last_element_brate > IVAS_24k4 ) - { - /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ - int16_t offset; - offset = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels; - mvr2r( st->hTcxDec->old_synthFB + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state, offset ); - } - } -#endif test(); test(); test(); @@ -941,40 +723,16 @@ ivas_error core_switching_pre_dec_fx( { set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } -#ifdef IVAS_CODE_SWITCHING - if ( st->element_mode != EVS_MONO ) - { - /* Estimate mem_env_delta to reinit env_stab */ - tmp = max( 0, ENV_STAB_EST1 + ( ENV_STAB_EST2 * st->stab_fac_smooth_lt ) + ( ENV_STAB_EST3 * st->log_energy_diff_lt ) ); - st->hHQ_core->mem_env_delta = (int16_t) min( MAX16B, (int32_t) ( tmp * ( 1 << 12 ) ) ); /* Convert to Q12 and handle saturation */ - - if ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE ) - { - set_f( st->hHQ_core->old_out, 0, output_frame ); - set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); - } - st->hHQ_core->no_att_hangover = 0; - st->hHQ_core->energy_lt = 300.0f; - - set_s( st->hHQ_core->old_is_transient, 0, 3 ); - set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); - st->hHQ_core->prev_R = 0; - set_s( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); - st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; - st->hHQ_core->prev_ni_ratio = 0.5f; - set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS ); + if ( st_fx->element_mode != EVS_MONO ) + { } else -#endif { set16_fx( hHQ_core->old_out_fx, 0, output_frame ); hHQ_core->Q_old_wtda_LB = 15; hHQ_core->Q_old_wtda = 15; move16(); -#ifdef IVAS_CODE_SWITCHING - set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); -#endif } } @@ -1081,12 +839,10 @@ ivas_error core_switching_pre_dec_fx( IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) ) { test(); -#ifdef IVAS_CODE_SWITCHING IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame ); } -#endif + lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); test(); IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) @@ -1122,22 +878,12 @@ ivas_error core_switching_pre_dec_fx( *---------------------------------------------------------------------*/ ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ -#ifdef IVAS_CODE_SWITCHING - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ -#ifdef IVAS_CODE_SWITCHING - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const Word16 nchan_out, /* i : number of output channels */ -#endif - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ) { Word16 i, delay_comp, delta; @@ -1152,9 +898,6 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; -#ifdef IVAS_CODE_SWITCHING - int16_t offset; -#endif #ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( last_element_mode ); #endif diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 60e13dd8f..a5a5ba6d9 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -360,15 +360,7 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ - if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, -#ifdef IVAS_CODE_SWITCHING - output, output_mem[], IVAS_FORMAT ivas_format, use_cldfb_for_dft, -#endif - output_frame, core_switching_flag, -#ifdef IVAS_CODE_SWITCHING - sba_dirac_stereo_flag, nchan_out, -#endif - st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From d716d99ff0cda5fd84edb3c30aacb7d92c45ee25 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:29:26 +0100 Subject: [PATCH 257/329] remove redundant code under IVAS_CODE_FCB --- lib_dec/dec4t64_fx.c | 235 ------------------------------------------- 1 file changed, 235 deletions(-) diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 58f9048c4..ee6ef65a6 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -793,242 +793,7 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack return; } -#ifdef IVAS_CODE_FCB -/*-------------------------------------------------------* - * dec_1p_N1() - * - * Decode 1 pulse with N+1 bits - *-------------------------------------------------------*/ - -static void dec_1p_N1_L_subfr( - const int32_t index, /* i : quantization index */ - const int16_t nb_pos, /* i : number of positions */ - const int16_t N, /* i : nb. of bits */ - int16_t pos[] /* o : pulse position */ -) -{ - int16_t i, pos1; - int32_t mask; - - mask = ( ( 1 << N ) - 1 ); - pos1 = (int16_t) ( index & mask ); - i = (int16_t) ( index >> N ) & 1; - - if ( i == 1 ) - { - pos1 += nb_pos; - } - - pos[0] = pos1; - - return; -} - -/*-------------------------------------------------------* - * add_pulses() - * - * Add decoded pulses to the codeword - *-------------------------------------------------------*/ - -static void add_pulses_L_subfr( - const int16_t nb_pos, /* i : number of positions */ - const int16_t pos[], /* i : pulse position */ - const int16_t nb_pulse, /* i : nb. of pulses */ - const int16_t track, /* i : no. of the tracks */ - float code[] /* i/o: decoded codevector */ -) -{ - int16_t i, k; - - for ( k = 0; k < nb_pulse; k++ ) - { - i = ( ( pos[k] & ( nb_pos - 1 ) ) * NB_TRACK_FCB_4T ) + track; - if ( ( pos[k] & nb_pos ) == 0 ) - { - code[i] += 1.0f; - } - else - { - code[i] -= 1.0f; - } - } - - return; -} - -/*----------------------------------------------------------------------------------* - * dec_acelp_fast() - * - * fast algebraic codebook decoder - *----------------------------------------------------------------------------------*/ - -void dec_acelp_fast( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t cdk_index, /* i : codebook index */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -) -{ - int16_t k, pos[7], skip_track; - int32_t L_index; - PulseConfig config; - - skip_track = -1; - set_f( code, 0.0f, L_subfr ); - - if ( L_subfr == L_SUBFR ) - { - config = PulseConfTable[cdk_index]; - - if ( cdk_index == 2 ) - { - dec_acelp_2t32( st, code ); - } - else if ( config.nb_pulse == 2 ) - { - /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks) */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 ) - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - else if ( config.nb_pulse == 3 ) - { - if ( config.codetrackpos == TRACKPOS_FIXED_FIRST ) - { - /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k++ ) - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - else if ( config.codetrackpos == TRACKPOS_FREE_THREE ) - { - /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */ - skip_track = get_next_indice( st, 2 ); - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - if ( k != skip_track ) - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - } - } - else - { - if ( config.bits == 20 ) - { - skip_track = -1; - } - else if ( config.codetrackpos == TRACKPOS_FIXED_FIRST ) - { - skip_track = 0; - } - else if ( config.codetrackpos == TRACKPOS_FREE_ONE ) - { - skip_track = get_next_indice( st, 2 ); - } - - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - if ( k == skip_track ) - { - L_index = get_next_indice( st, 9 ); - dec_2p_2N1( L_index, 4, 0, pos ); - add_pulses( pos, 2, k, code ); - } - else - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - } - } - else /* L_subfr == 2*L_SUBFR */ - { - config.bits = cdk_index; - - if ( cdk_index == 14 ) - { - /* 14 bits, 2 pulses, 2 tracks: 11 (used all tracks) */ - int16_t index, i0, i1; - - index = get_next_indice( st, 14 ); - - i0 = ( ( index >> 7 ) & ( NB_POS_FCB_2T_128 - 1 ) ) * NB_TRACK_FCB_2T; - i1 = ( ( index & ( NB_POS_FCB_2T_128 - 1 ) ) * NB_TRACK_FCB_2T ) + 1; - - code[i0] = -1.0f; - if ( ( index & 0x2000 ) == 0 ) - { - code[i0] = 1.0f; - } - - code[i1] = -1.0f; - if ( ( index & 0x40 ) == 0 ) - { - code[i1] = 1.0f; - } - } - else if ( cdk_index == 12 ) - { - /* 12 bits, 2 pulses, 4 tracks: 1010 (used only even tracks) */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - else if ( cdk_index == 18 ) - { - /* 18 bits, 3 pulses, 4 tracks: 1110 (used first three tracks) */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k++ ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - else if ( cdk_index == 20 ) - { - /* 20 bits, 3 pulses, 4 tracks (used all tracks): 1110, 1101, 1011, 0111 */ - skip_track = get_next_indice( st, 2 ); - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - if ( k != skip_track ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - } - else if ( cdk_index == 24 ) - { - /* 24 bits, 4 pulses, 4 tracks: 1111 */ - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - } - - return; -} -#endif /*-------------------------------------------------------* * dec_1p_N1() -- GitLab From 3c022b6dac418d2aa99a2d0c7779a63d18c6ea4b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:34:25 +0100 Subject: [PATCH 258/329] remove redundant code under IVAS_CODE_CPE, IVAS_CODE_DFT, and IVAS_CODE_BWD --- lib_enc/amr_wb_enc_fx.c | 6 +----- lib_enc/analy_sp_fx.c | 24 ++---------------------- lib_enc/bw_detect_fx.c | 11 +++-------- lib_enc/pre_proc_fx.c | 6 +----- lib_enc/prot_fx_enc.h | 4 ---- 5 files changed, 7 insertions(+), 44 deletions(-) diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 90bdc74a5..5a3aec3f4 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -292,11 +292,7 @@ void amr_wb_enc_fx( * Detect NB spectrum in a 16kHz-sampled input *----------------------------------------------------------------*/ - analy_sp_fx( st->element_mode, -#ifdef IVAS_CODE_CPE - hCPE, -#endif - st->input_Fs, inp, Q_new, fr_bands, lf_E, &Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, + analy_sp_fx( st->element_mode, inp, Q_new, fr_bands, lf_E, &Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, PS, st->lgBin_E_fx, st->band_energies, fft_buff ); noise_est_pre_fx( Etot, st->ini_frame, hNoiseEst, 0, EVS_MONO, EVS_MONO ); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index d5333ae13..185bac26b 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -19,9 +19,7 @@ static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new2, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies ); static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies ); -#ifdef IVAS_CODE_CPE -static void find_enr_dft( CPE_ENC_HANDLE hCPE, const int32_t input_Fs, float DFT_past_DMX[], float band[], float *ptE, float *Etot, const int16_t min_band, const int16_t max_band, float *Bin_E, float *band_ener ); -#endif + /*-------------------------------------------------------------------* * analy_sp_fx() @@ -31,10 +29,6 @@ static void find_enr_dft( CPE_ENC_HANDLE hCPE, const int32_t input_Fs, float DFT void analy_sp_fx( const Word16 element_mode, /* i : element mode */ -#ifdef IVAS_CODE_CPE - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#endif - const Word32 input_Fs, /* i : input sampling rate */ Word16 *speech, /* i : speech buffer Q_new - preemph_bits */ const Word16 Q_new, /* i : current scaling exp Q0 */ Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */ @@ -60,9 +54,7 @@ void analy_sp_fx( Word16 Min_val, Max_val; Word16 Scale_fac2; Word16 fft_temp[L_FFT]; -#ifndef IVAS_CODE_CPE - (void) input_Fs; -#endif + /*-----------------------------------------------------------------* * Compute spectrum * find energy per critical frequency band and total energy in dB @@ -134,18 +126,6 @@ void analy_sp_fx( pt_fft += L_FFT; } } -#ifdef IVAS_CODE_CPE - ELSE - { - /* find energy per critical band */ - find_enr_dft( hCPE, input_Fs, hCPE->hStereoDft->DFT[0], pt_bands, lf_E, Etot, min_band, max_band, Bin_E, band_ener ); - mvr2r( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); - mvr2r( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); - mvr2r( band_ener, band_ener + NB_BANDS, NB_BANDS ); - mvr2r( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); - *Etot *= 2.f; - } -#endif /* Average total log energy over both half-frames */ frac_etot = 0; diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 931b175ff..2e9b2c5db 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -67,12 +67,6 @@ void bw_detect_fx( const Word32 *pt32; Word32 max_NB32, max_WB32, max_SWB32, max_FB32, mean_NB32, mean_WB32, mean_SWB32, mean_FB32; /* Q11*/ /* we need Word32 for the new cldfb energy vectors */ Word16 bwd_count_wider_bw; -#ifdef IVAS_CODE_DFT - Word16 l_frame; -#endif -#ifndef IVAS_CODE_BWD - (void) spectrum; -#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -1046,7 +1040,7 @@ void set_bw_fx( move16(); } } -//#ifdef IVAS_CODE_BWD + /*-------------------------------------------------------------------* * set_bw_stereo() @@ -1093,7 +1087,8 @@ void set_bw_stereo_fx( return; } -//#endif + + /*-------------------------------------------------------------------* * set_bw_mct() * diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 5a8f4aa7c..7c17e76d8 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -254,11 +254,7 @@ void pre_proc_fx( * Spectral analysis *--------------------------------------------------------------------------*/ - analy_sp_fx( -1, -#ifdef IVAS_CODE_CPE - NULL, -#endif - st->input_Fs, inp_12k8, *Q_new, fr_bands, lf_E, Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, + analy_sp_fx( -1, inp_12k8, *Q_new, fr_bands, lf_E, Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, PS, st->lgBin_E_fx, st->band_energies, fft_buff ); st->band_energies_exp = sub( sub( WORD32_BITS - 1, *Q_new ), QSCALE ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0a058740b..02f8344d1 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2190,10 +2190,6 @@ void stat_noise_uv_enc_ivas_fx( void analy_sp_fx( const Word16 element_mode, /* i : element mode */ -#ifdef IVAS_CODE_CPE - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#endif - const Word32 input_Fs, /* i : i sampling rate */ Word16 *speech, /* i : speech buffer Q_new - preemph_bits */ const Word16 Q_new, /* i : current scaling exp Q0 */ Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */ -- GitLab From 510e8af8c52190ec433eafe94526aa07e37e6ab0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:55:26 +0100 Subject: [PATCH 259/329] clang-format --- lib_com/gs_bitallocation_fx.c | 56 +++++++++++++++++------------------ lib_enc/lsf_enc_fx.c | 8 ++--- lib_enc/pre_proc_fx.c | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index e8f32c804..87ba794d4 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -230,9 +230,9 @@ void bands_and_bit_alloc_fx( nb_bands = shr( *pvq_len, 4 ); /*------------------------------------------------------------------------ - * Ajustement of the maximum number of bands in function of the - * dynamics of the spectrum (more or less speech like) - *-----------------------------------------------------------------------*/ + * Ajustement of the maximum number of bands in function of the + * dynamics of the spectrum (more or less speech like) + *-----------------------------------------------------------------------*/ test(); test(); test(); @@ -268,8 +268,8 @@ void bands_and_bit_alloc_fx( } /*------------------------------------------------------------------------ - * Find extra number of band to code according to bit rate availables - *-----------------------------------------------------------------------*/ + * Find extra number of band to code according to bit rate availables + *-----------------------------------------------------------------------*/ test(); WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) ) { @@ -279,15 +279,15 @@ void bands_and_bit_alloc_fx( } /*------------------------------------------------------------------------ - * Fractional bits to distribute on the first x bands - *-----------------------------------------------------------------------*/ + * Fractional bits to distribute on the first x bands + *-----------------------------------------------------------------------*/ { bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ } /*------------------------------------------------------------------------ - * Complete the bit allocation per frequency band - *-----------------------------------------------------------------------*/ + * Complete the bit allocation per frequency band + *-----------------------------------------------------------------------*/ imax = 5; move16(); @@ -315,8 +315,8 @@ void bands_and_bit_alloc_fx( } /*-------------------------------------------------------------------------- - * Complete the bit allocation per frequency band for 16kHz high brate mode - *--------------------------------------------------------------------------*/ + * Complete the bit allocation per frequency band for 16kHz high brate mode + *--------------------------------------------------------------------------*/ { FOR( j = st_band; j < nb_bands; j++ ) @@ -327,9 +327,9 @@ void bands_and_bit_alloc_fx( } /*-------------------------------------------------------------------------- - * Compute a maximum band (band offset) for the search on maximal energy - * This is function of the spectral dynamic and the bitrate - *--------------------------------------------------------------------------*/ + * Compute a maximum band (band offset) for the search on maximal energy + * This is function of the spectral dynamic and the bitrate + *--------------------------------------------------------------------------*/ bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) ); @@ -351,10 +351,10 @@ void bands_and_bit_alloc_fx( bandoffset = s_max( bandoffset, 0 ); /*-------------------------------------------------------------------------- - * Initiazed sorted vector - * For the first x bands to be included in th final sorted vector - * Sort the remaining bands in decrease energy order - *--------------------------------------------------------------------------*/ + * Initiazed sorted vector + * For the first x bands to be included in th final sorted vector + * Sort the remaining bands in decrease energy order + *--------------------------------------------------------------------------*/ FOR( j = 0; j < nb_tot_bands; j++ ) { max_ener_band[j] = -10; @@ -432,10 +432,10 @@ void bands_and_bit_alloc_fx( } } /*-------------------------------------------------------------------------- - * Bit sum verification for GSC inactive at very high rate - * The maximum number of bits per band of length 16 is 112 - * Redistribute the overage bits if needed - *--------------------------------------------------------------------------*/ + * Bit sum verification for GSC inactive at very high rate + * The maximum number of bits per band of length 16 is 112 + * Redistribute the overage bits if needed + *--------------------------------------------------------------------------*/ sum_bit = 0; move16(); j = 0; @@ -468,8 +468,8 @@ void bands_and_bit_alloc_fx( } } /*-------------------------------------------------------------------------- - * second step of bit sum verification, normally sum_bit == *bit - *--------------------------------------------------------------------------*/ + * second step of bit sum verification, normally sum_bit == *bit + *--------------------------------------------------------------------------*/ w_sum_bit = 0; move16(); FOR( i = 0; i < nb_bands; i++ ) @@ -497,15 +497,15 @@ void bands_and_bit_alloc_fx( } /*-------------------------------------------------------------------------- - * Recompute the real number/length of frequency bands to encode - *--------------------------------------------------------------------------*/ + * Recompute the real number/length of frequency bands to encode + *--------------------------------------------------------------------------*/ *nb_subbands = nb_bands; move16(); *pvq_len = shl( *nb_subbands, 4 ); /*-------------------------------------------------------------------------- - * Concatenate bands (encoder only) - *--------------------------------------------------------------------------*/ + * Concatenate bands (encoder only) + *--------------------------------------------------------------------------*/ IF( exc_diff != NULL ) { FOR( j = 0; j < nb_bands; j++ ) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 96ab40547..709bb47e0 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1106,8 +1106,8 @@ void lsf_end_enc_fx( } /*--------------------------------------------------------------------------* \ - * Write indices to array \ - *--------------------------------------------------------------------------*/ + * Write indices to array \ + *--------------------------------------------------------------------------*/ IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->core, ACELP_CORE ) ) { @@ -1981,7 +1981,7 @@ static void first_VQstages( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -2171,7 +2171,7 @@ static void first_VQstages_ivas_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 7c17e76d8..4ce9403a6 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* -- GitLab From aab3f53c7208ea1ffbbb053ab70d6e86d912f1e9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 5 Mar 2025 12:13:28 +0100 Subject: [PATCH 260/329] add missing free() in ivas_destroy_handle_isar() --- lib_dec/lib_dec_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e182a471b..9753893e2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4277,6 +4277,9 @@ static void ivas_destroy_handle_isar( free( ( *hSplitBinRend )->hCldfbDataOut ); ( *hSplitBinRend )->hCldfbDataOut = NULL; } + + free( *hSplitBinRend ); + *hSplitBinRend = NULL; } return; -- GitLab From eb283286d62fcac0cad5bda9d4f4512f09d43af1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 14:20:53 +0100 Subject: [PATCH 261/329] fix build-codec-linux-make --- lib_com/frame_ener.c | 333 ------------------ lib_com/frame_ener_fx.c | 39 +++ lib_com/get_gain.c | 170 ---------- lib_com/gs_preech.c | 381 --------------------- lib_com/hp50.c | 728 ---------------------------------------- lib_com/hp50_fx.c | 10 - 6 files changed, 39 insertions(+), 1622 deletions(-) delete mode 100644 lib_com/frame_ener.c delete mode 100644 lib_com/get_gain.c delete mode 100644 lib_com/gs_preech.c delete mode 100644 lib_com/hp50.c diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c deleted file mode 100644 index e89c4dfad..000000000 --- a/lib_com/frame_ener.c +++ /dev/null @@ -1,333 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" -/*----------------------------------------------------------------------------------* - * fer_energy() - * - * Estimation of pitch-synchronous (voiced sounds) or half-frame energy - *----------------------------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_FIXED -void fer_energy( - const int16_t L_frame, /* i : frame length */ - const int16_t clas, /* i : frame classification */ - const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */ - const float pitch, /* i : pitch period */ - float *enr, /* o : pitch-synchronous or half_frame energy */ - const int16_t offset /* i : speech pointer offset (0 or L_frame) */ -) -{ - int16_t len; - const float *pt_synth; - - if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */ - { - len = (int16_t) ( pitch + 0.5f ); /* pitch value */ - - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame - len; - } - - emaximum( pt_synth, len, enr ); /* pitch synchronous E */ - } - else - { - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame / 2; - } - - *enr = dotp( pt_synth, pt_synth, L_frame / 2 ); - *enr /= (float) ( L_frame / 2 ); - } - return; -} -#endif - -void fer_energy_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 clas, /* i : frame classification */ - const Word32 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q(q_synth) */ - const Word16 q_synth, /* i : synthesized speech at Fs = 12k8 Hz */ - const Word16 pitch, /* i : pitch period Q0 */ - Word32 *enr, /* o : pitch-synchronous or half_frame energy Q0 */ - const Word16 offset /* i : speech pointer offset (0 or L_frame) */ -) -{ - Word16 len, shift, exp; - const Word32 *pt_synth; - Word16 enr_tmp, i; - Word64 W_tmp; - - test(); - test(); - IF( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */ - { - len = ( pitch ); /* pitch value */ - move16(); - - pt_synth = synth; - IF( offset != 0 ) - { - pt_synth = synth + sub( L_frame, len ); - } - - emaximum_32fx( q_synth, pt_synth, len, enr ); /* pitch synchronous E */ - } - ELSE - { - pt_synth = synth; - IF( offset != 0 ) - { - pt_synth = synth + shr( L_frame, 1 ); - } - - W_tmp = 0; - move64(); - FOR( i = 0; i < L_frame / 2; i++ ) - { - W_tmp = W_add( W_tmp, W_mult0_32_32( pt_synth[i], pt_synth[i] ) ); // Q = q_synth * 2 - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); // Q = q_synth * 2 + shift - *enr = W_extract_h( W_tmp ); // Q = q_synth * 2 + shift - 32 - move32(); - - enr_tmp = BASOP_Util_Divide3216_Scale( *enr, shr( L_frame, 1 ) /*Q0*/, &exp ); - *enr = L_shr( L_deposit_l( enr_tmp ), sub( sub( sub( shift, 32 ), exp ), 1 ) ); /*Q0*/ - move32(); - } - return; -} - - -/*----------------------------------------------------------------------------------* - * frame_ener() - * - * Estimation of pitch-synchronous (voiced) or mean half-frame (unvoiced) energy - *----------------------------------------------------------------------------------*/ -Word16 frame_ener_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 clas, /* i : frame classification */ - const Word16 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q_new */ - const Word16 pitch, /* i : pitch period Q0 */ - Word32 *enr_q, /* o : pitch-synchronous or half_frame energy Q0 */ - const Word16 offset, /* i : speech pointer offset (0 or L_FRAME) */ - const Word16 Q_new, /* i : Scaling factor */ - Word16 shift, /* i : Shift need to obtain 12 bits vectors */ - const Word16 enc /* i : Encoder/decoder */ -) -{ - Word16 len, exp_enrq, exp_tmp, pos; - Word16 i; - const Word16 *pt_synth; - Word32 Ltmp; - - exp_enrq = 0; - move16(); - test(); - test(); - IF( ( EQ_16( clas, VOICED_CLAS ) ) || ( EQ_16( clas, ONSET ) ) || ( EQ_16( clas, SIN_ONSET ) ) ) /* current frame is voiced */ - { - /* current frame is voiced */ - len = pitch; - move16(); /* pitch value at the end of frame */ - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + sub( L_frame, len ); - } - emaximum_fx( Q_new, pt_synth, len, enr_q ); - IF( enc != 0 ) - { - exp_enrq = norm_l( *enr_q ); - *enr_q = L_shl( *enr_q, exp_enrq ); - move32(); - exp_enrq = sub( exp_enrq, 2 ); - } - } - ELSE - { - /* current frame is unvoiced */ - Word16 L_frame2, exp2, enr_q_tmp; - - L_frame2 = shr( L_frame, 1 ); - pos = 0; - move16(); - - if ( offset != 0 ) - { - pos = sub( L_frame, L_frame2 ); - } - Ltmp = L_mult_sat( synth[pos], synth[pos] ); /*2 * Qnew + 1*/ - FOR( i = 1; i < L_frame2; i++ ) - { - Ltmp = L_mac_sat( Ltmp, synth[pos + i], synth[pos + i] ); /*2 * Qnew + 1*/ - } - test(); - IF( EQ_32( Ltmp, MAX_32 ) || enc != 0 ) - { - /* scale down when overflow occurs */ - *enr_q = Energy_scale( synth + pos, L_frame2, shift, &exp_enrq ); - move32(); - } - ELSE - { - shift = 0; - move16(); - /* Normalize acc in Q31 (energy already calculated) */ - pos = norm_l( Ltmp ); - Ltmp = L_shl( Ltmp, pos ); - exp_enrq = sub( 30, pos ); /* exponent = 0..30 */ - *enr_q = Ltmp; - move32(); - } - - /* enr2 = 1.0f/L_FRAME2 * dot_product(synth, synth, L_FRAME2) */ - exp_enrq = sub( exp_enrq, shl( shift, 1 ) ); - - IF( enc != 0 ) - { - assert( L_frame == 256 || L_frame == 320 ); - - exp_tmp = add( shl( Q_new, 1 ), -2 + 7 ); /* L_subfr == L_SUBFR */ - exp_enrq = sub( exp_enrq, exp_tmp ); - exp_enrq = sub( 31, exp_enrq ); - - IF( EQ_16( L_frame, 320 ) ) - { - *enr_q = Mult_32_16( *enr_q, 26214 ); /*x 0.8 to get /160*/ - move32(); - i = norm_l( *enr_q ); - *enr_q = L_shl( *enr_q, i ); - move32(); - exp_enrq = add( i, exp_enrq ); - } - } - ELSE - { - exp_enrq = sub( exp_enrq, add( Q_new, Q_new ) ); - enr_q_tmp /*Q30 exp2+exp_enrq*/ = BASOP_Util_Divide3216_Scale( *enr_q /*Q31*/, L_frame2 /*Q0*/, &exp2 ); - *enr_q = L_shr( L_deposit_l( enr_q_tmp ), sub( 30, add( exp2, exp_enrq ) ) ); /*Q0*/ - move32(); - *enr_q = L_add( *enr_q, 1 ); - move32(); - exp_enrq = 0; - move16(); - } - } - - return exp_enrq; -} - -/*------------------------------------------------------------------------* - * frame_energy() - * - * Compute pitch-synchronous energy at the frame end - *------------------------------------------------------------------------*/ -Word16 frame_energy_fx( /* o : Frame energy in Q8 */ - Word16 L_frame, - const Word16 *pitch, /* i : pitch values for each subframe Q6 */ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_syn*/ - const Word16 lp_speech, /* i : long term active speech energy average Q8 */ - Word16 *frame_ener, /* o : pitch-synchronous energy at frame end Q8 */ - const Word16 Q_syn /* i : Synthesis scaling */ -) -{ - Word32 Ltmp; - const Word16 *pt1; - Word16 tmp16, exp1, exp2, tmp1, tmp2; - Word16 len, enern; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - - /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */ - len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 ); - - if ( LT_16( len, L_SUBFR ) ) - { - len = shl( len, 1 ); - } - pt1 = speech + sub( L_frame, len ); - - /* *frame_ener = 10.0f * log10(dot_product(pt1, pt1, len) / (float)len) */ - - tmp1 = norm_s( len ); - tmp2 = shl( len, tmp1 ); - tmp1 = sub( 15, tmp1 ); - - Ltmp = Dot_productSq16HQ( 0, pt1, len, &exp1 ); - exp1 = sub( exp1, shl( Q_syn, 1 ) ); - exp1 = sub( exp1, 1 ); /* compensation of leftshift caused by mac operation in dot_productSq16HQ */ - tmp16 = BASOP_Util_Divide3216_Scale( Ltmp, len, &exp2 ); - - exp1 = add( exp1, exp2 ); - exp1 = add( exp1, 1 ); /* compensate result of division Q-1 */ - - - tmp2 = norm_s( tmp16 ); - Ltmp = L_shl( L_deposit_h( tmp16 ), tmp2 ); /*Q16, (exp1-tmp2) = Q31, exp1-tmp2+15*/ - - Ltmp = BASOP_Util_Log2( Ltmp ); /*Q(31-6) = Q25*/ - exp1 = sub( 15 + exp1, tmp2 ); - - /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ - exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ - Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ - - /*make 10*log10 out of log2*/ - Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/ - *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/ - move16(); - enern = sub_o( *frame_ener, lp_speech, &Overflow ); /*Q8*/ - - return enern; -} diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 4428c0796..7ee58371a 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -47,6 +47,45 @@ * Estimation of pitch-synchronous (voiced sounds) or half-frame energy *----------------------------------------------------------------------------------*/ +void fer_energy( + const int16_t L_frame, /* i : frame length */ + const int16_t clas, /* i : frame classification */ + const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */ + const float pitch, /* i : pitch period */ + float *enr, /* o : pitch-synchronous or half_frame energy */ + const int16_t offset /* i : speech pointer offset (0 or L_frame) */ +) +{ + int16_t len; + const float *pt_synth; + + if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */ + { + len = (int16_t) ( pitch + 0.5f ); /* pitch value */ + + pt_synth = synth; + if ( offset != 0 ) + { + pt_synth = synth + L_frame - len; + } + + emaximum( pt_synth, len, enr ); /* pitch synchronous E */ + } + else + { + pt_synth = synth; + if ( offset != 0 ) + { + pt_synth = synth + L_frame / 2; + } + + *enr = dotp( pt_synth, pt_synth, L_frame / 2 ); + *enr /= (float) ( L_frame / 2 ); + } + return; +} + + void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c deleted file mode 100644 index 89b5fa3de..000000000 --- a/lib_com/get_gain.c +++ /dev/null @@ -1,170 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*----------------------------------------------------------------------------------* - * get_gain() - * - * - *----------------------------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_FIXED -/*! r: codebook gain (adaptive or fixed) */ -float get_gain_flt( - const float x[], /* i : target signal */ - const float y[], /* i : filtered codebook excitation */ - const int16_t n, /* i : segment length */ - float *en_y /* o : energy of y (sum of y[]^2, optional) */ -) -{ - float corr = 0.0f, ener = 1e-6f; - int16_t i; - - for ( i = 0; i < n; i++ ) - { - corr += x[i] * y[i]; - ener += y[i] * y[i]; - } - - if ( en_y ) - { - *en_y = ener; - } - - return ( corr / ener ); -} -#endif - -Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */ - const Word16 x[], /* input : target signal Qx */ - const Word16 y[], /* input : filtered codebook excitation Qx */ - const Word16 n /* input : segment length */ -) -{ - Word32 tcorr, tener, Lgain; - Word16 exp_c, exp_e, exp, tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - - tcorr = L_deposit_l( 0 ); - tener = L_deposit_l( 0 ); - - - /*----------------------------------------------------------------* - * Find gain based on inter-correlation product - *----------------------------------------------------------------*/ - - tcorr = Dot_product16HQ( 0, x, y, n, &exp_c ); - tener = Dot_productSq16HQ( 0, y, n, &exp_e ); - - BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp ); - Lgain = L_shl_o( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ), &Overflow ) /*Q16*/; - - return Lgain; -} - -Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */ - const Word16 x[], /* input : target signal */ - const Word16 y[], /* input : filtered codebook excitation */ - const Word16 n /* input : segment length */ -) -{ - Word32 tcorr, tener, Lgain; - Word16 m_corr, m_ener, negative, Q_corr, Q_ener; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - negative = 0; - move16(); - - /*----------------------------------------------------------------* - * Find gain based on inter-correlation product - *----------------------------------------------------------------*/ - tcorr = Dot_product16HQ( 0, x, y, n, &Q_corr ); - tener = Dot_productSq16HQ( 0, y, n, &Q_ener ); - - tener = L_max( tener, 1 ); - - if ( tcorr <= 0 ) - { - negative = 1; - move16(); - } - BASOP_SATURATE_WARNING_OFF_EVS /*tcorr max be negative maxvall - not critical*/ - tcorr = L_abs( tcorr ); - BASOP_SATURATE_WARNING_ON_EVS - - m_corr = extract_h( tcorr ); - - m_ener = extract_h( tener ); - - IF( GT_16( m_corr, m_ener ) ) - { - m_corr = shr( m_corr, 1 ); - Q_corr = add( Q_corr, 1 ); - } - if ( m_ener == 0 ) - { - move16(); - m_corr = 0x7FFF; - } - IF( m_ener != 0 ) - { - m_corr = div_s( m_corr, m_ener ); - } - - Q_corr = sub( Q_corr, Q_ener ); - - Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */ - - if ( negative != 0 ) - { - Lgain = L_negate( Lgain ); /* Lgain in Q16 */ - } - - - return Lgain; -} diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c deleted file mode 100644 index 58b49172d..000000000 --- a/lib_com/gs_preech.c +++ /dev/null @@ -1,381 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define ATT_LENGHT16k 80 -#ifndef IVAS_FLOAT_FIXED -#define INV_L_FRAME16k ( 1.0f / L_FRAME16k ) -#endif - -#define ATT_LENGHT 64 -#define ATT_SEG_LEN ( L_FRAME / ATT_LENGHT ) - -#ifndef IVAS_FLOAT_FIXED -#define INV_ATT_SEG_LEN ( 1.0f / ATT_SEG_LEN ) -#define INV_L_FRAME ( 1.0f / L_FRAME ) -#endif - -#ifndef IVAS_FLOAT_FIXED -/*-------------------------------------------------------------------* - * pre_echo_att() - * - * Attenuation of the pre-echo when encoder specifies an attack - *-------------------------------------------------------------------*/ - -void pre_echo_att( - float *Last_frame_ener, /* i/o: Energy of the last frame */ - float *exc, /* i/o: Excitation of the current frame */ - const int16_t attack_flag, /* i : attack flag (GSC or TC) */ - const int16_t last_coder_type, /* i : Last coder type */ - const int16_t L_frame /* i : frame length */ -) -{ - float etmp; - float etmp1; - float finc[ATT_LENGHT16k], ratio_float, inv_l_frame; - int16_t att_len; - int16_t attack_pos, i; - - if ( attack_flag > 0 && last_coder_type == AUDIO ) - { - /*-------------------------------------------------------------------------* - * Find where the onset (attack) occurs by computing the energy per section - * The inverse weighting aims to favor the first maxima in case of - * gradual onset - *-------------------------------------------------------------------------*/ - - att_len = ATT_LENGHT; - if ( L_frame == L_FRAME16k ) - { - att_len = ATT_LENGHT16k; - } - for ( i = 0; i < att_len; i++ ) - { - finc[i] = sum2_f( exc + i * ATT_SEG_LEN, ATT_SEG_LEN ) * ( (float) ( att_len - i ) / ( att_len ) ); - } - etmp = -1; - attack_pos = maximum( finc, att_len, &etmp ); - - /* Scaled the maximum energy and allowed 6 dB increase*/ - etmp *= INV_ATT_SEG_LEN; - etmp1 = etmp; - *Last_frame_ener *= 4.0f; - - /* If the maximum normalized energy > last frame energy + 6dB */ - if ( etmp > *Last_frame_ener && attack_pos > 0 ) - { - /* Find the average energy before the attack */ - etmp = sum_f( finc, attack_pos ) + 0.01f; - etmp /= ( attack_pos * ATT_SEG_LEN ); - - /* Find the correction factor and apply it before the attack */ - ratio_float = (float) sqrt( *Last_frame_ener / etmp ); - - - /* Pre-echo atttenuation should never increase the energy */ - ratio_float = min( ratio_float, 1.0f ); - for ( i = 0; i < attack_pos * ATT_SEG_LEN; i++ ) - { - exc[i] *= ratio_float; - } - } - *Last_frame_ener = etmp1; - } - else - { - /*-------------------------------------------------------* - * In normal cases, just compute the energy of the frame - *-------------------------------------------------------*/ - - etmp = sum2_f( exc, L_frame ) + 0.01f; - inv_l_frame = INV_L_FRAME; - if ( L_frame == L_FRAME16k ) - { - inv_l_frame = INV_L_FRAME16k; - } - etmp *= inv_l_frame; - *Last_frame_ener = etmp; - } - - return; -} -#endif - -void pre_echo_att_fx( - Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ - Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ - const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ -) -{ - Word32 etmp_fx; - Word32 finc_fx[ATT_LENGHT16k] = { 0 }; - move16(); - Word16 ratio_fx; - Word16 attack_pos_fx, i; - Word32 L_tmp, L_tmp1; - Word16 tmp, n1, n2, exp, frac1, frac2; - Word32 etmp1_fx; - Word16 att_len; - - test(); - IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ - { - /*-------------------------------------------------------------------------* - * Find where the onset (attack) occurs by computing the energy per section - * The inverse weighting aims to favor the first maxima in case of - * gradual onset - *-------------------------------------------------------------------------*/ - att_len = ATT_LENGHT; /* Q0 */ - move16(); - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - att_len = ATT_LENGHT16k; /* Q0 */ - move16(); - } - FOR( i = 0; i < att_len; i++ ) - { - L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ - tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */ - finc_fx[i] = L_tmp; - move32(); /*2*Q_new+1 */ - } - - attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx ); - - /* Scaled the maximum energy and allowed 6 dB increase*/ - etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ - etmp1_fx = etmp_fx; - move32(); - *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); - move32(); /*2*Q_new+1 */ - - /* If the maximum normalized energy > last frame energy + 6dB */ - test(); - IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) - { - /* Find the average energy before the attack */ - L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ - L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ - tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */ - L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */ - etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */ - - etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ - /* Find the correction factor and apply it before the attack */ - /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ - /* = isqrt(etmp/(*Last_frame_ener)) */ - etmp_fx = L_max( etmp_fx, 1 ); - *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); - move32(); - n1 = norm_l( etmp_fx ); - n2 = norm_l( *Last_frame_ener_fx ); - - n1 = sub( n1, 1 ); - exp = sub( n1, n2 ); - - frac1 = round_fx( L_shl( etmp_fx, n1 ) ); - frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); - L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ - L_tmp = L_shr( L_tmp, exp ); /* add exponent */ - - L_tmp = Isqrt( L_tmp ); - ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */ - - /* Pre-echo atttenuation should never increase the energy */ - ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ - FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) - { - /*exc_fx[i] *= ratio_fx;*/ - exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) ); - move16(); - } - } - *Last_frame_ener_fx = etmp1_fx; /*2*Q_new+1*/ - move32(); - } - ELSE - { - /*-------------------------------------------------------* - * In normal cases, just compute the energy of the frame - *-------------------------------------------------------*/ - - etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ -#ifdef ADD_LRTD - PMTE() - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#else - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#endif - *Last_frame_ener_fx = etmp_fx; - move32(); /*2*Q_new+1*/ - } - - return; -} - - -void pre_echo_att_ivas_fx( - Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ - Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ - const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ -) -{ - Word32 etmp_fx; - Word32 finc_fx[ATT_LENGHT16k] = { 0 }; - move16(); - Word16 ratio_fx; - Word16 attack_pos_fx, i; - Word32 L_tmp, L_tmp1; - Word16 tmp, n1, n2, exp, frac1, frac2; - Word32 etmp1_fx; - Word16 att_len; - - test(); - IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ - { - /*-------------------------------------------------------------------------* - * Find where the onset (attack) occurs by computing the energy per section - * The inverse weighting aims to favor the first maxima in case of - * gradual onset - *-------------------------------------------------------------------------*/ - att_len = ATT_LENGHT; /* Q0 */ - move16(); - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - att_len = ATT_LENGHT16k; /* Q0 */ - move16(); - } - FOR( i = 0; i < att_len; i++ ) - { - L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ - tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */ - finc_fx[i] = L_tmp; - move32(); /*2*Q_new+1 */ - } - - attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx ); - - /* Scaled the maximum energy and allowed 6 dB increase*/ - etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ - etmp1_fx = etmp_fx; - move32(); - *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); - move32(); /*2*Q_new+1 */ - - /* If the maximum normalized energy > last frame energy + 6dB */ - test(); - IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) - { - /* Find the average energy before the attack */ - L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ - L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ - tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */ - L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */ - etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */ - - etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ - /* Find the correction factor and apply it before the attack */ - /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ - /* = isqrt(etmp/(*Last_frame_ener)) */ - etmp_fx = L_max( etmp_fx, 1 ); - *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); - move32(); - n1 = norm_l( etmp_fx ); - n2 = norm_l( *Last_frame_ener_fx ); - - n1 = sub( n1, 1 ); - exp = sub( n1, n2 ); - - frac1 = round_fx( L_shl( etmp_fx, n1 ) ); - frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); - L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ - L_tmp = L_shr( L_tmp, exp ); /* add exponent */ - - L_tmp = Isqrt( L_tmp ); - ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); - - /* Pre-echo atttenuation should never increase the energy */ - ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ - FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) - { - /*exc_fx[i] *= ratio_fx;*/ - exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) ); - move16(); - } - } - *Last_frame_ener_fx = etmp1_fx; /* 2 * Q_new + 1 */ - move32(); - } - ELSE - { - /*-------------------------------------------------------* - * In normal cases, just compute the energy of the frame - *-------------------------------------------------------*/ - Word16 exp_etmp = sub( 15, Q_new ); - etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ - - etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ - } - *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ - move32(); /*2*Q_new+1*/ - } - - return; -} diff --git a/lib_com/hp50.c b/lib_com/hp50.c deleted file mode 100644 index 6920063d4..000000000 --- a/lib_com/hp50.c +++ /dev/null @@ -1,728 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/* - * hp20 - * - * Function: - * 2nd order high pass filter with nominal cut off frequency at 20 Hz. - * - * Returns: - * void - */ - -#ifndef IVAS_FLOAT_FIXED -void hp20_flt( - Float32 signal[], - const Word16 lg, - Float32 mem[], - const Word32 Fs ) -{ - Word16 i; - Float32 x0, x1, x2, y0, y1, y2; - Float32 a1, a2, b1, b2; - - y1 = mem[0]; - y2 = mem[1]; - x0 = mem[2]; - x1 = mem[3]; - - if ( Fs == 8000 ) - { - /* hp filter 20Hz at 3dB for 8000KHz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1 = 1.977786483776764f; - a2 = -0.978030508491796f; - b1 = -1.977908496134280f; - b2 = 0.988954248067140f; - } - else if ( Fs == 16000 ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] - a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1 = 1.988892905899653f; - a2 = -0.988954249933127f; - b1 = -1.988923577916390f; - b2 = 0.994461788958195f; - } - else if ( Fs == 32000 ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b =[0.997227049904470 -1.994454099808940 0.997227049904470] - a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1 = 1.994446410541927f; - a2 = -0.994461789075954f; - b1 = -1.994454099808940f; - b2 = 0.997227049904470f; - } - else - { - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1 = 1.996297601769122f; - a2 = -0.996304442992686f; - b1 = -1.996301022380904f; - b2 = 0.998150511190452f; - } - - for ( i = 0; i < lg; i++ ) - { - x2 = x1; - x1 = x0; - x0 = signal[i]; - y0 = ( y1 * a1 ) + ( y2 * a2 ) + ( x0 * b2 ) + ( x1 * b1 ) + ( x2 * b2 ); - signal[i] = y0; - y2 = y1; - y1 = y0; - } - - mem[0] = ( ( y1 > 1e-10 ) | ( y1 < -1e-10 ) ) ? y1 : 0; - mem[1] = ( ( y2 > 1e-10 ) | ( y2 < -1e-10 ) ) ? y2 : 0; - mem[2] = ( ( x0 > 1e-10 ) | ( x0 < -1e-10 ) ) ? x0 : 0; - mem[3] = ( ( x1 > 1e-10 ) | ( x1 < -1e-10 ) ) ? x1 : 0; - - return; -} -#endif - - -#define HP20_COEFF_SCALE ( 2 ) -/* - * hp20 - * - * Function: - * 2nd order high pass filter with nominal cut off frequency at 20 Hz. - * - * Returns: - * void - */ - -static Word32 HP50_Mode2_Mpy_32_16_fix( Word32 a, Word16 b ) -{ - Word32 result = Mpy_32_16_1( a, b ); - /* perform rounding towards lower value for negative results */ - if ( result < 0 ) - result = L_add( result, 1 ); - return result; -} - -static Word32 HP50_Mpy_32_32_fix( Word32 a, Word32 b ) -{ - Word32 result = Mpy_32_32( a, b ); - /* perform rounding towards lower value for negative results */ - if ( result < 0 ) - result = L_add( result, 1 ); - return result; -} - - -static void filter_2nd_order( - Word16 signal[], - const Word16 stride, - const Word16 prescale, - const Word16 lg, - Word32 mem[4], - Word32 a1, - Word32 a2, - Word32 b1, - Word32 b2 ) -{ - - Word16 i; - Word16 x2, x1; - Word32 L_sum, L_y1, L_y2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - - - /* - * Saturation: The states of the filter, namely L_y1 and L_y2 shall - * never saturate, because that causes error in the filter feedback. - * The final output written into signal[] might saturate because of - * unavoidable filter overshoot. - */ - - /* Execute first 2 iterations with 32-bit x anx y memory values */ - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mpy_32_32_fix( b2, mem[2] ); /* b2*x2 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( b1, mem[3] ) ); /* b1*x1 */ - x2 = shr( signal[0], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) ); /* b2*x0 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) ); /* y2*a2 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) ); /* y1*a1 */ - - L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mpy_32_32_fix( b2, mem[3] ); /* b2*x2 */ - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); /* b1*x1 */ - x1 = shr( signal[stride], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) ); /* b2*x0 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) ); /* y2*a2 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); /* y1*a1 */ - - L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - move16(); - - /* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */ - FOR( i = 2; i < lg; i += 2 ) - { - /* y[i+0] = b2*x[i-2] + b1*x[i-1] + b2*x[i-0] + a2*y[i-2] + a1*y[i-1]; */ - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mode2_Mpy_32_16_fix( b2, x2 ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x1 ) ); - x2 = shr( signal[i * stride], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a2 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a1 ) ); - - L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */ - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mode2_Mpy_32_16_fix( b2, x1 ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); - x1 = shr( signal[( i + 1 ) * stride], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a2 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); - - L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - move16(); - } - /* update static filter memory from variables */ - mem[0] = L_y2; - move32(); - mem[1] = L_y1; - move32(); - mem[2] = L_deposit_h( x2 ); - move32(); - mem[3] = L_deposit_h( x1 ); - move32(); - - - return; -} - - -void hp20( Word16 signal[], /* i/o: signal to filter any */ - const Word16 stride, /* i : stride to be applied accessing signal */ - const Word16 lg, /* i : length of signal (integer) Q0 */ - Word32 mem[5], /* i/o: static filter memory with this layout: */ - /* mem[0]: y[-2] (32-bit) */ - /* mem[1]; y[-1] (32-bit) */ - /* mem[2]: x[-2] << 16 */ - /* mem[3]: x[-1] << 16 */ - /* Note: mem[0..3] need to be scaled per frame */ - /* mem[4]: states scale */ - const Word32 sFreq ) /* i : input sampling rate Q0 */ -{ - Word32 a1, b1, a2, b2; - Word16 prescale, prescaleOld, diff; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - - - prescale = getScaleFactor16( signal, lg ); - prescaleOld = extract_l( mem[4] ); - diff = norm_l( L_shl_sat( mem[2], prescaleOld ) ); - if ( mem[2] != 0 ) - { - prescale = s_min( prescale, diff ); - } - diff = norm_l( L_shl_o( mem[3], prescaleOld, &Overflow ) ); - if ( mem[3] != 0 ) - { - prescale = s_min( prescale, diff ); - } - /* Take into account the left shift performed into the loop + 1 bit headroom*/ - prescale = s_max( -12, sub( 1 + HP20_COEFF_SCALE, prescale ) ); - IF( prescale != prescaleOld ) - { - diff = sub( prescale, prescaleOld ); - mem[0] = L_shr_o( mem[0], diff, &Overflow ); - move32(); - mem[1] = L_shr_o( mem[1], diff, &Overflow ); - move32(); - mem[2] = L_shr_o( mem[2], diff, &Overflow ); - move32(); - mem[3] = L_shr_o( mem[3], diff, &Overflow ); - move32(); - mem[4] = L_deposit_l( prescale ); - } - - IF( EQ_32( sFreq, 8000 ) ) - { - /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1 = 1061816033l /* 1.977786483776764 Q29*/; - move32(); - a2 = -525076131l /*-0.978030508491796 Q29*/; - move32(); - b1 = -1061881538l /*-1.977908496134280 Q29*/; - move32(); - b2 = 530940769l /* 0.988954248067140 Q29*/; - move32(); - } - ELSE IF( EQ_32( sFreq, 16000 ) ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b = [0.994461788958195 -1.988923577916390 0.994461788958195] - a = [1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1 = 1067778748l /* 1.988892905899653 Q29*/; - move32(); - a2 = -530940770l /*-0.988954249933127 Q29*/; - move32(); - b1 = -1067795215l /*-1.988923577916390 Q29*/; - move32(); - b2 = 533897608l /* 0.994461788958195 Q29*/; - move32(); - } - ELSE IF( EQ_32( sFreq, 32000 ) ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b = [0.997227049904470 -1.994454099808940 0.997227049904470] - a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1 = 1070760263l /* 1.994446410541927 Q29*/; - move32(); - a2 = -533897608l /*-0.994461789075954 Q29*/; - move32(); - b1 = -1070764392l /*-1.994454099808940 Q29*/; - move32(); - b2 = 535382196l /* 0.997227049904470 Q29*/; - move32(); - } - ELSE - { - assert( sFreq == 48000 ); - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1 = 1071754114l /* 1.996297601769122 Q29*/; - move32(); - a2 = -534886875l /*-0.996304442992686 Q29*/; - move32(); - b1 = -1071755951l /*-1.996301022380904 Q29*/; - move32(); - b2 = 535877975l /* 0.998150511190452 Q29*/; - move32(); - } - - - filter_2nd_order( signal, stride, prescale, lg, - mem, a1, a2, b1, b2 ); - - return; -} - - -#ifdef HP20_FIX32_RECODING -void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ) -{ - Word32 i; - Word32 a1_fx, a2_fx, b1_fx, b2_fx; - Word32 diff_pos, diff_neg; - Flag Overflow = 0; - Word16 prescale, prescaleOld, prescale_current_frame, diff; - - prescale = getScaleFactor32( signal_fx, lg ); - prescale_current_frame = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); - - - prescaleOld = extract_l( mem_fx[4] ); - - diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); - diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); - - diff = L_max( diff_pos, diff_neg ); - - IF( NE_16( diff, 0 ) ) - { - prescale = s_min( prescale, diff ); - } - - prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); - - diff = sub( prescale, prescaleOld ); - mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow ); - move32(); - mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow ); - move32(); - mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow ); - move32(); - mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow ); - move32(); - mem_fx[4] = L_deposit_l( prescale_current_frame ); - move32(); - - IF( EQ_32( Fs, 8000 ) ) - { - /* hp filter 20Hz at 3dB for 8000KHz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1_fx = 1061816033l /* 1.977786483776764 Q29*/; - a2_fx = -525076131l /*-0.978030508491796 Q29*/; - b1_fx = -1061881538l /*-1.977908496134280 Q29*/; - b2_fx = 530940769l /* 0.988954248067140 Q29*/; - } - ELSE IF( EQ_32( Fs, 16000 ) ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] - a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1_fx = 1067778748l /* 1.988892905899653 Q29*/; - a2_fx = -530940770l /*-0.988954249933127 Q29*/; - b1_fx = -1067795215l /*-1.988923577916390 Q29*/; - b2_fx = 533897608l /* 0.994461788958195 Q29*/; - } - ELSE IF( EQ_32( Fs, 32000 ) ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b =[0.997227049904470 -1.994454099808940 0.997227049904470] - a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1_fx = 1070760263l /* 1.994446410541927 Q29*/; - a2_fx = -533897608l /*-0.994461789075954 Q29*/; - b1_fx = -1070764392l /*-1.994454099808940 Q29*/; - b2_fx = 535382196l /* 0.997227049904470 Q29*/; - } - ELSE - { - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1_fx = 1071754114l /* 1.996297601769122 Q29*/; - a2_fx = -534886875l /*-0.996304442992686 Q29*/; - b1_fx = -1071755951l /*-1.996301022380904 Q29*/; - b2_fx = 535877975l /* 0.998150511190452 Q29*/; - } - move32(); - move32(); - move32(); - move32(); - Word64 W_sum, W_y0, W_y1, W_y2; - Word32 x0, x1, x2; - - W_sum = W_mult_32_32( b2_fx, mem_fx[2] ); /* b2*x2 */ - W_sum = W_mac_32_32( W_sum, b1_fx, mem_fx[3] ); /* b1*x1 */ - x2 = L_shr( signal_fx[0], prescale ); - W_sum = W_mac_32_32( W_sum, b2_fx, x2 ); /* b2*x0 */ - W_sum = W_mac_32_32( W_sum, mem_fx[0], a2_fx ); /* y2*a2 */ - W_sum = W_mac_32_32( W_sum, mem_fx[1], a1_fx ); /* y1*a1 */ - W_y2 = W_shl( W_sum, HP20_COEFF_SCALE ); - signal_fx[0] = W_extract_h( W_shl( W_y2, prescale ) ); - move32(); - - W_sum = W_mult_32_32( b2_fx, mem_fx[3] ); /* b2*x2 */ - W_sum = W_mac_32_32( W_sum, b1_fx, x2 ); /* b1*x1 */ - x1 = L_shr( signal_fx[1], prescale ); - W_sum = W_mac_32_32( W_sum, b2_fx, x1 ); /* b2*x0 */ - W_sum = W_mac_32_32( W_sum, mem_fx[1], a2_fx ); /* y2*a2 */ - W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a1_fx ); /* y1*a1 */ - W_y1 = W_shl( W_sum, HP20_COEFF_SCALE ); - signal_fx[1] = W_extract_h( W_shl( W_y1, prescale ) ); - move32(); - - diff = sub( prescale_current_frame, prescale ); - W_y1 = W_shr( W_y1, diff ); - W_y2 = W_shr( W_y2, diff ); - x2 = L_shr( x2, diff ); - x1 = L_shr( x1, diff ); - - FOR( i = 2; i < lg; i++ ) - { - W_sum = W_mult_32_32( b2_fx, x2 ); /* b2*x2 */ - W_sum = W_mac_32_32( W_sum, b1_fx, x1 ); /* b1*x1 */ - x0 = L_shr( signal_fx[i], prescale_current_frame ); - W_sum = W_mac_32_32( W_sum, b2_fx, x0 ); /* b2*x0 */ - W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a2_fx ); /* y2*a2 */ - W_sum = W_mac_32_32( W_sum, W_extract_h( W_y1 ), a1_fx ); /* y1*a1 */ - W_y0 = W_shl( W_sum, HP20_COEFF_SCALE ); - - signal_fx[i] = W_extract_h( W_shl( W_y0, prescale_current_frame ) ); - move32(); - - x2 = x1; - x1 = x0; - W_y2 = W_y1; - W_y1 = W_y0; - - move32(); - move32(); - move64(); - move64(); - } - - mem_fx[0] = W_extract_h( W_y2 ); - mem_fx[1] = W_extract_h( W_y1 ); - mem_fx[2] = x2; - mem_fx[3] = x1; - - move32(); - move32(); - move32(); - move32(); - - return; -} -#else -void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ) -{ - Word16 i; - Word32 a1_fx, a2_fx, b1_fx, b2_fx; - Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; - Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; - - IF( EQ_32( Fs, 8000 ) ) - { - /* hp filter 20Hz at 3dB for 8000KHz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1_fx = 1061816033l /* 1.977786483776764 Q29*/; - a2_fx = -525076131l /*-0.978030508491796 Q29*/; - b1_fx = -1061881538l /*-1.977908496134280 Q29*/; - b2_fx = 530940769l /* 0.988954248067140 Q29*/; - } - ELSE IF( EQ_32( Fs, 16000 ) ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] - a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1_fx = 1067778748l /* 1.988892905899653 Q29*/; - a2_fx = -530940770l /*-0.988954249933127 Q29*/; - b1_fx = -1067795215l /*-1.988923577916390 Q29*/; - b2_fx = 533897608l /* 0.994461788958195 Q29*/; - } - ELSE IF( EQ_32( Fs, 32000 ) ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b =[0.997227049904470 -1.994454099808940 0.997227049904470] - a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1_fx = 1070760263l /* 1.994446410541927 Q29*/; - a2_fx = -533897608l /*-0.994461789075954 Q29*/; - b1_fx = -1070764392l /*-1.994454099808940 Q29*/; - b2_fx = 535382196l /* 0.997227049904470 Q29*/; - } - ELSE - { - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1_fx = 1071754114l /* 1.996297601769122 Q29*/; - a2_fx = -534886875l /*-0.996304442992686 Q29*/; - b1_fx = -1071755951l /*-1.996301022380904 Q29*/; - b2_fx = 535877975l /* 0.998150511190452 Q29*/; - } - move32(); - move32(); - move32(); - move32(); - - Qprev_y1 = extract_l( mem_fx[4] ); - Qprev_y2 = extract_l( mem_fx[5] ); - y1_fx64 = W_deposit32_l( mem_fx[0] ); - y2_fx64 = W_deposit32_l( mem_fx[1] ); - x0_fx64 = W_deposit32_l( mem_fx[2] ); - x1_fx64 = W_deposit32_l( mem_fx[3] ); - - FOR( i = 0; i < lg; i++ ) - { - x2_fx64 = x1_fx64; - move64(); - x1_fx64 = x0_fx64; - move64(); - x0_fx64 = W_deposit32_l( signal_fx[i] ); - - Qy1 = W_norm( y1_fx64 ); - if ( y1_fx64 == 0 ) - { - Qy1 = 62; - move16(); - } - Qy1 = sub( Qy1, 34 ); - R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx ); - Qy1 = add( Qy1, Qprev_y1 ); - - Qy2 = W_norm( y2_fx64 ); - if ( y2_fx64 == 0 ) - { - Qy2 = 62; - move16(); - } - Qy2 = sub( Qy2, 34 ); - R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx ); - Qy2 = add( Qy2, Qprev_y2 ); - - Qx0 = W_norm( x0_fx64 ); - if ( x0_fx64 == 0 ) - { - Qx0 = 62; - move16(); - } - Qx0 = sub( Qx0, 34 ); - R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx ); - - Qx1 = W_norm( x1_fx64 ); - if ( x1_fx64 == 0 ) - { - Qx1 = 62; - move16(); - } - Qx1 = sub( Qx1, 34 ); - R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx ); - - Qx2 = W_norm( x2_fx64 ); - if ( x2_fx64 == 0 ) - { - Qx2 = 62; - move16(); - } - Qx2 = sub( Qx2, 34 ); - R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx ); - - Qmin = s_min( Qy1, Qy2 ); - - y0_fx64 = W_add( W_shr( R1, sub( Qy1, Qmin ) ), W_shr( R2, sub( Qy2, Qmin ) ) ); - - Qmin = s_min( Qmin, Qx0 ); - Qmin = s_min( Qmin, Qx1 ); - Qmin = s_min( Qmin, Qx2 ); - - y0_fx64 = W_add( W_shr( y0_fx64, sub( s_min( Qy1, Qy2 ), Qmin ) ), W_add( W_shr( R3, sub( Qx0, Qmin ) ), W_add( W_shr( R4, sub( Qx1, Qmin ) ), W_shr( R5, sub( Qx2, Qmin ) ) ) ) ); - - y0_fx64 = W_shr( y0_fx64, 29 ); - - signal_fx[i] = W_extract_l( W_shr( y0_fx64, Qmin ) ); - move32(); - IF( signal_fx[i] < 0 ) - { - signal_fx[i] = L_add( signal_fx[i], 1 ); - move32(); - } - - y2_fx64 = y1_fx64; - y1_fx64 = y0_fx64; - Qprev_y2 = Qprev_y1; - Qprev_y1 = Qmin; - move64(); - move64(); - move16(); - move16(); - } - - Qy1 = W_norm( y1_fx64 ); - test(); - IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) ) - { - y1_fx64 = W_shr( y1_fx64, sub( 32, Qy1 ) ); - Qprev_y1 = sub( Qprev_y1, sub( 32, Qy1 ) ); - } - - Qy2 = W_norm( y2_fx64 ); - test(); - IF( y2_fx64 != 0 && LT_16( Qy2, 32 ) ) - { - y2_fx64 = W_shr( y2_fx64, sub( 32, Qy2 ) ); - Qprev_y2 = sub( Qprev_y2, sub( 32, Qy2 ) ); - } - - mem_fx[0] = W_extract_l( y1_fx64 ); - mem_fx[1] = W_extract_l( y2_fx64 ); - mem_fx[2] = W_extract_l( x0_fx64 ); - mem_fx[3] = W_extract_l( x1_fx64 ); - mem_fx[4] = Qprev_y1; - mem_fx[5] = Qprev_y2; - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - - return; -} -#endif diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index d13835f4c..9820eb3c8 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -41,16 +41,6 @@ #include "wmc_auto.h" #include "prot_fx.h" -/* - * hp20 - * - * Function: - * 2nd order high pass filter with nominal cut off frequency at 20 Hz. - * - * Returns: - * void - */ - #define HP20_COEFF_SCALE ( 2 ) /* -- GitLab From d46773e421e8e5ef085eefa98fcf63cbaa9e7c76 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 14:26:18 +0100 Subject: [PATCH 262/329] remove unused function --- lib_com/frame_ener_fx.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 7ee58371a..4428c0796 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -47,45 +47,6 @@ * Estimation of pitch-synchronous (voiced sounds) or half-frame energy *----------------------------------------------------------------------------------*/ -void fer_energy( - const int16_t L_frame, /* i : frame length */ - const int16_t clas, /* i : frame classification */ - const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */ - const float pitch, /* i : pitch period */ - float *enr, /* o : pitch-synchronous or half_frame energy */ - const int16_t offset /* i : speech pointer offset (0 or L_frame) */ -) -{ - int16_t len; - const float *pt_synth; - - if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */ - { - len = (int16_t) ( pitch + 0.5f ); /* pitch value */ - - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame - len; - } - - emaximum( pt_synth, len, enr ); /* pitch synchronous E */ - } - else - { - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame / 2; - } - - *enr = dotp( pt_synth, pt_synth, L_frame / 2 ); - *enr /= (float) ( L_frame / 2 ); - } - return; -} - - void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ -- GitLab From 54426a49982dbc40bdac0a07ee514d7c711fbd5a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 14:34:47 +0100 Subject: [PATCH 263/329] fix build-codec-linux-debugging-make --- lib_rend/lib_rend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 698c652e5..493979e30 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -45,6 +45,9 @@ #include #include #include "wmc_auto.h" +#ifdef DEBUGGING +#include "debug.h" +#endif /*-------------------------------------------------------------------* -- GitLab From 1afe839586e76766c822080214a21ec9cd7c1d51 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 16:02:36 +0100 Subject: [PATCH 264/329] remove ADD_IVAS_BWE --- lib_com/prot_fx.h | 35 ++++--------- lib_dec/decision_matrix_dec_fx.c | 4 +- lib_dec/evs_dec_fx.c | 20 +------- lib_dec/init_dec_fx.c | 6 +-- lib_dec/swb_bwe_dec_fx.c | 84 +++++--------------------------- lib_dec/swb_tbe_dec_fx.c | 5 +- lib_enc/cng_enc_fx.c | 7 +-- 7 files changed, 32 insertions(+), 129 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0371f747a..51fbb12d5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6057,10 +6057,7 @@ void TBEreset_dec_fx( void td_bwe_dec_init_fx( Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ -#ifdef ADD_IVAS_BWE - const Word16 extl, /* i : BWE extension layer */ -#endif - const Word32 output_Fs /* i : output sampling rate */ + const Word32 output_Fs /* i : output sampling rate */ ); // lsf_dec_fx.c @@ -7700,19 +7697,12 @@ Word16 WB_BWE_gain_deq_fx( ); Word16 wb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 output_frame, /* i : frame length */ Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx /* i/o: decoder state structure */ - , + Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *Qpost ); Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ @@ -7724,18 +7714,11 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class const Word16 hqswb_clas /* i : HQ BWE class */ ); -Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif - const Word16 output_frame /* i : frame length */ - , +Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ Word16 *Qpost ); void fd_bwe_dec_init( diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index a83de038a..f9833e80a 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -681,12 +681,12 @@ void decision_matrix_dec_fx( st->nb_subfr = NB_SUBFR16k; move16(); } -#if 1 // def ADD_IVAS_BWE 0> NEEDED for IO with conf_acelp1 + st->extl_orig = st->extl; move16(); st->extl_brate_orig = st->extl_brate; move32(); -#endif + test(); IF( EQ_32( st->output_Fs, 8000 ) ) { diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index a5a5ba6d9..aa997d4c0 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -383,15 +383,7 @@ ivas_error evs_dec_fx( ELSE IF( EQ_16( st_fx->extl, WB_BWE ) && st_fx->bws_cnt == 0 ) { /* WB BWE decoder */ - hb_synth_fx_exp = wb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - NULL, -#endif - synth_fx, hb_synth_fx, -#ifdef ADD_IVAS_BWE - 0, -#endif - output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/ + hb_synth_fx_exp = wb_bwe_dec_fx( synth_fx, hb_synth_fx, output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/ } /*---------------------------------------------------------------------* @@ -434,15 +426,7 @@ ivas_error evs_dec_fx( ( GE_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->core, ACELP_CORE ) && GT_16( st_fx->bwidth, NB ) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec && !( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) ) { /* SWB BWE decoder */ - hb_synth_fx_exp = swb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - NULL, -#endif - st_fx, synth_fx, hb_synth_fx, -#ifdef ADD_IVAS_BWE - 0, -#endif - output_frame, &Qpostd ); /*Q0*/ + hb_synth_fx_exp = swb_bwe_dec_fx( st_fx, synth_fx, hb_synth_fx, output_frame, &Qpostd ); /*Q0*/ } ELSE IF( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || EQ_16( st_fx->extl, FB_BWE_HIGHRATE ) ) { diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 5d8aee302..4f1db90ff 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -532,11 +532,7 @@ ivas_error init_decoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - td_bwe_dec_init_fx( st_fx, st_fx->hBWE_TD, -#ifdef ADD_IVAS_BWE - st_fx->extl, -#endif - st_fx->output_Fs ); + td_bwe_dec_init_fx( st_fx, st_fx->hBWE_TD, st_fx->output_Fs ); #ifdef MSAN_FIX st_fx->hBWE_TD->prev_hb_synth_fx_exp = 31; diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index d15a97821..b91dcdf32 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -505,19 +505,12 @@ Word16 ivas_wb_bwe_dec_fx( /* o : } Word16 wb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 output_frame, /* i : frame length */ Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx /* i/o: decoder state structure */ - , + Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *Qpost ) { Word16 mode; @@ -538,18 +531,7 @@ Word16 wb_bwe_dec_fx( new_input_fx_exp = *Qpost; move16(); -#ifdef ADD_IVAS_BWE - if ( st->element_mode == IVAS_CPE_DFT && !use_cldfb_for_dft ) - { - /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ - /* IVAS_fmToDo: delay output[] by 1.25ms ? */ - lerp( output, ysynth, L_FRAME16k, st->L_frame ); - wtda( ysynth, wtda_synth, hBWE_FD->old_wtda_swb, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k ); - direct_transform( wtda_synth, ysynth, 0, /*st->L_frame*/ L_FRAME16k, st->element_mode ); - } - else -#endif { wtda_fx( synth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ @@ -574,11 +556,7 @@ Word16 wb_bwe_dec_fx( Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); IF( !st_fx->bfi ) { -#ifdef ADD_IVAS_BWE - IF( st_fx->extl_brate > 0 ) -#else IF( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) -#endif { /* de-quantization */ mode = WB_BWE_gain_deq_fx( st_fx, WB_fenv_fx ); @@ -654,20 +632,15 @@ Word16 wb_bwe_dec_fx( window_ola_fx( t_audio32_tmp, hb_synth_fx, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); -#ifdef ADD_IVAS_BWE - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - /* add HB synth from hf_synth() */ - v_add( hb_synth, synth, hb_synth, output_frame ); - } -#endif hBWE_FD->prev_mode = mode; move16(); st_fx->prev_Q_synth = Q_syn; move16(); + return Q_syn_hb; } + + /*-------------------------------------------------------------------* * swb_bwe_gain_deq() * @@ -910,18 +883,11 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class * * SWB BWE decoder *-------------------------------------------------------------------*/ -Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif - const Word16 output_frame /* i : frame length */ - , +Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ Word16 *Qpost ) { Word16 i, l_subfr; @@ -957,19 +923,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ /* windowing of the ACELP core synthesis */ new_input_fx_exp = *Qpost; move16(); -#ifdef ADD_IVAS_BWE - if ( st->element_mode == IVAS_CPE_DFT && !use_cldfb_for_dft ) - { - /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ - /* IVAS_fmToDo: delay output[] by 1.25ms ? */ - lerp( output, ysynthIfx, L_FRAME16k, st_fx->L_frame ); - wtda_fx( ysynth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, - &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k ); - direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, /*st->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); - } - else -#endif { wtda_fx( synth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, @@ -1112,12 +1066,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ } fb_band_begin = FB_BAND_BEGIN; move16(); -#ifdef ADD_IVAS_BWE - IF( st_fx->L_frame == L_FRAME ) - { - fb_band_begin = FB_BAND_BEGIN_12k8; - } -#endif + FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ ) { tmp = sub( 32767, i_mult( j, 1024 ) ); @@ -1193,14 +1142,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ move16(); } } -#ifdef ADD_IVAS_BWE - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - /* add HB synth from hf_synth() */ - v_add( hb_synth, synth, hb_synth, output_frame ); - } -#endif + hBWE_FD->prev_frica_flag = frica_flag; move16(); hBWE_FD->prev_mode = mode; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index a37ebf9d9..bc8ef03cb 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5236,10 +5236,7 @@ void td_bwe_dec_init_ivas_fx( void td_bwe_dec_init_fx( Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ -#ifdef ADD_IVAS_BWE - const Word16 extl, /* i : BWE extension layer */ -#endif - const Word32 output_Fs /* i : output sampling rate */ + const Word32 output_Fs /* i : output sampling rate */ ) { Word16 i; diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 179d0230b..1721476b4 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2446,8 +2446,6 @@ static void shb_CNG_encod_fx( } ELSE { - /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ - // PMT("shb_CNG_encod_fx quantization in missing") } if ( LT_16( st_fx->bwidth, SWB ) ) @@ -2468,7 +2466,10 @@ static void shb_CNG_encod_fx( push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); - delete_indice( hBstr, IND_CNG_ENV1 ); + hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); + hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; + move16(); + move16(); if ( st_fx->element_mode == IVAS_CPE_DFT ) { -- GitLab From 95009451fea95fac053b01d04e25afef3f8dfd11 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 16:17:42 +0100 Subject: [PATCH 265/329] fix --- lib_dec/acelp_core_dec_fx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 1d59d1269..c0ad52a48 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1321,6 +1321,26 @@ ivas_error acelp_core_dec_fx( move16(); } } + + test(); + test(); + test(); + test(); + test(); + IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) + { + FOR( i = 0; i < st_fx->L_frame / 2; i++ ) + { + syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) ); + move16(); + } + } + + test(); + IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) ) + { + set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen ); + } } /*----------------------------------------------------------------* -- GitLab From 726b69f070b295ddd2c65a28eeb3e76757de6606 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 21:03:44 +0530 Subject: [PATCH 266/329] Optimizations for multichannel file decoded with binaural rendering ivas_binRenderer_filterModule_fx - 3.96 WMOPS improvement matrix_product_mant_exp - 9.631 WMOPS improvement BASOP_Util_Add_Mant32Exp - 15.926 WMOPS improvement --- lib_com/ivas_prot_fx.h | 14 ++ lib_com/ivas_tools_fx.c | 238 +++++++++++++++++-- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal_fx.c | 78 +++++- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 159 ++++++++++++- lib_dec/ivas_mc_param_dec_fx.c | 4 + lib_rend/ivas_stat_rend.h | 4 + 7 files changed, 466 insertions(+), 32 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 79ba75b81..3c01bebfd 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1314,6 +1314,20 @@ Word16 matrix_diag_product_fx( Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); +#ifdef OPT_BASOP_ADD_v1 +Word16 matrix_diag_product_fx_2( + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ + const Word16 X_e, + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ + const Word16 *Y_e, + const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ + Word16 *Z_e ); +#endif /* OPT_BASOP_ADD_v1 */ + Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix */ const Word16 *X_e, diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index d55766928..9cd1a063e 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -980,7 +980,9 @@ Word16 matrix_product_mant_exp_fx( Word16 out_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word16 *Zp_fx_e = out_e; Word16 row, col; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ Word64 temp; Word16 temp_e; Word16 prod_e = add( X_fx_e, Y_fx_e ); @@ -1007,9 +1009,13 @@ Word16 matrix_product_mant_exp_fx( FOR( k = 0; k < rowsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = k + i * rowsX; y_idx = k + j * rowsY; temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1047,9 +1053,13 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = i + k * rowsX; y_idx = j + k * rowsY; temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1087,9 +1097,13 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = k + i * rowsX; y_idx = j + k * rowsY; temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1128,9 +1142,13 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = i + k * rowsX; y_idx = k + j * rowsY; - temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e + temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1188,7 +1206,9 @@ Word16 matrix_product_fx( ) { Word16 i, j, k; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ Word32 *Zp_fx = Z_fx; /* Processing */ @@ -1209,9 +1229,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ - y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp_fx++; @@ -1232,9 +1256,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ - y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp_fx++; @@ -1255,9 +1283,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ - y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } @@ -1280,9 +1312,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ // TODO: overflow of Z_fx to be checked move32(); } @@ -1307,7 +1343,9 @@ Word16 matrix_product_q30_fx( ) { Word16 i, j, k; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ Word32 *Zp_fx = Z_fx; Word64 W_tmp; @@ -1330,10 +1368,14 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < rowsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 +#else /* OPT_BASOP_ADD_v1 */ //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 +#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1357,10 +1399,14 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 +#else /* OPT_BASOP_ADD_v1 */ //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 +#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1384,9 +1430,11 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifndef OPT_BASOP_ADD_v1 //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ +#endif /* OPT_BASOP_ADD_v1 */ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 } @@ -1413,10 +1461,14 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 +#else /* OPT_BASOP_ADD_v1 */ //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 +#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1449,7 +1501,9 @@ Word16 matrix_product_mant_exp( Word16 *Zp_e = Z_e; Word32 L_tmp; Word16 tmp_e; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ test(); @@ -1471,11 +1525,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ - y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[k + i * rowsX], Y_e[k + j * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ //( *Zp ) += X[k + i * rowsX] * Y[k + j * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1503,11 +1562,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[i + k * rowsX], Y_e[j + k * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[j + k * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); ( *Zp_e ) = tmp_e; @@ -1534,11 +1598,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[k + i * rowsX], Y_e[j + k * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[k + i * rowsX] * Y_fx[j + k * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1568,11 +1637,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[i + k * rowsX], Y_e[k + j * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[k + j * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1603,7 +1677,9 @@ Word16 matrix_diag_product_fx( { Word16 i, j; Word32 *Zp = Z; +#ifndef OPT_BASOP_ADD_v1 Word16 tmp; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1616,8 +1692,12 @@ Word16 matrix_diag_product_fx( { FOR( i = 0; i < colsX; ++i ) { +#ifdef OPT_BASOP_ADD_v1 + *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ tmp = add( j, imult1616( i, rowsX ) ); - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; } @@ -1648,6 +1728,100 @@ Word16 matrix_diag_product_fx( return EXIT_SUCCESS; } +#ifdef OPT_BASOP_ADD_v1 +Word16 matrix_diag_product_fx_2( + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ + const Word16 X_e, + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ + const Word16 *Y_e, + const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ + Word16 *Z_e ) +{ + Word16 i, j; + Word32 *Zp = Z; + Word16 *Z_ep = Z_e; + Word16 tmp; + Word16 max_exp = -31; + move16(); + + /* Processing */ + IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ + { + IF( NE_16( rowsX, entriesY ) ) + { + return EXIT_FAILURE; + } + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + tmp = j + i * rowsX; /*Q0*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ + move32(); + Zp++; + *( Z_ep ) = add( X_e, Y_e[j] ); + move16(); + max_exp = s_max( max_exp, *Z_ep ); // Find the max exp + Z_ep++; + } + } + + Zp = Z; + Z_ep = Z_e; + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + *Zp = L_shr( *Zp, sub( max_exp, *Z_ep ) ); + *Z_ep = max_exp; + Zp++; + Z_ep++; + } + } + } + ELSE /* Regular case */ + { + IF( NE_16( colsX, entriesY ) ) + { + return EXIT_FAILURE; + } + + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + *( Zp ) = Mpy_32_32( *( X ), Y[j] ); /*Q31 - (X_e + Y_e)*/ + move32(); + Zp++; + *( Z_ep ) = add( X_e, Y_e[j] ); + move16(); + max_exp = s_max( max_exp, *Z_ep ); // Find the max exp + Z_ep++; + X++; + } + } + Zp = Z; + Z_ep = Z_e; + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + *Zp = L_shr( *Zp, sub( max_exp, *Z_ep ) ); + *Z_ep = max_exp; + Zp++; + Z_ep++; + } + } + } + + return EXIT_SUCCESS; +} +#endif /* OPT_BASOP_ADD_v1 */ + Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix Q31 - X_e*/ const Word16 *X_e, @@ -1663,7 +1837,9 @@ Word16 matrix_diag_product_fx_1( Word16 i, j; Word32 *Zp = Z; Word16 *Z_ep = Z_e; +#ifndef OPT_BASOP_ADD_v1 Word16 tmp; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1676,11 +1852,19 @@ Word16 matrix_diag_product_fx_1( { FOR( i = 0; i < colsX; ++i ) { +#ifdef OPT_BASOP_ADD_v1 + *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ tmp = add( j, imult1616( i, rowsX ) ); /*Q0*/ *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; +#ifdef OPT_BASOP_ADD_v1 + *( Z_ep ) = add( X_e[j + i * rowsX], Y_e[j] ); +#else /* OPT_BASOP_ADD_v1 */ *( Z_ep ) = add( X_e[tmp], Y_e[j] ); +#endif /* OPT_BASOP_ADD_v1 */ move16(); Z_ep++; } @@ -1726,7 +1910,9 @@ Word16 diag_matrix_product_fx( { Word16 i, j; Word32 *Zp = Z; +#ifndef OPT_BASOP_ADD_v1 Word16 tmp; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1739,8 +1925,12 @@ Word16 diag_matrix_product_fx( { FOR( j = 0; j < entriesY; ++j ) { - tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/ - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#ifdef OPT_BASOP_ADD_v1 + *( Zp ) = Mpy_32_32( X[i + j * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ + tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; } @@ -1786,7 +1976,9 @@ Word16 matrix_product_diag_fx( { Word16 j, k; Word32 *Zp = Z; +#ifndef OPT_BASOP_ADD_v1 Word16 y_idx, x_idx; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ test(); @@ -1805,9 +1997,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; @@ -1825,9 +2021,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; @@ -1847,9 +2047,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } @@ -1869,9 +2073,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; diff --git a/lib_com/options.h b/lib_com/options.h index 59698f78e..b2f44bfe9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,4 +174,5 @@ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ +#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 748bdec38..a6e03eee3 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -68,9 +68,17 @@ static void ivas_binRenderer_filterModule_fx( { Word16 bandIdx, k, chIdx, tapIdx; Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; +#ifdef OPT_BASOP_ADD_v1 + Word16 Q_filterStates; +#else /* OPT_BASOP_ADD_v1 */ Word16 *Q_filterStates; +#endif /* OPT_BASOP_ADD_v1 */ const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; Word16 shift_q; +#ifdef OPT_BASOP_ADD_v1 + Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; + move16(); +#endif /* OPT_BASOP_ADD_v1 */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -78,7 +86,9 @@ static void ivas_binRenderer_filterModule_fx( { filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); +#ifndef OPT_BASOP_ADD_v1 Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx][0] ); +#endif /* OPT_BASOP_ADD_v1 */ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 @@ -100,39 +110,59 @@ static void ivas_binRenderer_filterModule_fx( filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; move32(); +#ifndef OPT_BASOP_ADD_v1 shift_q = sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ); outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); outRealRight_fx = W_shr( outRealRight_fx, shift_q ); outImagRight_fx = W_shr( outImagRight_fx, shift_q ); +#endif /* OPT_BASOP_ADD_v1 */ - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates[tapIdx - 1] - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates +#ifndef OPT_BASOP_ADD_v1 Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1]; move16(); +#endif /* OPT_BASOP_ADD_v1 */ } + +#ifdef OPT_BASOP_ADD_v1 + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); +#else /* OPT_BASOP_ADD_v1 */ shift_q = add( sub( Q_filterStates[1], Q_curr ), 1 ); - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); +#endif /* OPT_BASOP_ADD_v1 */ + +#ifdef OPT_BASOP_ADD_v1 + IF( shift_q != 0 ) + { +#endif /* OPT_BASOP_ADD_v1 */ + outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr +#ifdef OPT_BASOP_ADD_v1 + hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; move32(); filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; move32(); +#ifndef OPT_BASOP_ADD_v1 Q_filterStates[0] = Q_curr; move16(); +#endif /* OPT_BASOP_ADD_v1 */ /* Left Real and Imag */ @@ -318,10 +348,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -335,10 +367,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -352,10 +386,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ } } /* set memories */ @@ -400,7 +436,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); +#endif /* OPT_BASOP_ADD_v1 */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; @@ -414,7 +455,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif /* OPT_BASOP_ADD_v1 */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; @@ -1279,8 +1325,10 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] ); hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] ); @@ -1289,8 +1337,10 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[bandIdx] ); hBinRenConvModule->Q_filterStatesLeft[bandIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx ); @@ -1299,8 +1349,10 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx ); hBinRenConvModule->filterStatesLeftImag_fx = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft ); hBinRenConvModule->Q_filterStatesLeft = NULL; +#endif /* OPT_BASOP_ADD_v1 */ free( ( *hBinRenderer )->hBinRenConvModule ); ( *hBinRenderer )->hBinRenConvModule = NULL; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 13d8fc940..afbde5a60 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -725,7 +725,11 @@ Word16 computeMixingMatrices_fx( Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; Word16 G_hat_buff_e[MAX_OUTPUT_CHANNELS]; +#ifdef OPT_BASOP_ADD_v1 + Word16 mat_mult_buffer2_e, mat_mult_buffer3_e; +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer1_e, mat_mult_buffer2_e, mat_mult_buffer3_e; +#endif /* OPT_BASOP_ADD_v1 */ Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; @@ -775,7 +779,9 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); - +#ifdef OPT_BASOP_ADD_v1 + Word16 max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ /* Computing Ky */ FOR( i = 0; i < lengthCy; ++i ) { @@ -788,8 +794,20 @@ Word16 computeMixingMatrices_fx( move32(); Ky_fx_e[i + ( j * lengthCy )] = tmp_e; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, tmp_e ); +#endif /* OPT_BASOP_ADD_v1 */ } } +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCy * lengthCy; ++i ) + { + Ky_fx[i] = L_shr( Ky_fx[i], sub( max_e, Ky_fx_e[i] ) ); + move32(); + Ky_fx_e[i] = max_e; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Decomposition of Cx @@ -800,7 +818,9 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cx_fx, svd_in_buffer_fx, lengthCx, lengthCx, 0 ); svd_fx( svd_in_buffer_fx, Cx_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCx, lengthCx ); - +#ifdef OPT_BASOP_ADD_v1 + max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { FOR( j = 0; j < lengthCx; ++j ) @@ -812,9 +832,20 @@ Word16 computeMixingMatrices_fx( move32(); Kx_fx_e[( i + ( j * lengthCx ) )] = tmp_e; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, tmp_e ); +#endif /* OPT_BASOP_ADD_v1 */ } } - +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCx * lengthCx; ++i ) + { + Kx_fx[i] = L_shr( Kx_fx[i], sub( max_e, Kx_fx_e[i] ) ); + move32(); + Kx_fx_e[i] = max_e; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { @@ -938,14 +969,25 @@ Word16 computeMixingMatrices_fx( /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ +#ifdef OPT_BASOP_ADD_v1 + Word16 mat_mult_buffer1_fx_e; +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer1_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word16 Q_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; set16_fx( Q_e_arr, Q_e, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); matrix_product_mant_exp( Kx_fx, Kx_fx_e, lengthCx, lengthCx, 1, Q_fx, Q_e_arr, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer2_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( Kx_fx, Kx_fx_e[0], lengthCx, lengthCx, 1, Q_fx, Q_e, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); + + matrix_diag_product_fx_2( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); + + matrix_product_mant_exp_fx( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e[0], lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_diag_product_fx_1( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); matrix_product_mant_exp( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e, lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); @@ -969,6 +1011,7 @@ Word16 computeMixingMatrices_fx( mat_mult_buffer1_e = exp; move16(); +#endif /* OPT_BASOP_ADD_v1 */ IF( LT_16( lengthCx, lengthCy ) ) { @@ -977,7 +1020,11 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCx; move16(); +#ifdef OPT_BASOP_ADD_v1 + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_fx_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); +#else /* OPT_BASOP_ADD_v1 */ svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); +#endif /* OPT_BASOP_ADD_v1 */ } ELSE { @@ -986,7 +1033,11 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCy; move16(); +#ifdef OPT_BASOP_ADD_v1 + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); +#else /* OPT_BASOP_ADD_v1 */ svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); +#endif /* OPT_BASOP_ADD_v1 */ } /* Actually Processing P */ @@ -997,25 +1048,46 @@ Word16 computeMixingMatrices_fx( svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); +#ifdef OPT_BASOP_ADD_v1 + mat_mult_buffer1_fx_e = 0; +#else /* OPT_BASOP_ADD_v1 */ mat_mult_buffer1_e = 0; +#endif /* OPT_BASOP_ADD_v1 */ move16(); mat_mult_buffer2_e = 0; move16(); +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, + mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx, &mat_mult_buffer3_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); +#endif /* OPT_BASOP_ADD_v1 */ /************************ Formulate M **********************/ +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#ifdef OPT_BASOP_ADD_v1 + Word16 mat_mult_buffer1_fx_e1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + set16_fx( mat_mult_buffer1_fx_e1, mat_mult_buffer1_fx_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); + + matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Formulate Cr @@ -1026,9 +1098,15 @@ Word16 computeMixingMatrices_fx( Word16 Cx_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; set16_fx( Cx_e_arr, Cx_fx_e, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1 ); + + matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ exp = mixing_matrix_fx_e[0]; move16(); @@ -1067,7 +1145,11 @@ Word16 computeMixingMatrices_fx( } /* Avoid Meaningless negative main diagonal elements */ +#ifdef OPT_BASOP_ADD_v1 + IF( Cr_fx[i + ( i * lengthCy )] < 0 ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( Cr_fx[i + ( i * lengthCy )], exp, 0, 0 ) < 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { Cr_fx[i + ( i * lengthCy )] = 0; move32(); @@ -1129,7 +1211,11 @@ Word16 computeMixingMatrices_fx( { /* Avoid correction for very small energies, main diagonal elements of Cy_tilde_p may be negative */ +#ifdef OPT_BASOP_ADD_v1 + IF( Cy_tilde_p_fx[i + ( i * lengthCy )] < 0 ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( Cy_tilde_p_fx[i + ( i * lengthCy )], mat_mult_buffer2_e, 0, 0 ) < 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1148,7 +1234,12 @@ Word16 computeMixingMatrices_fx( move16(); } +#ifdef OPT_BASOP_ADD_v1 + Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, adj_e[i] ) ); + IF( GT_32( adj_fx_p[i], temp ) ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], adj_e[i], 1073741824, 3 ) > 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1281,6 +1372,9 @@ Word16 computeMixingMatricesResidual_fx( svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); /* Computing Ky */ +#ifdef OPT_BASOP_ADD_v1 + Word16 max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCy; ++i ) { FOR( j = 0; j < lengthCy; ++j ) @@ -1292,9 +1386,22 @@ Word16 computeMixingMatricesResidual_fx( move32(); Ky_fx_e[i + j * lengthCy] = tmp_e; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, tmp_e ); +#endif /* OPT_BASOP_ADD_v1 */ } } +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCy * lengthCy; ++i ) + { + Ky_fx[i] = L_shr( Ky_fx[i], sub( max_e, Ky_fx_e[i] ) ); + move32(); + Ky_fx_e[i] = max_e; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ + /*-----------------------------------------------------------------* * Decomposition of Cx *-----------------------------------------------------------------*/ @@ -1305,7 +1412,9 @@ Word16 computeMixingMatricesResidual_fx( * square root of the diagonal of Cx */ /* Computing Kx */ - +#ifdef OPT_BASOP_ADD_v1 + max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { exp = Cx_e; @@ -1314,7 +1423,20 @@ Word16 computeMixingMatricesResidual_fx( move32(); Kx_fx_e[i] = exp; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, exp ); +#endif /* OPT_BASOP_ADD_v1 */ + } + +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCx; ++i ) + { + Kx_fx[i] = L_shr( Kx_fx[i], sub( max_e, Kx_fx_e[i] ) ); + move32(); + Kx_fx_e[i] = max_e; + move16(); } +#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Regularization of Sx @@ -1322,16 +1444,25 @@ Word16 computeMixingMatricesResidual_fx( limit_fx = Kx_fx[0]; move32(); +#ifndef OPT_BASOP_ADD_v1 limit_e = Kx_fx_e[0]; move16(); +#endif /* OPT_BASOP_ADD_v1 */ + FOR( i = 1; i < lengthCx; i++ ) { +#ifdef OPT_BASOP_ADD_v1 + IF( GT_32( Kx_fx[i], limit_fx ) ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { limit_fx = Kx_fx[i]; move32(); +#ifndef OPT_BASOP_ADD_v1 limit_e = Kx_fx_e[i]; move16(); +#endif /* OPT_BASOP_ADD_v1 */ } } @@ -1339,7 +1470,11 @@ Word16 computeMixingMatricesResidual_fx( L_tmp = L_add( L_tmp, EPSILLON_FX ); limit_fx = L_tmp; move16(); +#ifdef OPT_BASOP_ADD_v1 + limit_e = add( Kx_fx_e[0], reg_Sx_e ); +#else /* OPT_BASOP_ADD_v1 */ limit_e = add( limit_e, reg_Sx_e ); +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { @@ -1488,10 +1623,16 @@ Word16 computeMixingMatricesResidual_fx( * Formulate M *-----------------------------------------------------------------*/ + +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); + set16_fx( mat_mult_buffer1_buff_e, mat_mult_buffer1_buff_e[0], MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); +#endif /* OPT_BASOP_ADD_v1 */ Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; @@ -1576,7 +1717,12 @@ Word16 computeMixingMatricesResidual_fx( move32(); adj_buff_e[i] = scale; move16(); +#ifdef OPT_BASOP_ADD_v1 + Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, scale ) ); + IF( GT_32( adj_fx_p[i], temp ) ) // 1073741824 -> 1.0f in Q30 +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], scale, 1073741824, 3 ) > 0 ) // 1073741824 -> 1.0f in Q30 +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1971,7 +2117,12 @@ Word16 computeMixingMatricesISM_fx( } } +#ifdef OPT_BASOP_ADD_v1 + Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, temp_e[i] ) ); + IF( GT_32( adj_fx[i], temp ) ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( adj_fx[i], temp_e[i], MAX_32, 2 ) > 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx[i] = MAX_32; move32(); diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 5a948bdfa..4c1d5d190 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2931,7 +2931,11 @@ static void ivas_param_mc_get_mixing_matrices_fx( FOR( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) { +#ifdef OPT_BASOP_ADD_v1 + if ( Cproto_diag_fx[ch_idx1] < 0 ) +#else /* OPT_BASOP_ADD_v1 */ if ( BASOP_Util_Cmp_Mant32Exp( Cproto_diag_fx[ch_idx1], Cproto_diag_e, 0, 0 ) < 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { Cproto_diag_fx[ch_idx1] = 0; move16(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 44207c79a..386644ab1 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -666,7 +666,11 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx Word32 ***filterStatesLeftReal_fx; Word32 ***filterStatesLeftImag_fx; +#ifdef OPT_BASOP_ADD_v1 + Word16 Q_filterStatesLeft; +#else /* OPT_BASOP_ADD_v1 */ Word16 ***Q_filterStatesLeft; +#endif /* OPT_BASOP_ADD_v1 */ Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; -- GitLab From c08fe4f43533a7ec9383b28fa30525126abb57b4 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 5 Mar 2025 17:36:30 +0100 Subject: [PATCH 267/329] Add check for variable PYTEST_MLD_SHORT in .rules-pytest-to-ref-short to enable scheduled trigger --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc4c023dc..ac52a99a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -274,12 +274,11 @@ stages: .rules-pytest-to-ref-short: rules: + - if: $PYTEST_MLD_SHORT # Set by scheduled pipeline - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'push' when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' - when: never .rules-pytest-to-input-short: rules: -- GitLab From 9070166f865c137b9d17c3786f678521908d5fa8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 21:49:33 +0530 Subject: [PATCH 268/329] Fix for 3GPP issue 1334: possible Overflow in stereo leading to a click/pop Link #1334 --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3c01bebfd..4a72b194a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2922,7 +2922,7 @@ void stereo_dft_enc_write_BS_fx( void stereo_dft_enc_res_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ - const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q16 */ + const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q15 */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ Word16 *nb_bits, /* o : number of bits written */ const Word16 max_bits ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 8f9a0edf6..3fd9c2d7a 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1207,7 +1207,7 @@ ivas_error ivas_cpe_enc_fx( FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { - Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 + Q1 ); + Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15 } stereo_dft_enc_res_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM - STEREO_DFT_OVL_8k, hCPE->hMetaData, &nb_bits, max_bits ); } diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index cf246368f..8578a46ae 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -2700,7 +2700,7 @@ static void stereo_dft_enc_get_res_cod_mode_flag_fx( void stereo_dft_enc_res_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ - const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q16 */ + const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q15 */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ Word16 *nb_bits, /* o : number of bits written */ const Word16 max_bits ) @@ -2745,7 +2745,7 @@ void stereo_dft_enc_res_fx( /* MDCT analysis */ // TCX_MDCT_flt( win, MDCT_RES, STEREO_DFT_OVL_8k, L_FRAME8k - STEREO_DFT_OVL_8k, STEREO_DFT_OVL_8k, IVAS_CPE_DFT ); - MDCT_RES_e = 16; + MDCT_RES_e = 17; move16(); TCX_MDCT( win, MDCT_RES, &MDCT_RES_e, STEREO_DFT_OVL_8k, L_FRAME8k - STEREO_DFT_OVL_8k, STEREO_DFT_OVL_8k, IVAS_CPE_DFT ); -- GitLab From e0bea5dc61bd03613b0c783ebf1acb6789fd143c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 5 Mar 2025 21:52:29 +0100 Subject: [PATCH 269/329] fix compiler warnings --- lib_enc/speech_music_classif_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 0188ba45c..415bbaafd 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2286,8 +2286,8 @@ Word16 ivas_smc_gmm_fx( lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #endif move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); @@ -2297,8 +2297,8 @@ Word16 ivas_smc_gmm_fx( lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #endif move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); @@ -2308,8 +2308,8 @@ Word16 ivas_smc_gmm_fx( lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #endif move32(); } @@ -2332,7 +2332,7 @@ Word16 ivas_smc_gmm_fx( hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 11 ) ); // Q7 move16(); #else - hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 + hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 move16(); hSpMusClas->lps_fx = extract_h( L_shl_sat( lps_fx, 16 - 11 ) ); // Q7 move16(); -- GitLab From 8bc215286d3f77b06cba38066fd7f1f98c542f75 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 6 Mar 2025 09:08:02 +0100 Subject: [PATCH 270/329] add cmak build job + cleanup --- .gitlab-ci.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ccb41bd9..988e9fbc5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,9 +79,6 @@ workflow: # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" when: never - # do not spawn pipelines for Draft MRs, see https://docs.gitlab.com/ee/ci/yaml/workflow.html#skip-pipelines-for-draft-merge-requests - # - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - # when: never - if: $CI_PIPELINE_SOURCE == 'merge_request_event' variables: IVAS_PIPELINE_NAME: 'MR pipeline: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME' @@ -319,6 +316,7 @@ stages: .activate-Werror-linux: &activate-Werror-linux - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile + - sed -i.bak "s/# \(set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -Werror\")\)/\1/" CMakeLists.txt .activate-WX-windows: &activate-WX-windows - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" @@ -1204,6 +1202,24 @@ build-codec-linux-make: - *activate-Werror-linux - make -j +build-codec-linux-cmake: + rules: + - if: $CI_PIPELINE_SOURCE == 'web' + - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs + - if: $CI_PIPELINE_SOURCE == 'schedule' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + extends: + - .build-job-linux + tags: + - ivas-basop-linux + script: + - *print-common-info + - *activate-Werror-linux + - cmake -B cmake-build -G "Unix Makefiles" + - cmake --build cmake-build -- -j + # ensure that codec builds on linux with instrumentation active build-codec-linux-instrumented-make: rules: -- GitLab From 02c899cd50ba4bcb1f9c88bc958940977e323cb8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 6 Mar 2025 09:13:01 +0100 Subject: [PATCH 271/329] get script repo with lc3plus test sources in build job --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 988e9fbc5..26067a319 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1217,6 +1217,7 @@ build-codec-linux-cmake: script: - *print-common-info - *activate-Werror-linux + - *update-scripts-repo - cmake -B cmake-build -G "Unix Makefiles" - cmake --build cmake-build -- -j -- GitLab From 7ef3abfd3193aa49cc92dafa1e31d0fd82ba98b7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 6 Mar 2025 09:18:59 +0100 Subject: [PATCH 272/329] remove Werror again --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 26067a319..025e865e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1216,7 +1216,6 @@ build-codec-linux-cmake: - ivas-basop-linux script: - *print-common-info - - *activate-Werror-linux - *update-scripts-repo - cmake -B cmake-build -G "Unix Makefiles" - cmake --build cmake-build -- -j -- GitLab From 75ccfd47463bd199135478c6a52e050d66571113 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:34:18 +0530 Subject: [PATCH 273/329] Bug fix related to 3GPP issue 1316 --- lib_enc/ivas_mdct_core_enc_fx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 6f1d4117d..edfc607ed 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1168,6 +1168,7 @@ void ivas_mdct_core_whitening_enc_fx( Word32 scf_fx[CPE_CHANNELS][NB_DIV][M]; Word32 scf_q_fx[CPE_CHANNELS][NB_DIV][M]; Word64 chE_fx[2], chE_tot_fx; + Word16 chE_q[2]; Word8 sns_low_br_mode; Word16 nbits_start_sns; Word16 num_sns; @@ -1905,6 +1906,7 @@ void ivas_mdct_core_whitening_enc_fx( IF( mct_on ) { set64_fx( chE_fx, 0, NB_DIV ); + set16_fx( chE_q, 0, NB_DIV ); } init_tcx_enc_info_fx( st, &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); @@ -1973,6 +1975,8 @@ void ivas_mdct_core_whitening_enc_fx( chE_fx[n] = W_add( W_deposit32_l( powerSpec_fx[i] ), chE_fx[n] ); move64(); } + chE_q[n] = sub( add( q_pow_tmp, q_pow ), 32 ); + move16(); } sns_compute_scf_fx( powerSpec_fx, st->hTcxCfg->psychParamsCurrent, st->L_frame, scf_fx[ch][n], sub( add( q_pow_tmp, q_pow ), 32 ) ); } @@ -1980,14 +1984,14 @@ void ivas_mdct_core_whitening_enc_fx( /* MCT: detect whether there are silent channels and set mct_chan_mode accordingly */ IF( mct_on ) { - Word16 q = sub( add( q_pow_tmp, q_pow ), 32 ); + Word16 q = s_min( chE_q[0], chE_q[1] ); Word64 silent_thr = SILENT_CHANNEL_THRES_FX; move64(); chE_tot_fx = 0; move64(); FOR( i = 0; i < NB_DIV; i++ ) { - chE_tot_fx = W_add( chE_fx[i], chE_tot_fx ); + chE_tot_fx = W_add( W_shr( chE_fx[i], sub( chE_q[i], q ) ), chE_tot_fx ); } IF( GT_16( q, Q24 ) ) { -- GitLab From caec0b360e69aa746d27ca4166994e5e810e43ce Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:40:51 +0530 Subject: [PATCH 274/329] Fix for 3GPP issue 1344: Decoder segfault for Stereo at 24.4kbps in ivas_fec_noise_filling_fx() Link #1344 --- lib_dec/FEC_HQ_phase_ecu_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index dd63b6508..34d01d7fe 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -4595,11 +4595,11 @@ static void ivas_fec_noise_filling_fx( { L_tmp = L_mult( *sinq_tab, *sinq_tab ); /*Q30 */ sinq_tab++; - q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */ - q1 = round_fx( L_tmp ); /*Q15 */ - L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */ - L_tmp = L_mac( L_tmp, shr( *pt6++, Q_old_out ), q2 ); /*Qsynth+16 */ - ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */ + q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */ + q1 = round_fx( L_tmp ); /*Q15 */ + L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */ + L_tmp = L_add( L_tmp, L_shr( Mpy_32_16_1( L_deposit_h( *pt6++ ), q2 ), Q_old_out ) ); /*Qsynth+16 */ + ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */ move16(); } -- GitLab From 9a549b097a08fad2217ee3414acccfc0d24ded1d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 6 Mar 2025 16:00:04 +0100 Subject: [PATCH 275/329] update .gitlab-ci.yaml - remove -p BASOP from instrumentation job and getWmops.sh --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac52a99a7..58547f2ab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -977,7 +977,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR build-codec-linux-debugging-make: @@ -1730,7 +1730,7 @@ voip-be-on-merge-request: stage: test variables: ret_val: 0 - GET_WMOPS_ARGS: "mem_only basop" + GET_WMOPS_ARGS: "mem_only" timeout: 3 hours 30 minutes before_script: - *print-common-info -- GitLab From 693ea5ac46f50e64ab13133926f168db57548a29 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:36:41 +0530 Subject: [PATCH 276/329] Fix for 3GPP issue 1346: Decoder crash for Stereo at 24.4kbps JBM decoding in ivas_hq_core_dec_fx() Link #1346 --- lib_com/lerp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/lerp.c b/lib_com/lerp.c index bb33d9922..28719205a 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -430,7 +430,7 @@ static void lerp_proc32( Word32 *f /*Qx*/, Word32 *f_out /*Qx*/, Word16 bufferNe { diff = sub( 16384 /*0.5f Q15*/, diff ); /*Q15*/ } - *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) ); /*Qx*/ + *ptr++ = L_add_sat( f[idx], L_sub( Mpy_32_16_1( f[idx + 1], diff ), Mpy_32_16_1( f[idx], diff ) ) ); /*Qx*/ move32(); pos = L_add( pos, shift ); /*Q16*/ idx = extract_h( pos ); -- GitLab From 842e5d97b7e8917b33ceddcf5de3006d0cdf55c5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:44:47 +0530 Subject: [PATCH 277/329] Fix for 3GPP issue 1307: Missing signal in BASOP enc-dec path compared to float enc-dec path using selection test MASA at 24.4 kbps with DTX enabled Link #1307 --- lib_enc/nois_est_fx.c | 37 ++++++++++++++++++++----------------- lib_enc/stat_enc.h | 3 +++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 68eed3d65..0851e4c17 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -326,6 +326,10 @@ void noise_est_init_ivas_fx( hNoiseEst->Etot_sq_st_est_fx = 1600; /* 400 in Q2 */ move16(); move16(); + hNoiseEst->L_Etot_st_est_fx = 167772160; /* 20.0f in Q23 */ + hNoiseEst->L_Etot_sq_st_est_fx = 26214400; /* 400 in Q16 */ + move32(); + move32(); hNoiseEst->epsP_0_2_lp_fx = 4096; /*1.0 Q12*/ move16(); hNoiseEst->epsP_0_2_ad_lp_fx = 0; @@ -2195,9 +2199,9 @@ void noise_est_ivas_fx( Word16 vad_bwidth_fx; /* vad ns control variabel for input bwidth from teh BWD */ /* for DTX operation */ - Word16 lim_Etot_fx; /* Q8 */ - Word16 lim_Etot_sq_fx; /* Q2 */ - Word16 st_E_var_est_fx; /* Q2 */ + Word16 lim_Etot_fx; /* Q8 */ + Word32 lim_Etot_sq_fx; /* Q16 */ + Word32 st_E_var_est_fx; NOISE_EST_HANDLE hNoiseEst; SP_MUS_CLAS_HANDLE hSpMusClas; Word32 Le_min_scaled; @@ -2720,32 +2724,31 @@ void noise_est_ivas_fx( Lnon_sta2 = L_deposit_l( 1024 ); /* 1.0 in Q10 */ } - lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */ - lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */ + lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */ + lim_Etot_sq_fx = L_mult0( lim_Etot_fx, lim_Etot_fx ); /* Q16 */ IF( LT_16( ini_frame, 150 ) ) { /* Allow use of quicker filter during init - if needed */ /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ - hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); // Q8 - move16(); + hNoiseEst->L_Etot_st_est_fx = Madd_32_16_r( L_mult0( 8192, lim_Etot_fx ), hNoiseEst->L_Etot_st_est_fx, 24576 ); // Q23 + move32(); /* st->Etot_sq_st_est = 0.25f * lim_Etot * lim_Etot + (1.0f-0.25f) * st->Etot_sq_st_est; */ - hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); // Q2 - move16(); + hNoiseEst->L_Etot_sq_st_est_fx = Madd_32_16_r( Mult_32_16( lim_Etot_sq_fx, 8192 ), hNoiseEst->L_Etot_sq_st_est_fx, 24576 ); // Q16 + move32(); } ELSE { /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ - hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); // Q8 - move16(); + hNoiseEst->L_Etot_st_est_fx = Madd_32_16_r( L_mult0( 8192, lim_Etot_fx ), hNoiseEst->L_Etot_st_est_fx, 24576 ); // Q23 + move32(); /* st->Etot_sq_st_est = 0.25f * lim_Etot * lim_Etot + (1.0f-0.25f) * st->Etot_sq_st_est; */ - hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); // Q2 - move16(); + hNoiseEst->L_Etot_sq_st_est_fx = Madd_32_16_r( Mult_32_16( lim_Etot_sq_fx, 8192 ), hNoiseEst->L_Etot_sq_st_est_fx, 24576 ); // Q16 + move32(); } - st_E_var_est_fx = sub( hNoiseEst->Etot_sq_st_est_fx, extract_h( L_shl_r( L_mult( hNoiseEst->Etot_st_est_fx, hNoiseEst->Etot_st_est_fx ), 1 ) ) ); // Q2 - - + Word16 exp_tmp; + st_E_var_est_fx = BASOP_Util_Add_Mant32Exp( hNoiseEst->L_Etot_sq_st_est_fx, Q15, L_negate( Mpy_32_32( hNoiseEst->L_Etot_st_est_fx, hNoiseEst->L_Etot_st_est_fx ) ), Q16, &exp_tmp ); // exp(exp_tmp) /*-----------------------------------------------------------------* * Count frames since last correlation or harmonic event *-----------------------------------------------------------------*/ @@ -2775,7 +2778,7 @@ void noise_est_ivas_fx( } test(); test(); - IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && GT_16( st_E_var_est_fx, 32 /* 8.0f in Q2 */ ) ) + IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && EQ_16( BASOP_Util_Cmp_Mant32Exp( st_E_var_est_fx, exp_tmp, 524288 /* 8.0f in Q16 */, Q15 ), 1 ) ) { /* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */ *st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 2 ) ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6fd9ce6f3..ad572d2ba 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -566,6 +566,9 @@ typedef struct noise_estimation_structure Word16 Etot_st_est_fx; /* Q8 Noise estimation - short term estimate of E{ Etot } */ Word16 Etot_sq_st_est_fx; /* Q2 Noise estimation - short term estimate of E{ Etot^2 } */ + Word32 L_Etot_st_est_fx; /* Q23 Noise estimation - short term estimate of E{ Etot } */ + Word32 L_Etot_sq_st_est_fx; /* Q16 Noise estimation - short term estimate of E{ Etot^2 } */ + Word16 aEn_inac_cnt; } NOISE_EST_DATA, *NOISE_EST_HANDLE; -- GitLab From 3116ef12792222dc5086b9edb5a9b52469994161 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 07:28:01 +0530 Subject: [PATCH 278/329] Clean up of prot.h file --- Workspace_msvc/lib_com.vcxproj | 3 - Workspace_msvc/lib_com.vcxproj.filters | 9 - lib_com/ari_hm_fx.c | 1 - lib_com/arith_coder_fx.c | 1 - lib_com/basop_tcx_utils.c | 2 +- lib_com/bitalloc_fx.c | 1 - lib_com/bitstream.c | 3 +- lib_com/cldfb.c | 1 - lib_com/cng_exc.c | 57 - lib_com/codec_tcx_common.c | 1 - lib_com/core_com_config.c | 60 +- lib_com/deemph.c | 3 +- lib_com/delay_comp.c | 3 +- lib_com/disclaimer.c | 2 +- lib_com/enr_1_az.c | 3 +- lib_com/env_adj.c | 3 +- lib_com/env_stab.c | 3 +- lib_com/env_stab_trans.c | 3 +- lib_com/fd_cng_com_fx.c | 1 - lib_com/fft.c | 2 +- lib_com/fft_fx.c | 2 +- lib_com/fft_rel.c | 3 +- lib_com/fill_spectrum.c | 3 +- lib_com/findpulse.c | 3 +- lib_com/float_to_fix_ops.c | 1 - lib_com/frame_ener_fx.c | 3 +- lib_com/get_gain_fx.c | 3 +- lib_com/gs_bitallocation_ivas_fx.c | 1 - lib_com/gs_gains.c | 1 - lib_com/gs_preech_fx.c | 3 +- lib_com/hp50_fx.c | 3 +- lib_com/hq2_core_com.c | 2 +- lib_com/hq_conf.c | 3 +- lib_com/hq_tools_fx.c | 1 - lib_com/ifft_rel.c | 3 +- lib_com/int_lsp.c | 3 +- lib_com/interleave_spectrum.c | 3 +- lib_com/interpol.c | 3 +- lib_com/ivas_agc_com_fx.c | 2 +- lib_com/ivas_arith_fx.c | 3 +- lib_com/ivas_avq_pos_reorder_com_fx.c | 2 +- lib_com/ivas_cov_smooth_fx.c | 1 - lib_com/ivas_dirac_com_fx.c | 3 +- lib_com/ivas_entropy_coder_common_fx.c | 2 +- lib_com/ivas_fb_mixer_fx.c | 3 +- lib_com/ivas_ism_com_fx.c | 3 +- lib_com/ivas_lfe_com_fx.c | 2 +- lib_com/ivas_masa_com_fx.c | 3 +- lib_com/ivas_mc_com_fx.c | 2 +- lib_com/ivas_mc_param_com_fx.c | 1 - lib_com/ivas_mct_com_fx.c | 2 +- lib_com/ivas_mdct_core_com_fx.c | 3 +- lib_com/ivas_mdft_imdft_fx.c | 3 +- lib_com/ivas_omasa_com_fx.c | 3 +- lib_com/ivas_pca_tools_fx.c | 1 - lib_com/ivas_qmetadata_com_fx.c | 3 +- lib_com/ivas_qspherical_com_fx.c | 4 +- lib_com/ivas_sba_config_fx.c | 2 +- lib_com/ivas_sns_com_fx.c | 1 - lib_com/ivas_spar_com_fx.c | 1 - lib_com/ivas_spar_com_quant_util_fx.c | 1 - lib_com/ivas_stereo_dft_com_fx.c | 2 +- lib_com/ivas_stereo_eclvq_com_fx.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 1 - lib_com/ivas_stereo_mdct_bands_com_fx.c | 3 +- lib_com/ivas_stereo_psychlpc_com_fx.c | 2 +- lib_com/ivas_stereo_td_bit_alloc_fx.c | 3 +- lib_com/ivas_tools_fx.c | 3 +- lib_com/ivas_transient_det_fx.c | 3 +- lib_com/lag_wind.c | 1 - lib_com/lerp.c | 129 - lib_com/limit_t0.c | 231 - lib_com/longarith.c | 3 +- lib_com/lsp_conv_poly_fx.c | 3 +- lib_com/modif_fs.c | 3 +- lib_com/mslvq_com.c | 3 +- lib_com/mslvq_com_fx.c | 1 - lib_com/preemph.c | 2 +- lib_com/prot.h | 8340 ----------------- lib_com/prot_fx.h | 793 +- lib_com/pvq_com_fx.c | 1 - lib_com/residu_fx.c | 1 - lib_com/rom_com.c | 3 +- lib_com/rom_com_fx.c | 2 +- lib_com/swb_tbe_com.c | 1 - lib_com/swb_tbe_com_fx.c | 1 - lib_com/tcx_mdct_window.c | 1 - lib_com/tcx_utils_fx.c | 1 - lib_com/tns_base.c | 1 - lib_com/tools.c | 1199 +-- lib_com/tools_fx.c | 1 - lib_com/wtda.c | 3 +- lib_dec/acelp_core_dec_ivas_fx.c | 1 - lib_dec/acelp_core_switch_dec_fx.c | 1 - lib_dec/ari_hm_dec.c | 3 +- lib_dec/arith_coder_dec_fx.c | 1 - lib_dec/avq_dec_fx.c | 1 - lib_dec/cng_dec_fx.c | 1 - lib_dec/core_dec_init_fx.c | 1 - lib_dec/core_dec_switch_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/gs_dec_fx.c | 1 - lib_dec/hf_synth_fx.c | 1 - lib_dec/hq_core_dec_fx.c | 1 - lib_dec/igf_dec_fx.c | 3 +- lib_dec/init_dec_fx.c | 1 - lib_dec/ivas_agc_dec_fx.c | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 3 +- lib_dec/ivas_core_dec_fx.c | 3 +- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 1 - lib_dec/ivas_cpe_dec_fx.c | 3 +- lib_dec/ivas_decision_matrix_dec_fx.c | 3 +- lib_dec/ivas_dirac_dec_fx.c | 3 +- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 3 +- lib_dec/ivas_entropy_decoder_fx.c | 3 +- lib_dec/ivas_init_dec.c | 3 +- lib_dec/ivas_ism_dec_fx.c | 3 +- lib_dec/ivas_ism_dtx_dec_fx.c | 3 +- lib_dec/ivas_ism_metadata_dec_fx.c | 1 - lib_dec/ivas_ism_param_dec_fx.c | 3 +- lib_dec/ivas_ism_renderer_fx.c | 1 - lib_dec/ivas_jbm_dec_fx.c | 3 +- lib_dec/ivas_lfe_dec_fx.c | 1 - lib_dec/ivas_lfe_plc_fx.c | 1 - lib_dec/ivas_ls_custom_dec_fx.c | 3 +- lib_dec/ivas_masa_dec_fx.c | 1 - lib_dec/ivas_mc_param_dec_fx.c | 3 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 1 - lib_dec/ivas_mcmasa_dec_fx.c | 2 +- lib_dec/ivas_mct_core_dec_fx.c | 3 +- lib_dec/ivas_mct_dec_fx.c | 1 - lib_dec/ivas_mct_dec_mct_fx_fx.c | 3 +- lib_dec/ivas_mdct_core_dec_fx.c | 3 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 1 - lib_dec/ivas_objectRenderer_internal_fx.c | 3 +- lib_dec/ivas_omasa_dec_fx.c | 3 +- lib_dec/ivas_osba_dec_fx.c | 3 +- lib_dec/ivas_out_setup_conversion_fx.c | 3 +- lib_dec/ivas_pca_dec_fx.c | 3 +- lib_dec/ivas_post_proc_fx.c | 1 - lib_dec/ivas_qmetadata_dec_fx.c | 3 +- lib_dec/ivas_qspherical_dec_fx.c | 2 +- lib_dec/ivas_range_uni_dec_fx.c | 3 +- lib_dec/ivas_sba_dec_fx.c | 3 +- lib_dec/ivas_sba_rendering_internal_fx.c | 3 +- lib_dec/ivas_sce_dec_fx.c | 1 - lib_dec/ivas_sns_dec_fx.c | 3 +- lib_dec/ivas_spar_decoder_fx.c | 3 +- lib_dec/ivas_spar_md_dec_fx.c | 3 +- lib_dec/ivas_stereo_adapt_GR_dec_fx.c | 3 +- lib_dec/ivas_stereo_cng_dec.c | 3 +- lib_dec/ivas_stereo_dft_dec.c | 1 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 3 +- lib_dec/ivas_stereo_dft_dec_fx.c | 1 - lib_dec/ivas_stereo_dft_plc_fx.c | 1 - lib_dec/ivas_stereo_eclvq_dec_fx.c | 2 +- lib_dec/ivas_stereo_ica_dec_fx.c | 3 +- lib_dec/ivas_stereo_icbwe_dec_fx.c | 1 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 3 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 3 +- lib_dec/ivas_stereo_switching_dec_fx.c | 3 +- lib_dec/ivas_stereo_td_dec_fx.c | 1 - lib_dec/ivas_svd_dec_fx.c | 3 +- lib_dec/ivas_tcx_core_dec_fx.c | 3 +- lib_dec/ivas_td_low_rate_dec_fx.c | 1 - lib_dec/jbm_jb4_circularbuffer.c | 2 +- lib_dec/jbm_jb4_circularbuffer.h | 2 +- lib_dec/jbm_jb4_inputbuffer.c | 2 +- lib_dec/jbm_jb4_jmf.c | 2 +- lib_dec/jbm_jb4sb.c | 1 - lib_dec/jbm_pcmdsp_apa.c | 3 +- lib_dec/lib_dec_fx.c | 5 +- lib_dec/swb_tbe_dec_fx.c | 1 - lib_dec/tonalMDCTconcealment_fx.c | 1 - lib_enc/ACcontextMapping_enc_fx.c | 1 - lib_enc/FEC_enc_fx.c | 1 - lib_enc/SNR_calc_fx.c | 1 - lib_enc/acelp_core_enc_fx.c | 1 - lib_enc/acelp_core_switch_enc_fx.c | 1 - lib_enc/ari_hm_enc_fx.c | 4 +- lib_enc/avq_cod_fx.c | 4 +- lib_enc/cng_enc_fx.c | 10 +- lib_enc/cod2t32_fx.c | 1 - lib_enc/cod4t64_fast.c | 1 - lib_enc/cod4t64_fx.c | 3 +- lib_enc/cod_tcx_fx.c | 2 - lib_enc/core_enc_init_fx.c | 1 - lib_enc/core_enc_switch_fx.c | 5 +- lib_enc/dtx_fx.c | 1 - lib_enc/enc_gen_voic_fx.c | 3 +- lib_enc/enc_higher_acelp_fx.c | 3 +- lib_enc/enc_pit_exc_fx.c | 1 - lib_enc/enc_prm_fx.c | 3 +- lib_enc/enc_tran_fx.c | 1 - lib_enc/enc_uv_fx.c | 3 +- lib_enc/eval_pit_contr_fx.c | 1 - lib_enc/evs_enc_fx.c | 3 +- lib_enc/fd_cng_enc_fx.c | 1 - lib_enc/find_wsp_fx.c | 3 +- lib_enc/gain_enc_fx.c | 1 - lib_enc/gaus_enc_fx.c | 1 - lib_enc/gs_enc_fx.c | 2 - lib_enc/hq_classifier_enc_fx.c | 1 - lib_enc/hq_core_enc_fx.c | 10 +- lib_enc/hq_env_enc_fx.c | 1 - lib_enc/hq_hr_enc_fx.c | 1 - lib_enc/hq_lr_enc_fx.c | 1 - lib_enc/hvq_enc_fx.c | 1 - lib_enc/igf_enc.c | 38 +- lib_enc/igf_enc_fx.c | 3 +- lib_enc/igf_scf_enc.c | 3 +- lib_enc/init_enc_fx.c | 1 - lib_enc/inov_enc_fx.c | 1 - lib_enc/ivas_agc_enc_fx.c | 3 +- lib_enc/ivas_core_enc_fx.c | 3 +- lib_enc/ivas_core_pre_proc_front_fx.c | 2 - lib_enc/ivas_core_pre_proc_fx.c | 3 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 1 - lib_enc/ivas_cpe_enc_fx.c | 3 +- lib_enc/ivas_decision_matrix_enc_fx.c | 3 +- lib_enc/ivas_dirac_enc_fx.c | 1 - lib_enc/ivas_enc_cov_handler_fx.c | 3 +- lib_enc/ivas_enc_fx.c | 3 +- lib_enc/ivas_entropy_coder_fx.c | 1 - lib_enc/ivas_front_vad_fx.c | 3 +- lib_enc/ivas_init_enc_fx.c | 3 +- lib_enc/ivas_ism_dtx_enc_fx.c | 3 +- lib_enc/ivas_ism_enc_fx.c | 3 +- lib_enc/ivas_ism_metadata_enc_fx.c | 3 +- lib_enc/ivas_ism_param_enc_fx.c | 1 - lib_enc/ivas_lfe_enc_fx.c | 3 +- lib_enc/ivas_masa_enc_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 2 - lib_enc/ivas_mc_paramupmix_enc_fx.c | 3 +- lib_enc/ivas_mcmasa_enc_fx.c | 1 - lib_enc/ivas_mct_core_enc_fx.c | 4 +- lib_enc/ivas_mct_enc_fx.c | 3 +- lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 3 +- lib_enc/ivas_omasa_enc_fx.c | 1 - lib_enc/ivas_osba_enc_fx.c | 3 +- lib_enc/ivas_pca_enc_fx.c | 3 +- lib_enc/ivas_qmetadata_enc_fx.c | 4 +- lib_enc/ivas_qspherical_enc_fx.c | 1 - lib_enc/ivas_range_uni_enc_fx.c | 2 +- lib_enc/ivas_sba_enc_fx.c | 3 +- lib_enc/ivas_sce_enc_fx.c | 1 - lib_enc/ivas_sns_enc_fx.c | 3 +- lib_enc/ivas_spar_encoder_fx.c | 1 - lib_enc/ivas_spar_md_enc_fx.c | 2 - lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 2 +- lib_enc/ivas_stereo_classifier_fx.c | 3 +- lib_enc/ivas_stereo_cng_enc_fx.c | 3 +- lib_enc/ivas_stereo_dft_enc_fx.c | 3 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 1 - lib_enc/ivas_stereo_dft_td_itd_fx.c | 3 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 2 - lib_enc/ivas_stereo_eclvq_enc_fx.c | 1 - lib_enc/ivas_stereo_ica_enc_fx.c | 3 +- lib_enc/ivas_stereo_icbwe_enc_fx.c | 3 +- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 1 - lib_enc/ivas_stereo_switching_enc_fx.c | 3 +- lib_enc/ivas_stereo_td_analysis_fx.c | 3 +- lib_enc/ivas_stereo_td_enc_fx.c | 3 +- lib_enc/ivas_tcx_core_enc_fx.c | 3 +- lib_enc/ivas_td_low_rate_enc_fx.c | 1 - lib_enc/lib_enc.c | 1 - lib_enc/lsf_enc_fx.c | 1 - lib_enc/lsf_msvq_ma_enc.c | 1 - lib_enc/mdct_classifier_fx.c | 1 - lib_enc/mslvq_enc_fx.c | 3 +- lib_enc/nelp_enc_fx.c | 1 - lib_enc/peak_vq_enc_fx.c | 1 - lib_enc/pit_enc_fx.c | 1 - lib_enc/range_enc_fx.c | 1 - lib_enc/speech_music_classif_fx.c | 1 - lib_enc/stat_noise_uv_enc_fx.c | 1 - lib_enc/swb_bwe_enc_fx.c | 3 +- lib_enc/swb_bwe_enc_lr_fx.c | 1 - lib_enc/swb_tbe_enc.c | 46 - lib_enc/swb_tbe_enc_fx.c | 1 - lib_enc/tcq_core_enc_fx.c | 1 - lib_enc/tns_base_enc_fx.c | 1 - lib_enc/transition_enc_fx.c | 1 - lib_rend/ivas_allrad_dec_fx.c | 2 +- lib_rend/ivas_crend_fx.c | 3 +- lib_rend/ivas_dirac_ana_fx.c | 3 +- .../ivas_dirac_dec_binaural_functions_fx.c | 1 - lib_rend/ivas_dirac_decorr_dec_fx.c | 3 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 3 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 +- lib_rend/ivas_dirac_rend_fx.c | 3 +- lib_rend/ivas_efap_fx.c | 1 - lib_rend/ivas_hrtf_fx.c | 2 +- lib_rend/ivas_limiter_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 3 +- lib_rend/ivas_mcmasa_ana_fx.c | 3 +- lib_rend/ivas_objectRenderer_fx.c | 3 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 3 +- lib_rend/ivas_objectRenderer_mix_fx.c | 3 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 3 +- lib_rend/ivas_objectRenderer_sources_fx.c | 3 +- lib_rend/ivas_objectRenderer_vec_fx.c | 3 +- lib_rend/ivas_omasa_ana_fx.c | 3 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_reflections_fx.c | 3 +- lib_rend/ivas_render_config_fx.c | 3 +- lib_rend/ivas_reverb_delay_line_fx.c | 3 +- lib_rend/ivas_reverb_fft_filter_fx.c | 3 +- lib_rend/ivas_reverb_filter_design_fx.c | 1 - lib_rend/ivas_reverb_fx.c | 3 +- lib_rend/ivas_reverb_iir_filter_fx.c | 3 +- lib_rend/ivas_reverb_utils_fx.c | 3 +- lib_rend/ivas_rotation_fx.c | 3 +- lib_rend/ivas_sba_rendering_fx.c | 1 - lib_rend/ivas_shoebox_fx.c | 1 - lib_rend/ivas_td_decorr_fx.c | 1 - lib_rend/ivas_vbap_fx.c | 3 +- lib_rend/lib_rend.c | 1 - lib_util/hrtf_file_reader.c | 3 +- lib_util/ls_custom_file_reader.c | 2 +- lib_util/mime_io.c | 2 +- lib_util/render_config_reader.c | 2 +- lib_util/rotation_file_reader.c | 1 - lib_util/vector3_pair_file_reader.c | 1 - 327 files changed, 990 insertions(+), 10601 deletions(-) delete mode 100644 lib_com/cng_exc.c delete mode 100644 lib_com/limit_t0.c delete mode 100644 lib_com/prot.h delete mode 100644 lib_enc/swb_tbe_enc.c diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 8c42f19ca..5b26a2911 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -138,7 +138,6 @@ - @@ -238,7 +237,6 @@ - @@ -324,7 +322,6 @@ - diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 8f2be8853..b9769e3ec 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -304,9 +304,6 @@ common_all_c - - common_all_c - common_all_c @@ -412,9 +409,6 @@ common_all_c - - common_all_c - common_all_c @@ -588,9 +582,6 @@ common_h - - common_h - common_h diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c index 076bc8d92..46f8ecea1 100644 --- a/lib_com/ari_hm_fx.c +++ b/lib_com/ari_hm_fx.c @@ -10,7 +10,6 @@ #include "basop_util.h" #include "rom_com.h" #include "prot_fx.h" -#include "prot.h" #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) void UnmapIndex( diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c index de22a7cf3..846b4dcea 100644 --- a/lib_com/arith_coder_fx.c +++ b/lib_com/arith_coder_fx.c @@ -6,7 +6,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "prot.h" #include "basop_util.h" #include "basop_proto_func.h" #include "cnst.h" diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index 378faae0f..8038c4f91 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -40,7 +40,7 @@ #include "cnst.h" #include "basop_proto_func.h" #include "stl.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #define WMC_TOOL_SKIP diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c index 92a8e3928..30ae2d47b 100644 --- a/lib_com/bitalloc_fx.c +++ b/lib_com/bitalloc_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ void bitalloc_fx( Word16 *y, /* i : reordered norm of sub-vectors Q0 */ diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index e5754fa35..9c0a53f8f 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -38,7 +38,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "stat_enc.h" #include "stat_dec.h" @@ -1884,7 +1883,7 @@ static void decision_matrix_core_dec( * Set up MDCT core switching if indicated in the bitstream *-------------------------------------------------------------------*/ -void mdct_switching_dec( +void mdct_switching_dec_ivas_fx( Decoder_State *st /* i/o: decoder state structure */ ) { diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 1907ef327..38195b65d 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -39,7 +39,6 @@ #include "options.h" #include #include "stat_dec.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "rom_com_fx.h" diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c deleted file mode 100644 index 494305e6f..000000000 --- a/lib_com/cng_exc.c +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - -#define A2 0.2f -#define GAIN_VAR 0.000011f - - -/*-------------------------------------------------------* - * cng_params_upd() - * - * update CNG parameters - *-------------------------------------------------------*/ diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index f6da34b55..1ebc2829c 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -6,7 +6,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "rom_basop_util.h" diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index fdf935461..ed72605de 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -38,10 +38,9 @@ #include #include "options.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #define FSCALE_DENOM_BY_12800_Q15 1311 @@ -551,63 +550,6 @@ int16_t sr2fscale( return (int16_t) ( ( FSCALE_DENOM * sr_core ) / 12800 ); } -/*-------------------------------------------------------------------* - * getCoreSamplerateMode2_flt() - * - * - *-------------------------------------------------------------------*/ - -int32_t getCoreSamplerateMode2_flt( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ -) -{ - int32_t sr_core = 0; - - if ( bwidth == NB ) - { - sr_core = INT_FS_12k8; - } - else if ( element_mode == EVS_MONO && ( ( bwidth == WB && total_brate < ACELP_13k20 ) || ( bwidth == SWB && total_brate <= ACELP_13k20 ) || ( rf_mode == 1 ) ) ) - { - sr_core = INT_FS_12k8; - } - else if ( element_mode > EVS_MONO && flag_ACELP16k == 0 ) - { - sr_core = INT_FS_12k8; - } - else if ( bwidth == WB || ( bwidth == SWB && total_brate <= ACELP_32k ) || ( bwidth == FB && total_brate <= ACELP_32k ) ) - { - sr_core = INT_FS_16k; - } - else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE && element_mode == IVAS_SCE && !is_ism_format ) - { - sr_core = INT_FS_16k; - } - else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE_ISM && element_mode == IVAS_SCE && is_ism_format ) - { - sr_core = INT_FS_16k; - } - else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE && element_mode == IVAS_SCE && is_ism_format ) - { - sr_core = 25600; - } - else if ( ( ( bwidth == SWB || bwidth == FB ) && element_mode == EVS_MONO && total_brate <= HQ_64k ) || ( element_mode > IVAS_SCE && ( ( bwidth == SWB && total_brate <= IVAS_96k ) || ( bwidth == FB && total_brate <= IVAS_96k ) ) ) ) - { - sr_core = 25600; - } - else if ( bwidth == SWB || bwidth == FB ) - { - sr_core = 32000; - } - - return sr_core; -} - Word32 getCoreSamplerateMode2( const Word16 element_mode, /* i : IVAS element mode Q0*/ const Word32 total_brate, /* i : total bitrate Q0*/ diff --git a/lib_com/deemph.c b/lib_com/deemph.c index b2b43cf72..c03a050bc 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -36,9 +36,8 @@ #include #include "options.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" void deemph_fx_32( diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 9e6c450cd..edccca074 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-------------------------------------------------------------------------- * get_delay() diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index ba0973f97..1a01c2c32 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -36,7 +36,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #define WMC_TOOL_SKIP diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index 81fb78262..5c99cdfa5 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -37,9 +37,8 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c index 18520e188..5a83dbe5f 100644 --- a/lib_com/env_adj.c +++ b/lib_com/env_adj.c @@ -38,9 +38,8 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*--------------------------------------------------------------------------* * env_adj() diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c index b80fd0a8b..a3140b4e4 100644 --- a/lib_com/env_stab.c +++ b/lib_com/env_stab.c @@ -39,11 +39,10 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" #include "stl.h" -#include "prot_fx.h" /*--------------------------------------------------------------------------* * Local constants *--------------------------------------------------------------------------*/ diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c index 8c6ec265f..829bef5f4 100644 --- a/lib_com/env_stab_trans.c +++ b/lib_com/env_stab_trans.c @@ -38,10 +38,9 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*--------------------------------------------------------------------------* * env_stab_transient_detect() * diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index e04a13fdf..78809ed2c 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -12,7 +12,6 @@ #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot.h" #define FFT_SCALING_512 1073741824 // Q22 #define FFT_SCALING_640 1342177280 // Q22 diff --git a/lib_com/fft.c b/lib_com/fft.c index 352a24be9..e262f3909 100644 --- a/lib_com/fft.c +++ b/lib_com/fft.c @@ -39,7 +39,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index acadbb06b..73ff582df 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -44,7 +44,7 @@ #include "options.h" #include #include "cnst.h" -// #include "prot.h" +// #include "prot_fx.h" #include "prot_fx.h" //#include "cnst_fx.h" #include "rom_com.h" diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index 839b2faaf..1d020cabd 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*---------------------------------------------------------------------* * Local constants diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c index 12ed75f0a..bd9080a7b 100644 --- a/lib_com/fill_spectrum.c +++ b/lib_com/fill_spectrum.c @@ -38,9 +38,8 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c index f2347d5b3..68853e061 100644 --- a/lib_com/findpulse.c +++ b/lib_com/findpulse.c @@ -37,10 +37,9 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" /*----------------------------------------------------------------------------------* * findpulse() diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 41d90359f..1f7c28fd8 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -3,7 +3,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #define WMC_TOOL_SKIP diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 4428c0796..68fdf33c3 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -38,9 +38,8 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*----------------------------------------------------------------------------------* * fer_energy() * diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c index d4c2413c3..8ec4f5a40 100644 --- a/lib_com/get_gain_fx.c +++ b/lib_com/get_gain_fx.c @@ -36,9 +36,8 @@ #include #include "options.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*----------------------------------------------------------------------------------* * get_gain() diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index eef3d50c6..0921dc88c 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -5,7 +5,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot.h" /* Function prototypes */ #include "assert.h" /* Debug prototypes */ diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c index 9adb448a4..8fa769475 100644 --- a/lib_com/gs_gains.c +++ b/lib_com/gs_gains.c @@ -39,7 +39,6 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 2e9e5eb96..3b3eaa777 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -39,9 +39,8 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 9820eb3c8..f5e7105cf 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -37,9 +37,8 @@ #include #include #include "options.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #define HP20_COEFF_SCALE ( 2 ) diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c index bc4edb869..121dae06a 100644 --- a/lib_com/hq2_core_com.c +++ b/lib_com/hq2_core_com.c @@ -39,7 +39,7 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "basop_util.h" #include "basop_proto_func.h" #include "wmc_auto.h" diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c index c139a493c..90a256cea 100644 --- a/lib_com/hq_conf.c +++ b/lib_com/hq_conf.c @@ -38,9 +38,8 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" void hq_configure_fx( diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 4426f85d9..cf3ce202e 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -39,7 +39,6 @@ #include "rom_com.h" /* Static table prototypes FIP version */ #include "stl.h" /* required for wmc_tool */ #include "prot_fx.h" -#include "prot.h" #include "ivas_prot_fx.h" /*--------------------------------------------------------------------------* diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index 423eea46d..9e64a4e25 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index 0f673b8fd..570e9ebd9 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -37,10 +37,9 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" void int_lsp_fx( diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c index 745ee6ac3..5c4c98e29 100644 --- a/lib_com/interleave_spectrum.c +++ b/lib_com/interleave_spectrum.c @@ -37,10 +37,9 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/interpol.c b/lib_com/interpol.c index 45021f1c2..a490a7552 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "rom_com.h" -#include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index b2c09fa07..94e6b222f 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -38,7 +38,7 @@ #include "ivas_prot_fx.h" #include #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" /*------------------------------------------------------------------------------------------* * Local constants diff --git a/lib_com/ivas_arith_fx.c b/lib_com/ivas_arith_fx.c index 2f729bbd4..006a31177 100644 --- a/lib_com/ivas_arith_fx.c +++ b/lib_com/ivas_arith_fx.c @@ -33,9 +33,8 @@ #include #include "options.h" #include "wmc_auto.h" -#include "prot.h" -#include "ivas_prot.h" #include "prot_fx.h" +#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "stat_dec.h" diff --git a/lib_com/ivas_avq_pos_reorder_com_fx.c b/lib_com/ivas_avq_pos_reorder_com_fx.c index ac539b787..25f8be3ad 100644 --- a/lib_com/ivas_avq_pos_reorder_com_fx.c +++ b/lib_com/ivas_avq_pos_reorder_com_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /*-----------------------------------------------------------------* diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index 445ea8c78..acc0df821 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "ivas_prot.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 557db9696..9b60b2c5c 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -37,10 +37,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index d28828d6f..99381d19a 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -35,7 +35,7 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 43f468fb0..883861024 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -34,13 +34,12 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index d3f18a795..f1201b06c 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -35,13 +35,12 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index 4d993d64f..7464c41c2 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -34,7 +34,7 @@ #include "math.h" #include "options.h" #include "ivas_stat_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index 35db926d0..fbe752aad 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -34,14 +34,13 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_rom_com_fx.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index 88d6c1b5e..62d623b83 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index d69da849a..a54abe7ab 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_com.h" diff --git a/lib_com/ivas_mct_com_fx.c b/lib_com/ivas_mct_com_fx.c index b220d69a7..1f3c58153 100644 --- a/lib_com/ivas_mct_com_fx.c +++ b/lib_com/ivas_mct_com_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_mdct_core_com_fx.c b/lib_com/ivas_mdct_core_com_fx.c index a5cfb8673..000f3992f 100644 --- a/lib_com/ivas_mdct_core_com_fx.c +++ b/lib_com/ivas_mdct_core_com_fx.c @@ -34,9 +34,8 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" /*--------------------------------------------------------------------------* diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index 0f24fba81..b10444307 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -33,14 +33,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" #include #include -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index eb230b224..ef6350285 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -35,11 +35,10 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" #include -#include "prot_fx.h" /*--------------------------------------------------------------- * Local constants diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 5689e81c0..1e36c5e8e 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -38,7 +38,6 @@ #include #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index cbc67de00..79a585e8b 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -37,10 +37,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 8ef48be2e..5caa850cb 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -37,12 +37,10 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 94ceb8e3c..38785956c 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -37,7 +37,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index 788fb3c56..f35de8eb0 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 0ebae0de6..fc6e60310 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "basop_util.h" #include "ivas_stat_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 0f0e003dd..8292de5c1 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "math.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index 1157fffcf..80e64c0cc 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -36,7 +36,7 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index b4fb66429..d0ffff39c 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -37,7 +37,7 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /*--------------------------------------------------------------- diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 78a3c90ca..9aa880842 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_mdct_bands_com_fx.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c index b1750fd16..c21abcf8c 100644 --- a/lib_com/ivas_stereo_mdct_bands_com_fx.c +++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c @@ -37,9 +37,8 @@ #include "ivas_rom_com.h" #include "ivas_prot.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_com/ivas_stereo_psychlpc_com_fx.c b/lib_com/ivas_stereo_psychlpc_com_fx.c index 996b262db..cb3c39df2 100644 --- a/lib_com/ivas_stereo_psychlpc_com_fx.c +++ b/lib_com/ivas_stereo_psychlpc_com_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index 14ab8131e..9074473d7 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -38,9 +38,8 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 9cd1a063e..e460637f7 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -34,11 +34,10 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #define ANGLE_90_DEG_Q22 377487360 diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index b5ea507eb..97025b46f 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -34,11 +34,10 @@ #include "options.h" #include "math.h" #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_stat_com.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c index e0871fa70..9fb287271 100644 --- a/lib_com/lag_wind.c +++ b/lib_com/lag_wind.c @@ -37,7 +37,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "cnst.h" #include "rom_com.h" diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 28719205a..4e306b936 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -36,154 +36,25 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" - /*-------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------*/ -static void lerp_proc_flt( const float *f, float *f_out, const int16_t bufferNewSize, const int16_t bufferOldSize ); - - /*-------------------------------------------------------------* * procedure lerp_flt() * * * * * *-------------------------------------------------------------*/ -void lerp_flt( - const float *f, - float *f_out, - const int16_t bufferNewSize, - const int16_t bufferOldSize_inp ) -{ - float maxFac; - int16_t bufferOldSize, tmpNewSize; - - maxFac = 507.0 / 128.0; - bufferOldSize = bufferOldSize_inp; - - if ( (float) bufferNewSize / bufferOldSize > maxFac ) - { - tmpNewSize = bufferOldSize * 2; - while ( bufferNewSize > bufferOldSize ) - { - if ( (float) bufferNewSize / bufferOldSize <= maxFac ) - { - tmpNewSize = bufferNewSize; - } - - lerp_proc_flt( f, f_out, tmpNewSize, bufferOldSize ); - - f = f_out; - bufferOldSize = tmpNewSize; - tmpNewSize *= 2; - } - } - else if ( (float) bufferOldSize / bufferNewSize > maxFac ) - { - tmpNewSize = bufferOldSize / 2; - while ( bufferNewSize < bufferOldSize ) - { - if ( (float) bufferOldSize / bufferNewSize <= maxFac ) - { - tmpNewSize = bufferNewSize; - } - - lerp_proc_flt( f, f_out, tmpNewSize, bufferOldSize ); - - f = f_out; - bufferOldSize = tmpNewSize; - tmpNewSize /= 2; - } - } - else - { - lerp_proc_flt( f, f_out, bufferNewSize, bufferOldSize ); - } - - return; -} - /*-------------------------------------------------------------* * procedure lerp_proc_flt() * * * * * *-------------------------------------------------------------*/ -static void lerp_proc_flt( - const float *f, - float *f_out, - const int16_t bufferNewSize, - const int16_t bufferOldSize ) -{ - int16_t i, idx; - float pos, shift, diff; - float buf[2 * L_FRAME_MAX]; - Word16 tmp; - - if ( bufferNewSize == bufferOldSize ) - { - mvr2r( f, buf, bufferNewSize ); - mvr2r( buf, f_out, bufferNewSize ); - return; - } - - /* Using the basop code to avoid reading beyond end of input for bufferOldSize=320, bufferNewSize=640 */ - tmp = div_s( bufferOldSize, shl( bufferNewSize, 4 ) ); - shift = (float) ( L_shl( L_deposit_l( tmp ), 4 - 15 + 16 ) ) / 65536.0f; - pos = 0.5f * shift - 0.5f; - - if ( shift < 0.3f ) - { - pos = pos - 0.13f; - } - - /* first point of interpolation */ - if ( pos < 0 ) - { - buf[0] = f[0] + pos * ( f[1] - f[0] ); - } - else - { - idx = (int16_t) pos; - diff = pos - idx; - buf[0] = f[idx] + diff * ( f[idx + 1] - f[idx] ); - } - - pos += shift; - - for ( i = 1; i < bufferNewSize - 1; i++ ) - { - idx = (int16_t) pos; - diff = pos - idx; - - buf[i] = f[idx] + diff * ( f[idx + 1] - f[idx] ); - pos += shift; - } - - - /* last point */ - idx = (int16_t) pos; - - if ( pos > bufferOldSize - 1 ) - { - idx = bufferOldSize - 2; - } - - diff = pos - idx; - - buf[bufferNewSize - 1] = f[idx] + diff * ( f[idx + 1] - f[idx] ); - - mvr2r( buf, f_out, bufferNewSize ); - - return; -} - - /*-------------------------------------------------------------* * Local constants *-------------------------------------------------------------*/ diff --git a/lib_com/limit_t0.c b/lib_com/limit_t0.c deleted file mode 100644 index d49cad283..000000000 --- a/lib_com/limit_t0.c +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------* - * Local constants - *-------------------------------------------------*/ - -#define LIMIT_PIT_REL_LOWER 2 /* delta interval to extend pitch coding in relative Q */ -#define LIMIT_PIT_REL_UPPER 0 - -/*-------------------------------------------------* - * limit_T0() - * - * Close-loop pitch lag search limitation - *-------------------------------------------------*/ - -void limit_T0( - const int16_t L_frame, /* i : length of the frame */ - const int16_t delta, /* i : Half the close-loop searched interval */ - const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const int16_t limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_max /* o : higher pitch limit */ -) -{ - int16_t delta2, T1; - int16_t pit_min, pit_max; - - if ( limit_flag == 0 ) /* restrained Q limits */ - { - /* set limits */ - if ( L_frame == L_FRAME ) - { - pit_max = PIT_MAX; - pit_min = PIT_MIN; - } - else /* L_frame == L_FRAME16k */ - { - pit_max = PIT16k_MAX; - pit_min = PIT16k_MIN; - } - - delta2 = 2 * delta - 1; - - T1 = T0; - if ( T0_frac >= 2 ) - { - T1++; - } - *T0_min = T1 - delta; - - if ( *T0_min < pit_min ) - { - *T0_min = pit_min; - } - *T0_max = *T0_min + delta2; - - if ( *T0_max > pit_max ) - { - *T0_max = pit_max; - *T0_min = *T0_max - delta2; - } - } - else /* extended Q limits */ - { - - /* set limits */ - if ( L_frame == L_FRAME ) - { - pit_max = PIT_MAX; - pit_min = PIT_MIN_EXTEND; - - if ( limit_flag == 2 ) - { - pit_min = PIT_MIN_DOUBLEEXTEND; - } - } - else /* L_frame == L_FRAME16k */ - { - pit_max = PIT16k_MAX; - pit_min = PIT16k_MIN_EXTEND; - } - - delta2 = 2 * delta - 1; - - T1 = T0; - if ( T0_frac >= 2 ) - { - T1++; - } - *T0_min = T1 - delta; - - if ( pit_flag == 0 ) - { - /* subframes with absolute search: keep Q range */ - if ( *T0_min < pit_min ) - { - *T0_min = pit_min; - } - *T0_max = *T0_min + delta2; - - if ( *T0_max > pit_max ) - { - *T0_max = pit_max; - *T0_min = *T0_max - delta2; - } - } - else - { - /* subframes with relative search: extend Q range */ - if ( *T0_min < pit_min - LIMIT_PIT_REL_LOWER ) - { - *T0_min = pit_min - LIMIT_PIT_REL_LOWER; - } - - if ( *T0_min < L_INTERPOL ) - { - *T0_min = L_INTERPOL; - } - *T0_max = *T0_min + delta2; - - if ( *T0_max > pit_max + LIMIT_PIT_REL_UPPER ) - { - *T0_max = pit_max + LIMIT_PIT_REL_UPPER; - *T0_min = *T0_max - delta2; - } - } - } - - return; -} - - -/*-------------------------------------------------* - * Routine limit_T0_voiced_ivas() - * - * Close-loop pitch lag search limitation - *-------------------------------------------------*/ - -void limit_T0_voiced_ivas( - const int16_t nbits, - const int16_t res, - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - const int16_t T0_res, /* i : pitch resolution */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_min_frac, /* o : lower pitch limit */ - int16_t *T0_max, /* o : higher pitch limit */ - int16_t *T0_max_frac, /* o : higher pitch limit */ - const int16_t pit_min, /* i : Minimum pitch lag */ - const int16_t pit_max /* i : Maximum pitch lag */ -) -{ - int16_t T1, temp1, temp2; - - /* Mid-point */ - T1 = T0; - if ( ( T0_res > 1 ) && ( T0_frac >= ( T0_res >> 1 ) ) ) - { - T1++; - } - - /* Lower-bound */ - temp1 = ( T1 * res ) - ( 1 << ( nbits - 1 ) ); - temp2 = temp1 / res; - *T0_min = temp2; - *T0_min_frac = temp1 - temp2 * res; - if ( *T0_min < pit_min ) - { - *T0_min = pit_min; - *T0_min_frac = 0; - } - - /* Higher-bound */ - temp1 = ( *T0_min * res ) + *T0_min_frac + ( 1 << nbits ) - 1; - temp2 = temp1 / res; - *T0_max = temp2; - *T0_max_frac = temp1 - temp2 * res; - if ( *T0_max > pit_max ) - { - *T0_max = pit_max; - *T0_max_frac = res - 1; - temp1 = ( *T0_max * res ) + *T0_max_frac - ( 1 << nbits ) + 1; - temp2 = temp1 / res; - *T0_min = temp2; - *T0_min_frac = temp1 - temp2 * res; - } - - return; -} diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 66c5dd15e..8946e41aa 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -37,10 +37,9 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c index 61ead2bf2..4f493cacd 100644 --- a/lib_com/lsp_conv_poly_fx.c +++ b/lib_com/lsp_conv_poly_fx.c @@ -6,10 +6,9 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 1b2836252..7ed3cb59b 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -38,10 +38,9 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" void Interpolate_allpass_steep_32( diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index 34e2083b9..a15b11611 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -38,10 +38,9 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index d97830a5f..10e560433 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "stl.h" diff --git a/lib_com/preemph.c b/lib_com/preemph.c index 490a18aef..9ebc0f72a 100644 --- a/lib_com/preemph.c +++ b/lib_com/preemph.c @@ -36,7 +36,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /*-------------------------------------------------------------* diff --git a/lib_com/prot.h b/lib_com/prot.h deleted file mode 100644 index f5d69075e..000000000 --- a/lib_com/prot.h +++ /dev/null @@ -1,8340 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#ifndef PROT_H -#define PROT_H - -#include -#include -#include -#include "options.h" -#include "typedef.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "stat_com.h" -#include "ivas_stat_com.h" -#include "ivas_stat_enc.h" -#include "ivas_stat_dec.h" -#include "cnst.h" -#include "stl.h" -#include "ivas_error_utils.h" - - -/*----------------------------------------------------------------------------------* - * Prototypes of global macros - *----------------------------------------------------------------------------------*/ - -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef TRUNC -#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) ) -#endif - -#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) -#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) - -#ifndef ABSVAL -#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) -#endif - -#ifndef SQR -#define SQR( a ) ( ( a ) * ( a ) ) -#endif - -#ifndef SWAP -#define SWAP( a, b ) \ - { \ - tempr = ( a ); \ - ( a ) = ( b ); \ - ( b ) = tempr; \ - } -#endif - -#ifndef swap -#define swap( x, y, type ) \ - { \ - type u__p; \ - u__p = x; \ - x = y; \ - y = u__p; \ - } -#endif - -#define set_max( a, b ) \ - { \ - if ( ( b ) > *a ) \ - { \ - *a = ( b ); \ - } \ - } /* If the first argument is already the highes or lowest, nothing is done. */ -#define set_min( a, b ) \ - { \ - if ( ( b ) < *a ) \ - { \ - *a = ( b ); \ - } \ - } /* Otherwise, the 2nd arg is stored at the address of the first arg. */ - - -/*----------------------------------------------------------------------------------* - * MODE1 prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: inverse square root of input value */ -float inv_sqrt( - const float x /* i : input value */ -); - -/*! r: output random value */ -int16_t own_random( - int16_t *seed /* i/o: random seed */ -); - -/*! r: sign of x (+1/-1) */ -float sign( - const float x /* i : input value of x */ -); - -/*! r: logarithm2 of x */ -float log2_f( - const float x /* i : input value of x */ -); - -int16_t norm_ul_float( - uint32_t UL_var1 ); - -/*! r: sum of all vector elements */ -int16_t sum_s( - const int16_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all vector elements */ -int32_t sum_l( - const int32_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all vector elements */ -float sum_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all squared vector elements */ -float sum2_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -void set_c( - int8_t y[], /* i/o: Vector to set */ - const int8_t a, /* i : Value to set the vector to */ - const int32_t N /* i : Length of the vector */ -); - -void set_s( - int16_t y[], /* i/o: Vector to set */ - const int16_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ -); - -void set_l( - int32_t y[], /* i/o: Vector to set */ - const int32_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Length of the vector */ -); - -void set_f( - float y[], /* i/o: Vector to set */ - const float a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ -); - -void set_zero_fx( - Word32 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); -void set_zero2_fx( - Word32 *vec, /* o : input vector */ - const Word32 lvec /* i : length of the vector */ -); -void set16_zero_fx( - Word16 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void set_zero( - float *vec, /* o : input vector */ - const int16_t lvec /* i : length of the vector */ -); - -void mvr2r( - const float x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvs2s( - const int16_t x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -uint32_t mvr2s( - const float x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvs2r( - const int16_t x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvl2l( - const int32_t x[], /* i : input vector */ - int32_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - - -/*! r: index of the maximum value in the input vector */ -int16_t maximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -); -/*! r: index of the maximum value in the input vector */ -int16_t maximumAbs( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -); - -Word16 maximumAbs_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -int16_t minimum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *min_val /* o : minimum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -int16_t minimum_s( - const int16_t *vec, /* i : Input vector */ - const int16_t lvec, /* i : Vector length */ - int16_t *min_val /* o : minimum value in the input vector */ -); - -/*! r: return index with max energy value in vector */ -int16_t emaximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *ener_max /* o : maximum energy value */ -); - -/*! r: vector mean */ -float mean( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: dot product of x[] and y[] */ -float dotp( - const float x[], /* i : vector x[] */ - const float y[], /* i : vector y[] */ - const int16_t n /* i : vector length */ -); - -void conv( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response (or second input vector) */ - float y[], /* o : output vetor (result of convolution) */ - const int16_t L /* i : vector size */ -); - -void fir( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response of the FIR filter */ - float y[], /* o : output vector (result of filtering) */ - float mem[], /* i/o: memory of the input signal (M samples) */ - const int16_t L, /* i : input vector size */ - const int16_t K, /* i : order of the FIR filter (M+1 coefs.) */ - const int16_t upd /* i : 1 = update the memory, 0 = not */ -); - -void v_add( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 + vector 2 */ - const int16_t N /* i : Vector length */ -); - -void v_sub( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 - vector 2 */ - const int16_t N /* i : Vector length */ -); - -void v_mult( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 .* vector 2*/ - const int16_t N /* i : Vector length */ -); - -void v_multc( - const float x[], /* i : Input vector */ - const float c, /* i : Constant */ - float y[], /* o : Output vector that contains c*x */ - const int16_t N /* i : Vector length */ -); - -/*! r: index of the winning codeword */ -int16_t squant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float cb[], /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -); - -int16_t squant_int( - uint8_t x, /* i : scalar value to quantize */ - uint8_t *xq, /* o : quantized value */ - const uint8_t *cb, /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -); - -/*! r: index of the winning codevector */ -int16_t vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize /* i : codebook size */ -); - -/*! r: index of the winning codevector */ -int16_t w_vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - const int16_t weights[], /* i : error weights */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize, /* i : codebook size */ - const int16_t reverse /* i : reverse codebook vectors */ -); - -/*! r: index of the winning codeword */ -int16_t usquant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta, /* i : quantization step */ - const int16_t cbsize /* i : codebook size */ -); - -/*! r: dequanzited gain */ -float usdequant( - const int16_t idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ -); - -void v_sort_float( - float *r, /* i/o: Vector to be sorted in place */ - const int16_t lo, /* i : Low limit of sorting range */ - const int16_t up /* i : High limit of sorting range */ -); - -void sort( - uint16_t *x, /* i/o: Vector to be sorted */ - uint16_t len /* i/o: vector length */ -); - -void sort_l( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 len /* i/o: vector length */ -); - -/*! r: variance of vector */ -float var( - const float *x, /* i : input vector */ - const int16_t len /* i : length of inputvector */ -); - -/*! r: standard deviation */ -float std_dev( - const float *x, /* i : input vector */ - const int16_t len /* i : length of the input vector */ -); - -/*! r: the dot product x'*A*x */ -float dot_product_mat( - const float *x, /* i : vector x */ - const float *A, /* i : matrix A */ - const int16_t m /* i : vector length */ -); - -float root_a( - float a ); - -float root_a_over_b( - float a, - float b ); - -void polezero_filter( - const float *in, /* i : input vector */ - float *out, /* o : output vector */ - const int16_t N, /* i : input vector size */ - const float *b, /* i : numerator coefficients */ - const float *a, /* i : denominator coefficients */ - const int16_t order, /* i : filter order */ - float *mem /* i/o: filter memory */ -); - -double rint_new( - double x /* i/o: Round to the nearest integer with mid point exception */ -); - -double anint( - double x /* i/o: Round to the nearest integer */ -); - -/*! r: Output either 1 if Numeric, 0 if NaN or Inf */ -int16_t is_numeric_float( - float x /* i : Input value which is checked if numeric or not */ -); - -void delay_signal_float( - float x[], /* i/o: signal to be delayed */ - const int16_t len, /* i : length of the input signal */ - float mem[], /* i/o: synchronization memory */ - const int16_t delay /* i : delay in samples */ -); - -ivas_error push_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t id, /* i : ID of the indice */ - uint16_t value, /* i : value of the quantized indice */ - int16_t nb_bits /* i : number of bits used to quantize the indice */ -); - -ivas_error push_next_indice( - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); - -ivas_error push_next_bits( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -/*! r: maximum number of indices */ -int16_t get_BWE_max_num_indices( - const int32_t extl_brate /* i : extensiona layer bitrate */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_metadata_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); -ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ -); - -ivas_error check_ind_list_limits( - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void move_indices( - INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ - INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const int16_t nb_indices /* i : number of moved indices */ -); - -/*! r: index of the indice in the list, -1 if not found */ -int16_t find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const int16_t id, /* i : ID of the indice */ - uint16_t *value, /* o : value of the quantized indice */ - int16_t *nb_bits /* o : number of bits used to quantize the indice */ -); - -/*! r: number of deleted indices */ -uint16_t delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t id /* i : ID of the indice */ -); - -/*! r: value of the indice */ -uint16_t get_next_indice( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ -); - -/*! r: value of the indice */ -uint16_t get_next_indice_1( - Decoder_State *st /* i/o: decoder state structure */ -); - -void get_next_indice_tmp( - Decoder_State *st, /* o : decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ -); - -/*! r: value of the indice */ -uint16_t get_indice( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t pos, /* i : absolute position in the bitstream */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ -); - -/*! r: value of the indice */ -uint16_t get_indice_1( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t pos /* i : absolute position in the bitstream */ -); - -void reset_indices_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t max_num_indices /* i : max number of indices */ -); - -void reset_indices_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -ivas_error write_indices_ivas( - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - uint16_t *bit_stream, /* i/o: output bitstream */ - uint16_t *num_bits /* i/o: number of bits written to output */ -); - -Word16 rate2EVSmode_float( - const Word32 brate, /* i : bitrate */ - int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ -); - - -/*! r: 1 = OK, 0 = something wrong */ -ivas_error read_indices( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t bit_stream[], /* i : bitstream buffer */ - UWord16 num_bits, /* i : number of bits in bitstream */ - int16_t *prev_ft_speech, - int16_t *CNG, - int16_t bfi /* i : bad frame indicator */ -); - - -void ivas_set_bitstream_pointers( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -Decoder_State **reset_elements( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -void convertSerialToBytestream( - const uint16_t *const serial, /* i : input serial bitstream with values 0 and 1 */ - const uint16_t num_bits, /* i : number of bits in the input bitstream */ - uint8_t *const bytestream /* o : output compact bitstream (bytestream) */ -); - -void convertBytestreamToSerial( - const uint8_t *const bytestream, /* i : input compact bitstream (bytestream) */ - const uint16_t num_bits, /* i : number of bits in the input bitstream */ - uint16_t *const serial /* o : output serial bitstream with values 0 and 1 */ -); - -void mdct_switching_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -void evs_dec_previewFrame_float( - uint8_t *bitstream, /* i : bitstream pointer */ - int16_t bitstreamSize, /* i : bitstream size */ - int16_t *partialCopyFrameType, /* o : frame type of the partial copy */ - int16_t *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */ -); - - -void getPartialCopyInfo_float( - Decoder_State *st, /* i : decoder state structure */ - int16_t *sharpFlag ); - -void get_NextCoderType( - uint8_t *bitstream, /* i : bitstream */ - int16_t *next_coder_type /* o : next coder type */ -); - -int16_t print_disclaimer( - FILE *fPtr ); - - -/*! r: delay value in ns */ -int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ -); - -void decision_matrix_enc( - Encoder_State *st, /* i/o: encoder state structure */ - int16_t *hq_core_type /* o : HQ core type */ -); - -void signaling_enc( - Encoder_State *st /* i : encoder state structure */ -); - -int16_t signaling_mode1_tcx20_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t push /* i : flag to push indice */ -); - -void decision_matrix_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *sharpFlag, /* o : formant sharpening flag */ - int16_t *hq_core_type, /* o : HQ core type */ - int16_t *core_switching_flag /* o : ACELP->HQ switching frame flag */ -); - - -void amr_wb_dec_init( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_init( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_reset( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_amr_wb( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t output_frame, /* i : output frame length */ - const float *Aq, /* i : quantized Az */ - const float *exc, /* i : excitation at 12.8 kHz */ - float *synth, /* i/o: synthesis signal at 12.8 kHz */ - int16_t *amr_io_class, /* i : signal class (determined by FEC algorithm) */ - float *synth_out, /* i/o: synthesis signal at output Fs */ - float fmerit, /* i : classify parameter from FEC */ - const int16_t *hf_gain, /* i : decoded HF gain */ - const float *voice_factors, /* i : voicing factors */ - const float pitch_buf[], /* i : pitch buffer */ - const float ng_ener_ST, /* i : Noise gate - short-term energy */ - const float *lsf_new /* i : ISF vector */ -); - -void hf_cod_init( - float *mem_hp400_enc, /* o : memory of hp 400 Hz filter */ - float *mem_hf1_enc, /* o : HF band-pass filter memory */ - float *mem_syn_hf_enc, /* o : HF synthesis memory */ - float *mem_hf2_enc, /* o : HF band-pass filter memory */ - float *gain_alpha /* o : smoothing gain for transitions between active and inactive frames */ -); - -void hf_cod( - const int32_t core_brate, /* i : core bitrate */ - const float *speech16k, /* i : original speech at 16 kHz */ - const float Aq[], /* i : quantized Aq */ - const float exc[], /* i : excitation at 12.8 kHz */ - float synth[], /* i : 12.8kHz synthesis signal */ - int16_t *seed2_enc, /* i/o: random seed for HF noise gen */ - float *mem_hp400_enc, /* i/o: memory of hp 400 Hz filter */ - float *mem_syn_hf_enc, /* i/o: HF synthesis memory */ - float *mem_hf1_enc, /* i/o: HF band-pass filter memory */ - float *mem_hf2_enc, /* i/o: HF band-pass filter memory */ - const int16_t *dtxHangoverCount, - float *gain_alpha, /* i/o: smoothing gain for transitions between active and inactive frames */ - int16_t *hf_gain /* o : HF gain to be transmitted to decoder */ -); - -void hf_synth_init( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_reset( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t output_frame, /* i : output frame length */ - const float *Aq, /* i : quantized Az */ - const float *exc, /* i : excitation at 12.8 kHz */ - float *synth, /* i/o: 12.8kHz synthesis signal */ - float *synth16k /* i/o: 16kHz synthesis signal */ -); - -void fft_rel( - float x[], /* i/o: input/output vector */ - const int16_t n, /* i : vector length */ - const int16_t m /* i : log2 of vector length */ -); - -void ifft_rel( - float io[], /* i/o: input/output vector */ - const int16_t n, /* i : vector length */ - const int16_t m /* i : log2 of vector length */ -); - -void preemph( - float *signal, /* i/o: signal */ - const float mu, /* i : preemphasis factor */ - const int16_t L, /* i : vector size */ - float *mem /* i/o: memory (x[-1]) */ -); -void preemph_ivas_fx( - Word32 *signal, /* i/o: signal Qx*/ - const Word16 mu, /* i : preemphasis factor Q15*/ - const Word16 L, /* i : vector size Q0*/ - Word32 *mem /* i/o: memory (x[-1]) Qx*/ -); - -void cb_shape( - const int16_t preemphFlag, /* i : flag for pre-emphasis */ - const int16_t pitchFlag, /* i : flag for pitch sharpening */ - const int16_t scramblingFlag, /* i : flag for phase scrambling */ - const int16_t formantFlag, /* i : flag for formant sharpening */ - const int16_t formantTiltFlag, /* i : flag for formant tilt */ - const float g1, /* i : formant sharpening numerator weighting */ - const float g2, /* i : formant sharpening denominator weighting */ - const float *p_Aq, /* i : LP filter coefficients */ - float *code, /* i/o: signal to shape */ - const float tilt_code, /* i : tilt of code */ - const float pt_pitch, /* i : pointer to current subframe fractional pitch*/ - const int16_t L_subfr /* i : subfframe length */ -); - -void CNG_exc( - const int32_t core_brate, /* i : core bitrate */ - const int16_t L_frame, /* i : length of the frame */ - float *Enew, /* i/o: decoded SID energy */ - int16_t *seed, /* i/o: random generator seed */ - float exc[], /* o : current non-enhanced excitation */ - float exc2[], /* o : current enhanced excitation */ - float *lp_ener, /* i/o: LP filtered E */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - int16_t *first_CNG, /* i/o: first CNG frame flag for energy init. */ - int16_t *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - float bwe_exc[], /* o : excitation for SWB TBE */ - const int16_t allow_cn_step, /* i : allow CN step */ - int16_t *last_allow_cn_step, /* i/o: last CN_step */ - const int16_t num_ho, /* i : number of selected hangover frames */ - float q_env[], - float *lp_env, - float *old_env, - float *exc_mem, - float *exc_mem1, - int16_t *sid_bw, - int16_t *cng_ener_seed1, - float exc3[], - const int16_t Opt_AMR_WB, /* i : AMR-WB interop flag */ - const int16_t element_mode /* i : IVAS Element mode */ -); - - -void cng_params_postupd( - const int16_t ho_circ_ptr, /* i : pointer for CNG averaging buffers */ - int16_t *cng_buf_cnt, /* i/o: counter for CNG store buffers */ - const float *cng_exc2_buf, /* i : Excitation buffer */ - const int32_t *cng_brate_buf, /* i : bitrate buffer */ - float ho_env_circ[], /* i/o: Envelope buffer */ - const int16_t element_mode, /* i : Element mode */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void calculate_hangover_attenuation_gain( - Encoder_State *st, /* i : encoder state structure */ - float *att, /* o : attenuation factor */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -int16_t get_cng_mode_ivas( - const int32_t last_active_brate /* i : last active bitrate */ -); - -void disf_ns_28b( - int16_t *indice, /* i : quantized indices, use indice[0] = -1 in the decoder*/ - float *isf_q /* o : ISF in the frequency domain (0..6400) */ -); - -void limit_T0( - const int16_t L_frame, /* i : length of the frame */ - const int16_t delta, /* i : Half the close-loop searched interval */ - const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const int16_t limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_max /* o : higher pitch limit */ -); - -/*! r: interpolated value */ -float interpolation( - const float *x, /* i : input vector */ - const float *win, /* i : interpolation window */ - const int16_t frac, /* i : fraction */ - const int16_t up_samp, /* i : upsampling factor */ - const int16_t nb_coef /* i : nb of filter coef */ -); - -void deemph( - float *signal, /* i/o: signal */ - const float mu, /* i : deemphasis factor */ - const int16_t L, /* i : vector size */ - float *mem /* i/o: memory (y[-1]) */ -); - -void weight_a( - const float *a, /* i : LP filter coefficients */ - float *ap, /* o : weighted LP filter coefficients */ - const float gamma, /* i : weighting factor */ - const int16_t m /* i : order of LP filter */ -); - -void weight_a_subfr( - const int16_t nb_subfr, /* i : number of subframes */ - const float *a, /* i : LP filter coefficients */ - float *ap, /* o : weighted LP filter coefficients */ - const float gamma, /* i : weighting factor */ - const int16_t m /* i : order of LP filter */ -); - -void syn_12k8( - const int16_t L_frame, /* i : length of the frame */ - const float *Aq, /* i : LP filter coefficients */ - const float *exc, /* i : input signal */ - float *synth, /* o : output signal */ - float *mem, /* i/o: initial filter states */ - const int16_t update_m /* i : update memory flag: 0 --> no memory update */ -); /* 1 --> update of memory */ - -void syn_filt( - const float a[], /* i : LP filter coefficients */ - const int16_t m, /* i : order of LP filter */ - const float x[], /* i : input signal */ - float y[], /* o : output signal */ - const int16_t l, /* i : size of filtering */ - float mem[], /* i/o: initial filter states */ - const int16_t update_m /* i : update memory flag: 0 --> no memory update */ -); /* 1 --> update of memory */ - -void synth_mem_updt2_flt( - const int16_t L_frame, /* i : frame length */ - const int16_t last_L_frame, /* i : frame length */ - float old_exc[], /* i/o: excitation buffer */ - float mem_syn_r[], /* i/o: synthesis filter memory */ - float mem_syn2[], /* o : synthesis filter memory for find_target */ - float mem_syn[], /* o : synthesis filter memory for find_target */ - const int16_t dec /* i : flag for decoder indication */ -); - -void int_lsp( - const int16_t L_frame, /* i : length of the frame */ - const float lsp_old[], /* i : LSPs from past frame */ - const float lsp_new[], /* i : LSPs from present frame */ - float *Aq, /* o : LP coefficients in both subframes */ - const int16_t m, /* i : order of LP filter */ - const float *int_coeffs, /* i : interpolation coefficients */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - -void int_lsp4( - const int16_t L_frame, /* i : length of the frame */ - const float lsp_old[], /* i : previous end-frame LSPs */ - const float lsp_mid[], /* i : current mid-frame LSPs */ - const float lsp_new[], /* i : current end-frame LSPs */ - float *Aq, /* o : LP coefficients in both subframes */ - const int16_t m, /* i : order of LP filter */ - int16_t relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ -); - -/*! r: length of output */ -int16_t modify_Fs( - const float sigIn[], /* i : signal to decimate */ - const int16_t lg, /* i : length of input */ - const int32_t fin, /* i : frequency of input */ - float sigOut[], /* o : decimated signal */ - const int32_t fout, /* i : frequency of output */ - float mem[], /* i/o: filter memory */ - const int16_t nblp /* i : flag indicating if NB low-pass is applied */ -); - -void pred_lt4_flt( - const float excI[], /* i : input excitation buffer */ - float excO[], /* o : output excitation buffer */ - const int16_t T0, /* i : integer pitch lag */ - int16_t frac, /* i : fraction of lag */ - const int16_t L_subfr, /* i : subframe size */ - const float *win, /* i : interpolation window */ - const int16_t nb_coef, /* i : nb of filter coef */ - const int16_t up_sample /* i : up_sample */ -); - -void pred_lt4_tc_flt( - float exc[], /* i : excitation buffer */ - const int16_t T0, /* i : integer pitch lag */ - int16_t frac, /* i : fraction of lag */ - const float *win, /* i : interpolation window */ - const int16_t imp_pos, /* i : glottal impulse position */ - const int16_t i_subfr /* i : subframe index */ -); - -void residu( - const float *a, /* i : LP filter coefficients */ - const int16_t m, /* i : order of LP filter */ - const float *x, /* i : input signal (usually speech) */ - float *y, /* o : output signal (usually residual) */ - const int16_t l /* i : size of filtering */ -); - -void calc_residu( - const float *speech, /* i : weighted speech signal */ - float *res, /* o : residual signal */ - const float *p_Aq, /* i : quantized LP filter coefficients */ - const int16_t L_frame /* i : size of frame */ -); - -/*! r: impulse response energy */ -float enr_1_Az( - const float Aq[], /* i : LP filter coefs */ - const int16_t len /* i : impulse response length */ -); - -void Es_pred_enc( - float *Es_pred, /* o : predicited scaled innovation energy */ - int16_t *Es_pred_indice, /* o : indice corresponding to above parameter */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_subfr, /* i : length of the subframe */ - const float *res, /* i : residual signal */ - const float *voicing, /* i : normal. correlattion in three 1/2frames */ - const int16_t nb_bits, /* i : allocated number of bits */ - const int16_t no_ltp /* i : no_ltp flag */ -); - -void create_offset( - UWord32 *offset_scale1, - UWord32 *offset_scale2, - const int16_t mode, - const int16_t prediction_flag ); - -float mslvq( - float *pTmp, /* i : M-dimensional input vector */ - float *quant, /* o : quantized vector */ - float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - int16_t *idx_lead, /* o : leader index for each 8-dim subvector */ - int16_t *idx_scale, /* o : scale index for each subvector */ - const float *w, /* i : weights for LSF quantization */ - const int16_t mode, /* i : number indicating the coding mode */ - const int16_t mode_glb, /* i : LVQ coding mode */ - const int16_t pred_flag /* i : prediction flag (0: safety net, 1 - predictive )*/ -); - -void permute( - float *pTmp1, /* i/o: vector whose components are to be permuted */ - const int16_t *perm /* i : permutation info (indexes that should be interchanged), max two perms */ -); - -void sort_desc_ind( - float *s, - const int16_t len, - int16_t *ind ); - -float mslvq_cng( - int16_t idx_cv, /* i : index of cv from previous stage */ - float *pTmp, /* i : 16 dimensional input vector */ - float *quant, /* o : quantized vector */ - float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - int16_t *idx_lead, /* o : leader index for each 8-dim subvector */ - int16_t *idx_scale, /* o : scale index for each subvector */ - const float *w /* i : weights for LSF quantization */ -); - -int16_t deindex_lvq_cng( - int16_t *index, /* i : index to be decoded, as an array of 3 short */ - float *x_lvq, /* o : decoded codevector */ - const int16_t idx_cv, /* i : relative mode_lvq, wrt START_CNG */ - const int16_t no_bits /* i : number of bits for lattice */ -); - -void multiply32_32_64( - UWord32 x, /* i : operand 1 */ - UWord32 y, /* i : operand 2 */ - UWord32 *res /* o : result as array of two uint32 */ -); - -int16_t deindex_lvq( - int16_t *index, /* i : index to be decoded, as an array of 3 short */ - float *x_lvq, /* o : decoded codevector */ - const int16_t mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ - const int16_t sf_flag, /* i : safety net flag */ - const int16_t no_bits /* i : number of bits for lattice */ -); - -void index_lvq( - float *quant, /* i : codevector to be indexed (2 8-dim subvectors) */ - int16_t *idx_lead, /* i : leader class index for each subvector */ - int16_t *idx_scale, /* i : scale index for each subvector */ - const int16_t mode, /* i : integer signaling the quantizer structure for the current bitrate */ - int16_t *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - const int16_t prediction_flag /* i : predictive mode or not */ -); - -int16_t qlsf_ARSN_tcvq_Dec_16k( - float *y, /* o : Quantized LSF vector */ - int16_t *indice, /* i : Indices */ - const int16_t nBits /* i : number of bits */ -); - - -int16_t lsf_bctcvq_decprm_ivas( - Decoder_State *st, - int16_t *param_lpc ); - - -void disf_2s_36b( - int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - float *isf_q, /* o : quantized ISFs in the cosine domain */ - float *mem_AR, /* i/o: quantizer memory for AR model */ - float *mem_MA /* i/o: quantizer memory for MA model */ -); - -void disf_2s_46b( - int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - float *isf_q, /* o : quantized ISFs in the cosine domain */ - float *mem_AR, /* o : quantizer memory for AR model */ - float *mem_MA /* i/o: quantizer memory for MA model */ -); - -void re8_k2y( - const int16_t *k, /* i : Voronoi index k[0..7] */ - const int16_t m, /* i : Voronoi modulo (m = 2^r = 1<=2) */ - int16_t *y /* o : 8-dimensional point y[0..7] in RE8 */ -); - -void re8_PPV( - const float x[], /* i : point in R^8 */ - int16_t y[] /* o : point in RE8 (8-dimensional integer vector) */ -); - -void enhancer( - const int16_t codec_mode, /* i : flag indicating Codec Mode */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t cbk_index, /* i : */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t coder_type, /* i : coding type */ - const int16_t L_frame, /* i : frame size */ - const float voice_fac, /* i : subframe voicing estimation */ - const float stab_fac, /* i : LP filter stablility measure */ - const float norm_gain_code, /* i : normalized innovative cb. gain */ - const float gain_inov, /* i : gain of the unscaled innovation */ - float *gc_threshold, /* i/o: code threshold */ - float *code, /* i/o: innovation */ - float *exc2, /* i/o: adapt. excitation/total exc. */ - const float gain_pit, /* i : Quantized pitch gain */ - float *dispMem /* i/o: Phase dispersion algorithm memory */ -); - -void phase_dispersion_flt( - const float gain_code, /* i : gain of code */ - const float gain_pit, /* i : gain of pitch */ - float code[], /* i/o: code vector */ - const int16_t mode, /* i : level, 0=hi, 1=lo, 2=off */ - float disp_mem[] /* i/o: static memory (size = 8) */ -); - -void re8_vor( - int16_t y[], /* i : point in RE8 (8-dimensional integer vector) */ - int16_t *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */ - int16_t k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 */ - int16_t c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */ - int16_t *ka /* o : identifier of absolute leader (needed to index c)*/ -); - -void DoRTFT480( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT320( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT160( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT128( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT120( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT80( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT20( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT40( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFTn( - float *x, /* i/o: real part of input and output data */ - float *y, /* i/o: imaginary part of input and output data */ - const int16_t n /* i : size of the FFT n=(2^k) up to 1024 */ -); - -void BASOP_cfft_ivas( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - Word16 s, /* i : stride real and imag part */ - Word16 *scale /* i : scalefactor */ -); - -void fft( - float *re, /* i/o: real part */ - float *im, /* i/o: imag part */ - const int16_t length, /* i : length of fft */ - const int16_t s /* i : sign */ -); - -void rfft( - float *x, /* i/o: values */ - const float *w, /* i : window */ - const int16_t length, /* i : length of fft */ - const int16_t isign /* i : sign */ -); - -void sinq( - const float tmp, /* i : sinus factor cos(tmp*i+phi) */ - const float phi, /* i : sinus phase cos(tmp*i+phi) */ - const int16_t N, /* i : size of output */ - float x[] /* o : output vector */ -); - -void edct2( - const int16_t n, - const int16_t isgn, - float *in, - float *a, - const int16_t *ip, - const float *w ); - -void stat_noise_uv_mod( - const int16_t coder_type, /* i : coder type */ - float noisiness, /* i : noisiness parameter */ - const float *const lsp_old, /* i : old LSP vector at 4th sfr */ - const float *const lsp_new, /* i : LSP vector at 4th sfr */ - const float *const lsp_mid, /* i : LSP vector at 2nd sfr */ - float *Aq, /* o : A(z) quantized for the 4 subframes */ - float *exc2, /* o : excitation buffer */ - const int16_t bfi, /* i : bad frame indicator */ - float *ge_sm, /* i/o: smoothed excitation gain */ - int16_t *uv_count, /* i/o: unvoiced counter */ - int16_t *act_count, /* i/o: activation counter */ - float lspold_s[], /* i/o: old LSP */ - int16_t *noimix_seed, /* i/o: mixture seed */ - float *st_min_alpha, /* i/o: minimum alpha */ - float *exc_pe, /* i/o: memory of the preemphasis filter */ - const int32_t bitrate, /* i : core bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void limit_band_noise_level_calc( - const int16_t *wnorm, /* i : reordered norm of sub-vectors */ - int16_t *limit, /* o : highest band of bit allocation */ - const int32_t core_brate, /* i : core bitrate */ - float *noise_level /* o : noise level */ -); - -/*! r: hqswb_clas */ -int16_t peak_avrg_ratio( - const int32_t total_brate, /* i : total bitrate */ - const float *input_hi, /* i : input signal */ - const int16_t N, /* i : number of coefficients */ - int16_t *mode_count, /* i/o: HQ_HARMONIC mode count */ - int16_t *mode_count1 /* i/o: HQ_NORMAL mode count */ -); - -/*! r: Number of coefficients in nf codebook */ -int16_t build_nf_codebook( - const int16_t flag_32K_env_ho, /* i : Envelope attenuation hangover flag */ - const float *coeff, /* i : Coded spectral coefficients */ - const int16_t *sfm_start, /* i : Subband start indices */ - const int16_t *sfmsize, /* i : Subband widths */ - const int16_t *sfm_end, /* i : Subband end indices */ - const int16_t nb_sfm, /* i : Last coded band */ - const int16_t *R, /* i : Per-band bit allocation */ - float *CodeBook, /* o : Noise-fill codebook */ - float *CodeBook_mod /* o : Densified noise-fill codebook */ -); - -void apply_noisefill_HQ( - const int16_t *R, /* i : bit allocation */ - const int16_t length, /* i : input frame length */ - const int16_t flag_32K_env_ho, /* i : envelope stability hangover flag */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t last_sfm, /* i : last coded subband */ - const float *CodeBook, /* i : Noise-fill codebook */ - const float *CodeBook_mod, /* i : Densified noise-fill codebook */ - const int16_t cb_size, /* i : Codebook length */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfmsize, /* i : Subband band width */ - float *coeff /* i/o: coded/noisefilled spectrum */ -); - -void harm_bwe_fine( - const int16_t *R, /* i : bit allocation */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t high_sfm, /* i : higher transition band to BWE */ - const int16_t num_sfm, /* i : total number of bands */ - const int16_t *norm, /* i : quantization indices for norms */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - float *coeff, /* i/o: coded/noisefilled normalized spectrum */ - float *coeff_out, /* o : coded/noisefilled spectrum */ - float *coeff_fine /* o : BWE fine structure */ -); - -void hvq_bwe_fine( - const int16_t last_sfm, /* i : last coded subband */ - const int16_t num_sfm, /* i : total number of bands */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *peak_idx, /* i : Peak index */ - const int16_t Npeaks, /* i : Number of peaks */ - int16_t *peak_pos, /* i/o: Peak positions */ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - float *coeff, /* i/o: coded/noisefilled normalized spectrum */ - int16_t *bwe_peaks, /* o : Positions of peaks in BWE */ - float *coeff_fine /* o : HVQ BWE fine structure */ -); - -void hq_fold_bwe( - const int16_t last_sfm, /* i : last coded subband */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t num_sfm, /* i : Number of subbands */ - float *coeff /* i/o: coded/noisefilled normalized spectrum */ -); - -void apply_nf_gain( - const int16_t nf_idx, /* i : noise fill gain index */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t *R, /* i : bit allocation */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - float *coeff /* i/o: coded/noisefilled normalized spectrum */ - -); - -void hq_generic_fine( - float *coeff, /* i : coded/noisefilled normalized spectrum */ - const int16_t last_sfm, /* i : Last coded band */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *coeff_out1 /* o : HQ GENERIC input */ -); - -void harm_bwe( - const float *coeff_fine, /* i : fine structure for BWE */ - const float *coeff, /* i : coded/noisefilled normalized spectrum */ - const int16_t num_sfm, /* i : Number of subbands */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t high_sfm, /* i : higher transition band to BWE */ - const int16_t *R, /* i : bit allocation */ - const int16_t prev_hq_mode, /* i : previous hq mode */ - int16_t *norm, /* i/o: quantization indices for norms */ - float *noise_level, /* i/o: noise levels for harmonic modes */ - float *prev_noise_level, /* i/o: noise factor in previous frame */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *coeff_out, /* o : coded/noisefilled spectrum */ - const int16_t element_mode /* i : element mode */ -); - -void hvq_bwe( - const float *coeff, /* i : coded/noisefilled spectrum */ - const float *coeff_fine, /* i : BWE fine structure */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfm_len, /* i : Subband length */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t prev_hq_mode, /* i : previous hq mode */ - const int16_t *bwe_peaks, /* i : HVQ bwe peaks */ - const int16_t bin_th, /* i : HVQ transition bin */ - const int16_t num_sfm, /* i : Number of bands */ - const int32_t core_brate, /* i : Core bitrate */ - const int16_t *R, /* i : Bit allocation */ - int16_t *norm, /* i/o: quantization indices for norms */ - float *noise_level, /* i/o: noise levels for harmonic modes */ - float *prev_noise_level, /* i/o: noise factor in previous frame */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *coeff_out /* o : coded/noisefilled spectrum */ -); - -void hvq_concat_bands( - const int16_t pvq_bands, /* i : Number of bands in concatenated PVQ target */ - const int16_t *sel_bnds, /* i : Array of selected high bands */ - const int16_t n_sel_bnds, /* i : Number of selected high bands */ - int16_t *hvq_band_start, /* o : Band start indices */ - int16_t *hvq_band_width, /* o : Band widths */ - int16_t *hvq_band_end /* o : Band end indices */ -); - -void hq_generic_bwe( - const int16_t HQ_mode, /* i : HQ mode */ - float *coeff_out1, /* i/o: BWE input & temporary buffer */ - const float *hq_generic_fenv, /* i : SWB frequency envelopes */ - float *coeff_out, /* o : SWB signal in MDCT domain */ - const int16_t hq_generic_offset, /* i : frequency offset for representing hq generic*/ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - const int16_t hq_generic_exc_clas, /* i : hq generic hf excitation class */ - const int16_t *sfm_end, /* i : End of bands */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t num_env_bands, /* i : Number of coded envelope bands */ - const int16_t *R /* i : Bit allocation */ -); - -void map_hq_generic_fenv_norm( - const int16_t hqswb_clas, /* i : signal classification flag */ - const float *hq_generic_fenv, /* i : HQ GENERIC envelope */ - int16_t *ynrm, /* o : high band norm indices */ - int16_t *normqlg2, /* o : high band norm values */ - const int16_t num_env_bands, /* i : Number coded envelope bands */ - const int16_t nb_sfm, /* i : Number of envelope bands */ - const int16_t hq_generic_offset /* i : Freq offset for HQ GENERIC */ -); - -/*! r: Number of bits consumed for the delta coding */ -int16_t calc_nor_delta_hf( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const float *t_audio, /* i : transform-domain coefficients */ - int16_t *ynrm, /* i/o: norm indices */ - int16_t *Rsubband, /* i/o: sub-band bit allocation */ - const int16_t num_env_bands, /* i : Number coded envelope bands */ - const int16_t nb_sfm, /* i : Number of envelope bands */ - const int16_t *sfmsize, /* i : band length */ - const int16_t *sfm_start, /* i : Start index of bands */ - const int16_t core_sfm /* i : index of the end band for core */ -); - -/*! r: Number of bits consumed for the delta coding */ -int16_t get_nor_delta_hf( - Decoder_State *st, /* i/o: Decoder state */ - int16_t *ynrm, /* i/o: norm indices */ - int16_t *Rsubband, /* i/o: sub-band bit allocation */ - const int16_t num_env_bands, /* i : Number coded envelope bands */ - const int16_t nb_sfm, /* i : Number of envelope bands */ - const int16_t core_sfm ); /* i : index of the end band for core */ - -void hq_wb_nf_bwe( - const float *coeff, /* i : coded/noisefilled normal. spectrum */ - const int16_t is_transient, /* i : is transient flag */ - const int16_t prev_bfi, /* i : previous bad frame indicator */ - const float *normq_v, /* i : norms */ - const int16_t num_sfm, /* i : Number of subbands */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfmsize, /* i : Subband band width */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t *R, /* i : bit allocation */ - const int16_t prev_is_transient, /* i : previous transient flag */ - float *prev_normq, /* i/o: previous norms */ - float *prev_env, /* i/o: previous noise envelopes */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */ - int16_t *prev_R, /* i/o: previous frame bit allocation info. */ - float *coeff_out /* o : coded/noisefilled spectrum */ -); - -/*! r: Number of bits */ -int16_t encode_envelope_indices( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t num_sfm, /* i : Number of subbands */ - const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */ - int16_t *difidx, /* i/o: Diff indices/encoded diff indices */ - int16_t *LCmode, /* o : Coding mode */ - const int16_t flag_pack, /* i : indicator of packing or estimating bits */ - const int16_t flag_HQ2, /* i : indicator of HQ2 core */ - const int16_t is_transient /* i : transient flag */ -); - -void diff_envelope_coding( - const int16_t is_transient, /* i : transient indicator */ - const int16_t num_env_bands, /* i : number of envelope bands to code */ - const int16_t start_norm, /* i : start of envelope coding */ - int16_t *ynrm, /* i/o: quantization indices for norms */ - int16_t *normqlg2, /* i/o: quantized norms */ - int16_t *difidx /* o : differential code */ -); - -/*! r: Number of bits */ -int16_t decode_envelope_indices( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t start_norm, /* i : First SDE encoded norm */ - const int16_t num_sfm, /* i : Number of norms */ - const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */ - int16_t *ynrm, /* o : Decoded norm indices */ - const int16_t flag_HQ2, /* i : indicator of HQ2 core */ - const int16_t is_transient /* i : transient flag */ -); - -/*! r: Number of bits */ -void dequantize_norms( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t start_norm, /* i : First SDE encoded norm */ - const int16_t num_sfm, /* i : Number of norms */ - const int16_t is_transient, /* i : Transient flag */ - int16_t *ynrm, /* o : Decoded norm indices */ - int16_t *normqlg2 /* o : Log2 of decoded norms */ -); - -void hq_configure( - const int16_t length, /* i : Frame length */ - const int16_t hqswb_clas, /* i : HQ SWB class */ - const int32_t core_brate, /* i : core bitrate */ - int16_t *num_sfm, /* o : Total number of subbands */ - int16_t *nb_sfm, /* o : Total number of coded bands */ - int16_t *start_norm, /* o : First norm to be SDE encoded */ - int16_t *num_sde_norm, /* o : Number of norms for SDE encoding */ - int16_t *numnrmibits, /* o : Number of bits in fall-back norm encoding */ - int16_t *hq_generic_offset, /* o : Freq offset for HQ GENERIC */ - int16_t *sfmsize, /* o : Subband bandwidths */ - int16_t *sfm_start, /* o : Subband start coefficients */ - int16_t *sfm_end /* o : Subband end coefficients */ -); - -/*! r: Consumed bits */ -int16_t hvq_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t hvq_bits, /* i : HVQ bit budget */ - const int16_t Npeaks, /* i : Number of peaks */ - const int16_t *ynrm, /* i : Envelope coefficients */ - int16_t *R, /* i/o: Bit allocation/updated bit allocation */ - int16_t *peaks, /* i/o: Peak pos. / Encoded peak pos. */ - float *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - float *noise_level, /* o : Quantized noise level */ - const float *pe_gains, /* i : Peak gains */ - const float *coefs, /* i : spectrum coefficients */ - float *coefs_out /* o : encoded spectrum coefficients */ -); -/*! r: Consumed bits */ -int16_t hq_classifier_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : Core bitrate */ - const int16_t length, /* i : Frame length */ - int16_t *is_transient, /* o : Transient flag */ - int16_t *hqswb_clas /* o : HQ class */ -); - -void hq_bit_allocation( - const int32_t core_brate, /* i : Core bitrate */ - const int16_t length, /* i : Frame length */ - const int16_t hqswb_clas, /* i : HQ class */ - int16_t *num_bits, /* i/o: Remaining bit budget */ - const int16_t *normqlg2, /* i : Quantized norms */ - const int16_t nb_sfm, /* i : Number sub bands to be encoded */ - const int16_t *sfmsize, /* i : Sub band bandwidths */ - float *noise_level, /* o : HVQ noise level */ - int16_t *R, /* o : Bit allocation per sub band */ - int16_t *Rsubband, /* o : Fractional bit allocation (Q3) */ - int16_t *sum, /* o : Sum of allocated shape bits */ - int16_t *core_sfm, /* o : Last coded band in core */ - const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ -); - -void enforce_zero_for_min_envelope( - const int16_t hqswb_clas, /* i : HQ coding class */ - const int16_t *ynrm, /* i : Envelope indices */ - float *coefsq, /* i/o: Quantized spectrum/zeroed spectrum */ - int16_t nb_sfm, /* i : Number of coded sub bands */ - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end /* i : Sub band end indices */ -); - -void apply_envelope( - const float *coeff, /* i/o: Coded/noisefilled normalized spectrum */ - const int16_t *norm, /* i : Envelope */ - const float *norm_adj, /* i : Envelope adjustment */ - const int16_t num_sfm, /* i : Total number of bands */ - const int16_t last_sfm, /* i : Last coded band */ - const int16_t HQ_mode, /* i : HQ mode */ - const int16_t length, /* i : Frame length */ - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end, /* i : Sub band end indices */ - float *normq_v, /* o : Envelope with adjustment */ - float *coeff_out, /* o : coded/noisefilled spectrum */ - float *coeff_out1 /* o : noisefilled spectrum for HQ SWB BWE */ -); - -void apply_envelope_enc( - float *coeff, /* i/o: Normalized/scaled normalized spectrum */ - const int16_t *norm, /* i : Envelope */ - const int16_t num_sfm, /* i : Total number of bands */ - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end /* i : Sub band end indices */ -); - -/*! r: Leading_sign_index, index, size, k_val */ -PvqEntry mpvq_encode_vec( - const int16_t *vec_in, /* i : Signed pulse train */ - const int16_t dim_in, /* i : Dimension */ - int16_t k_val_local /* i/o: Num unit pulses */ -); - -/*! r: Size, dim, k_val */ -PvqEntry get_size_mpvq_calc_offset( - const int16_t dim_in, /* i : Dimension */ - const int16_t k_val_in, /* i : Num unit pulses */ - uint32_t *h_mem /* o : Offsets */ -); - -void mpvq_decode_vec( - const PvqEntry *entry, /* i : Sign_ind, index, dim, k_val */ - uint32_t *h_mem, /* i : A/U offsets */ - int16_t *vec_out /* o : Pulse train */ -); - -/*! r: Multiplication result */ -uint32_t UMult_32_32( - const uint32_t UL_var1, /* i : factor 1 */ - const uint32_t UL_var2 /* i : factor 2 */ -); - -/*! r: inverse */ -uint32_t UL_inverse_float( - const uint32_t UL_val, /* i : input value Q_exp */ - int16_t *exp /* i/o: input exp / result exp */ -); - -/*! r: ratio */ -Word16 ratio_float( - const Word32 numer, /* i : numerator */ - const Word32 denom, /* i : denominator */ - Word16 *expo /* i/o: input exp / result exp */ -); - -/*! r: Angle between 0 and EVS_PI/2 radian (Q14) */ -Word16 atan2_fx_flt( - const Word32 y, /* i : near side (Argument must be positive) (Q15) */ - const Word32 x /* i : opposite side (Q15) */ -); - -void pvq_encode_frame( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const float *coefs_norm, /* i : normalized coefficients to encode */ - float *coefs_quant, /* o : quantized coefficients */ - float *gopt, /* o : optimal shape gains */ - int16_t *npulses, /* o : number of pulses per band */ - int16_t *pulse_vector, /* o : non-normalized pulse shapes */ - const int16_t *sfm_start, /* i : indices of first coefficients in the bands */ - const int16_t *sfm_end, /* i : indices of last coefficients in the bands */ - const int16_t *sfmsize, /* i : band sizes */ - const int16_t nb_sfm, /* i : total number of bands */ - const int16_t *R, /* i : bitallocation per band (Q3) */ - const int16_t pvq_bits, /* i : number of bits avaiable */ - const int16_t core /* i : core */ -); - -void pvq_decode_frame( - Decoder_State *st, /* i/o: Decoder state */ - float *coefs_quant, /* o : quantized coefficients */ - int16_t *npulses, /* o : number of pulses per band */ - int16_t *pulse_vector, /* o : non-normalized pulse shapes */ - const int16_t *sfm_start, /* i : indices of first coeffs in the bands */ - const int16_t *sfm_end, /* i : indices of last coeffs in the bands */ - const int16_t *sfmsize, /* i : band sizes */ - const int16_t nb_sfm, /* i : total number of bands */ - const int16_t *R, /* i : bitallocation per band (Q3) */ - const int16_t pvq_bits, /* i : number of bits avaiable */ - const int16_t core /* i : core */ -); - -void srt_vec_ind( - const int16_t *linear, /* linear input */ - int16_t *srt, /* sorted output */ - int16_t *I, /* index for sorted output */ - const int16_t length ); - -void srt_vec_ind_f( - const float *linear, /* linear input */ - float *srt, /* sorted output */ - int16_t *I, /* index for sorted output */ - const int16_t length /* length of vector */ -); - -/*! r: floor(sqrt(input)) */ -uint32_t floor_sqrt_exact( - const uint32_t input /* i : unsigned input [0.. UINT_MAX/4] */ -); - -void fine_gain_quant( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t *ord, /* i : Indices for energy order */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */ - float *fg_pred, /* i/o: Predicted gains / Corrected gains */ - const float *gopt /* i : Optimal gains */ -); - -void apply_gain( - const int16_t *ord, /* i : Indices for energy order */ - const int16_t *band_start, /* i : Sub band start indices */ - const int16_t *band_end, /* i : Sub band end indices */ - const int16_t num_sfm, /* i : Number of bands */ - const float *gains, /* i : Band gain vector */ - float *xq /* i/o: float synthesis / gain adjusted synth */ -); - -void fine_gain_pred( - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end, /* i : Sub band end indices */ - const int16_t *sfm_size, /* i : Sub band bandwidths */ - const int16_t *i_sort, /* i : Energy sorting indices */ - const int16_t *K, /* i : Number of pulses per band */ - const int16_t *maxpulse, /* i : Maximum pulse per band */ - const int16_t *R, /* i : Bits per sub band (Q3) */ - const int16_t num_sfm, /* i : Number of sub bands */ - float *xq, /* i/o: Quantized vector /quantized vector with finegain adj */ - int16_t *y, /* i/o: Quantized vector */ - float *fg_pred, /* o : Predicted fine gains */ - const int16_t core /* i : Core */ -); - -void fine_gain_dec( - Decoder_State *st, /* i/o: Decoder state struct */ - const int16_t *ord, /* i : Indices for energy order */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */ - float *fg_pred /* i/o: Predicted gains / Corrected gains */ -); - -void get_max_pulses( - const int16_t *band_start, /* i : Sub band start indices */ - const int16_t *band_end, /* i : Sub band end indices */ - const int16_t *k_sort, /* i : Indices for sorting by energy */ - const int16_t *npulses, /* i : Pulses per sub band */ - const int16_t BANDS, /* i : Number of bands */ - int16_t *inp_vector, /* i/o: Encoded shape vectors */ - int16_t *maxpulse /* o : Maximum pulse height per band */ -); - -Word32 ar_div_ivas( - Word32 num, - Word32 denum ); - -void ar_encoder_start( - PARCODEC arInst, - TCQ_PBITSTREAM bsInst, - int16_t max_bits ); - -void ar_decoder_start( - PARCODEC arInst, - TCQ_PBITSTREAM bsInst ); - -void ar_encoder_done( - PARCODEC arInst ); - -void ar_decoder_done( - PARCODEC arInst ); - - -Word32 Mult_32_16( - Word32 a, - Word16 b ); - -Word32 Mult_32_32( - Word32 a, - Word32 b ); - - -void decode_mangitude_tcq_fx_ivas( - ARCODEC *pardec, - Word16 size, - Word16 npulses, - Word16 nzpos, - Word32 *positions, - Word32 *out, - Word32 *surplus_fx ); - -void decode_signs_fx_ivas( - ARCODEC *pardec, - Word16 size, - Word32 *out ); - -void srt_vec_ind_fx_ivas( - const Word32 *linear, - Word32 *srt, - Word16 *I, - Word16 length ); - - -void bit_allocation_second_fx2( - Word32 *Rk, - Word32 *Rk_sort, - Word16 BANDS, - const Word16 *band_width, - Word16 *k_sort, - Word16 *k_num, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame ); - - -Word32 encode_magnitude_tcq_fx_ivas( - ARCODEC *parenc, - float *magn_fx, - Word16 size, - Word16 npulses, - Word16 nzpos, - Word32 *savedstates, - Word32 *est_frame_bits_fx ); - -Word32 encode_signs_fx_ivas( - ARCODEC *parenc, - float *magn, - Word16 size, - Word16 npos, - Word32 *est_frame_bits_fx ); - -Word32 encode_magnitude_usq_fx_ivas( - ARCODEC *parenc, - float *magn_fx, - Word16 size, - Word16 npulses, - Word16 nzpos, - Word32 *est_frame_bits_fx ); - -ivas_error tcq_core_LR_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int32_t inp_vector[], - const float coefs_norm[], - float coefs_quant[], - const int16_t bit_budget, /* number of bits */ - const int16_t nb_sfm, - const int16_t *sfm_start, - const int16_t *sfm_end, - const int16_t *sfmsize, - Word32 *Rk_fx, - int16_t *npulses, - int16_t *k_sort, - const int16_t *p2a_flags, - const int16_t p2a_bands, - const int16_t *last_bitalloc, - const int16_t input_frame, - const int16_t adjustFlag, - const int16_t is_transient ); - -void tcq_core_LR_dec( - Decoder_State *st, - int32_t *inp_vector, - const int16_t bit_budget, - const int16_t bands, - const int16_t *band_start, - const int16_t *band_width, - Word32 *Rk_fx, - int16_t npulses[], - int16_t *k_sort, - const int16_t *p2a_flags, - const int16_t p2a_bands, - const int16_t *last_bitalloc, - const int16_t input_frame, - const int16_t adjustFlag, - const int16_t *is_transient ); - - -void TCQLSB( - int16_t bcount, - float *abuffer, - float *mbuffer, - float *sbuffer, - int16_t *dpath ); - -void RestoreTCQ( - float *magn, - int16_t size, - int16_t *bcount, - float *mbuffer ); - -void SaveTCQdata( - PARCODEC arInst, - int16_t *dpath, - int16_t bcount ); - -void LoadTCQdata( - PARCODEC arInst, - int16_t *dpath, - int16_t bcount ); - -void RestoreTCQdec( - int32_t *magn, - int16_t size, - int16_t *bcount, - float *mbuffer ); - -void TCQLSBdec( - int16_t *dpath, - float *mbuffer, - int16_t bcount ); - -void bit_allocation_second_fx2( - Word32 *Rk, - Word32 *Rk_sort, - Word16 BANDS, - const Word16 *band_width, - Word16 *k_sort, - Word16 *k_num, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame ); - -void io_ini_enc( - const int32_t argc, /* i : command line arguments number */ - char *argv[], /* i : command line arguments */ - FILE **f_input, /* o : input signal file */ - FILE **f_stream, /* o : output bitstream file */ - FILE **f_rate, /* o : bitrate switching profile (0 if N/A) */ - FILE **f_bwidth, /* o : bandwidth switching profile (0 if N/A) */ - FILE **f_metadata, /* o : metadata files (NULL if N/A) */ -#ifdef DEBUGGING - FILE **f_force, /* o : force switching profile (0 if N/A) */ -#endif - FILE **f_rf, /* o : channel aware configuration file */ - int16_t *quietMode, /* o : limit printouts */ - int16_t *noDelayCmp, /* o : turn off delay compensation */ - Encoder_Struct *st /* o : IVAS encoder structure */ -); - -void read_next_rfparam( - int16_t *rf_fec_offset, /* o : RF offset */ - int16_t *rf_fec_indicator, /* o : RF FEC indicator */ - FILE *f_rf /* i : file pointer to read parameters */ -); - -void read_next_brate( - int32_t *total_brate, /* i/o: total bitrate */ - const int32_t last_total_brate, /* i : last total bitrate */ - FILE *f_rate, /* i : bitrate switching profile (0 if N/A) */ - const int16_t element_mode, /* i : IVAS element mode */ - int32_t input_Fs, /* i : input sampling frequency */ - int16_t *Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - int16_t *Opt_SC_VBR, /* i/o: SC-VBR flag */ - int16_t *codec_mode /* i/o: Mode 1 or 2 */ -); - -void read_next_bwidth( - int16_t *max_bwidth, /* i/o: maximum encoded bandwidth */ - FILE *f_bwidth, /* i : bandwidth switching profile (0 if N/A) */ - int32_t *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */ - int32_t input_Fs /* i : input sampling rate */ -); - -#ifdef DEBUGGING -void read_next_force( - int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ - FILE *f_force, /* i : force switching profile (0 if N/A) */ - int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ -); -#endif - -ivas_error init_encoder_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID, /* i : interval for SID update */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ -); - -void LPDmem_enc_init( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -); - -ivas_error evs_enc( - Encoder_State *st, /* i/o: state structure */ - const int16_t *data, /* i : input signal */ - float *mem_hp20_in, /* i/o: hp20 filter memory */ - const int16_t n_samples /* i : number of input samples */ -); -void amr_wb_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t *data, /* i : input signal */ - float *mem_hp20_in, /* i/o: hp20 filter memory */ - const int16_t n_samples /* i : number of input samples */ -); - -void sc_vbr_enc_init( - SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle */ -); - -void amr_wb_enc_init( - AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */ -); - -void pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t input_frame, /* i : frame length */ - float old_inp_12k8[], /* i/o: buffer of old input signal */ - float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */ - float **inp, /* o : ptr. to inp. signal in the current frame*/ - float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */ - float *ener, /* o : residual energy from Levinson-Durbin */ - int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */ - float A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* i/o: LP prediction errors */ - float lsp_new[M], /* i/o: LSPs at the end of the frame */ - float lsp_mid[M], /* i/o: LSPs in the middle of the frame */ - int16_t *vad_hover_flag, /* i : VAD hangover flag */ - int16_t *attack_flag, /* o : attack flag */ - float *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - int16_t *Voicing_flag, /* o : voicing flag for HQ FEC */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - int16_t *hq_core_type /* o : HQ core type */ -); - - -/*! r: HQ_CORE/TCX_20_CORE decision */ -int16_t mdct_classifier( - Encoder_State *st, /* i/o: Encoder state variable */ - const float *fft_buff, /* i : FFT spectrum from fft_rel */ - const float enerBuffer[], /* i : energy buffer */ - const int32_t brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ -); - -void MDCT_selector( - Encoder_State *st, /* i/o: Encoder State */ - const float sp_floor, /* i : Noise floor estimate */ - const float Etot, /* i : Total energy */ - const float cor_map_sum, /* i : sum of correlation map */ - const float enerBuffer[] /* i : energy buffer */ -); - -ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - Word16 Q_new ); - -ivas_error acelp_core_switch_dec_bfi( - Decoder_State *st /* i/o: decoder state structure */ -); - -void acelp_core_switch_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float inp12k8[], /* i : input signal @12.8 kHz */ - const float inp16k[], /* i : input signal @16 kHz */ - const float A[NB_SUBFR16k * ( M + 1 )] /* i : A(z) unquantized for the 4 subframes */ -); - -/*! r: length of output */ -int16_t modify_Fs_intcub3m_sup( - const float sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */ - const int16_t lg, /* i : length of input */ - const int32_t fin, /* i : frequency of input */ - float sigOut[], /* o : decimated signal */ - const int32_t fout, /* i : frequency of output */ - int16_t *delayout /* o : delay of output */ -); - -void core_switching_OLA( - const float *mem_over_hp, /* i : upsampling filter memory */ - const int16_t last_L_frame, /* i : last L_frame lengthture */ - const int32_t output_Fs, /* i : output sampling rate */ - float *synth, /* i/o: synthesized signal from HQ core */ - const float *synth_subfr_out, /* i : synthesized signal from ACELP core */ - float *synth_subfr_bwe, /* i : synthesized BWE from ACELP core */ - const int16_t output_frame, /* i : output frame length */ - const int16_t bwidth /* i : output bandwidth */ -); - -void retro_interp4_5( - const float *syn, - float *pst_old_syn ); - -void retro_interp5_4( - float *pst_old_syn ); -void core_switching_hq_prepare_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *num_bits, /* i/o: bit budget update */ - const int16_t input_frame /* i : input frame length */ -); - -ivas_error acelp_core_switch_dec( - Decoder_State *st, /* i/o: decoder structure */ - float *synth_subfr_out, /* o : synthesized ACELP subframe */ - float *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE */ - const int16_t output_frame, /* i : input frame length */ - const int16_t core_switching_flag, /* i : core switching flag */ - float *mem_synth, /* o : synthesis to overlap */ - const int16_t nchan_out /* i : number of output channels */ -); - -void ResetSHBbuffer_Enc( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void ResetSHBbuffer_Dec( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t extl /* i : BWE extension layer */ -); - -void calc_st_filt( - const float *apond2, /* i : coefficients of numerator */ - const float *apond1, /* i : coefficients of denominator */ - float *parcor0, /* o : 1st parcor calcul. on composed filter */ - float *sig_ltp_ptr, /* i/o: input of 1/A(gamma1) : scaled by 1/g0 */ - float *mem_zero, /* i/o: All zero memory */ - const int16_t L_subfr, /* i : the length of subframe */ - const int16_t extl /* i : extension layer info */ -); - - -void scale_st_ivas( - const float *sig_in, /* i : postfilter input signal */ - float *sig_out, /* i/o: postfilter output signal */ - float *gain_prec, /* i/o: last value of gain for subframe */ - const int16_t L_subfr, /* i : the length of subframe */ - const int16_t extl /* i : extension layer info */ -); - -void filt_mu( - const float *sig_in, /* i : signal (beginning at sample -1) */ - float *sig_out, /* o : output signal */ - const float parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - const int16_t L_subfr, /* i : the length of subframe */ - const int16_t extl /* i : extension layer info */ -); - -void PostShortTerm( - float *sig_in, /* i : input signal (ptr. to current subframe */ - float *lpccoeff, /* i : LPC coefficients for current subframe */ - float *sig_out, /* o : postfiltered output */ - float *mem_stp, /* i/o: postfilter memory */ - float *ptr_mem_stp, /* i/o: pointer to postfilter memory */ - float *ptr_gain_prec, /* i/o: for gain adjustment */ - float *mem_zero, /* i/o: null memory to compute h_st */ - const float formant_fac /* i : Strength of post-filter [0,1] */ -); - -/*! r: Formant filter strength [0,1] */ -float swb_formant_fac( - const float lpc_shb2, /* i : 2nd HB LPC coefficient */ - float *tilt_mem /* i/o: Tilt smoothing memory */ -); - -void GenShapedSHBExcitation( - float *excSHB, /* o : synthesized shaped shb exctiation */ - const float *lpc_shb, /* i : lpc coefficients */ - float *exc16kWhtnd, /* o : whitened synthesized shb excitation */ - float *mem_csfilt, /* i/o: memory */ - float *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - float *state_lpc_syn, /* i/o: memory */ - const int16_t coder_type, /* i : coding type */ - const float *bwe_exc_extended, /* i : bandwidth extended excitation */ - int16_t bwe_seed[], /* i/o: random number generator seed */ - float voice_factors[], /* i : voicing factor */ - const int16_t extl, /* i : extension layer */ - float *tbe_demph, /* i/o: de-emphasis memory */ - float *tbe_premph, /* i/o: pre-emphasis memory */ - float *lpc_shb_sf, /* i : LP coefficients */ - float *shb_ener_sf, /* i : SHB subframe energies */ - float *shb_res_gshape, /* i : SHB LP residual gain shape */ - float *shb_res, /* i : SHB residual used in encoder only */ - int16_t *vf_ind, /* i/o: Mixing factor index */ - const float formant_fac, /* i : Formant sharpening factor [0..1] */ - float fb_state_lpc_syn[], /* i/o: memory */ - float *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - const int32_t total_brate, /* i : overall bitrate */ - const int16_t prev_bfi, /* i : previous frame was lost flag */ - const int16_t element_mode, /* i : element mode */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - float *nlExc16k, /* i/o: NL exc for IC-BWE */ - float *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const int32_t extl_brate, /* i : TD BWE bitrate */ - const int16_t MSFlag, /* i : Multi-source flag */ - float EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - float *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - float *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - float *Env_error, /* o : error in SHB residual envelope modelling*/ - float Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); - -void GenSHBSynth( - const float *shb_target_speech, /* i : input synthesized speech */ - float *shb_syn_speech_32k, /* o : output highband component */ - float Hilbert_Mem[], /* i/o: memory */ - float state_lsyn_filt_shb_local[], /* i/o: memory */ - const int16_t L_frame, /* i : ACELP Frame length */ - int16_t *syn_dm_phase ); - -void ScaleShapedSHB( - const int16_t length, /* i : SHB overlap length */ - float *synSHB, /* i/o: synthesized shb signal */ - float *overlap, /* i/o: buffer for overlap-add */ - const float *subgain, /* i : subframe gain */ - const float frame_gain, /* i : frame gain */ - const float *win, /* i : window */ - const float *subwin /* i : subframes window */ -); - -void Interpolate_allpass_steep( - const float *in, /* i : input array of size N */ - float *mem, /* i/o: memory */ - const int16_t N, /* i : number of input samples */ - float *out /* o : output array of size 2*N */ -); - -void Decimate_allpass_steep( - const float *in, /* i : input array of size N */ - float *mem, /* i/o: memory */ - const int16_t N, /* i : number of input samples */ - float *out /* o : output array of size N/2 */ -); - -void interpolate_3_over_2_allpass( - const float *input, /* i : input signal */ - const int16_t len, /* i : number of input samples */ - float *out, /* o : output signal */ - float *mem /* i/o: memory */ -); - -void decimate_2_over_3_allpass( - const float *input, /* i : input signal */ - const int16_t len, /* i : number of input samples */ - float *out, /* o : output signal */ - float *mem, /* i/o: memory */ - float *lp_mem ); - -void interpolate_3_over_1_allpass( - const float *input, /* i : input signal */ - const int16_t len, /* i : number of input samples */ - float *out, /* o : output signal */ - float *mem /* i/o: memory */ -); - -void InitSWBencBuffer( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void InitSWBencBufferStates( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - float *shb_speech /* o : SHB target signal (6-14kHz) at 16kHz */ -); - -void swb_tbe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const float *new_speech, /* i : original input signal */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float voice_factors[], /* i : voicing factors */ - float *White_exc16k, /* o : shaped white excitation for the FB TBE */ - const float pitch_buf[] /* i : pitch for each subframe */ -); - -void swb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float voice_factors[], /* i : voicing factors */ - const float old_syn_12k8_16k[], /* i : low band synthesis at 12.8kHz or 16kHz */ - float *White_exc16k, /* o : shaped white excitation for the FB TBE */ - float *synth, /* i/o: ACELP core synthesis/final synthesis */ - float *pitch_buf ); - -void flip_and_downmix_generic( - float input[], /* i : input spectrum */ - float output[], /* o : output spectrum */ - const int16_t length, /* i : length of spectra */ - float mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ - float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - int16_t *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); -void flip_and_downmix_generic_fx_32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); -void non_linearity( - const float input[], /* i : input signal */ - float output[], /* i : output signal */ - float old_bwe_exc_extended[], /* i/o: memory bugffer */ - const int16_t length, /* i : input length */ - float *prev_scale, /* i/o: memory */ - const int16_t coder_type, /* i : Coder Type */ - const float *voice_factors, /* i : Voice Factors */ - const int16_t L_frame /* i : ACELP frame length */ -); - -void interp_code_5over2( - const float inp_code[], /* i : input vector */ - float interp_code[], /* o : output vector */ - const int16_t inp_length /* i : length of the input vector */ -); - -void interp_code_4over2( - const float inp_code[], /* i : input vector */ - float interp_code[], /* o : output vector */ - const int16_t inp_length /* i : length of the input vector */ -); - -void flip_spectrum_and_decimby4( - const float input[], /* i : input spectrum */ - float output[], /* o : output spectrum */ - const int16_t length, /* i : vector length */ - float mem1[], /* i/o: memory */ - float mem2[], /* i/o: memory */ - const int16_t ramp_flag /* i : flag to trigger slow ramp-up of output */ -); - -void GenShapedWBExcitation( - float *excSHB, /* o : synthesized shaped shb exctiation */ - const float *lpc_shb, /* i : lpc coefficients */ - float *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - float *mem_csfilt, /* i/o: memory */ - float *mem_genSHBexc_filt_down1, /* i/o: memory */ - float *mem_genSHBexc_filt_down2, /* i/o: memory */ - float *mem_genSHBexc_filt_down3, /* i/o: memory */ - float *state_lpc_syn, /* i/o: memory */ - const int16_t coder_type, /* i : coding type */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - int16_t bwe_seed[], /* i/o: random number generator seed */ - const float voice_factors[], /* i : voicing factor */ - const int16_t uv_flag, /* i : unvoiced flag */ - const int16_t igf_flag ); - -void GenWBSynth( - const float *input_synspeech, /* i : input synthesized speech */ - float *shb_syn_speech_16k, /* o : output highband compnent */ - float *state_lsyn_filt_shb1, /* i/o: memory */ - float *state_lsyn_filt_shb2 /* i/o: memory */ -); - -void wb_tbe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float pitch_buf[], /* i : pitch for each subframe */ - const float voicing[] /* o : OL maximum normalized correlation */ -); - -void wb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float voice_factors[], /* i : voicing factors */ - float *synth /* i/o: ACELP core synthesis/final synthesis */ -); - -void tbe_write_bitstream( - Encoder_State *st /* i/o: encoder state structure */ -); - -void tbe_read_bitstream( - Decoder_State *st /* i/o: decoder state structure */ -); - -void GenTransition( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - float *outputHB, /* o : synthesized HB transitions signal */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t element_mode, /* i : element mode */ - const int16_t L_frame, /* i : ACELP frame length */ - const int16_t rf_flag, /* i : RF flag */ - const int32_t total_brate /* i : total bitrate */ -); - - -void GenTransition_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 element_mode, /* i : element mode : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 rf_flag, /* i : RF flag : Q0 */ - const Word32 total_brate, /* i : total bitrate : Q0 */ - const Word16 prev_Qx ); - -void GenTransition_WB( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - float *outputHB, /* o : synthesized HB transitions signal */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void GenTransition_WB_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void td_bwe_dec_init( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t extl, /* i : BWE extension layer */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void TBEreset_enc( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t last_core, /* i : last core */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void TBEreset_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -/*! r: TBE bit consumption per frame */ -int16_t get_tbe_bits( - const int32_t total_brate, /* i : overall bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t rf_mode /* i : channel aware mode */ -); - -void fb_tbe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float new_input[], /* i : input speech at 48 kHz sample rate */ - const float fb_exc[] /* i : FB excitation from the SWB part */ -); - -void fb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const float fb_exc[], /* i : FB excitation from the SWB part */ - float *hb_synth, /* i/o: high-band synthesis */ - float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */ - const int16_t output_frame /* i : output frame length */ -); - -void calc_tilt_bwe( - const float *sp, /* i : input signal */ - float *tilt, /* o : signal tilt */ - const int16_t N /* i : signal length */ -); - -void fd_bwe_enc_init( - FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void swb_pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - float *new_swb_speech, /* o : original input signal at 32kHz */ - float *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void wb_pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ - const float *new_inp_resamp16k, /* i : original input signal */ - float *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */ -); - -void wb_bwe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float *new_wb_speech /* i : original input signal at 16kHz */ -); - -void wb_bwe_dec_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const float output[], /* i : synthesis @internal Fs */ - float *synth, /* i/o: ACELP core synthesis/final synthesis */ - float *hb_synth, /* o : SHB synthesis/final synthesis */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t output_frame, /* i : frame length */ - const float voice_factors[], /* i : voicing factors */ - const float pitch_buf[] /* i : pitch buffer */ -); - -void swb_bwe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ - const float *old_input_12k8, /* i : input signal @12.8kHz for SWB BWE */ - const float *old_input_16k, /* i : input signal @16kHz for SWB BWE */ - const float *old_syn_12k8_16k, /* i : ACELP core synthesis at 12.8kHz or 16kHz*/ - const float *new_swb_speech, /* i : original input signal at 32kHz */ - const float *shb_speech /* i : SHB target signal (6-14kHz) at 16kHz */ -); - -void swb_bwe_enc_hr( - Encoder_State *st, /* i/o: encoder state structure */ - const float *new_input, /* i : input signal */ - const int16_t input_frame, /* i : frame length */ - const int16_t unbits /* i : number of core unused bits */ -); - -void fd_bwe_dec_init_flt( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void swb_bwe_dec_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const float output[], /* i : synthesis @internal Fs */ - const float *synth, /* i : ACELP core synthesis/final synthesis */ - float *hb_synth, /* o : SHB synthesis/final synthesis */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t output_frame /* i : frame length */ -); - -void hr_bwe_dec_init_flt( - HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ -); - -void swb_bwe_dec_hr( - Decoder_State *st, /* i/o: decoder state structure */ - const float *syn_12k8_16k, /* i : ACELP core synthesis @16kHz */ - float *hb_synth, /* o : SHB synthesis */ - const int16_t output_frame, /* i : frame length */ - const int16_t unbits, /* i : number of core unused bits */ - const float pitch_buf[] /* i : pitch buffer */ -); - - -void calc_normal_length( - const int16_t core, /* i : core */ - const float *sp, /* i : input signal */ - const int16_t mode, /* i : input mode */ - const int16_t extl, /* i : extension layer */ - int16_t *L_swb_norm, /* o : normalize length */ - int16_t *prev_L_swb_norm /* i/o: last normalize length */ -); - -void calc_norm_envelop( - const float SWB_signal[], /* i : SWB spectrum */ - float *envelope, /* o : normalized envelope */ - const int16_t L_swb_norm, /* i : length of envelope */ - const int16_t SWB_flength, /* i : Length of input/output */ - const int16_t st_offset /* i : offset */ -); - -void time_envelop_shaping( - float werr[], /* i/o: SHB synthesis */ - float SWB_tenv[], /* i/o: frequency envelope */ - const int16_t L /* i : frame length */ -); - -void time_reduce_pre_echo( - const float *synth, /* i : ACELP core synthesis */ - float *error, /* o : SHB BWE synthesis */ - float prev_td_energy, /* o : last td energy */ - const int16_t L /* i : subframe length */ -); - -int16_t WB_BWE_gain_pred( - float *WB_fenv, /* o : WB frequency envelopes */ - const float *core_dec_freq, /* i : Frequency domain core decoded signal */ - const int16_t coder_type, /* i : coding type */ - const int16_t prev_code_type, /* i : coding type of last frame */ - const float prev_WB_fenv, /* i : envelope for last frame */ - const float voice_factors[], /* i : voicing factors */ - const float pitch_buf[], /* i : pitch buffer */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - const float last_wb_bwe_ener, /* i : previous frame wb bwe signal energy */ - const int16_t last_extl, /* i : extl. layer for last frame */ - const float tilt ); - -void WB_BWE_decoding( - const float *core_dec_freq, /* i : Frequency domain core decoded signal */ - float *WB_fenv, /* i : WB frequency envelopes */ - float *WB_signal, /* o : WB signal in MDCT domain */ - const int16_t WB_flength, /* i : Length of input/output */ - const int16_t mode, /* i : classification for WB signal */ - const int16_t last_extl, /* i : extl. layer for last frame */ - float *prev_Energy, /* i/o: energy for last frame */ - float *prev_WB_fenv, /* i/o: envelope for last frame */ - int16_t *prev_L_wb_norm, /* i/o: length for last frame wb norm */ - const int16_t extl, /* i : extension layer */ - const int16_t coder_type, /* i : coding type */ - const int32_t total_brate, /* i : core layer bitrate */ - int16_t *Seed, /* i/o: random generator seed */ - int16_t *prev_flag, /* i/o: attenu flag of last frame */ - int16_t prev_coder_type /* i : coding type of last frame */ -); - -void SWB_BWE_decoding( - const float *core_dec_freq, /* i : Frequency domain core decoded signal */ - float *SWB_fenv, /* i/o: SWB frequency envelopes */ - float *SWB_signal, /* o : SWB signal in MDCT domain */ - const int16_t SWB_flength, /* i : Length of input/output */ - const int16_t mode, /* i : classification for SWB signal */ - int16_t *frica_flag, /* o : fricative signal flag */ - float *prev_Energy, /* i/o: energy for last frame */ - float *prev_SWB_fenv, /* i/o: envelope for last frame */ - int16_t *prev_L_swb_norm, /* i/o: length for last frame wb norm */ - const float tilt_nb, /* i : tilt of synthesis wb signal */ - int16_t *Seed, /* i/o: random generator seed */ - const int16_t st_offset, /* i : offset value due to different core */ - float *prev_weight, /* i/o: excitation weight value of last frame */ - const int16_t extl, /* i : extension layer */ - const int16_t last_extl /* i : extension layer of last frame */ -); - -void CNG_reset_enc( - Encoder_State *st, /* i/o: encoder state structure */ - float *pitch_buf, /* o : floating pitch for each subframe */ - float *voice_factors, /* o : voicing factors */ - int16_t VBR_cng_reset_flag ); - -/*! r: stability flag */ -uint16_t a2rc( - const float *a, /* i : LPC coefficients */ - float *refl, /* o : Reflection co-efficients */ - const int16_t lpcorder /* i : LPC order */ -); - - -void analy_sp( - const int16_t element_mode, /* i : element mode */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int32_t input_Fs, /* i : input sampling rate */ - float *speech, /* i : speech buffer */ - float *Bin_E, /* o : per bin log energy spectrum */ - float *Bin_E_old, /* o : per bin log energy spectrum for mid-frame */ - float *fr_bands, /* o : per band energy spectrum (2 analyses) */ - float lf_E[], /* o : per bin E for first VOIC_BINS bins (without DC) */ - float *Etot, /* o : total input energy */ - const int16_t min_band, /* i : minimum critical band */ - const int16_t max_band, /* i : maximum critical band */ - float *band_ener, /* o : energy in critical frequency bands without minimum noise floor E_MIN */ - float *PS, /* o : Per bin energy spectrum */ - float *fft_buff /* o : FFT coefficients */ -); - -void CNG_enc( - Encoder_State *st, /* i/o: State structure */ - float Aq[], /* o : LP coefficients */ - const float *speech, /* i : pointer to current frame input speech buffer */ - float enr, /* i : frame energy output from Levinson recursion */ - const float *lsp_mid, /* i : mid frame LSPs */ - float *lsp_new, /* i/o: current frame LSPs */ - float *lsf_new, /* i/o: current frame LSFs */ - int16_t *allow_cn_step, /* o : allow CN step */ - float *q_env, - int16_t *sid_bw ); - -void swb_CNG_enc( - Encoder_State *st, /* i/o: State structure */ - const float *shb_speech, /* i : SHB target signal (6-14kHz) at 16kHz */ - const float *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz */ -); - -void lsf_enc( - Encoder_State *st, /* i/o: state structure */ - float *lsf_new, /* o : quantized LSF vector */ - float *lsp_new, /* i/o: LSP vector to quantize/quantized */ - float *lsp_mid, /* i : mid-frame LSP vector */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void isf_enc_amr_wb( - Encoder_State *st, /* i/o: state structure */ - float *isf_new, /* o : quantized ISF vector */ - float *isp_new, /* i/o: ISP vector to quantize/quantized */ - float *Aq /* o : quantized A(z) for 4 subframes */ -); - -void find_targets( - const float *speech, /* i : pointer to the speech frame */ - const float *mem_syn, /* i : memory of the synthesis filter */ - const int16_t i_subfr, /* i : subframe index */ - float *mem_w0, /* i/o: weighting filter denominator memory */ - const float *p_Aq, /* i : interpolated quantized A(z) filter */ - const float *res, /* i : residual signal */ - const int16_t L_subfr, /* i : length of vectors for gain quantization */ - const float *Ap, /* i : unquantized A(z) filter with bandwidth expansion */ - const float tilt_fac, /* i : tilt factor */ - float *xn, /* o : Close-loop Pitch search target vector */ - float *cn, /* o : target vector in residual domain */ - float *h1 /* o : impulse response of weighted synthesis filter */ -); - -Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */ - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ -); -void find_tilt( - const float fr_bands[], /* i : energy in frequency bands */ - const float bckr[], /* i : per band background noise energy estimate */ - float ee[2], /* o : lf/hf E ration for present frame */ - const int16_t pitch[3], /* i : open loop pitch values for 3 half-frames */ - const float voicing[3], /* i : normalized correlation for 3 half-frames */ - const float *lf_E, /* i : per bin energy for low frequencies */ - const float corr_shift, /* i : normalized correlation correction */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t max_band, /* i : maximum critical band */ - float hp_E[], /* o : energy in HF */ - const int16_t codec_mode, /* i : Mode 1 or 2 */ - float *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise */ - int16_t Opt_vbr_mode ); - -void init_gp_clip( - float mem[] /* o : memory of gain of pitch clipping algorithm */ -); - -int16_t gp_clip( - const int16_t element_mode, /* i : element mode */ - const int32_t core_brate, /* i : core bitrate */ - const float *voicing, /* i : normalized correlations (from OL pitch) */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t coder_type, /* i : coding type */ - const float xn[], /* i : target vector */ - float mem[] /* i/o: memory of gain of pitch clipping algorithm */ -); - -void gp_clip_test_lsf( - const int16_t element_mode, /* i : element mode */ - const int32_t core_brate, /* i : core bitrate */ - const float lsf[], /* i : LSF vector */ - float mem[], /* i/o: memory of gain of pitch clipping algorithm */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - -void gp_clip_test_gain_pit( - const int16_t element_mode, /* i : element mode */ - const int32_t core_brate, /* i : core bitrate */ - const float gain_pit, /* i : gain of quantized pitch */ - float mem[] /* i/o: memory of gain of pitch clipping algorithm */ -); - -void analy_lp( - const float speech[], /* i : pointer to the denoised speech frame */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_look, /* i : look-ahead length */ - float *ener, /* o : residual signal energy */ - float A[], /* o : A(z) filter coefficients */ - float epsP[], /* o : LP analysis residual energies for each iteration */ - float lsp_new[], /* o : current frame ISPs */ - float lsp_mid[], /* o : current mid-frame ISPs */ - float lsp_old[], /* i/o: previous frame unquantized ISPs */ - const int16_t Top[2], /* i : open loop pitch lag */ - const float Tnc[2], /* i : open loop pitch gain */ - const int32_t sr_core, /* i : internal sampling rate */ - const int16_t sec_chan_low_rate /* i : TD secondary channel flag */ -); - -void analy_lp_AMR_WB( - const float speech[], /* i : pointer to the speech frame */ - float *ener, /* o : residual energy from Levinson-Durbin */ - float A[], /* o : A(z) filter coefficients */ - float epsP[], /* o : LP analysis residual energies for each iteration */ - float isp_new[], /* o : current frame ISPs */ - float isp_old[], /* i/o: previous frame unquantized ISPs */ - float isf_new[], /* o : current frame ISFs */ - const int16_t Top, /* i : open loop pitch lag */ - const float Tnc /* i : open loop pitch gain */ -); - -void noise_est_init( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ -); - -void speech_music_clas_init( - SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ -); - -void long_enr( - Encoder_State *st, /* i/o: encoder state structure */ - const float Etot, /* i : total channel energy */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const int16_t high_lpn_flag, /* i : sp/mus LPN flag */ - FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ - const int16_t n_chan, /* i : number of channels */ - const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover LR channels */ - const float Etot_LR[] /* i : total channel energy LR channels */ -); - -void noise_est_pre( - const float Etot, /* i : Energy of current frame */ - const int16_t ini_frame, /* i : Frame number (init) */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation data handle */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t last_element_mode /* i : last element mode */ -); - -void noise_est_down( - const float fr_bands[], /* i : per band input energy (contains 2 vectors) */ - float bckr[], /* i/o: per band background noise energy estimate */ - float tmpN[], /* o : temporary noise update */ - float enr[], /* o : averaged energy over both subframes */ - const int16_t min_band, /* i : minimum critical band */ - const int16_t max_band, /* i : maximum critical band */ - float *totalNoise, /* o : noise estimate over all critical bands */ - const float Etot, /* i : Energy of current frame */ - float *Etot_last, /* i/o: Energy of last frame */ - float *Etot_v_h2 /* i/o: Energy variaions of noise frames */ -); - -void noise_est( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t old_pitch1, /* i : previous frame OL pitch[1] */ - const float tmpN[], /* i : temporary noise update */ - const float *epsP, /* i : LP prediction error energies */ - const float Etot, /* i : total channel E */ - const float relE, /* i : relative frame energy */ - const float corr_shift, /* i : normalized correlation correction */ - const float enr[], /* i : averaged energy over both subframes */ - float fr_bands[], /* i : spectrum per critical bands of the current frame */ - float *cor_map_sum, /* o : sum of correlation map from mult-harm analysis */ - float *ncharX, /* o : noise character for sp/mus classifier */ - float *sp_div, /* o : soectral diversity feature */ - float *non_staX, /* o : non-stationarity for sp/mus classifier */ - int16_t *loc_harm, /* o : multi-harmonicity flag for UV classifier */ - const float *lf_E, /* i : per bin energy for low frequencies */ - int16_t *st_harm_cor_cnt, /* i : 1st harm correlation timer */ - const float Etot_l_lp, /* i : Smoothed low energy */ - float *sp_floor, /* o : noise floor estimate */ - float S_map[], /* o : short-term correlation map */ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ - const int16_t ini_frame /* i : Frame number (init) */ -); - -void vad_param_updt( - Encoder_State *st, /* i/o: encoder state structure */ - const float corr_shift, /* i : correlation shift */ - const float corr_shiftR, /* i : correlation shift right channel */ - const float A[], /* i : A(z) unquantized for the 4 subframes */ - const int16_t old_pitch1, /* i : previous frame OL pitch[1] */ - FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ - const int16_t n_channels /* i : number of channels */ -); - - -void lp_gain_updt( - const int16_t i_subfr, /* i : subframe number */ - const float gain_pit, /* i : Decoded gain pitch */ - const float norm_gain_code, /* i : Normalised gain code */ - float *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) */ - float *lp_gainc, /* i/o: LP-filtered code gain (FEC) */ - const int16_t L_frame /* i : length of the frame */ -); - -void GSC_enc_init( - GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */ -); - - -/*! r: index of the last band where pitch contribution is significant */ -int16_t Pit_exc_contribution_len( - Encoder_State *st, /* i/o: state structure */ - const float *dct_res, /* i : DCT of residual */ - float *dct_pitex, /* i/o: DCT of pitch contribution */ - float *pitch_buf, /* i/o: Pitch per subframe */ - int16_t *hangover /* i : Hangover for the time contribution switching */ -); - -int16_t stab_est( - float etot, /* i : Total energy of the current frame */ - float *lt_diff_etot, /* i/o: Long term total energy variation */ - float *mem_etot, /* i/o: Total energy memory */ - int16_t *nb_thr_3, /* i/o: Number of consecutives frames of level 3 */ - int16_t *nb_thr_1, /* i/o: Number of consecutives frames of level 1 */ - float *thresh, /* i/o: Detection thresold */ - int16_t *last_music_flag, /* i/o: Previous music detection ouptut */ - const int16_t vad_flag /* i : VAD flag */ -); - -float gsc_gainQ( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - const float y_gain4[], /* i : gain per band */ - float y_gainQ[], /* o : quantized gain per band */ - const int32_t core_brate, /* i : Core rate */ - const int16_t coder_type, /* i : coding type */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t L_frame, /* i : frame length */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int32_t core_brate_inp /* i : true core brate */ -); - -void Comp_and_apply_gain( - float exc_diffQ[], /* i/o: gain per band */ - float Ener_per_bd_iQ[], /* o : Quant Ener per band */ - float Ener_per_bd_yQ[], /* o : Ener per band for quantize y */ - int16_t Mbands_gn, /* i : number of bands */ - const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */ -); - -void bands_and_bit_alloc_ivas_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -void GSC_dec_init_ivas( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ -); - -void decod_audio( - Decoder_State *st, /* i/o: decoder static memory */ - float dct_epit[], /* o : GSC excitation in DCT domain */ - const float *Aq, /* i : LP filter coefficient */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc_dct_in, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *lsf_new, /* i : current frame ISF vector */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag */ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void gsc_dec( - Decoder_State *st, /* i/o: State structure */ - float exc_dct_in[], /* i/o: dct of pitch-only/total excitation */ - const int16_t pit_band_idx, /* i : pitch band index */ - const int16_t Diff_len, /* i : */ - const int16_t bits_used, /* i : total number of bits used */ - const int16_t nb_subfr, /* i : Number of subframe considered */ - const int16_t coder_type, /* i : coding type */ - int16_t *last_bin, /* i : last bin of bit allocation */ - const float *lsf_new, /* i : ISFs at the end of the frame */ - float *exc_wo_nf, /* o : excitation (in f domain) without noisefill*/ - float *tmp_noise /* o : long-term noise energy */ -); - -void dec_pit_exc( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *code, /* o : innovation */ - float *exc, /* i/o: adapt. excitation exc */ - const int16_t nb_subfr, /* i : Number of subframe considered */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void music_postfilt_init_flt( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ -); - -void LD_music_post_filter( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const float dtc_in[], /* i : input synthesis */ - float dtc_out[], /* o : output synthesis */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t coder_type, /* i : Coder type : -1 in case of IO */ - const int16_t Last_coder_type /* i : last Coder type */ -); - -void Post_music_postP( - float dct_buffer_in[], /* i/o: excitation buffer */ - float exc_buffer_out[], /* o : DCT output buffer */ - float *exc2, /* i/o: Current excitation to be overwriten */ - const float *mem_tmp, /* i : previous frame synthesis memory */ - float *st_mem_syn2, /* i/o: current frame synthesis memory */ - const float *Aq, /* i : LPC filter coefficients */ - float *syn /* i/o: 12k8 synthesis */ -); - -void Prep_music_postP( - float exc_buffer_in[], /* i/o: excitation buffer */ - float dct_buffer_out[], /* o : DCT output buffer */ - float filt_lfE[], /* i/o: long term spectrum energy */ - const int16_t last_core, /* i : last core */ - const float *pitch_buf, /* i : current frame pitch information */ - float *LDm_enh_lp_gbin /* o : smoothed suppression gain, per bin FFT */ -); - -void speech_music_classif( - Encoder_State *st, /* i/o: encoder state structure */ - const float *new_inp, /* i : new input signal */ - const float *inp, /* i : input signal to locate attach position */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const float lsp_new[M], /* i : LSPs in current frame */ - const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */ - const float epsP[M + 1], /* i : LP prediciton error */ - const float PS[], /* i : energy spectrum */ - const float Etot, /* i : total frame energy */ - const float old_cor, /* i : max correlation from previous frame */ - int16_t *attack_flag, /* o : attack flag (GSC or TC) */ - const float non_staX, /* i : unbound non-stationarity for sp/mus classifier */ - const float relE, /* i : relative frame energy */ - int16_t *high_lpn_flag, /* o : sp/mus LPN flag */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, - /* i : A(z) filter coefficients */ // Q12 - Word16 *Aw_fx, - /* o : weighted A(z) filter coefficients */ // Q12 - const Word16 *speech_fx, - /* i : pointer to the denoised speech frame */ // Q_new - const Word16 tilt_fact, - /* i : tilt factor */ // Q15 - Word16 *wsp_fx, - /* o : poitnter to the weighted speech frame */ // Q_new - Word16 *mem_wsp_fx, - /* i/o: W(Z) denominator memory */ // Q_new - const Word16 gamma, - /* i : weighting factor */ // Q15 - const Word16 L_look /* i : look-ahead Q0*/ -); - -void gain_enc_amr_wb( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const float *xn, /* i : target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - const int32_t core_brate, /* i : core bitrate */ - float *gain_pit, /* i/o: Pitch gain / Quantized pitch gain */ - float *gain_code, /* o : Quantized codebook gain */ - float *gain_inov, /* o : innovation gain */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *coeff, /* i/o: correlations , -2,, -2 and 2 */ - const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - float *past_qua_en /* i/o: gain quantization memory (4 words) */ -); - -void gain_enc_lbr( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : subframe index */ - const float *xn, /* i : target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : gain of the innovation (used for normalization) */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */ - const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const int16_t L_subfr /* i : subfr Lenght */ -); - -void gain_enc_mless( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t element_mode, /* i : element mode */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t tc_subfr, /* i : TC subframe index */ - const float *xn, /* i : target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - const float Es_pred, /* i : predicted scaled innovation energy */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : innovation gain */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *coeff, /* i/o: correlations , -2,, -2 and 2 */ - const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */ -); - -void gain_enc_SQ( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t i_subfr, /* i : subframe index */ - const float *xn, /* i : target vector */ - const float *yy1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - const float Es_pred, /* i : predicted scaled innovation energy */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : gain of the innovation (used for normalization) */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */ -); - -/*! r: Return index of quantization */ -int16_t gain_enc_gaus( - float *gain, /* i/o: Code gain to quantize */ - const int16_t bits, /* i : number of bits to quantize */ - const float lowBound, /* i : lower bound of quantizer (dB) */ - const float topBound /* i : upper bound of quantizer (dB) */ -); - -void E_corr_xy2( - const float xn[], /* i : target vector */ - const float y1[], /* i : filtered excitation components 1 */ - const float y2[], /* i : filtered excitation components 2 */ - float g_corr[], /* o : correlations between x, y1, y2, y3, y4 */ - const int16_t L_subfr /* i : subframe size */ -); - - -/*! r: coding type */ -int16_t find_uv( - Encoder_State *st, /* i/o: encoder state structure */ - const float *pitch_fr, /* i : pointer to adjusted fractional pitch (4 val.) */ - const float *voicing_fr, /* i : refined correlation for each subframes */ - const float *speech, /* i : pointer to speech signal for E computation */ - const float *ee, /* i : lf/hf Energy ratio for present frame */ - float *dE1X, /* o : sudden energy increase for S/M classifier */ - const float corr_shift, /* i : normalized correlation correction in noise */ - const float relE, /* i : relative frame energy */ - const float Etot, /* i : total energy */ - const float hp_E[], /* i : energy in HF */ - int16_t *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */ - const int16_t last_core_orig, /* i : original last core */ - STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure */ -); - -/*! r: classification for current frames */ -int16_t signal_clas( - Encoder_State *st, /* i/o: encoder state structure */ - const float *speech, /* i : pointer to speech signal for E computation */ - const float *ee, /* i : lf/hf E ration for 2 half-frames */ - const float relE, /* i : frame relative E to the long term average */ - const int16_t L_look, /* i : look-ahead */ - int16_t *clas_mod /* o : class flag for NOOP detection */ -); - -void select_TC( - const int16_t codec_mode, /* i : codec mode */ - const int16_t tc_cnt, /* i : TC frame counter */ - int16_t *coder_type, /* i/o: coder type */ - const int16_t localVAD /* i : VAD without hangover */ -); - - -void wb_vad_init( - VAD_HANDLE hVAD /* i/o: VAD data handle */ -); - -int16_t dtx_hangover_addition( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t vad_flag, /* i : VAD flag */ - const float snr, /* i : input single SNR estimate */ - const int16_t cldfb_subtraction, /* i : */ - int16_t *vad_hover_flag, /* o : VAD hangover flag */ - VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ - NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ - int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ -); - -int16_t wb_vad( - Encoder_State *st, /* i/o: encoder state structure */ - const float fr_bands[], /* i : per band input energy (contains 2 vectors) */ - int16_t *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */ - int16_t *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ - int16_t *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ - float *snr_sum_he, /* i : voicing metric from SAD */ - int16_t *localVAD_HE_SAD, /* o : HE_SAD decision without hangovers */ - int16_t *flag_noisy_speech_snr, /* o : */ - VAD_HANDLE hVAD, /* i/o: VAD handle */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ - float lp_speech, /* i : long term active speech energy average */ - float lp_noise /* i : long term noise energy */ -); - -void bw_detect( - Encoder_State *st, /* i/o: Encoder State */ - const float signal_in[], /* i : input signal */ - float *spectrum, /* i : MDCT spectrum */ - const float *enerBuffer, /* i : energy buffer */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t mct_on /* i : flag MCT mode */ -); - -void set_bw( - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - Encoder_State *st, /* i/o: Encoder State */ - const int16_t codec_mode /* i : codec mode */ -); - -float gaus_encode( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t i_subfr, /* i : subframe index */ - const float *h1, /* i : weighted filter input response */ - const float *xn, /* i : target vector */ - float *exc, /* o : pointer to excitation signal frame */ - float *mem_w0, /* o : weighting filter denominator memory */ - float *gp_clip_mem, /* o : memory of gain of pitch clipping algorithm */ - float *tilt_code, /* o : synthesis excitation spectrum tilt */ - float *code, /* o : algebraic excitation */ - float *gain_code, /* o : Code gain. */ - float *y2, /* o : zero-memory filtered adaptive excitation */ - float *gain_inov, /* o : innovation gain */ - float *voice_fac, /* o : voicing factor */ - float *gain_pit, /* o : adaptive excitation gain */ - float *norm_gain_code /* o : normalized innovative cb. gain */ -); - -void td_cng_enc_init( - TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const int16_t Opt_DTX_ON, /* i : flag indicating DTX operation */ - const int16_t max_bwidth /* i : maximum encoded bandwidth */ -); - -void dtx( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t vad, /* i : VAD flag for DTX */ - const float speech[] /* i : Pointer to the speech frame */ -); - -void dtx_hangover_control( - Encoder_State *st, /* i/o: encoder state structure */ - const float lsp_new[M] /* i : current frame LSPs */ -); - - -void updt_enc_common( - Encoder_State *st /* i/o: encoder state structure */ -); - -void updt_IO_switch_enc( - Encoder_State *st, /* i/o: state structure */ - const int16_t input_frame /* i : input frame length */ -); - -void transition_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t i_subfr, /* i : subframe index */ - int16_t *tc_subfr, /* i/o: TC subframe index */ - int16_t *Jopt_flag, /* i : joint optimization flag */ - int16_t *position, /* i/o: maximum of residual signal index */ - int16_t *T0, /* i/o: close loop integer pitch */ - int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */ - int16_t *T0_min, /* i/o: lower limit for close-loop search */ - int16_t *T0_max, /* i/o: higher limit for close-loop search */ - float *exc, /* i/o: pointer to excitation signal frame */ - float *y1, /* o : zero-memory filtered adaptive excitation */ - const float *h1, /* i : weighted filter input response */ - const float *xn, /* i : target vector */ - float *xn2, /* o : target vector for innovation search */ - float *gp_cl, /* i/o: memory of gain of pitch clipping algorithm */ - float *gain_pit, /* o : adaptive excitation gain */ - float *g_corr, /* o : ACELP correlation values */ - int16_t *clip_gain, /* i/o: adaptive gain clipping flag */ - float **pt_pitch, /* o : floating pitch values */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - int16_t *unbits /* i/o: unused bits */ -); - -void tc_classif_enc( - const int16_t L_frame, /* i : length of the frame */ - int16_t *tc_subfr, /* i/o: TC subframe index */ - int16_t *position, /* i/o: maximum of residual signal index */ - const int16_t attack_flag, /* i : attack flag */ - const int16_t pitch, /* i : open loop pitch estimates for first halfframe */ - const float *res /* i : pointer to the LP residual signal frame */ -); - - -void gain_enc_tc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t i_subfr, /* i : subframe index */ - const float xn[], /* i : target vector */ - const float y2[], /* i : zero-memory filtered algebraic codebook excitation */ - const float code[], /* i : algebraic excitation */ - const float Es_pred, /* i : predicted scaled innovation energy */ - float *gain_pit, /* o : pitch gain / Quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - - -/*! r: comfort noise gain factor */ -float AVQ_cod( - const float xri[], /* i : vector to quantize */ - int16_t xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */ - const int16_t nb_bits, /* i : number of allocated bits */ - const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */ -); - -void AVQ_encmux( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t extl, /* i : extension layer */ - int16_t xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ - int16_t *nb_bits, /* i/o: number of allocated bits */ - const int16_t Nsv, /* i : number of subvectors */ - int16_t nq[], /* o : AVQ nq index */ - int16_t avq_bit_sFlag, /* i : flag indicating AVQ bit savings */ - int16_t trgtSvPos /* i : target SV for AVQ bit savings */ -); - -void ordr_esti( - const int16_t k, /* i : sub-vector index */ - int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */ - int16_t svOrder[], /* i/o: AVQ sub-vector order */ - const int16_t Nsv /* i : total sub-vectors in a sub-frames */ -); - -void re8_cod( - int16_t x[], /* i : point in RE8 (8-dimensional integer vector) */ - int16_t *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ - uint16_t *I, /* o : index of c (pointer to unsigned 16-bit word) */ - int16_t k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */ -); - -void pre_exc( - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t L_frame, /* i : frame length */ - const float *speech, /* i : input speech */ - const float *p_Aq, /* i : 12k8 Lp coefficient */ - const float *p_A, /* i : unquantized A(q) filter with bandwidth expansion */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : current sub frame indicator */ - float *Ap, /* o : weighted LP filter coefficients */ - const float *res, /* i : residual signal */ - float *h1, /* o : impulse response of weighted synthesis filter */ - float *xn, /* o : close-loop Pitch search target vector */ - float *cn, /* o : target vector in residual domain */ - float *mem_syn, /* i/o: memory of the synthesis filter */ - float *mem_w0, /* i/o: weighting filter denominator memory */ - const int16_t L_subfr /* i : subframe length */ -); - - -void encod_amr_wb( - Encoder_State *st, /* i/o: state structure */ - const float speech[], /* i : input speech */ - const float Aw[], /* i : weighted A(z) unquantized for subframes */ - const float Aq[], /* i : 12k8 Lp coefficient */ - const float *res, /* i : residual signal */ - float *syn, /* i/o: core synthesis */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *pitch_buf, /* i/o: floating pitch values for each subframe */ - int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */ - const float *speech16k /* i : input speech @16kHz */ -); - -void stat_noise_uv_enc( - Encoder_State *st, /* i/o: state structure */ - const float *epsP, /* i : LP prediction errors */ - const float *isp_new, /* i : immittance spectral pairs at 4th sfr */ - const float *isp_mid, /* i : immittance spectral pairs at 2nd sfr */ - float *Aq, /* i/o: A(z) quantized for the 4 subframes */ - float *exc2, /* i/o: excitation buffer */ - const int16_t uc_two_stage_flag /* o : flag undicating two-stage UC */ -); - -void re8_compute_base_index( - const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */ - const int16_t ka, /* i : Identifier of the absolute leader related to x */ - uint16_t *I /* o : index */ -); - -void transf_cdbk_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const int16_t i_subfr, /* i : subframe index */ - float cn[], /* i/o: target vector in residual domain */ - float exc[], /* i/o: pointer to excitation signal frame */ - const float *p_Aq, /* i : 12k8 Lp coefficient */ - const float Ap[], /* i : weighted LP filter coefficients */ - const float h1[], /* i : weighted filter input response */ - float xn[], /* i/o: target vector */ - float xn2[], /* i/o: target vector for innovation search */ - float y1[], /* i/o: zero-memory filtered adaptive excitation */ - const float y2[], /* i : zero-memory filtered innovative excitation */ - const float Es_pred, /* i : predicited scaled innovation energy */ - float *gain_pit, /* i/o: adaptive excitation gain */ - const float gain_code, /* i : innovative excitation gain */ - float g_corr[], /* o : ACELP correlation values */ - const int16_t clip_gain, /* i : adaptive gain clipping flag */ - float *gain_preQ, /* o : prequantizer excitation gain */ - float code_preQ[], /* o : prequantizer excitation */ - int16_t *unbits /* i/o: number of AVQ unused bits */ -); -void deemph_lpc( - float *p_Aq_cuerr, /* i : LP coefficients current frame */ - float *p_Aq_old, /* i : LP coefficients previous frame */ - float *LPC_de_curr, /* o : De-emphasized LP coefficients current frame */ - float *LPC_de_old, /* o : De-emphasized LP coefficients previous frame*/ - const int16_t deemph_old ); - -void Interpol_delay( - float *out, /* o : pitch interpolation output */ - float *last, /* i : last frame pitch lag */ - float *current, /* i : current frame pitch lag */ - int16_t SubNum, /* i : subframe number */ - const float *frac /* i : interpolation constant */ -); - -void dequantize_uvg( - int16_t iG1, /* i : gain 1 index */ - int16_t *iG2, /* i : gain 2 index */ - float *G, /* o : quantized gain */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void generate_nelp_excitation( - int16_t *seed, /* i/o: random number seed */ - float *Gains, /* i : excitation gains */ - float *output, /* o : excitation output */ - float gain_fac /* i : gain factor */ -); - -void nelp_encoder( - Encoder_State *st, /* i/o: encoder state */ - float *in, /* i : residual signal */ - float *exc, /* o : NELP quantized excitation signal */ - const int16_t reduce_gains ); - -void encod_nelp( - Encoder_State *st, /* i/o: state structure */ - const float *speech, /* i : input speech */ - const float Aw[], /* i : weighted A(z) unquantized for subframes */ - const float *Aq, /* i : 12k8 Lp coefficient */ - float *res, /* o : residual signal */ - float *synth, /* o : core synthesis */ - float *tmp_noise, /* o : long-term noise energy */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void realft( - float *data, /* i/o: data array */ - int16_t n, /* i : length of data array */ - int16_t isign /* i : sign +1 or -1 */ -); - -ivas_error DTFS_new( - DTFS_STRUCTURE **dtfs_out ); - -void DTFS_copy( - DTFS_STRUCTURE *Xout, /* o : DTFS */ - DTFS_STRUCTURE Xinp /* i : DTFS */ -); - -void DTFS_sub( - DTFS_STRUCTURE *tmp, /* o : output DFTS */ - DTFS_STRUCTURE X1, /* i : DTFS input 1 */ - DTFS_STRUCTURE X2 /* i : DTFS input 2 */ -); - -void DTFS_to_fs( - const float *x, /* i : Time domain signal */ - const int16_t N, /* i : Length of input vector */ - DTFS_STRUCTURE *X, /* o : DTFS structure with a, b, lag */ - const int32_t sampling_rate, - const int16_t FR_flag /* i : FR flag */ -); - -void DTFS_fs_inv( - DTFS_STRUCTURE *X, /* i : DTFS */ - float *x, /* o : time domain sig */ - const int16_t N, /* i : Output length */ - float ph0 /* i : Input phase */ -); - -void DTFS_car2pol( - DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */ - /* input in Cartesion, output in Polar */ -); - -void DTFS_pol2car( - DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */ - /* input in Polar, output in Cartesian */ -); - -/*! r: Return Input RMS between f1/f2 b4 scaling */ -float DTFS_setEngyHarm( - float f1, /* i : lower band freq of input to control energy */ - float f2, /* i : upper band freq of input to control energy */ - float g1, /* i : lower band freq of output to control energy */ - float g2, /* i : upper band freq of output to control energy */ - float en2, /* i : Target Energy to set the DTFS to */ - DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of */ -); - -void DTFS_to_erb( - DTFS_STRUCTURE X, /* i : DTFS input */ - float *out /* o : ERB output */ -); - -void DTFS_zeroPadd( - const int16_t N, /* i : Target lag */ - DTFS_STRUCTURE *X /* i/o: DTFS */ -); - -/*! r: Energy */ -float DTFS_getEngy( - DTFS_STRUCTURE X /* i : DTFS to compute energy of */ -); - -void DTFS_adjustLag( - DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for */ - const int16_t N /* i : Target lag */ -); - -void DTFS_poleFilter( - DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace */ - const float *LPC, /* i : LPCs */ - const int16_t N /* i : LPCORDER */ -); - -void DTFS_zeroFilter( - DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace */ - const float *LPC, /* i : LPCs */ - const int16_t N /* i : LPCORDER */ -); - -float DTFS_alignment_full( - DTFS_STRUCTURE X1_DTFS, /* i : reference DTFS */ - DTFS_STRUCTURE X2_DTFS, /* i : DTFS to shift */ - const int16_t num_steps /* i : resolution */ -); - -void DTFS_phaseShift( - DTFS_STRUCTURE *X, /* i : DTFS to shift */ - float ph /* i : phase to shift */ -); - -void erb_add( - float *curr_erb, /* i/o: current ERB */ - const int16_t l, /* i : current lag */ - const float *prev_erb, /* i : previous ERB */ - const int16_t pl, /* i : previous lag */ - const int16_t *index, /* i : ERB index */ - const int16_t num_erb /* i : number of ERBs */ -); - -void erb_slot( - int16_t lag, /* i : input lag */ - int16_t *out, /* o : ERB slots */ - float *mfreq, /* i : ERB frequencies */ - int16_t num_erb /* i : number of ERBs */ -); - -void erb_diff( - const float *prev_erb, /* i : previous ERB */ - const int16_t pl, /* i : previous lag */ - const float *curr_erb, /* i : current ERB */ - const int16_t l, /* i : current lag */ - const float *curr_lsp, /* i : current LSP coefficients */ - float *out, /* o : ERB difference */ - int16_t *index, /* i : ERB index */ - const int16_t num_erb /* i : Number of ERBs */ -); - -void DTFS_erb_inv( - float *in, /* i : ERB inpt */ - int16_t *slot, /* i : ERB slots filled based on lag */ - float *mfreq, /* i : erb frequence edges */ - DTFS_STRUCTURE *X, /* o : DTFS after erb-inv */ - const int16_t num_erb /* i : Number of ERB bands */ -); - -ivas_error ppp_quarter_encoder( - int16_t *returnFlag, /* o : return value */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - DTFS_STRUCTURE *CURRCW_Q, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW, /* o : DTFS with quant phase but unquant Amp */ - const int16_t prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ, /* i : Unquantized DTFS */ - const float *curr_lpc, /* i : LPCS */ - float *lastLgainE, /* i/o: last low band gain */ - float *lastHgainE, /* i/o: last high band gain */ - float *lasterbE, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E /* i : past DTFS */ -); - -ivas_error WIsyn( - DTFS_STRUCTURE PREVCW, /* i : Prev frame DTFS */ - DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS */ - const float *curr_lpc, /* i : LPC */ - float *ph_offset, /* i/o: Phase offset to line up at end of frame */ - float *out, /* o : Waveform Interpolated time domain signal */ - const int16_t N, /* i : Number of samples of output to generate */ - const int16_t FR_flag /* i : called for post-smoothing in FR */ -); - -void set_ppp_mode( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ - const int16_t clean_speech_HO, /* i : SC-VBR clean speech HO flag */ - const int16_t NB_speech_HO, /* i : SC-VBR NB speech HO flag */ - const int16_t localVAD_he /* i : HE-SAD flag without hangover */ -); - -ivas_error ppp_voiced_encoder( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t last_coder_type_raw, /* i : raw last_coder_type */ - const float old_pitch_buf[], /* i : buffer of old subframe pitch values */ - float *in, /* i : residual signal */ - float *out, /* o : Quantized residual signal */ - const int16_t delay, /* i : open loop pitch */ - float *lpc1, /* i : prev frame de-emphasized LPC */ - float *lpc2, /* i : current frame de-emphasized LPC */ - float *exc, /* i : previous frame quantized excitation */ - float *pitch /* o : floating pitch values for each subframe */ -); - -ivas_error encod_ppp( - Encoder_State *st, /* i/o: state structure */ - const float speech[], /* i : input speech */ - const float Aw[], /* i : weighted A(z) unquantized for subframes */ - const float Aq[], /* i : 12k8 Lp coefficient */ - float *res, /* i/o: residual signal */ - float *synth, /* i/o: core synthesis */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *pitch_buf, /* i/o: floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void reset_rf_indices( - RF_ENC_HANDLE hRF, /* i/o: RF state structure */ - const int16_t L_frame, /* i : frame length */ - int16_t *rf_target_bits_write ); - -void signaling_enc_rf( - Encoder_State *st /* i/o: encoder state structure */ -); - -ivas_error acelp_core_dec( - Decoder_State *st, /* i/o: Decoder state structure */ - float output[], /* o : synthesis @internal Fs */ - float synth[], /* o : synthesis */ - float save_hb_synth[], /* o : HB synthesis */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ - int16_t *unbits, /* o : number of unused bits */ - int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t last_element_mode, /* i : last element mode */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t read_sid_info /* i : read SID info flag */ -); - -void bass_psfilter_init( - BPF_DEC_HANDLE hBPF /* o : BPF data handle */ -); - -void bass_psfilter( - BPF_DEC_HANDLE hBPF, /* o : BPF data handle */ - const int16_t Opt_AMR_WB, /* i : AMR-WB IO flag */ - const float synth_in[], /* i : synthesis (at 16kHz) */ - const int16_t L_frame, /* i : length of the last frame */ - const float pitch_buf[], /* i : pitch for every subfr [0,1,2,3] */ - const int16_t bpf_off, /* i : do not use BPF when set to 1 */ - float v_stab, /* i : stability factor */ - float *v_stab_smooth, /* i : smoothed stability factor */ - const int16_t coder_type, /* i : coder_type */ - float bpf_noise_buf[] /* o : BPF error signal (at int_fs) */ -); - -void CNG_reset_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *pitch_buf, /* o : floating pitch for each subframe */ - float *voice_factors /* o : voicing factors */ -); - -void updt_dec( - Decoder_State *st, /* i/o: state structure */ - const float *old_exc, /* i : buffer of excitation */ - const float *pitch_buf, /* i : floating pitch values for each subframe */ - const float Es_pred, /* i : predicited scaled innovation energy */ - const float *Aq, /* i : A(z) quantized for all subframes */ - const float *lsf_new, /* i : current frame LSF vector */ - const float *lsp_new, /* i : current frame LSP vector */ - const float voice_factors[], /* i : voicing factors */ - const float *old_bwe_exc, /* i : buffer of excitation */ - const float *gain_buf /* o : floating pitch gain for each subframe */ -); - -void updt_IO_switch_dec( - const int16_t output_frame, /* i : output frame length */ - Decoder_State *st /* i/o: state structure */ -); - -void updt_dec_common( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t hq_core_type, /* i : HQ core type */ - const int16_t concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const float *synth /* i : decoded synthesis */ -); - -void td_cng_dec_init( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -); - -void CNG_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t last_element_mode, /* i : last element mode */ - float Aq[], /* o : LP coefficients */ - float *lsp_new, /* i/o: current frame LSPs */ - float *lsf_new, /* i/o: current frame LSFs */ - int16_t *allow_cn_step, /* o : allow cn step */ - int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - float *q_env ); - -void swb_CNG_dec( - Decoder_State *st, /* i/o: State structure */ - const float *synth, /* i : ACELP core synthesis at 32kHz */ - float *shb_synth, /* o : high-band CNG synthesis */ - const int16_t sid_bw /* i : 0-NB/WB, 1-SWB SID */ -); - -void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void isf_dec_amr_wb( - Decoder_State *st, /* i/o: State structure */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - float *isf_new, /* o : de-quantized ISF vector */ - float *isp_new /* o : de-quantized ISP vector */ -); - -void Es_pred_dec( - float *Es_pred, /* o : predicted scaled innovation energy */ - const int16_t enr_idx, /* i : indice */ - const int16_t nb_bits, /* i : number of bits */ - const int16_t no_ltp /* i : no LTP flag */ -); - -void gaus_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t i_subfr, /* i : subframe index */ - float *code, /* o : gaussian excitation */ - float *norm_gain_code, /* o : gain of the normalized gaussian excitation */ - float *lp_gainp, /* i/o: lp filtered pitch gain(FER) */ - float *lp_gainc, /* i/o: lp filtered code gain (FER) */ - float *gain_inov, /* o : unscaled innovation gain */ - float *tilt_code, /* o : synthesis excitation spectrum tilt */ - float *voice_fac, /* o : estimated voicing factor */ - float *gain_pit, /* o : reset pitch gain */ - float *pt_pitch, /* o : reset floating pitch buffer */ - float *exc, /* o : excitation signal frame */ - float *gain_code, /* o : gain of the gaussian excitation */ - float *exc2 /* o : scaled excitation signal frame */ -); - -void gain_dec_amr_wb( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : core bitrate */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *past_qua_en, /* i/o: gain quantization memory (4 words) */ - float *gain_inov, /* o : unscaled innovation gain */ - const float *code, /* i : algebraic code excitation */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -void gain_dec_lbr( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : subframe index */ - const float *code, /* i : algebraic excitation */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : gain of the innovation (used for normalization) */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */ - const int16_t L_subfr /* i : subframe length */ -); - -void gain_dec_mless( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : subframe number */ - const int16_t tc_subfr, /* i : TC subframe index */ - const float *code, /* i : algebraic code excitation */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *gain_inov, /* o : unscaled innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -void gain_dec_SQ( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t i_subfr, /* i : subframe number */ - const float *code, /* i : algebraic code excitation */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *gain_inov, /* o : unscaled innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -/*! r: quantized codebook gain */ -float gain_dec_gaus( - const int16_t index, /* i : quantization index */ - const int16_t bits, /* i : number of bits to quantize */ - const float lowBound, /* i : lower bound of quantizer (dB) */ - const float topBound, /* i : upper bound of quantizer (dB) */ - const float gain_inov, /* i : unscaled innovation gain */ - float *norm_gain_code /* o : gain of normalized gaus. excit. */ -); - -/*! r: floating pitch value */ -float pit_decode_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t L_frame, /* i : length of the frame */ - int16_t i_subfr, /* i : subframe index */ - const int16_t coder_type, /* i : coding type */ - int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : close loop integer pitch */ - int16_t *T0_frac, /* o : close loop fractional part of the pitch */ - int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */ - int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const int16_t L_subfr, /* i : subframe length */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void abs_pit_dec_flt( - const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - int16_t pitch_index, /* i : pitch index */ - const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac /* o : pitch fraction */ -); - -void delta_pit_dec_flt( - const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - const int16_t pitch_index, /* i : pitch index */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - const int16_t T0_min /* i : delta search min */ -); - -void pit_Q_dec_flt( - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t pitch_index, /* i : pitch index */ - const int16_t nBits, /* i : # of Q bits */ - const int16_t delta, /* i : Half the CL searched interval */ - const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */ - const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t *T0_min, /* i/o: delta search min */ - int16_t *T0_max, /* i/o: delta search max */ - int16_t *BER_detect /* o : BER detect flag */ -); - -void pit16k_Q_dec_flt( - const int16_t pitch_index, /* i : pitch index */ - const int16_t nBits, /* i : # of Q bits */ - const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t *T0_min, /* i/o: delta search min */ - int16_t *T0_max, /* i/o: delta search max */ - int16_t *BER_detect /* o : BER detect flag */ -); - - -void inov_decode( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const int16_t i_subfr, /* i : subframe index */ - const float *p_Aq, /* i : LP filter coefficients */ - const float tilt_code, /* i : tilt of of the excitation of previous subframe */ - const float pt_pitch, /* i : pointer to current subframe fractional pitch */ - float *code, /* o : algebraic excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void dec_acelp_1t64( - Decoder_State *st, /* i/o: decoder state structure */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void dec_acelp_2t32( - Decoder_State *st, /* i/o: decoder state structure */ - float code[] /* o : algebraic (fixed) codebook excitation */ -); - -void dec_acelp_4t64( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t nbbits, /* i : number of bits per codebook */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - - -void FEC_exc_estim( - Decoder_State *st, /* i/o: Decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - float *old_exc, /* i/o: excitation buffer */ - float *exc2, /* o : excitation buffer (for synthesis) */ - float *exc_dct_in, /* o : GSC excitation in DCT domain */ - float *pitch_buf, /* o : Floating pitch for each subframe */ - float *tmp_tc, /* o : FEC pitch */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - float *lsf_new, /* i : ISFs at the end of the frame */ - float *tmp_noise /* o : long-term noise energy */ -); - -void FEC_lsf2lsp_interp_flt( - Decoder_State *st, /* i/o: Decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - float *Aq, /* o : calculated A(z) for 4 subframes */ - float *lsf, /* o : estimated LSF vector */ - float *lsp /* o : estimated LSP vector */ -); - -void FEC_lsf_estim_enc( - Encoder_State *st, /* i : Encoder static memory */ - float *lsf /* o : estimated LSF vector */ -); - -float frame_energy( - const int16_t L_frame, /* i : length of the frame */ - const float *pitch, /* i : pitch values for each subframe */ - const float *speech, /* i : pointer to speech signal for E computation */ - const float lp_speech, /* i : long term active speech energy average */ - float *frame_ener /* o : pitch-synchronous energy at frame end */ -); - -void FEC_SinOnset( - float *exc, /* i/o: exc vector to modify */ - int16_t puls_pos, /* i : Last pulse position desired */ - int16_t T0, /* i : decoded first frame pitch */ - float enr_q, /* i : energy provided by the encoder */ - float *Aq, /* i : Lsp coefficient */ - const int16_t L_frame /* i : Frame length */ -); - -int16_t FEC_enhACB( - const int16_t L_frame, /* i : Frame length */ - const int16_t last_L_frame, /* i : frame length of last frame */ - float *exc_io, /* i/o: Adaptive codebook memory */ - const int16_t new_pit, /* i : decoded first frame pitch */ - const int16_t puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ - const float bfi_pitch /* i : Pitch used for concealment */ -); - -void FEC_scale_syn( - const int16_t L_frame, /* i : length of the frame */ - int16_t clas, /* i/o: frame classification */ - const int16_t last_good, /* i : last good frame classification */ - float *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const float *pitch, /* i : pitch values for each subframe */ - float enr_old, /* i : energy at the end of prvious frame */ - float enr_q, /* i : transmitted energy for current frame */ - const int16_t coder_type, /* i : coding type */ - const int16_t LSF_Q_prediction, /* i : LSF prediction mode */ - int16_t *scaling_flag, /* i/o: flag to indicate energy control of syn */ - float *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - float *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const int16_t bfi, /* i : current frame BFI */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t prev_bfi, /* i : previous frame BFI */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - float *exc, /* i/o: excitation signal without enhancement */ - float *exc2, /* i/o: excitation signal with enhancement */ - const float Aq[], /* i : LP filter coefs */ - float *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const float *mem_tmp, /* i : temp. initial synthesis filter states */ - float *mem_syn, /* o : initial synthesis filter states */ - const int16_t avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const int16_t force_scaling /* i : force scaling */ -); - -void FEC_pitch_estim( - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t last_core, /* i : last core */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t clas, /* i : current frame classification */ - const int16_t last_good, /* i : last good clas information */ - const float pitch_buf[], /* i : Floating pitch for each subframe */ - const float old_pitch_buf[], /* i : buffer of old subframe pitch values */ - float *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ - int16_t *bfi_pitch_frame, /* o : frame length when pitch was updated */ - int16_t *upd_cnt, /* i/o: update counter */ - const int16_t coder_type ); - -void FEC_encode( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i : configuration of the ACELP */ - const float *synth, /* i : pointer to synthesized speech for E computation */ - const int16_t coder_type, /* i : type of coder */ - int16_t clas, /* i : signal clas for current frame */ - const float *fpit, /* i : close loop fractional pitch buffer */ - const float *res, /* i : LP residual signal frame */ - int16_t *last_pulse_pos, /* i/o: Position of the last pulse */ - const int16_t L_frame, /* i : Frame length */ - const int32_t total_brate /* i : total codec bitrate */ -); - -int16_t FEC_pos_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */ - float *enr_q, /* o : Decoded energy */ - const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */ -); - -void improv_amr_wb_gs( - const int16_t clas, /* i : bitrate allocated to the core */ - const int16_t coder_type, /* i : coder_type */ - const int32_t core_brate, /* i : bitrate allocated to the core */ - int16_t *seed_tcx, /* i/o: Seed used for noise generation */ - float *old_Aq, /* i/o: old LPC filter coefficient */ - float *mem_syn2, /* i/o: synthesis memory */ - const float lt_voice_fac, /* i/o: long term voice factor */ - const int16_t locattack, /* i : Flag for a detected attack */ - float *Aq, /* i/o: Decoded LP filter coefficient */ - float *exc2, /* i/o: Decoded complete excitation */ - float *mem_tmp, /* i/o: synthesis temporary memory */ - float *syn, /* i/o: Decoded synthesis to be updated */ - const float *pitch_buf, /* i : Decoded pitch buffer */ - const float Last_ener, /* i : Last energy */ - const int16_t rate_switching_reset, /* i : rate switching reset flag */ - const int16_t last_coder_type, /* i : Last coder_type */ - const int16_t VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ -); - -int16_t tc_classif( - Decoder_State *st /* i/o: decoder state structure */ -); - -void transition_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t tc_subfr, /* i : TC subframe index */ - int16_t *Jopt_flag, /* i : joint optimization flag */ - float *exc, /* i/o: current frame excitation signal */ - int16_t *T0, /* o : close loop integer pitch */ - int16_t *T0_frac, /* o : close loop fractional part of the pitch */ - int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */ - int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */ - float **pt_pitch, /* o : floating pitch values */ - int16_t *position, /* i/o: first glottal impulse position in frame */ - float *bwe_exc /* i/o: excitation for SWB TBE */ -); - -void gain_dec_tc( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t i_subfr, /* i : subframe number */ - const float Es_pred, /* i : predicted scaled innov. energy */ - const float *code, /* i : algebraic code excitation */ - float *gain_pit, /* o : pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *gain_inov, /* o : unscaled innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excit. */ -); - -void stat_noise_uv_dec( - Decoder_State *st, /* i/o: decoder static memory */ - const float *lsp_new, /* i : end-frame LSP vector */ - const float *lsp_mid, /* i : mid-frame LSP vector */ - float *Aq, /* o : A(z) quantized for the 4 subframes */ - float *exc2, /* i/o: excitation buffer */ - const int16_t uc_two_stage_flag /* 1 : flag undicating two-stage UC */ -); - -void sc_vbr_dec_init_flt( - SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ -); - -void decod_nelp( - Decoder_State *st, /* i/o: decoder static memory */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *exc, /* o : adapt. excitation exc */ - float *exc2, /* o : adapt. excitation/total exc */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc, /* o : excitation for SWB TBE */ - const int16_t bfi, /* i : bad frame indicator */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -void nelp_decoder( - Decoder_State *st, /* i/o: decoder static memory */ - float *exc_nelp, /* o : adapt. excitation/total exc */ - float *exc, /* o : adapt. excitation exc */ - int16_t bfi, /* i : frame error rate */ - const int16_t coder_type, /* i : coding type */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -ivas_error decod_ppp( - Decoder_State *st, /* i/o: state structure */ - const float Aq[], /* i : 12k8 Lp coefficient */ - float *pitch_buf, /* i/o: floating pitch values for each subframe */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t bfi /* i : BFI flag */ -); - -ivas_error ppp_quarter_decoder( - Decoder_State *st, /* i/o: decoder state structure */ - DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS */ - int16_t prevCW_lag, /* i : Previous lag */ - float *lastLgainD, /* i/o: Last gain lowband */ - float *lastHgainD, /* i/o: Last gain highwband */ - float *lasterbD, /* i/o: Last ERB vector */ - int16_t bfi, /* i : FER flag */ - DTFS_STRUCTURE PREV_CW_D /* i : Previous DTFS */ -); - -ivas_error ppp_voiced_decoder( - Decoder_State *st, /* i/o: state structure */ - float *out, /* o : residual signal */ - const float *lpc2, /* i : current frame LPC */ - float *exc, /* i : previous frame excitation */ - float *pitch, /* o : floating pitch values for each subframe */ - const int16_t bfi /* i : BFI flag */ -); - -void AVQ_demuxdec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t xriq[], /* o : decoded subvectors [0..8*Nsv-1] */ - int16_t *nb_bits, /* i/o: number of allocated bits */ - const int16_t Nsv, /* i : number of subvectors */ - int16_t nq[], /* i/o: AVQ nq index */ - int16_t avq_bit_sFlag, /* i : flag for AVQ bit saving solution*/ - int16_t trgtSvPos /* i : target SV for AVQ bit savings */ -); - - -void Init_post_filter_ivas( - PFSTAT_HANDLE hPFstat /* i : post-filter state memories */ -); - -void nb_post_filt_ivas( - const int16_t L_frame, /* i : frame length */ - const int16_t L_subfr, /* i : sub-frame length */ - PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */ - float *lp_noise, /* i/o: long term noise energy */ - const float tmp_noise, /* i : noise energy */ - float *synth, /* i/o: synthesis */ - const float *Aq, /* i : LP filter coefficient */ - const float *pitch_buf, /* i : Floating pitch for each subframe */ - const int16_t coder_type, /* i : coder_type -> deactivated in AUDIO */ - const int16_t BER_detect, /* i : BER detect flag */ - const int16_t disable_hpf /* i : flag to diabled HPF */ -); - -void decod_unvoiced( - Decoder_State *st, /* i/o: decoder static memory */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* o : adapt. excitation exc */ - float *exc2, /* o : adapt. excitation/total exc */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - float *gain_buf /* o : floating pitch gain for each subfram */ -); - -void decod_tran( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t tc_subfr, /* i : TC subframe index */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - int16_t *unbits, /* i/o: number of unused bits */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -ivas_error decod_gen_voic( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - const int16_t do_WI, /* i : FEC fast recovery flag */ - float *pitch_buf, /* o : floating pitch for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - int16_t *unbits, /* i/o: number of unused bits */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void decod_amr_wb( - Decoder_State *st, /* i/o: decoder static memory */ - const float *Aq, /* i : LP filter coefficients */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */ - float *voice_factors, /* o : voicing factors */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -ivas_error init_decoder( - Decoder_State *st, /* o : Decoder static variables structure */ - const int16_t idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ -); - -void destroy_cldfb_decoder_flt( - Decoder_State *st /* o : Decoder static variables structure */ -); - -void HQ_core_dec_init_flt( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -); - -void HQ_nbfec_init_flt( - HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ -); - -ivas_error evs_dec( - Decoder_State *st, /* i/o: Decoder state structure */ - float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */ - float *output, /* o : output synthesis signal */ - FRAME_MODE frameMode /* i : Decoder frame mode */ -); - -void get_next_frame_parameters( - Decoder_State *st /* i/o: Decoder state structure */ -); - -ivas_error amr_wb_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */ - float *output /* o : synthesis output */ -); - -void transf_cdbk_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const int16_t i_subfr, /* i : subframe index */ - const float Es_pred, /* i : predicited scaled innovation energy */ - const float gain_code, /* i : innovative excitation gain */ - float *gain_preQ, /* o : prequantizer excitation gain */ - float *norm_gain_preQ, /* o : normalized prequantizer excitation gain */ - float code_preQ[], /* o : prequantizer excitation */ - int16_t *unbits /* o : number of AVQ unused bits */ -); - -/*! r: decoded gain */ -float gain_dequant( - int16_t index, /* i : quantization index */ - const float min_val, /* i : value of lower limit */ - const float max_val, /* i : value of upper limit */ - const int16_t bits /* i : number of bits to dequantize */ -); - -void hq_core_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float *audio, /* i : input audio signal */ - const int16_t input_frame, /* i : frame length */ - const int16_t hq_core_type, /* i : HQ core type */ - const int16_t Voicing_flag, /* i : Voicing flag for FER method selection */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -int16_t detect_transient( - Encoder_State *st, /* i/o: encoder state structure */ - const float *in, /* i : input signal */ - const int16_t L /* i : length */ -); - -void wtda( - const float *new_audio, /* i : input audio */ - float *wtda_audio, /* o : windowed audio */ - float *old_wtda, /* i/o: windowed audio from previous frame */ - const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const int16_t L /* i : length */ -); - -void wtda_ext( - const float *new_audio, /* i : input audio */ - float *wtda_audio, /* o : windowed audio */ - const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const int16_t L, /* i : length */ - const uint16_t kernel_type /* i : transform kernel type (0 - 3) */ -); - -void tcx_get_windows_mode1_flt( - const int16_t left_mode, /* i : overlap mode of left window half */ - const int16_t right_mode, /* i : overlap mode of right window half */ - float *left_win, /* o : left overlap window */ - float *right_win, /* o : right overlap window */ - float *left_win_int, /* o : left overlap window */ - float *right_win_int, /* o : right overlap window */ - const int16_t L /* i : length */ -); - -void direct_transform( - const float *in32, /* i : input signal */ - float *out32, /* o : output transformation */ - const int16_t is_transient, /* i : transient flag */ - const int16_t L, /* i : length */ - const int16_t element_mode /* i : IVAS element mode */ -); - - -void interleave_spectrum( - float *coefs, /* i/o: input and output coefficients */ - const int16_t length /* i : length of spectrum */ -); - -void hq_hr_enc( - Encoder_State *st, /* i/o: encoder state structure */ - float *coefs, /* i/o: transform-domain coefficients */ - const int16_t length, /* i : length of spectrum */ - int16_t *num_bits, /* i/o: number of available bits */ - const int16_t is_transient, /* i : transient flag */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void huff_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : Number of codewords to decode */ - const int16_t buffer_len, /* i : Number of bits to read */ - const int16_t num_lengths, /* i : Number of different huffman codeword lengths */ - const int16_t *thres, /* i : Threshold of first codeword of each length */ - const int16_t *offset, /* i : Offset for first codeword */ - const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */ - int16_t *index /* o : Decoded index */ -); - -void reordernorm( - const int16_t *ynrm, /* i : quantization indices for norms */ - const int16_t *normqlg2, /* i : quantized norms */ - int16_t *idxbuf, /* o : reordered quantization indices */ - int16_t *normbuf, /* o : reordered quantized norms */ - const int16_t nb_sfm /* i : number of bands */ -); - -void diffcod( - const int16_t N, /* i : number of sub-vectors */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx /* o : differential code */ -); - -void diffcod_lrmdct( - const int16_t N, /* i : number of sub-vectors */ - const int16_t be_ref, /* i : band energy reference */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx, /* o : differential code */ - const int16_t is_transient /* i : transient flag */ -); - -void bitallocsum( - int16_t *R, /* i : bit-allocation vector */ - const int16_t nb_sfm, /* i : number of sub-vectors */ - int16_t *sum, /* o : total number of bits allocated */ - int16_t *Rsubband, /* o : rate per subband (Q3) */ - const int16_t num_bits, /* i : number of bits */ - const int16_t length, /* i : length of spectrum */ - const int16_t *sfmsize /* i : Length of bands */ -); -/*! r: BWE class */ -int16_t swb_bwe_gain_deq_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t core, /* i : core */ - float *SWB_tenv, /* o : time-domain BWE envelope */ - float *SWB_fenv, /* o : frequency-domain BWE envelope */ - const int16_t hr_flag, /* i : high rate flag */ - const int16_t hqswb_clas /* i : HQ BWE class */ -); - -void save_old_syn( - const int16_t L_frame, /* i : frame length */ - const float syn[], /* i : ACELP synthesis */ - float old_syn[], /* o : old synthesis buffer */ - float old_syn_12k8_16k[], /* i/o: old synthesis buffer */ - const float preemph_fac, /* i : preemphasis factor */ - float *mem_deemph /* i/o: deemphasis filter memory */ -); - -void hq_generic_hf_decoding( - const int16_t HQ_mode, /* i : HQ mode */ - float *coeff_out1, /* i/o: BWE input & temporary buffer */ - const float *hq_generic_fenv, /* i : SWB frequency envelopes */ - float *coeff_out, /* o : SWB signal in MDCT domain */ - const int16_t hq_generic_offset, /* i : frequency offset for representing hq swb bwe*/ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - const int16_t hq_swb_bwe_exc_clas, /* i : bwe excitation class */ - const int16_t *R ); - -void hq_core_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float out[], /* o : output synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t hq_core_type, /* i : HQ core type */ - const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ - float *output /* o : LB synthesis in case of ACELP-HQ switch */ -); - -void IMDCT( - float *x, - float *old_syn_overl, - float *syn_Overl_TDAC, - float *xn_buf, - const float *tcx_aldo_window_1_trunc, - const float *tcx_aldo_window_2, - const float *tcx_mdct_window_half, - const float *tcx_mdct_window_minimum, - const float *tcx_mdct_window_trans, - const int16_t tcx_mdct_window_half_length, - const int16_t tcx_mdct_window_min_length, - int16_t index, - const uint16_t kernel_type, /* i : TCX transform kernel type */ - const int16_t left_rect, - const int16_t tcx_offset, - const int16_t overlap, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t L_spec_TCX5, - const int16_t L_frame_glob, - const int16_t frame_cnt, - const int16_t bfi, - float *old_out, - const int16_t FB_flag, - Decoder_State *st, - const int16_t fullband, - float *acelp_zir ); - -void hq_hr_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *t_audio_q, /* o : transform-domain coefficients */ - const int16_t length, /* i : frame length */ - const int16_t num_bits, /* i : number of available bits */ - int16_t *ynrm, /* o : norm quantization index vector */ - int16_t *is_transient, /* o : transient flag */ - int16_t *hqswb_clas, /* o : HQ SWB class */ - float *SWB_fenv, /* o : SWB frequency envelopes */ - const int16_t core_switching_flag /* i : Core switching flag */ - -); - -void hdecnrm_context( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of norms */ - int16_t *index, /* o : indices of quantized norms */ - int16_t *n_length /* o : decoded stream length */ -); - -void hdecnrm_tran( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of norms */ - int16_t *index /* o : indices of quantized norms */ -); - -void hdecnrm_resize( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of SFMs */ - int16_t *index /* o : norm quantization index vector */ -); - -void hdecnrm( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of norms */ - int16_t *index /* o : indices of quantized norms */ -); - -/*! r: index of last band */ -int16_t find_last_band( - const int16_t *bitalloc, /* i : bit allocation */ - const int16_t nb_sfm /* i : number of possibly coded bands */ -); - -void fill_spectrum( - float *coeff, /* i/o: normalized MLT spectrum / nf spectrum */ - int16_t *R, /* i : number of pulses per band */ - const int16_t is_transient, /* i : transient flag */ - int16_t norm[], /* i : quantization indices for norms */ - const float *hq_generic_fenv, /* i : HQ GENERIC envelope */ - const int16_t hq_generic_offset, /* i : HQ GENERIC offset */ - const int16_t nf_idx, /* i : noise fill index */ - const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */ - const float env_stab, /* i : Envelope stability measure [0..1] */ - int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */ - float *energy_lt, /* i/o: Long-term energy measure for transient detection */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - const int16_t hq_generic_exc_clas, /* i : HF excitation class */ - const int16_t core_sfm, /* i : index of the end band for core */ - int16_t HQ_mode, /* i : HQ mode */ - float noise_level[], /* i : noise level for harmonic modes */ - int32_t core_brate, /* i : target bitrate */ - float prev_noise_level[], /* i/o: noise factor in previous frame */ - int16_t *prev_R, /* i/o: bit allocation info. in previous frame */ - float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */ - const int16_t *peak_idx, /* i : peak positions */ - const int16_t Npeaks, /* i : number of peaks */ - const int16_t *npulses, /* i : Number of assigned pulses per band */ - int16_t prev_is_transient, /* i : previous transient flag */ - float *prev_normq, /* i : previous norms */ - float *prev_env, /* i : previous noise envelopes */ - int16_t prev_bfi, /* i : previous bad frame indicator */ - const int16_t *sfmsize, /* i : Length of bands */ - const int16_t *sfm_start, /* i : Start of bands */ - const int16_t *sfm_end, /* i : End of bands */ - int16_t *prev_L_swb_norm, /* i/o: last normalize length for harmonic mode */ - int16_t prev_hq_mode, /* i : previous HQ mode */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t num_env_bands, /* i : Number of envelope bands */ - const int16_t element_mode /* i : element mode */ -); - -void de_interleave_spectrum( - float *coefs, /* i/o: input and output coefficients */ - int16_t length /* i : length of spectrum */ -); - -void inverse_transform( - const float *InMDCT, /* i : input MDCT vector */ - float *Out, /* o : output vector */ - const int16_t IsTransient, /* i : transient flag */ - const int16_t L, /* i : output frame length */ - const int16_t L_inner, /* i : length of the transform */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void window_ola( - const float *ImdctOut, /* i : input */ - float *auOut, /* o : output audio */ - float *OldauOut, /* i/o: audio from previous frame */ - const int16_t L, /* i : length */ - const int16_t right_mode, - const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const int16_t use_bfi_win, /* i : use BFI windowing */ - const int16_t oldHqVoicing, /* i : previous HqVoicing */ - float *oldgapsynth /* i : previous gapsynth */ -); - -void window_ola_ext( - const float *ImdstOut, /* i : input */ - float *auOut, /* o : output audio */ - float *OldauOut, /* i/o: audio from previous frame */ - const int16_t L, /* i : length */ - const int16_t right_mode, - const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const uint16_t kernel_type /* i : transform kernel type */ -); - -void map_quant_weight( - const int16_t normqlg2[], /* i : quantized norms */ - int16_t wnorm[], /* o : weighted norm */ - const int16_t is_transient /* i : transient flag */ -); - -void recovernorm( - const int16_t *const idxbuf, /* i : reordered quantization indices */ - int16_t *ynrm, /* o : recovered quantization indices */ - int16_t *normqlg2, /* o : recovered quantized norms */ - const int16_t nb_sfm /* i : number of subbands */ -); - -void reordvct( - int16_t *y, /* i/o: vector to rearrange */ - const int16_t N, /* i : dimensions */ - int16_t *idx /* o : reordered vector index */ -); - -void bitalloc( - int16_t *y, /* i : reordered norm of sub-vectors */ - int16_t *idx, /* i : reordered sub-vector indices */ - int16_t sum, /* i : number of available bits */ - int16_t N, /* i : number of norms */ - int16_t K, /* i : maximum number of bits per dimension */ - int16_t *r, /* o : bit-allacation vector */ - const int16_t *sfmsize, /* i : Length of bands */ - const int16_t hqswb_clas /* i : signal classification flag */ -); - -/*! r: Integer (truncated) number of allocated bits */ -int16_t BitAllocF( - int16_t *y, /* i : norm of sub-vectors */ - int32_t bit_rate, /* i : bitrate */ - int16_t B, /* i : number of available bits */ - int16_t N, /* i : number of sub-vectors */ - int16_t *R, /* o : bit-allocation indicator */ - int16_t *Rsubband, /* o : sub-band bit-allocation vector (Q3) */ - const int16_t hqswb_clas, /* i : hq swb class */ - const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ -); - -/*! r: Integer (truncated) number of allocated bits */ -int16_t BitAllocWB( - int16_t *y, /* i : norm of sub-vectors */ - int16_t B, /* i : number of available bits */ - int16_t N, /* i : number of sub-vectors */ - int16_t *R, /* o : bit-allocation indicator */ - int16_t *Rsubband ); /* o : sub-band bit-allocation vector (Q3) */ - -/*! r: Number of low frequency bands */ -int16_t hvq_pvq_bitalloc( - int16_t num_bits, /* i/o: Number of available bits (including gain bits) */ - const int32_t core_brate, /* i : bitrate */ - const int16_t bwidth, /* i : Encoded bandwidth */ - const int16_t *ynrm, /* i : Envelope coefficients */ - const int32_t manE_peak, /* i : Peak energy mantissa */ - const int16_t expE_peak, /* i : Peak energy exponent */ - int16_t *Rk, /* o : bit allocation for concatenated vector */ - int16_t *R, /* i/o: Global bit allocation */ - int16_t *sel_bands, /* o : Selected bands for encoding */ - int16_t *n_sel_bands /* o : No. of selected bands for encoding */ -); - -void floating_point_add_float( - int32_t *mx, /* i/o: mantissa of the addend Q31 */ - int16_t *ex, /* i/o: exponent of the addend Q0 */ - const int32_t my, /* i : mantissa of the adder Q31 */ - const int16_t ey /* i : exponent of the adder Q0 */ -); - -/*! r: Number of bits needed */ -int16_t rc_get_bits2( - const int16_t N, /* i : Number of bits currently used */ - const uint32_t range /* i : Range of range coder */ -); - -void rc_enc_init( - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - int16_t tot_bits /* i : Total bit budget */ -); - -void rc_encode( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const uint32_t cum_freq, /* i : Cumulative frequency up to symbol */ - const uint32_t sym_freq, /* i : Symbol probability */ - const uint32_t tot /* i : Total cumulative frequency */ -); - -void rc_enc_finish( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ -); - -void rc_enc_bits( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const uint32_t value, /* i : Value to encode */ - const int16_t bits /* i : Number of bits used */ -); - -void rc_enc_uniform( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - uint32_t value, /* i : Value to encode */ - uint32_t tot /* i : Maximum value */ -); - -void rc_dec_init( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - int16_t tot_bits /* i : Total bit budget */ -); - -/*! r: Decoded value */ -uint32_t rc_decode( - int16_t *BER_detect, /* o : Bit error detection flag */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - uint32_t tot /* i : Total cumulative frequency */ -); - -void rc_dec_update( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - const uint32_t cum_freq, /* i : Cumulative frequency */ - const uint32_t sym_freq /* i : Symbol frequency */ -); - -/*! r: Decoded value */ -uint32_t rc_dec_bits( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - const int16_t bits /* i : Number of bits */ -); - -/*! r: Decoded value */ -uint32_t rc_dec_uniform( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - const uint32_t tot /* i : Maximum value */ -); - -void rc_dec_finish( - Decoder_State *st, /* i/o: decoder state structure */ - PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ -); - -/*! r: number of bits encoded */ -int16_t pvq_core_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - float coefs_norm[], /* i/o: normalized coefficients to encode */ - float coefs_quant[], /* o : quantized coefficients */ - const int16_t bits_tot, /* i : total number of bits */ - const int16_t nb_sfm, /* i : number of bands */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfmsize, /* i : subband width */ - int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */ - int16_t *Rs, /* i/o: Integer bit allocation */ - int16_t *npulses, /* o : number of pulses */ - int16_t *maxpulse, /* i : maximum pulse per band */ - const int16_t core /* i : number of bands */ -); - -/*! r: number of bits decoded */ -int16_t pvq_core_dec( - Decoder_State *st, /* i/o: Decoder state */ - const int16_t *sfm_start, /* i : indices of first coeffs in the bands */ - const int16_t *sfm_end, /* i : indices of last coeffs in the bands */ - const int16_t *sfmsize, /* i : band sizes */ - float coefs_quant[], /* o : output MDCT */ - const int16_t bits_tot, /* i : bit budget */ - const int16_t nb_sfm, /* i : number of bands */ - int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */ - int16_t *Rs, /* i/o: Integer bit allocation */ - int16_t *npulses, /* o : number of pulses per band */ - int16_t *maxpulse, /* o : maximum pulse per band */ - const int16_t core /* i : core */ -); - -void pvq_encode( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const float *x, /* i : vector to quantize */ - int16_t *y, /* o : quantized vector (non-scaled integer)*/ - float *xq, /* o : quantized vector (scaled float) */ - const int16_t pulses, /* i : number of allocated pulses */ - const int16_t N, /* i : Length of vector */ - const float gain /* i : Gain */ -); - -void pvq_decode( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - float *xq, /* o : decoded vector (scaled float) */ - int16_t *y, /* o : decoded vector (non-scaled short)*/ - const int16_t K, /* i : number of allocated pulses */ - const int16_t N, /* i : Length of vector */ - const float gain /* i : Gain */ -); - -void rangeCoderFinalizationFBits( - const int16_t Brc, /* i : Current number of decoded bits */ - const uint32_t INTrc, /* i : Range coder state */ - int16_t *FBits /* i : Fractional finalization bits */ -); - -void bandBitsAdjustment( - const int16_t Brc, /* i : Current number of read quanta in range coder */ - const uint32_t INTrc, /* i : Range coder state */ - const int16_t Bavail, /* i : Available number of quanta */ - const int16_t Nbands, /* i : Number of bands */ - const int16_t D, /* i : Remaining number of bands to encode */ - const int16_t L, /* i : Size of current band */ - const int16_t Bband, /* i : Quanta allocation for current band */ - const int16_t Breserv, /* i : Quanta reservoir */ - int16_t *Bband_adj, /* o : Actual used number of quanta */ - int16_t *Brem, /* o : Quanta remaining */ - int16_t *Breservplus /* o : Quanta pool size */ -); - -void conservativeL1Norm( - const int16_t L, /* i : Length of vector segment */ - const int16_t Qvec, /* i : Assigned number of quanta */ - const int16_t Fcons, /* i : Conservative rounding flag */ - const int16_t Qavail, /* i : Input quanta remaining */ - const int16_t Qreserv, /* i : Input quanta in reservoir */ - const int16_t Dspec, /* i : assigned diracs from bitalloc */ - int16_t *Dvec, /* o : actual number of diracs */ - int16_t *Qspare, /* o : Output quanta remaining */ - int16_t *Qreservplus, /* o : Output quanta in reservoir */ - int16_t *Dspecplus /* o : Output number of diracs */ -); - -void NearOppSplitAdjustment( - const int16_t qband, /* i : quanta for current band */ - const int16_t qzero, /* i : range coder finalization quanta */ - const int16_t Qac, /* i : range coder current quanta */ - const uint32_t INTac, /* i : range coder state */ - const int16_t qglobal, /* i : quanta input */ - const int16_t FlagCons, /* i : conservative rounding flag */ - const int16_t Np, /* i : number of parts */ - const int16_t Nhead, /* i : first part */ - const int16_t Ntail, /* i : remaining parts */ - const int16_t Nnear, /* i : length of near component */ - const int16_t Nopp, /* i : length of opposite component */ - int16_t oppRQ3, /* i : ratio */ - int16_t *qnear, /* o : quantized near */ - int16_t *qopp, /* o : quantized opposite */ - int16_t *qglobalupd /* o : quanta remaining */ -); - -/*! r: Approximate integer division for positive input */ -int32_t intLimCDivPos( - const int32_t NUM, /* i : numerator */ - const int16_t DEN /* i : denominator */ -); - -/*! r: Approximate integer division */ -int16_t shrtCDivSignedApprox_flt( - const int16_t num, /* i : numerator */ - const int16_t den /* i : denominator */ -); - -void QuantaPerDsDirac( - const int16_t td, /* i : Length of vector segment */ - const int16_t dsDiracIndex, /* i : Quanta table index */ - const uint8_t *const *dimFrQuanta, /* i : Quanta lookup table */ - int16_t *Quanta /* i : Quanta */ -); - -void obtainEnergyQuantizerDensity( - const int16_t L_in, /* i : left vector energy */ - const int16_t R_in, /* i : right vector energy */ - int16_t *Density /* o : quantizer density */ -); - -void densityAngle2RmsProjDec( - const int16_t D, /* i : density */ - const int16_t indexphi, /* i : decoded index from AR dec */ - int16_t *oppQ15, /* o : opposite */ - int16_t *nearQ15, /* o : near */ - int16_t *oppRatioQ3 /* o : ratio */ -); - -void densityAngle2RmsProjEnc( - const int16_t D, /* i : density */ - const int16_t phiQ14uq, /* i : angle */ - int16_t *indexphi, /* o : index */ - int16_t *oppQ15, /* o : opposite */ - int16_t *nearQ15, /* o : near */ - int16_t *oppRatioQ3 /* o : ratio */ -); - -void env_adj( - const int16_t *pulses, /* i : number of pulses per band */ - const int16_t length, /* i : length of spectrum */ - const int16_t last_sfm, /* i : Index of last band */ - float *adj, /* o : Adjustment factors for the envelope */ - const float env_stab, /* i : Envelope stability parameter */ - const int16_t *sfmsize /* i : Length of bands */ -); - -float env_stability( - const int16_t *ynrm, /* i : Norm vector for current frame */ - const int16_t nb_sfm, /* i : Number of sub-bands */ - int16_t *mem_norm, /* i/o: Norm vector memory from past frame */ - int16_t *mem_env_delta, /* i/o: Envelope stability memory for smoothing*/ - const int16_t core_switching_flag /* i : Core switching flag */ -); - -/*! r: New speech/music state */ -float env_stab_smo( - float env_stab, /* i : env_stab value */ - float *env_stab_state_p, /* i/o: env_stab state probabilities */ - int16_t *ho_cnt /* i/o: hangover counter for speech state */ -); -void core_switching_post_enc( - Encoder_State *st, /* i/o: encoder state structure */ - // const float *old_inp_12k8, /* i : old input signal @12.8kHz */ - float *old_inp_12k8, /* i : old input signal @12.8kHz */ - // const float *old_inp_16k, /* i : old input signal @16kHz */ - float *old_inp_16k, /* i : old input signal @16kHz */ - // const float A[] /* i : unquant. LP filter coefs. */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new ); -ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t output_frame, /* i : frame length */ - const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ - const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t last_element_mode /* i : element mode of previous frame */ -); - -ivas_error core_switching_pre_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t output_frame, /* i : frame length */ - const int32_t last_core_brate_st0, /* i : channel 0 last core bitrate */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t last_element_mode, /* i : last_element_mode */ - const int32_t last_element_brate /* i : last element bitrate */ -); - -void bandwidth_switching_detect( - Decoder_State *st /* i/o: decoder state structure */ -); - -void bw_switching_pre_proc( - Decoder_State *st, /* i/o: decoder state structure */ - const float *old_syn_12k8_16k, /* i : ACELP core synthesis @ 12.8kHz or 16kHz */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t nchan_out /* i : number of output channels */ -); - -void updt_bw_switching( - Decoder_State *st, /* i/o: decoder state structure */ - const float *synth /* i : float synthesis signal */ -); - -void swb_tbe_reset( - float mem_csfilt[], - float mem_genSHBexc_filt_down_shb[], - float state_lpc_syn[], - float syn_overlap[], - float state_syn_shbexc[], - float *tbe_demph, - float *tbe_premph, - float mem_stp_swb[], - float *gain_prec_swb ); - -void swb_tbe_reset_synth( - float genSHBsynth_Hilbert_Mem[], - float genSHBsynth_state_lsyn_filt_shb_local[] ); - -void find_td_envelope( - const float inp[], - const int16_t len, - const int16_t len_h, - float mem_h[], - float out[] ); - -void fb_tbe_reset_enc( - float elliptic_bpf_2_48k_mem[][4], - float *prev_fb_energy ); - -void fb_tbe_reset_synth( - float fbbwe_hpf_mem[][4], - float *prev_fbbwe_ratio ); - -void wb_tbe_extras_reset( - float mem_genSHBexc_filt_down_wb2[], - float mem_genSHBexc_filt_down_wb3[] ); - -void wb_tbe_extras_reset_synth( - float state_lsyn_filt_shb[], - float state_lsyn_filt_dwn_shb[], - float mem_resamp_HB[] ); - -void tbe_celp_exc_flt( - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - float *bwe_exc, /* i/o: BWE excitation */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_subfr, /* i : subframe length */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t T0, /* i : integer pitch lag */ - const int16_t T0_frac, /* i : fraction of lag */ - float *error, /* i/o: error */ - const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -void prep_tbe_exc( - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_subfr, /* i : subframe length */ - const int16_t i_subfr, /* i : subframe index */ - const float gain_pit, /* i : Pitch gain */ - const float gain_code, /* i : algebraic codebook gain */ - const float code[], /* i : algebraic excitation */ - const float voice_fac, /* i : voicing factor */ - float *voice_factors, /* o : TBE voicing factor */ - float bwe_exc[], /* i/o: excitation for TBE */ - const float gain_preQ, /* i : prequantizer excitation gain */ - const float code_preQ[], /* i : prequantizer excitation */ - const int16_t T0, /* i : integer pitch variables */ - const int16_t coder_type, /* i : coding type */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - const int16_t flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -void synthesise_fb_high_band( - const float excitation_in[], /* i : full band excitation */ - float output[], /* o : high band speech - 14.0 to 20 kHz */ - const float fb_exc_energy, /* i : full band excitation energy */ - const float ratio_float, /* i : energy ratio */ - const int16_t L_frame, /* i : ACELP frame length */ - const int16_t bfi, /* i : BFI flag */ - float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ - float bpf_memory[][4] /* i/o: memory for elliptic bpf 48k */ -); - -void elliptic_bpf_48k_generic( - const float input[], /* i : input signal */ - float output[], /* o : output signal */ - float memory[][4], /* i/o: 4 arrays for memory */ - const float full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 */ -); - -void HQ_FEC_processing( - Decoder_State *st, /* i/o: decoder state structure */ - float *t_audio_q, /* o : MDCT coeffs. (for synthesis) */ - int16_t is_transient, /* i : Old flag for transient */ - float ynrm_values[][MAX_PGF], /* i : Old average Norm values for each group of bands */ - float r_p_values[][MAX_ROW], /* i : Computed y-intercept and slope by Regression */ - int16_t num_Sb, /* i : Number of sub-band group */ - int16_t nb_sfm, /* i : Number of sub-band */ - int16_t *Num_bands_p, /* i : Number of coeffs. for each sub-band */ - int16_t output_frame, /* i : Frame size */ - const int16_t *sfm_start, /* i : Start of bands */ - const int16_t *sfm_end /* i : End of bands */ -); - -void HQ_FEC_Mem_update( - Decoder_State *st, /* i/o: decoder state structure */ - const float *t_audio_q, - float *normq, - int16_t *ynrm, - const int16_t *Num_bands_p, - const int16_t is_transient, - const int16_t hqswb_clas, - const int16_t c_switching_flag, - const int16_t nb_sfm, - const int16_t num_Sb, - float *mean_en_high, - const int16_t hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - const int16_t output_frame /* i : Frame size */ -); - -void time_domain_FEC_HQ( - Decoder_State *st, /* i : Decoder State */ - float *wtda_audio, /* i : input */ - float *out, /* o : output audio */ - const float mean_en_high, /* i : transient flag */ - const int16_t output_frame /* i : Frame size */ -); - -void save_synthesis_hq_fec( - Decoder_State *st, /* i/o: decoder state structure */ - const float *output, /* i : decoded synthesis */ - const int16_t output_frame, /* i : decoded synthesis */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ -); - -void Next_good_after_burst_erasures( - const float *ImdctOut, /* i : input */ - float *auOut, /* o : output audio */ - float *OldauOut, /* i/o: audio from previous frame */ - const int16_t ol_size /* i : overlap size */ -); - - -void reset_preecho_dec( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle */ -); - -void preecho_sb( - const int32_t core_brate, /* i : core bitrate */ - const float wtda_audio[], /* i : imdct signal */ - float *rec_sig, /* i : reconstructed signal, output of the imdct transform */ - const int16_t framelength, /* i : frame length */ - float *memfilt_lb, /* i/o: memory */ - float *mean_prev_hb, /* i/o: memory */ - float *smoothmem, /* i/o: memory */ - float *mean_prev, /* i/o: memory */ - float *mean_prev_nc, /* i/o: memory */ - float *wmold_hb, /* i/o: memory */ - int16_t *prevflag, /* i/o: flag */ - int16_t *pastpre, /* i/o: flag */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void hq2_core_configure( - const int16_t frame_length, /* i : frame length */ - const int16_t num_bits, /* i : number of bits */ - const int16_t is_transient, /* i : transient flag */ - int16_t *bands, - int16_t *length, - int16_t band_width[], - int16_t band_start[], - int16_t band_end[], - Word32 *L_qint, /* o : Q29 */ - Word16 *eref_fx, /* o : Q10 */ - Word16 *bit_alloc_weight_fx, /* o : Q13 */ - int16_t *gqlevs, - int16_t *Ngq, - int16_t *p2a_bands, - float *p2a_th, - float *pd_thresh, - float *ld_slope, - float *ni_coef, - float *ni_pd_th, - int32_t bwe_br ); - -void hq_lr_enc( - Encoder_State *st, /* i/o: encoder state structure */ - float t_audio[], /* i/o: transform-domain coefs. */ - const int16_t inner_frame, /* i : inner frame length */ - int16_t *num_bits, /* i/o: number of available bits */ - const int16_t is_transient /* i : transient flag */ -); - -void hq_lr_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float yout[], /* o : transform-domain output coefs. */ - const int16_t inner_frame, /* i : inner frame length */ - int16_t num_bits, /* i : number of available bits */ - int16_t *is_transient /* o : transient flag */ -); - -void hq2_bit_alloc( - const float band_energy[], /* i : band energy of each subband */ - const int16_t bands, /* i : total number of subbands in a frame */ - Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */ - int16_t *bit_budget, /* i/o: bit bugdet */ - int16_t *p2a_flags, /* i : HF tonal indicator */ - const Word16 weight_fx, /* i : weight (Q13) */ - const int16_t band_width[], /* i : Sub band bandwidth */ - const int16_t num_bits, /* i : available bits */ - const int16_t hqswb_clas, /* i : HQ2 class information */ - const int16_t bwidth, /* i : input bandwidth */ - const int16_t is_transient /* i : indicator HQ_TRANSIENT or not */ -); - -void hq2_noise_inject( - float y2hat[], - const int16_t band_start[], - const int16_t band_end[], - const int16_t band_width[], - float Ep[], - float Rk[], - const int16_t npulses[], - int16_t ni_seed, - const int16_t bands, - const int16_t ni_start_band, - const int16_t bw_low, - const int16_t bw_high, - const float enerL, - const float enerH, - float last_ni_gain[], - float last_env[], - int16_t *last_max_pos_pulse, - int16_t *p2a_flags, - int16_t p2a_bands, - const int16_t hqswb_clas, - const int16_t bwidth, - const int32_t bwe_br ); - -void mdct_spectrum_denorm( - const int32_t inp_vector[], - float y2[], - const int16_t band_start[], - const int16_t band_end[], - const int16_t band_width[], - const float band_energy[], - const int16_t npulses[], - const int16_t bands, - const float ld_slope, - const float pd_thresh ); - -void reverse_transient_frame_energies( - float band_energy[], /* o : band energies */ - const int16_t bands /* i : number of bands */ -); - - -void hvq_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t num_bits, /* i : Number of available bits */ - const int32_t core_brate, /* i : Core bitrate */ - const int16_t *ynrm, /* i : Envelope coefficients */ - int16_t *R, /* i/o: Bit allocation/updated bit allocation */ - float *noise_level, /* o : Noise level */ - int16_t *peak_idx, /* o : Peak position vector */ - int16_t *Npeaks, /* o : Total number of peaks */ - float *coefsq_norm, /* o : Output vector */ - const int16_t core /* i : Core */ -); - -void hq_configure_bfi( - int16_t *nb_sfm, /* o : Number of sub bands */ - int16_t *num_Sb, /* o : Number of FEC sub bands ? */ - int16_t *num_bands_p, /* o : FEC sub bands */ - const int16_t **sfmsize, /* o : Subband bandwidths */ - const int16_t **sfm_start, /* o : Subband start coefficients */ - const int16_t **sfm_end /* o : Subband end coefficients */ -); - -void swb_bwe_enc_lr( - Encoder_State *st, /* i/o: encoder state structure */ - const float m_core[], /* i : core synthesis (MDCT) */ - const float m_orig[], /* i/o: scaled orig signal (MDCT) */ - float m[], /* o : output, SWB part (MDCT) */ - const int32_t total_brate, /* i : total bitrate for selecting subband pattern */ - int16_t BANDS, - int16_t *band_start, - int16_t *band_end, - float *band_energy, - int16_t *p2a_flags, - const int16_t hqswb_clas, - int16_t lowlength, - int16_t highlength, - int16_t *prev_frm_index, - const int16_t har_bands, - int16_t *prev_frm_hfe2, - int16_t *prev_stab_hfe2, - int16_t band_width[], - const float y2_ni[], - int16_t *ni_seed ); - -void swb_bwe_dec_lr( - Decoder_State *st, /* i/o: decoder state structure */ - const float m_core[], /* i : lowband synthesis */ - float m[], /* o : highband synthesis with lowband zeroed */ - const int32_t total_brate, /* i : total bitrate for selecting subband pattern */ - int16_t BANDS, - int16_t *band_start, - int16_t *band_end, - float *band_energy, - int16_t *p2a_flags, - const int16_t hqswb_clas, - int16_t lowlength, - int16_t highlength, - const int16_t har_bands, - int16_t *prev_frm_hfe2, - int16_t *prev_stab_hfe2, - int16_t band_width[], - const float y2_ni[], - int16_t *ni_seed ); - -int16_t get_usebit_npswb( - const int16_t hqswb_clas ); - -void GetPredictedSignal( - const float *predBuf, /* i : prediction buffer */ - float *outBuf, /* o : output buffer */ - const int16_t lag, /* i : prediction buffer offset */ - const int16_t fLen, /* i : length of loop (output) */ - const float gain /* i : gain to be applied */ -); - -void convert_lagIndices_pls2smp( - int16_t lagIndices_in[], - int16_t nBands_search, - int16_t lagIndices_out[], - const float sspectra[], - const int16_t sbWidth[], - const int16_t fLenLow ); - -void FindNBiggest2_simple( - const float *inBuf, /* i : input buffer (searched) */ - GainItem *g, /* o : N biggest components found */ - const int16_t nIdx, /* i : search length */ - int16_t *n, /* i : number of components searched (N biggest) */ - const int16_t N_NBIGGESTSEARCH ); - -void updat_prev_frm( - float y2[], - float t_audio[], - const int32_t bwe_br, - const int16_t length, - const int16_t inner_frame, - const int16_t bands, - const int16_t bwidth, - const int16_t is_transient, - const int16_t hqswb_clas, - int16_t *prev_hqswb_clas, - int16_t *prev_SWB_peak_pos, - int16_t prev_SWB_peak_pos_tmp[], - int16_t *prev_frm_hfe2, - int16_t *prev_stab_hfe2, - const int16_t bws_cnt ); - -void hf_parinitiz( - const int32_t total_brate, - const int16_t hqswb_clas, - int16_t lowlength, - int16_t highlength, - int16_t wBands[], - const int16_t **subband_search_offset, - const int16_t **subband_offsets, - int16_t *nBands, - int16_t *nBands_search, - int16_t *swb_lowband, - int16_t *swb_highband ); - -float spectrumsmooth_noiseton( - float spectra[], - const float spectra_ni[], - float sspectra[], - float sspectra_diff[], - float sspectra_ni[], - const int16_t fLenLow, - int16_t *ni_seed ); - -void noiseinj_hf( - float xSynth_har[], - const float th_g[], - const float band_energy[], - float *prev_En_sb, - const int16_t p2a_flags[], - const int16_t BANDS, - const int16_t band_start[], - const int16_t band_end[], - const int16_t fLenLow ); - -void noise_extr_corcod( - float spectra[], - const float spectra_ni[], - float sspectra[], - float sspectra_diff[], - float sspectra_ni[], - const int16_t fLenLow, - int16_t prev_hqswb_clas, - float *prev_ni_ratio ); - -void genhf_noise( - float noise_flr[], - float xSynth_har[], - float *predBuf, - int16_t bands, /* i : total number of subbands in a frame */ - int16_t harmonic_band, /* i : Number of LF harmonic frames */ - int16_t har_freq_est2, - int16_t pos_max_hfe2, - int16_t *pul_res, - GainItem pk_sf[], - const int16_t fLenLow, - const int16_t fLenHigh, - const int16_t sbWidth[], - const int16_t lagIndices[], - const int16_t subband_offsets[], - const int16_t subband_search_offset[] ); - -void ton_ene_est( - float xSynth_har[], - float be_tonal[], - float band_energy[], - int16_t band_start[], - int16_t band_end[], - int16_t band_width[], - const int16_t fLenLow, - const int16_t fLenHigh, - int16_t bands, - int16_t har_bands, - float ni_lvl, - GainItem pk_sf[], - int16_t *pul_res ); - -void Gettonl_scalfact( - float *outBuf, /* o : synthesized spectrum */ - const float *codbuf, /* i : core coder */ - const int16_t fLenLow, /* i : lowband length */ - const int16_t fLenHigh, /* i : highband length */ - int16_t harmonic_band, /* i : Number of LF harmonic frames */ - int16_t bands, /* i : total number of subbands in a frame */ - float *band_energy, /* i : band energy of each subband */ - int16_t *band_start, /* i : subband start indices */ - int16_t *band_end, /* i : subband end indices */ - const int16_t p2aflags[], - float be_tonal[], - GainItem *pk_sf, - int16_t *pul_res ); - -void SpectrumSmoothing( - float *inBuf, - float *outBuf, - const int16_t fLen, - const float th_cut ); - -void hq2_bit_alloc_har( - float *y, /* i : band energy of sub-vectors */ - int16_t B, /* i : number of available bits */ - int16_t N, /* i : number of sub-vectors */ - Word32 *L_Rsubband, - int16_t p2a_bands, - int32_t core_brate, /* i : core bitrate */ - int16_t p2a_flags[], - int16_t band_width[] ); - -void GetSynthesizedSpecThinOut( - const float *predBuf, - float *outBuf, - const int16_t nBands, - const int16_t *sbWidth, - const int16_t *lagIndices, - const float *lagGains, - const int16_t predBufLen ); - -void return_bits_normal2( - int16_t *bit_budget, - const int16_t p2a_flags[], - const int16_t bands, - const int16_t bits_lagIndices[] ); - -void GetlagGains( - const float *predBuf, - const float *band_energy, - const int16_t nBands, - const int16_t *sbWidth, - const int16_t *lagIndices, - const int16_t predBufLen, - float *lagGains ); - -void preset_hq2_swb( - const int16_t hqswb_clas, - const int16_t band_end[], - int16_t *har_bands, - int16_t p2a_bands, - const int16_t length, - const int16_t bands, - int16_t *lowlength, - int16_t *highlength, - float m[] ); - -void post_hq2_swb( - const float m[], - const int16_t lowlength, - const int16_t highlength, - const int16_t hqswb_clas, - const int16_t har_bands, - const int16_t bands, - const int16_t p2a_flags[], - const int16_t band_start[], - const int16_t band_end[], - float y2[], - int16_t npulses[] ); - -void har_denorm_pulcnt( - float spectra[], /* i/o: MDCT domain spectrum */ - const int16_t band_start[], /* i : Number subbands/Frame */ - const int16_t band_end[], /* i : Band Start of each SB */ - const float band_energy[], /* i : Band end of each SB */ - const int16_t band_width[], - const int16_t npulses[], - const int16_t har_bands /* i : No. of harmonic bands */ -); - -int16_t har_est( - float spectra[], - const int16_t N, - int16_t *har_freq_est1, - int16_t *har_freq_est2, - int16_t *flag_dis, - int16_t *prev_frm_hfe2, - const int16_t subband_search_offset[], - const int16_t sbWidth[], - int16_t *prev_stab_hfe2 ); - -void spt_shorten_domain_pre( - const int16_t band_start[], - const int16_t band_end[], - const int16_t prev_SWB_peak_pos[], - const int16_t BANDS, - const int32_t bwe_br, - int16_t new_band_start[], - int16_t new_band_end[], - int16_t new_band_width[] ); - -void spt_shorten_domain_band_save( - const int16_t bands, - const int16_t band_start[], - const int16_t band_end[], - const int16_t band_width[], - int16_t org_band_start[], - int16_t org_band_end[], - int16_t org_band_width[] ); - -void spt_shorten_domain_band_restore( - const int16_t bands, - int16_t band_start[], - int16_t band_end[], - int16_t band_width[], - const int16_t org_band_start[], - const int16_t org_band_end[], - const int16_t org_band_width[] ); - -void spt_swb_peakpos_tmp_save( - const float y2[], - const int16_t bands, - const int16_t band_start[], - const int16_t band_end[], - int16_t prev_SWB_peak_pos_tmp[] ); - -void hq_ecu( - const float *prevsynth, /* i : buffer of previously synthesized signal */ - float *ecu_rec, /* o : reconstructed frame in tda domain */ - int16_t *time_offs, /* i/o: Sample offset for consecutive frame losses*/ - float *X_sav, /* i/o: Stored spectrum of prototype frame */ - int16_t *num_p, /* i/o: Number of identified peaks */ - int16_t *plocs, /* i/o: Peak locations */ - float *plocsi, /* i/o: Interpolated peak locations */ - const float env_stab, /* i : Envelope stability parameter */ - int16_t *last_fec, /* i/o: Flag for usage of pitch dependent ECU */ - const int16_t ph_ecu_HqVoicing, /* i : HQ Voicing flag */ - int16_t *ph_ecu_active, /* i : Phase ECU active flag */ - float *gapsynth, /* o : Gap synthesis */ - const int16_t prev_bfi, /* i : indicating burst frame error */ - const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/ - float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/ - float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */ - float *beta_mute, /* o : Factor for long-term mute */ - const int16_t output_frame, /* i : frame length */ - Decoder_State *st /* i/o: decoder state structure */ -); - -void peakfinder( - const float *x0, /* i : vector from which the maxima will be found */ - const int16_t len0, /* i : length of input vector */ - int16_t *plocs, /* o : the indicies of the identified peaks in x0 */ - int16_t *cInd, /* o : number of identified peaks */ - const float sel, /* i : The amount above surrounding data for a peak to be identified */ - const int16_t endpoints /* i : Flag to include endpoints in peak search */ -); - -/*! r: interpolated maximum position */ -float imax_pos( - const float *y /* i : Input vector for peak interpolation */ -); - - -void fft3( - const float X[], /* i : input frame */ - float Y[], /* o : DFT of input frame */ - const int16_t n /* i : block length (must be radix 3) */ -); - -void ifft3( - const float X[], /* i : input frame */ - float Y[], /* o : iDFT of input frame */ - const int16_t n /* i : block length (must be radix 3) */ -); - -/*! r: updated estimate of background noise */ -void minimumStatistics( - float *noiseLevelMemory, /* i/o: internal state */ - int16_t *noiseLevelIndex, /* i/o: internal state */ - int16_t *currLevelIndex, /* i/o: internal state (circular buffer) */ - float *noiseEstimate, /* i/o: previous estimate of background noise */ - float *lastFrameLevel, /* i/o: level of the last frame */ - float currentFrameLevel, /* i : level of the current frame */ - const float minLev, /* i : minimum level */ - const int16_t buffSize /* i : buffer size */ -); - -void E_ACELP_toeplitz_mul( - const float R[], - const float c[], - float d[] ); - -void E_ACELP_innovative_codebook( - const float *exc, /* i : pointer to the excitation frame */ - const int16_t T0, /* i : integer pitch lag */ - const int16_t T0_frac, /* i : fraction of lag */ - const int16_t T0_res, /* i : pitch resolution */ - const float pitch_gain, /* i : adaptive codebook gain */ - const float tilt_code, /* i : tilt factor */ - ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */ - const int16_t i_subfr, /* i : subframe index */ - const float *Aq, /* i : quantized LPC coefficients */ - const float *h1, /* i : impulse response of weighted synthesis filter */ - const float *xn, /* i : Close-loop Pitch search target vector */ - const float *cn, /* i : Innovative codebook search target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - float *y2, /* o : zero-memory filtered algebraic excitation */ - const int16_t acelpautoc, /* i : autocorrelation mode enabled */ - int16_t **pt_indice, /* i/o: quantization indices pointer */ - float *code, /* o : innovative codebook */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t last_L_frame, /* i : length of the last frame */ - const int32_t total_brate /* i : total bitrate */ -); - -int16_t E_ACELP_code43bit( - const float code[], - uint32_t *ps, - int16_t *p, - uint16_t idxs[] ); -void D_ACELP_indexing_ivas( - float code[], - PulseConfig config, - const int16_t num_tracks, - int16_t prm[], - int16_t *BER_detect ); - -void D_ACELP_decode_43bit( - uint16_t idxs[], - float code[], - int16_t *pulsestrack ); - -void fcb_pulse_track_joint_decode_ivas( - uint16_t *idxs, - const int16_t wordcnt, - uint32_t *index_n, - const int16_t *pulse_num, - const int16_t track_num ); - -void lag_wind_flt( - float r[], /* i/o: autocorrelations */ - const int16_t m, /* i : order of LP filter */ - const int32_t sr_core, /* i : sampling rate */ - const int16_t strength /* i : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */ -); - -void adapt_lag_wind_fx( - float r[], /* i/o: autocorrelations */ - const int16_t m, /* i : order of LP filter */ - const int16_t Top, /* i : open loop pitch lags from curr. frame (or NULL if n/a) */ - const float Tnc, /* i : open loop pitch gains from curr. frame (NULL if n/a) */ - const int32_t sr_core /* i : core sampling rate */ -); - -void core_coder_reconfig( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t last_total_brate /* i : last total bitrate */ -); - -void core_coder_mode_switch( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t last_total_brate, /* i : last bitrate */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void enc_acelp_tcx_main( - Encoder_State *st, /* i/o: encoder state structure */ - const float new_samples[], /* i : new samples */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/ - const float lsp_new[M], /* i : LSPs at the end of the frame */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float pitch_buf[], /* o : floating pitch for each subframe */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void getTCXMode_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void getTCXWindowing_ivas( - const Word16 core, /* i : current frame mode */ - const Word16 last_core, /* i : last frame mode */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ -); - -void getLPCparam_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t param_lpc[], /* o : LTP parameters */ - Decoder_State *st0, /* i : bitstream */ - const int16_t ch, /* i : channel */ - const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */ -); - -void getTCXparam_ivas( - Decoder_State *st, /* i/o: Decoder State handle */ - Decoder_State *st0, /* i : bitstream */ - CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - int16_t param[], /* o : decoded parameters */ - const int16_t bits_common, /* i : number of common bits */ - const int16_t start_bit_pos, /* i : position of the start bit */ - const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */ - int16_t p_param[2], /* o : pointer to parameters for next round of bs reading*/ - int16_t nTnsBitsTCX10[2], - const int16_t pre_past_flag ); - -void pitch_pred_linear_fit_flt( - const int16_t nbLostCmpt, /* i : bfi counter */ - const int16_t last_good, /* i : last classification type */ - float *old_pitch_buf, /* i : pitch lag buffer */ - float *old_fpitch, /* i/o: pitch used for initial ACB generation */ - float *T0_out, /* o : estimated close loop pitch */ - const int16_t pit_min, /* i : Minimum pitch lag */ - const int16_t pit_max, /* i : Maximum pitch lag */ - float *mem_pitch_gain, /* i : lag pitch gain [0] is the most recent subfr lag */ - const int16_t limitation, - const int16_t plc_use_future_lag, /* i : number of subframes to predict */ - int16_t *extrapolationFailed, /* o : flag if extrap decides not to change the pitch */ - const int16_t nb_subfr /* i : number of ACELP subframes */ -); - -void get_subframe_pitch_flt( - const int16_t nSubframes, /* i : number of subframes */ - float pitchStart, /* i : starting pitch lag (in subframe -1) */ - float pitchEnd, /* i : ending pitch lag (in subframe nSubframes-1) */ - float *pitchBuf /* o : interpolated pitch lag per subframe */ -); - -void core_encode_openloop( - Encoder_State *st, /* i/o: encoder state structure */ - const float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/ - const float lsp_new[M], /* i : LSPs at the end of the frame */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - float *pitch_buf, /* i/o: floating pitch values for each subfr*/ - float *voice_factors, /* o : voicing factors */ - float *ptr_bwe_exc, /* o : excitation for SWB TBE */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void core_acelp_tcx20_switching( - Encoder_State *st, /* i/o: encoder state structure */ - float non_staX, /* i : unbound non-stationarity for sp/mu clas */ - float *pitch_fr, /* i/o: fraction pitch values */ - float *voicing_fr, /* i/o: fractional voicing values */ - const float currTempFlatness, /* i : flatness */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - const float stab_fac /* i : LP filter stability */ -); - -void core_encode_twodiv( - Encoder_State *st, /* i/o: coder memory state */ - const float new_samples[], /* i : new samples */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void core_encode_update( - Encoder_State *st /* i/o: encoder state structure */ -); - -void core_encode_update_cng( - Encoder_State *st, /* i/o: encoder state structure */ - float *timeDomainBuffer, - float *A, - const float Aw[] /* i : weighted A(z) unquant. for subframes*/ -); - -void core_signal_analysis_high_bitrate( - const float *new_samples, - const int16_t T_op[3], /* i : open-loop pitch values for quantiz. */ - float lsp_new[], - float lsp_mid[], - Encoder_State *st, - float *mdst_spectrum[2], - int16_t pTnsSize[], - int16_t pTnsBits[], - int16_t param_core[], - int16_t *ltpBits, - float *windowed_samples, /* i/o: backup of windowed time signal */ - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t last_element_mode, - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void encode_acelp_gains( - const float *code, - const int16_t gains_mode, - const float mean_ener_code, - const int16_t clip_gain, - ACELP_CbkCorr *g_corr, - float *gain_pit, - float *gain_code, - int16_t **pt_indice, - float *past_gcode, - float *gain_inov, - const int16_t L_subfr, - float *code2, - float *gain_code2, - const int16_t noisy_speech_flag ); - -int16_t gain_enc_gacelp_uv( - const float *code, /* i : algebraic excitation */ - const float *code2, /* i : gaussian excitation */ - const int16_t lcode, /* i : Subframe size */ - const float mean_ener, /* i : quantized mean energy of the frame */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_code2, /* o : quantized codebook gain */ - ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */ - float *past_gcode, /* i/o: past gain of code */ - float *gain_inov, /* o : unscaled innovation gain */ - const int16_t noisy_speech_flag /* i : noisy speech flag */ -); - -int16_t Mode2_gain_enc_mless( - const float *code, /* i : algebraic excitation */ - const int16_t lcode, /* i : Subframe size */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */ - const float mean_ener, /* i : mean_ener defined in open-loop (3 bits) */ - const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - float *past_gcode, /* i/o: past gain of code */ - float *gain_inov, /* o : unscaled innovation gain */ - const int16_t coder_type /* i : type of coder */ -); - -void decode_acelp_gains( - const float *code, - const int16_t gains_mode, - const float mean_ener_code, - float *gain_pit, - float *gain_code, - int16_t **pt_indice, - float *past_gpit, - float *past_gcode, - float *gain_inov, - const int16_t L_subfr, - float *code2, - float *gain_code2 ); - -void gain_dec_gacelp_uv( - int16_t index, /* i/o: Quantization index vector */ - const float *code, /* i : algebraic code excitation */ - const float *code2, /* i : algebraic code excitation */ - const float mean_ener, /* i : mean energy */ - const int16_t lcode, /* i : Subframe size */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codebook gain */ - float *gain_code2, /* o : Quantized codebook gain */ - float *past_gpit, /* i/o: past gain of pitch */ - float *past_gcode, /* i/o: past energy of code */ - float *gain_inov /* o : unscaled innovation gain */ -); - -void limit_T0_voiced_ivas( - const int16_t nbits, - const int16_t res, - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - const int16_t T0_res, /* i : pitch resolution */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_min_frac, /* o : lower pitch limit */ - int16_t *T0_max, /* o : higher pitch limit */ - int16_t *T0_max_frac, /* o : higher pitch limit */ - const int16_t pit_min, /* i : Minimum pitch lag */ - const int16_t pit_max /* i : Maximum pitch lag */ -); - - -/*! r: floating pitch value */ -float Mode2_pit_decode_flt( - const int16_t coder_type, /* i : coding model */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t L_subfr, /* i : sub-frame length */ - int16_t **pt_indice, /* i/o: quantization indices pointer */ - int16_t *T0, /* o : close loop integer pitch */ - int16_t *T0_frac, /* o : close loop fractional part of the pitch */ - int16_t *T0_res, /* i/o: pitch resolution */ - int16_t *T0_min, /* i/o: lower limit for close-loop search */ - int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */ - int16_t *T0_max, /* i/o: higher limit for close-loop search */ - int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */ - const int16_t pit_min, - const int16_t pit_fr1, - const int16_t pit_fr1b, - const int16_t pit_fr2, - const int16_t pit_max, - const int16_t pit_res_max ); - -void Mode2_abs_pit_dec_flt( - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t *T0_res, /* o : pitch resolution */ - int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */ - const int16_t pit_min, - const int16_t pit_fr1, - const int16_t pit_fr2, - const int16_t pit_res_max ); - -void Mode2_delta_pit_dec_flt( - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t T0_res, /* i : pitch resolution */ - int16_t *T0_min, /* i : delta search min */ - int16_t *T0_min_frac, /* i : delta search min */ - int16_t **pt_indice /* i/o: pointer to Vector of Q indexes */ -); - -void formant_post_filt_ivas( - PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */ - float *synth_in, /* i : 12k8 synthesis */ - const float *Aq, /* i : LP filter coefficient */ - float *synth_out, /* i/o: input signal */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_subfr, /* i : sub-frame length */ - const float lp_noise, /* i : background noise energy */ - const int32_t brate, /* i : bitrate */ - const int16_t off_flag /* i : Off flag */ -); - - -int16_t dlpc_avq( - int16_t *index, /* i : Quantization indices */ - float *LSF_Q, /* o : Quantized LSF vectors */ - const int16_t numlpc, /* i : Number of sets of lpc */ - const int32_t sr_core /* i : internal sampling rate */ -); - -int16_t decode_lpc_avq( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t numlpc, /* i : Number of sets of lpc */ - int16_t *param_lpc, /* o : lpc parameters */ - const int16_t ch, /* i : channel */ - const int16_t element_mode, /* i : element mode */ - const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */ -); - - -void vlpc_2st_dec_flt( - float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - int16_t *indx, /* i : index[] (4 bits per words) */ - const int16_t mode, /* i : 0=abs, >0=rel */ - const int32_t sr_core /* i : internal sampling rate */ -); - -void lsf_weight_2st_flt( - const float *lsfq, - float *w, - const int16_t mode, - const int32_t sr_core ); - -void mdct_window_sine_flt( - float *window, - const int32_t Fs, - const int16_t n, - const int16_t window_type, - const int16_t element_mode ); - -void mdct_window_aldo_flt( - float *window1, - float *window2, - const int16_t n ); - -void AVQ_cod_lpc( - const float nvec[], /* i : vector to quantize */ - int16_t nvecq[], /* o : quantized normalized vector (assuming the bit budget is enough) */ - int16_t *indx, /* o : index[] (4 bits per words) */ - const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */ -); - -void AVQ_dec_lpc_ivas( - const int16_t indx[], /* i : index[] (4 bits per words) */ - int16_t nvecq[], /* o : vector quantized */ - const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */ -); - -void vlpc_1st_dec_flt( - const int16_t index, /* i : codebook index */ - float *lsfq, /* i/o: i:prediction o:quantized lsf */ - const int32_t sr_core ); - -void WindowSignal_flt( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - int16_t offset, /* i : left folding point offset relative to the input signal pointer */ - const int16_t left_overlap_mode, /* i : overlap mode of left window half */ - const int16_t right_overlap_mode, /* i : overlap mode of right window half */ - int16_t *left_overlap_length, /* o : TCX window left overlap length */ - int16_t *right_overlap_length, /* o : TCX window right overlap length */ - const float in[], /* i : input signal */ - int16_t *L_frame, /* i/o: frame length */ - float out[], /* o : output windowed signal */ - const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const int16_t fullband /* i : fullband flag */ -); - -void HBAutocorrelation( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const int16_t left_mode, /* i : overlap mode of left window half */ - const int16_t right_mode, /* i : overlap mode of right window half */ - float speech[], /* i : speech */ - int16_t L_frame_glob, /* i/o: frame length */ - float *r /* o : autocorrelations vector */ -); - -void TNSAnalysis( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const int16_t L_frame, /* i : frame length */ - int16_t L_spec, /* i : length of the spectrum */ - const int16_t transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */ - const int16_t isAfterACELP, /* i : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */ - float spectrum[], /* i : MDCT spectrum of the subframe */ - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float ltp_gain, /* i : ltp gain */ - STnsData *pTnsData, /* o : TNS data */ - int8_t *pfUseTns, /* o : Flag indicating if TNS is used */ - float *predictionGain /* o : TNS prediction gain */ -); - -void CalculateTnsFilt( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - const float pSpectrum[], /* i : MDCT spectrum */ - STnsData *pTnsData, /* o : TNS data struct */ - float *predictionGain /* o : TNS prediction gain */ -); - -void ShapeSpectrum( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const float A[], /* i : quantized coefficients NxAz_q[M+1] */ - float gainlpc[], /* o : MDCT gains for the previous frame */ - const int16_t L_frame_glob, /* i : frame length */ - int16_t L_spec, /* i : length of the spectrum */ - float spectrum[], /* i/o: MDCT spectrum */ - const int8_t fUseTns, /* i : Flag indicating if TNS is used */ - Encoder_State *st, /* i/o: encoder state structure */ - float *scf /* i : scale factors */ -); - -void QuantizeSpectrum( - Encoder_State *st, /* i/o: encoder state structure */ - const float A[], /* i : quantized coefficients NxAz_q[M+1] */ - const Word16 Aqind[], /* i : frame-independent quantized coeffs (M+1) */ - float gainlpc[], /* i : MDCT gains of the previous frame */ - float synth[], /* o : synthesis buffer */ - const int16_t nb_bits, /* i : bit budget */ - const int16_t tnsSize, /* i : number of tns parameters put into prm */ - int16_t prm[], /* o : tcx parameters */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - CONTEXT_HM_CONFIG *hm_cfg, /* i : HM configuration */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -/*! r: index of next coefficient */ -int16_t get_next_coeff_mapped_ivas( - int16_t ii[2], /* i/o: coefficient indexes */ - int32_t *pp, /* o : peak(1)/hole(0) indicator */ - int16_t *idx, /* o : index in unmapped domain */ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - - -void ACcontextMapping_encode2_no_mem_s17_LC( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t *x, - int16_t nt, - int16_t lastnz, - int16_t nbbits, - int16_t resQMaxBits, - CONTEXT_HM_CONFIG *hm_cfg ); - -int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas( - Decoder_State *st, /* i/o: decoder state */ - int16_t *x, /* o : decoded spectrum */ - int16_t nt, /* i : size of spectrum */ - int16_t nbbits, /* i : bit budget */ - int16_t resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */ -); - -int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC( - const int16_t *x, - const int16_t nt, - int16_t *lastnz, - int16_t *nEncoded, - const int16_t target, - int16_t *stop, - CONTEXT_HM_CONFIG *hm_cfg ); - -void RCcontextMapping_encode2_no_mem_s17_LCS( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t *x, - const int16_t nt, - int16_t lastnz, - const int16_t nbbits, - const int16_t resQMaxBits, - CONTEXT_HM_CONFIG *hm_cfg ); - -int16_t RCcontextMapping_decode2_no_mem_s17_LCS( - Decoder_State *st, /* i/o: decoder state */ - int16_t *x, /* o : decoded spectrum */ - const int16_t nt, /* i : size of spectrum */ - const int16_t nbbits, /* i : bit budget */ - const int16_t resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */ -); - -int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS( - int16_t *x, /* Spectral coefficients */ - const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */ - int16_t *lastnz_out, - int16_t *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */ - const int16_t target, /* Target bits */ - int16_t *stop, - int16_t mode, - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ -); - -Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - const Word16 target, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem ); - -Word16 RCcontextMapping_encode2_estimate_bandWise_fx( - Word16 *x, /* Q0 */ - const Word16 start_line, /* Q0 */ - const Word16 end_line, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ -); - -void tcx_get_windows_flt( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const int16_t left_mode, /* i : overlap mode of left window half */ - const int16_t right_mode, /* i : overlap mode of right window half */ - int16_t *left_overlap, /* o : left overlap length */ - const float **left_win, /* o : left overlap window */ - int16_t *right_overlap, /* o : right overlap length */ - const float **right_win, /* o : right overlap window */ - const int16_t fullband /* i : fullband flag */ -); - -void tcx_windowing_analysis_flt( - const float *signal, /* i : signal vector */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_overlap, /* i : left overlap length */ - const float *left_win, /* i : left overlap window */ - const int16_t right_overlap, /* i : right overlap length */ - const float *right_win, /* i : right overlap window */ - float *output /* o : windowed signal vector */ -); - -void tcx_windowing_synthesis_current_frame_flt( - float *signal, /* i/o: signal vector */ - const float *window, /* i : TCX window vector */ - const float *window_half, /* i : TCX window vector for half-overlap window */ - const float *window_min, /* i : TCX minimum overlap window */ - const int16_t window_length, /* i : TCX window length */ - const int16_t window_half_length, /* i : TCX half window length */ - const int16_t window_min_length, /* i : TCX minimum overlap length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t left_mode, /* i : overlap mode of left window half */ - float *acelp_zir, /* i/o: acelp ZIR */ - const float *old_syn, /* i : old synthesis */ - const float *syn_overl, /* i : overlap synthesis */ - const float *A_zir, - const float *window_trans, /* i : window for transition from ACELP */ - int16_t acelp_zir_len, - const int16_t acelp_mem_len, - const int16_t last_core_bfi, /* i : last mode */ - const int16_t last_is_cng, - const int16_t fullbandScale ); - -void tcx_windowing_synthesis_past_frame_flt( - float *signal, /* i/o: signal vector */ - const float *window, /* i : TCX window vector */ - const float *window_half, /* i : TCX window vector for half-overlap window */ - const float *window_min, /* i : TCX minimum overlap window */ - const int16_t window_length, /* i : TCX window length */ - const int16_t window_half_length, /* i : TCX half window length */ - const int16_t window_min_length, /* i : TCX minimum overlap length */ - const int16_t right_mode /* i : overlap mode (left_mode of current frame) */ -); - -void ProcessIGF( - Encoder_State *st, /* i : Encoder state */ - float *pMDCTSpectrum, /* i : MDCT spectrum */ - const float *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ - float *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate */ - const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const int16_t frameno, /* i : flag indicating index of current subframe */ - const int16_t sp_aud_decision0, /* i : first stage switching decision */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void ProcessStereoIGF( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t frameno, /* i : flag indicating index of current subframe*/ - const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void AnalyzePowerSpectrum( - Encoder_State *st, /* i/o: encoder states */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_frameTCX, /* i : full band frame length */ - const int16_t left_overlap, /* i : left overlap length */ - const int16_t right_overlap, /* i : right overlap length */ - const float mdctSpectrum[], /* i : MDCT spectrum */ - const float signal[], /* i : windowed signal corresponding to mdctSpectrum */ - float powerSpec[] /* o : Power spectrum */ -); - -void lpc2mdct_flt( - float *lpcCoeffs, - const int16_t lpcOrder, - float mdct_gains[], - const int16_t length, - const int16_t noInverse ); - -void mdct_preShaping( - float x[], - const int16_t lg, - const float gains[] ); - -void mdct_noiseShaping_flt( - float x[], - const int16_t lg, - const float gains[], - const int16_t nBands ); - - -void PsychAdaptLowFreqDeemph_flt( - float x[], - const float lpcGains[], - float lf_deemph_factors[] ); - -void AdaptLowFreqDeemph_flt( - float x[], - int16_t tcx_lpc_shaped_ari, - const float lpcGains[], - const int16_t lg, - float lf_deemph_factors[] ); - - -void tcx_noise_filling_flt( - float *Q, - const int16_t noiseFillSeed, - const int16_t iFirstLine, - const int16_t lowpassLine, - const int16_t nTransWidth, - const int16_t L_frame, - const float tiltCompFactor, - float fac_ns, - Word16 *infoTCXNoise, - const int16_t element_mode /* i : IVAS element mode */ -); - - -void tcx_decoder_memory_update_flt( - Decoder_State *st, /* i/o: decoder memory state */ - const float *xn_buf, /* i : mdct output buffer */ - float *synth, /* i/o: synth */ - const float *A /* i : Quantized LPC coefficients */ -); - - -/*! r: number of bits used (including "bits") */ -int16_t tcx_ari_res_invQ_spec_flt( - float x_Q[], /* i/o: quantized spectrum */ - const int16_t L_frame, /* i : number of lines */ - const int16_t prm[], /* i : bitstream */ - int16_t target_bits, /* i : number of bits available */ - int16_t bits, /* i : number of bits used so far */ - const float deadzone, /* i : quantizer deadzone */ - const float x_fac[] /* i : spectrum post-quantization factors */ -); - - -void ari_copy_states( - Tastat *source, - Tastat *dest ); - - -void ari_start_encoding_14bits( - Tastat *s ); - - -void ari_start_decoding_14bits_ivas( - Decoder_State *st, - Tastat *s ); - -int16_t ari_start_decoding_14bits_prm_ivas( - const int16_t *ptr, - int16_t bp, - Tastat *s ); - -void ari_decode_14bits_s17_ext_ivas( - Decoder_State *st, - uint16_t *res, - Tastat *s, - const uint16_t *cum_freq ); - -void ari_decode_14bits_s27_ext_ivas( - Decoder_State *st, - uint16_t *res, - Tastat *s, - const uint16_t *cum_freq ); - -void ari_decode_14bits_bit_ext_ivas( - Decoder_State *st, - uint16_t *res, - Tastat *s ); - -/*! r: Q15 */ -Word16 expfp_evs_fx( - const Word16 x, /* i : mantissa Q15-e */ - const Word16 x_e /* i : exponent Q0 */ -); - - -void tcx_arith_render_envelope_ivas_fx( - const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i : number of spectral lines Q0*/ - const Word16 L_spec, /* i : length of the coded spectrum Q0*/ - const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o : shaped signal envelope Q16*/ -); - -int16_t ari_encode_14bits_range( - int16_t *ptr, - int16_t bp, - int32_t bits, - Tastat *s, - uint16_t cum_freq_low, - uint16_t cum_freq_high ); - - -int16_t ari_done_cbr_encoding_14bits( - int16_t *ptr, - int16_t bp, - int32_t bits, - Tastat *s ); - - -void tcx_arith_encode_envelope( - float spectrum[], /* i/o: MDCT coefficients */ - int16_t signs[], /* o : signs (spectrum[.]<0) */ - const int16_t L_frame, /* i : frame or MDCT length */ - const int16_t L_spec, /* i : length w/o BW limitation */ - Encoder_State *st, /* i/o: coder state */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - int16_t target_bits, /* i : number of available bits */ - int16_t prm[], /* o : bitstream parameters */ - const int16_t use_hm, /* i : use HM in current frame? */ - int16_t prm_hm[], /* o : HM parameter area */ - const int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - int16_t *arith_bits, /* o : bits used for ari. coding */ - int16_t *signaling_bits, /* o : bits used for signaling */ - const int16_t low_complexity /* i : low-complexity flag */ -); - -void tcx_arith_decode_envelope( - Decoder_State *st, /* i/o: coder state */ - float q_spectrum[], /* o : quantised MDCT coefficients */ - const int16_t L_frame, /* i : frame or MDCT length */ - int16_t L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const int16_t target_bits, /* i : number of available bits */ - const int16_t prm[], /* i : bitstream parameters */ - const int16_t use_hm, /* i : use HM in current frame? */ - const int16_t prm_hm[], /* i : HM parameter area */ - int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - int16_t *arith_bits, /* o : bits used for ari. coding */ - int16_t *signaling_bits, /* o : bits used for signaling */ - const int16_t low_complexity /* i : low-complexity flag */ -); - -void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ -); - - -void UnmapIndex_fx( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word8 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ -); - -/*! r: PeriodicityIndex */ -int16_t SearchPeriodicityIndex( - const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */ - const float UnfilteredMdct[], /* i : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */ - const int16_t NumCoeffs, /* i : Number of coefficients */ - const int16_t shortTargetBits, /* i : Target bit budget (excl. Done flag) */ - const int16_t LtpPitchLag, /* i : TCX-LTP pitch */ - const float LtpGain, /* i : LTP gain */ - float *RelativeScore /* o : Energy concentration factor */ -); - - -int16_t EncodeIndex( - const int16_t Bandwidth, /* o : NB, 1: (S)WB */ - int16_t PeriodicityIndex, - BSTR_ENC_HANDLE hBstr ); - - -Word16 CountIndexBits_fx( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ - Word16 PeriodicityIndex /* Q0 */ -); - -int16_t DecodeIndex( - Decoder_State *st, - const int16_t Bandwidth, /* o : NB, 1: (S)WB */ - int16_t *PeriodicityIndex ); - -#define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution ) -#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) - - -Word32 tcx_hm_render_fx( - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ -); - - -void tcx_hm_modify_envelope_fx( - const Word16 gain, /* i: HM gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - const Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ -); - -void tcx_hm_analyse( - const float abs_spectrum[], /* i : absolute spectrum */ - const int16_t L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const int16_t targetBits, /* i : target bit budget */ - const int16_t coder_type, /* i : GC/VC coder type */ - int16_t prm_hm[], /* o : HM parameters */ - int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - const float LtpGain, /* i : LTP gain */ - int16_t *hm_bits /* o : bit consumption */ -); - -void tcx_hm_decode_ivas( - const int16_t L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const int16_t targetBits, /* i : target bit budget */ - const int16_t coder_type, /* i : GC/VC coder type */ - const int16_t prm_hm[], /* i : HM parameters */ - const int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - int16_t *hm_bits /* o : bit consumption */ -); - -void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ -); - -void coder_tcx( - Encoder_State *st, /* i/o: encoder state structure */ - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const float A[], /* i : quantized coefficients NxAz_q[M+1] */ - const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */ - float synth[], /* o : decoded synthesis */ - const int16_t L_frame_glob, /* i : frame length */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - int16_t nb_bits, /* i : bit budget */ - float spectrum[], /* i/o: MDCT spectrum */ - int16_t prm[], /* o : tcx parameters */ - CONTEXT_HM_CONFIG *hm_cfg, - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void coder_tcx_post( - Encoder_State *st, /* i/o: encoder memory state */ - float *A, /* o : Quantized LPC coefficients */ - const float *Ai /* i : Unquantized (interpolated) LPC coefficients */ -); - -void decoder_tcx( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - float A[], /* i : coefficients NxAz[M+1] */ - Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/ - float synth[], /* i/o: synth[-M..lg] */ - float synthFB[], /* i/o: encoder memory state */ - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void decoder_tcx_post( - Decoder_State *st, /* i/o: decoder memory state */ - float *synth, - float *synthFB, - float *A, /* i : A(z) filter coefficients */ - const int16_t bfi, - const int16_t isMCT ); - -void coder_acelp( - Encoder_State *st, /* i/o: coder memory state */ - const float A[], /* i : coefficients 4xAz[M+1] */ - const float Aq[], /* i : coefficients 4xAz_q[M+1] */ - const float speech[], /* i : speech[-M..lg] */ - LPD_state *LPDmem, /* i/o: ACELP memories */ - int16_t *prm, /* o : acelp parameters */ - const float stab_fac, - const int16_t target_bits, - float *gain_pitch_buf, /* o : gain pitch values */ - float *gain_code_buf, /* o : gain code values */ - float *pitch_buf, /* o : pitch values for each subfr.*/ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void coder_acelp_rf( - const int16_t target_bits, /* i : target bits */ - const float speech[], /* i : speech[-M..lg] */ - const int16_t coder_type, /* i : coding type */ - const int16_t rf_frame_type, /* i : rf_frame_type */ - const float A[], /* i : coefficients 4xAz[M+1] */ - const float Aq[], /* i : coefficients 4xAz_q[M+1] */ - const float voicing[], /* i : open-loop LTP gain */ - const int16_t T_op[], /* i : open-loop LTP lag */ - const float stab_fac, /* i : LP stability factor */ - Encoder_State *st, /* i/o: coder memory state */ - ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */ - float *exc_rf, /* i/o: pointer to RF excitation */ - float *syn_rf /* i/o: pointer to RF synthesis */ -); - -void decoder_acelp( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - const float A[], /* i : coefficients NxAz[M+1] */ - ACELP_config acelp_cfg, /* i : ACELP config */ - float synth[], /* i/o: synthesis */ - int16_t *pT, /* o : pitch for all subframe */ - float *pgainT, /* o : pitch gain for all subfr */ - const float stab_fac, /* i : stability of isf */ - float *pitch_buffer, /* o : pitch values for each subfr.*/ - float *voice_factors, /* o : voicing factors */ - const int16_t LSF_Q_prediction, /* i : LSF prediction mode */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ -); - -void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ -); - -void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const int16_t param_lpc[], /* i : LPC parameters to write */ - const int16_t bits_param_lpc[], /* i : bits per LPC parameter */ - const int16_t no_param_lpc, /* i : number of LPC parameters */ - int16_t *nbits_lpc /* o : LPC bits written */ -); - -void enc_prm( - Encoder_State *st, /* i/o: encoder state structure */ - int16_t param[], /* i : parameters */ - int16_t param_lpc[], /* i : LPC parameters */ - CONTEXT_HM_CONFIG hm_cfg[], - const int16_t bits_param_lpc[], - const int16_t no_param_lpc ); - -void writeTCXparam( - Encoder_State *st, /* i/o: Encoder State handle */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ - int16_t param[], /* i : parameters */ - const int16_t nbits_header, - const int16_t nbits_start, - const int16_t nbits_lpc, - const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */ - int16_t p_param[2], /* i/o: pointer to parameters from previous bs writing */ - const int16_t target_bitsTCX10[2], - const int16_t pre_past_flag ); - -void enc_prm_rf( - Encoder_State *st, /* i/o: encoder memory state */ - const int16_t rf_frame_type, - const int16_t fec_offset ); - -void dec_prm_hm_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t *prm_hm, - const int16_t hm_size ); - -void dec_prm_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t param[], /* o : decoded parameters */ - int16_t param_lpc[], /* i : LPC parameters */ - int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ - int16_t *bitsRead ); -void gaus_L2_dec_flt( - float *code, /* o : decoded gaussian codevector */ - float tilt_code, - const float *A, - float formant_enh_num, - int16_t *seed_acelp /* i/o: random seed */ -); - -/*! r: interpolated value */ -float interpolation( - const float *x, /* i : input vector */ - const float *win, /* i : interpolation window */ - const int16_t frac, /* i : fraction */ - const int16_t up_samp, /* i : upsampling factor */ - const int16_t nb_coef /* i : nb of filter coef */ -); - -void predict_signal_flt( - const float excI[], /* i : input excitation buffer */ - float excO[], /* o : output excitation buffer */ - const int16_t T0, /* i : integer pitch lag */ - int16_t frac, /* i : fraction of lag */ - const int16_t frac_max, /* i : max fraction */ - const int16_t L_subfr /* i : subframe size */ -); - -void tcx_ltp_encode( - Encoder_State *st, - const int16_t tcxMode, - const int16_t L_frame, - const float *speech, - float *speech_ltp, - const float *wsp, - const int16_t Top[], - int16_t *ltp_param, - int16_t *ltp_bits, - float *A, - const int16_t disable_ltp, - const int16_t element_mode ); - -void tcx_ltp_post_flt( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - const int16_t core, - const int16_t output_frame, - const int16_t L_frame, - float sig[], - const float tcx_buf[] ); - -int16_t tcx_ltp_decode_params_flt( - int16_t *ltp_param, - int16_t *pitch_int, - int16_t *pitch_fr, - float *gain, - const int16_t pitmin, - const int16_t pitfr1, - const int16_t pitfr2, - const int16_t pitmax, - const int16_t pitres ); - -void create_IDCT_N_Matrix( - float *inv_matrixFloatQ, /* i/o: RAM buffer */ - const int16_t N, /* i : DCT length, number of time samples */ - const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */ - const int16_t alloc_size /* i : RAM buffer size in elements */ -); - -void dctT2_N_apply_matrix( - const float *input, /* i : input in fdcng or DCT(fdcng) domain */ - float *output, /* o : output in DCT(fdcng) or fdcng ordomain */ - const int16_t dct_dim, /* i : dct processing dim possibly truncated */ - const int16_t fdcngvq_dim, /* i : fdcng domain length */ - const float *matrix, /* i : IDCT matrix */ - const int16_t matrix_row_dim, /* i : */ - const DCTTYPE dcttype /* i : matrix operation type */ -); - -void extend_dctN_input( - const float *input, /* i : input in fdcng domain */ - const float *dct_input, /* i : input in dctN(fdcng) domain */ - const int16_t in_dim, /* i : in_dim == N */ - float *ext_sig, /* o : extended output in fdcng domain */ - const int16_t out_dim, /* i : output total dim */ - float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */ - const int16_t n_cols, /* i : number of columns == DCT truncation length */ - const DCTTYPE dcttype /* i : matrix operation type */ -); - - -void PulseResynchronization( - const float *src_exc, /* i : Input excitation buffer */ - float *dst_exc, /* o : output excitation buffer */ - const int16_t nFrameLength, /* i : frame length */ - const int16_t nSubframes, /* i : Number of subframes */ - const float pitchStart, /* i : Pitch at the end of the last frame */ - const float pitchEnd /* i : Pitch at the end of the current frame */ -); - -void con_acelp( - float A[], /* i : coefficients NxAz[M+1] */ - const int16_t coder_type, /* i : ACELP coder type */ - float synth[], /* i/o: synthesis */ - int16_t *pT, /* o : pitch for all subframe */ - float *pgainT, /* o : pitch gain for all subfr */ - float stab_fac, /* i : stability of isf */ - Decoder_State *st, /* i/o: coder memory state */ - float pitch_buffer[], /* i/o: floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void con_tcx( - Decoder_State *st, /* i/o: coder memory state */ - float synth[], /* i/o: synth[] */ - const float coh, /* i : coherence of stereo signal */ - int16_t *noise_seed, /* i/o: noise seed for stereo */ - const int16_t only_left, /* i : TD-PLC only in left channel */ - const float A_cng[] /* i : CNG LP filter coefficients */ -); - -int16_t lsf_msvq_ma_decprm_ivas( - Decoder_State *st, - int16_t *param_lpc ); - -int16_t dec_lsf_tcxlpc_ivas( - Decoder_State *st, /* i : Decoder state */ - int16_t **indices, /* o : Ptr to VQ indices */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t cdk /* i : codebook selector */ -); - -int16_t D_lsf_tcxlpc_ivas( - const int16_t indices[], /* i : VQ indices */ - float lsf_q[], /* o : quantized lsf */ - Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t cdk, /* i : codebook selector */ - const float mem_MA[] /* i : MA memory */ -); - -int16_t Q_lsf_tcxlpc( - /* const */ float lsf[], /* i : original lsf */ - float lsf_q[], /* o : quantized lsf */ - Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ - int16_t indices[], /* o : VQ indices */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t cdk, /* i : codebook selector */ - const float mem_MA[], /* i : MA memory */ - const int16_t coder_type, /* i : acelp extended mode */ - const float *Bin_Ener /* i : Spectrum energy */ -); - -void midlsf_enc( - const float qlsf0[], - const float qlsf1[], - const float lsf[], - int16_t *idx, - const int16_t N, - const float *Bin_Ener, - const int16_t narrowBand, - const int32_t sr_core, - const int16_t coder_type ); - -void lsf_end_enc( - Encoder_State *st, - const float *lsf, - float *qlsf, - const int16_t nBits, - const int16_t coder_type_org, - const int16_t force_sf, - int16_t *lpc_param, - int16_t *no_stages, - int16_t *bits_param_lpc, - const int16_t coder_type_raw, - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void lsf_end_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t coder_type_org, /* i : coding type */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t nBits, /* i : number of bits used for ISF quantization*/ - float *qlsf, /* o : quantized LSFs in the cosine domain */ - int16_t *lpc_param, /* i : LPC parameters */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - int16_t *nb_indices, /* o : number of indices */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void lpc_quantization( - Encoder_State *st, - const float lsp[], - const float lspmid[], - float lsp_q[], - float lsf_q[], - float lspmid_q[], - const int16_t coder_type, - const int16_t acelp_midLpc, - int16_t param_lpc[], - int16_t nbits_lpc[], - int16_t *bits_param_lpc, - int16_t *no_param_lpc ); - -void lpc_unquantize( - Decoder_State *st, - float *lsf, - float *lsp, - int16_t *param_lpc, - float *lspmid, - float *lsfmid, - const int16_t coder_type, - int16_t *LSF_Q_prediction /* o : LSF prediction mode */ -); - -void dlpc_bfi_flt( - const int16_t L_frame, - float *lsf_q, /* o : quantized lsfs */ - const float *lsfold, /* i : past quantized lsf */ - const int16_t last_good, /* i : last good received frame */ - const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */ - float mem_MA[], /* i/o: quantizer memory for MA model */ - float mem_AR[], /* i/o: quantizer memory for MA model */ - float *stab_fac, /* i : lsf stability factor */ - float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */ - const int16_t numlpc, /* i : Number of division per superframe */ - float lsf_cng[], - const int16_t plcBackgroundNoiseUpdated, - float *lsf_q_cng, /* o : quantized lsfs of background noise */ - float *old_lsf_q_cng, /* o : old quantized lsfs for background noise */ - const float lsfBase[] /* i : base for differential lsf coding */ -); - -void Unified_weighting( - const float Bin_Ener_128[], /* i : FFT Bin energy 128 bins in two sets */ - const float lsf[], /* i : LSF vector */ - float w[], /* o : LP weighting filter (numerator) */ - const int16_t narrowBand, /* i : flag for Narrowband */ - const int16_t unvoiced, /* i : flag for Unvoiced frame */ - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t order /* i : LP order */ -); - -int16_t vad_init( - VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state */ -); - -int16_t vad_proc( - float realValues[16][60], /* i : CLDFB real values */ - float imagValues[16][60], /* i : CLDFB imag values */ - float *sb_power, /* i/o: Energy of CLDFB data */ - const int16_t numBands, /* i : number of input bands */ - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - int16_t *cldfb_addition, - const int16_t vada_flag /* i : VAD flag */ -); - - -int16_t update_decision( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - const float snr, /* i : frequency domain SNR */ - const float tsnr, /* i : time domain SNR */ - const float frame_energy, /* i : current frame energy */ - const float high_eng, /* i : current frame high frequency energy */ - const int16_t vad_flag, /* i : VAD flag */ - const int16_t music_backgound_f /* i : background music flag */ -); - -void frame_spec_dif_cor_rate( - float spec_amp[], /* i : spectral amplitude */ - float pre_spec_low_dif[], /* i/o: low spectrum different */ - float f_tonality_rate[] /* o : tonality rate */ -); - - -void SNR_calc( - const float frame_sb_energy[], /* i : energy of sub-band divided non-uniformly*/ - const float sb_bg_energy[], /* i : sub-band background energy */ - const float t_bg_energy, /* i : time background energy of several frames*/ - float *snr, /* o : frequency domain SNR */ - float *tsnr, /* o : time domain SNR */ - const float frame_energy, /* i : current frame energy */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void background_update( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - float frame_energy, /* i : current frame energy 2 */ - const int16_t update_flag, /* i : current frame update flag */ - const int16_t music_backgound_f, /* i : background music flag */ - const float snr ); - -void bg_music_decision( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - int16_t *music_backgound_f, /* i : background music flag */ - const float frame_energy /* i : current frame energy 1 */ -); - -void est_energy( - float sb_power[], /* o : energy of sub-band divided uniformly */ - float frame_sb_energy[], /* o : energy of sub-band divided non-uniformly*/ - float *p_frame_energy, /* o : frame energy 1 */ - float *p_frame_energy2, /* o : frame energy 2 */ - float *p_high_energy, /* o : high frequency energy */ - const int16_t bw /* i : bandwidth */ -); - - -int16_t comvad_decision( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - const float snr, /* i : frequency domain SNR */ - const float tsnr, /* i : time domain SNR */ - const float snr_flux, /* i : average tsnr of several frames */ - const float lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/ - const float lt_snr_org, /* i : original long time SNR */ - const float lf_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/ - const float frame_energy, /* i : current frame energy */ - const int16_t music_backgound_f, /* i : background music flag */ - int16_t *cldfb_addition, - const int16_t vada_flag /* i : VAD flag */ -); - -void calc_snr_flux( - float tsnr, /* i : time-domain SNR */ - float pre_snr[], /* i/o: time-domain SNR storage */ - float *snr_flux /* o : average tsnr */ -); - -void calc_lt_snr( - float *lt_snr_org, /* o : original long time SNR */ - float *lt_snr, /* o : long time SNR calculated by fg_energy and bg_energy*/ - const float fg_energy, /* i : foreground energy sum */ - const int16_t fg_energy_count, /* i : number of the foreground energy frame */ - const float bg_energy, /* i : background energy sum */ - const int16_t bg_energy_count, /* i : number of the background energy frame */ - const int16_t bw_index, /* i : band width index */ - const float lt_noise_sp_center0 /* i : long time noise spectral center by 0 */ -); - -void calc_lf_snr( - float *lf_snr_smooth, /* o : smoothed lf_snr */ - float *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/ - const float l_speech_snr, /* i : sum of active frames snr */ - const int16_t l_speech_snr_count, /* i : number of the active frame */ - const float l_silence_snr, /* i : sum of the nonactive frames snr */ - const int16_t l_silence_snr_count, /* i : number of the nonactive frame */ - const int16_t fg_energy_count, /* i : number of the foreground energy frame */ - const int16_t bg_energy_count, /* i : number of the background energy frame */ - const int16_t bw_index /* i : band width index */ -); - -float construct_snr_thresh( - const float sp_center[], /* i : spectral center */ - const float snr_flux, /* i : snr flux */ - const float lt_snr, /* i : long time time domain snr */ - const float lf_snr, /* i : long time frequency domain snr */ - const int16_t continuous_speech_num, /* i : continuous speech number */ - const int16_t continuous_noise_num, /* i : continuous noise number */ - const int16_t fg_energy_est_start, /* i : whether if estimated energy */ - const int16_t bw_index /* i : band width index */ -); - -void minimum_statistics_flt( - const int16_t len, /* i : Vector length */ - const int16_t lenFFT, /* i : Length of the FFT part of the vectors */ - float *psize_flt, - float *msPeriodog, /* i : Periodograms */ - float *msNoiseFloor, - float *msNoiseEst, /* o : Noise estimates */ - float *msAlpha, - float *msPsd, - float *msPsdFirstMoment, - float *msPsdSecondMoment, - float *msMinBuf, - float *msBminWin, - float *msBminSubWin, - float *msCurrentMin, - float *msCurrentMinOut, - float *msCurrentMinSubWindow, - int16_t *msLocalMinFlag, - int16_t *msNewMinFlag, - float *msPeriodogBuf, - int16_t *msPeriodogBufPtr, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t enc_dec, /* i : encoder/decoder indicator */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void generate_comfort_noise_enc( - Encoder_State *st /* i/o: encoder state structure */ -); - -void generate_comfort_noise_dec( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nchan_out /* i : number of output channels */ -); - -void generate_comfort_noise_dec_hf( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t cng_flag /* i : CNG Flag */ -); - -void generate_masking_noise( - float *timeDomainBuffer, /* i/o: time-domain signal */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t length, /* i : frame size */ - const int16_t core, /* i : core */ - const int16_t return_noise, /* i : noise is returned instead of added */ - const int16_t secondary, /* i : indicator for secondary channel */ - const int16_t element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -); - -void generate_masking_noise_update_seed( - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void generate_masking_noise_mdct( - float *mdctBuffer, /* i/o: time-domain signal */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void SynthesisSTFT_dirac_flt( - float *fftBuffer, /* i : FFT bins */ - float *timeDomainOutput, - float *olapBuffer, - const float *olapWin, - const int16_t samples_out, - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void generate_masking_noise_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - float *Cldfb_RealBuffer, /* o : CLDFD real buffer */ - float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */ - const int16_t slot_index, /* i : CLDFB slot index */ - const int16_t cna_flag, /* i : CNA flag for LB and HB */ - const int16_t fd_cng_flag /* i : FD-CNG flag for HB */ -); - -void generate_stereo_masking_noise( - float *syn, /* i/o: time-domain signal */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -); - -void apply_scale_flt( - float *scale, /* i : scale factor */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t brate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const int16_t scaleTableSize /* i : Size of scale table */ -); - -void compress_range_flt( - float *in, - float *out, - const int16_t len ); - -void expand_range_flt( - float *in, - float *out, - const int16_t len ); - -void bandcombinepow_flt( - const float *bandpow, /* i : Power for each band */ - const int16_t nband, /* i : Number of bands */ - int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const int16_t npart, /* i : Number of partitions */ - const float *psize_inv_flt, /* i : Inverse partition sizes */ - float *partpow /* o : Power for each partition */ -); - -void scalebands_flt( - const float *partpow, /* i : Power for each partition */ - int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const int16_t npart, /* i : Number of partitions */ - int16_t *midband, /* i : Central band of each partition */ - const int16_t nFFTpart, /* i : Number of FFT partitions */ - const int16_t nband, /* i : Number of bands */ - float *bandpow, /* o : Power for each band */ - const int16_t flag_fft_en ); - -void AnalysisSTFT_flt( - const float *timeDomainInput, - float *fftBuffer, /* o : FFT bins */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void SynthesisSTFT_flt( - float *fftBuffer, - float *timeDomainOutput, - float *olapBuffer, - const float *olapWin, - const int16_t tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, - const int16_t element_mode, /* i : element mode */ - const int16_t nchan_out /* i : number of output channels */ -); - -void lpc_from_spectrum_flt( - HANDLE_FD_CNG_COM hFdCngCom, - const int16_t start, - const int16_t stop, - const float preemph_fac ); - -ivas_error createFdCngDec( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -void deleteFdCngDec( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -void initFdCngDec( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -); - -void configureFdCngDec( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const int16_t bwidth, - const int32_t total_brate, - const int16_t L_frame, - const int16_t last_L_frame, - const int16_t element_mode ); - -void ApplyFdCng( - float *timeDomainInput, - float *powerSpectrum, - float **realBuffer, /* i/o: Real part of the buffer */ - float **imagBuffer, /* i/o: Imaginary part of the buffer */ - Decoder_State *st, - const int16_t concealWholeFrame, /* i : binary flag indicating frame loss */ - const int16_t is_music ); - -void generate_comfort_noise_dec( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nchan_out /* i : number of output channels */ -); - -/*! r: CNG energy */ -float cng_energy( - const int16_t element_mode, /* i : element mode */ - const int16_t bwidth, /* i : audio bandwidh */ - const int16_t CNG_mode, /* i : mode for DTX configuration */ - const float CNG_att, /* i : attenuation factor for CNG */ - const float *inputBuffer, /* i : input signal */ - const int16_t len /* i : vector length */ -); - -void FdCng_decodeSID( - Decoder_State *st /* i/o: decoder state structure */ -); - -void FdCng_exc_flt( - HANDLE_FD_CNG_COM hFdCngCom, - int16_t *CNG_mode, - const int16_t L_frame, - const float *lsp_old, - const int16_t first_CNG, - float *lsp_CNG, - float *Aq, /* o : LPC coeffs */ - float *lsp_new, /* o : lsp */ - float *lsf_new, /* o : lsf */ - float *exc, /* o : LP excitation */ - float *exc2, /* o : LP excitation */ - float *bwe_exc /* o : LP excitation for BWE */ -); - -void noisy_speech_detection( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ - const int16_t vad, /* i : VAD flag */ - const float syn[] /* i : input time-domain frame */ -); - -void deleteFdCngEnc( - HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */ -); - - -void resetFdCngEnc( - Encoder_State *st /* i/o: encoder state structure */ -); - -void perform_noise_estimation_enc( - float *band_energies, /* i : energy in critical bands without minimum noise floor E_MIN */ - float *enerBuffer, /* i : energy buffer */ - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ - const int32_t input_Fs, /* i : input sampling rate */ - CPE_ENC_HANDLE hCPE ); - -void AdjustFirstSID( - Encoder_State *st /* i/o: encoder state structure */ -); - -void FdCng_encodeSID( - Encoder_State *st /* i/o: encoder state structure */ -); - -void GetParameters( - ParamsBitMap const *paramsBitMap, - const int16_t nParams, - void const *pParameter, - int16_t **pStream, - int16_t *pnSize, - int16_t *pnBits ); - -void SetParameters( - ParamsBitMap const *paramsBitMap, - const int16_t nParams, - void *pParameter, - const int16_t **pStream, - int16_t *pnSize ); - -void WriteToBitstream( - ParamsBitMap const *paramsBitMap, - const int16_t nParams, - const int16_t **pStream, - int16_t *pnSize, - BSTR_ENC_HANDLE hBstr, - int16_t *pnBits ); - -void ReadFromBitstream( - ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, - Decoder_State *st, - int16_t **pStream, - int16_t *pnSize ); - -void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ); -void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ); -void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue ); -void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value ); - -int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); -int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); -int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index ); - -int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index ); -int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -void ResetTnsData_flt( - STnsData *pTnsData ); - -void ClearTnsFilterCoefficients_flt( - STnsFilter *pTnsFilter ); - - -int16_t DetectTnsFilt( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const float pSpectrum[], /* i : MDCT spectrum */ - TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */ - const int16_t isTCX10, /* i : TCX10 or TCX20? */ - const float ltp_gain, /* i : LTP gain */ - STnsData *pTnsData, /* o : TNS data struct */ - float *predictionGain /* o : TNS prediction gain */ -); - -void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - int16_t *stream, /* o : internal data stream */ - int16_t *pnSize, /* o : number of written parameters */ - int16_t *pnBits /* o : number of written bits */ -); - -int16_t DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const int16_t *stream, - int16_t *pnSize, - STnsData *pTnsData ); - -void WriteTnsData( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const int16_t *stream, /* i : internal data stream */ - int16_t *pnSize, /* o : number of written parameters */ - BSTR_ENC_HANDLE hBstr, /* o : bitstream */ - int16_t *pnBits /* o : number of written bits */ -); - -void ReadTnsData_ivas( - STnsConfig const *pTnsConfig, - Decoder_State *st, - int16_t *pnBits, - int16_t *stream, - int16_t *pnSize ); - -void cldfbAnalysis_ivas( - const float *timeIn, /* i : time buffer */ - float **realBuffer, /* o : real value buffer */ - float **imagBuffer, /* o : imag value buffer */ - const int16_t samplesToProcess, /* i : number of input samples */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ -); - -void cldfbAnalysis_ts_ivas( - const float *timeIn, /* i : time buffer */ - float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const int16_t samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ -); - -void cldfbSynthesis_ivas( - float **realBuffer, /* i : real values */ - float **imagBuffer, /* i : imag values */ - float *timeOut, /* o : synthesized output */ - const int16_t samplesToProcess, /* i : number of samples */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ -); - -void configureCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const int32_t sampling_rate /* i : sampling rate */ -); - - -void analysisCldfbEncoder_ivas( - Encoder_State *st, /* i/o: encoder state structure */ - const float *timeIn, - const int16_t samplesToProcess, - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float *ppBuf_Ener ); - -void analysisCldfbEncoder_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *timeIn, /*q11*/ - Word16 timeInq, /*q0*/ - Word16 samplesToProcess, /*q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 *ppBuf_Ener, - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - -ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const int32_t sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - -ivas_error openCldfb_ivas_enc( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - -void resampleCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const int32_t newSamplerate /* i : new samplerate to operate */ -); - -ivas_error cldfb_save_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void cldfb_restore_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void cldfb_reset_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void deleteCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -); - -void fft_cldfb( - float *data, /* i/o: input/output vector */ - const int16_t size /* i : size of fft operation */ -); - -void BITS_ALLOC_init_config_acelp_IVAS( - const int32_t bit_rate, - const int16_t narrowBand, - const int16_t nb_subfr, - ACELP_config *acelp_cfg /* o : configuration structure of ACELP */ -); - -int16_t BITS_ALLOC_config_acelp_IVAS( - const int16_t bits_frame, /* i : remaining bit budget for the frame */ - const int16_t coder_type, /* i : acelp coder type */ - ACELP_config *acelp_cfg, /* i/o: configuration structure of ACELP */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t nb_subfr /* i : number of subframes */ -); - - -void FEC_clas_estim( - const float *syn, - const float *pitch, /* i : pitch values for each subframe */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t coder_type, /* i : coder type */ - const int16_t codec_mode, /* i : codec mode */ - float *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - int16_t *clas, /* i/o: frame classification */ - float *lp_speech, /* i/o: long term active speech energy average */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - int16_t *decision_hyst, /* i/o: hysteresis of the music/speech decision */ - int16_t *locattack, /* i/o: detection of attack (mainly to localized speech burst) */ - int16_t *UV_cnt, /* i/o: number of consecutives frames classified as UV */ - float *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV */ - float *Last_ener, /* i/o: last_energy frame */ - int16_t *amr_io_class, /* i/o: classification for AMR-WB IO mode */ - float *lt_diff_etot, /* i/o: long-term total energy variation */ - float *class_para, /* o : classification para. fmerit1 */ - const float LTP_Gain, /* i : */ - const int16_t narrowBand, /* i : */ - const SIGNAL_CLASSIFIER_MODE mode, /* i : */ - const int16_t bfi, /* i : */ - const float preemph_fac, /* i : */ - const int16_t tcxonly, /* i : */ - const int32_t last_core_brate, /* i : last core bitrate */ - const int16_t FEC_mode /* i : ACELP FEC mode */ -); - - -void SetTCXModeInfo( - Encoder_State *st, /* i/o: encoder state structure */ - TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */ - int16_t *tcxModeOverlap /* o : window overlap of current frame */ -); - -void TCX_MDCT_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDST_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDCT_Inverse_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDST_Inverse_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDXT_Inverse_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const uint16_t kernel_type ); - -void post_decoder_flt( - Decoder_State *st, - float synth_buf[], - const float pit_gain[], - const int16_t pitch[], - float signal_out[], - float bpf_noise_buf[] ); -void cldfb_synth_set_bandsToZero_flt( - Decoder_State *st, /* i/o: decoder state structure */ - float **rAnalysis, - float **iAnalysis, - const int16_t nTimeSlots ); - -void longadd( - uint16_t a[], /* i/o: vector of the length lena */ - const uint16_t b[], /* i/o: vector of the length lenb */ - const int16_t lena, /* i/o: length of vector a[] */ - const int16_t lenb /* i/o: length of vector b[] */ -); - -void longshiftright( - uint16_t a[], /* i : vector of the length lena */ - const int16_t b, /* i : number of bit positions to shift right */ - uint16_t d[], /* o : vector of the length lend */ - int16_t lena, /* i : length of vector a[] */ - const int16_t lend /* i : length of vector d[] */ -); - -void longshiftleft( - const uint16_t a[], /* i : vector of the length len */ - const int16_t b, /* i : number of bit positions to shift left */ - uint16_t d[], /* o : vector of the length len */ - const int16_t len /* i : length of vector a[] and d[] */ -); - -void open_decoder_LPD( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t last_total_brate, /* i : last total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t last_element_mode, /* i : last element mode */ - const int16_t is_init /* i : indicate call during initialization */ -); - -void acelp_plc_mdct_transition( - Decoder_State *st /* i/o: Decoder state */ -); - -void tcxltp_dec_init( - TCX_LTP_DEC_HANDLE hTcxLtpDec, - const int16_t ini_frame, - const int16_t last_codec_mode, - const int16_t element_mode, - const int16_t pit_max, - const int32_t sr_core ); - -void reset_tcx_overl_buf( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ -); - -void update_decoder_LPD_cng_flt( - Decoder_State *st, /* i/o: decoder state structure */ - float *timeDomainBuffer, - float *A, - float *bpf_noise_buf ); - -void reconfig_decoder_LPD_ivas( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t bits_frame, /* i : bit budget */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t L_frame_old /* i : frame length */ -); - -void mode_switch_decoder_LPD( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t last_total_brate, /* i : last frame total bitrate */ - const int16_t frame_size_index, /* i : index determining the frame size */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const int16_t last_element_mode /* i : last element mode */ -); - -void dec_acelp_tcx_frame( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *concealWholeFrame, /* i/o: concealment flag */ - float *output, /* o : synthesis */ - float *bpf_noise_buf, /* i/o: BPF noise buffer */ - float *pcmbufFB, /* o : synthesis @output_FS */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float pitch_buf[], /* o : floating pitch for each subframe */ - STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ -); - -void decoder_LPD( - Decoder_State *st, /* i/o: decoder memory state pointer */ - float signal_out[], /* o : signal with LPD delay (7 subfrs) */ - float signal_outFB[], /* o : synthesis @output_FS */ - int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ - float *bpf_noise_buf, /* i/o: BPF noise buffer */ - int16_t bfi, /* i : BFI flag */ - int16_t *bitsRead, /* o : number of read bits */ - int16_t param[], /* o : buffer of parameters */ - float *pitch_buf, /* i/o: floating pitch values for each subfr*/ - float *voice_factors, /* o : voicing factors */ - float *ptr_bwe_exc /* o : excitation for SWB TBE */ -); - -int16_t tcxGetNoiseFillingTilt_flt( - const float A[], - const int16_t L_frame, - const int16_t mode, - float *noiseTiltFactor ); - -void tcxFormantEnhancement_flt( - float xn_buf[], - const float *gainlpc, - float spectrum[], - const int16_t L_frame ); - -void tcxInvertWindowGrouping_flt( - TCX_CONFIG_HANDLE hTcxCfg, - float xn_buf[], - float spectrum[], - const int16_t L_frame, - const int8_t fUseTns, - const int16_t last_core, - const int16_t index, - const int16_t frame_cnt, - const int16_t bfi ); - -void tcx5SpectrumInterleaving( - const int16_t tcx5Size, - float *spectrum ); - -void tcx5SpectrumDeinterleaving( - const int16_t tcx5Size, - float *spectrum ); - -void tcx5TnsGrouping( - const int16_t L_frame, - const int16_t L_spec, - float *spectrum ); - -void tcx5TnsUngrouping( - const int16_t L_frame, - const int16_t L_spec, - float *spectrum, - const int16_t enc_dec ); - -void lerp_flt( - const float *f, - float *f_out, - const int16_t bufferNewSize, - const int16_t bufferOldSize ); - -void encoderSideLossSimulation( - Encoder_State *st, - PLC_ENC_EVS_HANDLE hPlc_Ext, - float *isf_q, - const float stab_fac, - const int16_t calcOnlyISF, - const int16_t L_frame ); - -void enc_prm_side_Info( - PLC_ENC_EVS_HANDLE hPlc_Ext, - Encoder_State *st ); - -void GplcTcxEncSetup( - const int16_t tcxltp_pitch_int, - PLC_ENC_EVS_HANDLE hPlc_Ext ); - -int16_t encSideSpecPowDiffuseDetector( - float *isf_ref, - float *isf_con, - const int32_t sr_core, - float *prev_isf4_mean, - const int16_t sw, - const int16_t coder_type ); - -void updateSpecPowDiffuseIdx( - const float gain_pitch_buf[], /* i : gain pitch values */ - const float gain_code_buf[], /* i : gain pitch values */ - int16_t glr_idx[2], /* o : */ - float mean_gc[2] /* o : */ -); - -void getLookAheadResSig_flt( - float *speechLookAhead, - const float *A, - float *res, - const int16_t L_frame, - const int16_t L_subfr, - const int16_t m, - const int16_t numSubFrame ); - -void updatelsfForConcealment_flt( - PLC_ENC_EVS_HANDLE decState, - float *lsf ); - -void getConcealedLP_flt( - PLC_ENC_EVS_HANDLE memDecState, - float *AqCon, - const float xsfBase[], - const int32_t sr_core, - const int16_t last_good, - const int16_t L_frame ); - -void RecLpcSpecPowDiffuseLc_flt( - float *ispq, - float *isp_old, - float *isfq, - Decoder_State *st, - const int16_t reset_q ); - -void modify_lsf_flt( - float *lsf, - const int16_t n, - const int32_t sr_core, - const int16_t reset_q ); - -void init_PLC_enc( - PLC_ENC_EVS_HANDLE hPlcExt, - const int32_t sr_core ); - -void gPLC_encInfo( - PLC_ENC_EVS_HANDLE hPlcExt, - const int32_t total_brate, - const int16_t bwidth, - const int16_t last_clas, - const int16_t coder_type ); - -void resetTecDec( - TEC_DEC_HANDLE hTecDec ); - -void calcGainTemp_TBE( - float **pCldfbRealSrc, - float **pCldfbImagSrc, - float *loBuffer, - const int16_t startPos, /*!< Start position of the current envelope. */ - const int16_t stopPos, /*!< Stop position of the current envelope. */ - const int16_t lowSubband, /* lowSubband */ - float *pGainTemp, - const int16_t code ); - -void procTecTfa_TBE( - float *hb_synth, - float *gain, - const int16_t flat_flag, - const int16_t last_core, - const int16_t L_subfr, - const int16_t code ); - -void resetTecEnc( - TEC_ENC_HANDLE hTecEnc, - const int16_t flag ); - -void calcHiEnvLoBuff( - const int16_t noCols, - const int16_t *pFreqBandTable, /* i : freqbandTable */ - const int16_t nSfb, /* i : Number of scalefactors */ - float **pYBuf, - float *loBuf, - float *hiTempEnv ); - -void calcLoEnvCheckCorrHiLo( - const int16_t noCols, - const int16_t *pFreqBandTable, /* i : freqbandTable */ - float *loBuf, - float *loTempEnv, - float *loTempEnv_ns, - float *hiTempEnv, - int16_t *corr_flag /* o : 0 for original, 1 for TEC */ -); - - -void tecEnc_TBE( - int16_t *corrFlag, - const float *voicing, - const int16_t coder_type ); - -void set_TEC_TFA_code( - const int16_t corrFlag, - int16_t *tec_flag, - int16_t *tfa_flag ); - -float Damping_fact_flt( - const int16_t coder_type, /* i : ACELP core coder type */ - const int16_t nbLostCmpt, /* i : compt for number of consecutive lost frame */ - int16_t last_good, /* i : class of last good received frame */ - float stab_fac, /* i : LSF stability factor */ - float *lp_gainp, /* i/o: low passed pitch gain used for concealment */ - const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */ -); - -float getLevelSynDeemph( - const float h1Init[], /* i : input value or vector to be processed */ - const float A[], /* i : LPC coefficients */ - const int16_t lenLpcExc, /* i : length of the LPC excitation buffer */ - const float preemph_fac, /* i : preemphasis factor */ - const int16_t numLoops /* i : number of loops */ -); - -void genPlcFiltBWAdap( - const int32_t sr_core, /* i : core sampling rate */ - float *lpFiltAdapt, /* o : filter coefficients for filtering codebooks in case of flc */ - const int16_t type, /* i : type of filter, either 0 : lowpass or 1 : highpass */ - const float alpha /* i : fade out factor [0 1) used decrease filter tilt */ -); - -void highPassFiltering( - const int16_t last_good, /* i : last classification type */ - const int16_t L_buffer, /* i : buffer length */ - float exc2[], /* i/o: unvoiced excitation before the high pass filtering */ - const float hp_filt[], /* i : high pass filter coefficients */ - const int16_t l_fir_fer /* i : high pass filter length */ -); - -int16_t GetPLCModeDecision( - Decoder_State *st /* i/o: decoder memory state pointer */ -); - -void addBassPostFilter( - const float *harm_timeIn, - const int16_t samplesToProcess, - float **rAnalysis, - float **iAnalysis, - HANDLE_CLDFB_FILTER_BANK cldfb ); - -ivas_error TonalMDCTConceal_Init_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - const uint16_t samplesPerBlock, - const uint16_t nSamplesCore, - const uint16_t nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg ); - -void TonalMDCTConceal_SaveFreqSignal_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - const float *mdctSpectrum, - const uint16_t numSamples, - const uint16_t nNewSamplesCore, - const float *scaleFactors, - const int16_t infoIGFStartLine ); - -void TonalMDCTConceal_UpdateState_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - const int16_t numSamples, - const float pitchLag, - const int16_t badBlock, - const int16_t tonalConcealmentActive ); - -void TonalMDCTConceal_SaveTimeSignal_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - float *timeSignal, - const int16_t numSamples ); - -void TonalMDCTConceal_Detect_ivas( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - const float pitchLag, /*IN */ - int16_t *umIndices, /*OUT*/ - const PsychoacousticParameters *psychParamsCurrent /*IN*/ -); - -void TonalMDCTConceal_Apply_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - float *mdctSpectrum, /*OUT*/ - const PsychoacousticParameters *psychParamsCurrent /*IN*/ -); - -void TonalMDCTConceal_InsertNoise_ivas( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - float *mdctSpectrum, /*OUT*/ - const int16_t tonalConcealmentActive, - int16_t *pSeed, /*IN/OUT*/ - const float tiltCompFactor, - const float crossfadeGain, - const float concealment_noise[L_FRAME48k], - const float cngLevelBackgroundTrace_bfi, - const int16_t crossOverFreq ); - -void DetectTonalComponents_flt( - uint16_t indexOfTonalPeak[], - uint16_t lowerIndex[], - uint16_t upperIndex[], - uint16_t *pNumIndexes, - const float lastPitchLag, - const float currentPitchLag, - const float lastMDCTSpectrum[], - const float scaleFactors[], - const float secondLastPowerSpectrum[], - const uint16_t nSamples, - const uint16_t nSamplesCore, - float floorPowerSpectrum, - const PsychoacousticParameters *psychParamsCurrent ); - -void RefineTonalComponents_flt( - uint16_t indexOfTonalPeak[], - uint16_t lowerIndex[], - uint16_t upperIndex[], - float phaseDiff[], - float phases[], - uint16_t *pNumIndexes, - const float lastPitchLag, - const float currentPitchLag, - const float lastMDCTSpectrum[], - const float scaleFactors[], - const float secondLastPowerSpectrum[], - const uint16_t nSamples, - const uint16_t nSamplesCore, - float floorPowerSpectrum, - const PsychoacousticParameters *psychParamsCurrent ); - -ivas_error PsychoacousticParameters_Init( - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t nBins, /* i : Number of bins (spectral lines) */ - const int8_t nBands, /* i : Number of spectrum subbands */ - const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); - -void concealment_init( - const int16_t L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_decode( - const int16_t core, - float *invkoef, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_update( - const int16_t bfi, - const int16_t core, - const int16_t harmonic, - float *invkoef, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_update2( - const float *outx_new, - T_PLCInfo_HANDLE hPlcInfo, - const int16_t L_frameTCX ); - -void concealment_signal_tuning( - Decoder_State *st, - const int16_t bfi, - float *outx_new, - const int16_t past_core_mode ); - -void waveform_adj2( - T_PLCInfo_HANDLE hPlcInfo, - float *overlapbuf, - float *outx_new, - const int16_t delay, - const int16_t bfi_cnt, - const int16_t bfi ); - -float SFM_Cal( - const float fcoef[], - const int16_t n ); - -void set_state_ivas( - int16_t *state, - const int16_t num, - const int16_t N ); - -int16_t RFFTN( - float *afftData, - const float *trigPtr, - const int16_t len, - const int16_t isign ); - -void DoFFT( - float *re2, - float *im2, - const int16_t length ); - -/*! r: flag indicating a valid bitrate */ -int16_t is_EVS_bitrate( - const int32_t ivas_total_brate, /* i : EVS total bitrate */ - int16_t *Opt_AMR_WB /* i : AMR-WB IO flag */ -); - -int16_t getTcxonly_ivas( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const int16_t is_ism_format /* i : flag indicating ISM format */ -); - -int16_t getTnsAllowed( - const int32_t total_brate, /* i : total bitrate */ - const int16_t igf, /* i : flag indicating IGF activity*/ - const int16_t element_mode /* i : IVAS element mode */ -); - -int16_t getCtxHm( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t rf_flag /* i : flag to signal the RF mode */ -); - -int16_t getResq( - const int32_t total_brate /* i : total bitrate */ -); - -int16_t getMdctWindowLength( - const int16_t fscale ); - -int16_t sr2fscale( - const int32_t sr_core /* i : internal sampling rate */ -); - -int32_t getCoreSamplerateMode2_flt( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ -); - -float getTcxBandwidth_flt( - const int16_t bwidth /* i : audio bandwidth */ -); - - -int16_t getCnaPresent( - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -int16_t getTcxLtp( - const int32_t sr_core /* i : internal sampling rate */ -); - -int16_t initPitchLagParameters( - const int32_t sr_core, /* i : internal sampling rate */ - int16_t *pit_min, - int16_t *pit_fr1, - int16_t *pit_fr1b, - int16_t *pit_fr2, - int16_t *pit_max ); - -void attenuateNbSpectrum( - const int16_t L_frame, - float *spectrum ); - -void SetModeIndex( - Encoder_State *st, /* i : Encoder state */ - const int32_t last_total_brate, /* i : last total bitrate */ - const int16_t last_element_mode, /* i : last IVAS element mode */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -int16_t getNumTcxCodedLines( - const int16_t bwidth /* i : audio bandwidth */ -); - -int16_t getTcxLpcShapedAri( - const int32_t total_brate, /* i : total bitrate */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void IGFEncApplyMono( - Encoder_State *st, /* i : Encoder state */ - const int16_t igfGridIdx, /* i : IGF grid index */ - float *pMDCTSpectrum, /* i/o: MDCT spectrum */ - float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const int16_t isTNSActive, /* i : flag indicating if the TNS is active */ - const int16_t sp_aud_decision0, /* i : first stage switching decision */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void IGFEncApplyStereo( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ - int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ - const int16_t igfGridIdx, /* i : IGF grid index */ - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t frameno, /* i : flag indicating index of current subframe */ - const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - - -void IGFEncResetTCX10BitCounter_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */ -); - -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const int16_t igf, /* i : IGF on/off */ - const int16_t reset, /* i : reset flag */ - const int32_t brate, /* i : bitrate for configuration */ - const int16_t bwidth, /* i : signal bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -void IGFEncSetMode( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const int32_t total_brate, /* i : encoder total bitrate */ - const int16_t bwidth, /* i : encoder audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -/*! r: number of bits written per frame */ -int16_t IGFEncWriteBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t *pBitOffset, /* i : ptr to bitOffset counter */ - const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -); - -/*! r: total number of bits written */ -int16_t IGFEncWriteConcatenatedBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void IGFDecApplyMono_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ - float *spectrum, /* i/o: MDCT spectrum */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void IGFDecCopyLPCFlatSpectrum_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const float *pSpectrumFlat, /* i : LPC flattend spectrum from TCX dec */ - const int16_t igfGridIdx /* i : IGF grid index */ -); - -void IGFDecReadData_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */ - Decoder_State *st, /* i : decoder state */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ -); - -/*! r: return igfAllZero flag indicating if no envelope is transmitted */ -int16_t IGFDecReadLevel_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */ - Decoder_State *st, /* i : decoder state */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ -); - -void IGFDecRestoreTCX10SubFrameData_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const int16_t subFrameIdx /* i : index of subframe */ -); - -void init_igf_dec_flt( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ -); - -void IGFDecSetMode_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const int32_t total_brate, /* i : bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t defaultStartLine, /* i : default start subband index */ - const int16_t defaultStopLine, /* i : default stop subband index */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -void IGFDecStoreTCX10SubFrameData_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const int16_t subFrameIdx /* i : index of subframe */ -); - -void IGFDecUpdateInfo_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const int16_t subFrameIdx, /* i : subframe index */ - const int16_t igfGridIdx /* i : IGF grid index */ -); - -/*! r: error value: 0 -> error, 1 -> ok */ -int16_t IGFCommonFuncsIGFConfiguration_flt( - const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -/*! r: error value: 0 -> error, 1 -> ok */ -int16_t IGFCommonFuncsIGFGetCFTables_flt( - const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : element mode */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const uint16_t **cf_se00, /* i : CF table for t == 0 and f == 0 */ - const uint16_t **cf_se01, /* i : CF table for t == 0 and f == 1 */ - int16_t *cf_off_se01, /* o : offset for CF table above */ - const uint16_t **cf_se02, /* i : CF tables for t == 0 and f >= 2 */ - const int16_t **cf_off_se02, /* o : offsets for CF tables above */ - const uint16_t **cf_se10, /* i : CF table for t == 1 and f == 0 */ - int16_t *cf_off_se10, /* o : offset for CF table above */ - const uint16_t **cf_se11, /* i : CF tables for t == 1 and f >= 1 */ - const int16_t **cf_off_se11 /* o : offsets for CF tables above */ -); - -/*! r: multiplication factor */ -int16_t IGF_ApplyTransFac_flt( - const int16_t val, /* i : input value for multiplication, Q15 */ - const float transFac /* i : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ -); - -/*! r: return bitrate index */ -int16_t IGF_MapBitRateToIndex_flt( - const int32_t brate, /* i : bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - - -void IGFSCFDecoderOpen_ivas( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ - H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const int32_t total_brate, - const int16_t bwidth, - const int16_t element_mode, - const int16_t rf_mode ); - -void IGFSCFDecoderReset_ivas( - IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */ -); - -void IGFSCFDecoderDecode_ivas( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ - Decoder_State *st, /* i/o: pointer to decoder state */ - int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ - const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset, - if 0 on input the decoder will be forced to encode without a reset */ -); - -/*! r: offset value */ -int16_t tbe_celp_exc_offset_flt( - const int16_t T0, /* i : Integer pitch */ - const int16_t T0_frac /* i : Fractional part of the pitch */ -); - -void blend_subfr2_flt( - float *sigIn1, /* i : input signal for fade-out */ - float *sigIn2, /* i : input signal for fade-in */ - float *sigOut /* o : output signal */ -); - -void init_tcx_window_cfg( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ - const int32_t sr_core, /* i : SR core */ - const int32_t input_Fs, /* i : input/output SR */ - const int16_t L_frame, /* i : L_frame at sr_core */ - const int16_t L_frameTCX, /* i : L_frame at i/o SR */ - const int16_t encoderLookahead_enc, /* i : encoder LA at sr_core */ - const int16_t encoderLookahead_FB, /* i : encoder LA at i/o SR */ - const int16_t mdctWindowLength, /* i : window length at sr_core */ - const int16_t mdctWindowLengthFB, /* i : window length at i/o SR */ - const int16_t element_mode /* i : mode of CPE/SCE */ -); - -void init_tcx_cfg( - TCX_CONFIG_HANDLE hTcxCfg, - const int32_t total_brate, - const int32_t sr_core, - const int32_t input_Fs, - const int16_t L_frame, - const int16_t bwidth, - const int16_t L_frameTCX, - const int16_t fscale, - const int16_t encoderLookahead_enc, - const int16_t encoderLookahead_FB, - const float preemph_fac, - const int16_t tcxonly, - const int16_t rf_mode, - const int16_t igf, - const int16_t infoIGFStopFreq, - const int16_t element_mode, - const int16_t ini_frame, - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -#endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 51fbb12d5..9b596ca42 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -49,14 +49,63 @@ #include "ivas_cnst.h" #include "stat_enc.h" #include "stat_dec.h" +#include "stat_com.h" #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" +#include "ivas_stat_com.h" #include "ivas_error.h" #include "ivas_error_utils.h" #include "complex_basop.h" #define TCX_IMDCT_SCALE 15 #define TCX_IMDCT_HEADROOM 1 + +/*----------------------------------------------------------------------------------* + * Prototypes of global macros + *----------------------------------------------------------------------------------*/ + +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef TRUNC +#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) ) +#endif + +#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) +#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) + +#ifndef ABSVAL +#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) +#endif + +#ifndef SQR +#define SQR( a ) ( ( a ) * ( a ) ) +#endif + +#ifndef SWAP +#define SWAP( a, b ) \ + { \ + tempr = ( a ); \ + ( a ) = ( b ); \ + ( b ) = tempr; \ + } +#endif + +#ifndef swap +#define swap( x, y, type ) \ + { \ + type u__p; \ + u__p = x; \ + x = y; \ + y = u__p; \ + } +#endif + /*================================================================================*/ /* conversion functions: */ /*================================================================================*/ @@ -10920,7 +10969,6 @@ void IGFEncConcatenateBitstream( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); -#endif void hq_generic_hf_encoding_fx( const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ @@ -11205,3 +11253,746 @@ void WriteToBitstream_ivas_fx( Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); + + +/*===========================================================================================*/ +/*----------------------------------------------------------------------------------* + * MODE1 prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: inverse square root of input value */ +float inv_sqrt( + const float x /* i : input value */ +); + +/*! r: output random value */ +int16_t own_random( + int16_t *seed /* i/o: random seed */ +); + +/*! r: sign of x (+1/-1) */ +float sign( + const float x /* i : input value of x */ +); + +/*! r: logarithm2 of x */ +float log2_f( + const float x /* i : input value of x */ +); + +int16_t norm_ul_float( + uint32_t UL_var1 ); + +/*! r: sum of all vector elements */ +int16_t sum_s( + const int16_t *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +/*! r: sum of all vector elements */ +int32_t sum_l( + const int32_t *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +/*! r: sum of all squared vector elements */ +float sum2_f( + const float *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +void set_c( + int8_t y[], /* i/o: Vector to set */ + const int8_t a, /* i : Value to set the vector to */ + const int32_t N /* i : Length of the vector */ +); + +void set_s( + int16_t y[], /* i/o: Vector to set */ + const int16_t a, /* i : Value to set the vector to */ + const int16_t N /* i : Lenght of the vector */ +); + +void set_l( + int32_t y[], /* i/o: Vector to set */ + const int32_t a, /* i : Value to set the vector to */ + const int16_t N /* i : Length of the vector */ +); + +void set_f( + float y[], /* i/o: Vector to set */ + const float a, /* i : Value to set the vector to */ + const int16_t N /* i : Lenght of the vector */ +); + +void set_zero_fx( + Word32 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); +void set_zero2_fx( + Word32 *vec, /* o : input vector */ + const Word32 lvec /* i : length of the vector */ +); +void set16_zero_fx( + Word16 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); + +void set_zero( + float *vec, /* o : input vector */ + const int16_t lvec /* i : length of the vector */ +); + +void mvr2r( + const float x[], /* i : input vector */ + float y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void mvs2s( + const int16_t x[], /* i : input vector */ + int16_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +uint32_t mvr2s( + const float x[], /* i : input vector */ + int16_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void mvs2r( + const int16_t x[], /* i : input vector */ + float y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void mvl2l( + const int32_t x[], /* i : input vector */ + int32_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + + +/*! r: index of the maximum value in the input vector */ +int16_t maximum( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *max_val /* o : maximum value in the input vector */ +); +/*! r: index of the maximum value in the input vector */ +int16_t maximumAbs( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *max_val /* o : maximum value in the input vector */ +); + +Word16 maximumAbs_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +int16_t minimum( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *min_val /* o : minimum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +int16_t minimum_s( + const int16_t *vec, /* i : Input vector */ + const int16_t lvec, /* i : Vector length */ + int16_t *min_val /* o : minimum value in the input vector */ +); + +/*! r: return index with max energy value in vector */ +int16_t emaximum( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *ener_max /* o : maximum energy value */ +); + +/*! r: vector mean */ +float mean( + const float *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +/*! r: dot product of x[] and y[] */ +float dotp( + const float x[], /* i : vector x[] */ + const float y[], /* i : vector y[] */ + const int16_t n /* i : vector length */ +); + +void v_add( + const float x1[], /* i : Input vector 1 */ + const float x2[], /* i : Input vector 2 */ + float y[], /* o : Output vector that contains vector 1 + vector 2 */ + const int16_t N /* i : Vector length */ +); + +void v_sub( + const float x1[], /* i : Input vector 1 */ + const float x2[], /* i : Input vector 2 */ + float y[], /* o : Output vector that contains vector 1 - vector 2 */ + const int16_t N /* i : Vector length */ +); + +/*! r: dequanzited gain */ +float usdequant( + const int16_t idx, /* i : quantizer index */ + const float qlow, /* i : lowest codebook entry (index 0) */ + const float delta /* i : quantization step */ +); + +void sort( + uint16_t *x, /* i/o: Vector to be sorted */ + uint16_t len /* i/o: vector length */ +); + +void sort_l( + Word32 *x, /* i/o: Vector to be sorted */ + Word16 len /* i/o: vector length */ +); + + +ivas_error push_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + int16_t id, /* i : ID of the indice */ + uint16_t value, /* i : value of the quantized indice */ + int16_t nb_bits /* i : number of bits used to quantize the indice */ +); + +ivas_error push_next_indice( + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +ivas_error push_next_bits( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +/*! r: maximum number of indices */ +int16_t get_BWE_max_num_indices( + const int32_t extl_brate /* i : extensiona layer bitrate */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_metadata_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); +ivas_error ind_list_realloc( + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ +); + +ivas_error check_ind_list_limits( + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +); + +void move_indices( + INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ + INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ + const int16_t nb_indices /* i : number of moved indices */ +); + +/*! r: index of the indice in the list, -1 if not found */ +int16_t find_indice( + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + const int16_t id, /* i : ID of the indice */ + uint16_t *value, /* o : value of the quantized indice */ + int16_t *nb_bits /* o : number of bits used to quantize the indice */ +); + +/*! r: number of deleted indices */ +uint16_t delete_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t id /* i : ID of the indice */ +); + +/*! r: value of the indice */ +uint16_t get_next_indice( + Decoder_State *st, /* i/o: decoder state structure */ + int16_t nb_bits /* i : number of bits that were used to quantize the indice */ +); + +/*! r: value of the indice */ +uint16_t get_next_indice_1( + Decoder_State *st /* i/o: decoder state structure */ +); + +void get_next_indice_tmp( + Decoder_State *st, /* o : decoder state structure */ + int16_t nb_bits /* i : number of bits that were used to quantize the indice */ +); + +/*! r: value of the indice */ +uint16_t get_indice( + Decoder_State *st, /* i/o: decoder state structure */ + int16_t pos, /* i : absolute position in the bitstream */ + int16_t nb_bits /* i : number of bits that were used to quantize the indice */ +); + +void reset_indices_enc( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t max_num_indices /* i : max number of indices */ +); + +void reset_indices_dec( + Decoder_State *st /* i/o: decoder state structure */ +); + +Word16 rate2EVSmode_float( + const Word32 brate, /* i : bitrate */ + int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ +); + + +/*! r: 1 = OK, 0 = something wrong */ +ivas_error read_indices( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + uint16_t bit_stream[], /* i : bitstream buffer */ + UWord16 num_bits, /* i : number of bits in bitstream */ + int16_t *prev_ft_speech, + int16_t *CNG, + int16_t bfi /* i : bad frame indicator */ +); + + +void ivas_set_bitstream_pointers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void mdct_switching_dec_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +); + +int16_t print_disclaimer( + FILE *fPtr ); + +void fft_rel( + float x[], /* i/o: input/output vector */ + const int16_t n, /* i : vector length */ + const int16_t m /* i : log2 of vector length */ +); + +void preemph_ivas_fx( + Word32 *signal, /* i/o: signal Qx*/ + const Word16 mu, /* i : preemphasis factor Q15*/ + const Word16 L, /* i : vector size Q0*/ + Word32 *mem /* i/o: memory (x[-1]) Qx*/ +); + +void create_offset( + UWord32 *offset_scale1, + UWord32 *offset_scale2, + const int16_t mode, + const int16_t prediction_flag ); + +void BASOP_cfft_ivas( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ +); + +Word32 ar_div_ivas( + Word32 num, + Word32 denum ); + +Word32 Mult_32_16( + Word32 a, + Word16 b ); + +Word32 Mult_32_32( + Word32 a, + Word32 b ); + + +void bit_allocation_second_fx2( + Word32 *Rk, + Word32 *Rk_sort, + Word16 BANDS, + const Word16 *band_width, + Word16 *k_sort, + Word16 *k_num, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame ); + +void bit_allocation_second_fx2( + Word32 *Rk, + Word32 *Rk_sort, + Word16 BANDS, + const Word16 *band_width, + Word16 *k_sort, + Word16 *k_num, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame ); + +#ifdef DEBUGGING +void read_next_force( + int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ + FILE *f_force, /* i : force switching profile (0 if N/A) */ + int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ +); +#endif + +ivas_error init_encoder_ivas_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ + const Word16 interval_SID, /* i : interval for SID update */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ +); + +ivas_error acelp_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + Word16 Q_new ); + +void flip_and_downmix_generic_fx_32( + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ +); + +void GenTransition_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 element_mode, /* i : element mode : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 rf_flag, /* i : RF flag : Q0 */ + const Word32 total_brate, /* i : total bitrate : Q0 */ + const Word16 prev_Qx ); + +void GenTransition_WB_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ +); + +Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */ + const Word16 pos1, /* i: position of the pulse 1 */ + const Word16 pos2, /* i: position of the pulse 2 */ + const Word16 N /* i: number of bits FOR position */ +); + +void bands_and_bit_alloc_ivas_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, + /* i : A(z) filter coefficients */ // Q12 + Word16 *Aw_fx, + /* o : weighted A(z) filter coefficients */ // Q12 + const Word16 *speech_fx, + /* i : pointer to the denoised speech frame */ // Q_new + const Word16 tilt_fact, + /* i : tilt factor */ // Q15 + Word16 *wsp_fx, + /* o : poitnter to the weighted speech frame */ // Q_new + Word16 *mem_wsp_fx, + /* i/o: W(Z) denominator memory */ // Q_new + const Word16 gamma, + /* i : weighting factor */ // Q15 + const Word16 L_look /* i : look-ahead Q0*/ +); + +Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + const Word16 target, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem ); + +Word16 RCcontextMapping_encode2_estimate_bandWise_fx( + Word16 *x, /* Q0 */ + const Word16 start_line, /* Q0 */ + const Word16 end_line, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ +); + + +/*! r: Q15 */ +Word16 expfp_evs_fx( + const Word16 x, /* i : mantissa Q15-e */ + const Word16 x_e /* i : exponent Q0 */ +); + + +void tcx_arith_render_envelope_ivas_fx( + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ + const Word16 L_spec, /* i : length of the coded spectrum Q0*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ +); + +void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ +); + + +void UnmapIndex_fx( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word8 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ +); + +#define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution ) +#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) + + +Word32 tcx_hm_render_fx( + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ +); + + +void tcx_hm_modify_envelope_fx( + const Word16 gain, /* i: HM gain Q11 */ + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + const Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + const Word16 L_frame /* i: number of spectral lines Q0 */ +); + +void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ +); + +void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ +); + +void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ +); + +void writeLPCparam( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const int16_t param_lpc[], /* i : LPC parameters to write */ + const int16_t bits_param_lpc[], /* i : bits per LPC parameter */ + const int16_t no_param_lpc, /* i : number of LPC parameters */ + int16_t *nbits_lpc /* o : LPC bits written */ +); + +void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ); +void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ); +void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue ); +void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value ); + +int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index ); + +int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index ); +int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +void ResetTnsData_flt( + STnsData *pTnsData ); + +void ClearTnsFilterCoefficients_flt( + STnsFilter *pTnsFilter ); + +void EncodeTnsData( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + Word16 *pnBits /* o : number of written bits */ +); + +Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +void WriteTnsData( + const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ + const Word16 *stream, /* i : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + BSTR_ENC_HANDLE hBstr, /* o : bitstream */ + Word16 *pnBits /* o : number of written bits */ +); + +void ReadTnsData_ivas( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void analysisCldfbEncoder_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *timeIn, /*q11*/ + Word16 timeInq, /*q0*/ + Word16 samplesToProcess, /*q0*/ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 *ppBuf_Ener, + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + +ivas_error openCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const int32_t sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); + +ivas_error openCldfb_ivas_enc( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); + +void resampleCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate /* i : new samplerate to operate */ +); + +ivas_error cldfb_save_memory_ivas( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +void deleteCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ +); + +/*! r: flag indicating a valid bitrate */ +Word16 is_EVS_bitrate( + const Word32 ivas_total_brate, /* i : EVS total bitrate */ + Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ +); + +void IGFEncResetTCX10BitCounter_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */ +); + +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); + +/*===========================================================================================*/ +#endif diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index ed914f2a1..479bc04d9 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -4,7 +4,6 @@ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 665dbfae6..32d18d1fe 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" -#include "prot.h" /*--------------------------------------------------------------------* * residu_ivas_fx() diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index bad47f065..172dadf82 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -38,10 +38,9 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "basop_util.h" #include "wmc_auto.h" -#include "prot_fx.h" /* clang-format off */ diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index 611658884..49f50e162 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -38,7 +38,7 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ -#include "prot.h" +#include "prot_fx.h" #include "basop_util.h" #include "wmc_auto.h" #include "rom_com_fx.h" diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 2aa781a43..1f112c911 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -38,7 +38,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 6cdf1185a..7e9471c45 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7,7 +7,6 @@ #include "options.h" #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "ivas_prot_fx.h" diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index cececd8f5..44ce806f7 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -39,7 +39,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 4e40e4ab2..c5ff95e04 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" #include "rom_basop_util.h" #include "basop_util.h" -#include "prot.h" #define inv_int InvIntTable diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 515746bd5..101bc1df8 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -12,7 +12,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "basop_util.h" -#include "prot.h" /*---------------------------------------------------------------------------- * Local constants diff --git a/lib_com/tools.c b/lib_com/tools.c index 4d9f5e956..e4ccd9955 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -37,7 +37,6 @@ #include #include "options.h" #include -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" @@ -136,23 +135,6 @@ int16_t sum_s( return tmp; } -/*! r: sum of all vector elements */ -int32_t sum_l( - const int32_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - int16_t i; - int32_t tmpL; - - tmpL = 0; - for ( i = 0; i < lvec; i++ ) - { - tmpL += vec[i]; - } - - return tmpL; -} /*! r: sum of all vector elements */ Word32 sum_l_fx( const Word32 *vec, /* i : input vector */ @@ -171,23 +153,6 @@ Word32 sum_l_fx( return tmpL; } -/*! r: sum of all vector elements */ -float sum_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - int16_t i; - float tmp; - - tmp = 0.0f; - for ( i = 0; i < lvec; i++ ) - { - tmp += vec[i]; - } - - return tmp; -} /*---------------------------------------------------------------------- * sum2_f() @@ -228,22 +193,6 @@ Word32 sum2_f_16_gb_fx( return tmp; } -float sum2_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - int16_t i; - float tmp; - - tmp = 0.0f; - for ( i = 0; i < lvec; i++ ) - { - tmp += vec[i] * vec[i]; - } - - return tmp; -} Word32 sum2_16_exp_fx( const Word16 *vec, /* i : input vector Q(15 - exp) */ @@ -532,101 +481,6 @@ void mvs2s( return; } -uint32_t mvr2s( - const float x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -) -{ - int16_t i; - float temp; - uint32_t noClipping = 0; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return 0; - } - - if ( (void *) y <= (const void *) x ) - { - for ( i = 0; i < n; i++ ) - { - temp = x[i]; - temp = (float) floor( temp + 0.5f ); - - if ( temp > MAX16B_FLT ) - { - temp = MAX16B_FLT; - noClipping++; - } - else if ( temp < MIN16B_FLT ) - { - temp = MIN16B_FLT; - noClipping++; - } - - y[i] = (int16_t) temp; - } - } - else - { - for ( i = n - 1; i >= 0; i-- ) - { - temp = x[i]; - temp = (float) floor( temp + 0.5f ); - - if ( temp > MAX16B_FLT ) - { - temp = MAX16B_FLT; - noClipping++; - } - else if ( temp < MIN16B_FLT ) - { - temp = MIN16B_FLT; - noClipping++; - } - - y[i] = (int16_t) temp; - } - } - - return noClipping; -} - -void mvs2r( - const int16_t x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ -) -{ - int16_t i; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return; - } - - if ( (void *) y < (const void *) x ) - { - for ( i = 0; i < n; i++ ) - { - y[i] = (float) x[i]; - } - } - else - { - for ( i = n - 1; i >= 0; i-- ) - { - y[i] = (float) x[i]; - } - } - - return; -} - - void mvl2l( const int32_t x[], /* i : input vector */ int32_t y[], /* o : output vector */ @@ -659,44 +513,6 @@ void mvl2l( return; } - -/*---------------------------------------------------------------------* - * maximum() - * - * Find index and value of the maximum in a vector - *---------------------------------------------------------------------*/ - -/*! r: index of the maximum value in the input vector */ -int16_t maximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -) -{ - int16_t j, ind; - float tmp; - - ind = 0; - tmp = vec[0]; - - for ( j = 1; j < lvec; j++ ) - { - if ( vec[j] > tmp ) - { - ind = j; - tmp = vec[j]; - } - } - - if ( max_val != NULL ) - { - *max_val = tmp; - } - - return ind; -} - - /*! r: index of the maximum value in the input vector */ Word16 maximum_s( const Word16 *vec, /* i : input vector */ @@ -766,42 +582,6 @@ Word16 maximum_l( return ind; } -/*---------------------------------------------------------------------* - * maximumAbs() - * - * Find index and value of the maximum in a vector - *---------------------------------------------------------------------*/ - -/*! r: index of the maximum value in the input vector */ -int16_t maximumAbs( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -) -{ - int16_t j, ind; - float tmp; - - ind = 0; - tmp = (float) fabs( vec[0] ); - - for ( j = 1; j < lvec; j++ ) - { - if ( (float) fabs( vec[j] ) > tmp ) - { - ind = j; - tmp = (float) fabs( vec[j] ); - } - } - - if ( max_val != NULL ) - { - *max_val = tmp; - } - - return ind; -} - /*! r: index of the maximum value in the input vector */ Word16 maximumAbs_l( const Word32 *vec, /* i : input vector */ @@ -835,42 +615,6 @@ Word16 maximumAbs_l( return ind; } -/*---------------------------------------------------------------------* - * minimum() - * - * Find index of a minimum in a vector - *---------------------------------------------------------------------*/ - -/*! r: index of the minimum value in the input vector */ -int16_t minimum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *min_val /* o : minimum value in the input vector */ -) -{ - int16_t j, ind; - float tmp; - - ind = 0; - tmp = vec[0]; - - for ( j = 1; j < lvec; j++ ) - { - if ( vec[j] < tmp ) - { - ind = j; - tmp = vec[j]; - } - } - - if ( min_val != NULL ) - { - *min_val = tmp; - } - - return ind; -} - /*-------------------------------------------------------------------* * minimum_s() * @@ -988,59 +732,6 @@ Word16 minimum_l( return ind; } -/*---------------------------------------------------------------------* - * emaximum() - * - * Find index of a maximum energy in a vector - *---------------------------------------------------------------------*/ - -/*! r: return index with max energy value in vector */ -int16_t emaximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *ener_max /* o : maximum energy value */ -) -{ - int16_t j, ind; - float temp; - - *ener_max = 0.0f; - ind = 0; - - for ( j = 0; j < lvec; j++ ) - { - temp = vec[j] * vec[j]; - - if ( temp > *ener_max ) - { - ind = j; - *ener_max = temp; - } - } - - return ind; -} - - -/*---------------------------------------------------------------------* - * mean() - * - * Find the mean of the vector - *---------------------------------------------------------------------*/ - -/*! r: mean of vector */ -float mean( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - float tmp; - - tmp = sum_f( vec, lvec ) / (float) lvec; - - return tmp; -} - /*---------------------------------------------------------------------* * dotp() * @@ -1168,114 +859,6 @@ float inv_sqrt( return (float) ( 1.0 / sqrt( x ) ); } - -/*-------------------------------------------------------------------* - * conv() - * - * Convolution between vectors x[] and h[] written to y[] - * All vectors are of length L. Only the first L samples of the - * convolution are considered. - *-------------------------------------------------------------------*/ - -void conv( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response (or second input vector) */ - float y[], /* o : output vetor (result of convolution) */ - const int16_t L /* i : vector size */ -) -{ - float temp; - int16_t i, n; - for ( n = 0; n < L; n++ ) - { - temp = x[0] * h[n]; - for ( i = 1; i <= n; i++ ) - { - temp += x[i] * h[n - i]; - } - y[n] = temp; - } - - return; -} - -/*-------------------------------------------------------------------* - * fir() - * - * FIR filtering of vector x[] with filter having impulse response h[] - * written to y[] - * The input vector has length L and the FIR filter has an order of K, i.e. - * K+1 coefficients. The memory of the input signal is provided in the vector mem[] - * which has K values - * The maximum length of the input signal is L_FRAME32k and the maximum order - * of the FIR filter is L_FILT_MAX - *-------------------------------------------------------------------*/ - -void fir( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response of the FIR filter */ - float y[], /* o : output vector (result of filtering) */ - float mem[], /* i/o: memory of the input signal (L samples) */ - const int16_t L, /* i : input vector size */ - const int16_t K, /* i : order of the FIR filter (K+1 coefs.) */ - const int16_t upd /* i : 1 = update the memory, 0 = not */ -) -{ - float buf_in[L_FRAME48k + 60], buf_out[L_FRAME48k], s; - int16_t i, j; - - /* prepare the input buffer (copy and update memory) */ - mvr2r( mem, buf_in, K ); - mvr2r( x, buf_in + K, L ); - - if ( upd ) - { - mvr2r( buf_in + L, mem, K ); - } - - /* do the filtering */ - for ( i = 0; i < L; i++ ) - { - s = buf_in[K + i] * h[0]; - - for ( j = 1; j <= K; j++ ) - { - s += h[j] * buf_in[K + i - j]; - } - - buf_out[i] = s; - } - - /* copy to the output buffer */ - mvr2r( buf_out, y, L ); - - return; -} - -/*-------------------------------------------------------------------* - * v_add() - * - * Addition of two vectors sample by sample - *-------------------------------------------------------------------*/ - -void v_add( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 + vector 2 */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = x1[i] + x2[i]; - } - - return; -} - - /*-------------------------------------------------------------------* * v_add_w64() * @@ -1351,55 +934,9 @@ void v_sub_fixed( } /*-------------------------------------------------------------------* - * v_mult() + * v_multc_fixed() * - * Multiplication of two vectors - *-------------------------------------------------------------------*/ - -void v_mult( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = x1[i] * x2[i]; - } - - return; -} - -/*-------------------------------------------------------------------* - * v_multc() - * - * Multiplication of vector by constant - *-------------------------------------------------------------------*/ - -void v_multc( - const float x[], /* i : Input vector */ - const float c, /* i : Constant */ - float y[], /* o : Output vector that contains c*x */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = c * x[i]; - } - - return; -} - -/*-------------------------------------------------------------------* - * v_multc_fixed() - * - * Multiplication of vector by constant + * Multiplication of vector by constant *-------------------------------------------------------------------*/ void v_multc_fixed( @@ -1456,102 +993,6 @@ void v_multc_fixed_16_16( return; } -/*-------------------------------------------------------------------* - * squant() - * - * Scalar quantizer according to MMSE criterion (nearest neighbour in Euclidean space) - * - * Searches a given codebook to find the nearest neighbour in Euclidean space. - * Index of the winning codeword and the winning codeword itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codeword */ -int16_t squant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float cb[], /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -) -{ - float dist, mindist, tmp; - int16_t c, idx; - - idx = 0; - mindist = 1e16f; - - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - tmp = x - cb[c]; - dist += tmp * tmp; - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - *xq = cb[idx]; - - return idx; -} - -/*! r: index of the winning codeword */ -int16_t squant_int( - uint8_t x, /* i : scalar value to quantize */ - uint8_t *xq, /* o : quantized value */ - const uint8_t *cb, /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -) -{ - int16_t i, idx; - float mindist, d; - - idx = 0; - mindist = 10000000.0f; - for ( i = 0; i < cbsize; i++ ) - { - d = (float) ( x - cb[i] ) * ( x - cb[i] ); - if ( d < mindist ) - { - mindist = d; - idx = i; - } - } - *xq = cb[idx]; - - return idx; -} - - -/*-------------------------------------------------------------------* - * usquant() - * - * Uniform scalar quantizer according to MMSE criterion - * (nearest neighbour in Euclidean space) - * - * Applies quantization based on scale and round operations. - * Index of the winning codeword and the winning codeword itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codeword */ -int16_t usquant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta, /* i : quantization step */ - const int16_t cbsize /* i : codebook size */ -) -{ - int16_t idx; - - idx = (int16_t) max( 0.f, min( cbsize - 1, ( ( x - qlow ) / delta + 0.5f ) ) ); - *xq = idx * delta + qlow; - - return idx; -} - - /*-------------------------------------------------------------------* * usdequant() * @@ -1573,219 +1014,6 @@ float usdequant( return ( g ); } - -/*-------------------------------------------------------------------* - * vquant() - * - * Vector quantizer according to MMSE criterion (nearest neighbour in Euclidean space) - * - * Searches a given codebook to find the nearest neighbour in Euclidean space. - * Index of the winning codevector and the winning vector itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codevector */ -int16_t vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize /* i : codebook size */ -) -{ - float dist, mindist, tmp; - int16_t c, d, idx, j; - - idx = 0; - mindist = 1e16f; - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - x[d] -= x_mean[d]; - } - } - - j = 0; - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - for ( d = 0; d < dim; d++ ) - { - tmp = x[d] - cb[j++]; - dist += tmp * tmp; - } - - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - if ( xq == 0 ) - { - return idx; - } - - j = idx * dim; - for ( d = 0; d < dim; d++ ) - { - xq[d] = cb[j++]; - } - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - xq[d] += x_mean[d]; - } - } - - return idx; -} - -/*-------------------------------------------------------------------* - * w_vquant() - * - * Vector quantizer according to MMSE criterion (nearest neighbour in Euclidean space) - * - * Searches a given codebook to find the nearest neighbour in Euclidean space. - * Weights are put on the error for each vector element. - * Index of the winning codevector and the winning vector itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codevector */ -int16_t w_vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - const int16_t weights[], /* i : error weights */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize, /* i : codebook size */ - const int16_t rev_vect /* i : reverse codebook vectors */ -) -{ - float dist, mindist, tmp; - int16_t c, d, idx, j, k; - - idx = 0; - mindist = 1e16f; - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - x[d] -= x_mean[d]; - } - } - - j = 0; - if ( rev_vect ) - { - k = dim - 1; - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - - for ( d = k; d >= 0; d-- ) - { - tmp = x[d] - cb[j++]; - dist += weights[d] * ( tmp * tmp ); - } - - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - if ( xq == 0 ) - { - return idx; - } - - j = idx * dim; - for ( d = k; d >= 0; d-- ) - { - xq[d] = cb[j++]; - } - } - else - { - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - - for ( d = 0; d < dim; d++ ) - { - tmp = x[d] - cb[j++]; - dist += weights[d] * ( tmp * tmp ); - } - - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - if ( xq == 0 ) - { - return idx; - } - - j = idx * dim; - for ( d = 0; d < dim; d++ ) - { - xq[d] = cb[j++]; - } - } - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - xq[d] += x_mean[d]; - } - } - - return idx; -} - - -/*----------------------------------------------------------------------------------* - * v_sort() - * - * Sorting of vectors. This is very fast with almost ordered vectors. - *----------------------------------------------------------------------------------*/ - -void v_sort_float( - float *r, /* i/o: Vector to be sorted in place */ - const int16_t lo, /* i : Low limit of sorting range */ - const int16_t up /* I : High limit of sorting range */ -) -{ - int16_t i, j; - float tempr; - - for ( i = up - 1; i >= lo; i-- ) - { - tempr = r[i]; - for ( j = i + 1; j <= up && ( tempr > r[j] ); j++ ) - { - r[j - 1] = r[j]; - } - - r[j - 1] = tempr; - } - - return; -} - void sort( UWord16 *x, /* i/o: Vector to be sorted */ UWord16 len /* i/o: vector length */ @@ -1810,426 +1038,3 @@ void sort( return; } - -/*---------------------------------------------------------------------* - * var() - * - * Calculate the variance of a vector - *---------------------------------------------------------------------*/ - -/*! r: variance of vector */ -float var( - const float *x, /* i : input vector */ - const int16_t len /* i : length of inputvector */ -) -{ - float m; - float v; - int16_t i; - - m = mean( x, len ); - - v = 0.0f; - for ( i = 0; i < len; i++ ) - { - v += ( x[i] - m ) * ( x[i] - m ); - } - v /= len; - - return v; -} - - -/*---------------------------------------------------------------------* - * std_dev() - * - * Calculate the standard deviation of a vector - *---------------------------------------------------------------------*/ - -/*! r: standard deviation */ -float std_dev( - const float *x, /* i : input vector */ - const int16_t len /* i : length of the input vector */ -) -{ - int16_t i; - float std; - - std = 1e-16f; - for ( i = 0; i < len; i++ ) - { - std += x[i] * x[i]; - } - - std = (float) sqrt( std / len ); - - return std; -} - - -/*---------------------------------------------------------------------* - * dot_product_mat() - * - * Calculates dot product of type x'*A*x, where x is column vector of size m, - * and A is square matrix of size m*m - *---------------------------------------------------------------------*/ - -/*! r: the dot product x'*A*x */ -float dot_product_mat( - const float *x, /* i : vector x */ - const float *A, /* i : matrix A */ - const int16_t m /* i : vector & matrix size */ -) -{ - int16_t i, j; - float suma, tmp_sum; - const float *pt_x, *pt_A; - - pt_A = A; - suma = 0; - - for ( i = 0; i < m; i++ ) - { - tmp_sum = 0; - pt_x = x; - for ( j = 0; j < m; j++ ) - { - tmp_sum += *pt_x++ * *pt_A++; - } - - suma += x[i] * tmp_sum; - } - - return suma; -} - - -/*--------------------------------------------------------------------------------* - * polezero_filter() - * - * Y(Z)=X(Z)(b[0]+b[1]z^(-1)+..+b[L]z^(-L))/(a[0]+a[1]z^(-1)+..+a[M]z^(-M)) - * mem[n]=x[n]+cp[0]mem[n-1]+..+cp[M-1]mem[n-M], where cp[i]=-a[i+1]/a[0] - * y[n]=cz[0]mem[n]+cz[1]mem[n-1]+..+cz[L]mem[n-L], where cz[i]=b[i]/a[0] - * mem={mem[n-K] mem[n-K+1] . . . . mem[n-2] mem[n-1]}, where K=max(L,M) - * - * a[0] must be equal to 1.0f! - *---------------------------------------------------------------------------------*/ - -void polezero_filter( - const float *in, /* i : input vector */ - float *out, /* o : output vector */ - const int16_t N, /* i : input vector size */ - const float *b, /* i : numerator coefficients */ - const float *a, /* i : denominator coefficients */ - const int16_t order, /* i : filter order */ - float *mem /* i/o: filter memory */ -) -{ - int16_t i, j, k; - - - for ( i = 0; i < order; i++ ) - { - out[i] = in[i] * b[0]; - for ( j = 0; j < i; j++ ) - { - out[i] += in[i - 1 - j] * b[j + 1] - out[i - 1 - j] * a[j + 1]; - } - - for ( k = order - 1; j < order; j++, k-- ) - { - out[i] += mem[k] * b[j + 1] - mem[k + order] * a[j + 1]; - } - } - - for ( ; i < N; i++ ) - { - out[i] = in[i] * b[0]; - for ( j = 0; j < order; j++ ) - { - out[i] += in[i - 1 - j] * b[j + 1] - out[i - 1 - j] * a[j + 1]; - } - } - - for ( i = 0; i < order; i++ ) - { - mem[i] = in[N - order + i]; - mem[i + order] = out[N - order + i]; - } - - return; -} - -#define WMC_TOOL_SKIP -static float fleft_shift( float input, const int16_t shift ) -{ - return ( input * (float) pow( 2.0, (double) shift ) ); -} - -static float fright_shift( float input, const int16_t shift ) -{ - return ( input * (float) pow( 0.5, (double) shift ) ); -} -#undef WMC_TOOL_SKIP - - -/*--------------------------------------------------------------------------------* - * root_a() - * - * Implements a quadratic approximation to sqrt(a) - * Firstly, a is normalized to lie between 0.25 & 1.0 - * by shifting the input left or right by an even number of - * shifts. Even shifts represent powers of 4 which, after - * the sqrt, can easily be converted to powers of 2 and are - * easily dealt with. - * At the heart of the algorithm is a quadratic - * approximation of the curve sqrt(a) for 0.25 <= a <= 1.0. - * Sqrt(a) approx = 0.27 + 1.0127 * a - 0.2864 * a^2 - * - *---------------------------------------------------------------------------------*/ - -float root_a( - float a ) -{ - int16_t shift_a; - float mod_a; - float approx; - - if ( a <= 0.0f ) - { - return 0.0; - } - -#define WMC_TOOL_SKIP - /* This next piece of code implements a "norm" function */ - /* and returns the shift needed to scale "a" to have a */ - /* 1 in the (MSB-1) position. This is equivalent to */ - /* giving a value between 0.5 & 1.0. */ - mod_a = a; - - shift_a = 0; - while ( mod_a > 1.0 ) - { - mod_a /= 2.0; - shift_a--; - } - - while ( mod_a < 0.5 ) - { - mod_a *= 2.0; - shift_a++; - } -#undef WMC_TOOL_SKIP - - shift_a &= 0xfffe; - mod_a = fleft_shift( a, shift_a ); - - approx = 0.27f + 1.0127f * mod_a - 0.2864f * mod_a * mod_a; - - approx = fright_shift( approx, ( shift_a >> 1 ) ); - - return ( approx ); -} - -/*--------------------------------------------------------------------------------* - * root_a_over_b() - * - * Implements an approximation to sqrt(a/b) - * Firstly a & b are normalized to lie between 0.25 & 1.0 - * by shifting the inputs left or right by an even number - * of shifts. - * Even shifts represent powers of 4 which, after the sqrt, - * become powers of 2 and are easily dealt with. - * At the heart of the algorithm is an approximation of the - * curve sqrt(a/b) for 0.25 <= a <= 1.0 & 0.25 <= b <= 1.0. - * Given the value of b, the 2nd order coefficients p0, p1 - * & p2 can be determined so that... - * Sqrt(a/b) approx = p0 + p1 * a + p2 * a^2 - * where p0 approx = 0.7176 - 0.8815 * b + 0.4429 * b^2 - * p1 approx = 2.6908 - 3.3056 * b + 1.6608 * b^2 - * p2 approx = -0.7609 + 0.9346 * b - 0.4695 * b^2 - * - *---------------------------------------------------------------------------------*/ - -float root_a_over_b( - float a, - float b ) -{ - int16_t shift_a, shift_b, shift; - float mod_a, mod_b; - float p2 = -0.7609f; - float p1 = 2.6908f; - float p0 = 0.7176f; - float b_sqr; - float approx; - - if ( ( a <= 0.0f ) || ( b <= 0.0f ) ) - { - return 0.0; - } -#define WMC_TOOL_SKIP - if ( isinf( a ) ) -#undef WMC_TOOL_SKIP - { - return FLT_MAX; - } -#define WMC_TOOL_SKIP - if ( isinf( b ) ) -#undef WMC_TOOL_SKIP - { - return 0.f; - } - - a += 0x00000001; - b += 0x00000001; - -#define WMC_TOOL_SKIP - /* This next piece of code implements a "norm" function */ - /* and returns the shift needed to scale "a" to have a */ - /* 1 in the (MSB-1) position. This is equivalent to */ - /* giving a value between 0.5 & 1.0. */ - mod_a = a; - - shift_a = 0; - while ( mod_a > 1.0 ) - { - mod_a /= 2.0; - shift_a--; - } - - while ( mod_a < 0.5 ) - { - mod_a *= 2.0; - shift_a++; - } -#undef WMC_TOOL_SKIP - - shift_a &= 0xfffe; - mod_a = fleft_shift( a, shift_a ); - -#define WMC_TOOL_SKIP - /* This next piece of code implements a "norm" function */ - /* and returns the shift needed to scale "b" to have a */ - /* 1 in the (MSB-1) position. This is equivalent to */ - /* giving a value between 0.5 & 1.0. */ - mod_b = b; - - shift_b = 0; - while ( mod_b > 1.0 ) - { - mod_b /= 2.0; - shift_b--; - } - - while ( mod_b < 0.5 ) - { - mod_b *= 2.0; - shift_b++; - } -#undef WMC_TOOL_SKIP - - shift_b &= 0xfffe; - mod_b = fleft_shift( b, shift_b ); - - shift = ( shift_b - shift_a ) >> 1; - - b_sqr = mod_b * mod_b; - - p2 += 0.9346f * mod_b + -0.4695f * b_sqr; - p1 += -3.3056f * mod_b + 1.6608f * b_sqr; - p0 += -0.8815f * mod_b + 0.4429f * b_sqr; - - approx = p0 + p1 * mod_a + p2 * mod_a * mod_a; - - approx = fleft_shift( approx, shift ); - - return ( approx ); -} - -/*--------------------------------------------------------------------------------* - * rint_new() - * - * Round to the nearest integer with mid-point exception - *---------------------------------------------------------------------------------*/ - -double rint_new( - double x ) -{ - int16_t a; - - /* middle value point test */ - if ( ceil( x + 0.5 ) == floor( x + 0.5 ) ) - { - a = (int16_t) ceil( x ); - - if ( a % 2 == 0 ) - { - return ceil( x ); - } - else - { - return floor( x ); - } - } - else - { - return floor( x + 0.5 ); - } -} - - -/*-------------------------------------------------------------------* - * anint() - * - * Round to the nearest integer. - *-------------------------------------------------------------------*/ - -double anint( - double x ) -{ - return ( x ) >= 0 ? (int32_t) ( ( x ) + 0.5 ) : (int32_t) ( (x) -0.5 ); -} - -/*-------------------------------------------------------------------* - * is_numeric_float() - * - * Returns 0 for all NaN and Inf values defined according to IEEE 754 - * floating point number's definition. Returns 1 for numeric values. - *-------------------------------------------------------------------*/ - -int16_t is_numeric_float( - float x ) -{ - union float_int - { - float float_val; - int32_t int_val; - } float_int; - - float_int.float_val = x; - - return ( ( float_int.int_val & 0x7f800000 ) != 0x7f800000 ); -} - -/*-------------------------------------------------------------------* - * delay_signal_float() - * - * Delay buffer by defined number of samples - *-------------------------------------------------------------------*/ - -void delay_signal_float( - float x[], /* i/o: signal to be delayed */ - const int16_t len, /* i : length of the input signal */ - float mem[], /* i/o: synchronization memory */ - const int16_t delay /* i : delay in samples */ -) -{ - float tmp_buffer[L_FRAME48k]; - - mvr2r( mem, tmp_buffer, delay ); - mvr2r( x + len - delay, mem, delay ); - mvr2r( x, x + delay, len - delay ); - mvr2r( tmp_buffer, x, delay ); - - return; -} diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index efa9d7e5a..1aa0bb84a 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -50,7 +50,6 @@ #include "basop32.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot.h" #include "ivas_prot_fx.h" #define INV_BANDS10 3277 /* 1/10 in Q15 */ diff --git a/lib_com/wtda.c b/lib_com/wtda.c index a7ea5314c..3fb408138 100644 --- a/lib_com/wtda.c +++ b/lib_com/wtda.c @@ -37,11 +37,10 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include #include "wmc_auto.h" -#include "prot_fx.h" void wtda_fx32( diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 9597a97ae..11379a62d 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -39,7 +39,6 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index f1772b9a7..fc8aba043 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index da7722325..ef4fb62d5 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -40,10 +40,9 @@ #include "cnst.h" #include "stl.h" #include "basop_util.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" Word16 DecodeIndex_fx( diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index e5a1220e0..60a59c4da 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -10,7 +10,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "basop_proto_func.h" -#include "prot.h" /* Returns: number of bits consumed */ static Word16 tcx_arith_decode_fx( diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index 3bf7e3eb6..a8ba2bfc3 100644 --- a/lib_dec/avq_dec_fx.c +++ b/lib_dec/avq_dec_fx.c @@ -7,7 +7,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ /*-------------------------------------------------------------------* diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index e3401739e..ab349773e 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -6,7 +6,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 8fefa3bb2..dd268fe08 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -7,7 +7,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "rom_com.h" diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index c7d2c5265..2fd3f1d2e 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -8,7 +8,6 @@ #include "basop_util.h" #include "prot_fx.h" #include "rom_com.h" -#include "prot.h" void mode_switch_decoder_LPD_fx( Decoder_State *st, /* i/o: decoder state structure */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e71157a1e..20f7a0adf 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -9,7 +9,6 @@ #include "basop_util.h" #include "stl.h" #include "options.h" -#include "prot.h" #include "math.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 385339664..6c63377fd 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -6,7 +6,6 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" /*=========================================================================*/ diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index c61bf95ce..ee7a7eca6 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -7,7 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "basop32.h" -#include "prot.h" /*---------------------------------------------------------------------* * Local constants diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 626f25ef4..86cf9784a 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------------- * hq_core_dec() diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 4f74c31ca..907a4a350 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -8,10 +8,9 @@ #include #include "options.h" #include "stl.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "cnst.h" #include "stat_dec.h" #include "basop_util.h" diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 4f1db90ff..3865cd61c 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -8,7 +8,6 @@ #include "rom_com.h" /* Static table prototypes */ #include "stl.h" /* required for wmc_tool */ #include "basop_util.h" -#include "prot.h" #include "ivas_prot_fx.h" /*----------------------------------------------------------------------* diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index f5418abc6..e73d89158 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -34,7 +34,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index a6e03eee3..3fe40c1f3 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "cnst.h" @@ -43,7 +43,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_binauralRenderer.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" #include "debug.h" diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 261a3c74e..5bb4736e9 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -36,12 +36,11 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 89ca9a5ba..697f9d715 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -35,7 +35,6 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "prot.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index c22c617c0..9bf53f1de 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -36,10 +36,9 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index a8c151edb..f7fd5e8e2 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -35,11 +35,10 @@ #include "stat_dec.h" #include "rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------* * ivas_decision_matrix_dec() diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 9849647ea..7dd7371fd 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" @@ -43,7 +43,6 @@ #include "ivas_rom_dec.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" /* Function prototypes */ #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index afbde5a60..e03913f8a 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -40,7 +40,7 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" @@ -48,7 +48,6 @@ #include "ivas_rom_dec.h" #include "wmc_auto.h" #include "rom_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_entropy_decoder_fx.c b/lib_dec/ivas_entropy_decoder_fx.c index 0c489fb04..e637a6a93 100644 --- a/lib_dec/ivas_entropy_decoder_fx.c +++ b/lib_dec/ivas_entropy_decoder_fx.c @@ -32,13 +32,12 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 037ef4eb9..8db782c4e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -40,9 +40,8 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 14e83fe83..664e3eeac 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -32,13 +32,12 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 0365005be..cbf088597 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -35,10 +35,9 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * ivas_ism_dtx_dec_fx() diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 833ed5e16..a6f5e47b6 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -37,7 +37,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_stat_enc.h" #include diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 424e6fb86..9040a8a71 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -36,13 +36,12 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 738e5a598..a19ba70ec 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3b66d3107..f632d86c8 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -35,7 +35,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" @@ -46,7 +46,6 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 616b15c6e..e68c0142d 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index f5e7816ad..a8b54d3fb 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_ls_custom_dec_fx.c b/lib_dec/ivas_ls_custom_dec_fx.c index eabee357b..45f59d82f 100644 --- a/lib_dec/ivas_ls_custom_dec_fx.c +++ b/lib_dec/ivas_ls_custom_dec_fx.c @@ -32,10 +32,9 @@ #include #include "options.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 4ca5c05b0..806785c15 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -40,7 +40,6 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 4c1d5d190..897fd4433 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" @@ -45,7 +45,6 @@ #include "math.h" #include "wmc_auto.h" #include "rom_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #define INV_EPSILON_MANT 214748365 diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index be53d79c8..e03b385b7 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot.h" diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index 687efb3ce..c2228b610 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -35,7 +35,7 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index 824370bb8..be457da47 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -33,7 +33,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" #include "cnst.h" @@ -42,7 +42,6 @@ #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index c95a5285a..081eca88d 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -38,7 +38,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 331bdc253..69f601724 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -34,11 +34,10 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include #include "stat_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*----------------------------------------------------------* diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 190cc6b14..7f079277a 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -33,7 +33,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -44,7 +44,6 @@ #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 231aee8aa..bb5dead22 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 3a6480386..391a27522 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "debug.h" diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0fb4163be..bf7fba094 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -35,12 +35,11 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index a5285b5cb..07ea14ea2 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -34,12 +34,11 @@ #include #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 02f37672d..4811911fd 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -34,13 +34,12 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "debug.h" diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 4a0c62e8d..08ac17799 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "math.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 853aa365f..397f26bbc 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index c225f126a..4bebcda5c 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -39,9 +39,8 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "prot.h" - #include "prot_fx.h" + #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_qspherical_dec_fx.c b/lib_dec/ivas_qspherical_dec_fx.c index 43ac60305..d34b5402a 100644 --- a/lib_dec/ivas_qspherical_dec_fx.c +++ b/lib_dec/ivas_qspherical_dec_fx.c @@ -37,7 +37,7 @@ #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index 6d6631f73..e629111ce 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -38,10 +38,9 @@ #include "rom_com.h" #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /* diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 417079541..efd766f76 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" @@ -44,7 +44,6 @@ #include #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * ivas_sba_set_cna_cng_flag() * diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 434fdf5fa..a42c67389 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" @@ -40,7 +40,6 @@ #include #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index ce4992046..89581565c 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 37489e58f..170256181 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index cddbf8cdf..812027468 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -35,7 +35,7 @@ #include #include "options.h" #include "ivas_stat_dec.h" -#include "prot.h" +#include "prot_fx.h" #include "string.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" @@ -45,7 +45,6 @@ #include "ivas_stat_com.h" #include "stat_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 3ad16b981..2b6b145f9 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -33,13 +33,12 @@ #include #include "options.h" #include "math.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" #include "ivas_stat_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c index c67a52b6c..8446af47d 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "rom_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index b3bddae59..15885a661 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -34,13 +34,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" /*------------------------------------------------------------------- diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index b0100063a..166ac72e5 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_com.h" #include "rom_dec.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 0db9ab09f..0781d49a6 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" @@ -43,7 +43,6 @@ #include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 7c1c892aa..c806f358a 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_com.h" #include "rom_dec.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 9e6878faf..d3415a8eb 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c index ed26543d3..693df8c77 100644 --- a/lib_dec/ivas_stereo_eclvq_dec_fx.c +++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c @@ -37,7 +37,7 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 08ac60ffc..b49ab5399 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -36,12 +36,11 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "basop32.h" #include "ivas_stat_dec.h" diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index b634d4557..22a8c4a90 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index bf343da7f..04781a9cb 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -34,13 +34,12 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "stat_com.h" #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 20fa578f8..69083a078 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -36,10 +36,9 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index c8a59cd6a..2dd2a30c3 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" @@ -42,7 +42,6 @@ #include "wmc_auto.h" #include #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index e31c9f6bc..8ab7da035 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index a22502188..bb73fe7f0 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -32,13 +32,12 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 37ffc5128..c908e4dc3 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -34,14 +34,13 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "stat_dec.h" #include "wmc_auto.h" #include "basop_proto_func.h" #include "stat_com.h" #include "ivas_prot.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------* diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index a4380bd4e..63819b056 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -37,7 +37,6 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer.c index cdabe4700..f9d6d1ca1 100644 --- a/lib_dec/jbm_jb4_circularbuffer.c +++ b/lib_dec/jbm_jb4_circularbuffer.c @@ -38,7 +38,7 @@ #include #include "options.h" #include "string.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /* local includes */ #include "jbm_jb4_circularbuffer.h" diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h index de614eeea..9e3102feb 100644 --- a/lib_dec/jbm_jb4_circularbuffer.h +++ b/lib_dec/jbm_jb4_circularbuffer.h @@ -37,7 +37,7 @@ #ifndef JBM_JB4_CIRCULARBUFFER_H #define JBM_JB4_CIRCULARBUFFER_H JBM_JB4_CIRCULARBUFFER_H -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" /** handle for circular buffer (FIFO) with fixed capacity */ diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer.c index 55113ee13..5497a4371 100644 --- a/lib_dec/jbm_jb4_inputbuffer.c +++ b/lib_dec/jbm_jb4_inputbuffer.c @@ -39,7 +39,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "string.h" #include "jbm_jb4_inputbuffer.h" #include "wmc_auto.h" diff --git a/lib_dec/jbm_jb4_jmf.c b/lib_dec/jbm_jb4_jmf.c index 940df5ecb..5ab8242c7 100644 --- a/lib_dec/jbm_jb4_jmf.c +++ b/lib_dec/jbm_jb4_jmf.c @@ -42,7 +42,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /* local includes */ diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 4878b7d64..002b4bc10 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -48,7 +48,6 @@ #include "jbm_jb4_inputbuffer.h" #include "jbm_jb4_jmf.h" #include "jbm_jb4sb.h" -#include "prot.h" #include "prot_fx.h" #define WMC_TOOL_SKIP diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 10b91a60c..ac6a28b86 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -44,7 +44,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /* local headers */ #include "jbm_pcmdsp_apa.h" @@ -54,7 +54,6 @@ #include "rom_dec.h" -#include "prot_fx.h" #define INV_100_Q15 328 #define INV_400_Q15 82 #define INV_80_Q15 410 diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2cc4c6387..66109b555 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -37,9 +37,8 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" -#include "ivas_prot_fx.h" #include "prot_fx.h" +#include "ivas_prot_fx.h" #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" @@ -3398,7 +3397,7 @@ static ivas_error evs_dec_main_fx( move32(); hCoreCoder[0]->output_frame_fx = extract_l( Mult_32_16( hCoreCoder[0]->output_Fs, 0x0290 /*Q0*/ ) ); // Q0 move16(); - mdct_switching_dec( hCoreCoder[0] ); + mdct_switching_dec_ivas_fx( hCoreCoder[0] ); FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) { diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index bc8ef03cb..cc9b681fb 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -7,7 +7,6 @@ #include "options.h" #include "rom_com.h" #include "prot_fx.h" -#include "prot.h" #include "rom_dec.h" #include "stl.h" diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 3cf5f51f3..36cadf6ff 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -14,7 +14,6 @@ #include "cnst.h" #include "prot_fx.h" #include "stat_com.h" -#include "prot.h" #include "ivas_prot_fx.h" #define CROSSFADE_THRESHOLD ( 32762 ) // close to 1.0f in Q15 such that (x == 1.0f) is true diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 203f39707..1e8bef488 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -7,7 +7,6 @@ #include "options.h" #include "basop_util.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "rom_com.h" diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 9106e23e7..87243e8d2 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c index f44530c84..09acfd5dc 100644 --- a/lib_enc/SNR_calc_fx.c +++ b/lib_enc/SNR_calc_fx.c @@ -10,7 +10,6 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 94d7f0471..0f58bcdad 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -6,7 +6,6 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "stat_enc.h" #include "rom_com.h" diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8268d48b1..90768aca1 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -11,7 +11,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#include "prot.h" /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index a94f45528..76d48ccf4 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -10,9 +10,7 @@ #include "basop_util.h" #include "rom_com.h" #include "rom_enc.h" -#include "prot.h" -//#include "prot_fx.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------* diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 202d60e51..93a0146f3 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -5,9 +5,7 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -#include /* Compilation switches */ -#include "prot.h" /* Function prototypes */ -//#include "prot_fx.h" /* Function prototypes */ +#include /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 1721476b4..e1b5ca562 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2,12 +2,10 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_enc.h" /* Encoder static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_enc.h" /* Encoder static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ //#include "basop_mpy.h" diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index c9bbe5f30..a948a4656 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -5,7 +5,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index 16651b8f2..a901690e3 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 44cde6f27..99b794b42 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -5,10 +5,9 @@ #include "options.h" /* VMR-WB compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_enc.h" /* Encoder static table prototypes */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index de9763df0..c54e8ccf4 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -16,11 +16,9 @@ #include "prot_fx_enc.h" #ifdef IVAS_FLOAT_FIXED_CONVERSIONS #include -#include "prot.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" -#include "prot.h" #endif #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index c2b1c22e1..a2995245d 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -13,7 +13,6 @@ #include "ivas_cnst.h" #include #include "rom_com.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index 82bb5fca9..f3b4aea6b 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -4,14 +4,11 @@ #include #include #include "options.h" -#include "prot.h" -//#include "prot_fx.h" -//#include "basop_mpy.h" +#include "prot_fx.h" #include "cnst.h" /* Common constants */ #include "ivas_cnst.h" #include "rom_com_fx.h" #include "rom_com.h" /* Common constants */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index a6b9e0aa4..6e4d2a043 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -10,7 +10,6 @@ #include #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 1053f8b00..06c49a8d3 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -4,10 +4,9 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*======================================================================*/ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index a01550978..64a11be5b 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -4,10 +4,9 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" #include "prot_fx_enc.h" /*---------------------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 18948a93f..3ed50017c 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index da2ea5863..ecd4e2f01 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -11,8 +11,7 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index bf04daff5..5b9f67503 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -7,7 +7,6 @@ // #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 2a621f1d5..cd23c1a6f 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -5,9 +5,8 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------* diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index e49463a5c..75e82409e 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 6970597c8..c86b7e061 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -5,10 +5,9 @@ #include #include #include "options.h" /* Compilation switches */ -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Common constants */ -#include "prot_fx.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ #include "prot_fx_enc.h" #ifdef DEBUGGING diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 9cb2cd8e0..307d42078 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -11,7 +11,6 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "rom_enc.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index d08922a2a..155e49904 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -6,8 +6,7 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 6af068bae..0321cd763 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -7,7 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index a7d60642b..f943b104d 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -7,7 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "rom_enc.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ //#include "basop_mpy.h" diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 8ed7e9d6c..375d4c2cf 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -6,8 +6,6 @@ #include "cnst.h" #include "rom_com_fx.h" #include "rom_com.h" -//#include "prot_fx.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 53ad3dbb2..944cb2649 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -8,7 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-----------------------------------------------------------------* diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 11583ea11..f22218d13 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -2,12 +2,10 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/hq_env_enc_fx.c b/lib_enc/hq_env_enc_fx.c index b0875968e..5d47710ed 100644 --- a/lib_enc/hq_env_enc_fx.c +++ b/lib_enc/hq_env_enc_fx.c @@ -10,7 +10,6 @@ #include "stl.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ /*--------------------------------------------------------------------------------------* * encode_envelope_indices_fx() diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 4d4742cc1..1cd516b43 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -7,7 +7,6 @@ //#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 424689804..9aca0f646 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -12,7 +12,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#include "prot.h" /*--------------------------------------------------------------------------* * Local function prototypes diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 54bc4fb58..b06a1734d 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -8,7 +8,6 @@ //#include "prot_fx.h" #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #define HVQ_ENC_NOISE_DELTA ( (Word16) 3277 ) /* 0.1 in Q15 */ diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 6ac6e6811..f6adb0f31 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -38,13 +38,12 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "cnst.h" #include "stat_enc.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" #define INV_Log2_10_Q15 9864 /*1/log2(10) in Q15*/ @@ -2535,41 +2534,6 @@ void IGFEncResetTCX10BitCounter_ivas_fx( } -/*-------------------------------------------------------------------* - * IGFEncWriteConcatenatedBitstream() - * - * - *-------------------------------------------------------------------*/ - -/*! r: total number of bits written */ -Word16 IGFEncWriteConcatenatedBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -) -{ - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - Word16 i; - Word16 bitsLeft; - UWord8 *pBitstream; - - hPrivateData = &hIGFEnc->igfData; - pBitstream = hPrivateData->igfBitstream; - - for ( i = 0; i < ( hPrivateData->igfBitstreamBits >> 3 ); i++ ) - { - push_next_indice( hBstr, pBitstream[i], 8 ); - } - - bitsLeft = hPrivateData->igfBitstreamBits & 0x7; - if ( bitsLeft > 0 ) - { - push_next_indice( hBstr, shr( pBitstream[i], sub( 8, bitsLeft ) ), bitsLeft ); - } - - return hIGFEnc->infoTotalBitsWritten; -} - - /*-------------------------------------------------------------------* * IGFEncApplyMono() * diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index ca1759c89..cc4840876 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -8,8 +8,7 @@ #include "options.h" #include "cnst.h" #include "stl.h" -#include "prot.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ #include "stat_enc.h" #include "basop_util.h" diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index 192d7e597..2921b5886 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -36,12 +36,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "stat_enc.h" #include "stat_com.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 5de4e8e92..615ca1b33 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -10,7 +10,6 @@ #include "stl.h" #include "ivas_cnst.h" #include "ivas_error.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 7bb13239f..46bec5f4d 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 649c5bae5..37d25c508 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -36,10 +36,9 @@ #include #include "options.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "basop_util.h" diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 303adecfd..5f318e959 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -34,12 +34,11 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "wmc_auto.h" #include -#include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f963b55a4..f41eb7f9c 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" @@ -50,7 +49,6 @@ #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*---------------------------------------------------------------* * Local constants diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 1234a6876..a9da7f342 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -37,9 +37,8 @@ #include "ivas_prot.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" #include "basop_util.h" diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 1b4d5da4a..32e3e7107 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 3fd9c2d7a..811e53d12 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" @@ -45,7 +45,6 @@ #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_enc.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index a3194a9d0..1158f72fa 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -35,11 +35,10 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index ec55850fd..7bfa9f268 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 95a114b67..576bbb2c6 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -32,11 +32,10 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 2bab65c42..0a2d976e1 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -36,14 +36,13 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index eb82aa78a..a95f2884c 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 3844598c6..f1aeb5398 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -36,14 +36,13 @@ #include "ivas_cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "prot_fx_enc.h" #include #include "wmc_auto.h" #include #include "prot_fx_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------------------------* diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 9d31297bd..3eeb45d14 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_enc.h" @@ -42,7 +42,6 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 615660761..64b8991d6 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -34,10 +34,9 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 51af4e5a9..22bf88df8 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -33,12 +33,11 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "prot_fx_enc.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index a5a1286a2..a36ee78e2 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -38,10 +38,9 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index bef6912bd..e6b23fcfc 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "cnst.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index fee34abd8..86237fb31 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -33,12 +33,11 @@ #include #include "options.h" #include "math.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index f4fe68c59..21c23c34a 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 36324ae0f..2797fa5e4 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "ivas_rom_enc.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -46,7 +45,6 @@ #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- * Local function prototypes diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 392f1d9ab..9060c786b 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -36,10 +36,9 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "basop_util.h" #include "ivas_rom_com_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index b3f99e27c..bb6ef0d01 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index d11447c03..439c227ae 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -34,14 +34,12 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index dbced19fd..55da30e73 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -36,10 +36,9 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" #include "rom_com.h" diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 7e8547841..88d773b53 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index edfc607ed..403d379fa 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -36,13 +36,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index f09d4513d..7c8b78ffb 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 5eee0975a..648dcdb73 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -36,12 +36,11 @@ #include #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 8b61cb6c8..410d5dd52 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3f0218e97..7a2a28767 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -35,15 +35,13 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "prot.h" -#include "prot_fx.h" #include "basop_util.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index eb60d4849..a6f40c8f0 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index 35ecad69c..cf32c644d 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -39,7 +39,7 @@ #include "rom_com.h" #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index b247900a0..86427eb2d 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -37,13 +37,12 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 9f63c4fc7..8c2c945d6 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 8f93c4d76..e6038186e 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -35,10 +35,9 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index a0c5be842..674a80549 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -38,7 +38,6 @@ #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_com.h" -#include "prot.h" #include "math.h" #include "wmc_auto.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 8b23eca5f..925f4e702 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -42,7 +41,6 @@ #include "ivas_rom_com_fx.h" #include #include "wmc_auto.h" -#include "prot_fx.h" /*------------------------------------------------------------------------------------------* * PreProcessor diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 62fed34f7..70c2165f8 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "stat_enc.h" #include "wmc_auto.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 0c90d5fdc..bfe683d6b 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -38,13 +38,12 @@ #endif #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index 4727cd188..255b6e938 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -36,12 +36,11 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 8578a46ae..3f7237ce5 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -37,10 +37,9 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 70a467232..7900033f4 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index dd7f575b7..58e66a01a 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "ivas_prot.h" #include "ivas_rom_com.h" @@ -43,7 +43,6 @@ #include "ivas_cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 7b0e7df62..a3388db61 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -45,7 +44,6 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index cd0e6fe2d..f4962c802 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" /* used only for norm_s in the code_length_from_count function */ diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index e0a8a8ed4..351b87cd0 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -36,12 +36,11 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 8c2d136b7..78891c5f7 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -35,12 +35,11 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 2a87ea4f9..28b0e41b9 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index 38be1a6a4..57bb18e80 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include -#include "prot.h" #include "prot_fx.h" #include "cnst.h" #include "stat_enc.h" diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 9c729709d..b1213a750 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "prot.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 190adbf1c..f3ceb2757 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -34,14 +34,13 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com_fx.h" #include "ivas_rom_com.h" #include "assert.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 79e05bf09..efae1e80d 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -35,14 +35,13 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 304754fc3..f8d600276 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -44,7 +44,6 @@ #endif #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 84bffa87c..28044b45d 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -35,13 +35,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "basop_proto_func.h" #include "wmc_auto.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "prot_fx_enc.h" #include "rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 4d6a908b3..34215025f 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 1f2fee684..211c53f8c 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -41,7 +41,6 @@ #include "lib_enc.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 709bb47e0..a61b2ebff 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -8,7 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 830f1ecd6..7f58a9501 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -38,7 +38,6 @@ #include "options.h" #include "cnst.h" #include "ivas_prot.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "rom_enc.h" diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 265fce7f2..eec85c254 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index d8a78c525..771ef480b 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -6,9 +6,8 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot.h" /* Function prototypes */ -#include "basop32.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ +#include "basop32.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 3bd8e340d..a7588283a 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" diff --git a/lib_enc/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c index 9ea1af949..aa4763aa6 100644 --- a/lib_enc/peak_vq_enc_fx.c +++ b/lib_enc/peak_vq_enc_fx.c @@ -11,7 +11,6 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------------- diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index d53e2eb6e..bcf7d33bb 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ #include "rom_basop_util.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/range_enc_fx.c b/lib_enc/range_enc_fx.c index 05916e801..689b313d8 100644 --- a/lib_enc/range_enc_fx.c +++ b/lib_enc/range_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index a735c498d..353de8ec9 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -19,7 +19,6 @@ #include #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" /*---------------------------------------------------------------------* diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 91dca8d63..0a20db8ed 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -11,7 +11,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /*======================================================================*/ /* FUNCTION : stat_noise_uv_enc_fx */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 3ca3f3f3f..2ca0b6d74 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -4,12 +4,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*---------------------------------------------------------------------* diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index acd984509..1a397c514 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -36,7 +36,6 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" #include "stl.h" -#include "prot.h" /*--------------------------------------------------------------------------* * GetSubbandCorrIndex2_har() diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c deleted file mode 100644 index db4e51127..000000000 --- a/lib_enc/swb_tbe_enc.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" -#include "ivas_prot.h" diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index a5e4e902b..61ca9b101 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -8,7 +8,6 @@ #include "cnst.h" #include "rom_com_fx.h" #include "rom_com.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot.h" /* Function prototypes */ diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index fbd9775c4..82088be50 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -10,7 +10,6 @@ #include "ivas_error.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" #define IVAS_FLOAT ivas_error tcq_core_LR_enc_fx( diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index f1881a427..cf6e5dd64 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -12,7 +12,6 @@ #include #include "rom_com_fx.h" #include "rom_com.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 0089fc745..9911d766a 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 4a4c1ff89..008e27d6c 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 67d47e89d..81437c49d 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -33,7 +33,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" @@ -41,7 +41,6 @@ #include "ivas_rom_binaural_crend_head.h" #include "ivas_stat_rend.h" #include "lib_rend.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 06744dc6e..9cc764afb 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -35,11 +35,10 @@ #include "ivas_cnst.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index e2ab6cd3e..7e41581f4 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 01fd1e610..4ea5c5e96 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -35,13 +35,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index c6119cc34..4eae9c286 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -34,14 +34,13 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- * ivas_dirac_dec_onset_detection_open() diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index d6c999aa0..29eac3635 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" @@ -43,7 +43,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index b563d4399..882c6e5b8 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -35,13 +35,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 8947809d1..52ca3e6f9 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -35,7 +35,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 506d76efd..5d53d2ae3 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_error.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_limiter_fx.c b/lib_rend/ivas_limiter_fx.c index 595573016..b66127e09 100644 --- a/lib_rend/ivas_limiter_fx.c +++ b/lib_rend/ivas_limiter_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index e8d06d0bb..8b7e6575d 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -36,9 +36,8 @@ #include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 0b0c8ffeb..25fddaa80 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -37,12 +37,11 @@ #include "options.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 8b689b94b..93fe67436 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -33,14 +33,13 @@ #include "ivas_stat_rend.h" #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" #define float_to_fixed( n, factor ) ( round( n * ( 1 << factor ) ) ) diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index ab09a82b5..a7f46b2a4 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -33,13 +33,12 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" /*---------------------------------------------------------------------* * Local function prototypes diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index a328a51bf..7ee6c828b 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_rom_rend.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index caa393355..971e2c2d1 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -35,9 +35,8 @@ #include #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index af60f7746..307d38351 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -33,11 +33,10 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index c8efd80ad..4d259a68e 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -33,10 +33,9 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 7d6129d20..d7387ecd4 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -37,11 +37,10 @@ #include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 980e5ca17..054e5e981 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index e5e8cdb56..a02a29d0d 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "rom_dec.h" #include "lib_rend.h" #include "ivas_prot_rend.h" @@ -42,7 +42,6 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 792b485a7..b730b1510 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* * Local constants diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index 3eeb4ede4..44550803a 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -34,9 +34,8 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "debug.h" /*-----------------------------------------------------------------------------------------* * Function ivas_rev_delay_line_init() diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index 3befcde91..2d0722ceb 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -32,11 +32,10 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 428cf3353..652fc898f 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_rend.h" #include diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9e621ce83..6b41815c4 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "math.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define float_to_fixQ31( n ) ( round( n * 0x7fffffff ) ) diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index 217e16dd8..98b66e0c7 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -32,10 +32,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 46ef576a8..ee2bada9d 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "options_warnings.h" /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 39720469b..7ad4c4ccb 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -37,11 +37,10 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "debug.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 7c7a20223..4323fc96f 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 9ed0d8d33..7c930104a 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -36,7 +36,6 @@ #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index af51a7820..6d5b23f12 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot.h" diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index e1a6868d8..06cbd83a6 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -34,12 +34,11 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 493979e30..0cda39d62 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -32,7 +32,6 @@ #include "basop_util.h" #include "options.h" #include "lib_rend.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 8920e6780..930bb79dc 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -32,9 +32,8 @@ #include "hrtf_file_reader.h" #include -#include "prot.h" -#include "ivas_prot_rend.h" #include "prot_fx.h" +#include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 01d1f0307..90d47b7c9 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -34,7 +34,7 @@ #include #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" struct LsCustomFileReader diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 782f818d0..2976e1895 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -32,7 +32,7 @@ #include "mime_io.h" #include "mime.h" -#include "prot.h" +#include "prot_fx.h" #include "string.h" #include #include diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index b6122ec0f..e099842be 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -37,7 +37,7 @@ #include #include #include "cmdl_tools.h" -#include "prot.h" +#include "prot_fx.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 468f80765..2299f3265 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -34,7 +34,6 @@ #include #include #include -#include "prot.h" #include "prot_fx.h" diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index ec14ebc71..5745e9595 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -35,7 +35,6 @@ #include #include #include -#include "prot.h" #include "options.h" /* only included to get access to the feature-defines */ #include "prot_fx.h" #include "ivas_prot_fx.h" -- GitLab From 1411ee404ff299ce7211e7cd1325aa27e2d9ad6b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 10:13:00 +0530 Subject: [PATCH 279/329] Fix for 3GPP issue 1140: Missing conversion of some flt. pt. functions in the BASOP code Link #1140 --- lib_com/float_to_fix_ops.c | 8 ++--- lib_com/ivas_spar_com_fx.c | 39 ++++++++++++++++--------- lib_dec/dec_tcx_fx.c | 19 ++++++------ lib_dec/ivas_lfe_plc_fx.c | 12 ++++---- lib_dec/ivas_mc_paramupmix_dec_fx.c | 6 ++-- lib_dec/ivas_qmetadata_dec_fx.c | 3 +- lib_dec/ivas_spar_md_dec_fx.c | 7 +++-- lib_dec/ivas_stereo_cng_dec.c | 6 ++-- lib_dec/ivas_stereo_dft_dec_fx.c | 38 +++++++++++++++--------- lib_enc/ACcontextMapping_enc_fx.c | 7 +++-- lib_enc/fd_cng_enc_fx.c | 2 +- lib_enc/ivas_agc_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 2 +- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_lfe_enc_fx.c | 20 ++++++------- lib_enc/ivas_mc_paramupmix_enc_fx.c | 10 +++---- lib_enc/ivas_osba_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 3 +- lib_enc/ivas_sba_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 9 ++++-- lib_enc/ivas_stereo_dmx_evs_fx.c | 6 ++-- lib_enc/ivas_stereo_ica_enc_fx.c | 4 +-- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 4 +-- lib_rend/ivas_dirac_rend_fx.c | 2 +- lib_rend/ivas_reverb_filter_design_fx.c | 6 ++-- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/lib_rend.c | 12 ++++---- 29 files changed, 137 insertions(+), 102 deletions(-) diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 1f7c28fd8..8b69e05e8 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -183,14 +183,14 @@ Word16 Q_factor( float x ) { Word16 Q = 15; if ( x >= 1 || x <= -1 ) - Q = norm_s( (Word16) abs( (Word32) x ) ); + Q = norm_s( (Word16) L_abs( (Word32) x ) ); return Q; } Word16 Q_factor_L( float x ) { Word16 Q = 31; if ( x >= 1 || x <= -1 ) - Q = norm_l( abs( (Word32) x ) ); + Q = norm_l( L_abs( (Word32) x ) ); return Q; } Word16 Q_factor_L_32( Word32 x ) @@ -206,7 +206,7 @@ Word16 Q_factor_arr( float *x, Word16 l ) for ( int i = 0; i < l; i++ ) { if ( x[i] >= 1 || x[i] <= -1 ) - Q = s_min( Q, norm_s( (Word16) abs( (Word32) x[i] ) ) ); + Q = s_min( Q, norm_s( (Word16) L_abs( (Word32) x[i] ) ) ); } return Q; } @@ -216,7 +216,7 @@ Word16 Q_factor_arrL( float *x, Word16 l ) for ( int i = 0; i < l; i++ ) { if ( x[i] >= 1 || x[i] <= -1 ) - Q = s_min( Q, norm_l( (Word32) abs( (Word32) x[i] ) ) ); + Q = s_min( Q, norm_l( (Word32) L_abs( (Word32) x[i] ) ) ); } return Q; } diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index fc6e60310..6c80c1898 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4004,7 +4004,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( move16(); P_norm_fx[0] = 0; move32(); - FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ ) + Word16 len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) { P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4014,7 +4015,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[1] = 0; move32(); - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4031,8 +4033,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( } P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); - - FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ ) + len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4045,7 +4047,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4057,6 +4060,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } + FOR( ; i < ( num_ch - ndm ); i++ ) { idx = sub( remix_order[i + ndm], ndm ); @@ -4222,7 +4226,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( /*normalize 2nd order*/ norm_fx = 0; move32(); - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } @@ -4243,7 +4248,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) { @@ -4557,7 +4563,8 @@ void ivas_get_spar_md_from_dirac_fx( move16(); P_norm_fx[0] = 0; move32(); - FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ ) + Word16 len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) // i < max( 0, sub( foa_ch, ndm ) ) { P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4567,7 +4574,8 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[1] = 0; move32(); - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4584,8 +4592,8 @@ void ivas_get_spar_md_from_dirac_fx( } P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); - - FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ ) + len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4598,7 +4606,8 @@ void ivas_get_spar_md_from_dirac_fx( move32(); } } - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4775,7 +4784,8 @@ void ivas_get_spar_md_from_dirac_fx( /*normalize 2nd order*/ norm_fx = 0; move32(); - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } @@ -4796,7 +4806,8 @@ void ivas_get_spar_md_from_dirac_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) { diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 20f7a0adf..00f372154 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3807,7 +3807,7 @@ void decoder_tcx_invQ_fx( FOR( i = 0; i < noiseFillingSize; ++i ) { tmp32 = L_shr( x[i], sub( 31, *x_e ) ); - *nf_seed = add_o( *nf_seed, (Word16) abs( tmp32 ) * i * 2, &Overflow ); + *nf_seed = add_o( *nf_seed, shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ), &Overflow ); // abs( tmp32 ) * i * 2 move16(); } } @@ -3875,7 +3875,8 @@ void decoder_tcx_invQ_fx( test(); IF( !st->tcxonly || ( hTcxCfg->resq && hTcxDec->tcx_lpc_shaped_ari ) ) { - FOR( i = 0; i < max( L_spec, L_frameTCX ); i++ ) + Word16 len = s_max( L_spec, L_frameTCX ); + FOR( i = 0; i < len; i++ ) { xn_buf[i] = ONE_IN_Q14; move16(); @@ -4891,11 +4892,11 @@ void decoder_tcx_tns_fx( move16(); test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 ) { test(); test(); - IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) + IF( frame_cnt != 0 && bfi == 0 && st->last_core != ACELP_CORE ) { /* fix sub-window overlap */ hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; @@ -4940,14 +4941,14 @@ void decoder_tcx_tns_fx( test(); test(); test(); - IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) + IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && fUseTns != 0 && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) { /* Apply TNS to get the reconstructed signal */ SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); test(); test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx ); } @@ -4956,10 +4957,10 @@ void decoder_tcx_tns_fx( test(); test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { test(); - IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ { tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); tmp = L_frameTCX; @@ -5232,7 +5233,7 @@ void decoder_tcx_imdct_fx( { IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); } ELSE { diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index a8b54d3fb..018f99fe7 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -396,7 +396,7 @@ static Word16 lfeplc_lev_dur_fx( IF( LT_16( rc_q_fx[i - 1], 31 ) ) { - IF( GT_32( abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 + IF( GT_32( L_abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 { return 1; } @@ -413,7 +413,7 @@ static Word16 lfeplc_lev_dur_fx( } ELSE { - IF( GT_32( abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 + IF( GT_32( L_abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 { return 1; } @@ -465,7 +465,7 @@ static Word16 d_a2rc_fx( move32(); km_q_fx = ff_q_fx[m]; move16(); - IF( GE_64( W_shr( abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) ) + IF( GE_64( W_shr( L_abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) ) { FOR( j = 0; j < lpcorder; j++ ) { @@ -826,7 +826,7 @@ static Word32 find_max_delta_fx( IF( !stable ) { - temp = abs( eps_fx ); + temp = L_abs( eps_fx ); IF( GT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) { exp1 = norm_l( -temp ); @@ -836,12 +836,12 @@ static Word32 find_max_delta_fx( } ELSE { - eps_fx = L_negate( abs( eps_fx ) ); + eps_fx = L_negate( L_abs( eps_fx ) ); } } ELSE { - temp = abs( eps_fx ); + temp = L_abs( eps_fx ); if ( LT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) { BREAK; diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index e03b385b7..9ea666237 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -132,7 +132,8 @@ void ivas_mc_paramupmix_dec_read_BS( nb_bits_read_orig = 0; move16(); last_bit_pos = sub( last_bit_pos, nb_bits_read_orig ); /* reverse the bitstream for easier reading of indices */ - FOR( i = 0; i < min( MAX_BITS_METADATA, last_bit_pos ); i++ ) + Word16 len = s_min( MAX_BITS_METADATA, last_bit_pos ); + FOR( i = 0; i < len; i++ ) { bstr_meta[i] = st_ivas->bit_stream[last_bit_pos - i]; move16(); @@ -269,7 +270,8 @@ void ivas_mc_paramupmix_dec_render( ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx ); - FOR( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) + Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); + FOR( ch = 0; ch < num_ch; ch++ ) { output_local_fx[ch] += n_samples_sf; } diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index 4bebcda5c..81768af44 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -3257,7 +3257,8 @@ static Word16 read_truncGR_azimuth_fx( move16(); IF( LE_16( allowed_bits, add( no_subframes, 1 ) ) ) { - FOR( i = 0; i < min( allowed_bits, no_subframes ); i++ ) + Word16 len = s_min( allowed_bits, no_subframes ); + FOR( i = 0; i < len; i++ ) { IF( bitstream[( *pbit_pos )--] == 0 ) { diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 2b6b145f9..d1efbbd2c 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -936,9 +936,10 @@ Word16 ivas_spar_chk_zero_coefs_fx( ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0]; /*Q0*/ move16(); - FOR( b = 0; b < min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); b++ ) + Word16 min_bands = s_min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); + FOR( b = 0; b < min_bands; b++ ) { - FOR( j = 0; j < sub( add( ndm, ndec ), 1 ); j++ ) + FOR( j = 0; j < ( ( ndm + ndec ) - 1 ); j++ ) { if ( hMdDec->spar_md.band_coeffs[b].pred_re_fx[j] != 0 ) { @@ -948,7 +949,7 @@ Word16 ivas_spar_chk_zero_coefs_fx( } FOR( j = 0; j < ndec; j++ ) { - FOR( k = 0; k < sub( ndm, 1 ); k++ ) + FOR( k = 0; k < ( ndm - 1 ); k++ ) { if ( hMdDec->spar_md.band_coeffs[b].C_re_fx[j][k] != 0 ) { diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 15885a661..4d50ba350 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -585,7 +585,8 @@ static void stereo_dft_generate_comfort_noise_fx( ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) ); /* q_dft */ ptr_i = ptr_r + 1; - FOR( i = 0; i < ( min( output_frame, hFdCngCom->regularStopBand * 16 ) - hFdCngCom->stopFFTbin ) / 2; i++ ) + Word16 len = shr( ( sub( s_min( output_frame, i_mult( hFdCngCom->regularStopBand, 16 ) ), hFdCngCom->stopFFTbin ) ), 1 ); + FOR( i = 0; i < len; i++ ) { /* Real part in FFT bins */ rand_gauss_fx( ptr_r, &st->hTdCngDec->cng_seed, q_dft ); @@ -622,7 +623,8 @@ static void stereo_dft_generate_comfort_noise_fx( ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) ); /* q_dft */ ptr_i = ptr_r + 1; - FOR( i = 0; i < ( min( output_frame, hFdCngCom->regularStopBand * 16 ) - hFdCngCom->stopFFTbin ) / 2; i++ ) + tmp = shr( sub( s_min( output_frame, i_mult( hFdCngCom->regularStopBand, 16 ) ), hFdCngCom->stopFFTbin ), 1 ); + FOR( i = 0; i < tmp; i++ ) { ( *ptr_r ) = L_shl( Mpy_32_32( ( *ptr_r ), tmp32_1 ), q_shift ); /* q_dft + q_shift */ move32(); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index c806f358a..8dcc7ada9 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1522,6 +1522,7 @@ void stereo_dft_dec_fx( Word16 q_samp_ratio = Q15; move16(); #endif /* OPT_STEREO_32KBPS_V1 */ + Word16 len; output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */ @@ -1890,7 +1891,8 @@ void stereo_dft_dec_fx( DFT_R[2 * i + 1] = L_sub( DFT_W, DFT_Y ); /* qDFT */ move32(); } - FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( stop, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] ), L_add( hStereoDft->mixer_mat_smooth_fx[0][1][b + k * IVAS_MAX_NUM_BANDS], @@ -1997,7 +1999,8 @@ void stereo_dft_dec_fx( } ELSE { - FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( stop, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { tmp = L_add( Madd_32_16( pDFT_RES[2 * i], pDFT_DMX[2 * i], g ), DFT_PRED_RES[2 * i] ); /* qDFT */ @@ -2218,8 +2221,8 @@ void stereo_dft_dec_fx( gamma = 0; move16(); } - - FOR( i = max( hFdCngDec->cna_band_limits[b], ( hFdCngCom->startBand / 2 ) ); i < min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); i++ ) + len = s_min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); + FOR( i = s_max( hFdCngDec->cna_band_limits[b], ( hFdCngCom->startBand >> 1 ) ); i < len; i++ ) // i < min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); { Word32 l_tmp; lev1 = *ptr_per++; @@ -2597,6 +2600,7 @@ void stereo_dft_generate_res_pred_fx( q_norm_fac = 0; move16(); #endif /* OPT_STEREO_32KBPS_V1 */ + Word16 len; push_wmops( "gen_respred" ); /* smoothing and limiting parameters */ @@ -2665,7 +2669,8 @@ void stereo_dft_generate_res_pred_fx( move64(); /* calculate band energies (low band only in case of ACELP) */ - FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], bin0 ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { #ifdef OPT_STEREO_32KBPS_V1 dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), @@ -2847,7 +2852,8 @@ void stereo_dft_generate_res_pred_fx( } #endif /* OPT_STEREO_32KBPS_V1 */ - FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], bin0 ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { #ifdef OPT_STEREO_32KBPS_V1 DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */ @@ -2969,7 +2975,8 @@ void stereo_dft_generate_res_pred_fx( move32(); dmx_nrg = EPSILON_FIX; move32(); - FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( bin0, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { dmx_nrg = Madd_32_32( Madd_32_32( dmx_nrg, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft - 31 */ @@ -3010,8 +3017,8 @@ void stereo_dft_generate_res_pred_fx( q_sqrt = 0; move16(); } - - FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( bin0, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, DFT_PRED_RES[2 * i] ), q_sqrt ); /* q_dft */ move32(); @@ -3068,7 +3075,8 @@ void stereo_dft_generate_res_pred_fx( // past_dmx_nrg = EPSILON_FIX; past_dmx_nrg = 0; move32(); - FOR( i = bin0; i < min( ( hStereoDft->NFFT / 2 ), ( STEREO_DFT32MS_N_32k / 2 ) ); i++ ) + len = s_min( shr( hStereoDft->NFFT, 1 ), ( STEREO_DFT32MS_N_32k >> 1 ) ); + FOR( i = bin0; i < len; i++ ) // i < min( ( hStereoDft->NFFT / 2 ), ( hStereoDft->NFFT / 2 ) ) { past_dmx_nrg = L_add( past_dmx_nrg, Madd_32_32( Mpy_32_32( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1] ) ); /* 2 * hStereoDft->q_DFT_past_DMX_fx[d_short_ind] - 31 */ } @@ -3129,7 +3137,8 @@ void stereo_dft_generate_res_pred_fx( } q_shift = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[d_short_ind] ); move16(); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k >> 1 ); + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < len; i++ ) // i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ) { DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), q_shift ); /* q_dft */ move32(); @@ -3243,7 +3252,8 @@ void stereo_dft_generate_res_pred_fx( move32(); dmx_nrg = EPSILON_FIX; move32(); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k >> 1 ); + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < len; i++ ) // i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ) { dmx_nrg = L_add( dmx_nrg, L_shr( Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ), 1 ) ); /* 2 * q_dft - 31 - 1 */ @@ -3269,8 +3279,8 @@ void stereo_dft_generate_res_pred_fx( g2 = L_min( Mpy_32_16_1( pred_gain_avg, STEREO_DFT_STEFFI_GAIN_AMP_FX ), Madd_32_16( Mpy_32_16_1( pred_gain_avg, sub( (Word16) ( 0x7FFF ), STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ), g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ); /* Q31 */ - - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k >> 1 ); + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < len; i++ ) // i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ) { DFT_PRED_RES[2 * i] = Mpy_32_32( g2, DFT_PRED_RES[2 * i] ); /* Q31 */ move32(); diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 1e8bef488..44439540f 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1341,8 +1341,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /* Init current 2-tuple encoding */ - a1 = (Word16) abs( x[a1_i] ); - b1 = (Word16) abs( x[b1_i] ); + a1 = abs_s( x[a1_i] ); + b1 = abs_s( x[b1_i] ); lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); @@ -1731,7 +1731,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( /* Main Loop through the 2-tuples */ /*hContextMem->nt_half = end_line >> 1;*/ - FOR( k = start_line; k < min( hContextMem->lastnz, end_line ); k += 2 ) + Word16 len = s_min( hContextMem->lastnz, end_line ); + FOR( k = start_line; k < len; k += 2 ) { a1_i = k; /* Q0 */ move16(); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 307d42078..2db8b956b 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -3039,7 +3039,7 @@ void FdCngEncodeMDCTStereoSID_fx( /* quantize channel coherence */ coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); - coh_idx = max( 0, min( coh_idx, 15 ) ); + coh_idx = s_max( 0, s_min( coh_idx, 15 ) ); /* ---- Write SID bitstream ---- */ diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 37d25c508..104eeb998 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -623,7 +623,7 @@ void ivas_agc_enc_process_fx( temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e ); /* exp(div_e) */ IF( div_e < 0 ) { - temp_16 = shr( temp_16, (Word16) abs( div_e ) ); + temp_16 = shr( temp_16, abs_s( div_e ) ); div_e = 0; move16(); } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index a9da7f342..73403a848 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -184,7 +184,7 @@ ivas_error pre_proc_ivas_fx( } IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) ) { - configureFdCngEnc_ivas_fx( st->hFdCngEnc, max( st->input_bwidth, WB ), flag_1 ); + configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 ); } if ( st->ini_frame == 0 ) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 811e53d12..a9d62a2b0 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -856,7 +856,7 @@ ivas_error ivas_cpe_enc_fx( } ELSE { - internal_Fs = max( INT_FS_16k, sts[0]->sr_core ); + internal_Fs = L_max( INT_FS_16k, sts[0]->sr_core ); } /* iDFT at input sampling rate */ diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 3eeb45d14..c65c85356 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -493,7 +493,7 @@ ivas_error ivas_init_encoder( if ( NE_32( ivas_format, MONO_FORMAT ) ) { /* In IVAS, ensure that minimum coded bandwidth is WB */ - hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ + hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ move16(); } st_ivas->ism_mode = ISM_MODE_NONE; diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 86237fb31..11056b535 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -170,17 +170,17 @@ static void ivas_lfe_enc_quant_fx( { temp_lfe_dct[4 * i] = pLfe_dct[2 * i]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i] ) ); temp_lfe_dct[4 * i + 1] = pLfe_dct[2 * i + 1]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i + 1] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i + 1] ) ); temp_lfe_dct[4 * i + 2] = pLfe_dct[2 * i + num_dct_pass_bins]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i + 2] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i + 2] ) ); temp_lfe_dct[4 * i + 3] = pLfe_dct[2 * i + num_dct_pass_bins + 1]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i + 3] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i + 3] ) ); } IF( LE_64( lfe_abs_sum, W_shr( IVAS_LFE_ABS_SUM_FLT_THR_Q42, sub( 42, q_pLfe_dct ) ) ) ) @@ -250,9 +250,9 @@ static void ivas_lfe_enc_quant_fx( move16(); } - IF( LT_32( max_of_vals, abs( values[i] ) ) ) + IF( LT_32( max_of_vals, abs_s( values[i] ) ) ) { - max_of_vals = (Word16) abs( values[i] ); + max_of_vals = abs_s( values[i] ); move16(); } } @@ -475,8 +475,8 @@ void ivas_lfe_enc_fx( IF( GT_16( q_out1, q_out2 ) ) { - Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, min( q_tmp2, sub( q_out1, q_out2 ) ) ); - q_out2 = add( q_out2, min( q_tmp2, sub( q_out1, q_out2 ) ) ); + Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, s_min( q_tmp2, sub( q_out1, q_out2 ) ) ); + q_out2 = add( q_out2, s_min( q_tmp2, sub( q_out1, q_out2 ) ) ); IF( GT_16( q_out1, q_out2 ) ) { Scale_sig32( lfe_dct_fx, num_dct_pass_bins, sub( q_out2, q_out1 ) ); // q_out2 @@ -486,8 +486,8 @@ void ivas_lfe_enc_fx( } ELSE IF( LT_16( q_out1, q_out2 ) ) { - Scale_sig32( lfe_dct_fx, num_dct_pass_bins, min( q_tmp1, sub( q_out2, q_out1 ) ) ); - q_out1 = add( q_out1, min( q_tmp1, sub( q_out2, q_out1 ) ) ); + Scale_sig32( lfe_dct_fx, num_dct_pass_bins, s_min( q_tmp1, sub( q_out2, q_out1 ) ) ); + q_out1 = add( q_out1, s_min( q_tmp1, sub( q_out2, q_out1 ) ) ); IF( LT_16( q_out1, q_out2 ) ) { Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, sub( q_out1, q_out2 ) ); // q_out1 diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 9060c786b..abd09cbbd 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -201,7 +201,7 @@ ivas_error ivas_mc_paramupmix_enc_open_fx( /* still 1.5ms off, since MCT delay is not large enough */ /* param at end of frame */ fb_cfg->prior_input_length = (Word16) ( NS2SA_FX2( input_Fs, 12000000L ) + NS2SA_FX2( input_Fs, DELAY_FB_4_NS / 2 ) - input_frame / 2 - NS2SA_FX2( input_Fs, DELAY_FB_1_NS / 2 ) ); - fb_cfg->prior_input_length = (Word16) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); + fb_cfg->prior_input_length = s_max( fb_cfg->prior_input_length, (Word16) input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Allocate and initialize FB mixer handle */ IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hMCParamUpmix->hFbMixer ), input_Fs, fb_cfg, 0 ) ), IVAS_ERR_OK ) ) @@ -496,12 +496,12 @@ static void quantize_pars_fx( Word16 exp_var1 = 0; move16(); Word32 var1 = BASOP_Util_Add_Mant32Exp( v_fx[iv], exp_v, L_negate( data_fx[iq0] ), 31 - Q28, &exp_var1 ); - var1 = abs( var1 ); + var1 = L_abs( var1 ); Word16 exp_var2 = 0; move16(); Word32 var2 = BASOP_Util_Add_Mant32Exp( v_fx[iv], exp_v, L_negate( data_fx[iq1] ), 31 - Q28, &exp_var2 ); - var2 = abs( var2 ); + var2 = L_abs( var2 ); Word16 cmp_2 = BASOP_Util_Cmp_Mant32Exp( var1, exp_var1, var2, exp_var2 ); @@ -591,12 +591,12 @@ static void quantize_beta_fx( Word16 exp_var1 = 0; move16(); Word32 var1 = BASOP_Util_Add_Mant32Exp( beta_fx[iv], exp_beta, L_negate( quant_table_fx.data[iq0] ), 31 - Q28, &exp_var1 ); - var1 = abs( var1 ); + var1 = L_abs( var1 ); Word16 exp_var2 = 0; move16(); Word32 var2 = BASOP_Util_Add_Mant32Exp( beta_fx[iv], exp_beta, L_negate( quant_table_fx.data[iq1] ), 31 - Q28, &exp_var2 ); - var2 = abs( var2 ); + var2 = L_abs( var2 ); Word16 cmp_2 = BASOP_Util_Cmp_Mant32Exp( var1, exp_var1, var2, exp_var2 ); diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 648dcdb73..1229624de 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -300,7 +300,7 @@ ivas_error ivas_osba_enc_reconfig( } } - ivas_spar_config_fx( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + ivas_spar_config_fx( ivas_total_brate, s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); hSpar = st_ivas->hSpar; diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 7a2a28767..3416ab279 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4089,7 +4089,8 @@ static ivas_error requantize_direction_EC_3_fx( IF( LE_16( allowed_bits, add( no_subframes, 1 ) ) ) { - FOR( k = 0; k < min( no_subframes, allowed_bits ); k++ ) + Word16 len = s_min( no_subframes, allowed_bits ); + FOR( k = 0; k < len; k++ ) { push_next_indice( hMetaData, q_direction->band_data[j].azimuth_index[k], 1 ); } diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index 86427eb2d..8fdca5815 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -199,7 +199,7 @@ ivas_error ivas_sba_enc_reconfigure_fx( } } - ivas_spar_config_fx( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + ivas_spar_config_fx( ivas_total_brate, s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); hSpar = st_ivas->hSpar; diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 7900033f4..862102d3b 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -547,7 +547,8 @@ static Word32 calc_mean_E_ratio_fx( sum_nrg_R_e = 0; move16(); - FOR( i = band_limits[b]; i < min( band_limits[b + 1], STEREO_DFT_N_32k_ENC / 2 ); i++ ) + Word16 len = s_min( band_limits[b + 1], STEREO_DFT_N_32k_ENC >> 1 ); + FOR( i = band_limits[b]; i < len; i++ ) { // sum_xcorr[0] += hItd->xcorr_smooth[2 * i]; sum_xcorr[0] = BASOP_Util_Add_Mant32Exp( sum_xcorr[0], sum_xcorr_e[0], hItd->xcorr_smooth_fx[2 * i], hItd->xcorr_smooth_fx_e[2 * i], &sum_xcorr_e[0] ); @@ -2568,7 +2569,11 @@ void stereo_dft_enc_compute_itd_fx( prev_itd_max = hItd->hybrid_itd_max; move16(); /* enable hybrid ITD handling for very large ITDs*/ - hItd->hybrid_itd_max = ( abs( itd ) > STEREO_DFT_ITD_MAX && abs( itd ) < STEREO_DFT_ITD_MAX_ANA && !hCPE->hCoreCoder[0]->sp_aud_decision0 && hCPE->element_brate < IVAS_32k ); + // hItd->hybrid_itd_max = ( abs_s( itd ) > STEREO_DFT_ITD_MAX && abs_s( itd ) < STEREO_DFT_ITD_MAX_ANA && !hCPE->hCoreCoder[0]->sp_aud_decision0 && hCPE->element_brate < IVAS_32k ); + test(); + test(); + test(); + hItd->hybrid_itd_max = ( GT_16( abs_s( itd ), STEREO_DFT_ITD_MAX ) && LT_16( abs_s( itd ), STEREO_DFT_ITD_MAX_ANA ) && !hCPE->hCoreCoder[0]->sp_aud_decision0 && LT_32( hCPE->element_brate, IVAS_32k ) ); move16(); /* Update memory */ hItd->prev_itd = itd; diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index a3388db61..c3cb68719 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -1203,7 +1203,7 @@ static Word32 find_poc_peak_fx( /*compute peak_range*/ tmp1 = idiv1616( hPOC->shift_limit, STEREO_DMX_EVS_FIND_POC_PEAK_TAU ); - peak_range = idiv1616( add( extract_l( abs( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 + peak_range = idiv1616( add( extract_l( abs_s( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 FOR( i = 1; i <= peak_range; i++ ) { @@ -1250,7 +1250,7 @@ static Word32 find_poc_peak_fx( IF( on[n] ) /*if channel n was active (likely to be preceding) in the previous frame*/ { tmp13_e = 0, tmp15_e = 0; - tmp13 = BASOP_Util_Divide1616_Scale( (Word16) abs( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); + tmp13 = BASOP_Util_Divide1616_Scale( abs_s( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); tmp14 = L_mult( 6554 /*0.2f Q15*/, tmp13 ); // tmp13_e tmp15 = BASOP_Util_Add_Mant32Exp( 644245120 /*0.75f in Q31*/, 0, L_negate( tmp14 ), tmp13_e, &tmp15_e ); tmp15 = Mpy_32_32( tmp15, peakQ_fx[n] ); // tmp15_e + peakQ_e[n] @@ -1299,7 +1299,7 @@ static Word32 find_poc_peak_fx( tmp13_e = 0, tmp15_e = 0; move16(); move16(); - tmp13 = BASOP_Util_Divide1616_Scale( (Word16) abs( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); + tmp13 = BASOP_Util_Divide1616_Scale( abs_s( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); tmp14 = L_mult( 6554 /*0.2f Q15*/, tmp13 ); // tmp13_e tmp15 = BASOP_Util_Add_Mant32Exp( 1610612736 /*0.75f in Q31*/, 0, L_negate( tmp14 ), tmp13_e, &tmp15_e ); diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 351b87cd0..78c324cce 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -1737,7 +1737,7 @@ void stereo_tca_enc_fx( prev_ICA_flag = 0; move16(); test(); - if ( hCPE->hStereoTD->prev_fr_LRTD_TD_dec && abs( hStereoTCA->prevCorrLagStats[2] ) != 0 ) + if ( hCPE->hStereoTD->prev_fr_LRTD_TD_dec && abs_s( hStereoTCA->prevCorrLagStats[2] ) != 0 ) { prev_ICA_flag = 1; move16(); @@ -1924,7 +1924,7 @@ void stereo_tca_enc_fx( /* Note!! : Always keep the assert (prevNCShift>>1) below according to the equation used here to get tempS */ tempS = shr( currentNCShift, 1 ); /* Q0 */ - IF( LE_32( abs( sub( currentNCShift, prevNCShift ) ), L_min( N_MAX_SHIFT_CHANGE, Mpy_32_32( imult3216( input_Fs, N_MAX_SHIFT_CHANGE ), 67109 /* 1/32000.0f in Q31*/ ) ) ) ) + IF( LE_32( abs_s( sub( currentNCShift, prevNCShift ) ), L_min( N_MAX_SHIFT_CHANGE, Mpy_32_32( imult3216( input_Fs, N_MAX_SHIFT_CHANGE ), 67109 /* 1/32000.0f in Q31*/ ) ) ) ) { adjustTargetSignal_fx( ( target_fx - tempS ), prevNCShift, currentNCShift, L_shift_adapt, 0 ); } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index f3ceb2757..6513a3fa7 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -241,7 +241,7 @@ ivas_error stereo_memory_enc_fx( IF( hCPE->hStereoTCA != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { #ifdef FIX_1132_STACK_CORRUPTION - Word16 tmp = extract_h( abs( hCPE->hStereoDft->hItd->itd_fx[1] ) ); + Word16 tmp = extract_h( L_abs( hCPE->hStereoDft->hItd->itd_fx[1] ) ); if ( hCPE->hStereoDft->hItd->itd_fx[1] < 0 ) { tmp = negate( tmp ); diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 4ea5c5e96..32803f6c3 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -949,8 +949,8 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = add( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, q_shift ); move16(); } - h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); - h_freq_domain_decorr_ap_state->q_direct_energy_smooth = min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); + h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); + h_freq_domain_decorr_ap_state->q_direct_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); #endif e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 882c6e5b8..cc8e4d8bd 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -3811,7 +3811,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->num_protos_diff, hDirACRend->proto_index_diff, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport ), + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * s_min( 4, nchan_transport ), &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, onset_filter_fx, hDirACRend->h_freq_domain_decorr_ap_params, diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 652fc898f..45e492fc8 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -740,7 +740,7 @@ void ivas_reverb_calc_color_levels_fx( Word16 temp = 0, result_e = 0; move16(); move16(); - cos_w = getCosWord16R2( (Word16) abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) ); // q = 15 + cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) ); // q = 15 H_filter = L_add( L_shr( L_add( L_shr( Mpy_32_32( coefB[0], coefB[0] ), 1 ), L_shr( Mpy_32_32( coefB[1], coefB[1] ), 1 ) ), 2 ), L_shr( Mpy_32_32( coefB[0], Mpy_32_32( coefB[1], L_shl( cos_w, 15 ) ) ), 1 ) ); // q = 28 H_filter = BASOP_Util_Divide3232_Scale_cadence( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp ); H_filter = Sqrt32( H_filter, &temp ); @@ -1155,9 +1155,9 @@ void ivas_reverb_get_hrtf_set_properties_fx( IA_coherence[freq_idx] = L_shl( IA_coherence[freq_idx], sub( 27, sub( 15, temp ) ) ); // q = 27 move32(); /* Limiting to (0...1) range in case of small numerical errors or negative values */ - IA_coherence[freq_idx] = min( IA_coherence[freq_idx], ONE_IN_Q27 ); // Q27 + IA_coherence[freq_idx] = L_min( IA_coherence[freq_idx], ONE_IN_Q27 ); // Q27 move32(); - IA_coherence[freq_idx] = max( IA_coherence[freq_idx], 0 ); // Q27 + IA_coherence[freq_idx] = L_max( IA_coherence[freq_idx], 0 ); // Q27 move32(); } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 7ad4c4ccb..8b352218b 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -399,7 +399,7 @@ void rotateAziEle_fx( angle = extract_l( L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 24 ) ); // Q0 } - *azi = s_max( -180, min( 180, angle ) ); + *azi = s_max( -180, s_min( 180, angle ) ); move16(); IF( isPlanar == 0 ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 0cda39d62..ae3166520 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1177,8 +1177,8 @@ static Word8 checkObjectPositionChanged_fx( IVAS_ISM_METADATA *previousPos ) { test(); - return !( LT_32( abs( L_sub( currentPos->azimuth_fx, previousPos->azimuth_fx ) ), EPSILLON_FX ) && - LT_32( abs( L_sub( currentPos->elevation_fx, previousPos->elevation_fx ) ), EPSILLON_FX ) ); + return !( LT_32( L_abs( L_sub( currentPos->azimuth_fx, previousPos->azimuth_fx ) ), EPSILLON_FX ) && + LT_32( L_abs( L_sub( currentPos->elevation_fx, previousPos->elevation_fx ) ), EPSILLON_FX ) ); } static rendering_context getRendCtx( @@ -2018,7 +2018,7 @@ static ivas_error updateMcPanGainsForAmbiOut( Word32 temp = inputMc->panGains_fx[ch_out][i]; move32(); - IF( GE_32( abs( temp ), ONE_IN_Q29 ) ) + IF( GE_32( L_abs( temp ), ONE_IN_Q29 ) ) { IF( temp > 0 ) { @@ -2066,7 +2066,7 @@ static ivas_error updateMcPanGainsForAmbiOut( { Word32 temp = inputMc->panGains_fx[ch_out][i]; move32(); - IF( GE_32( abs( temp ), ONE_IN_Q29 ) ) + IF( GE_32( L_abs( temp ), ONE_IN_Q29 ) ) { IF( temp > 0 ) { @@ -4537,7 +4537,7 @@ static void renderBufferChannelLerp_fx( /* Process current output channel only if applying non-zero gains */ test(); test(); - IF( GT_32( abs( currentGain ), EPSILON_FX ) || ( gainsPrev != NULL && GT_32( abs( previousGain ), EPSILON_FX ) ) ) + IF( GT_32( L_abs( currentGain ), EPSILON_FX ) || ( gainsPrev != NULL && GT_32( L_abs( previousGain ), EPSILON_FX ) ) ) { /* Reset input pointer to the beginning of input channel */ inSmpl = getSmplPtr_fx( inAudio, inChannelIdx, 0 ); @@ -4546,7 +4546,7 @@ static void renderBufferChannelLerp_fx( outSmpl = getSmplPtr_fx( outAudio, outChnlIdx, 0 ); test(); - IF( gainsPrev == NULL || LE_32( abs( L_sub( L_shr( previousGain, 1 ), L_shr( currentGain, 1 ) ) ), EPSILON_FX ) ) + IF( gainsPrev == NULL || LE_32( L_abs( L_sub( L_shr( previousGain, 1 ), L_shr( currentGain, 1 ) ) ), EPSILON_FX ) ) { /* If no interpolation from previous frame, apply current gain */ DO -- GitLab From 7a5cb1ab39d2b4053aa3ad960201a0e82542acb7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 10:45:15 +0530 Subject: [PATCH 280/329] Fix for 3GPP issue 1347: Saturation of energies memory for dtx path Link #1347 --- lib_enc/ivas_core_pre_proc_front_fx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f41eb7f9c..46de4e232 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1016,14 +1016,14 @@ ivas_error pre_proc_front_ivas_fx( Word16 msNoiseEst_Q = Q31; move16(); move16(); - zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART ); + zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); IF( zero_flag ) { - msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART ); + msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); + scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ + st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); + move16(); } - Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ - st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); - move16(); perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); } ELSE @@ -1049,14 +1049,14 @@ ivas_error pre_proc_front_ivas_fx( move16(); Word16 msNoiseEst_Q = Q31; move16(); - zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART ); /* Q0 */ + zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); /* Q0 */ IF( zero_flag ) { - msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART ); + msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); + scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ + st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); + move16(); } - Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ - st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); - move16(); zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); /* Q0 */ Word16 normmsperiodog = 31; move16(); -- GitLab From 9a19ecf2e21bcafd8553cce25ad5e0154b88399c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 11:49:53 +0530 Subject: [PATCH 281/329] ASAN issue fix for decoder --- lib_dec/evs_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index aa997d4c0..f20ff77f3 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -36,7 +36,7 @@ ivas_error evs_dec_fx( Word16 exp, fra; Word16 tmp_buffer_fx[L_FRAME48k]; Word16 tmp16, tmp16_2; - Word16 synth_fx[L_FRAME48k]; + Word16 synth_fx[L_FRAME48k + HQ_DELTA_MAX * HQ_DELAY_COMP]; Word16 fb_exc_fx[L_FRAME16k]; Word16 pitch_buf_fx[NB_SUBFR16k] = { 0 }; Word16 Q_fb_exc; -- GitLab From 99ee84bae7b22a7366a33bbf804308b8eb0ce60f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 7 Mar 2025 10:16:53 +0100 Subject: [PATCH 282/329] port FIX_923_EXTERNAL_REND_COMMAND_LINE --- lib_com/options.h | 1 + lib_util/cmdln_parser.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8eb059537..b57c3beb6 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,6 +181,7 @@ #define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif +#define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index b2c8f85bc..432db36a5 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -150,7 +150,26 @@ static int8_t optionMatchesString( const char *optionName = stringToOptionName( str ); +#ifdef FIX_923_EXTERNAL_REND_COMMAND_LINE + char optionName_to_upper[FILENAME_MAX]; + strncpy( optionName_to_upper, optionName, sizeof( optionName_to_upper ) - 1 ); + optionName_to_upper[sizeof( optionName_to_upper ) - 1] = '\0'; + to_upper( optionName_to_upper ); + + char match_to_upper[FILENAME_MAX]; + strncpy( match_to_upper, opt.props.match, sizeof( match_to_upper ) - 1 ); + optionName_to_upper[sizeof( match_to_upper ) - 1] = '\0'; + to_upper( match_to_upper ); + + char matchShort_to_upper[FILENAME_MAX]; + strncpy( matchShort_to_upper, opt.props.matchShort, sizeof( matchShort_to_upper ) - 1 ); + optionName_to_upper[sizeof( matchShort_to_upper ) - 1] = '\0'; + to_upper( matchShort_to_upper ); + + if ( strncmp( optionName_to_upper, match_to_upper, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName_to_upper, matchShort_to_upper, MAX_OPTION_LENGTH ) == 0 ) +#else if ( strncmp( optionName, opt.props.match, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName, opt.props.matchShort, MAX_OPTION_LENGTH ) == 0 ) +#endif { return 1; } -- GitLab From 7ad3ba2cbf01ffbfc70feb1c499fceafa669cda1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 14:58:16 +0530 Subject: [PATCH 283/329] Fix for LTV crash issue Fix for LTV crash : 4 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, DTX on, BINAURAL ROOM IR out, random FER at 5% --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 00f372154..191065855 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3807,7 +3807,7 @@ void decoder_tcx_invQ_fx( FOR( i = 0; i < noiseFillingSize; ++i ) { tmp32 = L_shr( x[i], sub( 31, *x_e ) ); - *nf_seed = add_o( *nf_seed, shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ), &Overflow ); // abs( tmp32 ) * i * 2 + *nf_seed = add_o( *nf_seed, extract_l( L_shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ) ), &Overflow ); // abs( tmp32 ) * i * 2 move16(); } } -- GitLab From 617ebe4d741ed8b312a516dd000bcbd481cebddd Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 7 Mar 2025 10:49:04 +0100 Subject: [PATCH 284/329] port FIX_921_OMASA_DELAY_PRINTOUT --- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8eb059537..0685b3ae8 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,6 +181,7 @@ #define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif +#define FIX_921_OMASA_DELAY_PRINTOUT /* VA: issue 921: correct OMASA decoder delay printout */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9753893e2..23cd54a62 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2843,7 +2843,12 @@ ivas_error IVAS_DEC_GetDelay( nSamples[0] = add( nSamples[1], nSamples[2] ); move16(); +#ifdef FIX_921_OMASA_DELAY_PRINTOUT + test(); + IF( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) +#else IF( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) ) +#endif { /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ nSamples[1] = sub( nSamples[1], NS2SA_FX2( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ) ); -- GitLab From 2687fb430e76ef5d563281f682de1edf86bd5448 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 11:14:59 +0100 Subject: [PATCH 285/329] run clang-format --- lib_dec/ivas_binRenderer_internal_fx.c | 10 +- lib_dec/lib_dec_fx.c | 184 ++++++++++++------------- 2 files changed, 96 insertions(+), 98 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index e3a66da49..192d42033 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1857,8 +1857,8 @@ void ivas_binRenderer_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ @@ -1866,9 +1866,9 @@ void ivas_binRenderer_fx( Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index df3981a37..80eff327c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1183,125 +1183,123 @@ ivas_error IVAS_DEC_GetSamples( { /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ /* setup */ - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ + return error; + } +} +{ + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) + { + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) { return error; } } - { - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) - { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) - { - return error; - } - } + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 - } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 - } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 } - ELSE + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); + return IVAS_ERR_UNKNOWN; } - - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - return error; + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 } - - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } + return IVAS_ERR_UNKNOWN; } - hIvasDec->hasBeenFedFrame = false; - move16(); } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); + } + ELSE + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); + } - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); - } - ELSE + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) { - *needNewFrame = false; - move16(); + return IVAS_ERR_UNKNOWN; } } + hIvasDec->hasBeenFedFrame = false; + move16(); } - *nOutSamples = nSamplesRendered; - move16(); + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - return IVAS_ERR_OK; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } +} +} + +*nOutSamples = nSamplesRendered; +move16(); + +return IVAS_ERR_OK; } -- GitLab From 40d41173a5b485a8aa746d775b8dd7d6c5fd9c13 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 12:24:09 +0100 Subject: [PATCH 286/329] fix compilation --- apps/renderer.c | 2 +- lib_com/ivas_rotation_com.c | 2 +- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 15 +++--- lib_dec/ivas_mc_param_dec_fx.c | 65 +++++++++++++++++++++++++ lib_isar/isar_NoiseGen.c | 2 +- lib_isar/isar_PerceptualModel.c | 2 +- lib_isar/isar_PredDecoder.c | 2 +- lib_isar/isar_PredEncoder.c | 2 +- lib_isar/isar_RMSEnvGrouping.c | 2 +- lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_enc.c | 2 +- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 2 +- lib_isar/isar_lcld_prot.h | 1 - lib_isar/isar_lcld_rom_tables.c | 2 +- lib_isar/isar_splitRend_lcld_dec.c | 2 +- lib_isar/isar_splitRendererPLC.c | 2 +- lib_isar/isar_splitRendererPost.c | 2 +- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/isar_splitRenderer_utils.c | 2 +- lib_isar/lib_isar_post_rend.c | 2 +- lib_isar/lib_isar_pre_rend.c | 2 +- lib_rend/ivas_stat_rend.h | 7 ++- lib_util/split_rend_bfi_file_reader.c | 2 +- lib_util/split_render_file_read_write.c | 2 +- 26 files changed, 102 insertions(+), 30 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 365d45689..0ee2ac94d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -3918,8 +3918,8 @@ static void convertInputBuffer_fx( ++i; } } - *out_q_factor = in_q_factor; #ifdef SPLIT_REND_WITH_HEAD_ROT + *out_q_factor = in_q_factor; } #endif diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index e6f1808e4..d33d3119d 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -36,7 +36,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING diff --git a/lib_com/options.h b/lib_com/options.h index 7aeea040f..0320c6a57 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,5 +181,5 @@ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ +//#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 192d42033..81608189d 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -98,6 +98,7 @@ static void ivas_binRenderer_filterModule_fx( #ifndef OPT_BASOP_ADD_v1 Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx][0] ); #endif /* OPT_BASOP_ADD_v1 */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 @@ -153,7 +154,7 @@ static void ivas_binRenderer_filterModule_fx( #ifdef OPT_BASOP_ADD_v1 IF( shift_q != 0 ) { -#endif /* OPT_BASOP_ADD_v1 */ +#endif /* OPT_BASOP_ADD_v1 */ outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr @@ -532,6 +533,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( #else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ +#endif /* !SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; @@ -552,6 +554,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( #else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; @@ -1857,8 +1860,8 @@ void ivas_binRenderer_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ @@ -1866,9 +1869,9 @@ void ivas_binRenderer_fx( Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 897fd4433..f407baf2e 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1843,8 +1843,13 @@ void ivas_param_mc_dec_render_fx( /*CLDFB*/ Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { @@ -2178,8 +2183,31 @@ void ivas_param_mc_dec_render_fx( { Word16 input_q = 6; move16(); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + FOR( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + } + } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); + } + } +#endif + /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, @@ -2198,6 +2226,20 @@ void ivas_param_mc_dec_render_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + { + FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) + { + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 + } + } + } +#else FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) @@ -2206,6 +2248,24 @@ void ivas_param_mc_dec_render_fx( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 } } +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) + { + Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + } + } + } + } +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } @@ -2229,8 +2289,13 @@ void ivas_param_mc_dec_render_fx( { IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; // Q6 + ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[0][ch][i]; // Q6 +#else RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; // Q6 ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; // Q6 +#endif } ELSE { diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c index b872e89c9..7273b0e81 100644 --- a/lib_isar/isar_NoiseGen.c +++ b/lib_isar/isar_NoiseGen.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index ad3329500..16558dd36 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_rom_tables.h" #include #include "wmc_auto.h" diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index c55a88011..b30a6e0a8 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" #include "isar_prot.h" #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 85dc5f8f8..0cd32b70c 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -36,7 +36,7 @@ #include #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_prot.h" #include "wmc_auto.h" #include "prot_fx.h" diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 3c40cb096..9b5de2574 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -36,7 +36,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index bad857764..17143ec3b 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "isar_lc3plus_dec.h" #include "isar_lc3plus_common.h" diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 2f9ab6f01..08ec7c0a8 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -34,7 +34,7 @@ #include "isar_lc3plus_common.h" #include "lc3.h" #include "ivas_error_utils.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "options.h" diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 682176a91..a64a12aea 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" -#include "prot.h" +#include "prot_fx.h" #include #include "isar_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index b9c60b8d4..48445d080 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -37,7 +37,7 @@ #include #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" -#include "prot.h" +#include "prot_fx.h" #include "prot_fx.h" #include "isar_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index fffeb6c5c..49e03f5ef 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -38,7 +38,6 @@ #include "typedef.h" #include "common_api_types.h" #include "isar_lcld_rom_tables.h" -// #include "prot.h" /* clang-format off */ typedef struct LCLD_ENCODER LCLDEncoder; diff --git a/lib_isar/isar_lcld_rom_tables.c b/lib_isar/isar_lcld_rom_tables.c index 3b35a3282..8ecf74336 100644 --- a/lib_isar/isar_lcld_rom_tables.c +++ b/lib_isar/isar_lcld_rom_tables.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_prot.h" #include diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index d275a0aff..d96e5b3ec 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_prot.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "prot_fx.h" //#include "control.h" #ifdef DEBUGGING diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 037c43048..c5f5300af 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_cnst.h" #include "isar_prot.h" #include "enh64.h" diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 6f6af1484..f8cf7c571 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -39,7 +39,7 @@ #endif #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_rom_post_rend.h" #include "isar_prot.h" #ifdef DEBUGGING diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index a766418d1..74484eb62 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -39,7 +39,7 @@ #endif #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "lib_isar_pre_rend.h" #include "isar_rom_post_rend.h" #include "isar_prot.h" diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index fa51d44ef..0c4238ac6 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "isar_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index dd2884731..57317269a 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -35,7 +35,7 @@ #include "lib_isar_post_rend.h" #include "isar_stat.h" #include "isar_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index c44767404..367e0be5b 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "prot_fx.h" #include "isar_cnst.h" #include "isar_rom_post_rend.h" diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 370a5452c..993ad40b2 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -667,7 +667,11 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 ****filterStatesLeftReal_fx; Word32 ****filterStatesLeftImag_fx; +#ifdef OPT_BASOP_ADD_v1 + Word16 Q_filterStatesLeft; +#else Word16 ****Q_filterStatesLeft; +#endif #else Word32 ***filterStatesLeftReal_fx; Word32 ***filterStatesLeftImag_fx; @@ -676,6 +680,7 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx #else /* OPT_BASOP_ADD_v1 */ Word16 ***Q_filterStatesLeft; #endif /* OPT_BASOP_ADD_v1 */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; @@ -835,7 +840,7 @@ typedef struct ivas_combined_orientation_struct Word32 Rmat_prev_fx[MAX_HEAD_ROT_POSES][3][3]; #else Word32 Rmat_prev_fx[3][3]; -#endif /* Q30 */ +#endif /* Q30 */ Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ Word16 q_chEneIIR; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */ diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 3fc633317..4c5770f45 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -35,7 +35,7 @@ #include "split_rend_bfi_file_reader.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" struct SplitRendBFIFileReader { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index e52f9fe86..065300c10 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -35,7 +35,7 @@ #include "split_render_file_read_write.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" /*------------------------------------------------------------------------------------------* -- GitLab From 20f818d290df750af39d29c345878d3a8abce5b8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 12:25:13 +0100 Subject: [PATCH 287/329] remove unaccessed variable to fix compiler warning --- lib_dec/dec_uv_fx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index aa898956a..ed54a32af 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -44,7 +44,6 @@ void decod_unvoiced_fx( Word16 voice_fac_fx; /* Voicing factor */ Word16 code_fx[L_SUBFR]; /* algebraic codevector */ Word16 i_subfr_fx; - const Word16 *p_Aq_fx; Word16 *pt_pitch_fx; gain_pit_fx = 0; @@ -57,7 +56,6 @@ void decod_unvoiced_fx( CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx ); } - p_Aq_fx = Aq_fx; move16(); /*Q12*/ /* pointer to interpolated LPC parameters */ pt_pitch_fx = pitch_buf_fx; move16(); /* pointer to the pitch buffer */ @@ -92,7 +90,6 @@ void decod_unvoiced_fx( interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR ); - p_Aq_fx += ( M + 1 ); pt_pitch_fx++; st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx; move16(); -- GitLab From 14a2604be045b47a5bcb014c410b46c36292070b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 13:25:36 +0100 Subject: [PATCH 288/329] fix compiler warning --- lib_com/prot_fx.h | 1 - lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/dec_uv_fx.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 7bc835807..310237884 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8560,7 +8560,6 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag // dec_uv_fx.c void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index c0ad52a48..daec97ba8 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -801,7 +801,7 @@ ivas_error acelp_core_dec_fx( ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) ) { /* UNVOICED frames */ - decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); + decod_unvoiced_fx( st_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); } ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) ) { diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index ed54a32af..f39deaf16 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -27,7 +27,6 @@ static void gain_dec_gacelp_uv_fx( void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ -- GitLab From 55424144763042ec79028d5748e7435e8593b286 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 14:59:35 +0100 Subject: [PATCH 289/329] activate OPT_BASOP_ADD_v1 again and make everything compile --- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0320c6a57..7aeea040f 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,5 +181,5 @@ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -//#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ +#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 81608189d..c442e29f5 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -91,7 +91,9 @@ static void ivas_binRenderer_filterModule_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); +#ifndef OPT_BASOP_ADD_v1 Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx][0] ); +#endif #else filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); @@ -367,10 +369,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { @@ -384,10 +388,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -401,10 +407,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -418,10 +426,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -609,7 +619,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); +#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -625,7 +640,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -1596,9 +1616,11 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); @@ -1606,18 +1628,22 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) -- GitLab From 6ca11d89314921e6c09f6ff4200a69e8b50946bf Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 15:11:41 +0100 Subject: [PATCH 290/329] fix windows build --- Workspace_msvc/lib_com.vcxproj | 16 ++++++++++++++-- Workspace_msvc/lib_com.vcxproj.filters | 13 +++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9bb04c835..4f40c8799 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -222,6 +222,7 @@ + @@ -229,7 +230,7 @@ - + @@ -309,10 +310,13 @@ + + + @@ -320,10 +324,17 @@ + + + + + + + @@ -332,6 +343,7 @@ + @@ -341,4 +353,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index b9769e3ec..eaacf1ba7 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -538,6 +538,8 @@ common_ivas_c + + @@ -621,6 +623,17 @@ common_all_c + + + + + + + + + + + -- GitLab From a58d5ed734a3394bd99eb84c056023f4a9707fc8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 10 Mar 2025 08:43:15 +0100 Subject: [PATCH 291/329] use long testvectors for USAN tests too --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 58547f2ab..cb532dd7d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1307,7 +1307,7 @@ ivas-pytest-enc-usan: before_script: - CLANG_NUM=3 - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE=$SHORT_TEST_SUITE_ENCODER + - TEST_SUITE=$LONG_TEST_SUITE_ENCODER <<: *ivas-pytest-sanitizers-anchor ### jobs that test flt encoder -> fx decoder @@ -1397,7 +1397,7 @@ ivas-pytest-dec-usan: before_script: - CLANG_NUM=3 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE=$SHORT_TEST_SUITE + - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER <<: *ivas-pytest-sanitizers-anchor # --------------------------------------------------------------- -- GitLab From 629b1639d0b5383c62d8f0b35352ba1ca19f898a Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 11 Mar 2025 12:42:14 +1100 Subject: [PATCH 292/329] Q filter state per pose --- lib_dec/ivas_binRenderer_internal_fx.c | 2864 ++++++++++++------------ lib_rend/ivas_stat_rend.h | 2 +- 2 files changed, 1442 insertions(+), 1424 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c442e29f5..c561ea3df 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -79,10 +79,17 @@ static void ivas_binRenderer_filterModule_fx( #endif /* OPT_BASOP_ADD_v1 */ const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; Word16 shift_q; +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef OPT_BASOP_ADD_v1 + Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; + move16(); +#endif /* OPT_BASOP_ADD_v1 */ +#else #ifdef OPT_BASOP_ADD_v1 Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; move16(); #endif /* OPT_BASOP_ADD_v1 */ +#endif FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -162,279 +169,288 @@ static void ivas_binRenderer_filterModule_fx( outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr #ifdef OPT_BASOP_ADD_v1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; +#else hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; +#endif move16(); } #endif /* OPT_BASOP_ADD_v1 */ - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); #ifndef OPT_BASOP_ADD_v1 - Q_filterStates[0] = Q_curr; - move16(); + Q_filterStates[0] = Q_curr; + move16(); #endif /* OPT_BASOP_ADD_v1 */ - /* Left Real and Imag */ - // Q29 + Q_curr + /* Left Real and Imag */ + // Q29 + Q_curr - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 - move64(); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); + out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 + move64(); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 - move64(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 + move64(); - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 - move64(); + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 + move64(); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 - move64(); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 + move64(); + } } } - } - return; -} + return; + } -/*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ -static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, + /*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ + static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, #ifdef SPLIT_REND_WITH_HEAD_ROT - const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses #else const HRTFS_FASTCONV_HANDLE hHrtf #endif -) -{ - Word16 bandIdx, chIdx; + ) + { + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx; + Word16 pos_idx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ - - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( !isLoudspeaker ) - { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); - move16(); - } - ELSE - { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); - move16(); - } + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; - move16(); + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - /* Use variable order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( ; bandIdx < 20; bandIdx++ ) + + IF( !isLoudspeaker ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + hBinRenderer->nInChannels = audioCfg2channels( input_config ); move16(); } - FOR( ; bandIdx < 30; bandIdx++ ) + ELSE { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); move16(); } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; move16(); - } - } - ELSE - { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + + /* Use variable order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < 5; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } + FOR( ; bandIdx < 10; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; + move16(); + } + FOR( ; bandIdx < 20; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + move16(); + } + FOR( ; bandIdx < 30; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + move16(); + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } } ELSE { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + move16(); + } + ELSE + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS; + move16(); + } - /* Use fixed order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + /* Use fixed order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } } - } - - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) +#ifdef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#else + IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ + + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + +#ifndef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#endif /* OPT_BASOP_ADD_v1 */ + } } } - } #else IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) @@ -494,960 +510,962 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } #endif - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - Word16 tmp = 0; - move16(); - - IF( isLoudspeaker ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + Word16 tmp = 0; + move16(); + + IF( isLoudspeaker ) { - tmp = channelIndex_CICP19[chIdx]; - move16(); + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) + { + tmp = channelIndex_CICP6[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) + { + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + { + tmp = channelIndex_CICP19[chIdx]; + move16(); + } } - } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - /* set the memories to zero */ + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + /* set the memories to zero */ #ifndef SPLIT_REND_WITH_HEAD_ROT - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* !SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + IF( isLoudspeaker ) + { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + } } - } - ELSE - { + ELSE + { #ifndef SPLIT_REND_WITH_HEAD_ROT - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; - } - ELSE - { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + IF( isLoudspeaker ) { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; } ELSE { - return IVAS_ERR_INVALID_INPUT_FORMAT; + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } } } - } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); -#else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); +#endif + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); +#ifndef OPT_BASOP_ADD_v1 + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ + } } } } - } - ELSE - { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + ELSE { - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); -#else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); -#endif /* OPT_BASOP_ADD_v1 */ - } + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); +#endif + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); +#ifndef OPT_BASOP_ADD_v1 + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif /* OPT_BASOP_ADD_v1 */ + } + } } } - } #endif - hBinRenderer->hBinRenConvModule = hBinRenConvModule; - - return IVAS_ERR_OK; -} + hBinRenderer->hBinRenConvModule = hBinRenConvModule; -/*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ -void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ -) -{ - Word16 i; - - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); - - HrtfFastConv->allocate_init_flag = 0; - move16(); + return IVAS_ERR_OK; + } - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + /*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ + void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ + ) { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + Word16 i; + + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; move32(); - } - return; -} + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); -/*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ -static ivas_error ivas_alloc_pppMem_fx( - Word32 ****pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) -{ - Word16 i, j; - Word32 ***localMem = NULL; + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; + move32(); - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; + move32(); + + HrtfFastConv->allocate_init_flag = 0; + move16(); + + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + move32(); + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + move32(); + } + + return; } - for ( i = 0; i < dim1; i++ ) + /*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ + static ivas_error ivas_alloc_pppMem_fx( + Word32 * ***pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) { - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) + Word16 i, j; + Word32 ***localMem = NULL; + + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - IF( allocate_init_flag == 0 ) + + for ( i = 0; i < dim1; i++ ) { - FOR( j = 0; j < dim2; j++ ) + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } + IF( allocate_init_flag == 0 ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + FOR( j = 0; j < dim2; j++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } } } } - } - *pppMem = localMem; + *pppMem = localMem; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*-------------------------------------------------------------------------* - * ivas_allocate_binaural_hrtf() - * - * Allocate memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ -ivas_error ivas_allocate_binaural_hrtf_fx( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ - const AUDIO_CONFIG input_config, /* i : input audio configuration */ - const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const Word16 allocate_init_flag /* i : Memory allocation flag */ -) -{ - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) + /*-------------------------------------------------------------------------* + * ivas_allocate_binaural_hrtf() + * + * Allocate memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ + ivas_error ivas_allocate_binaural_hrtf_fx( + HRTFS_FASTCONV * HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + const AUDIO_CONFIG input_config, /* i : input audio configuration */ + const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const Word16 allocate_init_flag /* i : Memory allocation flag */ + ) { test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); + } } } - } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) - { - test(); test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); + } } } - } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) - { - test(); test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); + } } } - } - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) - { - test(); test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); + } } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + } + + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + { + test(); + test(); + test(); + IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); + } } } + + return IVAS_ERR_OK; } - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + /*-------------------------------------------------------------------------* + * ivas_binaural_HRTF_open() + * + * + *-------------------------------------------------------------------------*/ + static ivas_error ivas_binaural_hrtf_open_fx( + HRTFS_FASTCONV_HANDLE * hHrtfFastConv, /* i : fastconv HRTF handle */ + const AUDIO_CONFIG input_config, /* i : output configuration */ + const RENDERER_TYPE renderer_type /* i : renderer type */ + ) { + Word16 i, j; + ivas_error error; + test(); - test(); - test(); - IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) + IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) { + /* Tables already loaded from file */ return IVAS_ERR_OK; } ELSE { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + /* Initialise tables from ROM */ + HRTFS_FASTCONV *HrtfFastConv; + + IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + + ivas_init_binaural_hrtf_fx( HrtfFastConv ); + + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; + move32(); } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; + move32(); } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; + move32(); + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; + move32(); } - } - } - - return IVAS_ERR_OK; -} - -/*-------------------------------------------------------------------------* - * ivas_binaural_HRTF_open() - * - * - *-------------------------------------------------------------------------*/ -static ivas_error ivas_binaural_hrtf_open_fx( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ - const AUDIO_CONFIG input_config, /* i : output configuration */ - const RENDERER_TYPE renderer_type /* i : renderer type */ -) -{ - Word16 i, j; - ivas_error error; - - test(); - IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) - { - /* Tables already loaded from file */ - return IVAS_ERR_OK; - } - ELSE - { - /* Initialise tables from ROM */ - HRTFS_FASTCONV *HrtfFastConv; - - IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); - } - - ivas_init_binaural_hrtf_fx( HrtfFastConv ); - - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) - { - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; - move32(); - } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; - move32(); - } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; - move32(); - } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; - move32(); - } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; - move32(); - } - HrtfFastConv->allocate_init_flag = 1; - move16(); + HrtfFastConv->allocate_init_flag = 1; + move16(); - IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) - { - return error; - } - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; - HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; - HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; - HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; - } + return error; } - ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; - HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; - HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; - HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; + HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; + HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; + HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; + } } - } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - FOR( j = 0; j < HOA3_CHANNELS; j++ ) + ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) + { + HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; + HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; + HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; + HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; + } } - } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - FOR( j = 0; j < HOA2_CHANNELS; j++ ) + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { - HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; + FOR( j = 0; j < HOA3_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; + } } - } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - FOR( j = 0; j < FOA_CHANNELS; j++ ) + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + FOR( j = 0; j < HOA2_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; + } + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) { - HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; - HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; - HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; - HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; + FOR( j = 0; j < FOA_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; + HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; + HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; + HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; + } } } + Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); + Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); + + *hHrtfFastConv = HrtfFastConv; } - Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); - Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - *hHrtfFastConv = HrtfFastConv; + return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* + * ivas_binaural_obtain_DMX_fx() + * + * + *-------------------------------------------------------------------------*/ - return IVAS_ERR_OK; -} -/*-------------------------------------------------------------------------* - * ivas_binaural_obtain_DMX_fx() - * - * - *-------------------------------------------------------------------------*/ - -static void ivas_binaural_obtain_DMX_fx( - const Word16 numTimeSlots, - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ - Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ -{ - Word16 chIdx, bandIdx, k; - - test(); - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + static void ivas_binaural_obtain_DMX_fx( + const Word16 numTimeSlots, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ + Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ { - /* Obtain the downmix */ - Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 P_out_fx, factEQ_fx; - Word16 chOutIdx; - Word32 temp1_fx, temp2_fx; + Word16 chIdx, bandIdx, k; - FOR( k = 0; k < numTimeSlots; k++ ) + test(); + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) { - FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + /* Obtain the downmix */ + Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 P_out_fx, factEQ_fx; + Word16 chOutIdx; + Word32 temp1_fx, temp2_fx; + + FOR( k = 0; k < numTimeSlots; k++ ) { - set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + { + set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } - } - - FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) - { - set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { - Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; - move32(); + set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in - move32(); - imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in - move32(); + Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; + move32(); - P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - move32(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in + move32(); + imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in + move32(); + + P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in + move32(); + } } } - } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - P_out_fx = 0; - move32(); - FOR( k = 0; k < numTimeSlots; k++ ) - { - temp1_fx = realDMX[chOutIdx][k][bandIdx]; - move32(); - temp2_fx = imagDMX[chOutIdx][k][bandIdx]; - move32(); - P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - } - test(); - IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) - { - factEQ_fx = 0x40000000; // 1.0f in Q30 - move32(); - } - ELSE - { - Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); - Word16 exp = norm_l( div ); - factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); - factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 - } - if ( factEQ_fx <= 0 ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - factEQ_fx = 0x40000000; // 1.0f in Q30 + P_out_fx = 0; move32(); - } + FOR( k = 0; k < numTimeSlots; k++ ) + { + temp1_fx = realDMX[chOutIdx][k][bandIdx]; + move32(); + temp2_fx = imagDMX[chOutIdx][k][bandIdx]; + move32(); + P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in + } + test(); + IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } + ELSE + { + Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); + Word16 exp = norm_l( div ); + factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); + factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 + } + if ( factEQ_fx <= 0 ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } - factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 - FOR( k = 0; k < numTimeSlots; k++ ) - { - realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); - imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); + factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 + FOR( k = 0; k < numTimeSlots; k++ ) + { + realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); + imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); + } } } } - } - ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) - { - Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; - Word32 *inRealPtr_fx, *inImagPtr_fx; - - /*compute DMX */ - FOR( k = 0; k < numTimeSlots; k++ ) + ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) { - outRealLeftPtr_fx = realDMX[0][k]; - outImagLeftPtr_fx = imagDMX[0][k]; - outRealRightPtr_fx = realDMX[1][k]; - outImagRightPtr_fx = imagDMX[1][k]; - set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; + Word32 *inRealPtr_fx, *inImagPtr_fx; - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + /*compute DMX */ + FOR( k = 0; k < numTimeSlots; k++ ) { - Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - - inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); - inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + outRealLeftPtr_fx = realDMX[0][k]; + outImagLeftPtr_fx = imagDMX[0][k]; + outRealRightPtr_fx = realDMX[1][k]; + outImagRightPtr_fx = imagDMX[1][k]; + set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); + Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); + inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); + inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + + outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + } } } } - } - return; -} + return; + } #ifdef SPLIT_REND_WITH_HEAD_ROT -/*------------------------------------------------------------------------- - * ivas_rend_openCldfbRend() - * - * Allocate and initialize CLDFB fast conv renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_rend_openCldfbRend( - CLDFB_REND_WRAPPER *pCldfbRend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs ) -{ - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand; - ivas_error error; - - error = IVAS_ERR_OK; + /*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Allocate and initialize CLDFB fast conv renderer handle + *------------------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ - - if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER * pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand; + ivas_error error; - if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); - } + error = IVAS_ERR_OK; - hBinRenderer->rotInCldfb = 1; - hBinRenderer->ivas_format = SBA_FORMAT; + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); + if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - convBand = hBinRenderer->max_band; - move16(); + if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); + } - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ - move16(); + hBinRenderer->rotInCldfb = 1; + hBinRenderer->ivas_format = SBA_FORMAT; - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; - move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); move16(); - } - hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; - hBinRenderer->hInputSetup->output_config = inConfig; - IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) - { - return error; - } + convBand = hBinRenderer->max_band; + move16(); - IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = pMultiBinPoseData->num_poses; + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ move16(); - } - ELSE - { - hBinRenderer->numPoses = 1; + + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; + move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } + + hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; + hBinRenderer->hInputSetup->output_config = inConfig; + IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = pMultiBinPoseData->num_poses; + move16(); + } + ELSE + { + hBinRenderer->numPoses = 1; + move16(); + } + + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; move16(); - } - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; - move16(); + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Allocate memories and buffers needed for convolutional module in CICP19 */ + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } + + pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); + move32(); + hBinRenderer->hReverb = NULL; + move32(); + hBinRenderer->hEFAPdata = NULL; + move32(); + pCldfbRend->hCldfbRend = hBinRenderer; + move32(); - /* Allocate memories and buffers needed for convolutional module in CICP19 */ - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { return error; } - - pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); - move32(); - hBinRenderer->hReverb = NULL; - move32(); - hBinRenderer->hEFAPdata = NULL; - move32(); - pCldfbRend->hCldfbRend = hBinRenderer; - move32(); - - return error; -} #endif -/*------------------------------------------------------------------------- - * ivas_binRenderer_open() - * - * Open fastconv binaural renderer handle - *-------------------------------------------------------------------------*/ -ivas_error ivas_binRenderer_open_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand, chIdx, k; - ivas_error error; + /*------------------------------------------------------------------------- + * ivas_binRenderer_open() + * + * Open fastconv binaural renderer handle + *-------------------------------------------------------------------------*/ + ivas_error ivas_binRenderer_open_fx( + Decoder_Struct * st_ivas /* i/o: IVAS decoder structure */ + ) + { + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand, chIdx, k; + ivas_error error; - error = IVAS_ERR_OK; - move32(); + error = IVAS_ERR_OK; + move32(); - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - hBinRenderer->hInputSetup = &st_ivas->hIntSetup; + hBinRenderer->hInputSetup = &st_ivas->hIntSetup; - /* Define of head rotation has to be done in binRendeder in CLDFB*/ - hBinRenderer->rotInCldfb = 0; - move16(); - test(); - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - hBinRenderer->rotInCldfb = 1; + /* Define of head rotation has to be done in binRendeder in CLDFB*/ + hBinRenderer->rotInCldfb = 0; move16(); - } + test(); + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + hBinRenderer->rotInCldfb = 1; + move16(); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; - move16(); - } - else - { - hBinRenderer->numPoses = 1; - move16(); - } + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } + else + { + hBinRenderer->numPoses = 1; + move16(); + } #endif - /* Declare some common variables needed for renderer */ - /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ - IF( st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->ivas_format = MC_FORMAT; - move32(); - } - ELSE - { - hBinRenderer->ivas_format = SBA_FORMAT; - move32(); - } - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); - - convBand = hBinRenderer->max_band; - move16(); - - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ - move16(); + /* Declare some common variables needed for renderer */ + /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ + IF( st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->ivas_format = MC_FORMAT; + move32(); + } + ELSE + { + hBinRenderer->ivas_format = SBA_FORMAT; + move32(); + } + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; + convBand = hBinRenderer->max_band; move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; + + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ move16(); - } - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; - move16(); + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; + move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } - test(); - if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->render_lfe = 1; + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; move16(); - } - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) - { - return error; - } - - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) - { - IVAS_OUTPUT_SETUP out_setup; + test(); + if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->render_lfe = 1; + move16(); + } - /* Allocate memories and buffers needed for convolutional module in CICP19 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) { return error; } + + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) + { + IVAS_OUTPUT_SETUP out_setup; + + /* Allocate memories and buffers needed for convolutional module in CICP19 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { return error; } #endif - ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); + ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); - IF( st_ivas->hoa_dec_mtx == NULL ) - { - IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) + IF( st_ivas->hoa_dec_mtx == NULL ) { - return error; + IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) + { + return error; + } } - } - hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - ELSE - { - /* Allocate memories and buffers needed for convolutional module */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { - return error; + hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; + move32(); } + ELSE + { + /* Allocate memories and buffers needed for convolutional module */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { @@ -1455,196 +1473,196 @@ ivas_error ivas_binRenderer_open_fx( } #endif - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) - { - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; - move32(); - } - ELSE - { - IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; move32(); } ELSE { - return IVAS_ERR_INVALID_INPUT_FORMAT; + IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; + move32(); + } + ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; + move32(); + } + ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; + move32(); + } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } - } - ELSE - { - /* same value for MC or HOA both use MC BRIR*/ - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - } - - /* Allocate memories needed for reverb module */ - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* initialize the dmx matrix */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) + ELSE { - hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + /* same value for MC or HOA both use MC BRIR*/ + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; move32(); } } - } - ELSE - { - hBinRenderer->hReverb = NULL; - } - hBinRenderer->hEFAPdata = NULL; - - IF( hBinRenderer->hReverb != NULL ) - { + /* Allocate memories needed for reverb module */ test(); - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - FOR( k = 0; k < 11; k++ ) + IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { - ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); - // Q29: hBinRenderer->hReverb->foa_enc_fx[k] + return error; } + + /* initialize the dmx matrix */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) + { + hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + move32(); + } + } + } + ELSE + { + hBinRenderer->hReverb = NULL; } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + + hBinRenderer->hEFAPdata = NULL; + + IF( hBinRenderer->hReverb != NULL ) { - IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) + test(); + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { - return error; + FOR( k = 0; k < 11; k++ ) + { + ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); + // Q29: hBinRenderer->hReverb->foa_enc_fx[k] + } } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { + IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* Copy handles to bin renderer handle*/ - hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + /* Copy handles to bin renderer handle*/ + hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + } } - } - /* Copy the handles to main handle */ - st_ivas->hBinRenderer = hBinRenderer; + /* Copy the handles to main handle */ + st_ivas->hBinRenderer = hBinRenderer; - return error; -} + return error; + } -/*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleClose() - * - * Close convolution module handle of fastconv binaural renderer - *------------------------------------------------------------------------*/ -static void ivas_binRenderer_convModuleClose_fx( + /*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleClose() + * + * Close convolution module handle of fastconv binaural renderer + *------------------------------------------------------------------------*/ + static void ivas_binRenderer_convModuleClose_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT - BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ - const Word16 num_poses /* i : number of poses */ + BINAURAL_RENDERER_HANDLE * hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 num_poses /* i : number of poses */ #else BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ #endif -) -{ - Word16 bandIdx, chIdx; + ) + { + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 posIdx; + Word16 posIdx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; + hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; - IF( hBinRenConvModule == NULL ) - { - return; - } + IF( hBinRenConvModule == NULL ) + { + return; + } - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) - { - free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + { + free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; - } + free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; + } - free( hBinRenConvModule->filterTapsLeftReal_fx ); - hBinRenConvModule->filterTapsLeftReal_fx = NULL; + free( hBinRenConvModule->filterTapsLeftReal_fx ); + hBinRenConvModule->filterTapsLeftReal_fx = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx ); - hBinRenConvModule->filterTapsLeftImag_fx = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx ); + hBinRenConvModule->filterTapsLeftImag_fx = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx ); - hBinRenConvModule->filterTapsRightReal_fx = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx ); + hBinRenConvModule->filterTapsRightReal_fx = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx ); - hBinRenConvModule->filterTapsRightImag_fx = NULL; + free( hBinRenConvModule->filterTapsRightImag_fx ); + hBinRenConvModule->filterTapsRightImag_fx = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) - { - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) { - FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; + FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + { + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; + } + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { @@ -1674,281 +1692,281 @@ static void ivas_binRenderer_convModuleClose_fx( #endif /* OPT_BASOP_ADD_v1 */ } #endif - free( hBinRenConvModule->filterStatesLeftReal_fx ); - hBinRenConvModule->filterStatesLeftReal_fx = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx ); + hBinRenConvModule->filterStatesLeftReal_fx = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx ); - hBinRenConvModule->filterStatesLeftImag_fx = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx ); + hBinRenConvModule->filterStatesLeftImag_fx = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft ); - hBinRenConvModule->Q_filterStatesLeft = NULL; + free( hBinRenConvModule->Q_filterStatesLeft ); + hBinRenConvModule->Q_filterStatesLeft = NULL; #endif /* OPT_BASOP_ADD_v1 */ - free( ( *hBinRenderer )->hBinRenConvModule ); - ( *hBinRenderer )->hBinRenConvModule = NULL; - - return; -} + free( ( *hBinRenderer )->hBinRenConvModule ); + ( *hBinRenderer )->hBinRenConvModule = NULL; -/*------------------------------------------------------------------------- - * ivas_binRenderer_close() - * - * Close fastconv binaural renderer memories - *------------------------------------------------------------------------*/ -void ivas_binRenderer_close_fx( - BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ -) -{ - test(); - IF( hBinRenderer == NULL || *hBinRenderer == NULL ) - { return; } - IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) + /*------------------------------------------------------------------------- + * ivas_binRenderer_close() + * + * Close fastconv binaural renderer memories + *------------------------------------------------------------------------*/ + void ivas_binRenderer_close_fx( + BINAURAL_RENDERER_HANDLE * hBinRenderer /* i/o: fastconv binaural renderer handle */ + ) { + test(); + IF( hBinRenderer == NULL || *hBinRenderer == NULL ) + { + return; + } + + IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); + ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); #else ivas_binRenderer_convModuleClose_fx( hBinRenderer ); #endif - } - - IF( ( *hBinRenderer )->hReverb != NULL ) - { - ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); - } + } - free( *hBinRenderer ); - *hBinRenderer = NULL; + IF( ( *hBinRenderer )->hReverb != NULL ) + { + ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); + } - return; -} + free( *hBinRenderer ); + *hBinRenderer = NULL; -/*------------------------------------------------------------------------- - * ivas_free_pppHrtfMem() - * - * Free fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ -static void ivas_free_pppHrtfMem_fx( - Word32 ****ppppHRIR, /*Qx*/ - const Word16 dim, - const Word16 alloc_init ) -{ - Word16 i, j; + return; + } - IF( *ppppHRIR != NULL ) + /*------------------------------------------------------------------------- + * ivas_free_pppHrtfMem() + * + * Free fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ + static void ivas_free_pppHrtfMem_fx( + Word32 * ***ppppHRIR, /*Qx*/ + const Word16 dim, + const Word16 alloc_init ) { - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + Word16 i, j; + + IF( *ppppHRIR != NULL ) { - IF( alloc_init == 0 ) + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - FOR( j = 0; j < dim; j++ ) + IF( alloc_init == 0 ) { - free( ( *ppppHRIR )[i][j] ); - ( *ppppHRIR )[i][j] = NULL; + FOR( j = 0; j < dim; j++ ) + { + free( ( *ppppHRIR )[i][j] ); + ( *ppppHRIR )[i][j] = NULL; + } } + free( ( *ppppHRIR )[i] ); + ( *ppppHRIR )[i] = NULL; } - free( ( *ppppHRIR )[i] ); - ( *ppppHRIR )[i] = NULL; + free( *ppppHRIR ); + *ppppHRIR = NULL; } - free( *ppppHRIR ); - *ppppHRIR = NULL; - } - - return; -} - -/*------------------------------------------------------------------------- - * ivas_binaural_hrtf_close() - * - * Close fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ -void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i : fastconv HRTF handle */ -) -{ - Word16 allocate_init_flag; - test(); - IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) - { return; } - allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; - move16(); + /*------------------------------------------------------------------------- + * ivas_binaural_hrtf_close() + * + * Close fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ + void ivas_binaural_hrtf_close( + HRTFS_FASTCONV_HANDLE * hHrtfFastConv /* i : fastconv HRTF handle */ + ) + { + Word16 allocate_init_flag; - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + test(); + IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) + { + return; + } - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; + move16(); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - return; -} + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); -/*-------------------------------------------------------------------------* - * ivas_binaural_add_LFE() - * - * The functions adds the LFE to the left and right channels after binaural rendering - *-------------------------------------------------------------------------*/ -void ivas_binaural_add_LFE_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word16 output_frame, /* i : length of input frame */ - Word32 *input_fx[], /* i : transport channels Q11*/ - Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ -) -{ - Word16 render_lfe, idx_lfe, gain_fx; - Word32 lfe_tc[L_FRAME48k]; + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - IF( st_ivas->hBinRenderer != NULL ) - { - render_lfe = st_ivas->hBinRenderer->render_lfe; - move16(); - } - ELSE - { - render_lfe = TRUE; - move16(); + return; } - - IF( render_lfe ) + /*-------------------------------------------------------------------------* + * ivas_binaural_add_LFE() + * + * The functions adds the LFE to the left and right channels after binaural rendering + *-------------------------------------------------------------------------*/ + void ivas_binaural_add_LFE_fx( + Decoder_Struct * st_ivas, /* i/o: IVAS decoder structure */ + Word16 output_frame, /* i : length of input frame */ + Word32 * input_fx[], /* i : transport channels Q11*/ + Word32 * output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ + ) { - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) + Word16 render_lfe, idx_lfe, gain_fx; + Word32 lfe_tc[L_FRAME48k]; + + IF( st_ivas->hBinRenderer != NULL ) { - gain_fx = GAIN_LFE_FX; + render_lfe = st_ivas->hBinRenderer->render_lfe; move16(); } ELSE { - test(); - IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) + render_lfe = TRUE; + move16(); + } + + + IF( render_lfe ) + { + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; + gain_fx = GAIN_LFE_FX; move16(); } ELSE { - gain_fx = GAIN_LFE_FX; - move16(); + test(); + IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) + { + gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; + move16(); + } + ELSE + { + gain_fx = GAIN_LFE_FX; + move16(); + } } - } - FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) - { - v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 - /* copy LFE to left and right channels */ - FOR( int idx = 0; idx < output_frame; idx++ ) + FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { - lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q - move32(); - output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); - move32(); - output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); - move32(); + v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 + /* copy LFE to left and right channels */ + FOR( int idx = 0; idx < output_frame; idx++ ) + { + lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q + move32(); + output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); + move32(); + output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); + move32(); + } } } - } - return; -} + return; + } -/*------------------------------------------------------------------------- - * ivas_binRenderer_fx() - * - * Fastconv binaural renderer main function - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * ivas_binRenderer_fx() + * + * Fastconv binaural renderer main function + *-------------------------------------------------------------------------*/ -void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + void ivas_binRenderer_fx( + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT - Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ - Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ #else Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ -) -{ - Word16 chIdx, i, j, k; + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ + ) + { + Word16 chIdx, i, j, k; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx, num_poses; - Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 pos_idx, num_poses; + Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #endif - // to be checked: feasibility with 32 bit buffers - Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + // to be checked: feasibility with 32 bit buffers + Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - push_wmops( "fastconv_binaural_rendering" ); + push_wmops( "fastconv_binaural_rendering" ); #ifdef SPLIT_REND_WITH_HEAD_ROT - num_poses = hBinRenderer->numPoses; + num_poses = hBinRenderer->numPoses; #endif - /* Compute Convolution */ - /* memory reset for the binaural output */ + /* Compute Convolution */ + /* memory reset for the binaural output */ #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } } - } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } - } - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { - Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } } - } #else FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { @@ -1962,301 +1980,301 @@ void ivas_binRenderer_fx( } #endif - /* Head rotation in HOA3 or CICPx */ - test(); - test(); - IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) - { - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + /* Head rotation in HOA3 or CICPx */ + test(); + test(); + IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) { - /* Rotation in SHD (HOA3) */ - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); + /* Rotation in SHD (HOA3) */ + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); + } + ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); + } } - ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) + ELSE { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); + /* Rotation in SD (CICPx) */ + rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } } - ELSE + + /* HOA decoding to CICP19 if needed*/ + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) { - /* Rotation in SD (CICPx) */ - rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } - } - - /* HOA decoding to CICP19 if needed*/ - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) - { - ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); - } #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); #else ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); #endif - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); + Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); #else Cldfb_RealBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); Cldfb_ImagBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); #endif + } } } - } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( pMultiBinPoseData != NULL ) - { - IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) + IF( pMultiBinPoseData != NULL ) { - IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; - Word32 Rmat_local[3][3]; - Word16 q_fact_orig, extra_shift = 0; - - IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) + IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { - Quaternions_ref = hCombinedOrientationData->Quaternions[0]; - q_fact_orig = Quaternions_ref.q_fact; - - modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; + Word32 Rmat_local[3][3]; + Word16 q_fact_orig, extra_shift = 0; - Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) + IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) { - /*HOA signal already rotated by DirAC*/ - Quaternions_ref2.x_fx = 0; - Quaternions_ref2.y_fx = 0; - Quaternions_ref2.z_fx = 0; - extra_shift = 1; - } - ELSE - { - /*euler*/ - Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ - } + Quaternions_ref = hCombinedOrientationData->Quaternions[0]; + q_fact_orig = Quaternions_ref.q_fact; - FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + + Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) { - FOR( k = 0; k < numTimeSlots; k++ ) + /*HOA signal already rotated by DirAC*/ + Quaternions_ref2.x_fx = 0; + Quaternions_ref2.y_fx = 0; + Quaternions_ref2.z_fx = 0; + extra_shift = 1; + } + ELSE + { + /*euler*/ + Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + } + + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { - Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } } - } - Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); - Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); - Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); - Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 - Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); - modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); - QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + QuatToRotMat_fx( Quaternions_abs, Rmat_local ); - modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) - { - rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); - } - else - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - } + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + { + rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + else + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } - } - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); + } } } } } } } - } #endif - /* Obtain the binaural dmx and compute the reverb */ - IF( hBinRenderer->hReverb != NULL ) - { - Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* Obtain the binaural dmx and compute the reverb */ + IF( hBinRenderer->hReverb != NULL ) + { + Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); + ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); - set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); + set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); + } } - } - ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); + ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < numTimeSlots; j++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) + FOR( j = 0; j < numTimeSlots; j++ ) { - reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in - move32(); - reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in - move32(); + FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) + { + reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in + move32(); + reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in + move32(); + } } } - } - /* Add the conv module and reverb module output */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + /* Add the conv module and reverb module output */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + FOR( k = 0; k < numTimeSlots; k++ ) { - /* Combine first and second parts to generate binaural output signal with room effect */ - v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + /* Combine first and second parts to generate binaural output signal with room effect */ + v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + } #else /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in v_add_32( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in #endif + } } } + pop_wmops(); + return; } - pop_wmops(); - return; -} #ifdef SPLIT_REND_WITH_HEAD_ROT -/*------------------------------------------------------------------------- - * ivas_rend_CldfbMultiBinRendProcess() - * - * - *-------------------------------------------------------------------------*/ - -void ivas_rend_CldfbMultiBinRendProcess( - const BINAURAL_RENDERER_HANDLE hCldfbRend, - const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word16 low_res_pre_rend_rot, - const Word16 num_subframes, - const Word16 Q_in /* i : LS signals exp */ -) -{ - int16_t slot_idx, ch_idx, idx, pose_idx, i, j; - int16_t sf_idx; - Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word16 Q_in_orig; - - FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) - { - Q_in_orig = Q_in; - move16(); - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) - { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) + /*------------------------------------------------------------------------- + * ivas_rend_CldfbMultiBinRendProcess() + * + * + *-------------------------------------------------------------------------*/ + + void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes, + const Word16 Q_in /* i : LS signals exp */ + ) + { + int16_t slot_idx, ch_idx, idx, pose_idx, i, j; + int16_t sf_idx; + Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_in_orig; + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + Q_in_orig = Q_in; + move16(); + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { - Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) + { + Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + } } - } - IF( ( *pCombinedOrientationData ) != NULL ) - { - IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) + IF( ( *pCombinedOrientationData ) != NULL ) { - Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); - - FOR( i = 0; i < 3; i++ ) + IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) { - FOR( j = 0; j < 3; j++ ) + Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); + + FOR( i = 0; i < 3; i++ ) { - ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; - move32(); + FOR( j = 0; j < 3; j++ ) + { + ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; + move32(); + } } } + ( *pCombinedOrientationData )->shd_rot_max_order = -1; + move16(); } - ( *pCombinedOrientationData )->shd_rot_max_order = -1; - move16(); - } - ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); + ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); - FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) - { - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { - Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + } } } } - } - return; -} + return; + } #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 993ad40b2..028afd9d7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -668,7 +668,7 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx Word32 ****filterStatesLeftReal_fx; Word32 ****filterStatesLeftImag_fx; #ifdef OPT_BASOP_ADD_v1 - Word16 Q_filterStatesLeft; + Word16 *Q_filterStates; #else Word16 ****Q_filterStatesLeft; #endif -- GitLab From 4cc0b0dda1afad6c2cc9373fc5eab7c3d86352a3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 11 Mar 2025 12:45:04 +1100 Subject: [PATCH 293/329] clang formatting fix --- lib_dec/ivas_binRenderer_internal_fx.c | 2848 ++++++++++++------------ 1 file changed, 1424 insertions(+), 1424 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c561ea3df..fa7db4593 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -178,279 +178,279 @@ static void ivas_binRenderer_filterModule_fx( } #endif /* OPT_BASOP_ADD_v1 */ - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); #ifndef OPT_BASOP_ADD_v1 - Q_filterStates[0] = Q_curr; - move16(); + Q_filterStates[0] = Q_curr; + move16(); #endif /* OPT_BASOP_ADD_v1 */ - /* Left Real and Imag */ - // Q29 + Q_curr + /* Left Real and Imag */ + // Q29 + Q_curr - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 - move64(); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); + out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 + move64(); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 - move64(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 + move64(); - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 - move64(); + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 + move64(); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 - move64(); - } + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 + move64(); } } - - return; } - /*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ - static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, + return; +} + +/*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ +static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, #ifdef SPLIT_REND_WITH_HEAD_ROT - const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses #else const HRTFS_FASTCONV_HANDLE hHrtf #endif - ) - { - Word16 bandIdx, chIdx; +) +{ + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx; + Word16 pos_idx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( !isLoudspeaker ) + { + hBinRenderer->nInChannels = audioCfg2channels( input_config ); + move16(); + } + ELSE + { + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); + move16(); + } - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; + move16(); - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + /* Use variable order filtering */ + bandIdx = 0; + move16(); + FOR( ; bandIdx < 5; bandIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); } - - IF( !isLoudspeaker ) + FOR( ; bandIdx < 10; bandIdx++ ) { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; move16(); } - ELSE + FOR( ; bandIdx < 20; bandIdx++ ) { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; move16(); } - - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + FOR( ; bandIdx < 30; bandIdx++ ) { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; move16(); - - /* Use variable order filtering */ - bandIdx = 0; + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } + } + ELSE + { + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); - } - FOR( ; bandIdx < 20; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; - move16(); - } - FOR( ; bandIdx < 30; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; - move16(); - } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; - move16(); - } } ELSE { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; - move16(); - } - ELSE - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } - - /* Use fixed order filtering */ - bandIdx = 0; + hBinRenConvModule->numTaps = BINAURAL_NTAPS; move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } } - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + /* Use fixed order filtering */ + bandIdx = 0; + move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); } + } + + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - } +#ifdef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#else + IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#endif /* OPT_BASOP_ADD_v1 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifdef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#else - IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) +#ifndef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ - } } } + } #else IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) @@ -510,962 +510,962 @@ static void ivas_binRenderer_filterModule_fx( } } #endif - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word16 tmp = 0; - move16(); + Word16 tmp = 0; + move16(); - IF( isLoudspeaker ) + IF( isLoudspeaker ) + { + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) - { - tmp = channelIndex_CICP19[chIdx]; - move16(); - } + tmp = channelIndex_CICP6[chIdx]; + move16(); } - - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) { - /* set the memories to zero */ + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + { + tmp = channelIndex_CICP19[chIdx]; + move16(); + } + } + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + /* set the memories to zero */ #ifndef SPLIT_REND_WITH_HEAD_ROT - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* !SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; - } - } - ELSE + IF( isLoudspeaker ) { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + } + } + ELSE + { #ifndef SPLIT_REND_WITH_HEAD_ROT - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) + IF( isLoudspeaker ) + { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; + } + ELSE + { + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; } ELSE { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; - } - ELSE - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } + return IVAS_ERR_INVALID_INPUT_FORMAT; } } } } + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); #endif - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifndef OPT_BASOP_ADD_v1 - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ - } } } } - ELSE + } + ELSE + { + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); #endif - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifndef OPT_BASOP_ADD_v1 - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ - } } } } + } #endif - hBinRenderer->hBinRenConvModule = hBinRenConvModule; + hBinRenderer->hBinRenConvModule = hBinRenConvModule; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ - void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ - ) - { - Word16 i; +/*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ +void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ +) +{ + Word16 i; + + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; + move32(); + + HrtfFastConv->allocate_init_flag = 0; + move16(); - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; move32(); - - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; move32(); + } - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); - - HrtfFastConv->allocate_init_flag = 0; - move16(); + return; +} - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; - move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; - move32(); - } +/*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ +static ivas_error ivas_alloc_pppMem_fx( + Word32 ****pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) +{ + Word16 i, j; + Word32 ***localMem = NULL; - return; + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - /*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ - static ivas_error ivas_alloc_pppMem_fx( - Word32 * ***pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) + for ( i = 0; i < dim1; i++ ) { - Word16 i, j; - Word32 ***localMem = NULL; - - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - - for ( i = 0; i < dim1; i++ ) + IF( allocate_init_flag == 0 ) { - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } - IF( allocate_init_flag == 0 ) + FOR( j = 0; j < dim2; j++ ) { - FOR( j = 0; j < dim2; j++ ) + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } } } + } - *pppMem = localMem; + *pppMem = localMem; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*-------------------------------------------------------------------------* - * ivas_allocate_binaural_hrtf() - * - * Allocate memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ - ivas_error ivas_allocate_binaural_hrtf_fx( - HRTFS_FASTCONV * HrtfFastConv, /* i/o: FASTCONV HRTF structure */ - const AUDIO_CONFIG input_config, /* i : input audio configuration */ - const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const Word16 allocate_init_flag /* i : Memory allocation flag */ - ) +/*-------------------------------------------------------------------------* + * ivas_allocate_binaural_hrtf() + * + * Allocate memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ +ivas_error ivas_allocate_binaural_hrtf_fx( + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + const AUDIO_CONFIG input_config, /* i : input audio configuration */ + const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const Word16 allocate_init_flag /* i : Memory allocation flag */ +) +{ + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) { test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); } - } - - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) - { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); } } + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) + { test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); } - } - - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) - { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); } } + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) + { test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); } } - - return IVAS_ERR_OK; } - /*-------------------------------------------------------------------------* - * ivas_binaural_HRTF_open() - * - * - *-------------------------------------------------------------------------*/ - static ivas_error ivas_binaural_hrtf_open_fx( - HRTFS_FASTCONV_HANDLE * hHrtfFastConv, /* i : fastconv HRTF handle */ - const AUDIO_CONFIG input_config, /* i : output configuration */ - const RENDERER_TYPE renderer_type /* i : renderer type */ - ) + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) { - Word16 i, j; - ivas_error error; - test(); - IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) { - /* Tables already loaded from file */ return IVAS_ERR_OK; } ELSE { - /* Initialise tables from ROM */ - HRTFS_FASTCONV *HrtfFastConv; - - IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); } - - ivas_init_binaural_hrtf_fx( HrtfFastConv ); - - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); + } + } + } + + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + { + test(); + test(); + test(); + IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) + { + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); } - - HrtfFastConv->allocate_init_flag = 1; - move16(); - - IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) { - return error; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); } - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + } + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------------* + * ivas_binaural_HRTF_open() + * + * + *-------------------------------------------------------------------------*/ +static ivas_error ivas_binaural_hrtf_open_fx( + HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ + const AUDIO_CONFIG input_config, /* i : output configuration */ + const RENDERER_TYPE renderer_type /* i : renderer type */ +) +{ + Word16 i, j; + ivas_error error; + + test(); + IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_OK; + } + ELSE + { + /* Initialise tables from ROM */ + HRTFS_FASTCONV *HrtfFastConv; + + IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); + } + + ivas_init_binaural_hrtf_fx( HrtfFastConv ); + + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + { + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; + move32(); + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; + move32(); + } + + HrtfFastConv->allocate_init_flag = 1; + move16(); + + IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) + { + return error; + } + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; - HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; - HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; - HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; + HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; + HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; + HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; } - ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + } + ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; - HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; - HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; - HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; - } + HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; + HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; + HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; + HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + FOR( j = 0; j < HOA3_CHANNELS; j++ ) { - FOR( j = 0; j < HOA3_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + FOR( j = 0; j < HOA2_CHANNELS; j++ ) { - FOR( j = 0; j < HOA2_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + FOR( j = 0; j < FOA_CHANNELS; j++ ) { - FOR( j = 0; j < FOA_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; - HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; - HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; - HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; + HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; + HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; + HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; } } - Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); - Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - - *hHrtfFastConv = HrtfFastConv; } + Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); + Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - return IVAS_ERR_OK; + *hHrtfFastConv = HrtfFastConv; } - /*-------------------------------------------------------------------------* - * ivas_binaural_obtain_DMX_fx() - * - * - *-------------------------------------------------------------------------*/ - static void ivas_binaural_obtain_DMX_fx( - const Word16 numTimeSlots, - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ - Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ - { - Word16 chIdx, bandIdx, k; + return IVAS_ERR_OK; +} +/*-------------------------------------------------------------------------* + * ivas_binaural_obtain_DMX_fx() + * + * + *-------------------------------------------------------------------------*/ - test(); - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) - { - /* Obtain the downmix */ - Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 P_out_fx, factEQ_fx; - Word16 chOutIdx; - Word32 temp1_fx, temp2_fx; +static void ivas_binaural_obtain_DMX_fx( + const Word16 numTimeSlots, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ + Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ +{ + Word16 chIdx, bandIdx, k; - FOR( k = 0; k < numTimeSlots; k++ ) - { - FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) - { - set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } - } + test(); + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + { + /* Obtain the downmix */ + Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 P_out_fx, factEQ_fx; + Word16 chOutIdx; + Word32 temp1_fx, temp2_fx; + FOR( k = 0; k < numTimeSlots; k++ ) + { FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { - set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); + set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; - move32(); + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + { + set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in - move32(); - imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in - move32(); - - P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - move32(); - } - } - } + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; + move32(); FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - P_out_fx = 0; - move32(); FOR( k = 0; k < numTimeSlots; k++ ) { - temp1_fx = realDMX[chOutIdx][k][bandIdx]; - move32(); - temp2_fx = imagDMX[chOutIdx][k][bandIdx]; + temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in move32(); - P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - } - test(); - IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) - { - factEQ_fx = 0x40000000; // 1.0f in Q30 + imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in move32(); - } - ELSE - { - Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); - Word16 exp = norm_l( div ); - factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); - factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 - } - if ( factEQ_fx <= 0 ) - { - factEQ_fx = 0x40000000; // 1.0f in Q30 + + P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in move32(); } + } + } - factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 - FOR( k = 0; k < numTimeSlots; k++ ) - { - realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); - imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); - } + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + P_out_fx = 0; + move32(); + FOR( k = 0; k < numTimeSlots; k++ ) + { + temp1_fx = realDMX[chOutIdx][k][bandIdx]; + move32(); + temp2_fx = imagDMX[chOutIdx][k][bandIdx]; + move32(); + P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in + } + test(); + IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } + ELSE + { + Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); + Word16 exp = norm_l( div ); + factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); + factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 + } + if ( factEQ_fx <= 0 ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } + + factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 + FOR( k = 0; k < numTimeSlots; k++ ) + { + realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); + imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); } } } - ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) + } + ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) + { + Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; + Word32 *inRealPtr_fx, *inImagPtr_fx; + + /*compute DMX */ + FOR( k = 0; k < numTimeSlots; k++ ) { - Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; - Word32 *inRealPtr_fx, *inImagPtr_fx; + outRealLeftPtr_fx = realDMX[0][k]; + outImagLeftPtr_fx = imagDMX[0][k]; + outRealRightPtr_fx = realDMX[1][k]; + outImagRightPtr_fx = imagDMX[1][k]; + set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - /*compute DMX */ - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - outRealLeftPtr_fx = realDMX[0][k]; - outImagLeftPtr_fx = imagDMX[0][k]; - outRealRightPtr_fx = realDMX[1][k]; - outImagRightPtr_fx = imagDMX[1][k]; - set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 + Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); - inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); + inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); - outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - } + outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); } } } - - return; } + return; +} + #ifdef SPLIT_REND_WITH_HEAD_ROT - /*------------------------------------------------------------------------- - * ivas_rend_openCldfbRend() - * - * Allocate and initialize CLDFB fast conv renderer handle - *------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Allocate and initialize CLDFB fast conv renderer handle + *------------------------------------------------------------------------*/ + +ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) +{ + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand; + ivas_error error; - ivas_error ivas_rend_openCldfbRend( - CLDFB_REND_WRAPPER * pCldfbRend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs ) - { - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand; - ivas_error error; + error = IVAS_ERR_OK; - error = IVAS_ERR_OK; + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); + } - if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); - } + hBinRenderer->rotInCldfb = 1; + hBinRenderer->ivas_format = SBA_FORMAT; - hBinRenderer->rotInCldfb = 1; - hBinRenderer->ivas_format = SBA_FORMAT; + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); + convBand = hBinRenderer->max_band; + move16(); - convBand = hBinRenderer->max_band; - move16(); + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + move16(); - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; - move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; - move16(); - } - - hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; - hBinRenderer->hInputSetup->output_config = inConfig; - IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = pMultiBinPoseData->num_poses; - move16(); - } - ELSE - { - hBinRenderer->numPoses = 1; - move16(); - } + hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; + hBinRenderer->hInputSetup->output_config = inConfig; + IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = pMultiBinPoseData->num_poses; move16(); + } + ELSE + { + hBinRenderer->numPoses = 1; + move16(); + } + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; + move16(); - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* Allocate memories and buffers needed for convolutional module in CICP19 */ - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { - return error; - } - pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); - move32(); - hBinRenderer->hReverb = NULL; - move32(); - hBinRenderer->hEFAPdata = NULL; - move32(); - pCldfbRend->hCldfbRend = hBinRenderer; - move32(); + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) + { + return error; + } + /* Allocate memories and buffers needed for convolutional module in CICP19 */ + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { return error; } + + pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); + move32(); + hBinRenderer->hReverb = NULL; + move32(); + hBinRenderer->hEFAPdata = NULL; + move32(); + pCldfbRend->hCldfbRend = hBinRenderer; + move32(); + + return error; +} #endif - /*------------------------------------------------------------------------- - * ivas_binRenderer_open() - * - * Open fastconv binaural renderer handle - *-------------------------------------------------------------------------*/ - ivas_error ivas_binRenderer_open_fx( - Decoder_Struct * st_ivas /* i/o: IVAS decoder structure */ - ) - { - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand, chIdx, k; - ivas_error error; +/*------------------------------------------------------------------------- + * ivas_binRenderer_open() + * + * Open fastconv binaural renderer handle + *-------------------------------------------------------------------------*/ +ivas_error ivas_binRenderer_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand, chIdx, k; + ivas_error error; - error = IVAS_ERR_OK; - move32(); + error = IVAS_ERR_OK; + move32(); - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - hBinRenderer->hInputSetup = &st_ivas->hIntSetup; + hBinRenderer->hInputSetup = &st_ivas->hIntSetup; - /* Define of head rotation has to be done in binRendeder in CLDFB*/ - hBinRenderer->rotInCldfb = 0; + /* Define of head rotation has to be done in binRendeder in CLDFB*/ + hBinRenderer->rotInCldfb = 0; + move16(); + test(); + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + hBinRenderer->rotInCldfb = 1; move16(); - test(); - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - hBinRenderer->rotInCldfb = 1; - move16(); - } + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; - move16(); - } - else - { - hBinRenderer->numPoses = 1; - move16(); - } + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } + else + { + hBinRenderer->numPoses = 1; + move16(); + } #endif - /* Declare some common variables needed for renderer */ - /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ - IF( st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->ivas_format = MC_FORMAT; - move32(); - } - ELSE - { - hBinRenderer->ivas_format = SBA_FORMAT; - move32(); - } - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); + /* Declare some common variables needed for renderer */ + /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ + IF( st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->ivas_format = MC_FORMAT; + move32(); + } + ELSE + { + hBinRenderer->ivas_format = SBA_FORMAT; + move32(); + } + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); - convBand = hBinRenderer->max_band; - move16(); + convBand = hBinRenderer->max_band; + move16(); - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + move16(); + + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; - move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; - move16(); - } + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; + move16(); - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; + test(); + if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->render_lfe = 1; move16(); + } - test(); - if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->render_lfe = 1; - move16(); - } + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) + { + return error; + } + + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) + { + IVAS_OUTPUT_SETUP out_setup; - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) + /* Allocate memories and buffers needed for convolutional module in CICP19 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) { return error; } - - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) - { - IVAS_OUTPUT_SETUP out_setup; - - /* Allocate memories and buffers needed for convolutional module in CICP19 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { - return error; - } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { return error; } #endif - ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); + ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); - IF( st_ivas->hoa_dec_mtx == NULL ) - { - IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - - hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - ELSE + IF( st_ivas->hoa_dec_mtx == NULL ) { - /* Allocate memories and buffers needed for convolutional module */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) { return error; } + } + + hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; + move32(); + } + ELSE + { + /* Allocate memories and buffers needed for convolutional module */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { @@ -1473,196 +1473,196 @@ static void ivas_binRenderer_filterModule_fx( } #endif - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + { + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; + move32(); + } + ELSE { - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; move32(); } - ELSE + ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) { - IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; - move32(); - } - ELSE - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; + move32(); } - } - ELSE - { - /* same value for MC or HOA both use MC BRIR*/ - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - } - - /* Allocate memories needed for reverb module */ - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* initialize the dmx matrix */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) + ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) { - hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; move32(); } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } ELSE { - hBinRenderer->hReverb = NULL; + /* same value for MC or HOA both use MC BRIR*/ + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; + move32(); } + } - hBinRenderer->hEFAPdata = NULL; + /* Allocate memories needed for reverb module */ + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) + { + return error; + } - IF( hBinRenderer->hReverb != NULL ) + /* initialize the dmx matrix */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - test(); - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) { - FOR( k = 0; k < 11; k++ ) - { - ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); - // Q29: hBinRenderer->hReverb->foa_enc_fx[k] - } + hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + move32(); } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) - { - IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) - { - return error; - } + } + } + ELSE + { + hBinRenderer->hReverb = NULL; + } + + hBinRenderer->hEFAPdata = NULL; - /* Copy handles to bin renderer handle*/ - hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + IF( hBinRenderer->hReverb != NULL ) + { + test(); + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + { + FOR( k = 0; k < 11; k++ ) + { + ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); + // Q29: hBinRenderer->hReverb->foa_enc_fx[k] } } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { + IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* Copy the handles to main handle */ - st_ivas->hBinRenderer = hBinRenderer; - - return error; + /* Copy handles to bin renderer handle*/ + hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + } } - /*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleClose() - * - * Close convolution module handle of fastconv binaural renderer - *------------------------------------------------------------------------*/ - static void ivas_binRenderer_convModuleClose_fx( + /* Copy the handles to main handle */ + st_ivas->hBinRenderer = hBinRenderer; + + return error; +} + +/*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleClose() + * + * Close convolution module handle of fastconv binaural renderer + *------------------------------------------------------------------------*/ +static void ivas_binRenderer_convModuleClose_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT - BINAURAL_RENDERER_HANDLE * hBinRenderer, /* i/o: fastconv binaural renderer handle */ - const Word16 num_poses /* i : number of poses */ + BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 num_poses /* i : number of poses */ #else BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ #endif - ) - { - Word16 bandIdx, chIdx; +) +{ + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 posIdx; + Word16 posIdx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; + hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; - IF( hBinRenConvModule == NULL ) - { - return; - } + IF( hBinRenConvModule == NULL ) + { + return; + } - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) - { - free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + { + free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; - } + free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; + } - free( hBinRenConvModule->filterTapsLeftReal_fx ); - hBinRenConvModule->filterTapsLeftReal_fx = NULL; + free( hBinRenConvModule->filterTapsLeftReal_fx ); + hBinRenConvModule->filterTapsLeftReal_fx = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx ); - hBinRenConvModule->filterTapsLeftImag_fx = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx ); + hBinRenConvModule->filterTapsLeftImag_fx = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx ); - hBinRenConvModule->filterTapsRightReal_fx = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx ); + hBinRenConvModule->filterTapsRightReal_fx = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx ); - hBinRenConvModule->filterTapsRightImag_fx = NULL; + free( hBinRenConvModule->filterTapsRightImag_fx ); + hBinRenConvModule->filterTapsRightImag_fx = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) + FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) + { + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) { - FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) - { - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; + } + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { @@ -1692,281 +1692,281 @@ static void ivas_binRenderer_filterModule_fx( #endif /* OPT_BASOP_ADD_v1 */ } #endif - free( hBinRenConvModule->filterStatesLeftReal_fx ); - hBinRenConvModule->filterStatesLeftReal_fx = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx ); + hBinRenConvModule->filterStatesLeftReal_fx = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx ); - hBinRenConvModule->filterStatesLeftImag_fx = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx ); + hBinRenConvModule->filterStatesLeftImag_fx = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft ); - hBinRenConvModule->Q_filterStatesLeft = NULL; + free( hBinRenConvModule->Q_filterStatesLeft ); + hBinRenConvModule->Q_filterStatesLeft = NULL; #endif /* OPT_BASOP_ADD_v1 */ - free( ( *hBinRenderer )->hBinRenConvModule ); - ( *hBinRenderer )->hBinRenConvModule = NULL; + free( ( *hBinRenderer )->hBinRenConvModule ); + ( *hBinRenderer )->hBinRenConvModule = NULL; + + return; +} +/*------------------------------------------------------------------------- + * ivas_binRenderer_close() + * + * Close fastconv binaural renderer memories + *------------------------------------------------------------------------*/ +void ivas_binRenderer_close_fx( + BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ +) +{ + test(); + IF( hBinRenderer == NULL || *hBinRenderer == NULL ) + { return; } - /*------------------------------------------------------------------------- - * ivas_binRenderer_close() - * - * Close fastconv binaural renderer memories - *------------------------------------------------------------------------*/ - void ivas_binRenderer_close_fx( - BINAURAL_RENDERER_HANDLE * hBinRenderer /* i/o: fastconv binaural renderer handle */ - ) + IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) { - test(); - IF( hBinRenderer == NULL || *hBinRenderer == NULL ) - { - return; - } - - IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); + ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); #else ivas_binRenderer_convModuleClose_fx( hBinRenderer ); #endif - } + } - IF( ( *hBinRenderer )->hReverb != NULL ) - { - ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); - } + IF( ( *hBinRenderer )->hReverb != NULL ) + { + ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); + } - free( *hBinRenderer ); - *hBinRenderer = NULL; + free( *hBinRenderer ); + *hBinRenderer = NULL; - return; - } + return; +} - /*------------------------------------------------------------------------- - * ivas_free_pppHrtfMem() - * - * Free fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ - static void ivas_free_pppHrtfMem_fx( - Word32 * ***ppppHRIR, /*Qx*/ - const Word16 dim, - const Word16 alloc_init ) - { - Word16 i, j; +/*------------------------------------------------------------------------- + * ivas_free_pppHrtfMem() + * + * Free fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ +static void ivas_free_pppHrtfMem_fx( + Word32 ****ppppHRIR, /*Qx*/ + const Word16 dim, + const Word16 alloc_init ) +{ + Word16 i, j; - IF( *ppppHRIR != NULL ) + IF( *ppppHRIR != NULL ) + { + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + IF( alloc_init == 0 ) { - IF( alloc_init == 0 ) + FOR( j = 0; j < dim; j++ ) { - FOR( j = 0; j < dim; j++ ) - { - free( ( *ppppHRIR )[i][j] ); - ( *ppppHRIR )[i][j] = NULL; - } + free( ( *ppppHRIR )[i][j] ); + ( *ppppHRIR )[i][j] = NULL; } - free( ( *ppppHRIR )[i] ); - ( *ppppHRIR )[i] = NULL; } - free( *ppppHRIR ); - *ppppHRIR = NULL; + free( ( *ppppHRIR )[i] ); + ( *ppppHRIR )[i] = NULL; } + free( *ppppHRIR ); + *ppppHRIR = NULL; + } + + return; +} + +/*------------------------------------------------------------------------- + * ivas_binaural_hrtf_close() + * + * Close fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ +void ivas_binaural_hrtf_close( + HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i : fastconv HRTF handle */ +) +{ + Word16 allocate_init_flag; + test(); + IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) + { return; } - /*------------------------------------------------------------------------- - * ivas_binaural_hrtf_close() - * - * Close fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ - void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE * hHrtfFastConv /* i : fastconv HRTF handle */ - ) - { - Word16 allocate_init_flag; + allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; + move16(); - test(); - IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) - { - return; - } + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; - move16(); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + return; +} - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); +/*-------------------------------------------------------------------------* + * ivas_binaural_add_LFE() + * + * The functions adds the LFE to the left and right channels after binaural rendering + *-------------------------------------------------------------------------*/ +void ivas_binaural_add_LFE_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word16 output_frame, /* i : length of input frame */ + Word32 *input_fx[], /* i : transport channels Q11*/ + Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ +) +{ + Word16 render_lfe, idx_lfe, gain_fx; + Word32 lfe_tc[L_FRAME48k]; - return; + IF( st_ivas->hBinRenderer != NULL ) + { + render_lfe = st_ivas->hBinRenderer->render_lfe; + move16(); } - - /*-------------------------------------------------------------------------* - * ivas_binaural_add_LFE() - * - * The functions adds the LFE to the left and right channels after binaural rendering - *-------------------------------------------------------------------------*/ - void ivas_binaural_add_LFE_fx( - Decoder_Struct * st_ivas, /* i/o: IVAS decoder structure */ - Word16 output_frame, /* i : length of input frame */ - Word32 * input_fx[], /* i : transport channels Q11*/ - Word32 * output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ - ) + ELSE { - Word16 render_lfe, idx_lfe, gain_fx; - Word32 lfe_tc[L_FRAME48k]; + render_lfe = TRUE; + move16(); + } + - IF( st_ivas->hBinRenderer != NULL ) + IF( render_lfe ) + { + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - render_lfe = st_ivas->hBinRenderer->render_lfe; + gain_fx = GAIN_LFE_FX; move16(); } ELSE { - render_lfe = TRUE; - move16(); - } - - - IF( render_lfe ) - { - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) + test(); + IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) { - gain_fx = GAIN_LFE_FX; + gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; move16(); } ELSE { - test(); - IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) - { - gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; - move16(); - } - ELSE - { - gain_fx = GAIN_LFE_FX; - move16(); - } + gain_fx = GAIN_LFE_FX; + move16(); } - FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + } + FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + { + v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 + /* copy LFE to left and right channels */ + FOR( int idx = 0; idx < output_frame; idx++ ) { - v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 - /* copy LFE to left and right channels */ - FOR( int idx = 0; idx < output_frame; idx++ ) - { - lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q - move32(); - output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); - move32(); - output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); - move32(); - } + lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q + move32(); + output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); + move32(); + output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); + move32(); } } - - return; } - /*------------------------------------------------------------------------- - * ivas_binRenderer_fx() - * - * Fastconv binaural renderer main function - *-------------------------------------------------------------------------*/ + return; +} - void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ +/*------------------------------------------------------------------------- + * ivas_binRenderer_fx() + * + * Fastconv binaural renderer main function + *-------------------------------------------------------------------------*/ + +void ivas_binRenderer_fx( + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT - Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ - Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ #else Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ - ) - { - Word16 chIdx, i, j, k; + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ +) +{ + Word16 chIdx, i, j, k; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx, num_poses; - Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 pos_idx, num_poses; + Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #endif - // to be checked: feasibility with 32 bit buffers - Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + // to be checked: feasibility with 32 bit buffers + Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - push_wmops( "fastconv_binaural_rendering" ); + push_wmops( "fastconv_binaural_rendering" ); #ifdef SPLIT_REND_WITH_HEAD_ROT - num_poses = hBinRenderer->numPoses; + num_poses = hBinRenderer->numPoses; #endif - /* Compute Convolution */ - /* memory reset for the binaural output */ + /* Compute Convolution */ + /* memory reset for the binaural output */ #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } - } - } + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { FOR( k = 0; k < numTimeSlots; k++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } + } + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - } + Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } + } #else FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { @@ -1980,301 +1980,301 @@ static void ivas_binRenderer_filterModule_fx( } #endif - /* Head rotation in HOA3 or CICPx */ - test(); - test(); - IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) + /* Head rotation in HOA3 or CICPx */ + test(); + test(); + IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) + { + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + /* Rotation in SHD (HOA3) */ + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) { - /* Rotation in SHD (HOA3) */ - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); - } - ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); - } + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); } - ELSE + ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) { - /* Rotation in SD (CICPx) */ - rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); } } - - /* HOA decoding to CICP19 if needed*/ - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) + ELSE { - ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); + /* Rotation in SD (CICPx) */ + rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } + } + + /* HOA decoding to CICP19 if needed*/ + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) + { + ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); #else ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); #endif - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); + Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); #else Cldfb_RealBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); Cldfb_ImagBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); #endif - } } } + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( pMultiBinPoseData != NULL ) + IF( pMultiBinPoseData != NULL ) + { + IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { - IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) - { - IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; - Word32 Rmat_local[3][3]; - Word16 q_fact_orig, extra_shift = 0; + IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; + Word32 Rmat_local[3][3]; + Word16 q_fact_orig, extra_shift = 0; - IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) - { - Quaternions_ref = hCombinedOrientationData->Quaternions[0]; - q_fact_orig = Quaternions_ref.q_fact; + IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) + { + Quaternions_ref = hCombinedOrientationData->Quaternions[0]; + q_fact_orig = Quaternions_ref.q_fact; - modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); - Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) - { - /*HOA signal already rotated by DirAC*/ - Quaternions_ref2.x_fx = 0; - Quaternions_ref2.y_fx = 0; - Quaternions_ref2.z_fx = 0; - extra_shift = 1; - } - ELSE - { - /*euler*/ - Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ - } + Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) + { + /*HOA signal already rotated by DirAC*/ + Quaternions_ref2.x_fx = 0; + Quaternions_ref2.y_fx = 0; + Quaternions_ref2.z_fx = 0; + extra_shift = 1; + } + ELSE + { + /*euler*/ + Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + } - FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - } + Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } + } - Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); - Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); - Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); - Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 - Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); - modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); - QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + QuatToRotMat_fx( Quaternions_abs, Rmat_local ); - modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) - { - rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); - } - else - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - } + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + { + rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + else + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); + } + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - } + Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); } } } } } } + } #endif - /* Obtain the binaural dmx and compute the reverb */ - IF( hBinRenderer->hReverb != NULL ) - { - Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* Obtain the binaural dmx and compute the reverb */ + IF( hBinRenderer->hReverb != NULL ) + { + Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); + ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); - set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); - } + set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); + set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); } + } - ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); + ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < numTimeSlots; j++ ) { - FOR( j = 0; j < numTimeSlots; j++ ) + FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) { - FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) - { - reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in - move32(); - reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in - move32(); - } + reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in + move32(); + reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in + move32(); } } + } - /* Add the conv module and reverb module output */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + /* Add the conv module and reverb module output */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - /* Combine first and second parts to generate binaural output signal with room effect */ - v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - } + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + /* Combine first and second parts to generate binaural output signal with room effect */ + v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + } #else /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in v_add_32( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in #endif - } } } - pop_wmops(); - return; } + pop_wmops(); + return; +} #ifdef SPLIT_REND_WITH_HEAD_ROT - /*------------------------------------------------------------------------- - * ivas_rend_CldfbMultiBinRendProcess() - * - * - *-------------------------------------------------------------------------*/ - - void ivas_rend_CldfbMultiBinRendProcess( - const BINAURAL_RENDERER_HANDLE hCldfbRend, - const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word16 low_res_pre_rend_rot, - const Word16 num_subframes, - const Word16 Q_in /* i : LS signals exp */ - ) - { - int16_t slot_idx, ch_idx, idx, pose_idx, i, j; - int16_t sf_idx; - Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word16 Q_in_orig; - - FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) - { - Q_in_orig = Q_in; - move16(); - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) +/*------------------------------------------------------------------------- + * ivas_rend_CldfbMultiBinRendProcess() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes, + const Word16 Q_in /* i : LS signals exp */ +) +{ + int16_t slot_idx, ch_idx, idx, pose_idx, i, j; + int16_t sf_idx; + Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_in_orig; + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + Q_in_orig = Q_in; + move16(); + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) - { - Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); - } + Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); } + } - IF( ( *pCombinedOrientationData ) != NULL ) + IF( ( *pCombinedOrientationData ) != NULL ) + { + IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) { - IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) - { - Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); + Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); - FOR( i = 0; i < 3; i++ ) + FOR( i = 0; i < 3; i++ ) + { + FOR( j = 0; j < 3; j++ ) { - FOR( j = 0; j < 3; j++ ) - { - ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; - move32(); - } + ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; + move32(); } } - ( *pCombinedOrientationData )->shd_rot_max_order = -1; - move16(); } + ( *pCombinedOrientationData )->shd_rot_max_order = -1; + move16(); + } - ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); + ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); - FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) + FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) - { - Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - } + Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig } } } - - return; } + + return; +} #endif -- GitLab From e5668dda7f0ab8d18636164edf0451e1a6c9f798 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 09:30:57 +0530 Subject: [PATCH 294/329] Fix for 3GPP issue 1345: Decoder crash for Stereo at 32kbps in stereo_dft_dec_res_fx() Link #1345 --- lib_dec/ivas_stereo_dft_dec_fx.c | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 8dcc7ada9..fb54476fa 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1368,23 +1368,23 @@ void stereo_dft_dec_res_fx( /*Inverse MDCT*/ TCX_MDCT_Inverse( res_buf, q_res, win, STEREO_DFT_OVL_8k, L_FRAME8k - STEREO_DFT_OVL_8k, STEREO_DFT_OVL_8k, IVAS_CPE_DFT ); + scale_sig( win, L_FRAME8k + STEREO_DFT_OVL_8k, -1 ); + + Word16 q_shift = sub( hCPE->hStereoDft->q_res_cod_mem_fx, Q16 ); IF( !prev_bfi ) { /*OLA*/ /*overlapping parts*/ - Word16 q_shift = sub( hCPE->hStereoDft->q_res_cod_mem_fx, Q16 ); + FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ ) { - win[i] = extract_h( L_add( hCPE->hStereoDft->res_cod_mem_fx[i], L_shl( L_mult( win[i], hCPE->hStereoDft->win_8k_fx[i] ), q_shift ) ) ); /* q_res_cod_mem_fx */ + win[i] = extract_h( L_add( L_shr( hCPE->hStereoDft->res_cod_mem_fx[i], 1 ), L_shl( L_mult( win[i], hCPE->hStereoDft->win_8k_fx[i] ), q_shift ) ) ); /* q_res_cod_mem_fx -17 (q_shift -1)*/ move16(); - hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ); /* q_res_cod_mem_fx */ + hCPE->hStereoDft->res_cod_mem_fx[i] = L_shl( L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ), 1 ); /* -1 +15 +1 +1 */ move32(); } - IF( q_shift != 0 ) - { - v_shr_16( &win[STEREO_DFT_OVL_8k], negate( q_shift ), &win[STEREO_DFT_OVL_8k], L_FRAME8k ); - } - hCPE->hStereoDft->q_res_cod_mem_fx = Q16; + + move16(); } ELSE @@ -1396,23 +1396,30 @@ void stereo_dft_dec_res_fx( move16(); FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ ) { - win[i] = extract_h( Madd_32_16( Mpy_32_16_1( hCPE->hStereoDft->res_cod_mem_fx[i], sub( MAX_16, mult( fac, fac ) ) ), - L_mult( hCPE->hStereoDft->win_8k_fx[i], win[i] ), - sub( MAX_16, mult( sub( MAX_16, fac ), sub( MAX_16, fac ) ) ) ) ); /* Q0 */ + win[i] = extract_h( Madd_32_16( Mpy_32_16_1( L_shr( hCPE->hStereoDft->res_cod_mem_fx[i], 1 ), sub( MAX_16, mult( fac, fac ) ) ), + L_shl( L_mult( hCPE->hStereoDft->win_8k_fx[i], win[i] ), q_shift ), + sub( MAX_16, mult( sub( MAX_16, fac ), sub( MAX_16, fac ) ) ) ) ); /* Q(q_shift -1) */ move16(); - hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ); /* Q16 */ + hCPE->hStereoDft->res_cod_mem_fx[i] = L_shl( L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ), 1 ); /* Q16 */ move32(); fac = add( fac, step ); } } - Copy( win, out_16, L_FRAME8k ); /* Q0 */ + IF( q_shift != 0 ) + { + v_shr_16( &win[STEREO_DFT_OVL_8k], negate( q_shift ), &win[STEREO_DFT_OVL_8k], L_FRAME8k ); + } + + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; + + Copy( win, out_16, L_FRAME8k ); /* Q(q_shift -1 ) */ IF( hCPE->hCoreCoder[0]->core == ACELP_CORE ) { /* bass post-filter */ bass_psfilter_fx( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, out_16, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off, - hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, 0, bpf_error_signal_8k_16 ); + hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, sub( q_shift, 1 ), bpf_error_signal_8k_16 ); Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_8k_16, bpf_error_signal_8k, L_FRAME8k, Q15 ); /* Q15 */ res_bpf_flag = res_bpf_adapt_ivas_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf, q_res ); @@ -1430,7 +1437,7 @@ void stereo_dft_dec_res_fx( } } #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ #else Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ #endif @@ -1445,7 +1452,7 @@ void stereo_dft_dec_res_fx( hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; move16(); #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ #else Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ #endif @@ -1454,7 +1461,7 @@ void stereo_dft_dec_res_fx( { /* This step is needed to ensure output is properly populated with scaled values in all cases*/ #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ #else Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ #endif -- GitLab From f934b4d2d794ed257ff77f5cffff9ec1e6ebd66e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 09:48:48 +0530 Subject: [PATCH 295/329] Fix for 3GPP issue 1037: Wrong variable type used in the fixed-point code - 1 Link #1037 --- lib_com/cng_exc_fx.c | 2 +- lib_com/cnst.h | 6 +- lib_com/common_api_types.h | 50 +- lib_com/fft_evs.c | 2 +- lib_com/ivas_cnst.h | 10 +- lib_com/ivas_rom_com_fx.c | 24 +- lib_com/ivas_spar_com_fx.c | 8 +- lib_com/ivas_stat_com.h | 250 +++---- lib_com/ivas_tools_fx.c | 6 +- lib_com/longarith.c | 44 +- lib_com/lsf_dec_bfi_fx.c | 2 +- lib_com/mslvq_com.c | 6 +- lib_com/parameter_bitmaping_fx.c | 26 +- lib_com/prot_fx.h | 6 +- lib_com/rom_basop_util.c | 2 +- lib_com/rom_com.h | 2 +- lib_com/stat_com.h | 13 +- lib_dec/FEC_clas_estim_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 1 - lib_dec/core_switching_dec_fx.c | 2 +- lib_dec/dec_uv_fx.c | 22 +- lib_dec/er_dec_acelp_fx.c | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 4 +- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 6 +- lib_dec/ivas_jbm_dec_fx.c | 26 +- lib_dec/ivas_mc_param_dec_fx.c | 10 +- lib_dec/ivas_rom_dec.c | 44 +- lib_dec/ivas_rom_dec.h | 16 +- lib_dec/ivas_spar_md_dec_fx.c | 10 +- lib_dec/ivas_stat_dec.h | 524 +++++++-------- lib_dec/ivas_stereo_switching_dec_fx.c | 8 +- lib_dec/ivas_svd_dec_fx.c | 1 - lib_dec/jbm_jb4sb.h | 2 +- lib_dec/jbm_pcmdsp_apa.h | 8 +- lib_dec/jbm_pcmdsp_window.h | 2 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/avq_cod_fx.c | 12 +- lib_enc/core_enc_init_fx.c | 8 +- lib_enc/core_enc_reconf_fx.c | 2 +- lib_enc/enc_acelp_fx.c | 4 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 2 +- lib_enc/ivas_mct_enc_fx.c | 2 +- lib_enc/ivas_mdct_core_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 6 +- lib_enc/ivas_sns_enc_fx.c | 10 +- lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_fx.c | 6 +- lib_enc/ivas_stereo_td_enc_fx.c | 3 +- lib_enc/lib_enc.c | 64 +- lib_enc/lib_enc.h | 64 +- lib_enc/lsf_enc_fx.c | 4 +- lib_enc/lsf_msvq_ma_enc.c | 2 +- lib_enc/prot_fx_enc.h | 24 +- lib_enc/stat_enc.h | 624 +++++++++--------- lib_enc/swb_bwe_enc_fx.c | 2 +- lib_enc/swb_pre_proc_fx.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 6 +- lib_enc/transient_detection_fx.c | 6 +- .../ivas_dirac_dec_binaural_functions_fx.c | 22 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 4 +- lib_rend/ivas_reverb_fx.c | 32 +- lib_rend/ivas_rom_binaural_crend_head.h | 180 ++--- lib_rend/ivas_rom_binaural_crend_head_fx.c | 180 ++--- lib_rend/ivas_rom_rend_fx.c | 20 +- lib_rend/lib_rend.h | 2 +- 67 files changed, 1215 insertions(+), 1237 deletions(-) diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 3eab0b1f5..4153afa32 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -47,7 +47,7 @@ void CNG_exc_fx( Word16 *cng_ener_seed1, Word16 exc3[], /*Q_exc*/ Word16 Opt_AMR_WB, - const int16_t element_mode /* i : IVAS Element mode */ + const Word16 element_mode /* i : IVAS Element mode */ ) { Word16 i, tmp, tmp2, exp, exp2, Q_ener; diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 87aafb11a..7c93498af 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -239,7 +239,7 @@ enum{ #define L_FRAME48k_EXT 1200 /* Extended MDCT frame size in samples at 48kHz */ /* Conversion of ns to samples for a given sampling frequency */ -#define NS2SA( fs, x ) ( int16_t )( ( ( ( int32_t )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L ) +#define NS2SA( fs, x ) ( Word16 )( ( ( ( Word32 )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L ) #define NRG_CHANGE_E 8 #define AVG_FLAT_E 8 #define ACTIVE_FRAME 0xFF @@ -1172,7 +1172,6 @@ enum #define NBITS_NOISE_FILL_LEVEL 3 /* Number of bits used for coding noise filling level for each range */ #define NF_GAIN_BITS ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) #define MIN_NOISE_FILLING_HOLE 8 -#define HOLE_SIZE_FROM_LTP_FLT( gain ) ( 4 + ( int16_t )( 2.0f * gain * ( 4.0f / 0.625f ) ) ) #define HOLE_SIZE_FROM_LTP( gain ) (add(4, extract_h(L_shr(L_mult0(gain, 0x6666), 10)))) /* gain (Q15), 0x6666 = 2.0*(4.0/0.625) (4Q11) */ #define HOLE_SIZE_FROM_LTP32( gain ) (add(4, extract_h(L_shr(Mpy_32_32(gain, 0x66666667), 11)))) /* gain (Q31), 0x66666667 = 2.0*(4.0/0.625) (4Q27) */ @@ -1469,7 +1468,7 @@ enum #define cbitsnew 16 #define stat_bitsnew 14 -#define ari_q4new ( ( (int32_t) 1 << cbitsnew ) - 1 ) +#define ari_q4new ( ( (Word32) 1 << cbitsnew ) - 1 ) #define ari_q1new ( ari_q4new / 4 + 1 ) #define ari_q2new ( 2 * ari_q1new ) #define ari_q3new ( 3 * ari_q1new ) @@ -1951,7 +1950,6 @@ typedef enum _DCTTYPE #define N_SMC_MIXTURES 6 /* number of mixtures */ #define N_PCA_COEF 12 /* number of PCA components */ #define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 )) -#define SMC_ST_MEAN_FACT 0.5 /* forgetting factor of short-term IIR mean filter */ #define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ #define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */ diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 553a34f56..bc6fd4f1a 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -108,9 +108,9 @@ typedef enum _IVAS_ENC_FEC_INDICATOR typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG { - int16_t channelAwareModeEnabled; + Word16 channelAwareModeEnabled; IVAS_ENC_FEC_INDICATOR fec_indicator; - int16_t fec_offset; + Word16 fec_offset; } IVAS_ENC_CHANNEL_AWARE_CONFIG; @@ -130,7 +130,7 @@ typedef struct _IVAS_ISM_METADATA float gainFactor; float yaw; float pitch; - int16_t non_diegetic_flag; + Word16 non_diegetic_flag; } IVAS_ISM_METADATA; @@ -183,29 +183,29 @@ typedef struct ivas_LS_setup_custom IVAS_LSSETUP_CUSTOM_STRUCT; typedef struct _IVAS_LS_CUSTOM_LAYOUT { - int16_t num_spk; + Word16 num_spk; float azimuth[IVAS_MAX_OUTPUT_CHANNELS]; float elevation[IVAS_MAX_OUTPUT_CHANNELS]; Word32 azimuth_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22 Word32 elevation_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22 - int16_t num_lfe; - int16_t lfe_idx[IVAS_MAX_OUTPUT_CHANNELS]; + Word16 num_lfe; + Word16 lfe_idx[IVAS_MAX_OUTPUT_CHANNELS]; } IVAS_CUSTOM_LS_DATA; typedef struct _IVAS_JBM_TRACE_DATA { - uint32_t systemTimestamp_ms; - uint16_t extBufferedSamples; - uint16_t lastDecodedWasActive; - int32_t output_Fs; - int16_t dataUnit_flag; - uint16_t sequenceNumber; - uint32_t timeStamp; - uint32_t rcvTime; - - int16_t partial_frame; - int16_t partialCopyOffset; + UWord32 systemTimestamp_ms; + UWord16 extBufferedSamples; + UWord16 lastDecodedWasActive; + Word32 output_Fs; + Word16 dataUnit_flag; + UWord16 sequenceNumber; + UWord32 timeStamp; + UWord32 rcvTime; + + Word16 partial_frame; + Word16 partialCopyOffset; } IVAS_JBM_TRACE_DATA; @@ -217,8 +217,8 @@ typedef struct _IVAS_JBM_TRACE_DATA typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { - int16_t override; - int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ + Word16 override; + Word16 nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ @@ -231,12 +231,12 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG Word32 inputPreDelay_fx; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ /* Assumed Q-27*/ /* early reflections */ - int16_t use_er; /* ER activation flag */ - int32_t lowComplexity; /* Low complexity ER flag */ - IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ - float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ - IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ - int32_t AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ + Word16 use_er; /* ER activation flag */ + Word32 lowComplexity; /* Low complexity ER flag */ + IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ + float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ + IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ + Word32 AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ } IVAS_ROOM_ACOUSTICS_CONFIG_DATA; diff --git a/lib_com/fft_evs.c b/lib_com/fft_evs.c index e53404f0b..94c2dea8f 100644 --- a/lib_com/fft_evs.c +++ b/lib_com/fft_evs.c @@ -505,7 +505,7 @@ static void fft15_with_cmplx_data( cmplx *inp_data /*Qx*/ ) */ void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ) { - int i; + Word16 i; if ( s == 2 ) { fft16_with_cmplx_data( (cmplx *) re, bScale ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6612fac1f..2abb790f1 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1440,12 +1440,12 @@ typedef enum _COV_SMOOTHING_TYPE } COV_SMOOTHING_TYPE; typedef struct { - const int32_t *value; - const uint16_t *length; + const Word32 *value; + const UWord16 *length; } HUFF_TAB; typedef struct { - int32_t value[81]; + Word32 value[81]; unsigned short length[81]; } HUFF_ELEMENTS; @@ -1467,8 +1467,8 @@ typedef struct { typedef struct { - const int16_t (*alpha)[2]; - const int16_t (*beta)[2]; + const Word16 (*alpha)[2]; + const Word16 (*beta)[2]; } HUFF_NODE_TABLE; /*----------------------------------------------------------------------------------* diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 8ea2b91e4..a7a8bdcbf 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1617,23 +1617,23 @@ const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBAND }; /* Multi-channel input and output setups */ -const int16_t ls_azimuth_CICP2_idx[2] = { 1, 2 }; -const int16_t ls_elevation_CICP2_idx[2] = { 0, 0 }; +const Word16 ls_azimuth_CICP2_idx[2] = { 1, 2 }; +const Word16 ls_elevation_CICP2_idx[2] = { 0, 0 }; -const int16_t ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 }; -const int16_t ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 }; +const Word16 ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 }; +const Word16 ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 }; -const int16_t ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 }; -const int16_t ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 }; +const Word16 ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 }; +const Word16 ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 }; -const int16_t ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 }; -const int16_t ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 }; +const Word16 ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 }; +const Word16 ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 }; -const int16_t ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 }; -const int16_t ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 }; +const Word16 ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 }; +const Word16 ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 }; -const int16_t ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 }; -const int16_t ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 }; +const Word16 ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 }; +const Word16 ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 }; const Word32 shoebox_sin_cos_tbl_fx[11][2] = { { 0, 1073741824 }, // 0 { 536870912, 929887680 }, diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 6c80c1898..96df64aa5 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -3807,7 +3807,7 @@ void ivas_compute_spar_params_fx( { Word32 pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; - Word16 b, i, ndm; + Word16 b, i, ndm, j; Word16 q_pred_coeffs; ivas_get_pred_coeffs_fx( cov_real, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, active_w_vlbr, dtx_vad, from_dirac, dyn_active_w_flag, hSparMd->res_ind, &q_pred_coeffs, q_dm_fv_re ); @@ -3869,7 +3869,7 @@ void ivas_compute_spar_params_fx( #ifdef MSAN_FIX FOR( i = 0; i < ( num_ch - ndm ); i++ ) { - FOR( Word16 j = 0; j < sub( ndm, 1 ); j++ ) + FOR( j = 0; j < sub( ndm, 1 ); j++ ) { hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].C_re_fx[i][j], sub( q_tmp, 22 ) ); // q22 move32(); @@ -3878,7 +3878,7 @@ void ivas_compute_spar_params_fx( #else for ( i = 0; i < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; i++ ) { - for ( int j = 0; j < IVAS_SPAR_MAX_DMX_CHS - 1; j++ ) + for ( j = 0; j < IVAS_SPAR_MAX_DMX_CHS - 1; j++ ) { hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j], sub( q_tmp, 22 ) ); } @@ -3891,7 +3891,7 @@ void ivas_compute_spar_params_fx( q_tmp = hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].q_P_re_fx; move16(); - FOR( Word16 j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ ) + FOR( j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ ) { hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].P_re_fx[j] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].P_re_fx[j], sub( q_tmp, 22 ) ); // q22 move32(); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 249d1e963..fb11d3934 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -46,18 +46,18 @@ typedef struct { - int16_t last_angle1_idx; /* last frame index of coded azimuth/yaw */ - int16_t angle1_diff_cnt; /* FEC counter of consecutive differentially azimuth/yaw coded frames */ - int16_t last_angle2_idx; /* last frame index of coded elevation/pitch */ - int16_t angle2_diff_cnt; /* FEC counter of consecutive differentially elevation/pitch coded frames */ + Word16 last_angle1_idx; /* last frame index of coded azimuth/yaw */ + Word16 angle1_diff_cnt; /* FEC counter of consecutive differentially azimuth/yaw coded frames */ + Word16 last_angle2_idx; /* last frame index of coded elevation/pitch */ + Word16 angle2_diff_cnt; /* FEC counter of consecutive differentially elevation/pitch coded frames */ } ISM_METADATA_ANGLE, *ISM_METADATA_ANGLE_HANDLE; /* ISM metadata handle (storage for one frame of read ISM metadata) */ typedef struct { - int16_t ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */ - int16_t last_ism_metadata_flag; /* last frame ism_metadata_flag */ + Word16 ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */ + Word16 last_ism_metadata_flag; /* last frame ism_metadata_flag */ Word32 azimuth_fx; /* azimuth value read from the input metadata file */ /* Q22 */ Word32 elevation_fx; /* elevation value read from the input metadata file */ /* Q22 */ @@ -65,25 +65,25 @@ typedef struct Word32 yaw_fx; /* yaw value read from the input metadata file */ /* Q22 */ Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ - int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ + Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ ISM_METADATA_ANGLE position_angle; /* Angle structs for azimuth and elevation */ ISM_METADATA_ANGLE orientation_angle; /* Angle structs for yaw and pitch */ - int16_t last_radius_idx; /* last frame index of coded radius */ - int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ + Word16 last_radius_idx; /* last frame index of coded radius */ + Word16 radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ Word32 last_azimuth_fx; /* MD smoothing in DTX- last Q azimuth value */ /* Q22 */ Word32 last_elevation_fx; /* MD smoothing in DTX - last Q elevation value */ /* Q22 */ Word32 last_true_azimuth_fx; /* MD smoothing in DTX- last true Q azimuth value */ /* Q22 */ Word32 last_true_elevation_fx; /* MD smoothing in DTX- last true Q elevation value */ /* Q22 */ - int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ - int16_t ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */ - Word16 last_true_radius_fx; /* last true Q radius value */ + Word16 ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ + Word16 ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */ + Word16 last_true_radius_fx; /* last true Q radius value */ - int16_t ism_imp; /* ISM importance flag */ - int16_t ism_md_null_flag; - int16_t ism_md_lowrate_flag; + Word16 ism_imp; /* ISM importance flag */ + Word16 ism_md_null_flag; + Word16 ism_md_lowrate_flag; Word32 q_azimuth_old_fx; Word32 q_elevation_old_fx; @@ -96,15 +96,15 @@ typedef struct typedef struct stereo_dft_config_data_struct { - int16_t dmx_active; - int16_t band_res; - int16_t prm_res; /* Send prm every # DFT frames */ - int16_t res_pred_mode; /* mode : from 0 (off) to 1 (on) */ - int16_t res_cod_mode; /* mode : from 0 (off) to 3 */ - int16_t hybrid_itd_flag; - int16_t ada_wb_res_cod_mode; /* res_cod_mode for adaptive wide band residual coding */ + Word16 dmx_active; + Word16 band_res; + Word16 prm_res; /* Send prm every # DFT frames */ + Word16 res_pred_mode; /* mode : from 0 (off) to 1 (on) */ + Word16 res_cod_mode; /* mode : from 0 (off) to 3 */ + Word16 hybrid_itd_flag; + Word16 ada_wb_res_cod_mode; /* res_cod_mode for adaptive wide band residual coding */ - int16_t force_mono_transmission; + Word16 force_mono_transmission; } STEREO_DFT_CONFIG_DATA, *STEREO_DFT_CONFIG_DATA_HANDLE; @@ -115,20 +115,20 @@ typedef struct stereo_dft_config_data_struct typedef struct { - uint8_t const bandLengthsTCX20[SMDCT_MAX_STEREO_BANDS_TCX20]; /* Length of a band in number of bins. Range is 4..160 */ - const int16_t bdnCnt_TCX20[4]; /* uppermost band for FB,SWB,WB,NB */ - uint8_t const bandLengthsTCX10[SMDCT_MAX_STEREO_BANDS_TCX10]; /* Length of a band in number of bins. Range is 2..80, always divisible by 2 */ - const int16_t bndCnt_TCX10[4]; /* uppermost band for FB,SWB,WB,NB */ + UWord8 const bandLengthsTCX20[SMDCT_MAX_STEREO_BANDS_TCX20]; /* Length of a band in number of bins. Range is 4..160 */ + const Word16 bdnCnt_TCX20[4]; /* uppermost band for FB,SWB,WB,NB */ + UWord8 const bandLengthsTCX10[SMDCT_MAX_STEREO_BANDS_TCX10]; /* Length of a band in number of bins. Range is 2..80, always divisible by 2 */ + const Word16 bndCnt_TCX10[4]; /* uppermost band for FB,SWB,WB,NB */ } MDCTStereoBands_config; /* MDCT stereo frequency band structure */ typedef struct stereo_mdct_dec_band_parameters_struct { - int16_t sfbOffset[MAX_SFB + 1]; /* stereo frequency band start offsets */ - int16_t sfbCnt; /* number of stereo frequency bands */ - int16_t nBandsStereoCore; /* number of stereo frequency bands in the core */ - int16_t sfbIgfStart; /*index for first IGF band*/ + Word16 sfbOffset[MAX_SFB + 1]; /* stereo frequency band start offsets */ + Word16 sfbCnt; /* number of stereo frequency bands */ + Word16 nBandsStereoCore; /* number of stereo frequency bands in the core */ + Word16 sfbIgfStart; /*index for first IGF band*/ } STEREO_MDCT_BAND_PARAMETERS; @@ -139,9 +139,9 @@ typedef struct stereo_mdct_dec_band_parameters_struct typedef struct { - int16_t config_index; - int16_t encoding_active; /* internal state specifying if actual encoding is active or only length evaluation is active */ - int32_t bit_count_estimate; /* uses 22Q10 fixed-point representation */ + Word16 config_index; + Word16 encoding_active; /* internal state specifying if actual encoding is active or only length evaluation is active */ + Word32 bit_count_estimate; /* uses 22Q10 fixed-point representation */ void *ac_handle; } ECSQ_instance; @@ -153,9 +153,9 @@ typedef struct typedef struct ivas_dirac_config_data_struct { - int16_t enc_param_start_band; - int16_t dec_param_estim; - int16_t nbands; + Word16 enc_param_start_band; + Word16 dec_param_estim; + Word16 nbands; } DIRAC_CONFIG_DATA, *DIRAC_CONFIG_DATA_HANDLE; @@ -180,9 +180,9 @@ typedef struct ivas_band_coeffs_t typedef struct ivas_band_coeffs_ind_t { - int16_t pred_index_re[IVAS_SPAR_MAX_CH - 1]; - int16_t drct_index_re[IVAS_SPAR_MAX_C_COEFF]; - int16_t decd_index_re[IVAS_SPAR_MAX_CH - 1]; + Word16 pred_index_re[IVAS_SPAR_MAX_CH - 1]; + Word16 drct_index_re[IVAS_SPAR_MAX_C_COEFF]; + Word16 decd_index_re[IVAS_SPAR_MAX_CH - 1]; } ivas_band_coeffs_ind_t; @@ -192,7 +192,7 @@ typedef struct ivas_spar_md_t ivas_band_coeffs_ind_t band_coeffs_idx[IVAS_MAX_NUM_BANDS]; Word16 num_bands; Word32 min_max_fx[2]; /*q28*/ - int16_t dtx_vad; + Word16 dtx_vad; Word32 en_ratio_slow_fx[IVAS_MAX_NUM_BANDS]; Word32 ref_pow_slow_fx[IVAS_MAX_NUM_BANDS]; Word16 res_ind; @@ -210,7 +210,7 @@ typedef struct ivas_quant_coeffs_t { Word32 min_fx; /* Q28 */ Word32 max_fx; /* Q28 */ - int16_t q_levels[2]; + Word16 q_levels[2]; } ivas_quant_coeffs_t; typedef struct ivas_quant_strat_t @@ -224,23 +224,23 @@ typedef struct ivas_quant_strat_t typedef struct ivas_spar_md_com_cfg { - int16_t max_freq_per_chan[IVAS_SPAR_MAX_CH]; - int16_t num_dmx_chans_per_band[IVAS_MAX_NUM_BANDS]; - int16_t num_decorr_per_band[IVAS_MAX_NUM_BANDS]; - int16_t active_w; - int16_t remix_unmix_order; + Word16 max_freq_per_chan[IVAS_SPAR_MAX_CH]; + Word16 num_dmx_chans_per_band[IVAS_MAX_NUM_BANDS]; + Word16 num_decorr_per_band[IVAS_MAX_NUM_BANDS]; + Word16 active_w; + Word16 remix_unmix_order; ivas_quant_strat_t quant_strat[MAX_QUANT_STRATS]; - int16_t quant_strat_bits; - int16_t nchan_transport; - int16_t num_quant_strats; - int16_t prior_strat; - int16_t tgt_bits_per_blk; - int16_t max_bits_per_blk; - int16_t prev_quant_idx; - int16_t agc_bits_ch_idx; - int16_t planarCP; - int16_t num_umx_chs; - int16_t max_md_bits_spar; + Word16 quant_strat_bits; + Word16 nchan_transport; + Word16 num_quant_strats; + Word16 prior_strat; + Word16 tgt_bits_per_blk; + Word16 max_bits_per_blk; + Word16 prev_quant_idx; + Word16 agc_bits_ch_idx; + Word16 planarCP; + Word16 num_umx_chs; + Word16 max_md_bits_spar; } ivas_spar_md_com_cfg; @@ -248,26 +248,26 @@ typedef struct ivas_spar_md_com_cfg /* arithmetic coder structures */ typedef struct ivas_cell_dim_t { - int16_t dim1; - int16_t dim2; + Word16 dim1; + Word16 dim2; } ivas_cell_dim_t; typedef struct ivas_freq_models_t { - int16_t freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; - int16_t diff_freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; - int16_t vals[IVAS_MAX_QUANT_LEVELS]; - int16_t diff_vals[IVAS_MAX_QUANT_LEVELS]; - int16_t num_models; - int16_t diff_num_models; + Word16 freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word16 diff_freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word16 vals[IVAS_MAX_QUANT_LEVELS]; + Word16 diff_vals[IVAS_MAX_QUANT_LEVELS]; + Word16 num_models; + Word16 diff_num_models; } ivas_freq_models_t; typedef struct ivas_huff_models_t { - int16_t code_book[IVAS_MAX_QUANT_LEVELS][3]; - int16_t diff_code_book[IVAS_MAX_QUANT_LEVELS][3]; + Word16 code_book[IVAS_MAX_QUANT_LEVELS][3]; + Word16 diff_code_book[IVAS_MAX_QUANT_LEVELS][3]; } ivas_huff_models_t; @@ -275,22 +275,22 @@ typedef struct ivas_huff_models_t /* Entropy coder structures */ typedef struct ivas_huffman_cfg_t { - const int16_t *codebook; - int16_t min_len; - int16_t max_len; - int16_t sym_len; + const Word16 *codebook; + Word16 min_len; + Word16 max_len; + Word16 sym_len; } ivas_huffman_cfg_t; typedef struct ivas_arith_t { - int16_t dyn_model_bits; - const int16_t *pFreq_model; - const int16_t *pAlt_freq_models[IVAS_NUM_PROB_MODELS]; - const int16_t *vals; - int16_t cum_freq[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; - int16_t range; - int16_t num_models; + Word16 dyn_model_bits; + const Word16 *pFreq_model; + const Word16 *pAlt_freq_models[IVAS_NUM_PROB_MODELS]; + const Word16 *vals; + Word16 cum_freq[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word16 range; + Word16 num_models; Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; /* Q15 */ } ivas_arith_t; @@ -338,18 +338,18 @@ typedef struct ivas_cov_smooth_state_t Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 *q_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 *q_prior_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - int16_t prior_bank_idx; + Word16 prior_bank_idx; Word32 *pSmoothing_factor_fx; /* Q31 */ - int16_t num_bins; + Word16 num_bins; } ivas_cov_smooth_state_t; typedef struct ivas_cov_smooth_cfg_t { Word32 max_update_rate_fx; /* Q31 */ - int16_t min_pool_size; - int16_t max_bands; - int16_t num_bins; + Word16 min_pool_size; + Word16 max_bands; + Word16 num_bins; } ivas_cov_smooth_cfg_t; @@ -357,20 +357,20 @@ typedef struct ivas_cov_smooth_cfg_t /* SPAR bitrate constant table structure */ typedef struct ivas_spar_br_table_t { - int32_t ivas_total_brate; - int16_t isPlanar; - int16_t sba_order; - int16_t bwidth; - int16_t fpcs; - int16_t nchan_transport; + Word32 ivas_total_brate; + Word16 isPlanar; + Word16 sba_order; + Word16 bwidth; + Word16 fpcs; + Word16 nchan_transport; ivas_spar_pmx_strings_t dmx_str; - int16_t active_w; - int16_t tmode; - int32_t core_brs[FOA_CHANNELS][3]; - int16_t q_lvls[MAX_QUANT_STRATS][NUM_MD_Q_COEFS_SET]; - int16_t td_ducking; - int16_t agc_bits_ch_idx; /* 0-3, Indicates core-coder channel index from which AGC bits have been taken from*/ - int16_t usePlanarCoeff; + Word16 active_w; + Word16 tmode; + Word32 core_brs[FOA_CHANNELS][3]; + Word16 q_lvls[MAX_QUANT_STRATS][NUM_MD_Q_COEFS_SET]; + Word16 td_ducking; + Word16 agc_bits_ch_idx; /* 0-3, Indicates core-coder channel index from which AGC bits have been taken from*/ + Word16 usePlanarCoeff; } ivas_spar_br_table_t; @@ -419,7 +419,7 @@ typedef struct ivas_masa_common_spatial_meta_struct typedef struct ivas_omasa_meta_struct { - uint8_t num_dirs; + UWord8 num_dirs; MASA_DIRECTIONAL_SPATIAL_META directional_meta[MASA_MAXIMUM_DIRECTIONS]; MASA_COMMON_SPATIAL_META common_meta; @@ -435,16 +435,16 @@ typedef struct ivas_masa_metadata_frame_struct typedef struct ivas_masa_config_struct { - uint16_t max_metadata_bits; - int16_t block_grouping[5]; - int16_t band_grouping[MASA_FREQUENCY_BANDS + 1]; - uint8_t numCodingBands; - uint8_t numTwoDirBands; - uint8_t numberOfDirections; - uint8_t joinedSubframes; - uint8_t useCoherence; - uint8_t coherencePresent; - uint8_t mergeRatiosOverSubframes; + UWord16 max_metadata_bits; + Word16 block_grouping[5]; + Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; + UWord8 numCodingBands; + UWord8 numTwoDirBands; + UWord8 numberOfDirections; + UWord8 joinedSubframes; + UWord8 useCoherence; + UWord8 coherencePresent; + UWord8 mergeRatiosOverSubframes; IVAS_FORMAT input_ivas_format; } MASA_CODEC_CONFIG; @@ -456,11 +456,11 @@ typedef struct ivas_masa_config_struct typedef struct { - int16_t nbands; - int16_t nblocks; - int16_t start_band; - uint8_t inactiveBands; - int16_t search_effort; + Word16 nbands; + Word16 nblocks; + Word16 start_band; + UWord8 inactiveBands; + Word16 search_effort; MC_LS_SETUP mc_ls_setup; } IVAS_METADATA_CONFIG; @@ -615,10 +615,10 @@ typedef struct ivas_parametric_mc_metadata_struct typedef struct ivas_lfe_window { - int16_t dct_len; - int16_t fade_len; - int16_t zero_pad_len; - int16_t full_len; + Word16 dct_len; + Word16 fade_len; + Word16 zero_pad_len; + Word16 full_len; const Word32 *pWindow_coeffs_fx; @@ -626,14 +626,14 @@ typedef struct ivas_lfe_window typedef struct ivas_lfe_freq_models { - uint16_t entropy_coder_model_fine_sg1[65]; - uint16_t entropy_coder_model_fine_sg2[33]; - uint16_t entropy_coder_model_fine_sg3[9]; - uint16_t entropy_coder_model_fine_sg4[3]; - uint16_t entropy_coder_model_coarse_sg1[33]; - uint16_t entropy_coder_model_coarse_sg2[17]; - uint16_t entropy_coder_model_coarse_sg3[5]; - uint16_t entropy_coder_model_coarse_sg4; + UWord16 entropy_coder_model_fine_sg1[65]; + UWord16 entropy_coder_model_fine_sg2[33]; + UWord16 entropy_coder_model_fine_sg3[9]; + UWord16 entropy_coder_model_fine_sg4[3]; + UWord16 entropy_coder_model_coarse_sg1[33]; + UWord16 entropy_coder_model_coarse_sg2[17]; + UWord16 entropy_coder_model_coarse_sg3[5]; + UWord16 entropy_coder_model_coarse_sg4; } ivas_lfe_freq_models; diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index e460637f7..e15db9a15 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -2970,7 +2970,7 @@ Word64 var_32_fx( Word16 q /* q : q-factor for the array */ ) { - + Word16 i; Word64 mean, var; mean = 0; @@ -2978,14 +2978,14 @@ Word64 var_32_fx( var = 0; move64(); - FOR( int i = 0; i < len; i++ ) + FOR( i = 0; i < len; i++ ) { mean = W_add( mean, x[i] ); /*q*/ } mean = mean / len; /* NOTE: No BASOP for 64 bit division q*/ - FOR( int i = 0; i < len; i++ ) + FOR( i = 0; i < len; i++ ) { var = W_add( var, Mpy_32_32( L_sub( x[i], W_extract_l( mean ) ), L_sub( x[i], W_extract_l( mean ) ) ) ); /*q + q - 31*/ } diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 8946e41aa..72a763de3 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -52,27 +52,27 @@ *--------------------------------------------------------------------*/ void longadd( - uint16_t a[], /* i/o: vector of the length lena */ - const uint16_t b[], /* i/o: vector of the length lenb */ - const int16_t lena, /* i/o: length of vector a[] */ - const int16_t lenb /* i/o: length of vector b[] */ + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ ) { - int16_t h; - int32_t carry = 0; + Word16 h; + Word32 carry = 0; assert( lena >= lenb ); for ( h = 0; h < lenb; h++ ) { carry += ( (uint32_t) a[h] ) + ( (uint32_t) b[h] ); - a[h] = (uint16_t) carry; + a[h] = (UWord16) carry; carry = carry >> 16; } for ( ; h < lena; h++ ) { carry = ( (uint32_t) a[h] ) + carry; - a[h] = (uint16_t) carry; + a[h] = (UWord16) carry; carry = carry >> 16; } @@ -91,14 +91,14 @@ void longadd( *--------------------------------------------------------------------*/ void longshiftright( - uint16_t a[], /* i : vector of the length lena */ - const int16_t b, /* i : number of bit positions to shift right */ - uint16_t d[], /* o : vector of the length lend */ - int16_t lena, /* i : length of vector a[] */ - const int16_t lend /* i : length of vector d[] */ + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ ) { - int16_t intb, fracb, fracb_u, k; + Word16 intb, fracb, fracb_u, k; intb = b >> 4; @@ -164,16 +164,16 @@ void longshr( *--------------------------------------------------------------------*/ void longshiftleft( - const uint16_t a[], /* i : vector of the length len */ - const int16_t b, /* i : number of bit positions to shift left */ - uint16_t d[], /* o : vector of the length len */ - const int16_t len /* i : length of vector a[] and d[] */ + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ ) { - int16_t intb; /* integer part of b */ - int16_t fracb; /* shift left value for all upper words a[k] */ - int16_t fracb_l; /* shift right value for all lower words a[k-1] */ - int16_t k = len - 1; + Word16 intb; /* integer part of b */ + Word16 fracb; /* shift left value for all upper words a[k] */ + Word16 fracb_l; /* shift right value for all lower words a[k-1] */ + Word16 k = len - 1; intb = b >> 4; fracb = b & 0xF; diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c index 6292630af..33de5d9ac 100644 --- a/lib_com/lsf_dec_bfi_fx.c +++ b/lib_com/lsf_dec_bfi_fx.c @@ -36,7 +36,7 @@ void lsf_dec_bfi( const Word16 Last_GSC_pit_band_idx, const Word16 Opt_AMR_WB, /* i : IO flag */ const Word8 tcxonly, - const short bwidth /* i: coded bandwidth */ + const Word16 bwidth /* i: coded bandwidth */ ) { Word16 i; diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index a15b11611..6bd8026c4 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -75,10 +75,10 @@ static void make_offset_scale( void create_offset( UWord32 *offset_scale1, UWord32 *offset_scale2, - const int16_t mode, - const int16_t prediction_flag ) + const Word16 mode, + const Word16 prediction_flag ) { - int16_t tmp, tmp1; + Word16 tmp, tmp1; if ( prediction_flag == 0 ) { diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 180275d8f..0846c618b 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -58,15 +58,15 @@ static Word16 FixedWidthEncoding( Word16 value, Word16 index ) void GetParameters( ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, + const Word16 nArrayLength, void const *pParameter, - int16_t **pStream, - int16_t *pnSize, - int16_t *pnBits ) + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ) { - int16_t index; - int16_t iParam, nParams; - int16_t value; + Word16 index; + Word16 iParam, nParams; + Word16 value; void const *pSubStruct; assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pParameter != NULL ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( pnBits != NULL ) ); @@ -168,14 +168,14 @@ void GetParameters_fx( void SetParameters( ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, + const Word16 nArrayLength, void *pParameter, - const int16_t **pStream, - int16_t *pnSize ) + const Word16 **pStream, + Word16 *pnSize ) { - int16_t index; - int16_t iParam, nParams; - int16_t value; + Word16 index; + Word16 iParam, nParams; + Word16 value; void *pSubStruct; assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pParameter != NULL ) && ( pStream != NULL ) && ( pnSize != NULL ) ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9b596ca42..d0f0efb72 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -72,10 +72,6 @@ #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif -#ifndef TRUNC -#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) ) -#endif - #define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) #define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) @@ -11101,7 +11097,7 @@ void init_coder_ace_plus_ivas_fx( void core_coder_reconfig_ivas_fx( Encoder_State *st, - const int32_t last_total_brate ); + const Word32 last_total_brate ); void core_coder_mode_switch_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c index c3bfc6eef..eb79cc026 100644 --- a/lib_com/rom_basop_util.c +++ b/lib_com/rom_basop_util.c @@ -1449,7 +1449,7 @@ void BASOP_getTables( const PWord16 **ptwiddle /*Q15*/, const PWord16 **sin_twid ld2_length = sub( 16 - 1 - 1, norm_s( length ) ); /* Extract sort of "eigenvalue" (the 5 left most bits) of length. */ - SWITCH( (unsigned short) L_shl( length, sub( 15, ld2_length ) ) ) + SWITCH( (UWord16) L_shl( length, sub( 15, ld2_length ) ) ) { case 0xa000: /* 640 */ move16(); diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 274a33a18..33661fb58 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -66,7 +66,7 @@ typedef struct Word16 filt_len; /* number of filter coeff. */ Word16 filt_len_fx; /* number of filter coeff. Q0 */ - uint16_t flags; /* flags from config. table */ + UWord16 flags; /* flags from config. table */ UWord16 flags_fx; /* flags from config. table Q0 */ // UNS_Word16 flags_fx; /* flags from config. table Q0 */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 9edc28c03..c96dcc884 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -74,7 +74,7 @@ typedef struct typedef struct { Word16 lead_sign_ind; - uint32_t index, size; + UWord32 index, size; Word16 dim, k_val; } PvqEntry; @@ -313,7 +313,7 @@ typedef struct { Word32 low; Word32 high; - uint32_t value; + UWord32 value; Word32 bits_to_follow; } Tastat; typedef struct @@ -490,15 +490,6 @@ typedef Word16 ( *TEncodeValue )( Word16 value, Word16 index ); */ typedef Word16 ( *TDecodeValue )( struct Decoder_State *st, Word16 index, Word16 *pValue ); -/** Linear prediction analysis/synthesis filter definition. - * @param order filter order. - * @param parCoeff filter (PARCOR) coefficients. - * @param state state of the filter. Must be at least of 'order' size. - * @param x the current input value. - * @return the output of the filter. - */ -typedef float ( *TLinearPredictionFilter_flt )( const int16_t order, const float parCoeff[], float *state, float x ); - /** Structure that defines mapping between a parameter and a bitstream. */ typedef struct ParamBitMap { diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 9b58084e3..e56a77be1 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -82,7 +82,7 @@ void FEC_clas_estim_fx( Word16 bfi, /* i : bad frame indicator */ /*B*/ Word32 last_core_brate, /* i : bitrate of previous frame */ - const int16_t FEC_mode /* i : ACELP FEC mode */ + const Word16 FEC_mode /* i : ACELP FEC mode */ ) { Word16 i, j, pos; diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index fc8aba043..b2cc593b3 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -847,7 +847,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( move16(); Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ - // cldfbSynthesis_ivas_fx(realBuffer, imagBuffer, synth_out, (int16_t)(st_fx->output_Fs * 0.01f), st_fx->cldfbSyn); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), st_fx->cldfbSyn ); Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, -1 ); // Q_cldfb_state-1 st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 17b3f9fbc..0f361e658 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1290,7 +1290,7 @@ ivas_error core_switching_post_dec_ivas_fx( FD_BWE_DEC_HANDLE hBWE_FD; HQ_DEC_HANDLE hHQ_core; ivas_error error; - int16_t offset; + Word16 offset; L_tmp = 0; move32(); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index aa898956a..42f3250fb 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -114,17 +114,17 @@ void decod_unvoiced_fx( *-------------------------------------------------------------------*/ void decod_unvoiced_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ) { Word16 gain_pit_fx; /* Quantized pitch gain */ diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 7c3ecaa0a..e30553d38 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -446,7 +446,7 @@ void con_acelp_fx( ELSE { /* No harmonic part */ - assert( (int) ( sizeof( buf ) / sizeof( buf[0] ) ) - M - L_EXC_MEM_DEC >= st->L_frame + st->L_frame / 2 ); + assert( (Word32) ( sizeof( buf ) / sizeof( buf[0] ) ) - M - L_EXC_MEM_DEC >= st->L_frame + st->L_frame / 2 ); set16_fx( &exc[0], 0, add( st->L_frame, shr( st->L_frame, 1 ) ) ); FOR( i = 0; i < st->nb_subfr; i++ ) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 3fe40c1f3..3c234c098 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1484,7 +1484,7 @@ void ivas_binaural_add_LFE_fx( Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ ) { - Word16 render_lfe, idx_lfe, gain_fx; + Word16 render_lfe, idx_lfe, gain_fx, idx; IF( st_ivas->hBinRenderer != NULL ) { @@ -1523,7 +1523,7 @@ void ivas_binaural_add_LFE_fx( { v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); // q_input_fx - 1 /* copy LFE to left and right channels */ - FOR( int idx = 0; idx < output_frame; idx++ ) + FOR( idx = 0; idx < output_frame; idx++ ) { input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx] = L_shl_sat( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx], 1 ); // saturating to keep same q move32(); diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 7dd7371fd..59d9c9e38 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2216,7 +2216,7 @@ void ivas_dirac_dec_render_sf_fx( DIRAC_DEC_STACK_MEM DirAC_mem; Word32 *p_onset_filter_fx = NULL; - uint16_t coherence_flag; + UWord16 coherence_flag; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word16 scale = 0; move16(); diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 9040a8a71..eae0e9069 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1428,9 +1428,9 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( static void ivas_ism_param_dec_render_sf_fx( Decoder_Struct *st_ivas, IVAS_OUTPUT_SETUP hSetup, - const int16_t nchan_transport, - const int16_t nchan_out, - const int16_t nchan_out_woLFE, + const Word16 nchan_transport, + const Word16 nchan_out, + const Word16 nchan_out_woLFE, Word32 *output_f_fx[], /*Q_output*/ Word16 Q_output[] ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f632d86c8..428c817ef 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -83,7 +83,7 @@ ivas_error ivas_jbm_dec_tc_fx( Word32 *data_fx /*Q11*/ ) { - Word16 n, output_frame, nchan_out, i; + Word16 n, output_frame, nchan_out, i, ii; Decoder_State *st; /* used for bitstream handling */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ Word16 nchan_remapped; @@ -512,14 +512,14 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; move16(); } #ifdef MSAN_FIX - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx } @@ -534,7 +534,7 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } #ifdef MSAN_FIX - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } @@ -614,7 +614,7 @@ ivas_error ivas_jbm_dec_tc_fx( st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; move16(); - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; @@ -999,7 +999,7 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; @@ -1045,7 +1045,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; @@ -1464,7 +1464,7 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; @@ -1509,7 +1509,7 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( st_ivas->hSpar != NULL ) { - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; @@ -1787,7 +1787,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { @@ -1882,7 +1882,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_error error; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; - Word16 subframe_len, gd_bits, exp, nchan_in, i, j; + Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch; const Word16 output_q_factor = Q11; move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -2448,7 +2448,7 @@ ivas_error ivas_jbm_dec_render_fx( move16(); } /* CLDFB synthesis */ - FOR( Word16 ch = 0; ch < nchan_out_cldfb; ch++ ) + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { IF( st_ivas->cldfbSynDec[ch] ) { @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx ); - FOR( int ch = 0; ch < nchan_out_cldfb; ch++ ) + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { IF( st_ivas->cldfbSynDec[ch] ) { diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 897fd4433..be2363469 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -107,7 +107,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, cons static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); -static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); +static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); /*------------------------------------------------------------------------- * ivas_param_mc_dec_open() @@ -1509,8 +1509,8 @@ void ivas_param_mc_dec_read_BS_fx( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ Word32 *transport_channels_f_fx[], Word16 transport_f_e ) { @@ -2361,7 +2361,7 @@ static void param_mc_protoSignalComputation_fx( Word32 *ImagBuffer_fx, /* i : CLDFB samples of the transport channels (imaginary part) */ Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */ const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */ - const int16_t num_freq_bands /* i : number of frequency bands for the prototypes */ + const Word16 num_freq_bands /* i : number of frequency bands for the prototypes */ ) { Word16 band; @@ -2680,7 +2680,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( Word16 nY_band; Word16 num_lfe_bands; Word16 brange[2]; - uint16_t i; + UWord16 i; Word16 ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; Word16 remove_lfe; Word16 lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 812d9957f..6f75230c9 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -100,7 +100,7 @@ const Word32 dft_ap_gains_fx[5][3] = { 644245094, -644245120, 1073741824 } }; -const int16_t dft_ap_delays[3][3] = +const Word16 dft_ap_delays[3][3] = { { 2, 47, 61}, {29, 41, 73}, @@ -196,7 +196,7 @@ const Word16 dft_win_8k_fx[70] = * stereo CNA tables *------------------------------------------------------------------------*/ -const int16_t cna_init_bands[CNA_INIT_NBANDS + 1] = +const Word16 cna_init_bands[CNA_INIT_NBANDS + 1] = { 1, 4, 14, 33, 67, 171, 320 }; @@ -235,7 +235,7 @@ const Word16 min_smooth_gains2_fx[SBA_DIRAC_STEREO_NUM_BANDS] = /* all the "probability" tables for the actual AC are in the reversed cumulative counts table format; for example, given the counts table [c0 | c1 | c2 | c3] with c0 + c1 + c2 + c3 = 2 ^ 14, the reversed cumulative counts table is [2 ^ 14 | 2 ^ 14 - c0 | 2 ^ 14 - c0 - c1 | 2 ^ 14 - c0 - c1 - c2 | 2 ^ 14 - c0 - c1 - c2 - c3] */ -const uint16_t cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] = +const UWord16 cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] = { {0,1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312,14336,15360,16384 }, {0,9294,16019,16213,16311,16346,16363,16371,16375,16377,16378,16379,16380,16381,16382,16383,16384 }, @@ -246,7 +246,7 @@ const uint16_t cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] {0,5836,14448,15610,16267,16343,16374,16375,16376,16377,16378,16379,16380,16381,16382,16383,16384 } }; -const uint16_t sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT] = +const UWord16 sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT] = { {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024 }, {9294,6725,194,98,35,17,8,4,2,1,1,1,1,1,1,1 }, @@ -257,7 +257,7 @@ const uint16_t sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT] = {5836,8612,1162,657,76,31,1,1,1,1,1,1,1,1,1,1 } }; -const uint16_t cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] = +const UWord16 cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] = { {0,6445,12725,15035,15885,16198,16313,16355,16370,16376,16378,16379,16380,16381,16382,16383,16384 }, {0,3624,8645,11690,13537,14657,15336,15748,15998,16150,16242,16298,16332,16352,16364,16372,16384 }, @@ -276,7 +276,7 @@ const uint16_t cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SI {0,3623,6446,8644,10356,11689,12727,13536,14166,14657,15039,15337,15569,15749,15890,15999,16384 }, }; -const uint16_t sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE] = +const UWord16 sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE] = { {6445,6280,2310,850,313,115,42,15,6,2,1,1,1,1,1,1 }, {3624,5021,3045,1847,1120,679,412,250,152,92,56,34,20,12,8,12 }, @@ -295,59 +295,59 @@ const uint16_t sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE] {3623,2823,2198,1712,1333,1038,809,630,491,382,298,232,180,141,109,385 }, }; -const uint16_t cum_freq_ECSQ_tab_abs_1bit[1 + 2] = +const UWord16 cum_freq_ECSQ_tab_abs_1bit[1 + 2] = { 0, 5462, 16384 }; /* table for uniform coding of absolute values in {0, +-1, +-2, +-3} */ -const uint16_t cum_freq_ECSQ_tab_abs_2bit[1 + 4] = +const UWord16 cum_freq_ECSQ_tab_abs_2bit[1 + 4] = { 0, 2338, 7020, 11702, 16384 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-7} */ -const uint16_t cum_freq_ECSQ_tab_abs_3bit[1 + 8] = +const UWord16 cum_freq_ECSQ_tab_abs_3bit[1 + 8] = { 0, 1096, 3280, 5464, 7648, 9832, 12016, 14200, 16384 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-15} */ -const uint16_t cum_freq_ECSQ_tab_abs_4bit[1 + 16] = +const UWord16 cum_freq_ECSQ_tab_abs_4bit[1 + 16] = { 0, 514, 1572, 2630, 3688, 4746, 5804, 6862, 7920, 8978, 10036, 11094, 12152, 13210, 14268, 15326, 16384 }; -const uint16_t sym_freq_ECSQ_tab_abs_1bit[2] = +const UWord16 sym_freq_ECSQ_tab_abs_1bit[2] = { 5462, 10922 }; /* table for uniform coding of absolute values in {0, +-1, +-2, +-3} */ -const uint16_t sym_freq_ECSQ_tab_abs_2bit[4] = +const UWord16 sym_freq_ECSQ_tab_abs_2bit[4] = { 2338, 4682, 4682, 4682 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-7} */ -const uint16_t sym_freq_ECSQ_tab_abs_3bit[8] = +const UWord16 sym_freq_ECSQ_tab_abs_3bit[8] = { 1096, 2184, 2184, 2184, 2184, 2184, 2184, 2184 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-15} */ -const uint16_t sym_freq_ECSQ_tab_abs_4bit[16] = +const UWord16 sym_freq_ECSQ_tab_abs_4bit[16] = { 514, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058 }; /* array of tables for uniform coding of absolute values */ -const uint16_t * const cum_freq_ECSQ_tab_abs_lsbs[1 + 4] = +const UWord16 * const cum_freq_ECSQ_tab_abs_lsbs[1 + 4] = { NULL, cum_freq_ECSQ_tab_abs_1bit, cum_freq_ECSQ_tab_abs_2bit, cum_freq_ECSQ_tab_abs_3bit, cum_freq_ECSQ_tab_abs_4bit }; -const uint16_t * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = +const UWord16 * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = { NULL, sym_freq_ECSQ_tab_abs_1bit, sym_freq_ECSQ_tab_abs_2bit, sym_freq_ECSQ_tab_abs_3bit, sym_freq_ECSQ_tab_abs_4bit }; @@ -391,7 +391,7 @@ const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][11] = *-----------------------------------------------------------------------*/ /* Alpha Fine Huffman table df0 */ -static const int16_t huff_nodes_first_band_alpha[32][2] = +static const Word16 huff_nodes_first_band_alpha[32][2] = { { -17, 1 }, { 3, 2 }, @@ -428,7 +428,7 @@ static const int16_t huff_nodes_first_band_alpha[32][2] = }; /* Alpha Fine Huffman table df */ -static const int16_t huff_nodes_alpha_1D_DF[64][2] = +static const Word16 huff_nodes_alpha_1D_DF[64][2] = { { -33, 1 }, { 3, 2 }, @@ -497,7 +497,7 @@ static const int16_t huff_nodes_alpha_1D_DF[64][2] = }; /* Alpha Fine Huffman table dt */ -static const int16_t huff_nodes_alpha_1D_DT[64][2] = +static const Word16 huff_nodes_alpha_1D_DT[64][2] = { { -33, 1 }, { -34, 2 }, @@ -566,19 +566,19 @@ static const int16_t huff_nodes_alpha_1D_DT[64][2] = }; /* Beta Fine Huffman table df0 */ -static const int16_t huff_nodes_first_band_beta[8][2] = +static const Word16 huff_nodes_first_band_beta[8][2] = { { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 }, { -6, 6 }, { -7, 7 }, { -8, -9 } }; /* Beta Fine Huffman table df */ -static const int16_t huff_nodes_beta_1D_DF[16][2] = +static const Word16 huff_nodes_beta_1D_DF[16][2] = { { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { 9, 8 }, { -5, -13 }, { 11, 10 }, { -4, -14 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; /* Beta Fine Huffman table dt */ -static const int16_t huff_nodes_beta_1D_DT[16][2] = +static const Word16 huff_nodes_beta_1D_DT[16][2] = { { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { -13, 8 }, { -5, 9 }, { -14, 10 }, { -4, 11 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 11752380d..84c1a94a0 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -53,7 +53,7 @@ extern const Word16 dft_alpha_s2_b2_fx[STEREO_DFT_BAND_MAX]; extern const Word32 dft_bpf_weights_fx[]; extern const Word32 dft_ap_gains_fx[5][3]; -extern const int16_t dft_ap_delays[3][3]; +extern const Word16 dft_ap_delays[3][3]; extern const Word16 dft_win232ms_8k_fx[75]; extern const Word16 dft_win232ms_12k8_fx[120]; extern const Word16 dft_win232ms_16k_fx[150]; @@ -62,7 +62,7 @@ extern const Word16 dft_win232ms_48k_fx[450]; extern const Word16 dft_res_pred_weights_fx[][STEREO_DFT_BAND_MAX]; extern const Word16 dft_win_8k_fx[70]; -extern const int16_t cna_init_bands[CNA_INIT_NBANDS + 1]; +extern const Word16 cna_init_bands[CNA_INIT_NBANDS + 1]; extern const Word16 min_smooth_gains1_fx[SBA_DIRAC_STEREO_NUM_BANDS]; @@ -74,12 +74,12 @@ extern const Word16 max_smooth_gains2_fx[SBA_DIRAC_STEREO_NUM_BANDS]; * ECLVQ Stereo ROM tables *----------------------------------------------------------------------------------*/ -extern const uint16_t cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT]; -extern const uint16_t sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT]; -extern const uint16_t cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE]; -extern const uint16_t sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE]; -extern const uint16_t *const cum_freq_ECSQ_tab_abs_lsbs[1 + 4]; -extern const uint16_t *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; +extern const UWord16 cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT]; +extern const UWord16 sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT]; +extern const UWord16 cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE]; +extern const UWord16 sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE]; +extern const UWord16 *const cum_freq_ECSQ_tab_abs_lsbs[1 + 4]; +extern const UWord16 *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index d1efbbd2c..bb79b956c 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -49,11 +49,11 @@ #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) /* PLC constants */ -static const int16_t ivas_spar_dec_plc_num_frames_keep = 9; -// static const int16_t ivas_spar_dec_plc_num_frames_fade_out = 9; -static const int16_t ivas_spar_dec_plc_per_frame_ramp_down_gain_dB = 3; -static const int16_t ivas_spar_dec_plc_max_num_frames_ramp_down = 33; -static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0, 0, 0, 0, 0, 0, 0 }; +static const Word16 ivas_spar_dec_plc_num_frames_keep = 9; +// static const Word16 ivas_spar_dec_plc_num_frames_fade_out = 9; +static const Word16 ivas_spar_dec_plc_per_frame_ramp_down_gain_dB = 3; +static const Word16 ivas_spar_dec_plc_max_num_frames_ramp_down = 33; +static const Word16 ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /*------------------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b1522be36..5704f4f60 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -49,14 +49,14 @@ /* State of the range decoder */ typedef struct { - uint32_t rc_low; - uint32_t rc_range; + UWord32 rc_low; + UWord32 rc_range; - uint16_t *bit_buffer; - int16_t bit_count; - int16_t max_allowable_bit_count; + UWord16 *bit_buffer; + Word16 bit_count; + Word16 max_allowable_bit_count; - int16_t bit_error_detected; + Word16 bit_error_detected; } RangeUniDecState; @@ -78,11 +78,11 @@ typedef struct stereo_dft_dec_data_struct STEREO_DFT_CONFIG_DATA_HANDLE hConfig; /*Sizes*/ - int16_t N; /* Size of DFT hop size */ - int16_t NFFT; /* Size of DFT */ + Word16 N; /* Size of DFT hop size */ + Word16 NFFT; /* Size of DFT */ /*FFT*/ - int16_t dft_trigo_step; + Word16 dft_trigo_step; const Word16 *dft_trigo_fx; /* Q15 */ const Word16 *dft_trigo_12k8_fx; /* Q15 */ @@ -90,13 +90,13 @@ typedef struct stereo_dft_dec_data_struct const Word16 *dft_trigo_8k_fx; /* Q15 */ - int16_t dft32ms_ovl; /* Overlap size */ + Word16 dft32ms_ovl; /* Overlap size */ const Word16 *win32ms_fx; /* DFT window */ /* Q15 */ const Word16 *win32ms_12k8_fx; /* DFT window */ /* Q15 */ const Word16 *win32ms_16k_fx; /* DFT window */ /* Q15 */ const Word16 *win32ms_8k_fx; /* DFT window */ /* Q15 */ - int16_t dft32ms_ovl2; /* Overlap2 size */ + Word16 dft32ms_ovl2; /* Overlap2 size */ const Word16 *win232ms_fx; /* DFT window */ /* Q15 */ const Word16 *win232ms_12k8_fx; /* DFT window */ /* Q15 */ const Word16 *win232ms_16k_fx; /* DFT window */ /* Q15 */ @@ -105,31 +105,31 @@ typedef struct stereo_dft_dec_data_struct /*Bands*/ - int16_t band_res[STEREO_DFT_DEC_DFT_NB]; - int16_t band_limits[STEREO_DFT_BAND_MAX + 1]; - int16_t nbands; + Word16 band_res[STEREO_DFT_DEC_DFT_NB]; + Word16 band_limits[STEREO_DFT_BAND_MAX + 1]; + Word16 nbands; /*Configuration*/ - int16_t prm_res[STEREO_DFT_DEC_DFT_NB]; + Word16 prm_res[STEREO_DFT_DEC_DFT_NB]; /*Stereo parameters*/ Word32 side_gain_fx[STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX]; /* Q31 */ - int16_t side_gain_flag_1; - int16_t side_gain_flag_2; - int16_t side_gain_index_previous[STEREO_DFT_BAND_MAX]; - int16_t side_gain_index[STEREO_DFT_BAND_MAX]; + Word16 side_gain_flag_1; + Word16 side_gain_flag_2; + Word16 side_gain_index_previous[STEREO_DFT_BAND_MAX]; + Word16 side_gain_index[STEREO_DFT_BAND_MAX]; Word32 gipd_fx[STEREO_DFT_DEC_DFT_NB]; /* Q27 */ - int16_t no_ipd_flag; /* flag to indicate when no IPD gets used */ + Word16 no_ipd_flag; /* flag to indicate when no IPD gets used */ - int16_t itd_xfade_counter; - int32_t last_active_element_brate; - int16_t ipd_xfade_counter; + Word16 itd_xfade_counter; + Word32 last_active_element_brate; + Word16 ipd_xfade_counter; /*residual prediction*/ - int16_t res_pred_mode[STEREO_DFT_DEC_DFT_NB]; /* residual prediction mode: 0(off), 1(stereo filling only), 2(enhanced stereo filling) */ - Word32 itd_fx[STEREO_DFT_DEC_DFT_NB]; /* Q15 */ + Word16 res_pred_mode[STEREO_DFT_DEC_DFT_NB]; /* residual prediction mode: 0(off), 1(stereo filling only), 2(enhanced stereo filling) */ + Word32 itd_fx[STEREO_DFT_DEC_DFT_NB]; /* Q15 */ Word32 itd_xfade_step_fx; /* Q15 */ Word32 itd_xfade_target_fx; /* Q15 */ @@ -139,19 +139,19 @@ typedef struct stereo_dft_dec_data_struct Word32 ipd_xfade_step_fx; /* Q27 */ Word32 ipd_xfade_prev_fx; /* Q27 */ Word32 res_pred_gain_fx[STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX]; /* prediction gain for the residual HFs */ /* Q31 */ - int16_t res_pred_band_min; /* Band min for prediction of residual */ - int16_t past_DMX_pos; - int16_t res_pred_flag_0; - int16_t res_pred_flag_1; - int16_t res_pred_index_previous[STEREO_DFT_BAND_MAX]; + Word16 res_pred_band_min; /* Band min for prediction of residual */ + Word16 past_DMX_pos; + Word16 res_pred_flag_0; + Word16 res_pred_flag_1; + Word16 res_pred_index_previous[STEREO_DFT_BAND_MAX]; - int16_t reverb_flag; - int16_t nbands_respred; + Word16 reverb_flag; + Word16 nbands_respred; /*residual coding*/ - int16_t res_cod_mode[STEREO_DFT_DEC_DFT_NB]; /* mode from 0 (off) to 3 */ - int16_t res_cod_band_max; /* Band max for coding of residual */ - int16_t res_cod_line_max; + Word16 res_cod_mode[STEREO_DFT_DEC_DFT_NB]; /* mode from 0 (off) to 3 */ + Word16 res_cod_band_max; /* Band max for coding of residual */ + Word16 res_cod_line_max; Word32 DFT_past_DMX_fx[STEREO_DFT_PAST_MAX][STEREO_DFT32MS_N_32k]; /* Past DMX for residual prediction */ /* Q(q_DFT_past_DMX_fx) */ Word32 past_res_pred_gain_fx[STEREO_DFT_PAST_MAX][STEREO_DFT_BAND_MAX]; /* Q31 */ Word32 res_gains_ind_fx[2][2 * STEREO_DFT_BAND_MAX]; /* Q26 */ @@ -171,9 +171,9 @@ typedef struct stereo_dft_dec_data_struct BPF_DEC_HANDLE hBpf; TCX_LTP_DEC_HANDLE hTcxLtpDec; - int16_t trans; - int16_t attackPresent; - int16_t wasTransient; + Word16 trans; + Word16 attackPresent; + Word16 wasTransient; basic_allpass_t ap1, ap2, ap3; @@ -188,9 +188,9 @@ typedef struct stereo_dft_dec_data_struct Word32 ap_fade_mem_fx[STEREO_DFT_ALLPASS_FADELEN_16k]; /* Q(q_ap_fade_mem_fx) */ Word16 q_ap_fade_mem_fx; - int16_t ap_wasTransient; - int16_t core_hist[STEREO_DFT_CORE_HIST_MAX]; - int16_t hb_stefi_delay; + Word16 ap_wasTransient; + Word16 core_hist[STEREO_DFT_CORE_HIST_MAX]; + Word16 hb_stefi_delay; Word32 smooth_dmx_nrg_fx[STEREO_DFT_BAND_MAX]; /* Q(q_smoothed_nrg) */ Word32 smooth_res_nrg_fx[STEREO_DFT_BAND_MAX]; /* Q(q_smoothed_nrg) */ Word32 td_gain_fx[STEREO_DFT_CORE_HIST_MAX]; /* Q(q_td_gain) */ @@ -206,16 +206,16 @@ typedef struct stereo_dft_dec_data_struct /* stereo DTX */ Word16 g_state_fx[STEREO_DFT_BAND_MAX]; /* Q15 */ - int16_t frame_sid_nodata; - int16_t frame_nodata; - int16_t frame_sid; + Word16 frame_sid_nodata; + Word16 frame_nodata; + Word16 frame_sid; Word16 scale_fx; /* Q15 */ /* PLC on residual signal */ - int16_t time_offs; - int16_t sg_mem_corrupt; - int16_t recovery_flg; + Word16 time_offs; + Word16 sg_mem_corrupt; + Word16 recovery_flg; /* PLC on residual signal */ Word32 sg_mean_fx; /* Q31 */ @@ -228,7 +228,7 @@ typedef struct stereo_dft_dec_data_struct Word16 q_hb_nrg_subr; Word16 q_res_mem; - int16_t first_frame; + Word16 first_frame; Word32 mixer_mat_smooth_fx[2][4][2 * IVAS_MAX_NUM_BANDS]; /* Q31 */ Word32 g_L_prev_fx; /* Q31 */ Word32 g_R_prev_fx; /* Q31 */ @@ -257,26 +257,26 @@ typedef struct stereo_dec_cng { Word16 cm_fx[STEREO_DFT_BAND_MAX]; /* cm */ /* Q15 */ Word16 coh_fx[STEREO_DFT_BAND_MAX + 1]; /* coherence */ /* Q15 */ - int16_t first_SID; /* first SID indicator */ - int16_t first_SID_after_TD; /* first SID after TD-stereo indicator */ - int16_t prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ - int16_t last_tdm_idx; /* last tdm index */ + Word16 first_SID; /* first SID indicator */ + Word16 first_SID_after_TD; /* first SID after TD-stereo indicator */ + Word16 prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ + Word16 last_tdm_idx; /* last tdm index */ Word32 c_LR_LT_fx; /* left right cross correlation */ /* Q31 */ - int16_t active_frame_counter; /* counter for active frames */ - int16_t xfade_frame_counter; /* xfade counter */ - int16_t xfade_length; /* number of frames to perform xfade */ - int16_t nr_dft_frames; /* dft frame counter */ - int16_t nr_corr_frames; /* correlation frame counter */ - int16_t nr_sid_frames; /* SID frame counter */ - int16_t last_act_element_mode; /* Element mode of last active frame */ + Word16 active_frame_counter; /* counter for active frames */ + Word16 xfade_frame_counter; /* xfade counter */ + Word16 xfade_length; /* number of frames to perform xfade */ + Word16 nr_dft_frames; /* dft frame counter */ + Word16 nr_corr_frames; /* correlation frame counter */ + Word16 nr_sid_frames; /* SID frame counter */ + Word16 last_act_element_mode; /* Element mode of last active frame */ Word16 olapBufferSynth22_fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ Word32 olapBufferSynth22_32fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ - int16_t flag_cna_fade; /* flag enabling CNA fade out */ + Word16 flag_cna_fade; /* flag enabling CNA fade out */ Word16 maskingNoiseS_fx[L_FRAME16k]; /* masking noise (CNA) for secondary channel */ - int16_t enableSecCNA; /* flag enabling secondary channel CNA */ + Word16 enableSecCNA; /* flag enabling secondary channel CNA */ Word16 c_PS_LT_fx; /* long term cross-correlation between primary and secondary channel */ // Assumed Q15 for initialization. Can be modified later if reqd. - const int16_t *frameSize; /* Frame size in samples */ - const int16_t *fftlen; /* FFT length used for the decomposition */ + const Word16 *frameSize; /* Frame size in samples */ + const Word16 *fftlen; /* FFT length used for the decomposition */ } STEREO_CNG_DEC, *STEREO_CNG_DEC_HANDLE; @@ -287,18 +287,18 @@ typedef struct stereo_dec_cng typedef struct stereo_td_dec_data_structure { - int16_t tdm_last_ratio_idx; /* last TDM ratio index */ - int16_t tdm_last_SM_flag; /* last channel combination scheme flag */ - int16_t tdm_prev_last_SM_flag; /* channel combination scheme flag before last frame */ - int16_t tdm_SM_flag; /* current channel combination scheme flag */ - int16_t tdm_use_IAWB_Ave_lpc; /* Flag to indicate the usage of mean inactive LP coefficients */ - - int16_t tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ - int16_t tdm_low_rate_mode; /* secondary channel low rate mode flag */ + Word16 tdm_last_ratio_idx; /* last TDM ratio index */ + Word16 tdm_last_SM_flag; /* last channel combination scheme flag */ + Word16 tdm_prev_last_SM_flag; /* channel combination scheme flag before last frame */ + Word16 tdm_SM_flag; /* current channel combination scheme flag */ + Word16 tdm_use_IAWB_Ave_lpc; /* Flag to indicate the usage of mean inactive LP coefficients */ + + Word16 tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ + Word16 tdm_low_rate_mode; /* secondary channel low rate mode flag */ Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; - int16_t tdm_Pitch_reuse_flag; - int16_t tdm_LRTD_flag; - int16_t flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */ + Word16 tdm_Pitch_reuse_flag; + Word16 tdm_LRTD_flag; + Word16 flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */ Word32 TCX_old_syn_Overl_fx[L_FRAME16k / 2]; /* past ovrl buffer for possible switching from TD stereo ACELP to MDCT stereo TCX frame */ /* Q11 */ Word16 prevSP_ratio_fx; /* previous SP ratio */ @@ -320,24 +320,24 @@ typedef struct stereo_mdct_dec_data_structure STEREO_MDCT_BAND_PARAMETERS stbParamsTCX20afterACELP; /* stereo frequency band parameters for transition frame */ /* only intraframe */ - int16_t mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */ - int16_t global_ild[2]; /* Quantized ILD for the whole spectrum */ - int16_t split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */ + Word16 mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */ + Word16 global_ild[2]; /* Quantized ILD for the whole spectrum */ + Word16 split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */ - int16_t IGFStereoMode[2]; /* MDCT stereo mode for IGF */ + Word16 IGFStereoMode[2]; /* MDCT stereo mode for IGF */ - int16_t use_itd; - int16_t itd_mode; /*0/1*/ - Word32 itd_fx; /* Q15 */ + Word16 use_itd; + Word16 itd_mode; /*0/1*/ + Word32 itd_fx; /* Q15 */ - int16_t reverse_dmx; + Word16 reverse_dmx; Word32 smooth_ratio_fx; /* Q26 */ - int16_t prev_ms_mask[NB_DIV][MAX_SFB]; + Word16 prev_ms_mask[NB_DIV][MAX_SFB]; Word16 lastCoh_fx; /* Q14 */ - int16_t noise_seeds_channels[CPE_CHANNELS]; - int16_t noise_seed_common; - int16_t isSBAStereoMode; + Word16 noise_seeds_channels[CPE_CHANNELS]; + Word16 noise_seed_common; + Word16 isSBAStereoMode; } STEREO_MDCT_DEC_DATA, *STEREO_MDCT_DEC_DATA_HANDLE; @@ -348,18 +348,18 @@ typedef struct stereo_mdct_dec_data_structure typedef struct stereo_tca_dec_data_structure { - int16_t refChanIndx; /* reference channel index in current frame */ - int16_t prevRefChanIndx; /* reference channel index in previous frame */ - int16_t indx_ica_NCShift; /* ICA target channel inter-channel corrstats */ - int16_t indx_ica_gD; /* ICA target gain */ + Word16 refChanIndx; /* reference channel index in current frame */ + Word16 prevRefChanIndx; /* reference channel index in previous frame */ + Word16 indx_ica_NCShift; /* ICA target channel inter-channel corrstats */ + Word16 indx_ica_gD; /* ICA target gain */ Word32 targetGain_fx; /* gain norm applied on target (or right) channel in current frame */ // Q29 Word32 prevTargetGain_fx; /* gain norm applied on target (or right) channel in previous frame */ // Q29 - int16_t corrLagStats; /* corr lag stats in current frame */ - int16_t prevCorrLagStats; /* corr lag stats in previous frame */ + Word16 corrLagStats; /* corr lag stats in current frame */ + Word16 prevCorrLagStats; /* corr lag stats in previous frame */ - int16_t interp_dec_prevNCShift; /* NC Shift in previous frame */ - int16_t interp_dec_switch_to_zero_diff; /* switch flag for interpolation */ + Word16 interp_dec_prevNCShift; /* NC Shift in previous frame */ + Word16 interp_dec_switch_to_zero_diff; /* switch flag for interpolation */ Word32 memChanL_fx[L_DEC_MEM_LEN_ICA]; /* left channel input to correct at the cross-over for Fixed */ @@ -428,10 +428,10 @@ typedef struct stereo_icbwe_dec_data_structure typedef struct { - int16_t dtx_flag; - int16_t sce_id_dtx; + Word16 dtx_flag; + Word16 sce_id_dtx; - int16_t ism_dtx_hangover_cnt; /* hangover counter for ISM DTX decoder */ + Word16 ism_dtx_hangover_cnt; /* hangover counter for ISM DTX decoder */ } ISM_DTX_DATA_DEC; @@ -478,9 +478,9 @@ typedef struct ivas_dirac_dec_data_structure { DIRAC_CONFIG_DATA_HANDLE hConfig; - int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; - int16_t dithering_seed; - int16_t spar_to_dirac_write_idx; + Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; + Word16 dithering_seed; + Word16 spar_to_dirac_write_idx; IVAS_FB_MIXER_HANDLE hFbMdft; @@ -521,10 +521,10 @@ typedef struct dirac_output_synthesis_cov_state_structure typedef struct ivas_param_mc_diff_proto_info_structure { - int16_t num_protos_diff; - int16_t *proto_index_diff; - int16_t *num_source_chan_diff; - int16_t **source_chan_idx; + Word16 num_protos_diff; + Word16 *proto_index_diff; + Word16 *num_source_chan_diff; + Word16 **source_chan_idx; Word32 **proto_fac_fx; } PARAM_MC_DIFF_PROTO_INFO; @@ -532,42 +532,42 @@ typedef struct ivas_param_mc_diff_proto_info_structure typedef struct ivas_param_mc_dec_data_structure { - int16_t slot_size; + Word16 slot_size; Word32 *Cldfb_RealBuffer_tc_fx; // Q12 Word16 Cldfb_RealBuffer_tc_e; Word32 *Cldfb_ImagBuffer_tc_fx; // Q12 Word16 Cldfb_ImagBuffer_tc_e; Word16 sz; - int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; - int16_t nb_subframes; - int16_t subframes_rendered; - int16_t slots_rendered; - int16_t num_slots; - int16_t num_freq_bands; - int16_t num_param_bands_synth; + Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; + Word16 nb_subframes; + Word16 subframes_rendered; + Word16 slots_rendered; + Word16 num_slots; + Word16 num_freq_bands; + Word16 num_param_bands_synth; - int16_t band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1]; + Word16 band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1]; /*Decoder parameters */ /*Prototypes*/ - int16_t num_outputs_diff; + Word16 num_outputs_diff; PARAM_MC_DIFF_PROTO_INFO *diff_proto_info; PARAM_MC_SYNTHESIS_CONF synthesis_conf; /*Options*/ /* Decorrelator options */ - int16_t max_band_decorr; + Word16 max_band_decorr; /*Decoder states=memories*/ Word32 *proto_frame_f_fx; /* Q11 */ Word32 *proto_frame_dec_f_fx; /* Q11 */ DIRAC_OUTPUT_SYNTHESIS_COV_STATE h_output_synthesis_cov_state; DIRAC_OUTPUT_SYNTHESIS_PARAMS h_output_synthesis_params; - int16_t max_band_energy_compensation; + Word16 max_band_energy_compensation; HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC; Word16 *icc_q_fx; /* ICC parameters*/ /* Q15 */ Word16 *icld_q_fx; /* Q8 */ - int16_t max_param_band_abs_cov; + Word16 max_param_band_abs_cov; Word16 q_proto_frame_f; Word32 *ls_conv_dmx_matrix_fx; /* Q30 */ Word32 *proto_matrix_int_fx; @@ -588,12 +588,12 @@ typedef struct ivas_param_mc_dec_data_structure typedef struct ivas_mc_paramupmix_dec_data_structure { - int16_t num_freq_bands; + Word16 num_freq_bands; ivas_td_decorr_state_t *hTdDecorr[MC_PARAMUPMIX_COMBINATIONS]; - int32_t alpha_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; - int32_t beta_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; - int16_t first_frame; - int16_t free_param_interpolator; + Word32 alpha_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; + Word32 beta_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; + Word16 first_frame; + Word16 free_param_interpolator; Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // Q28 @@ -627,30 +627,30 @@ typedef struct ivas_spar_md_dec_state_t ivas_spar_dec_matrices_t spar_coeffs; ivas_spar_dec_matrices_t spar_coeffs_prev; ivas_spar_dec_matrices_t spar_coeffs_tar; - int16_t dtx_md_smoothing_cntr; - int16_t valid_bands[IVAS_MAX_NUM_BANDS]; - int16_t base_band_age[IVAS_MAX_NUM_BANDS]; - int16_t spar_plc_num_lost_frames; - int16_t num_decorr; - int16_t td_decorr_flag; - int16_t spar_plc_enable_fadeout_flag; + Word16 dtx_md_smoothing_cntr; + Word16 valid_bands[IVAS_MAX_NUM_BANDS]; + Word16 base_band_age[IVAS_MAX_NUM_BANDS]; + Word16 spar_plc_num_lost_frames; + Word16 num_decorr; + Word16 td_decorr_flag; + Word16 spar_plc_enable_fadeout_flag; Word32 ***mixer_mat_fx; /* Q(Q_mixer_mat) */ Word32 mixer_mat_prev_fx[MAX_PARAM_SPATIAL_SUBFRAMES + 1][IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS]; /* Q(Q_mixer_mat) */ Word16 Q_mixer_mat; ivas_spar_md_com_cfg spar_md_cfg; ivas_arith_coeffs_t arith_coeffs; ivas_huff_coeffs_t huff_coeffs; - int16_t table_idx; - int16_t dtx_vad; - int16_t spar_hoa_md_flag; - int16_t spar_hoa_dirac2spar_md_flag; - int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]; + Word16 table_idx; + Word16 dtx_vad; + Word16 spar_hoa_md_flag; + Word16 spar_hoa_dirac2spar_md_flag; + Word16 HOA_md_ind[IVAS_SPAR_MAX_CH]; Word32 smooth_buf_fx[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q0 */ Word16 smooth_fac_fx[IVAS_MAX_NUM_BANDS]; /* Q15 */ Word32 mixer_mat_prev2_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; /* Q(Q_mixer_mat) */ - int16_t first_valid_frame; + Word16 first_valid_frame; ivas_band_coeffs_t *band_coeffs_prev; - int16_t base_band_coeffs_age[IVAS_MAX_NUM_BANDS]; + Word16 base_band_coeffs_age[IVAS_MAX_NUM_BANDS]; } ivas_spar_md_dec_state_t; @@ -676,11 +676,11 @@ typedef struct { Word16 prev_ql_fx[IVAS_PCA_INTERP]; Word16 prev_qr_fx[IVAS_PCA_INTERP]; - int16_t prev_pca_bypass; + Word16 prev_pca_bypass; Word16 mem_eigVec_interp_fx[IVAS_PCA_LEN_INTERP_EIG_DEC]; /* parser output: */ - int16_t pca_bypass; - int32_t index[2]; + Word16 pca_bypass; + Word32 index[2]; } PCA_DEC_STATE; @@ -690,20 +690,20 @@ typedef struct ivas_spar_dec_lib_t ivas_td_decorr_state_t *hTdDecorr; ivas_spar_md_dec_state_t *hMdDec; IVAS_FB_MIXER_HANDLE hFbMixer; - int16_t AGC_flag; + Word16 AGC_flag; ivas_agc_dec_state_t *hAgcDec; PCA_DEC_STATE *hPCA; - int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; - int16_t enc_param_start_band; - int32_t core_nominal_brate; /* Nominal bitrate for core coding */ - int16_t i_subframe; - - int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; - int16_t render_to_md_map[MAX_JBM_CLDFB_TIMESLOTS]; - int16_t nb_subframes; - int16_t subframes_rendered; - int16_t slots_rendered; - int16_t num_slots; + Word16 dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; + Word16 enc_param_start_band; + Word32 core_nominal_brate; /* Nominal bitrate for core coding */ + Word16 i_subframe; + + Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; + Word16 render_to_md_map[MAX_JBM_CLDFB_TIMESLOTS]; + Word16 nb_subframes; + Word16 subframes_rendered; + Word16 slots_rendered; + Word16 num_slots; } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; @@ -712,8 +712,8 @@ typedef struct ivas_spar_dec_lib_t typedef struct ivas_osba_data { Word32 **delayBuffer_fx; - int16_t delayBuffer_size; - int16_t delayBuffer_nchan; + Word16 delayBuffer_size; + Word16 delayBuffer_nchan; } SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; @@ -724,9 +724,9 @@ typedef struct ivas_osba_data typedef struct sce_dec_data_structure { - int16_t sce_id; /* SCE # identifier */ - int32_t element_brate; /* SCE total bitrate in bps */ - int32_t last_element_brate; /* SCE last total bitrate in bps */ + Word16 sce_id; /* SCE # identifier */ + Word32 element_brate; /* SCE total bitrate in bps */ + Word32 last_element_brate; /* SCE last total bitrate in bps */ /* core coder handle */ DEC_CORE_HANDLE hCoreCoder[1]; @@ -747,15 +747,15 @@ typedef struct sce_dec_data_structure typedef struct cpe_dec_data_structure { - int16_t cpe_id; /* CPE # identifier */ - int32_t element_brate; /* CPE element total bitrate in bps */ - int32_t last_element_brate; /* last CPE element total bitrate in bps */ + Word16 cpe_id; /* CPE # identifier */ + Word32 element_brate; /* CPE element total bitrate in bps */ + Word32 last_element_brate; /* last CPE element total bitrate in bps */ - int16_t element_mode; /* element mode, in CPE it can be IVAS_CPE_DFT, IVAS_CPE_TD or IVAS_CPE_MDCT */ - int16_t last_element_mode; /* last element mode */ + Word16 element_mode; /* element mode, in CPE it can be IVAS_CPE_DFT, IVAS_CPE_TD or IVAS_CPE_MDCT */ + Word16 last_element_mode; /* last element mode */ - int16_t stereo_switching_counter; - int16_t NbFrameMod; + Word16 stereo_switching_counter; + Word16 NbFrameMod; /* core coder handle */ DEC_CORE_HANDLE hCoreCoder[CPE_CHANNELS]; @@ -768,7 +768,7 @@ typedef struct cpe_dec_data_structure STEREO_ICBWE_DEC_HANDLE hStereoICBWE; /* Stereo inter-channel BWE data handle */ STEREO_CNG_DEC_HANDLE hStereoCng; /* Stereo CNG data structure */ - int16_t nchan_out; /* number of output channels (1: mono dmx, 2: default stereo) */ + Word16 nchan_out; /* number of output channels (1: mono dmx, 2: default stereo) */ /* DFT stereo I/O channel buffer memories that need to be updated for TD->DFT stereo switching */ @@ -792,7 +792,7 @@ typedef struct cpe_dec_data_structure /* buffers used for fading between MDCT and DFT Stereo */ - int32_t brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */ + Word32 brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */ } CPE_DEC_DATA, *CPE_DEC_HANDLE; @@ -803,8 +803,8 @@ typedef struct cpe_dec_data_structure typedef struct mct_dec_block_data_struct { - int16_t ch1, ch2; - int16_t mask[2][MAX_SFB]; + Word16 ch1, ch2; + Word16 mask[2][MAX_SFB]; STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; /* MDCT stereo data handle */ } MCT_DEC_BLOCK_DATA, *MCT_DEC_BLOCK_DATA_HANDLE; @@ -812,14 +812,14 @@ typedef struct mct_dec_block_data_struct typedef struct mct_dec_data_structure { - int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */ - int16_t currBlockDataCnt; - int16_t bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */ + Word16 nchan_out_woLFE; /* number of active channels within multi-channel configuration */ + Word16 currBlockDataCnt; + Word16 bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */ MCT_DEC_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS]; - int16_t chBitRatios[MCT_MAX_CHANNELS]; - int16_t lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ - uint16_t mc_global_ild[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ + Word16 chBitRatios[MCT_MAX_CHANNELS]; + Word16 lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ + UWord16 mc_global_ild[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ } MCT_DEC_DATA, *MCT_DEC_HANDLE; @@ -866,12 +866,12 @@ typedef struct ivas_binaural_rendering_struct IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ EFAP_HANDLE hEFAPdata; /* EFAP structure*/ Word32 *hoa_dec_mtx; /* pointer to HOA decoder mtx */ /*Q29*/ - int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ - int16_t max_band; /* band upto which rendering is performed */ - int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ - int16_t timeSlots; /* number of time slots of binaural renderer */ - int16_t nInChannels; /* number input channels */ - int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + Word8 rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + Word16 max_band; /* band upto which rendering is performed */ + Word16 conv_band; /* band upto which convolution in cldfb domain is performed */ + Word16 timeSlots; /* number of time slots of binaural renderer */ + Word16 nInChannels; /* number input channels */ + Word8 render_lfe; /* Flag to render LFE in binaural rendering*/ IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ /* Convolution module structure */ @@ -892,18 +892,18 @@ typedef struct ivas_masa_decoder_ext_out_meta_struct { MASA_DECRIPTIVE_META descriptiveMeta; - uint16_t directionIndex[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t spreadCoherence[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord16 directionIndex[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 spreadCoherence[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t surroundCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t diffuseToTotalRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 surroundCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 diffuseToTotalRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_DECODER_EXT_OUT_META; typedef struct ivas_masa_decoder_data_struct { - int16_t band_mapping[MASA_FREQUENCY_BANDS + 1]; + Word16 band_mapping[MASA_FREQUENCY_BANDS + 1]; SPHERICAL_GRID_DATA *sph_grid16; MASA_DECODER_EXT_OUT_META *extOutMeta; @@ -922,32 +922,32 @@ typedef struct ivas_masa_decoder_struct /* Data structure for MASA_ISM rendering */ typedef struct ivas_masa_ism_data_structure { - int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; /* Q30 */ Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ - int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; - int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; - uint8_t ism_is_edited[MAX_NUM_OBJECTS]; + Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; + Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; + UWord8 ism_is_edited[MAX_NUM_OBJECTS]; - int16_t idx_separated_ism; - int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 idx_separated_ism; + Word16 azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word32 q_azimuth_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ - uint8_t objectsMoved; + UWord8 objectsMoved; Word32 eneMoveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; /*Q-22*/ Word32 enePreserveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; /*Q-22*/ Word32 preprocEneTarget_fx[CLDFB_NO_CHANNELS_MAX]; /*Q-19*/ Word32 preprocEneRealized_fx[CLDFB_NO_CHANNELS_MAX]; /*Q-19*/ Word32 **delayBuffer_fx; /* Q11 */ - int16_t delayBuffer_size; - int16_t delayBuffer_nchan; + Word16 delayBuffer_size; + Word16 delayBuffer_nchan; } MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; @@ -965,41 +965,41 @@ typedef struct decoder_tc_buffer_structure Word16 no_channels; /*Stores no of channels in tc_fx with values*/ #endif Word16 q_tc_fx; - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ - int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - int16_t nchan_buffer_full; /* number of channels to be fully buffered */ - int16_t n_samples_available; /* samples still available for rendering in the current frame */ - int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - int16_t n_samples_rendered; /* samples already rendered in the current frame */ - int16_t n_samples_granularity; /* render granularity */ - int16_t n_samples_flushed; - int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; - int16_t nb_subframes; - int16_t subframes_rendered; - int16_t slots_rendered; - int16_t num_slots; - int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + Word16 nchan_transport_jbm; /* number of TCs after TC decoding */ + Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + Word16 nchan_buffer_full; /* number of channels to be fully buffered */ + Word16 n_samples_available; /* samples still available for rendering in the current frame */ + Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + Word16 n_samples_rendered; /* samples already rendered in the current frame */ + Word16 n_samples_granularity; /* render granularity */ + Word16 n_samples_flushed; + Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; + Word16 nb_subframes; + Word16 subframes_rendered; + Word16 slots_rendered; + Word16 num_slots; + Word16 n_samples_discard; /* number of samples to discard from the beginning of the output */ } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; typedef struct jbm_metadata_structure { - int16_t sf_write_idx; - int16_t sf_md_buffer_length; + Word16 sf_write_idx; + Word16 sf_md_buffer_length; - uint16_t directionIndexBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t directToTotalRatioBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t spreadCoherenceBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t surroundCoherenceBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t diffuseToTotalRatioBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t numberOfDirections[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES]; /* Descriptive metadata, value is 0 or 1 */ + UWord16 directionIndexBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 directToTotalRatioBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 spreadCoherenceBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 surroundCoherenceBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 diffuseToTotalRatioBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 numberOfDirections[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES]; /* Descriptive metadata, value is 0 or 1 */ - int16_t slot_read_idx; - int16_t slot_write_idx; - int16_t slot_md_buffer_length; + Word16 slot_read_idx; + Word16 slot_write_idx; + Word16 slot_md_buffer_length; - int16_t sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME * MASA_JBM_RINGBUFFER_FRAMES]; + Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME * MASA_JBM_RINGBUFFER_FRAMES]; } JBM_METADATA, *JBM_METADATA_HANDLE; @@ -1010,25 +1010,25 @@ typedef struct jbm_metadata_structure typedef struct decoder_config_structure { - int32_t ivas_total_brate; /* IVAS total bitrate in bps */ - int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ - int32_t output_Fs; /* output signal sampling frequency in Hz */ - int16_t nchan_out; /* number of output audio channels */ + Word32 ivas_total_brate; /* IVAS total bitrate in bps */ + Word32 last_ivas_total_brate; /* last IVAS total bitrate in bps */ + Word32 output_Fs; /* output signal sampling frequency in Hz */ + Word16 nchan_out; /* number of output audio channels */ AUDIO_CONFIG output_config; /* output audio configuration */ - int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ - int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + Word16 Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ + Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ + Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ + Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ + Word16 Opt_non_diegetic_pan; /* indicates diegetic or not */ Word16 non_diegetic_pan_gain_fx; /* non diegetic panning gain*/ /* Q15 */ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ - int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ - int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ - int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ + Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + Word16 Opt_ExternalOrientation; /* indiates whether external orientations are used */ + Word16 Opt_dpid_on; /* indicates whether Directivity pattern option is used */ + Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */ + Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; - int16_t Opt_delay_comp; /* flag indicating delay compensation active */ + Word16 Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; @@ -1047,8 +1047,8 @@ typedef struct Decoder_Struct IVAS_FORMAT ivas_format; /* IVAS format */ IVAS_FORMAT last_ivas_format; /* last frame IVAS format */ - int16_t sid_format; /* IVAS format indicator from SID frame */ - int16_t nchan_transport; /* number of transport channels */ + Word16 sid_format; /* IVAS format indicator from SID frame */ + Word16 nchan_transport; /* number of transport channels */ IVAS_OUTPUT_SETUP hOutSetup; /* output setup structure */ AUDIO_CONFIG intern_config; /* internal audio configuration */ IVAS_OUTPUT_SETUP hIntSetup; /* internal setup structure */ @@ -1056,24 +1056,24 @@ typedef struct Decoder_Struct AUDIO_CONFIG transport_config; /* transport audio configuration */ IVAS_OUTPUT_SETUP hTransSetup; /* transport setup structure */ - int16_t element_mode_init; /* element mode used at initialization */ - int16_t codec_mode; /* Mode 1 or 2 */ - int16_t ini_frame; /* initialization frames counter */ - int16_t ini_active_frame; /* initialization active frames counter */ + Word16 element_mode_init; /* element mode used at initialization */ + Word16 codec_mode; /* Mode 1 or 2 */ + Word16 ini_frame; /* initialization frames counter */ + Word16 ini_active_frame; /* initialization active frames counter */ - int16_t bfi; /* FEC - bad frame indicator */ - int16_t BER_detect; /* BER detect flag */ - int16_t num_bits; /* BER detect flag */ + Word16 bfi; /* FEC - bad frame indicator */ + Word16 BER_detect; /* BER detect flag */ + Word16 num_bits; /* BER detect flag */ - uint16_t *bit_stream; /* Pointer to bitstream buffer */ - int16_t writeFECoffset; /* parameter for debugging JBM stuff */ + UWord16 *bit_stream; /* Pointer to bitstream buffer */ + Word16 writeFECoffset; /* parameter for debugging JBM stuff */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ /* core-decoder modules */ - int16_t nSCE; /* number of total SCEs */ - int16_t nCPE; /* number of total CPEs */ - int16_t nCPE_old; /* number of total CPEs available in the last frame before bitrate switching */ + Word16 nSCE; /* number of total SCEs */ + Word16 nCPE; /* number of total CPEs */ + Word16 nCPE_old; /* number of total CPEs available in the last frame before bitrate switching */ SCE_DEC_HANDLE hSCE[MAX_SCE]; /* SCE handles */ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS]; /* CPE handles */ @@ -1092,12 +1092,12 @@ typedef struct Decoder_Struct LFE_DEC_HANDLE hLFE; /* LFE handle */ ISM_MODE ism_mode; /* ISM format mode */ - int16_t nchan_ism; /* number of ISM channels */ + Word16 nchan_ism; /* number of ISM channels */ MC_MODE mc_mode; /* MC format mode */ - int16_t sba_order; /* Ambisonic (SBA) order */ - int16_t sba_planar; /* Ambisonic (SBA) planar flag */ - int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ - int16_t sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ + Word16 sba_order; /* Ambisonic (SBA) order */ + Word16 sba_planar; /* Ambisonic (SBA) planar flag */ + Word16 sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ + Word16 sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ /* rendering modules */ RENDERER_TYPE renderer_type; /* renderer type */ @@ -1120,7 +1120,7 @@ typedef struct Decoder_Struct Word32 *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ - int32_t binaural_latency_ns; /* Binauralization latency in ns */ + Word32 binaural_latency_ns; /* Binauralization latency in ns */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData; /* External orientation data structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */ DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ @@ -1128,16 +1128,16 @@ typedef struct Decoder_Struct MASA_ISM_DATA_HANDLE hMasaIsmData; /* OMASA rendering handle */ SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ - int16_t flag_omasa_brate; + Word16 flag_omasa_brate; /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ - int32_t last_active_ivas_total_brate; - int16_t ism_extmeta_active; /* Extended metadata active in decoder */ - int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ + Word32 last_active_ivas_total_brate; + Word16 ism_extmeta_active; /* Extended metadata active in decoder */ + Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ Word32 **mem_hp20_out_fx; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ Word16 p_out_len;/*Stores the total no of channels for which memory is allocated to p_output_fx*/ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 2dd2a30c3..e5e18083d 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -2078,7 +2078,7 @@ void stereo_td2dft_update_fx( ) { Word16 ovl, ovl_TCX, dft32ms_ovl, hq_delay_comp; - Word16 ns, nsLB; + Word16 ns, nsLB, i; Word16 old_out_len, old_outLB_len; Decoder_State **sts; @@ -2181,9 +2181,9 @@ void stereo_td2dft_update_fx( v_add_fx( sts[0]->hHQ_core->old_outLB_fx + nsLB, sts[1]->hHQ_core->old_outLB_fx + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); #ifndef MSAN_FIX - for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) + for ( i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) #else - FOR( Word32 i = 0; i < old_outLB_len; i++ ) + FOR( i = 0; i < old_outLB_len; i++ ) #endif { hCPE->old_outLB_mdct_fx[i] = L_shr( hCPE->old_outLB_mdct_fx[i], 1 ); /* Q11 */ @@ -2193,7 +2193,7 @@ void stereo_td2dft_update_fx( #ifndef MSAN_FIX for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) #else - FOR( Word32 i = 0; i < old_out_len; i++ ) + FOR( i = 0; i < old_out_len; i++ ) #endif { hCPE->old_out_mdct_fx[i] = L_shr( hCPE->old_out_mdct_fx[i], 1 ); /* q_old_out_mdct */ diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index bb73fe7f0..375dbdad0 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -306,7 +306,6 @@ Word16 svd_fx( Word16 iCh, jCh; Word16 lengthSingularValues; Word16 errorMessage, condition; - // int16_t max_length = ((nChannelsL > nChannelsC) ? nChannelsL : nChannelsC); Word32 secDiag_fx[MAX_OUTPUT_CHANNELS]; #ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE Word16 secDiag_fx_e = 0; diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index 939fad2cb..5b5ff16c5 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -67,7 +67,7 @@ struct JB4_DATAUNIT Word16 qBit; /** the binary encoded access unit */ - uint8_t *data; + UWord8 *data; /** the size of the binary encoded access unit [bits] */ UWord16 dataSize; diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 1fe7481df..7955d0ea6 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -92,7 +92,7 @@ typedef struct apa_state_t *PCMDSP_APA_HANDLE; /*! Allocates memory for state struct and initializes elements. * @return 0 on success, 1 on failure */ ivas_error apa_init( apa_state_t **s, - const int32_t num_channels ); + const Word32 num_channels ); /*! Sets state variables to initial value. */ void apa_reset( apa_state_t *s ); @@ -106,7 +106,7 @@ void apa_reset( apa_state_t *s ); * @param[in] output_Fs sample rate [Hz] * @param[in] num_channels number of channels * @return 0 on success, 1 on failure */ -bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs ); +bool apa_set_rate( apa_state_t *ps, const Word32 output_Fs ); /*! Set scaling. * The scale is given in % and will be valid until changed again. @@ -120,7 +120,7 @@ bool apa_set_renderer_residual_samples( apa_state_t *ps, UWord16 l_r_buf ); bool apa_set_evs_compat_mode( apa_state_t *ps, bool mode ); -uint8_t apa_reconfigure( apa_state_t *ps, uint16_t num_channels, uint16_t l_ts ); +UWord8 apa_reconfigure( apa_state_t *ps, UWord16 num_channels, UWord16 l_ts ); bool apa_set_complexity_options( apa_state_t *s, UWord16 wss, UWord16 css ); @@ -129,5 +129,5 @@ bool apa_set_quality( apa_state_t *s, Word32 quality, UWord16 qualityred, UWord1 bool apa_exit( apa_state_t **s ); UWord8 apa_exec_ivas_fx( apa_state_t *s, const Word32 a_in[], UWord16 l_in, UWord16 maxScaling, Word32 a_out[], UWord16 *l_out ); -uint8_t apa_exec_fx( apa_state_t *s, const Word16 a_in[], UWord16 l_in, UWord16 maxScaling, Word16 a_out[], UWord16 *l_out ); +UWord8 apa_exec_fx( apa_state_t *s, const Word16 a_in[], UWord16 l_in, UWord16 maxScaling, Word16 a_out[], UWord16 *l_out ); #endif /* JBM_PCMDSP_APA_H */ diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index 3551380de..1d193433e 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -52,7 +52,7 @@ * <------> * n */ -void hannWindow( uint16_t n, float *w ); +void hannWindow( UWord16 n, float *w ); /** Overlap/Add of two signal with a given window. */ /** @param[in] fadeOut signal to fade out diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 5a3aec3f4..976826949 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -612,7 +612,7 @@ void amr_wb_enc_init_fx( AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */ ) { - int16_t i; + Word16 i; /* HF (6-7kHz) BWE */ hAmrwb_IO->seed2_enc = RANDOM_INITSEED; diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 93a0146f3..962b715cd 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -519,7 +519,7 @@ void AVQ_encmux_fx( bit_tmp = add( unusedbitsFlag, unused_bits_idx ); /*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/ nq_est = mult( 6554, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) ); - assert( (int16_t) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); + assert( (Word16) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); if ( EQ_16( nq_est, 1 ) ) { @@ -946,7 +946,7 @@ void AVQ_encmux_ivas_fx( bit_tmp = add( unusedbitsFlag, unused_bits_idx ); /*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/ nq_est = mult( 6554 /*.2 in Q15*/, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) ); - assert( (int16_t) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); + assert( (Word16) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); if ( EQ_16( nq_est, 1 ) ) { @@ -1085,8 +1085,8 @@ static void wrte_cv( Word16 *nbits /* i/o: bits */ ) { - int16_t pos, j; - int16_t bits, nq4; + Word16 pos, j; + Word16 bits, nq4; bits = *nbits; move16(); @@ -1145,8 +1145,8 @@ static void wrte_cv_ivas_fx( Word16 *nbits /* i/o: bits */ ) { - int16_t pos, j; - int16_t bits, nq4; + Word16 pos, j; + Word16 bits, nq4; bits = *nbits; move16(); diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index a2995245d..1c60f2ecd 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -30,8 +30,8 @@ static void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, co static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); static void init_core_sig_ana_ivas_fx( Encoder_State *st ); static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate ); +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate ); /*-----------------------------------------------------------------------* * init_coder_ace_plus_fx() @@ -1324,7 +1324,7 @@ static void init_tcx_ivas_fx( * Initialization of signal buffers *-----------------------------------------------------------------------*/ /*copy of evs function since it was static */ -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate ) { LPD_state_HANDLE hLPDmem = st->hLPDmem; @@ -1542,7 +1542,7 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st ) * * *-----------------------------------------------------------------------*/ -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate ) { Word16 mem_syn_r_size_old; Word16 mem_syn_r_size_new; diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c index 3637dd53f..1ba496b0e 100644 --- a/lib_enc/core_enc_reconf_fx.c +++ b/lib_enc/core_enc_reconf_fx.c @@ -344,7 +344,7 @@ void core_coder_reconfig_fx( void core_coder_reconfig_ivas_fx( Encoder_State *st, - const int32_t last_total_brate ) + const Word32 last_total_brate ) { Word16 i, bwidth, index; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 7dd342318..a509a7cd7 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1761,7 +1761,7 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const int16_t cmpl_flag /*Q0*/ ) + const Word16 cmpl_flag /*Q0*/ ) { PulseConfig config; Word16 ind[NPMAXPT * 4]; @@ -1824,7 +1824,7 @@ void E_ACELP_4t_ivas_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const int16_t cmpl_flag, /*Q0*/ + const Word16 cmpl_flag, /*Q0*/ Word16 element_mode /*Q0*/ ) { PulseConfig config; diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index a36ee78e2..4305e5bca 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -216,7 +216,7 @@ ivas_error ivas_ism_metadata_enc_fx( move16(); Word32 valQ_fx; ISM_METADATA_HANDLE hIsmMetaData; - int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; + Word32 element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; Word16 ism_metadata_flag_global; Word16 non_diegetic_flag_global; Word16 ism_imp[MAX_NUM_OBJECTS]; diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index bb6ef0d01..c4d3908ca 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -574,7 +574,7 @@ ivas_error ivas_mcmasa_enc_reconfig_fx( void ivas_mcmasa_enc_close_fx( MCMASA_ENC_HANDLE *hMcMasa, /* i/o: encoder McMASA handle */ - const int32_t input_Fs /* i : input sampling rate */ + const Word32 input_Fs /* i : input sampling rate */ ) { Word16 i, j; diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 55da30e73..d6bc4c7f0 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -421,7 +421,7 @@ ivas_error ivas_mct_enc_fx( } /* joint MCT encoding */ - ivas_mct_core_enc_fx( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE, ivas_total_brate, switch_bw, ( ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); + ivas_mct_core_enc_fx( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE, ivas_total_brate, switch_bw, ( ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) ? (Word16) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 403d379fa..70b2b0034 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -799,7 +799,7 @@ static void applyStereoPreProcessingCplx( * * encoder-side complex-valued stereo pre-processing (crosstalk) *---------------------------------------------------------------*/ -static uint16_t enc_ste_pre_mdct( +static UWord16 enc_ste_pre_mdct( Word32 *sigR0_fx, /* i/o: MDCT samples of the 1st (left) channel q_com*/ Word32 *sigR1_fx, /* i/o: MDCT samples of the 2nd (right) channel q_com*/ Word32 *sigI0_fx, /* i/o: MDST samples of the 1st (left) channel q_com*/ diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3416ab279..b32c80404 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -160,7 +160,7 @@ static Word16 encode_coherence_indexesDCT1_fx( BSTR_ENC_HANDLE hMetaData /* i : metadata handle */ ); -static UWord64 create_combined_index_fx( uint16_t *idx_dct, const Word16 len, const Word16 *no_cb_vec ); +static UWord64 create_combined_index_fx( UWord16 *idx_dct, const Word16 len, const Word16 *no_cb_vec ); static Word16 encode_surround_coherence_fx( IVAS_QMETADATA *hQMetaData, /* i : quantized metadata */ @@ -184,7 +184,7 @@ static void ivas_diffuseness_huff_ec_prepare_fx( UWord16 *avr_idx, Word16 *diffuseness_bits_huff ); -static Word16 coherence_coding_length( const uint16_t *idx_sur_coh_shift, const UWord8 idx_shift_len, const Word16 coding_subbands, const Word16 *no_cv, uint16_t *mr_idx, Word16 *no_cv_shift, Word16 *p_min_idx, Word16 *GR_ord, Word16 *nbits_fr, Word16 *nbits_fr1 ); +static Word16 coherence_coding_length( const UWord16 *idx_sur_coh_shift, const UWord8 idx_shift_len, const Word16 coding_subbands, const Word16 *no_cv, UWord16 *mr_idx, Word16 *no_cv_shift, Word16 *p_min_idx, Word16 *GR_ord, Word16 *nbits_fr, Word16 *nbits_fr1 ); static Word16 write_2dir_info( BSTR_ENC_HANDLE hMetaData, UWord8 *twoDirBands, const Word16 n, const Word16 k ); @@ -2326,7 +2326,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( move16(); UWord16 dist_elevation_indexes_best[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_MAXIMUM_CODING_SUBBANDS]; Word16 gr_param_azimuth_best, avg_azimuth_index_best; - uint16_t dist_azimuth_indexes_best[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_MAXIMUM_CODING_SUBBANDS]; + UWord16 dist_azimuth_indexes_best[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_MAXIMUM_CODING_SUBBANDS]; UWord16 idx, dist_count; Word16 direction_bits_ec; diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index e6038186e..e321f1c7c 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -60,7 +60,7 @@ static Word16 sns_1st_cod_fx( Word32 *snsq_fx /* o : quantized sns Q16 */ ) { - Word16 index; + Word16 index, i; const Word16 split_len = M / 2; move16(); const Word16 *means; @@ -85,7 +85,7 @@ static Word16 sns_1st_cod_fx( Word16 exp_snsq_buffer[M] = { 0 }, exp_snsq = 0; move16(); move16(); - FOR( Word16 i = 0; i < M; ++i ) + FOR( i = 0; i < M; ++i ) { Word32 tmp = L_mult( means[i], means_fix ); // Q16 exp_snsq_buffer[i] = 0; @@ -93,11 +93,11 @@ static Word16 sns_1st_cod_fx( snsq_fx[i] = BASOP_Util_Add_Mant32Exp( sns_fx[i], exp_sns, L_negate( tmp ), 15, &exp_snsq_buffer[i] ); move32(); } - FOR( int i = 0; i < M; i++ ) + FOR( i = 0; i < M; i++ ) { exp_snsq = s_max( exp_snsq_buffer[i], exp_snsq ); } - FOR( int i = 0; i < M; i++ ) + FOR( i = 0; i < M; i++ ) { snsq_fx[i] = L_shr( snsq_fx[i], exp_snsq - exp_snsq_buffer[i] ); move32(); @@ -121,7 +121,7 @@ static Word16 sns_1st_cod_fx( dist_min_fx = MAXVAL_WORD32; Word16 exp_dist_min = 31; index_split = 0; - FOR( Word16 i = 0; i < 32; ++i ) + FOR( i = 0; i < 32; ++i ) { Word32 dist_fx = 0; move32(); diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 925f4e702..2ace35473 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -1665,7 +1665,7 @@ static void ivas_write_parameter_bitstream_dtx_fx( Word16 *num_dec, const Word16 num_bands ) { - int16_t i, j; + Word16 i, j; Word32 val; Word16 idx; Word32 pr_min_max[2]; diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 3f7237ce5..ede3d3ad9 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3302,8 +3302,8 @@ static void stereo_dft_enc_compute_prm_fx( Word32 *dot_prod_nrg_ratio_fx, // Q(31-dot_prod_nrg_ratio_fx_e[]) Word16 *dot_prod_nrg_ratio_fx_e ) { - int16_t b, i; - int16_t b2; + Word16 b, i; + Word16 b2; Word32 *pDFT_L, *pDFT_R; // Word16 DFT_L_e, DFT_R_e; Word32 sum_nrg_L, sum_nrg_R; @@ -3352,7 +3352,7 @@ static void stereo_dft_enc_compute_prm_fx( Word16 sum_past_dot_prod_abs_e, sum_past_dot_prod_abs2_e = 0; Word32 sum_past_nrg_dmx; Word16 sum_past_nrg_dmx_e; - int16_t pos; + Word16 pos; Word32 pIpd[STEREO_DFT_BAND_MAX]; // Q13 Word32 ipd_smooth[STEREO_DFT_BAND_MAX]; // Q13 Word32 ipd_mean_change; // Q13 diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index f8d600276..979978c03 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -1006,9 +1006,8 @@ void stereo_tdm_prep_dwnmx_fx( const Word16 input_q /* i : frame lenght */ ) { -#define USER_ENER Word32 mener; - int16_t i, sw_pos, enr_len; + Word16 i, sw_pos, enr_len; Encoder_State **sts; Word16 mener_e; sts = hCPE->hCoreCoder; diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 211c53f8c..9d4736368 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -59,8 +59,8 @@ struct IVAS_ENC bool cmd_stereo; #endif bool switchingActive; /* flag for configuration changes during encoding - currently only used with mono */ - int16_t Opt_RF_ON_loc; - int16_t rf_fec_offset_loc; + Word16 Opt_RF_ON_loc; + Word16 rf_fec_offset_loc; bool ismMetadataProvided[MAX_NUM_OBJECTS]; bool maxBandwidthUser; /* Was a specific max bandwith selected by the user? */ IVAS_ENC_BANDWIDTH newBandwidthApi; /* maximum encoded bandwidth, as set on API level */ @@ -77,14 +77,14 @@ static ivas_error setChannelAwareConfig_fx( IVAS_ENC_HANDLE hIvasEnc, const IVAS static ivas_error sanitizeBandwidth_fx( const IVAS_ENC_HANDLE hIvasEnc ); static ivas_error sanitizeBitrateISM_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, const bool extMetadataApi ); static Word16 getInputBufferSize_fx( const Encoder_Struct *st_ivas ); -static ivas_error configureEncoder( IVAS_ENC_HANDLE hIvasEnc, const int32_t inputFs, const int32_t initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); -static ivas_error setBitrate( IVAS_ENC_HANDLE hIvasEnc, const int32_t totalBitrate ); +static ivas_error configureEncoder( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); +static ivas_error setBitrate( IVAS_ENC_HANDLE hIvasEnc, const Word32 totalBitrate ); static ivas_error doCommonConfigureChecks( IVAS_ENC_HANDLE hIvasEnc ); static ivas_error doCommonSetterChecks( IVAS_ENC_HANDLE hIvasEnc ); static void init_encoder_config( ENCODER_CONFIG_HANDLE hEncoderConfig ); static void resetIsmMetadataProvidedFlags( IVAS_ENC_HANDLE hIvasEnc ); -static ivas_error bandwidthApiToInternal( const IVAS_ENC_BANDWIDTH maxBandwidth, int16_t *internalMaxBandwidth ); -static ivas_error fecIndicatorApiToInternal( const IVAS_ENC_FEC_INDICATOR fecIndicator, int16_t *fecIndicatorInternal ); +static ivas_error bandwidthApiToInternal( const IVAS_ENC_BANDWIDTH maxBandwidth, Word16 *internalMaxBandwidth ); +static ivas_error fecIndicatorApiToInternal( const IVAS_ENC_FEC_INDICATOR fecIndicator, Word16 *fecIndicatorInternal ); #ifdef DEBUGGING static ivas_error forcedModeApiToInternal( IVAS_ENC_FORCED_MODE forcedMode, int16_t *forcedModeInternal ); #endif @@ -276,8 +276,8 @@ void IVAS_ENC_Close( ivas_error IVAS_ENC_ConfigureForMono( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -296,7 +296,7 @@ ivas_error IVAS_ENC_ConfigureForMono( } hIvasEnc->st_ivas->hEncoderConfig->ivas_format = MONO_FORMAT; - hIvasEnc->st_ivas->hEncoderConfig->is_binaural = (int16_t) is_binaural; + hIvasEnc->st_ivas->hEncoderConfig->is_binaural = (Word16) is_binaural; if ( downmixFromStereo ) { @@ -318,8 +318,8 @@ ivas_error IVAS_ENC_ConfigureForMono( ivas_error IVAS_ENC_ConfigureForStereo( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -344,7 +344,7 @@ ivas_error IVAS_ENC_ConfigureForStereo( hEncoderConfig = st_ivas->hEncoderConfig; hEncoderConfig->nchan_inp = 2; hEncoderConfig->ivas_format = STEREO_FORMAT; - hEncoderConfig->is_binaural = (int16_t) is_binaural; + hEncoderConfig->is_binaural = (Word16) is_binaural; #ifdef DEBUGGING switch ( stereoMode ) @@ -458,12 +458,12 @@ ivas_error IVAS_ENC_ConfigureForMASAObjects( ivas_error IVAS_ENC_ConfigureForObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ + const UWord16 numObjects, /* i : number of objects to be encoded */ const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ ) { @@ -503,7 +503,7 @@ ivas_error IVAS_ENC_ConfigureForObjects( ivas_error IVAS_ENC_FeedObjectMetadata( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const uint16_t ismIndex, /* i : object index */ + const UWord16 ismIndex, /* i : object index */ const IVAS_ISM_METADATA metadata /* i : object metadata handle for current frame */ ) { @@ -551,8 +551,8 @@ ivas_error IVAS_ENC_FeedObjectMetadata( ivas_error IVAS_ENC_ConfigureForAmbisonics( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -580,7 +580,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( hEncoderConfig->nchan_inp = ivas_sba_get_nchan_fx( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ - hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; + hEncoderConfig->Opt_PCA_ON = (Word16) Opt_PCA_ON; hIvasEnc->maxBandwidthUser = max_bwidth_user; @@ -780,8 +780,8 @@ ivas_error IVAS_ENC_FeedMasaMetadata( ivas_error IVAS_ENC_ConfigureForMultichannel( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -841,8 +841,8 @@ ivas_error IVAS_ENC_ConfigureForMultichannel( static ivas_error configureEncoder( IVAS_ENC_HANDLE hIvasEnc, - const int32_t inputFs, - const int32_t initBitrate, + const Word32 inputFs, + const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ) @@ -850,7 +850,7 @@ static ivas_error configureEncoder( Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; - int32_t cpe_brate; + Word32 cpe_brate; error = IVAS_ERR_OK; @@ -1476,7 +1476,7 @@ static Word16 getInputBufferSize_fx( *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ + Word16 *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ) { if ( hIvasEnc == NULL || numInChannels == NULL ) @@ -1824,8 +1824,8 @@ ivas_error IVAS_ENC_SetBandwidth( *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_SetBitrate( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t totalBitrate /* i : requested bitrate of the output bitstream */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const Word32 totalBitrate /* i : requested bitrate of the output bitstream */ ) { ivas_error error; @@ -2003,11 +2003,11 @@ const char *IVAS_ENC_GetErrorMessage( static ivas_error printConfigInfo_enc( IVAS_ENC_HANDLE hIvasEnc, - const int16_t channelAwareModeEnabled ) + const Word16 channelAwareModeEnabled ) { Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; - int16_t newBandwidthApi; + Word16 newBandwidthApi; ivas_error error; st_ivas = hIvasEnc->st_ivas; @@ -2237,7 +2237,7 @@ static ivas_error printConfigInfo_enc( static ivas_error setBitrate( IVAS_ENC_HANDLE hIvasEnc, - const int32_t totalBitrate ) + const Word32 totalBitrate ) { Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -2753,8 +2753,8 @@ static ivas_error forcedModeApiToInternal( *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_PrintConfig( - const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ - const int16_t channelAwareModeEnabled /* i : channel-aware mode enabled flag */ + const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ + const Word16 channelAwareModeEnabled /* i : channel-aware mode enabled flag */ ) { return printConfigInfo_enc( hIvasEnc, channelAwareModeEnabled ); diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 4911711d7..ab6c39c23 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -68,7 +68,7 @@ typedef struct _IVAS_ENC_DTX_CONFIG { bool enabled; bool variable_SID_rate; - int16_t SID_interval; + Word16 SID_interval; } IVAS_ENC_DTX_CONFIG; typedef enum _IVAS_ENC_SBA_ORDER @@ -169,8 +169,8 @@ ivas_error IVAS_ENC_Open_fx( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForMono( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -182,8 +182,8 @@ ivas_error IVAS_ENC_ConfigureForMono( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForStereo( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -197,34 +197,34 @@ ivas_error IVAS_ENC_ConfigureForStereo( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ + const UWord16 numObjects, /* i : number of objects to be encoded */ const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMASAObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the ouput bitstream */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ - const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ + const UWord16 numObjects, /* i : number of objects to be encoded */ + const Word16 masaVariant /* i : index specifying the number of MASA transport channels */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForSBAObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the ouput bitstream */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ + const UWord16 numObjects, /* i : number of objects to be encoded */ const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_PCA_ON /* i : PCA option flag */ @@ -233,8 +233,8 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForAmbisonics( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -245,8 +245,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -257,8 +257,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForMasa( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -268,8 +268,8 @@ ivas_error IVAS_ENC_ConfigureForMasa( /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMultichannel( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -285,7 +285,7 @@ void IVAS_ENC_Close( /*! r: error code */ ivas_error IVAS_ENC_FeedObjectMetadata( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const uint16_t ismIndex, /* i : object index */ + const UWord16 ismIndex, /* i : object index */ const IVAS_ISM_METADATA metadata /* i : object metadata handle for current frame */ ); @@ -307,10 +307,10 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( /*! r: error code */ ivas_error IVAS_ENC_EncodeFrameToCompact( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *inputBuffer, /* i : PCM input */ - const int16_t inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ - uint8_t *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ - uint16_t *numOutBits /* o : number of bits written to output bitstream */ + Word16 *inputBuffer, /* i : PCM input */ + const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ + UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ + UWord16 *numOutBits /* o : number of bits written to output bitstream */ ); /* Setter functions - apply changes to encoder configuration */ @@ -324,7 +324,7 @@ ivas_error IVAS_ENC_SetBandwidth( /*! r: error code */ ivas_error IVAS_ENC_SetBitrate( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t totalBitrate /* i : requested bitrate of the output bitstream */ + const Word32 totalBitrate /* i : requested bitrate of the output bitstream */ ); /*! r: error code */ @@ -355,13 +355,13 @@ ivas_error IVAS_ENC_GetDelay( /*! r: encoder error code */ ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ + Word16 *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_GetInputBufferSize( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *inputBufferSize /* o : total number of samples expected in the input buffer for current encoder configuration */ + Word16 *inputBufferSize /* o : total number of samples expected in the input buffer for current encoder configuration */ ); /* Utility functions */ @@ -388,7 +388,7 @@ const char *IVAS_ENC_GetErrorMessage( ivas_error IVAS_ENC_PrintConfig( const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ - const int16_t channelAwareModeEnabled /* i : channel-aware mode enabled flag */ + const Word16 channelAwareModeEnabled /* i : channel-aware mode enabled flag */ ); void IVAS_ENC_PrintDisclaimer( diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index a61b2ebff..24179f375 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -31,9 +31,9 @@ static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, Word16 u[], Word16 static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word16 *resq, Word16 *lsfq ); -static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, int16_t nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); +static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); -static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, int16_t nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); +static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); /*===========================================================================*/ /* FUNCTION : lsf_enc_fx() */ diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 7f58a9501..28e1a39de 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -366,7 +366,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ const Word32 *u_fx, /* i : target signal */ const Word16 u_e, /* i : exp for target signal */ - const int16_t maxC_st1, /* i : number of candidates in stage1 */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 02f8344d1..10d020ee3 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -143,7 +143,7 @@ void bw_detect_fx( const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t mct_on /* i : flag MCT mode */ + const Word16 mct_on /* i : flag MCT mode */ ); void core_switching_post_enc_fx( /*done */ @@ -627,7 +627,7 @@ void swb_bwe_enc_fx( void swb_bwe_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ + const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */ const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ @@ -1585,7 +1585,7 @@ void E_ACELP_4t_ivas_fx( const Word16 last_L_frame, const Word32 total_brate, const Word16 i_subfr, - const int16_t cmpl_flag, + const Word16 cmpl_flag, Word16 element_mode ); void E_ACELP_innovative_codebook_fx( @@ -3077,15 +3077,15 @@ void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state #ifdef MSAN_FIX Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ #endif - const int16_t igfGridIdx, /* i : IGF grid index */ - Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ - Word16 e_mdct, /* i : exponent of pMDCTspectrum */ - Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *e_ps, /* i : exponent of pPowerSpectrum */ - const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const int8_t isTNSActive, /* i : flag indicating if the TNS is active */ - const int16_t sp_aud_decision0, /* i : first stage switching decision */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ + const Word16 igfGridIdx, /* i : IGF grid index */ + Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ + Word16 e_mdct, /* i : exponent of pMDCTspectrum */ + Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *e_ps, /* i : exponent of pPowerSpectrum */ + const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ + const Word8 isTNSActive, /* i : flag indicating if the TNS is active */ + const Word16 sp_aud_decision0, /* i : first stage switching decision */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ ); void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index ad572d2ba..41c6b0468 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -51,9 +51,9 @@ typedef struct { - int16_t id; /* id of the indice */ - uint16_t value; /* value of the quantized indice */ - int16_t nb_bits; /* number of bits used for the quantization of the indice */ + Word16 id; /* id of the indice */ + UWord16 value; /* value of the quantized indice */ + Word16 nb_bits; /* number of bits used for the quantization of the indice */ } Indice, *INDICE_HANDLE; typedef struct @@ -84,12 +84,12 @@ typedef struct typedef struct bitstream_enc_data_structure { - int16_t nb_ind_tot; /* total number of indices already written */ - int16_t nb_bits_tot; /* total number of bits already written */ - Indice *ind_list; /* list of indices */ - int16_t *ivas_max_num_indices; /* maximum total number of indices in the list */ - Indice **ivas_ind_list_zero; /* beginning of the buffer of indices */ - void *st_ivas; /* IVAS encoder structure */ + Word16 nb_ind_tot; /* total number of indices already written */ + Word16 nb_bits_tot; /* total number of bits already written */ + Indice *ind_list; /* list of indices */ + Word16 *ivas_max_num_indices; /* maximum total number of indices in the list */ + Indice **ivas_ind_list_zero; /* beginning of the buffer of indices */ + void *st_ivas; /* IVAS encoder structure */ // Word16 nb_bits_tot_fx; /* total number of bits already written */ // Indice *ind_list_fx; /* list of indices */ Word16 next_ind_fx; /* pointer to the next empty slot in the list of indices */ @@ -128,9 +128,9 @@ typedef struct signal_buffers_enc_data_structure /* Delay buffer: Used to buffer input samples and to define the subblock size of a transient detector. */ typedef struct { - int16_t nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ + Word16 nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ Word16 buffer[L_FRAME48k / NSUBBLOCKS]; - int16_t nDelay; /* Size of the delay buffer in use. Maximum delay from all users of this buffer. */ + Word16 nDelay; /* Size of the delay buffer in use. Maximum delay from all users of this buffer. */ } DelayBuffer; @@ -141,8 +141,8 @@ typedef struct Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; // IVAS Q(-1) Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; // IVAS Q(-1) Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* EVS: Q7(15 - SUBBLOCK_NRG_CHANGE_E) */ /* IVAS: Q3 */ - int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ - int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ + Word16 nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ + Word16 nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ /* Decay factor for the recursive accumulation */ Word16 facAccSubblockNrg; @@ -152,27 +152,25 @@ typedef struct Word16 firState2; Word16 q_firState; - uint16_t ramp_up_flag; /* bit map flags to indicate a ramp up in beginning of TCX frame */ + UWord16 ramp_up_flag; /* bit map flags to indicate a ramp up in beginning of TCX frame */ } SubblockEnergies; /* Attack detection function. */ -typedef void ( *TCheckSubblocksForAttack )( const float *pSubblockNrg, const float *pAccSubblockNrg, int16_t nSubblocks, int16_t nPastSubblocks, float attackRatioThreshold, int16_t *pbIsAttackPresent, int16_t *pAttackIndex ); typedef void ( *TCheckSubblocksForAttack_fx )( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ); /* Transient detector. */ typedef struct TransientDetector { SubblockEnergies *pSubblockEnergies; /* Subblock energies used in this transient detector. */ - int16_t nDelay; /* Delay of the transient detector in number of subblocks, nDelay <= pSubblockEnergies->nDelay. */ - int16_t nSubblocksToCheck; /* Number of subblocks to check for transients. */ - TCheckSubblocksForAttack CheckSubblocksForAttack; /* Function for checking a presence of an attack. */ + Word16 nDelay; /* Delay of the transient detector in number of subblocks, nDelay <= pSubblockEnergies->nDelay. */ + Word16 nSubblocksToCheck; /* Number of subblocks to check for transients. */ TCheckSubblocksForAttack_fx CheckSubblocksForAttack_fx; /* Function for checking a presence of an attack. */ Word16 attackRatioThreshold; /* Attack ratio threshold Q11 */ - int16_t bIsAttackPresent; /* True when an attack was detected. */ - int16_t prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ - int16_t attackIndex; /* The index of an attack. */ + Word16 bIsAttackPresent; /* True when an attack was detected. */ + Word16 prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ + Word16 attackIndex; /* The index of an attack. */ } TransientDetector; /* Transient detection: Holds all transient detectors and buffers used by them. */ @@ -191,25 +189,25 @@ typedef struct TransientDetection_structure typedef struct vad_structure { - int16_t nb_active_frames; - int16_t hangover_cnt; - int16_t nb_active_frames_he; - int16_t hangover_cnt_he; - int32_t vad_flag_reg_H; - int32_t vad_flag_reg_L; - int32_t vad_prim_reg; - - int16_t vad_flag_cnt_50; - int16_t vad_prim_cnt_16; - - int16_t hangover_cnt_dtx; - int16_t hangover_cnt_music; + Word16 nb_active_frames; + Word16 hangover_cnt; + Word16 nb_active_frames_he; + Word16 hangover_cnt_he; + Word32 vad_flag_reg_H; + Word32 vad_flag_reg_L; + Word32 vad_prim_reg; + + Word16 vad_flag_cnt_50; + Word16 vad_prim_cnt_16; + + Word16 hangover_cnt_dtx; + Word16 hangover_cnt_music; Word16 bcg_flux_fx; // Q4 - int16_t soft_hangover; - int16_t voiced_burst; - int16_t bcg_flux_init; - int16_t nb_active_frames_he1; - int16_t hangover_cnt_he1; + Word16 soft_hangover; + Word16 voiced_burst; + Word16 bcg_flux_init; + Word16 nb_active_frames_he1; + Word16 hangover_cnt_he1; Word16 prim_act_quick_fx; /*Q15 */ /* Noise estimator - primary activity quick */ Word16 prim_act_slow_fx; /*Q15 */ /* Noise estimator - primary activity slow */ Word16 prim_act_fx; /*Q15 */ /* Noise estimator - primary activity slow rise quick fall */ @@ -217,22 +215,22 @@ typedef struct vad_structure Word16 prim_act_slow_he_fx; /*Q15 */ /* Noise estimator - primary activity slow */ Word16 prim_act_he_fx; /*Q15 */ /* Q15 Noise estimator - primary activity slow rise quick fall */ - int16_t spectral_tilt_reset; - int16_t consec_inactive; + Word16 spectral_tilt_reset; + Word16 consec_inactive; Word16 ra_deltasum_fx; - int16_t trigger_SID; + Word16 trigger_SID; Word16 snr_sum_vad_fx; /*Q15 */ Word16 running_avg_fx; /*Q15 */ Word32 L_snr_sum_vad_fx; /*Q4*/ - int16_t hangover_terminate_flag; /* CNG and DTX - flag indicating whether to early terminate DTX hangover */ - int16_t vad_flag; /* VAD flag */ + Word16 hangover_terminate_flag; /* CNG and DTX - flag indicating whether to early terminate DTX hangover */ + Word16 vad_flag; /* VAD flag */ } VAD_DATA, *VAD_HANDLE; typedef struct cldfb_vad_structure { - int16_t bw_index; /* index of band width */ + Word16 bw_index; /* index of band width */ /* feature */ Word16 sp_center[SP_CENTER_NUM]; /* spectral center*/ @@ -248,8 +246,8 @@ typedef struct cldfb_vad_structure Word32 t_bg_energy; /* time background energy of several frames*/ Word16 scale_t_bg_energy; /* the Scaling of t_bg_energy*/ T_VAD_EXP t_bg_energy_sum; /* number of time background energy*/ - int16_t tbg_energy_count; /* sum of time background energy of several frames*/ - int16_t bg_update_count; /* time of background update*/ + Word16 tbg_energy_count; /* sum of time background energy of several frames*/ + Word16 bg_update_count; /* time of background update*/ Word32 frame_energy_smooth; /* smoothed energy of several frames*/ Word16 frame_energy_smooth_scale; /* the Scaling of frame_energy_smooth*/ @@ -268,14 +266,14 @@ typedef struct cldfb_vad_structure Word16 fg_energy_scale; /* the Scaling of fg_energy*/ Word32 bg_energy; /* background energy sum */ Word16 bg_energy_scale; /* the Scaling of bg_energy*/ - int16_t fg_energy_count; /* number of the foreground energy frame */ - int16_t bg_energy_count; /* number of the background energy frame */ + Word16 fg_energy_count; /* number of the foreground energy frame */ + Word16 bg_energy_count; /* number of the background energy frame */ Word32 fg_energy_est_start; /* flag by that indicate whether if estimate energy*/ - int16_t speech_flag; /* residual number of hangover 1 */ - int16_t continuous_noise_num; /* time of continuous noise frames*/ - int16_t continuous_speech_num; /* time of continuous speech frames*/ - int16_t continuous_speech_num2; /* time 2 of continuous speech frames*/ - int16_t frameloop; /* number of frame*/ + Word16 speech_flag; /* residual number of hangover 1 */ + Word16 continuous_noise_num; /* time of continuous noise frames*/ + Word16 continuous_speech_num; /* time of continuous speech frames*/ + Word16 continuous_speech_num2; /* time 2 of continuous speech frames*/ + Word16 frameloop; /* number of frame*/ Word16 tonality_rate3; /* tonality rate*/ Word16 music_background_rate; /* music background rate*/ Word32 lt_noise_sp_center_diff_sum; /* different sum of long time noise sp_center*/ @@ -283,10 +281,10 @@ typedef struct cldfb_vad_structure Word16 lt_noise_sp_center0; /* long time noise sp_center0*/ Word16 lt_noise_sp_center3; /* long time noise sp_center3*/ Word32 lt_bg_highf_eng; /* average of long time high frequency energy*/ - int16_t update_num_with_snr; /* the number of the background update with SNR*/ - int16_t update_count; - int16_t warm_hang_num; /* the number of hangover for warm up*/ - int16_t vad_flag_for_bk_update; + Word16 update_num_with_snr; /* the number of the background update with SNR*/ + Word16 update_count; + Word16 warm_hang_num; /* the number of hangover for warm up*/ + Word16 vad_flag_for_bk_update; } T_CldfbVadState, *VAD_CLDFB_HANDLE; @@ -326,7 +324,7 @@ typedef struct td_cng_enc_structure Word16 cng_buf_cnt; /* CNG and DTX - Counter of buffered CNG parameters */ Word16 cng_exc2_buf[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ Word16 cng_Qexc_buf[HO_HIST_SIZE]; /* CNG and DTX - Q_exc buffer for storing */ - int32_t cng_brate_buf[HO_HIST_SIZE]; /* CNG and DTX - buffer for storing last_active_brate */ + Word32 cng_brate_buf[HO_HIST_SIZE]; /* CNG and DTX - buffer for storing last_active_brate */ Word16 CNG_att_fx; /* CNG and DTX - attenuation factor for CNG, in dB Q7 */ Word16 ho_16k_lsp[HO_HIST_SIZE]; /* CNG and DTX - 16k LSPs flags */ Word16 act_cnt2; /* CNG and DTX - counter of active frames for CNG_mode switching */ @@ -432,23 +430,23 @@ typedef struct dtx_enc_structure typedef struct igfscfenc_public_data_struct { - int16_t ptrBitIndex; - int16_t bitCount; - int16_t prev[64]; /* no more than 64 SCFs for the IGF energy envelope of one block */ - int16_t prevSave[64]; - int16_t scfCountLongBlock[IGF_NOF_GRIDS]; - int16_t t; - int16_t Tsave; - int16_t contex_saved; - const uint16_t *cf_se00; - const uint16_t *cf_se01; - int16_t cf_off_se01; - const uint16_t *cf_se02; - const int16_t *cf_off_se02; - const uint16_t *cf_se10; - int16_t cf_off_se10; - const uint16_t *cf_se11; - const int16_t *cf_off_se11; + Word16 ptrBitIndex; + Word16 bitCount; + Word16 prev[64]; /* no more than 64 SCFs for the IGF energy envelope of one block */ + Word16 prevSave[64]; + Word16 scfCountLongBlock[IGF_NOF_GRIDS]; + Word16 t; + Word16 Tsave; + Word16 contex_saved; + const UWord16 *cf_se00; + const UWord16 *cf_se01; + Word16 cf_off_se01; + const UWord16 *cf_se02; + const Word16 *cf_off_se02; + const UWord16 *cf_se10; + Word16 cf_off_se10; + const UWord16 *cf_se11; + const Word16 *cf_off_se11; Tastat acState; TastatEnc acState_fx; @@ -749,21 +747,21 @@ typedef struct acelp_cbkcorr_structure typedef struct gsc_enc_structure { - int16_t seed_tcx; /* AC mode (GSC) - seed for noise fill */ - int16_t cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - int16_t mem_last_pit_band; /* AC mode (GSC) - memory of the last band where pitch contribution was significant */ + Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill */ + Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ + Word16 mem_last_pit_band; /* AC mode (GSC) - memory of the last band where pitch contribution was significant */ Word16 mem_w0_tmp_fx; Word16 mem_syn_tmp_fx[M]; Word16 mid_dyn_fx; /* AC mode (GSC) - signal dynamic Q7 */ - int16_t noise_lev; /* AC mode (GSC) - noise level */ - int16_t past_dyn_dec; /* AC mode (GSC) - Past noise level decision */ + Word16 noise_lev; /* AC mode (GSC) - noise level */ + Word16 past_dyn_dec; /* AC mode (GSC) - Past noise level decision */ Word32 Last_frame_ener_fx; /* AC mode (GSC) - Last frame energy */ - int16_t pit_exc_hangover; /* AC mode (GSC) - Hangover for the time contribution switching */ + Word16 pit_exc_hangover; /* AC mode (GSC) - Hangover for the time contribution switching */ Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous exciation */ Word16 Q_last_exc_dct_in; - Word16 last_ener_fx; /* AC mode (GSC) - previous energy Q0 */ - int16_t last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ - Word16 lt_gpitch_fx; /* Q15 */ + Word16 last_ener_fx; /* AC mode (GSC) - previous energy Q0 */ + Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ + Word16 lt_gpitch_fx; /* Q15 */ } GSC_ENC_DATA, *GSC_ENC_HANDLE; @@ -804,14 +802,14 @@ typedef struct hq_enc_structure /* PVQ range coder state */ typedef struct pvq_enc_structure { - uint32_t rc_low; - uint32_t rc_range; - int16_t rc_cache; - int16_t rc_carry; - int16_t rc_carry_count; - int16_t rc_num_bits; - int16_t rc_tot_bits; - int16_t rc_offset; + UWord32 rc_low; + UWord32 rc_range; + Word16 rc_cache; + Word16 rc_carry; + Word16 rc_carry_count; + Word16 rc_num_bits; + Word16 rc_tot_bits; + Word16 rc_offset; } PVQ_ENC_DATA, *PVQ_ENC_HANDLE; @@ -838,33 +836,33 @@ typedef struct sc_vbr_enc_structure Word16 nelp_lp_fit_mem[NELP_LP_ORDER * 2]; /* Q(prev_Q_new) */ Word32 bp1_filt_mem_nb_fx[14]; /* Q(qprevGain_fx) */ - int16_t nelp_enc_seed; + Word16 nelp_enc_seed; Word16 nelp_gain_mem_fx; /* Q0 */ - int16_t last_nelp_mode; - int16_t nelp_mode; + Word16 last_nelp_mode; + Word16 nelp_mode; Word16 qprevIn_fx; Word16 qprevGain_fx; /* PPP variables */ - int16_t pppcountE; - int16_t bump_up; - int16_t last_ppp_mode; - int16_t last_last_ppp_mode; - int16_t ppp_mode; + Word16 pppcountE; + Word16 bump_up; + Word16 last_ppp_mode; + Word16 last_last_ppp_mode; + Word16 ppp_mode; Word16 prev_ppp_gain_pit_fx; /* Q14 */ Word16 prev_tilt_code_fx; /* Q15 */ /* voiced encoder variables */ - int16_t firstTime_voicedenc; + Word16 firstTime_voicedenc; /* DTFS variables */ Word16 dtfs_enc_a_fx[MAXLAG_WI]; /* Q(dtfs_enc_Q) */ Word16 dtfs_enc_b_fx[MAXLAG_WI]; /* Q(dtfs_enc_Q) */ - int16_t dtfs_enc_lag; - int16_t dtfs_enc_nH; - int16_t dtfs_enc_nH_4kHz; + Word16 dtfs_enc_lag; + Word16 dtfs_enc_nH; + Word16 dtfs_enc_nH_4kHz; Word16 dtfs_enc_upper_cut_off_freq_of_interest_fx; /* Q0 */ Word16 dtfs_enc_upper_cut_off_freq_fx; /* Q0 */ Word16 dtfs_enc_Q; @@ -876,23 +874,23 @@ typedef struct sc_vbr_enc_structure Word16 lasterbE_fx[NUM_ERB_WB]; /* Previous Amplitude spectrum (ERB) Q13 */ Word16 Q_prev_cw_en_fx; - int16_t mode_QQF; - int16_t rate_control; + Word16 mode_QQF; + Word16 rate_control; Word16 SNR_THLD_fx; /* Q8 */ - int16_t Q_to_F; - int16_t pattern_m; - int16_t patterncount; - int16_t Last_Resort; - int16_t numactive; /* keep the count of the frames inside current 600 frame block */ + Word16 Q_to_F; + Word16 pattern_m; + Word16 patterncount; + Word16 Last_Resort; + Word16 numactive; /* keep the count of the frames inside current 600 frame block */ Word32 sum_of_rates_fx; /*Q=13 sum of the rates of past 600 active frames*/ Word32 global_avr_rate_fx; /*Q=13 global rate upto current time. recorded a (rate in kbps) *6000*/ - int16_t global_frame_cnt; /* 600 active frame block count. Used to update the global rate */ - int16_t set_ppp_generic; - int16_t avoid_HQ_VBR_NB; + Word16 global_frame_cnt; /* 600 active frame block count. Used to update the global rate */ + Word16 set_ppp_generic; + Word16 avoid_HQ_VBR_NB; - int16_t vbr_generic_ho; - int16_t Local_VAD; - int16_t last_7k2_coder_type; + Word16 vbr_generic_ho; + Word16 Local_VAD; + Word16 last_7k2_coder_type; } SC_VBR_ENC_DATA, *SC_VBR_ENC_HANDLE; @@ -910,7 +908,7 @@ typedef struct amrwb_io_enc_structure Word16 mem_hp400_enc_fx[6]; Word16 mem_hf_enc_fx[L_FIR - 1]; Word16 mem_syn_hf_enc_fx[M]; - int16_t seed2_enc; + Word16 seed2_enc; } AMRWB_IO_ENC_DATA, *AMRWB_IO_ENC_HANDLE; @@ -944,7 +942,7 @@ typedef struct td_bwe_enc_structure Word16 state_syn_shbexc_fx[L_SHB_LAHEAD]; /* Q(prev_Q_bwe_exc - 16) */ Word16 state_lpc_syn_fx[LPC_SHB_ORDER]; /* Q(prev_Q_bwe_exc - 16) */ Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/ - int16_t bwe_seed[2]; + Word16 bwe_seed[2]; Word32 bwe_non_lin_prev_scale_fx; /* Q30 */ Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; /* Q(prev_Q_bwe_exc - 16) */ Word16 syn_overlap_fx[L_SHB_LAHEAD]; /* overlap buffer used to Adjust SHB Frame Gain */ @@ -964,7 +962,7 @@ typedef struct td_bwe_enc_structure Word16 shb_inv_filt_mem_fx[LPC_SHB_ORDER]; /* Q(Q_shb_spch) */ Word16 lsp_shb_spacing_fx[3]; /* Q15 */ Word16 prev_swb_GainShape_fx; /* Q15 */ - int16_t prev_frGainAtten; + Word16 prev_frGainAtten; Word16 prev_wb_GainShape; /* Q15 */ Word16 swb_lsp_prev_interp_fx[LPC_SHB_ORDER]; /* Q15 */ @@ -973,25 +971,25 @@ typedef struct td_bwe_enc_structure Word16 fb_tbe_demph_fx; Word16 tilt_mem_fx; /* Q12 */ - int16_t prev_coder_type; + Word16 prev_coder_type; Word16 prev_lsf_diff_fx[LPC_SHB_ORDER - 2]; /* Q15 */ Word16 prev_tilt_para_fx; /* Q10 */ Word16 cur_sub_Aq_fx[M + 1]; /* Q12 */ /* quantized data */ - int16_t lsf_idx[NUM_Q_LSF]; - int16_t m_idx; - int16_t grid_idx; - int16_t idxSubGains; - int16_t idxFrameGain; - int16_t idx_shb_fr_gain; - int16_t idx_res_gs[NB_SUBFR16k]; - int16_t idx_mixFac; - - int16_t lsf_WB; - int16_t gFrame_WB; - - int16_t idxGain; + Word16 lsf_idx[NUM_Q_LSF]; + Word16 m_idx; + Word16 grid_idx; + Word16 idxSubGains; + Word16 idxFrameGain; + Word16 idx_shb_fr_gain; + Word16 idx_res_gs[NB_SUBFR16k]; + Word16 idx_mixFac; + + Word16 lsf_WB; + Word16 gFrame_WB; + + Word16 idxGain; Word16 dec_2_over_3_mem_fx[L_FILT_2OVER3]; Word16 dec_2_over_3_mem_lp_fx[6]; @@ -1041,9 +1039,9 @@ typedef struct fd_bwe_enc_structure typedef struct rf_enc_structure { - int16_t rf_frame_type; - int16_t rf_targetbits_buff[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_frametype[MAX_RF_FEC_OFFSET]; + Word16 rf_frame_type; + Word16 rf_targetbits_buff[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_frametype[MAX_RF_FEC_OFFSET]; ACELP_config acelp_cfg_rf; /* configuration for RF frame */ @@ -1054,31 +1052,31 @@ typedef struct rf_enc_structure struct dispMem_fx rf_dm_fx; Word32 rf_gc_threshold; - int16_t rf_target_bits; + Word16 rf_target_bits; Word16 rf_tilt_buf[NB_SUBFR16k]; - int16_t rf_indx_lsf[MAX_RF_FEC_OFFSET][3]; - int16_t rf_indx_pitch[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_fcb[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_gain[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_EsPred[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_ltfMode[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_lsf[MAX_RF_FEC_OFFSET][3]; + Word16 rf_indx_pitch[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_fcb[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_gain[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_EsPred[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_ltfMode[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_nelp_fid[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_nelp_iG1[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_nelp_iG2[MAX_RF_FEC_OFFSET][2]; + Word16 rf_indx_nelp_fid[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_nelp_iG1[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_nelp_iG2[MAX_RF_FEC_OFFSET][2]; - int16_t rf_indx_tbeGainFr[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_tbeGainFr[MAX_RF_FEC_OFFSET]; - int16_t rf_tcxltp_pitch_int_past; - int16_t rf_last_tns_active; - int16_t rf_second_last_tns_active; - int16_t rf_second_last_core; - int16_t rf_clas[MAX_RF_FEC_OFFSET]; - int16_t rf_gain_tcx[MAX_RF_FEC_OFFSET]; - int16_t rf_tcxltp_param[MAX_RF_FEC_OFFSET]; + Word16 rf_tcxltp_pitch_int_past; + Word16 rf_last_tns_active; + Word16 rf_second_last_tns_active; + Word16 rf_second_last_core; + Word16 rf_clas[MAX_RF_FEC_OFFSET]; + Word16 rf_gain_tcx[MAX_RF_FEC_OFFSET]; + Word16 rf_tcxltp_param[MAX_RF_FEC_OFFSET]; - int16_t RF_bwe_gainFr_ind; + Word16 RF_bwe_gainFr_ind; } RF_ENC_DATA, *RF_ENC_HANDLE; @@ -1088,17 +1086,17 @@ typedef struct rf_enc_structure typedef struct plc_enc_evs_structure { - int16_t nBits; /* number of bits */ + Word16 nBits; /* number of bits */ Word16 Q_new; Word16 Q_exp; - int16_t enableGplc; - int16_t T0_4th; - int16_t T0; - int16_t calcOnlylsf; - int16_t pit_min; - int16_t pit_max; + Word16 enableGplc; + Word16 T0_4th; + Word16 T0; + Word16 calcOnlylsf; + Word16 pit_min; + Word16 pit_max; Word16 mem_MA_14Q1[M]; Word16 mem_AR[M]; @@ -1131,8 +1129,8 @@ typedef struct tec_enc_structure Word16 loTempEnv[CLDFB_NO_COL_MAX]; /* Q7 */ Word16 loTempEnv_ns[CLDFB_NO_COL_MAX]; /* Q7 */ Word16 hiTempEnv[CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV]; /* Q7 */ - int16_t tranFlag; - int16_t corrFlag; + Word16 tranFlag; + Word16 corrFlag; } TEC_ENC_DATA, *TEC_ENC_HANDLE; @@ -1143,63 +1141,63 @@ typedef struct tec_enc_structure typedef struct tcx_enc_structure { - int16_t L_frameTCX; + Word16 L_frameTCX; - int16_t tcxMode; /* Chosen TCX mode for this frame */ - int16_t transform_type[2]; /* TCX20/10/5 mode in each subframe */ + Word16 tcxMode; /* Chosen TCX mode for this frame */ + Word16 transform_type[2]; /* TCX20/10/5 mode in each subframe */ /* Core Signal Analysis Outputs */ Word16 noiseTiltFactor; /* compensation for LPC tilt in noise filling Q15 */ - int16_t noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ + Word16 noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ Word16 ltpGainMemory_fx[N_LTP_GAIN_MEMS]; /* for smoothing noiseTransWidth Q15 */ STnsData tnsData[2]; - // int16_t fUseTns[2]; + // Word16 fUseTns[2]; Word8 fUseTns[2]; - int16_t bTnsOnWhithenedSpectra[2]; + Word16 bTnsOnWhithenedSpectra[2]; - // int16_t memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ + // Word16 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word8 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word16 *speech_TCX; Word16 *new_speech_TCX; // Word16 q_speech_TCX; - int16_t tcxltp; - int16_t tcxltp_pitch_int; - int16_t tcxltp_pitch_fr; + Word16 tcxltp; + Word16 tcxltp_pitch_int; + Word16 tcxltp_pitch_fr; Word16 tcxltp_gain; /* Q15 */ - int16_t tcxltp_pitch_int_past; - int16_t tcxltp_pitch_fr_past; + Word16 tcxltp_pitch_int_past; + Word16 tcxltp_pitch_fr_past; Word16 tcxltp_gain_past; /* Q15 */ Word16 tcxltp_norm_corr_past; /* Q15 */ Word16 tcxltp_norm_corr_mem; /* Q15 */ Word16 kernel_switch_corr_past; /* Q15 */ - uint16_t kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ - uint16_t kernel_symmetry_past; /* last TDA symmetry (0 for MDCT, 1 for MDST type) */ - uint16_t enc_ste_pre_corr_past; + UWord16 kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ + UWord16 kernel_symmetry_past; /* last TDA symmetry (0 for MDCT, 1 for MDST type) */ + UWord16 enc_ste_pre_corr_past; Word32 tfm_mem_fx; /* state of IIR filtered temporal flatness measure Q31 */ Word16 buf_speech_ltp[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; Word16 exp_buf_speech_ltp; Word16 *speech_ltp; Word16 *new_speech_ltp; - int16_t tcxltp_filt_idx; - int16_t tcxltp_bits; - int16_t tcxltp_param[LTPSIZE]; - int16_t tcxltp_on_mem; + Word16 tcxltp_filt_idx; + Word16 tcxltp_bits; + Word16 tcxltp_param[LTPSIZE]; + Word16 tcxltp_on_mem; Word16 measuredBwRatio; /* measured bw; used for TCX noise-filling. 1Q14 */ - int16_t nmStartLine; /* Starting line for the noise measurement */ + Word16 nmStartLine; /* Starting line for the noise measurement */ - int16_t tcx_lpc_shaped_ari; + Word16 tcx_lpc_shaped_ari; Word16 old_out_fx[L_FRAME32k]; /* buffer for OLA; at the encoder, the maximum length is L_FRAME32k (corresponds to maximum internal L_frame length) */ Word16 Q_old_out; /* MDCT switching */ Word16 prev_hi_ener; /* Q8 */ - int16_t prev_hi_sparse; + Word16 prev_hi_sparse; Word16 clas_sec_old_fx; /* Q13 */ - int16_t clas_final_old; + Word16 clas_final_old; Word32 last_gain1; /* Q(31 - st->last_enerBuffer_exp) */ Word32 last_gain2; /* Q(31 - st->last_enerBuffer_exp) */ @@ -1209,7 +1207,7 @@ typedef struct tcx_enc_structure Word16 q_Txnq; Word16 tcx_target_bits_fac; /* Q14 */ - int16_t tns_ms_flag[2]; + Word16 tns_ms_flag[2]; Word32 *spectrum_fx[2]; /* MDCT output for a short block */ Word16 spectrum_e[2]; Word32 spectrum_long_fx[N_MAX]; /* MDCT output for a long block. Points to spectrum */ @@ -1241,9 +1239,9 @@ typedef struct enc_core_structure Word16 idchan; /* channel ID (audio channel number) */ Word16 id_element; /* element ID */ - int16_t element_mode; /* element mode */ + Word16 element_mode; /* element mode */ Word16 last_element_mode; /* element mode */ - int32_t element_brate; /* element bitrate */ + Word32 element_brate; /* element bitrate */ Word16 extl_orig; /* extension layer */ Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ @@ -1257,40 +1255,40 @@ typedef struct enc_core_structure BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ Word16 last_enerBuffer_exp; - int16_t bitstreamformat; /* Bitstream format flag (G.192/MIME) */ - Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ - - int32_t input_Fs; /* input signal sampling frequency in Hz */ - int32_t total_brate; /* total bitrate in kbps of the codec */ - int32_t last_total_brate; /* last frame's total bitrate in kbps of the codec */ - int32_t last_total_brate_cng; /* last inactive frame's total bitrate in kbps of the codec */ - int16_t core; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ - int16_t last_core; /* previous frame core */ - int16_t coder_type; /* core coder type */ - int16_t flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ - int32_t core_brate; /* core bitrate */ - int32_t last_core_brate; /* previous frame core bitrate */ - int16_t extl; /* extension layer */ - int16_t last_extl; /* previous extension layer */ - int32_t extl_brate; /* extension layer bitrate */ - int16_t input_bwidth; /* input signal bandwidth */ - int16_t bwidth; /* encoded bandwidth NB, WB, SWB or FB */ - int16_t max_bwidth; /* maximum encoded bandwidth */ - int16_t last_input_bwidth; /* input signal bandwidth in the previous frame */ - int16_t last_bwidth; /* coded bandwidth in the previous frame */ - int16_t last_bwidth_cng; /* coded bandwidth in the previous inactive frame */ - int16_t bwidth_sw_cnt; /* bandwidth switching counter */ - int16_t L_frame; /* ACELP core internal frame length */ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_DTX_ON; /* flag indicating DTX operation */ - int16_t cng_type; /* flag indicating LP or CLDFB based SID/CNG */ - int16_t cng_sba_flag; /* flag indicating CNG/SID for SBA 2TC */ - int16_t Opt_SC_VBR; /* flag indicating SC-VBR mode */ - int16_t last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ - int16_t low_rate_mode; /* low-rate mode flag */ - int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ + Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME) */ + Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ + + Word32 input_Fs; /* input signal sampling frequency in Hz */ + Word32 total_brate; /* total bitrate in kbps of the codec */ + Word32 last_total_brate; /* last frame's total bitrate in kbps of the codec */ + Word32 last_total_brate_cng; /* last inactive frame's total bitrate in kbps of the codec */ + Word16 core; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ + Word16 last_core; /* previous frame core */ + Word16 coder_type; /* core coder type */ + Word16 flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ + Word32 core_brate; /* core bitrate */ + Word32 last_core_brate; /* previous frame core bitrate */ + Word16 extl; /* extension layer */ + Word16 last_extl; /* previous extension layer */ + Word32 extl_brate; /* extension layer bitrate */ + Word16 input_bwidth; /* input signal bandwidth */ + Word16 bwidth; /* encoded bandwidth NB, WB, SWB or FB */ + Word16 max_bwidth; /* maximum encoded bandwidth */ + Word16 last_input_bwidth; /* input signal bandwidth in the previous frame */ + Word16 last_bwidth; /* coded bandwidth in the previous frame */ + Word16 last_bwidth_cng; /* coded bandwidth in the previous inactive frame */ + Word16 bwidth_sw_cnt; /* bandwidth switching counter */ + Word16 L_frame; /* ACELP core internal frame length */ + Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + Word16 Opt_DTX_ON; /* flag indicating DTX operation */ + Word16 cng_type; /* flag indicating LP or CLDFB based SID/CNG */ + Word16 cng_sba_flag; /* flag indicating CNG/SID for SBA 2TC */ + Word16 Opt_SC_VBR; /* flag indicating SC-VBR mode */ + Word16 last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ + Word16 low_rate_mode; /* low-rate mode flag */ + Word16 inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ #ifdef DEBUGGING - int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ + Word16 force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ #ifdef DEBUG_FORCE_DIR char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ #endif @@ -1328,13 +1326,13 @@ typedef struct enc_core_structure * ACELP core parameters *----------------------------------------------------------------------------------*/ - int16_t clas; /* current frame clas */ - int16_t last_clas; /* previous frame signal classification */ + Word16 clas; /* current frame clas */ + Word16 last_clas; /* previous frame signal classification */ Word16 prev_fmerit; /* previous signal classification score Q15 */ Word16 fmerit_dt; /* signal classification score difference Q15 */ - int16_t Nb_ACELP_frames; + Word16 Nb_ACELP_frames; - int16_t pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ + Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ // Word16 pitch_fx[3]; Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ @@ -1348,7 +1346,7 @@ typedef struct enc_core_structure Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - int16_t pstreaklen; /* LSF quantizer */ + Word16 pstreaklen; /* LSF quantizer */ Word16 streaklimit_fx; /* LSF quantizer Q15 */ Word16 stab_fac_fx; /* LSF stability factor Q15 */ Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ @@ -1375,42 +1373,42 @@ typedef struct enc_core_structure Word16 mem_deemph_fx; /* deemphasis filter memory */ Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ - int16_t GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ - int16_t GSC_IVAS_mode; + Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ + Word16 GSC_IVAS_mode; GSC_ENC_HANDLE hGSCEnc; - int16_t Last_pulse_pos; /* FEC - last position of the first glottal pulse in the frame */ + Word16 Last_pulse_pos; /* FEC - last position of the first glottal pulse in the frame */ Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame Qlog2(2.56) */ Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame Qlog2(2.56) */ Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC Qlog2(2.56) */ - int16_t next_force_safety_net; /* FEC - flag to force safety net in next frame */ + Word16 next_force_safety_net; /* FEC - flag to force safety net in next frame */ // Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ - int16_t uv_count; /* Stationary noise UV modification - unvoiced counter */ - int16_t act_count; /* Stationary noise UV modification - activation counter */ + Word16 uv_count; /* Stationary noise UV modification - unvoiced counter */ + Word16 act_count; /* Stationary noise UV modification - activation counter */ Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain Q(GE_SHIFT) */ Word16 lspold_s_fx[M]; /* Stationary noise UV modification - old LSP vector Q15 */ - int16_t noimix_seed; /* Stationary noise UV modification - mixture seed */ + Word16 noimix_seed; /* Stationary noise UV modification - mixture seed */ Word16 min_alpha_fx; /* Stationary noise UV modification - minimum alpha Q15 */ Word16 exc_pe_fx; /* Stationary noise UV modification - memory of the preemphasis filter */ - int16_t coder_type_raw; /* raw coder_type (before UNVOICED is lost) */ - int16_t last_coder_type_raw; /* raw last_coder_type (coming from the sigal classification) */ - int16_t last_coder_type; /* previous coding type */ + Word16 coder_type_raw; /* raw coder_type (before UNVOICED is lost) */ + Word16 last_coder_type_raw; /* raw last_coder_type (coming from the sigal classification) */ + Word16 last_coder_type; /* previous coding type */ Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q14 */ Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ - int16_t old_pitch; /* previous pitch for open-loop pitch search */ - int16_t delta_pit; /* open-loop pitch extrapolation correction */ + Word16 old_pitch; /* previous pitch for open-loop pitch search */ + Word16 delta_pit; /* open-loop pitch extrapolation correction */ Word32 ee_old_fx; /* previous frame low/high frequency energy ratio Q6 */ - int16_t min_band; /* minimum critical band of useful bandwidth */ - int16_t max_band; /* maximum critical band of useful bandwidth */ - int16_t tc_cnt; /* TC frame counter */ - int16_t audio_frame_cnt; /* Counter of relative presence of audio frames */ + Word16 min_band; /* minimum critical band of useful bandwidth */ + Word16 max_band; /* maximum critical band of useful bandwidth */ + Word16 tc_cnt; /* TC frame counter */ + Word16 audio_frame_cnt; /* Counter of relative presence of audio frames */ Word32 old_dE1_fx; /* Maximum energy increase in previous frame Q13 */ - int16_t old_ind_deltaMax; /* Index of the sub-subframe of maximum energy in previous frame */ + Word16 old_ind_deltaMax; /* Index of the sub-subframe of maximum energy in previous frame */ Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ - int16_t spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ - int16_t last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ + Word16 spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ + Word16 last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ Word16 old_Es_pred_fx; /* old Es_pred for core switching Q8 */ Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ @@ -1433,7 +1431,7 @@ typedef struct enc_core_structure Word16 voicing0_sm_fx; Word16 voicing_sm_fx; Word16 LF_EnergyRatio_sm_fx; - int16_t predecision_flag; + Word16 predecision_flag; Word32 diff_sm_fx; /* Q7 */ Word32 energy_sm_fx; /* Q7 */ @@ -1492,9 +1490,9 @@ typedef struct enc_core_structure Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ - int16_t sp_aud_decision0; /* 1st stage speech/music decision flag */ - int16_t sp_aud_decision1; /* 1st stage speech/music classification flag */ - int16_t sp_aud_decision2; /* 2nd stage speech/music classification flag */ + Word16 sp_aud_decision0; /* 1st stage speech/music decision flag */ + Word16 sp_aud_decision1; /* 1st stage speech/music classification flag */ + Word16 sp_aud_decision2; /* 2nd stage speech/music classification flag */ /*----------------------------------------------------------------------------------* * VAD/DTX/CNG @@ -1505,9 +1503,9 @@ typedef struct enc_core_structure VAD_CLDFB_HANDLE hVAD_CLDFB; T_CldfbVadState vad_st; - int16_t vad_flag; /* i : VAD flag */ - int16_t sharpFlag; - int16_t localVAD; /* i : local VAD flag */ + Word16 vad_flag; /* i : VAD flag */ + Word16 sharpFlag; + Word16 localVAD; /* i : local VAD flag */ Word32 bckr_tilt_lt; /* Q16 */ Word16 lp_speech_fx; /* Q8 */ @@ -1517,7 +1515,7 @@ typedef struct enc_core_structure Word16 voicing_old_fx; Word16 var_SID_rate_flag_fx; /* CNG and DTX - flag for variable SID rate */ Word16 interval_SID_fx; - int16_t active_cnt; /* counter of active frames */ + Word16 active_cnt; /* counter of active frames */ TD_CNG_ENC_HANDLE hTdCngEnc; @@ -1544,10 +1542,10 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ HANDLE_FD_CNG_ENC hFdCngEnc; - int16_t fd_cng_reset_flag; + Word16 fd_cng_reset_flag; Word16 last_totalNoise_fx; /* Q8 */ Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; /* Q8 */ - int16_t totalNoise_increase_len; + Word16 totalNoise_increase_len; /*----------------------------------------------------------------------------------* * SC-VBR parameters @@ -1564,7 +1562,7 @@ typedef struct enc_core_structure Word16 old_hpfilt_out_fx; Word32 EnergyLT_fx; /* Q(EnergyLT_fx_exp) */ Word32 Energy_Old_fx; - int16_t TransientHangOver; + Word16 TransientHangOver; HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ @@ -1588,21 +1586,21 @@ typedef struct enc_core_structure Word16 lt_mean_NB_fx; /* Q11 */ Word16 lt_mean_WB_fx; /* Q11 */ Word16 lt_mean_SWB_fx; /* Q11 */ - int16_t count_WB; - int16_t count_SWB; - int16_t count_FB; + Word16 count_WB; + Word16 count_SWB; + Word16 count_FB; /*----------------------------------------------------------------------------------* * Channel-aware mode *----------------------------------------------------------------------------------*/ - int16_t rf_mode; /* flag to signal the RF mode */ - int16_t rf_mode_last; - int16_t last_rf_mode_cng; - int16_t Opt_RF_ON; - int16_t rf_fec_offset; - int16_t rf_target_bits_write; - int16_t rf_fec_indicator; + Word16 rf_mode; /* flag to signal the RF mode */ + Word16 rf_mode_last; + Word16 last_rf_mode_cng; + Word16 Opt_RF_ON; + Word16 rf_fec_offset; + Word16 rf_target_bits_write; + Word16 rf_fec_indicator; RF_ENC_HANDLE hRF; /* RF encoder handle */ @@ -1650,17 +1648,17 @@ typedef struct enc_core_structure Word16 *wspeech_enc; // exp_buf_wspeech_enc Word16 *synth; - int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ - int16_t envWeighted; /* are is{p,f}_old_q[] weighted or not? */ + Word16 enableTcxLpc; /* global toggle for the TCX LPC quantizer */ + Word16 envWeighted; /* are is{p,f}_old_q[] weighted or not? */ - int16_t acelpEnabled; /* Flag indicating if ACELP can be used */ - int16_t tcx10Enabled; /* Flag indicating if TCX 10 can be used */ - int16_t tcx20Enabled; /* Flag indicating if TCX 20 can be used */ + Word16 acelpEnabled; /* Flag indicating if ACELP can be used */ + Word16 tcx10Enabled; /* Flag indicating if TCX 10 can be used */ + Word16 tcx20Enabled; /* Flag indicating if TCX 20 can be used */ Word16 mem_wsp_enc; /* wsp vector memory */ - int16_t nb_bits_header_ace; /* number of bits for the header */ - int16_t nb_bits_header_tcx; /* number of bits for the header */ + Word16 nb_bits_header_ace; /* number of bits for the header */ + Word16 nb_bits_header_tcx; /* number of bits for the header */ Word16 preemph_fac; /*Preemphasis factor Q15*/ Word16 gamma; /* Q15 */ @@ -1669,7 +1667,7 @@ typedef struct enc_core_structure TRAN_DET_HANDLE hTranDet; TransientDetection transientDetection; Word16 transient_info[3]; - int16_t acelpFramesCount; + Word16 acelpFramesCount; Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E Q7 in EVS */ /* Q4 in IVAS */ // float currEnergyLookAhead; @@ -1684,34 +1682,34 @@ typedef struct enc_core_structure Word16 parcorr[2]; Word16 parcorr_mid[2]; - int16_t lpcQuantization; + Word16 lpcQuantization; Word16 numlpc; - int16_t encoderLookahead_enc; - int16_t encoderPastSamples_enc; - int16_t encoderLookahead_FB; + Word16 encoderLookahead_enc; + Word16 encoderPastSamples_enc; + Word16 encoderLookahead_FB; /* pitch_ol for adaptive lag window */ - int16_t old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ + Word16 old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ Word32 band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor MODE2_E_MIN */ Word16 band_energies_exp; /* exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ - int16_t acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ + Word16 acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ - int16_t pit_min; - int16_t pit_fr1; - int16_t pit_fr1b; - int16_t pit_fr2; - int16_t pit_max; - int16_t pit_res_max; + Word16 pit_min; + Word16 pit_fr1; + Word16 pit_fr1b; + Word16 pit_fr2; + Word16 pit_max; + Word16 pit_res_max; /* for FAC */ - int16_t L_frame_past; + Word16 L_frame_past; /*Adaptive BPF*/ - int16_t bpf_gain_param; + Word16 bpf_gain_param; Word32 mem_bpf_fx1[2 * L_FILT16k]; Word32 mem_error_bpf_fx[2 * L_FILT16k]; Word16 bpf_T[NB_SUBFR16k]; @@ -1726,24 +1724,24 @@ typedef struct enc_core_structure Word16 noise_shift_old; } mem_bpf_fx; - int16_t glr; - int16_t glr_idx[2]; + Word16 glr; + Word16 glr_idx[2]; Word32 mean_gc[2]; /* Q15 */ Word16 prev_lsf4_mean; /* Qlog2(2.56) */ - int16_t glr_reset; - int32_t last_sr_core; + Word16 glr_reset; + Word32 last_sr_core; Word16 last_stab_fac; /* Q15 */ Word32 gain_code[NB_SUBFR16k]; /*for rate switching*/ - int16_t rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ - int16_t rate_switching_reset_16kHz; + Word16 rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ + Word16 rate_switching_reset_16kHz; - int16_t enablePlcWaveadjust; - int16_t Tonal_SideInfo; + Word16 enablePlcWaveadjust; + Word16 Tonal_SideInfo; - int16_t seed_acelp; + Word16 seed_acelp; PLC_ENC_EVS_HANDLE hPlcExt; @@ -1752,23 +1750,23 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ IGF_ENC_INSTANCE_HANDLE hIGFEnc; /* IGF encoder handle */ - int16_t igf; + Word16 igf; /*----------------------------------------------------------------------------------* * TEC *----------------------------------------------------------------------------------*/ - int16_t tec_tfa; + Word16 tec_tfa; TEC_ENC_HANDLE hTECEnc; /* TEC encoder handle */ - int16_t tec_flag; - int16_t tfa_flag; + Word16 tec_flag; + Word16 tfa_flag; Word32 tfa_enr[N_TEC_TFA_SUBFR]; /*---------------------------------------------------------------* * IVAS parameters *---------------------------------------------------------------*/ - int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ + Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ Word16 cna_dirac_flag; /* CNA in DirAC flag */ /* stereo switching memories */ @@ -1813,24 +1811,24 @@ typedef struct enc_core_structure Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; - int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ + Word16 sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ } Encoder_State, *ENC_CORE_HANDLE; typedef struct GainItemStr { - int16_t gainIndex; + Word16 gainIndex; } GainItem; typedef struct context_rc_mem_struct { - int16_t nbits_old; - int16_t ctx; + Word16 nbits_old; + Word16 ctx; Word64 bit_estimate_fx; /* Q23 */ - int16_t rateFlag; - int16_t lastnz; - int16_t nt_half; + Word16 rateFlag; + Word16 lastnz; + Word16 nt_half; } RC_CONTEXT_MEM, *HANDLE_RC_CONTEXT_MEM; diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 2ca0b6d74..b1a3f2f20 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -282,7 +282,7 @@ void wb_bwe_enc_ivas_fx( *-------------------------------------------------------------------*/ void swb_bwe_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ + const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */ const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 3bad5fa7f..7bbc54780 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1390,7 +1390,7 @@ void swb_pre_proc_ivas_fx( } /* Dirty downsampling to match Nyquist to upper frequency limit of target */ - lerp( st->input_fx, new_swb_speech, L_resamp, (int16_t) Mpy_32_32( input_Fs, one_by_50_Q31 ) ); + lerp( st->input_fx, new_swb_speech, L_resamp, extract_l( Mpy_32_32( input_Fs, one_by_50_Q31 ) ) ); /* flip the spectrum */ Copy( new_swb_speech, spchTmp, L_resamp ); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 2a6f040ac..7247b6446 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -48,14 +48,12 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, Word8 *noiseFlags, Word16 lowpassLine ) { - Word16 i, lastTone; + Word16 i, lastTone, j; Word32 s, c; Word16 tmp16; Word32 tmp1, tmp2 = 0; /* initialization only to avoid compiler warning, not counted */ move32(); - int j; - IF( resetMemory != 0 ) { FOR( i = 0; i < lowpassLine; i++ ) @@ -81,7 +79,7 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, i = sub( startLine, 1 ); s = 0; move32(); - for ( j = -7; j < 8; j++ ) + FOR( j = -7; j < 8; j++ ) { s = L_add( s, L_shr( powerSpec[i + j], 4 ) ); } diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 82d24ceba..3c88ca224 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -1288,7 +1288,7 @@ static void UpdateDelayBuffer( Word16 const *input, Word16 nSamplesAvailable, De move16(); nDelay = pDelayBuffer->nDelay; - assert( ( nDelay >= 0 ) && ( nDelay <= (int) sizeof( pDelayBuffer->buffer ) / (int) sizeof( pDelayBuffer->buffer[0] ) ) ); + assert( ( nDelay >= 0 ) && ( nDelay <= (Word32) sizeof( pDelayBuffer->buffer ) / (Word32) sizeof( pDelayBuffer->buffer[0] ) ) ); assert( nSamplesAvailable <= NSUBBLOCKS * pDelayBuffer->nSubblockSize ); /* If this is not the last frame */ IF( EQ_16( nSamplesAvailable, imult1616( NSUBBLOCKS, pDelayBuffer->nSubblockSize ) ) ) @@ -1307,7 +1307,7 @@ static void UpdateSubblockEnergies( Word16 const *input, Word16 nSamplesAvailabl Word16 i; - assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (int) sizeof( pSubblockEnergies->subblockNrg ) / (int) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); + assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (Word32) sizeof( pSubblockEnergies->subblockNrg ) / (Word32) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); assert( pSubblockEnergies->nPartialDelay <= pSubblockEnergies->pDelayBuffer->nDelay ); /* At least one block delay is required when subblock energy change is required */ assert( pSubblockEnergies->nDelay >= 1 ); @@ -1332,7 +1332,7 @@ static void UpdateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamples Word16 i; - assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (int) sizeof( pSubblockEnergies->subblockNrg ) / (int) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); + assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (Word32) sizeof( pSubblockEnergies->subblockNrg ) / (Word32) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); assert( pSubblockEnergies->nPartialDelay <= pSubblockEnergies->pDelayBuffer->nDelay ); /* At least one block delay is required when subblock energy change is required */ assert( pSubblockEnergies->nDelay >= 1 ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 7e41581f4..730705ffd 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -83,8 +83,8 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; typedef struct hrtfGainCache { - int16_t azi; - int16_t ele; + Word16 azi; + Word16 ele; Word32 shVec_fx[HRTF_SH_CHANNELS]; @@ -92,13 +92,13 @@ typedef struct hrtfGainCache typedef struct parambin_rend_config_data { - int16_t separateCenterChannelRendering; + Word16 separateCenterChannelRendering; IVAS_FORMAT ivas_format; MC_MODE mc_mode; - int32_t ivas_total_brate; - int16_t nchan_transport; + Word32 ivas_total_brate; + Word16 nchan_transport; Word32 qualityBasedSmFactor_fx; /* Q31 */ - int16_t processReverb; + Word16 processReverb; ISM_MODE ism_mode; } PARAMBIN_REND_CONFIG, *PARAMBIN_REND_CONFIG_HANDLE; @@ -113,7 +113,7 @@ static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBi static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 Rmat_fx[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData, Word16 q ); -static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const Word16 max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat ); @@ -137,8 +137,8 @@ static void matrixTransp2Mul_fx( Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, #ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx - int Ascale, - int Bscale, + Word32 Ascale, + Word32 Bscale, #endif Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, @@ -3810,8 +3810,8 @@ static void matrixTransp2Mul_fx( Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ Word16 *q_B, #ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx - int Ascale, - int Bscale, + Word32 Ascale, + Word32 Bscale, #endif Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 32803f6c3..e89414542 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -67,7 +67,7 @@ *------------------------------------------------------------------------*/ static void get_lattice_coeffs_fx( const Word16 band_index, const Word16 channel_index, Word16 *lattice_coeffs ); -static void lattice2allpass_fx( const int16_t filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, Word16 *filter_coeffs_den_real_fx ); +static void lattice2allpass_fx( const Word16 filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, Word16 *filter_coeffs_den_real_fx ); /*------------------------------------------------------------------------- * ivas_dirac_dec_decorr_open() @@ -1280,7 +1280,7 @@ static void get_lattice_coeffs_fx( /* convert lattice filter coeffs to all pass transfer function coeffs */ static void lattice2allpass_fx( - const int16_t filter_length, // Q0 + const Word16 filter_length, // Q0 const Word16 *lattice_coeffs_fx, // Q15 Word16 *filter_coeffs_num_real_fx, // Q12 Word16 *filter_coeffs_den_real_fx ) // Q12 diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6b41815c4..c8e6aa12f 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -165,13 +165,13 @@ static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, co * *------------------------------------------------------------------------*/ -static uint16_t binRend_rand( +static UWord16 binRend_rand( REVERB_STRUCT_HANDLE hReverb /* i/o: binaural reverb handle */ ) { hReverb->binRend_RandNext = hReverb->binRend_RandNext * 1103515245 + 12345; - return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768; + return (UWord16) ( hReverb->binRend_RandNext / 65536 ) % 32768; } @@ -886,9 +886,9 @@ static ivas_error calc_jot_t60_coeffs_fx( Word32 L_tmp; Word16 f0_fx, tmp_fx, lf_target_gain_dB_fx, hf_target_gain_dB_fx, mid_crossing_gain_dB_fx; Word16 lin_gain_lf_fx, lin_gain_hf_fx, shift, expl, exph; - int16_t f_idx, e = pH_dB_exp; + Word16 f_idx, e = pH_dB_exp; move16(); - uint16_t n_points_lf, n_points_hf; + UWord16 n_points_lf, n_points_hf; lf_target_gain_dB_fx = 0; move16(); @@ -1471,7 +1471,7 @@ ivas_error ivas_reverb_open_fx( { ivas_error error; REVERB_HANDLE pState = NULL; - Word16 bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; + Word16 bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx, i; ivas_reverb_params_t params; Word32 pColor_target_l_fx[RV_LENGTH_NR_FC]; Word32 pColor_target_r_fx[RV_LENGTH_NR_FC]; @@ -1559,7 +1559,7 @@ ivas_error ivas_reverb_open_fx( set_reverb_acoustic_data_fx( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { params.pRt60_fx[i] = L_abs( params.pRt60_fx[i] ); move32(); @@ -1601,7 +1601,7 @@ ivas_error ivas_reverb_open_fx( Word32 *pT60_filter_coeff = (Word32 *) malloc( ( lenT60_filter_coeff ) * sizeof( Word32 * ) ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { params.pDsr_fx[i] = L_shl( params.pDsr_fx[i], params.pDsr_e[i] ); move32(); @@ -1610,7 +1610,7 @@ ivas_error ivas_reverb_open_fx( pHrtf_avg_pwr_response_r_const[i] = L_shl( params.pHrtf_avg_pwr_response_r_const_fx[i], 5 ); /*Q23+5*/ move32(); } - FOR( Word16 i = 0; i < lenT60_filter_coeff; i++ ) + FOR( i = 0; i < lenT60_filter_coeff; i++ ) { pT60_filter_coeff[i] = L_shl_sat( params.pT60_filter_coeff_fx[i], 17 ); move32(); @@ -1648,20 +1648,20 @@ ivas_error ivas_reverb_open_fx( { /* Computing correlation filters on the basis of target IA coherence */ #ifdef MSAN_FIX - FOR( int i = 0; i < shl( sub( nr_fc_fft_filter, 1 ), 1 ); i++ ) + FOR( i = 0; i < shl( sub( nr_fc_fft_filter, 1 ), 1 ); i++ ) { pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 ); /*Scaling signal down to 30*/ move32(); } #else - FOR( int i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++ ) + FOR( i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++ ) { pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 ); /*Scaling signal down to 30*/ } #endif // MSAN_FIX Word32 *pHrtf_inter_aural_coherence_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 ) ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pHrtf_inter_aural_coherence_const[i] = L_shl( params.pHrtf_inter_aural_coherence_const_fx[i], 3 ); /*Scaling up to Q30*/ move32(); @@ -1670,14 +1670,14 @@ ivas_error ivas_reverb_open_fx( free( pHrtf_inter_aural_coherence_const ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch0_fx[i][0] = L_shl( pFft_wf_filter_ch0_fx[i][0], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); pFft_wf_filter_ch0_fx[i][1] = L_shl( pFft_wf_filter_ch0_fx[i][1], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); } - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], sub( 31, q_pFft_wf_filter_ch1_fx ) ); move32(); @@ -1699,14 +1699,14 @@ ivas_error ivas_reverb_open_fx( /* Computing coloration filters on the basis of target responses */ ivas_reverb_calc_color_filters_fx( pColor_target_l_fx, pColor_target_r_fx, pTime_window_fx, pState->fft_size, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx ); - FOR( int i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch0_fx[i][0] = L_shl( pFft_wf_filter_ch0_fx[i][0], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); pFft_wf_filter_ch0_fx[i][1] = L_shl( pFft_wf_filter_ch0_fx[i][1], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); } - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], sub( 31, q_pFft_wf_filter_ch1_fx ) ); move32(); @@ -2492,7 +2492,7 @@ ivas_error ivas_binaural_reverb_open_parambin( const Word16 numBins, /* i : number of CLDFB bins Q0 */ const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const int32_t sampling_rate, /* i : sampling rate Q0 */ + const Word32 sampling_rate, /* i : sampling rate Q0 */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ) { diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index bc0d3cd17..2b4c3e919 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -56,13 +56,13 @@ extern Word32 CRendBin_Combined_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_Combined_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_Combined_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[15]; -extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_Combined_HRIR_coeff_im_48kHz_fx[15][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -70,13 +70,13 @@ extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNEL /* Sample Rate = 32000 */ -extern int16_t CRendBin_Combined_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_Combined_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[15]; -extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_32kHz_fx[15][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_Combined_HRIR_coeff_im_32kHz_fx[15][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -84,13 +84,13 @@ extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNEL /* Sample Rate = 16000 */ -extern int16_t CRendBin_Combined_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_Combined_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[15]; -extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_16kHz_fx[15][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_Combined_HRIR_coeff_im_16kHz_fx[15][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -105,13 +105,13 @@ extern Word32 CRendBin_FOA_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_FOA_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_FOA_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[4]; -extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_48kHz_fx[4][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_FOA_HRIR_coeff_im_48kHz_fx[4][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -119,13 +119,13 @@ extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ -extern int16_t CRendBin_FOA_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_FOA_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[4]; -extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_32kHz_fx[4][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_FOA_HRIR_coeff_im_32kHz_fx[4][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -133,13 +133,13 @@ extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ -extern int16_t CRendBin_FOA_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_FOA_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[4]; -extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_16kHz_fx[4][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_FOA_HRIR_coeff_im_16kHz_fx[4][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -153,13 +153,13 @@ extern Word32 CRendBin_HOA2_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_HOA2_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_HOA2_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[9]; -extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_48kHz_fx[9][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_48kHz_fx[9][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -167,13 +167,13 @@ extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ -extern int16_t CRendBin_HOA2_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_HOA2_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[9]; -extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_32kHz_fx[9][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_32kHz_fx[9][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -181,13 +181,13 @@ extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ -extern int16_t CRendBin_HOA2_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_HOA2_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[9]; -extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[9][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[9][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -200,13 +200,13 @@ extern Word32 CRendBin_HOA3_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_HOA3_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_HOA3_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[16]; -extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_48kHz_fx[16][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_48kHz_fx[16][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -214,13 +214,13 @@ extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ -extern int16_t CRendBin_HOA3_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_HOA3_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[16]; -extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_32kHz_fx[16][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_32kHz_fx[16][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -228,13 +228,13 @@ extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ -extern int16_t CRendBin_HOA3_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_HOA3_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[16]; -extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_16kHz_fx[16][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_16kHz_fx[16][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -248,13 +248,13 @@ extern Word32 CRendBin_Combined_BRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_Combined_BRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]; -extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_Combined_BRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]; +extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[15]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_im_48kHz_fx[15][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS][2885]; @@ -262,13 +262,13 @@ extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS /* Sample Rate = 32000 */ -extern int16_t CRendBin_Combined_BRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]; -extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_Combined_BRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]; +extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[15]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_32kHz_fx[15][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_im_32kHz_fx[15][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS][2870]; @@ -276,13 +276,13 @@ extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS /* Sample Rate = 16000 */ -extern int16_t CRendBin_Combined_BRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]; -extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_Combined_BRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]; +extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[15]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_16kHz_fx[15][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[15][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2522]; diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 068ce0927..be015058b 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -56,35 +56,35 @@ const Word32 CRendBin_Combined_HRIR_latency_s_fx = 44741;/*Q-31*/ /* Sample Rate = 48000 */ -const int16_t CRendBin_Combined_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_Combined_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_Combined_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_Combined_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_Combined_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_Combined_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -96,35 +96,35 @@ const Word32 CRendBin_FOA_HRIR_latency_s_fx = 44741; // Q31 /* Sample Rate = 48000 */ -const int16_t CRendBin_FOA_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_FOA_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[4]={0, 0, 0, 0}; -const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_FOA_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_FOA_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[4]={0, 0, 0, 0}; -const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_FOA_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_FOA_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[4]={0, 0, 0, 0}; -const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -135,35 +135,35 @@ const Word32 CRendBin_HOA2_HRIR_latency_s_fx = 44741; // Q31 /* Sample Rate = 48000 */ -const int16_t CRendBin_HOA2_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_HOA2_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_HOA2_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_HOA2_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_HOA2_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_HOA2_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -173,36 +173,36 @@ const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={N const Word32 CRendBin_HOA3_HRIR_latency_s_fx = 44741;/*Q-31*/ /* Sample Rate = 48000 */ -const int16_t CRendBin_HOA3_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_HOA3_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_HOA3_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_HOA3_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_HOA3_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_HOA3_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz = 0; const float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[16]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -212,34 +212,34 @@ const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={N const Word32 CRendBin_Combined_BRIR_latency_s_fx = 313176;/*Q-31*/ /* Sample Rate = 48000 */ -const int16_t CRendBin_Combined_BRIR_max_num_iterations_48kHz = 22; -const uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; -const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {40, 40}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]={{{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240},{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240}},{{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240},{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240}},{{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240},{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240}},{{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240},{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240}},{{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240},{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240}},{{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240},{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240}},{{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240},{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240}},{{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240},{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240}},{{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240},{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240}},{{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240},{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240}},{{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240},{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240}},{{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240},{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240}},{{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240},{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240}},{{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240},{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240}},{{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240},{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240}}}; -const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz = 98; +const Word16 CRendBin_Combined_BRIR_max_num_iterations_48kHz = 22; +const UWord16 CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; +const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {40, 40}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]={{{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240},{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240}},{{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240},{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240}},{{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240},{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240}},{{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240},{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240}},{{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240},{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240}},{{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240},{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240}},{{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240},{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240}},{{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240},{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240}},{{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240},{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240}},{{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240},{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240}},{{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240},{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240}},{{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240},{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240}},{{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240},{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240}},{{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240},{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240}},{{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240},{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240}}}; +const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz = 98; const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[15]={0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[15]={7346, 7453, 7924, 6788, 7146, 7305, 7607, 8133, 8167, 8571, 8069, 9147, 9361, 8602, 8907,}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; /* Sample Rate = 32000 */ -const int16_t CRendBin_Combined_BRIR_max_num_iterations_32kHz = 22; -const uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; -const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {40, 40}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]={{{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160},{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160}},{{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160},{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160}},{{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160},{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160}},{{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160},{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160}},{{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160},{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160}},{{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160},{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160}},{{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160},{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160}},{{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160},{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160}},{{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160},{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160}},{{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160},{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160}},{{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160},{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160}},{{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160},{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160}},{{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160},{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160}},{{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160},{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160}},{{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160},{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160}}}; -const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz = 97; +const Word16 CRendBin_Combined_BRIR_max_num_iterations_32kHz = 22; +const UWord16 CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; +const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {40, 40}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]={{{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160},{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160}},{{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160},{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160}},{{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160},{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160}},{{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160},{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160}},{{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160},{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160}},{{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160},{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160}},{{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160},{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160}},{{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160},{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160}},{{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160},{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160}},{{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160},{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160}},{{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160},{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160}},{{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160},{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160}},{{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160},{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160}},{{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160},{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160}},{{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160},{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160}}}; +const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz = 97; const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[15]={0.224190f, 0.227445f, 0.241827f, 0.207131f, 0.218113f, 0.222941f, 0.232139f, 0.248192f, 0.249239f, 0.261572f, 0.246309f, 0.279145f, 0.285786f, 0.262528f, 0.271847f}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[15]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907,}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; /* Sample Rate = 16000 */ -const int16_t CRendBin_Combined_BRIR_max_num_iterations_16kHz = 23; -const uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23} }; -const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {40, 40}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]={{{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80},{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80}},{{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80},{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80}},{{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80},{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80}},{{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80},{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80}},{{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80},{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80}},{{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80},{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80}},{{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80},{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80}},{{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80},{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80}},{{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80},{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80}},{{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80},{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80}},{{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80},{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80}},{{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80},{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80}},{{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80},{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80}},{{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80},{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80}},{{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80},{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80}}}; -const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz = 77; +const Word16 CRendBin_Combined_BRIR_max_num_iterations_16kHz = 23; +const UWord16 CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23} }; +const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {40, 40}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]={{{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80},{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80}},{{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80},{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80}},{{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80},{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80}},{{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80},{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80}},{{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80},{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80}},{{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80},{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80}},{{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80},{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80}},{{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80},{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80}},{{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80},{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80}},{{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80},{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80}},{{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80},{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80}},{{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80},{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80}},{{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80},{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80}},{{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80},{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80}},{{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80},{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80}}}; +const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz = 77; const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[15]={0.223532f, 0.226827f, 0.248830f, 0.208782f, 0.220391f, 0.219790f, 0.231187f, 0.248730f, 0.251408f, 0.263698f, 0.243858f, 0.281483f, 0.283080f, 0.261660f, 0.273527f}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[15]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77}}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77}}; //BRIR and HRIR coeff tables in Q29 const Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][2955] ={ { diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 54940355c..2b46ff611 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -49,9 +49,9 @@ const Word16 diffuse_response_CICP6_fx[5] = { 13824, 13824, 12137, 16495, 16495 const Word16 diffuse_response_CICP14_fx[7] = { 12507, 12507, 9237, 17691, 17691, 4977, 4977 };//Q15 const Word16 diffuse_response_CICP16_fx[9] = { 11324, 11324, 9945, 13513, 13513, 8853, 8853, 9905, 9905 };//Q15 -const int16_t ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 7, 2, 1 }; +const Word16 ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 7, 2, 1 }; -const int16_t ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 15, 6, 3 }; +const Word16 ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 15, 6, 3 }; const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECORR_FILTER_LEN] /*Q14*/ = { @@ -91,11 +91,11 @@ const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]/*Q14*/ = 0 , 2048, 6144, 16384 }; -const int16_t sba_map_tc[11] = +const Word16 sba_map_tc[11] = { 0, 1, 2, 3, 4, 8, 9, 15, 5, 6, 7 }; -const int16_t sba_map_tc_512[11] = +const Word16 sba_map_tc_512[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 }; @@ -121,11 +121,11 @@ const int16_t sba_map_tc_512[11] = * 13 = 135, 35 * 14 = -135, 35 */ -const int16_t channelIndex_CICP6[5] = { 0, 1, 2, 5, 6 }; -const int16_t channelIndex_CICP12[7] = { 0, 1, 2, 5, 6, 3, 4 }; -const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; -const int16_t channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 }; -const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; +const Word16 channelIndex_CICP6[5] = { 0, 1, 2, 5, 6 }; +const Word16 channelIndex_CICP12[7] = { 0, 1, 2, 5, 6, 3, 4 }; +const Word16 channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; +const Word16 channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 }; +const Word16 channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] /* Q13 */ = { @@ -160,7 +160,7 @@ const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFERENCE_B * TD ISM binaural renderer ROM tables *----------------------------------------------------------------------------------*/ -const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = +const Word16 HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = { 13, 12, 11 }; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 22ed7ed65..0a489600a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -88,7 +88,7 @@ typedef enum IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN, } IVAS_REND_AudioConfigType; -typedef uint16_t IVAS_REND_InputId; +typedef UWord16 IVAS_REND_InputId; typedef enum _IVAS_REND_COMPLEXITY_LEVEL { -- GitLab From d94a7eff4bf5be0f0b522420ddb8463d14c81108 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 11 Mar 2025 07:57:46 +0100 Subject: [PATCH 296/329] move switches in options.h to have porting section last --- lib_com/options.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7aeea040f..5ce425476 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,9 @@ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ +//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ +#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ +#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ /* #################### Start BASOP porting switches ############################ */ @@ -179,7 +182,4 @@ /* #################### End BASOP porting switches ############################ */ -//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif -- GitLab From 919bec712ef79ca4e3f5d4f559c28d5032974833 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 12:49:24 +0530 Subject: [PATCH 297/329] Fix for 3GPP issue 1342: Decoder crash for Stereo at 48/64 kbps mono decoding in IMDCT_ivas_fx() Link #1342 --- lib_com/edct_fx.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 8d77da13a..b1e2a7dd9 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -592,11 +592,12 @@ void edxt_fx( const UWord16 synthesis /* i : nonzero for inverse Q0*/ ) { - Word16 k, m, fac; + Word16 k, m, fac, hdrm, tmp = 0; const Word16 *cosPtr, *sinPtr; Word16 n; n = 0; move16(); + move16(); cosPtr = NULL; sinPtr = NULL; IF( EQ_16( length, 512 ) ) @@ -735,7 +736,23 @@ void edxt_fx( IF( EQ_16( length, 512 ) ) { + /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */ + hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) ); + IF( LT_16( hdrm, 4 ) ) + { + tmp = sub( hdrm, 4 ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } + DoRTFTn_fx( re, im, 512 ); + + IF( LT_16( hdrm, 4 ) ) + { + tmp = negate( tmp ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } } ELSE /* fft() doesn't support 512 */ { @@ -831,7 +848,23 @@ void edxt_fx( IF( EQ_16( length, 512 ) ) { + /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */ + hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) ); + IF( LT_16( hdrm, 4 ) ) + { + tmp = sub( hdrm, 4 ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } + DoRTFTn_fx( re, im, 512 ); + + IF( LT_16( hdrm, 4 ) ) + { + tmp = negate( tmp ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } } ELSE /* fft() doesn't support 512 */ { -- GitLab From 9d3de014d988ce108565071fe569b5f88bd9faed Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 13:51:43 +0530 Subject: [PATCH 298/329] Fix for 3GPP issue 1202: BASOP encoder ParamISM: strong timbre differences in the noise track - 2 [x] Link #1202 [x] Corrected the formula for the computation of xcorr_ene_fx which then rectifies the computation of hISMDTX->coh_fx that leads to proper value of idx being written to the bitstream on the encoder side. --- lib_enc/ivas_ism_dtx_enc_fx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 64b8991d6..f99043708 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -445,9 +445,9 @@ void ivas_ism_coh_estim_dtx_enc_fx( Word16 sce_id, i; Word32 acorr_ene_fx[MAX_NUM_OBJECTS], xcorr_ene_fx; Word16 acorr_ene_e[MAX_NUM_OBJECTS], xcorr_ene_e; - Word16 norm_inp; - Word16 tot_exp; - Word32 scaled_inp; + Word16 norm_inp, norm_inp0; + Word16 tot_exp, tot_exp2; + Word32 scaled_inp, scaled_inp0; set16_fx( acorr_ene_e, 0, MAX_NUM_OBJECTS ); IF( EQ_16( nchan_transport, 1 ) ) @@ -493,10 +493,13 @@ void ivas_ism_coh_estim_dtx_enc_fx( { norm_inp = norm_l( st->input32_fx[i] ); scaled_inp = L_shl( st->input32_fx[i], norm_inp ); - tot_exp = shl( sub( 20, norm_inp ), 1 ); + tot_exp = shl( sub( sub(31, st->q_inp32), norm_inp ), 1 ); acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] ); /* exp(acorr_ene_e) */ move32(); - xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &xcorr_ene_e ); /* exp(xcorr_ene_e) */ + norm_inp0 = norm_l( st_id0->input32_fx[i] ); + scaled_inp0 = L_shl( st_id0->input32_fx[i], norm_inp0 ); + tot_exp2 = add( sub( sub( 31, st_id0->q_inp32 ), norm_inp0 ), sub( sub( 31, st->q_inp32 ), norm_inp ) ); + xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp0 ), tot_exp2, &xcorr_ene_e ); /* exp(xcorr_ene_e) */ } Word16 coh_e; Word16 temp_e = acorr_ene_e[hISMDTX->sce_id_dtx] + acorr_ene_e[sce_id]; -- GitLab From 22acde4d19351ed8a7c2fc93c338e6eb44276da5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:01:34 +0530 Subject: [PATCH 299/329] Clang formatting changes --- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index f99043708..1a4110245 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -493,7 +493,7 @@ void ivas_ism_coh_estim_dtx_enc_fx( { norm_inp = norm_l( st->input32_fx[i] ); scaled_inp = L_shl( st->input32_fx[i], norm_inp ); - tot_exp = shl( sub( sub(31, st->q_inp32), norm_inp ), 1 ); + tot_exp = shl( sub( sub( 31, st->q_inp32 ), norm_inp ), 1 ); acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] ); /* exp(acorr_ene_e) */ move32(); norm_inp0 = norm_l( st_id0->input32_fx[i] ); -- GitLab From 4d386408b80762fd726b85cf4b3c4923be40ee8b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:07:06 +0530 Subject: [PATCH 300/329] Fix for 3GPP issue 1004: Modulation artifact in OMASA at 24 kbps using LTV 3ISM 2TC input and output to MONO Link #1004, #1363 Fixes 3GPP issue #1363: Assert in BASOP decoder function protoSignalComputation2_fx when fed with BASOP encoder MASA bitstream --- lib_rend/ivas_dirac_rend_fx.c | 93 ++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index cc8e4d8bd..958a23a3f 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -1692,7 +1692,7 @@ void protoSignalComputation2_fx( Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx; Word32 sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS]; Word16 q_sum_total_ratio; - Word32 a_fx, b_fx; + Word32 a_fx, b_fx, a2_fx, b2_fx; Word16 interpolatorSpaced_fx, interpolatorDmx_fx; Word32 tempSpaced_fx, tempDmx_fx; Word16 q_shift, min_q_shift, exp, q_temp, temp_q_shift, q_temp2; @@ -1700,6 +1700,7 @@ void protoSignalComputation2_fx( Word64 W_tmp1, W_tmp2; Word64 reference_power_64fx[CLDFB_NO_CHANNELS_MAX]; Word16 q_reference_power_64fx; + Word16 head_room, q_Left_Right_power; /* Calculate maximum possible shift for the buffers RealBuffer_fx and ImagBuffer_fx */ min_q_shift = Q31; move16(); @@ -1866,8 +1867,10 @@ void protoSignalComputation2_fx( a_fx = 21474836; /*0.01 in Q31*/ /* Temporal smoothing coefficient */ move32(); b_fx = L_sub( ONE_IN_Q31, a_fx ); /* Temporal smoothing coefficient q31*/ - // a2_fx = 214748365; /*0.1 in Q31*/ /* Temporal smoothing coefficient */ - // b2_fx = L_sub( ONE_IN_Q31, a2_fx ); /* Temporal smoothing coefficient */ + move32(); + a2_fx = 214748365; /*0.1 in Q31*/ /* Temporal smoothing coefficient */ + move32(); + b2_fx = L_sub( ONE_IN_Q31, a2_fx ); /* Temporal smoothing coefficient */ IF( stereo_type_detect->interpolator > 0 ) { @@ -1890,6 +1893,23 @@ void protoSignalComputation2_fx( q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); q_temp2 = sub( add( add( q_cldfb, temp_q_shift ), add( q_cldfb, temp_q_shift ) ), 31 ); + head_room = 63; + move16(); + FOR( l = 0; l < num_freq_bands; l++ ) + { + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + + W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); + W_tmp2 = W_add( W_mult0_32_32( re2, re2 ), W_mult0_32_32( im2, im2 ) ); + + head_room = s_min( head_room, W_norm( W_add( W_tmp1, W_tmp2 ) ) ); + } + head_room = sub( head_room, find_guarded_bits_fx( num_freq_bands ) ); + q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift ), 1 ), sub( head_room, 32 ) ); + FOR( l = 0; l < num_freq_bands; l++ ) { re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift @@ -1904,26 +1924,26 @@ void protoSignalComputation2_fx( /* Compute reference power */ // Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); // 2*(q_cldfb+min_q_shift) - Left_power_fx = W_extract_l( W_shr( W_tmp1, 31 ) ); + Left_power_fx = W_extract_h( W_shl( W_tmp1, head_room ) ); // q_Left_Right_power // Right_power_fx = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); W_tmp2 = W_add( W_mult0_32_32( re2, re2 ), W_mult0_32_32( im2, im2 ) ); // 2*(q_cldfb+min_q_shift) - Right_power_fx = W_extract_l( W_shr( W_tmp2, 31 ) ); + Right_power_fx = W_extract_h( W_shl( W_tmp2, head_room ) ); // q_Left_Right_power // reference_power_fx[l] = L_add( Left_power_fx, Right_power_fx ); reference_power_64fx[l] = W_add( W_tmp1, W_tmp2 ); // 2*(q_cldfb+min_q_shift) move64(); - left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // 2*(q_cldfb+min_q_shift) -31 + left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // q_Left_Right_power + right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // q_Left_Right_power // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); - total_bb_power_fx = L_add( total_bb_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 + total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power IF( GT_16( l, MASA_HI_FREQ_START_BIN ) ) { - left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // 2*(q_cldfb+min_q_shift) -31 + left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // q_Left_Right_power + right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // q_Left_Right_power // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); - total_hi_power_fx = L_add( total_hi_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 + total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power } IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) @@ -1960,12 +1980,17 @@ void protoSignalComputation2_fx( test(); IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) ) { - sum_total_ratio_fx[l] = MAX_16; // q15 + sum_total_ratio_fx[l] = MAX_32; // q15 + move32(); + } + ELSE IF( stereo_type_detect->total_power_fx[l] == 0 ) + { + sum_total_ratio_fx[l] = MAX_32; // q15 move32(); } ELSE { - sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) + sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) move32(); q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); // q15 @@ -2237,45 +2262,45 @@ void protoSignalComputation2_fx( } } - temp = Mpy_32_32( a_fx, left_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp, stereo_type_detect->q_left_bb_power ) ) + temp = Mpy_32_32( a_fx, left_bb_power_fx ); // q_Left_Right_power + IF( LT_16( q_Left_Right_power, stereo_type_detect->q_left_bb_power ) ) { - stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_temp ) ) ); // q_temp + stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_Left_Right_power ) ) ); // q_Left_Right_power move32(); - stereo_type_detect->q_left_bb_power = q_temp; + stereo_type_detect->q_left_bb_power = q_Left_Right_power; move16(); } ELSE { - stereo_type_detect->left_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ) ); // stereo_type_detect->q_left_bb_power + stereo_type_detect->left_bb_power_fx = Madd_32_32( L_shr( temp, sub( q_Left_Right_power, stereo_type_detect->q_left_bb_power ) ), b_fx, stereo_type_detect->left_bb_power_fx ); // stereo_type_detect->q_left_bb_power move32(); } - temp = Mpy_32_32( a_fx, right_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp, stereo_type_detect->q_right_bb_power ) ) + temp = Mpy_32_32( a_fx, right_bb_power_fx ); // q_Left_Right_power + IF( LT_16( q_Left_Right_power, stereo_type_detect->q_right_bb_power ) ) { - stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_temp ) ) ); // q_temp + stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_Left_Right_power ) ) ); // q_Left_Right_power move32(); - stereo_type_detect->q_right_bb_power = q_temp; + stereo_type_detect->q_right_bb_power = q_Left_Right_power; move16(); } ELSE { - stereo_type_detect->right_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ) ); // stereo_type_detect->q_right_bb_power + stereo_type_detect->right_bb_power_fx = Madd_32_32( L_shr( temp, sub( q_Left_Right_power, stereo_type_detect->q_right_bb_power ) ), b_fx, stereo_type_detect->right_bb_power_fx ); // stereo_type_detect->q_right_bb_power move32(); } - temp = Mpy_32_32( a_fx, total_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp, stereo_type_detect->q_total_bb_power ) ) + temp = Mpy_32_32( a_fx, total_bb_power_fx ); // q_Left_Right_power + IF( LT_16( q_Left_Right_power, stereo_type_detect->q_total_bb_power ) ) { - stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_temp ) ) ); // q_temp + stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_Left_Right_power ) ) ); // q_Left_Right_power move32(); - stereo_type_detect->q_total_bb_power = q_temp; + stereo_type_detect->q_total_bb_power = q_Left_Right_power; move16(); } ELSE { - stereo_type_detect->total_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ) ); // stereo_type_detect->q_total_bb_power + stereo_type_detect->total_bb_power_fx = Madd_32_32( L_shr( temp, sub( q_Left_Right_power, stereo_type_detect->q_total_bb_power ) ), b_fx, stereo_type_detect->total_bb_power_fx ); // stereo_type_detect->q_total_bb_power move32(); } @@ -2293,8 +2318,7 @@ void protoSignalComputation2_fx( q_lr_bb_power = stereo_type_detect->q_right_bb_power; move16(); } - q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */ - + q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */ temp = BASOP_Util_Divide3232_Scale_cadence( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power)) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_bb_power, stereo_type_detect->q_total_bb_power ) ) ); temp = BASOP_Util_Log2( temp ); // q25 @@ -2305,15 +2329,15 @@ void protoSignalComputation2_fx( // 20480 = 10 in Q11 lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 - stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); + stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); move32(); stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power ); move16(); - stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, right_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); + stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); move32(); stereo_type_detect->q_right_hi_power = sub( 31, stereo_type_detect->q_right_hi_power ); move16(); - stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, total_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); + stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); move32(); stereo_type_detect->q_total_hi_power = sub( 31, stereo_type_detect->q_total_hi_power ); move16(); @@ -2330,8 +2354,7 @@ void protoSignalComputation2_fx( move32(); q_lr_hi_power = stereo_type_detect->q_right_hi_power; } - q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ - + q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ temp = BASOP_Util_Divide3232_Scale_cadence( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) ); temp = BASOP_Util_Log2( temp ); // q25 -- GitLab From b2a9054e28a698b6e1f7f91f85e98a0c1d23a73f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:14:28 +0530 Subject: [PATCH 301/329] Fix for 3GPP issue 1048: Problem in stereo during bitrate switching and frame erasure Link #1048 --- lib_dec/er_dec_tcx_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 8c10e5f81..5cc06dabf 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1168,7 +1168,7 @@ void con_tcx_ivas_fx( /* apply pre-emphasis to the signal */ mem = synth[( -( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) - 1 )]; /*Q0*/ move16(); - Q_exc = E_UTIL_f_preemph3_ivas_fx( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); + Q_exc = E_UTIL_f_preemph3_ivas_fx( &( synth[-( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); st->Mode2_lp_gainc = L_deposit_l( 0 ); st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 7f079277a..a5855a0f6 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1282,11 +1282,6 @@ void ivas_mdct_core_reconstruct_fx( ELSE /*ACELP core for ACELP-PLC */ { assert( EQ_16( st->bfi, 1 ) ); - - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( -2, q_syn ) ); // Q0 - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( -2, q_syn ) ); // Q0 - q_syn = -2; - move16(); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) { @@ -1316,11 +1311,11 @@ void ivas_mdct_core_reconstruct_fx( IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { - Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) + Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), 1 ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) } ELSE { - Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) + Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, sub( st->hTcxDec->L_frameTCX, 1 ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) } lerp( synthFB_fx, synth_fx, st->L_frame, st->hTcxDec->L_frameTCX ); -- GitLab From f0586ef9c852dfb866511c4c31789b6e39d82b34 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:34:44 +0530 Subject: [PATCH 302/329] Fix for 3GPP issue 1327: Glitch when stereo is switching from TD to FD Link #1327 --- lib_com/options.h | 1 + lib_enc/ivas_stereo_switching_enc_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 563855275..d03261715 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,4 +171,5 @@ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ #define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ +#define FIX_ISSUE_1327 /* Ittiam: Fix for issue 1327: Glitch when stereo is switching from TD to FD*/ #endif diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 6513a3fa7..cbdbc0501 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -680,6 +680,10 @@ void stereo_switching_enc_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */ +#ifdef FIX_ISSUE_1327 + hCPE->q_input_mem[n] = sts[n]->q_inp; + move16(); +#endif } } -- GitLab From c2d223dab8078c0e12726f33b7396c1235f43dbe Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 19:34:14 +0530 Subject: [PATCH 303/329] Bug fixes, ivas_prot.h cleanup, Q documentation updates --- lib_com/bitstream.c | 1 - lib_com/core_com_config.c | 1 - lib_com/fft_fx.c | 20 + lib_com/gs_bitallocation_ivas_fx.c | 1 - lib_com/ivas_agc_com_fx.c | 1 - lib_com/ivas_arith_fx.c | 1 - lib_com/ivas_cov_smooth_fx.c | 1 - lib_com/ivas_dirac_com_fx.c | 1 - lib_com/ivas_entropy_coder_common_fx.c | 1 - lib_com/ivas_fb_mixer_fx.c | 1 - lib_com/ivas_filters_fx.c | 1 - lib_com/ivas_ism_com_fx.c | 1 - lib_com/ivas_lfe_com_fx.c | 1 - lib_com/ivas_masa_com_fx.c | 1 - lib_com/ivas_mc_com_fx.c | 1 - lib_com/ivas_mc_param_com_fx.c | 1 - lib_com/ivas_mcmasa_com-fx.c | 1 - lib_com/ivas_mct_com_fx.c | 2 +- lib_com/ivas_mdct_core_com_fx.c | 1 - lib_com/ivas_mdft_imdft_fx.c | 1 - lib_com/ivas_omasa_com_fx.c | 1 - lib_com/ivas_pca_tools_fx.c | 1 - lib_com/ivas_prot_fx.h | 817 ++++++++++++++++++ lib_com/ivas_qmetadata_com_fx.c | 1 - lib_com/ivas_qspherical_com_fx.c | 1 - lib_com/ivas_sba_config_fx.c | 1 - lib_com/ivas_sns_com_fx.c | 177 ++-- lib_com/ivas_spar_com_fx.c | 1 - lib_com/ivas_spar_com_quant_util_fx.c | 1 - lib_com/ivas_stereo_dft_com_fx.c | 1 - lib_com/ivas_stereo_eclvq_com_fx.c | 1 - lib_com/ivas_stereo_ica_com_fx.c | 1 - lib_com/ivas_stereo_mdct_bands_com_fx.c | 1 - lib_com/ivas_stereo_mdct_stereo_com_fx.c | 1 - lib_com/ivas_stereo_psychlpc_com_fx.c | 2 - lib_com/ivas_stereo_td_bit_alloc_fx.c | 1 - lib_com/ivas_tools_fx.c | 1 - lib_com/ivas_transient_det_fx.c | 1 - lib_com/mslvq_com.c | 1 - lib_com/prot_fx.h | 1 + lib_com/swb_tbe_com.c | 1 - lib_dec/ACcontextMapping_dec_fx.c | 1 - lib_dec/acelp_core_dec_ivas_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/igf_dec_fx.c | 5 +- lib_dec/ivas_agc_dec_fx.c | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 1 - lib_dec/ivas_core_dec_fx.c | 1 - lib_dec/ivas_corecoder_dec_reconfig_fx.c | 1 - lib_dec/ivas_cpe_dec_fx.c | 1 - lib_dec/ivas_decision_matrix_dec_fx.c | 1 - lib_dec/ivas_dirac_dec_fx.c | 1 - lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 1 - lib_dec/ivas_entropy_decoder_fx.c | 1 - lib_dec/ivas_init_dec.c | 1 - lib_dec/ivas_ism_dec_fx.c | 1 - lib_dec/ivas_ism_dtx_dec_fx.c | 1 - lib_dec/ivas_ism_metadata_dec_fx.c | 1 - lib_dec/ivas_ism_param_dec_fx.c | 1 - lib_dec/ivas_ism_renderer_fx.c | 1 - lib_dec/ivas_jbm_dec_fx.c | 1 - lib_dec/ivas_lfe_dec_fx.c | 1 - lib_dec/ivas_lfe_plc_fx.c | 1 - lib_dec/ivas_ls_custom_dec_fx.c | 1 - lib_dec/ivas_masa_dec_fx.c | 1 - lib_dec/ivas_mc_param_dec_fx.c | 1 - lib_dec/ivas_mc_paramupmix_dec_fx.c | 1 - lib_dec/ivas_mcmasa_dec_fx.c | 1 - lib_dec/ivas_mct_core_dec_fx.c | 1 - lib_dec/ivas_mct_dec_fx.c | 1 - lib_dec/ivas_mct_dec_mct_fx_fx.c | 1 - lib_dec/ivas_mdct_core_dec_fx.c | 1 - lib_dec/ivas_mono_dmx_renderer_fx.c | 1 - lib_dec/ivas_objectRenderer_internal_fx.c | 1 - lib_dec/ivas_omasa_dec_fx.c | 1 - lib_dec/ivas_osba_dec_fx.c | 1 - lib_dec/ivas_out_setup_conversion_fx.c | 1 - lib_dec/ivas_output_config_fx.c | 1 - lib_dec/ivas_pca_dec_fx.c | 1 - lib_dec/ivas_post_proc_fx.c | 1 - lib_dec/ivas_qmetadata_dec_fx.c | 1 - lib_dec/ivas_qspherical_dec_fx.c | 1 - lib_dec/ivas_range_uni_dec_fx.c | 1 - lib_dec/ivas_sba_dec_fx.c | 1 - lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 1 - lib_dec/ivas_sba_rendering_internal_fx.c | 1 - lib_dec/ivas_sce_dec_fx.c | 1 - lib_dec/ivas_sns_dec_fx.c | 1 - lib_dec/ivas_spar_decoder_fx.c | 1 - lib_dec/ivas_spar_md_dec_fx.c | 1 - lib_dec/ivas_stereo_adapt_GR_dec_fx.c | 1 - lib_dec/ivas_stereo_cng_dec.c | 1 - lib_dec/ivas_stereo_dft_dec.c | 1 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 1 - lib_dec/ivas_stereo_dft_dec_fx.c | 1 - lib_dec/ivas_stereo_dft_plc_fx.c | 1 - lib_dec/ivas_stereo_eclvq_dec_fx.c | 1 - lib_dec/ivas_stereo_esf_dec_fx.c | 1 - lib_dec/ivas_stereo_ica_dec_fx.c | 1 - lib_dec/ivas_stereo_icbwe_dec_fx.c | 1 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 1 - lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 1 - lib_dec/ivas_stereo_switching_dec_fx.c | 1 - lib_dec/ivas_stereo_td_dec_fx.c | 40 - lib_dec/ivas_svd_dec_fx.c | 1 - lib_dec/ivas_tcx_core_dec_fx.c | 1 - lib_dec/ivas_td_low_rate_dec_fx.c | 1 - lib_dec/lib_dec_fx.c | 1 - lib_dec/lsf_dec_fx.c | 1 - lib_enc/ACcontextMapping_enc_fx.c | 1 - lib_enc/acelp_core_enc_fx.c | 1 - lib_enc/cod4t64_fast.c | 1 - lib_enc/cod_tcx_fx.c | 1 - lib_enc/ext_sig_ana_fx.c | 40 +- lib_enc/igf_enc.c | 1 - lib_enc/ivas_agc_enc_fx.c | 1 - lib_enc/ivas_core_enc_fx.c | 1 - lib_enc/ivas_core_pre_proc_front_fx.c | 1 - lib_enc/ivas_core_pre_proc_fx.c | 1 - lib_enc/ivas_corecoder_enc_reconfig_fx.c | 1 - lib_enc/ivas_cpe_enc_fx.c | 1 - lib_enc/ivas_decision_matrix_enc_fx.c | 1 - lib_enc/ivas_dirac_enc_fx.c | 1 - lib_enc/ivas_enc_cov_handler_fx.c | 1 - lib_enc/ivas_enc_fx.c | 1 - lib_enc/ivas_entropy_coder_fx.c | 1 - lib_enc/ivas_front_vad_fx.c | 25 - lib_enc/ivas_init_enc_fx.c | 1 - lib_enc/ivas_ism_dtx_enc_fx.c | 1 - lib_enc/ivas_ism_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 1 - lib_enc/ivas_ism_param_enc_fx.c | 1 - lib_enc/ivas_lfe_enc_fx.c | 1 - lib_enc/ivas_masa_enc_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 1 - lib_enc/ivas_mc_paramupmix_enc_fx.c | 1 - lib_enc/ivas_mcmasa_enc_fx.c | 1 - lib_enc/ivas_mct_core_enc_fx.c | 1 - lib_enc/ivas_mct_enc_fx.c | 1 - lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 29 +- lib_enc/ivas_omasa_enc_fx.c | 1 - lib_enc/ivas_osba_enc_fx.c | 1 - lib_enc/ivas_pca_enc_fx.c | 1 - lib_enc/ivas_qmetadata_enc_fx.c | 1 - lib_enc/ivas_qspherical_enc_fx.c | 1 - lib_enc/ivas_range_uni_enc_fx.c | 1 - lib_enc/ivas_sba_enc_fx.c | 1 - lib_enc/ivas_sce_enc_fx.c | 1 - lib_enc/ivas_sns_enc_fx.c | 1 - lib_enc/ivas_spar_encoder_fx.c | 1 - lib_enc/ivas_spar_md_enc_fx.c | 1 - lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 1 - lib_enc/ivas_stereo_classifier_fx.c | 1 - lib_enc/ivas_stereo_cng_enc_fx.c | 1 - lib_enc/ivas_stereo_dft_enc_fx.c | 1 - lib_enc/ivas_stereo_dft_enc_itd_fx.c | 1 - lib_enc/ivas_stereo_dft_td_itd_fx.c | 1 - lib_enc/ivas_stereo_dmx_evs_fx.c | 1 - lib_enc/ivas_stereo_eclvq_enc_fx.c | 1 - lib_enc/ivas_stereo_ica_enc_fx.c | 1 - lib_enc/ivas_stereo_icbwe_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_core_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 1 - lib_enc/ivas_stereo_switching_enc_fx.c | 1 - lib_enc/ivas_stereo_td_analysis_fx.c | 1 - lib_enc/ivas_stereo_td_enc_fx.c | 1 - lib_enc/ivas_tcx_core_enc_fx.c | 1 - lib_enc/ivas_td_low_rate_enc_fx.c | 1 - lib_enc/lib_enc.c | 1 - lib_enc/lp_exc_e_fx.c | 106 +-- lib_enc/lsf_enc_fx.c | 147 ++-- lib_enc/lsf_msvq_ma_enc.c | 27 +- lib_enc/lsf_msvq_ma_enc_fx.c | 52 +- lib_enc/ltd_stable_fx.c | 63 +- lib_enc/mdct_classifier_fx.c | 99 +-- lib_enc/mdct_selector_fx.c | 36 +- lib_enc/mslvq_enc_fx.c | 52 +- lib_enc/multi_harm_fx.c | 16 +- lib_enc/speech_music_classif_fx.c | 1 - lib_enc/swb_pre_proc_fx.c | 1 - lib_enc/swb_tbe_enc_fx.c | 1 - lib_rend/ivas_allrad_dec_fx.c | 1 - lib_rend/ivas_crend_fx.c | 1 - lib_rend/ivas_dirac_ana_fx.c | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 1 - lib_rend/ivas_dirac_decorr_dec_fx.c | 1 - lib_rend/ivas_dirac_onsets_dec_fx.c | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 1 - lib_rend/ivas_dirac_rend_fx.c | 1 - lib_rend/ivas_efap_fx.c | 1 - lib_rend/ivas_hrtf_fx.c | 1 - lib_rend/ivas_masa_merge_fx.c | 1 - lib_rend/ivas_mcmasa_ana_fx.c | 1 - lib_rend/ivas_objectRenderer_fx.c | 1 - lib_rend/ivas_omasa_ana_fx.c | 1 - lib_rend/ivas_orient_trk_fx.c | 1 - lib_rend/ivas_output_init.c | 1 - lib_rend/ivas_output_init_fx.c | 1 - lib_rend/ivas_reflections_fx.c | 1 - lib_rend/ivas_reverb_delay_line_fx.c | 1 - lib_rend/ivas_sba_rendering_fx.c | 1 - lib_rend/ivas_td_decorr_fx.c | 1 - lib_rend/ivas_vbap_fx.c | 1 - lib_rend/lib_rend.c | 1 - lib_util/hrtf_file_reader.c | 1 - lib_util/ls_custom_file_reader.c | 2 +- lib_util/masa_file_reader.c | 1 - 209 files changed, 1267 insertions(+), 679 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 9c0a53f8f..90b49f8c2 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -43,7 +43,6 @@ #include "stat_dec.h" #include "rom_com.h" #include "mime.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index ed72605de..f0ee8efd8 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -40,7 +40,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #define FSCALE_DENOM_BY_12800_Q15 1311 diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 73ff582df..7b63e9c67 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -7636,6 +7636,26 @@ Word16 norm_arr( Word16 *arr, Word16 size ) return q; } +Word16 W_norm_arr( Word64 *arr, Word16 size ) +{ + Word16 q = 63; + Word16 exp = 0; + move16(); + move16(); + FOR( Word16 i = 0; i < size; i++ ) + { + if ( arr[i] != 0 ) + { + exp = W_norm( arr[i] ); + } + if ( arr[i] != 0 ) + { + q = s_min( q, exp ); + } + } + return q; +} + Word16 get_min_scalefactor( Word32 x, Word32 y ) { #ifndef FIX_1104_OPT_GETMINSCALEFAC diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 0921dc88c..71b30ea75 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "ivas_prot.h" /* Function prototypes */ #include "assert.h" /* Debug prototypes */ #include "stl.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 94e6b222f..3f6e181ef 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include #include "wmc_auto.h" diff --git a/lib_com/ivas_arith_fx.c b/lib_com/ivas_arith_fx.c index 006a31177..311bccff8 100644 --- a/lib_com/ivas_arith_fx.c +++ b/lib_com/ivas_arith_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "wmc_auto.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "stat_dec.h" diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index acc0df821..3a93ed1f5 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 9b60b2c5c..146587791 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -36,7 +36,6 @@ #include #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index 99381d19a..f52d59859 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" #include "prot_fx.h" diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 883861024..d5cd8d4f1 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 7705deb6a..1e9aaf0c2 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_stat_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index f1201b06c..5f1a13afb 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index 7464c41c2..3d1e7aee6 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "cnst.h" diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index fbe752aad..cfed06357 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -36,7 +36,6 @@ #include #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index 62d623b83..8201037a1 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index a54abe7ab..4469e7f93 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_mcmasa_com-fx.c b/lib_com/ivas_mcmasa_com-fx.c index da0b8f1c4..23a3800fb 100644 --- a/lib_com/ivas_mcmasa_com-fx.c +++ b/lib_com/ivas_mcmasa_com-fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "ivas_cnst.h" -#include "ivas_prot.h" #include "options.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mct_com_fx.c b/lib_com/ivas_mct_com_fx.c index 1f3c58153..81a56df14 100644 --- a/lib_com/ivas_mct_com_fx.c +++ b/lib_com/ivas_mct_com_fx.c @@ -33,8 +33,8 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" +#include "ivas_prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_mdct_core_com_fx.c b/lib_com/ivas_mdct_core_com_fx.c index 000f3992f..fe313eecd 100644 --- a/lib_com/ivas_mdct_core_com_fx.c +++ b/lib_com/ivas_mdct_core_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index b10444307..5d7bee1a6 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index ef6350285..1c1d4bf6c 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 1e36c5e8e..c84078a7d 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include #include diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4a72b194a..6b23f8eed 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5896,4 +5896,821 @@ void reset_metadata_spatial_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 nb_bits_metadata /* i : number of meatdata bits */ ); + +/*=============================================================================================*/ +/* clang-format off */ + +/*----------------------------------------------------------------------------------* + * General IVAS prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: number of channels to be analysed */ + +void copy_encoder_config_ivas_fx( + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ +); + +ivas_error create_mct_enc_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void destroy_cpe_enc( + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ +); + +void ivas_mct_enc_close_fx( + MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ +); + +ivas_error pre_proc_front_ivas_fx( + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 n, /* i : channel number Q0*/ + Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ + Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 *relE_fx, /* o : frame relative energy Q8*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ + Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ + Word16 *epsP_fx_q, + Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ + Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ + Word16 *attack_flag, /* o : flag signaling attack Q0*/ + Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ + Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ + Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ + Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ + Word16 *q_old_wsp, + Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ + Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ + Word16 *loc_harm, /* o : harmonicity flag Q0*/ + Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ + Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ + Word16 *enerBuffer_fx_exp, /* o : energy buffer */ + Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ + Word16 *fft_buff_fx_q, /* o : FFT buffer */ + const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ + const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ + const Word16 currFlatness_fx, /* i : flatness parameter Q7*/ + const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ + Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ + Word16 fr_bands_LR_fx_q[CPE_CHANNELS], + const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ + Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ + Word16 lf_E_LR_fx_q, + const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ + Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ + Word16 band_energies_LR_fx_q, + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ + const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ + const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ +#endif + const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ + Word16 *Q_new +#ifdef DEBUG_MODE_INFO + , + const Word16 ch_idx +#endif +); +ivas_error pre_proc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word32 last_element_brate, /* i : last element bitrate Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ + Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ + Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word16 *epsP_fx_q, /* i : LP prediction errors */ + Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ + Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ + Word16 e_old_wsp, + const Word16 loc_harm, /* i : harmonicity flag Q0*/ + const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ + Word16 e_enerBuffer, + Word16 fft_buff_fx[2 * L_FFT], /* Qx */ + Word16 cor_map_sum_fx, /* Q8 */ + Word16 *Q_new +); +/*! r: number of clipped samples */ +void ivas_initialize_handles_enc_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +ivas_error ivas_init_encoder( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_destroy_enc_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +ivas_error ivas_initialize_MD_bstr_enc_fx( + BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_destroy_MD_bstr_enc_fx( + BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */ +); + +ivas_error ivas_init_decoder_front( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +void ivas_mct_dec_close( + MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ +); + +/*! r: number of channels to be synthesised */ + +void copy_decoder_config( + Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ + Decoder_State *st /* o : decoder state structure */ +); + +void ivas_initialize_handles_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_core_enc_fx( + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ + Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ + Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ + Word16 Q_new[], + Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/ + Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word16 epsP_fx_q[], /* i : LP prediction errors */ + Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/ + Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/ + Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/ + Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/ + Word16 *q_re_im_buf, + Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/ + Word16 e_old_wsp[], + const Word16 loc_harm[], /* i : harmonicity flag Q0*/ + const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ + const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ + Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ + Word16 enerBuffer_fx_exp[], /* o : energy buffer */ + Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ + const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ + const Word16 ivas_format, /* i : IVAS format Q0*/ + const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ +); + +void ivas_renderer_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_mc_enc_config_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +/*! r: flag indicating a valid bitrate */ +Word16 is_IVAS_bitrate_fx( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +int16_t is_DTXrate( + const int32_t ivas_total_brate /* i : IVAS total bitrate */ +); + + +/*----------------------------------------------------------------------------------* + * JBM prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_jbm_dec_set_discard_samples( + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ +); + +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); + +void ivas_jbm_dec_tc_buffer_close( + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ +); + +void ivas_jbm_dec_td_renderers_adapt_subframes( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_jbm_dec_metadata_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_jbm_masa_sf_to_sf_map( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +/*----------------------------------------------------------------------------------* + * ISM prototypes + *----------------------------------------------------------------------------------*/ + +void bitbudget_to_brate( + const Word16 x[], /* i : bitbudgets Q0 */ + Word32 y[], /* o : bitrates Q0 */ + const Word16 N /* i : number of entries to be converted */ +); + +void ivas_ism_reset_metadata( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ +); + +void ivas_ism_reset_metadata_enc( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ +); +void ivas_ism_reset_metadata_API( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ +); + +/*! r: index of the winning codeword */ +Word16 ism_quant_meta_fx( + const Word32 val, /* i : scalar value to quantize Q22 */ + Word32 *valQ, /* o : quantized value Q22 */ + const Word32 borders_fx[], /* i : level borders Q22 */ + const Word32 q_step_fx, /* i : quantization step Q22 */ + const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */ + const Word16 cbsize /* i : codebook size */ +); + +ivas_error ivas_ism_metadata_enc_create_fx( + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 n_ISms, /* i : number of objects */ + Word32 element_brate_tmp[] /* o : element bitrate per object */ +); + +/*----------------------------------------------------------------------------------* + * Parametric ISM prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: ISM format mode */ + +ivas_error ivas_param_ism_enc_open_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_param_ism_enc_close_fx( + PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ + const Word32 input_Fs /* i : input sampling_rate */ +); + +void ivas_ism_metadata_close( + ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ + const Word16 first_idx /* i : index of first handle to deallocate */ +); + + +ivas_error ivas_ism_enc_config( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +/*----------------------------------------------------------------------------------* + * ISM DTX prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_ism_dtx_open( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_ism_metadata_sid_enc_fx( + ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ + const Word16 flag_noisy_speech, /* i : noisy speech flag */ + const Word16 nchan_ism, /* i : number of objects */ + const Word16 nchan_transport, /* i : number of transport channels */ + const ISM_MODE ism_mode, /* i : ISM mode */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const Word16 sid_flag, /* i : indication of SID frame */ + const Word16 md_diff_flag[], /* i : metadata differental flag */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 nb_bits_metadata[] /* o : number of metadata bits */ +); + + + +void ivas_param_ism_compute_noisy_speech_flag_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +/*----------------------------------------------------------------------------------* + * DFT Stereo prototypes + *----------------------------------------------------------------------------------*/ + +void stereo_dft_dec_destroy( + STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */ +); + +/*----------------------------------------------------------------------------------* + * Range Coder prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: Read bit */ +UWord16 rc_uni_dec_read_bit( + RangeUniDecState *rc_st_dec /* i/o: RC state handle */ +); + +/*! r: Read bit */ +UWord16 rc_uni_dec_read_bit_prob_fast( + RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ + const Word16 freq0, /* i : Frequency for symbol 0 */ + const UWord16 tot_shift /* i : Total frequency as a power of 2 */ +); + +/*! r: Read bits */ +UWord16 rc_uni_dec_read_bits( + RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ + const Word16 bits /* i : Number of bits */ +); + + +/*----------------------------------------------------------------------------------* + * TD Stereo prototypes + *----------------------------------------------------------------------------------*/ + +void tdm_bit_alloc( + const Word16 ivas_format, /* i : IVAS format */ + const Word16 ism_mode, /* i : ISM mode in combined format */ + const Word32 element_brate_wo_meta, /* i : element bitrate without metadata */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag */ + Word32 *total_brate_pri, /* o : Allocated primary channel bitrate */ + Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate */ + Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */ + const Word16 coder_type, /* i : secondary channel coder type */ + const Word16 ener_ratio_idx, /* i : correlation ratio indexe */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 bwidth_pri, /* i : bandwidth of the primary channel */ + const Word16 bwidth_sec, /* i : bandwidth of the secondary channel */ + const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ + const Word16 tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ +); + + +/*! r: value of the indice */ +uint16_t get_indice_st( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 pos, /* i : absolute position in the bitstream */ + const Word16 nb_bits /* i : number of bits to quantize the indice */ +); + +/*----------------------------------------------------------------------------------* + * MDCT Stereo prototypes + *----------------------------------------------------------------------------------*/ + +void stereo_mdct_core_enc_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ + Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ + Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ +); + +Word16 write_stereo_to_bitstream_fx +( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */ + Encoder_State **sts, /* i/o: Encoder state structure */ + Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ +); + +/*----------------------------------------------------------------------------------* + * Stereo CNG prototypes + *----------------------------------------------------------------------------------*/ +void stereo_cng_dec_update( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ +); + + +/*----------------------------------------------------------------------------------* + * Framework general prototypes + *----------------------------------------------------------------------------------*/ + +void mvc2c( + const uint8_t x[], /* i : input vector */ + uint8_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void stereo_switching_dec( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ +); + + +/*! r: number of bits written */ + + + +/*----------------------------------------------------------------------------------* + * MCT prototypes + *----------------------------------------------------------------------------------*/ +void ivas_mdct_core_whitening_enc_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ + Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ + Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ + Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ + Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ + Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ + Word16 p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ + const Word16 nChannels, /* i : total number of coded channels */ +Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], +Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] +); + +void splitAvailableBitsMCT_fx( + void **sts, /* i/o: encoder/decoder state structure */ + const Word16 total_bits, /* i : total number of available bits */ + const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */ + const Word16 enc_dec, /* i : encoder or decoder flag */ + const Word16 nchan /* i : number of channels */ +); + +void enc_prm_igf_mdct( + Encoder_State *st, /* i : Encoder state handle */ + BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */ +); + +/*----------------------------------------------------------------------------------* + * Q Metadata prototypes for DirAC and MASA + *----------------------------------------------------------------------------------*/ +/*! r: number of bits written */ + +/*! r: number of bits read */ +Word16 ivas_qmetadata_dec_decode( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ +); + +/*! r: number of bits read */ +Word16 ivas_qmetadata_dec_decode_hr_384_512( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ + const Word16 bits_sph_idx, + const Word16 bits_sp_coh, + const UWord8 ncoding_bands_config +); + +/*! r: number of bits read */ +Word16 ivas_qmetadata_dec_sid_decode( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word16 *element_mode, /* o : element mode */ + const Word16 ivas_format /* i : IVAS format */ +); + + +UWord16 ivas_qmetadata_reorder_generic_fx( + const Word16 signed_value +); + +void ivas_sba_set_cna_cng_flag( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +/*! r: number of ambisonics metadata channels */ + +void ivas_sba_dirac_stereo_config( + STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ +); + + +Word16 ivas_get_sba_dirac_stereo_flag( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +/*----------------------------------------------------------------------------------* + * DirAC prototypes + *----------------------------------------------------------------------------------*/ + + +ivas_error ivas_dirac_enc_reconfigure( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +ivas_error ivas_mc_paramupmix_enc_open_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +void ivas_mc_paramupmix_enc_close_fx( + MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ + const int32_t input_Fs /* i : input sampling rate */ +); + +ivas_error ivas_mc_paramupmix_dec_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_mc_paramupmix_dec_close( + MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ +); + +void ivas_mc_paramupmix_dec_read_BS( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_State *st, /* i/o: decoder state structure */ + MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ + Word16 *nb_bits /* o : number of bits written */ +); + +void ivas_mc_paramupmix_dec_digest_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const Word16 nSamplesForRendering /* i : number of samples provided */ +); + +void ivas_param_mc_set_coded_bands_fx( + HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ +); + +UWord16 ivas_param_mc_get_configuration_index_fx( + const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +/*----------------------------------------------------------------------------------* + * SPAR prototypes + *----------------------------------------------------------------------------------*/ + +/* MD module */ + +/*! r: number of MD subframes */ +ivas_error ivas_spar_md_dec_open( + ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const Word16 num_channels, /* i : number of internal channels */ + const Word16 sba_order, /* i : SBA order */ + const Word16 sid_format, /* i : SID format */ + const Word32 last_active_ivas_total_brate /* i : IVAS last active bitrate */ +); + +void ivas_spar_md_dec_close( + ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */ +); + +ivas_error ivas_spar_md_dec_init( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const Word16 num_channels, /* i : number of internal channels */ + const Word16 sba_order /* i : SBA order */ +); + +/* Transient detector module */ +ivas_error ivas_transient_det_open_fx( + ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ + const Word32 sampling_rate /* i : sampling rate */ +); + +void ivas_transient_det_close_fx( + ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ +); + +void ivas_huffman_encode_fx( + ivas_huffman_cfg_t *huff_cfg, + Word16 in, + Word16 *hcode, + Word16 *hlen +); + +ivas_error ivas_huffman_decode( + ivas_huffman_cfg_t *huff_cfg, + Decoder_State *st0, + Word16 *dec_out +); + +void ivas_arith_decode_cmplx_cell_array( + ivas_arith_t *pArith_re, + ivas_arith_t *pArith_re_diff, + Decoder_State *st0, + ivas_cell_dim_t *pCell_dims, + Word16 *pDo_diff, const Word16 nB, + Word16 *pSymbol_re, + Word16 *pSymbol_re_old +); + +void ivas_map_prior_coeffs_quant( + ivas_spar_md_prev_t *pSpar_md_prior, + ivas_spar_md_com_cfg *pSpar_md_cfg, + const Word16 qsi, + const Word16 nB +); + +void ivas_clear_band_coeff_idx( + ivas_band_coeffs_ind_t *pband_coeff_idx, + const UWord16 num_bands +); + + +/*----------------------------------------------------------------------------------* + * MASA prototypes + *----------------------------------------------------------------------------------*/ +ivas_error ivas_masa_enc_open_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +void ivas_masa_enc_close_fx( + MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ +); + +int16_t ivas_qmetadata_encode_extended_gr_length_fx( + const UWord16 value, + const UWord16 alphabet_size, + const Word16 gr_param); + +void ivas_qmetadata_encode_extended_gr_fx( + BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ + const UWord16 value, /* i : value to be encoded */ + const UWord16 alphabet_size, /* i : alphabet size */ + const Word16 gr_param); /* i : GR order */ + + +void ivas_set_qmetadata_maxbit_req_fx( + IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +); + + +/*---------------------------------------------------------------------------------* + * Binaural FastConv Renderer Prototypes +*-----------------------------------------------------------------------------------*/ + + +void ivas_binaural_hrtf_close( + HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ +); + +/*----------------------------------------------------------------------------------* + * renderer prototypes + *----------------------------------------------------------------------------------*/ + +void ivas_ism_renderer_close( + ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ +); + + +/*----------------------------------------------------------------------------------* + * Amplitude Panning VBAP prototypes + *----------------------------------------------------------------------------------*/ + +void panning_wrap_angles( + const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ + const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ + float *azi_wrapped, /* o : wrapped azimuth component */ + float *ele_wrapped /* o : wrapped elevation component */ +); + + +/*----------------------------------------------------------------------------------* + * McMASA prototypes + *----------------------------------------------------------------------------------*/ + + +ivas_error ivas_mcmasa_dec_reconfig( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +); + +void ivas_mcmasa_dmx_modify_fx( + const Word16 n_samples, /* i : input frame length in samples */ + Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ + Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ + const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ + const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ +); + +ivas_error ivas_mono_dmx_renderer_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +void ivas_mono_dmx_renderer_close( + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ +); + + +/*----------------------------------------------------------------------------------* + * LFE encoder low pass filter prototypes + *----------------------------------------------------------------------------------*/ + +void ivas_lfe_lpf_enc_close_fx( + ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */ +); + + +/*----------------------------------------------------------------------------------* + * LFE Coding prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_create_lfe_enc_fx( + LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */ + const Word32 input_Fs /* i : input sampling rate */ +); + +void ivas_lfe_enc_close_fx( + LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ +); + +void ivas_filters_init_fx( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ + const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ + const Word16 order ) ; + +void ivas_filter_process_fx( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ + const Word16 length, /* i : filter order */ + Word16 q_factor ); + +/*----------------------------------------------------------------------------------* + * OSBA prototypes + *----------------------------------------------------------------------------------*/ +ivas_error ivas_osba_enc_reconfig( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_set_surplus_brate_enc( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +#ifdef DEBUG_MODE_INFO + , + const int16_t *nb_bits_metadata /* i : number of metadata bits */ +#endif +); + +void ivas_set_surplus_brate_dec( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + int32_t *ism_total_brate /* i : ISM total bitrate */ +); + +ivas_error ivas_omasa_separate_object_renderer_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_omasa_separate_object_renderer_close( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +/*----------------------------------------------------------------------------------* + * Filter-bank (FB) Mixer + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_fb_set_cfg( + IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ + const Word16 ivas_format, /* i : IVAS format */ + const Word16 num_in_chans, /* i : number of FB input channels */ + const Word16 num_out_chans, /* i : number of FB output channels */ + const Word16 active_w_mixing, /* i : active_w_mixing flag */ + const Word32 sampling_Fs, /* i : sampling rate */ + const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */ +); + + +/*=============================================================================================*/ + #endif diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index 79a585e8b..c9ad84097 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 5caa850cb..6661026a8 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -36,7 +36,6 @@ #include #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 38785956c..b3a0806d4 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -38,7 +38,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index f35de8eb0..fa64b0092 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include @@ -61,12 +60,11 @@ void sns_compute_scf_fx( Word64 sum; Word32 L_tmp; const Word32 *pow_tilt; + Word16 q_shift, q_out, f_tmp; + Word16 bw, inv_bw, exp; const UWord8 nBands = pPsychParams->nBands; move16(); const UWord8 *bandLengths = pPsychParams->bandLengths; - Word8 bw = 0; - move16(); - Word16 q_shift; const Word16 w_0 = 2730; // (1.0f / 12.0f) in Q15 move16(); @@ -88,91 +86,83 @@ void sns_compute_scf_fx( IF( bandLengths == NULL ) { - bw = (Word8) shr( L_frame, 6 ); + bw = shr( L_frame, 6 ); move16(); + + exp = norm_s( bw ); + inv_bw = div_s( ONE_IN_Q14, shl( bw, exp ) ); // Q:15+14-exp = 29-exp + inv_bw = shl( inv_bw, sub( exp, 14 ) ); // Q15 + /* Energy per band */ k = 0; move16(); FOR( i = 0; i < nBands; ++i ) { - x_64[i] = 0; + sum = 0; move64(); FOR( n = 0; n < bw; ( ++n, ++k ) ) { - x_64[i] = W_add( x_64[i], W_deposit32_l( spectrum[k] ) ); // Q_in - move64(); + /* x[i] += spectrum[k]; + inv_bw is for x[i] /= bw; */ + sum = W_mac_32_16( sum, spectrum[k], inv_bw ); // Q_in+15+1 } + x_64[i] = sum; // Q_in+16 + move64(); } } ELSE { /* Energy per band */ k = 0; - move32(); + move16(); FOR( i = 0; i < nBands; ++i ) { - x_64[i] = 0; + exp = norm_s( bandLengths[i] ); + inv_bw = div_s( ONE_IN_Q14, shl( bandLengths[i], exp ) ); // Q:15+14-exp + inv_bw = shl( inv_bw, sub( exp, 14 ) ); // Q15 + + sum = 0; move64(); FOR( n = 0; n < bandLengths[i]; ( ++n, ++k ) ) { - x_64[i] = W_add( x_64[i], W_deposit32_l( spectrum[k] ) ); // Q_in - move64(); + /* x[i] += spectrum[k]; + inv_bw is for x[i] /= bandLengths[i]; */ + sum = W_mac_32_16( sum, spectrum[k], inv_bw ); // Q_in+15+1 } + x_64[i] = sum; // Q_in+16 + move64(); } } /* Move accumulated values to 32-bit */ - q_shift = 0; - move16(); - IF( x_64[0] != 0 ) + q_shift = W_norm_arr( x_64, nBands ); // W_norm_arr return 63 when all the values of the input buffer are zeroes + IF( EQ_16( q_shift, 63 ) ) { - q_shift = W_norm( x_64[0] ); - } - FOR( i = 1; i < nBands; ++i ) - { - IF( x_64[i] != 0 ) - { - q_shift = s_min( q_shift, W_norm( x_64[i] ) ); - } - } - FOR( i = 0; i < nBands; ++i ) - { - x[i] = W_extract_l( W_shl( x_64[i], sub( q_shift, 32 ) ) ); // Q_in + (q_shift - 32) - } + /* If all the values of x_64 are zeros, the scale factor (scf) values will be calculated as zeroes as per the below operations. + To avoid extra computations in such a case, set scf values as zeroes and return. */ - IF( bandLengths == NULL ) - { - Word16 inv_bw; - bw = (Word8) shr( L_frame, 6 ); - move16(); - inv_bw = div_l( ONE_IN_Q16 /*1 Q16*/, bw ); // Q15 - FOR( i = 0; i < nBands; ++i ) - { - x[i] = Mpy_32_16_1( x[i], inv_bw ); // Q_in + (q_shift - 32) - move32(); - } + set_zero_fx( scf, SNS_NPTS ); + + return; } - ELSE + + FOR( i = 0; i < nBands; ++i ) { - FOR( i = 0; i < nBands; ++i ) - { - Word16 inv_bw = div_l( ONE_IN_Q16 /*1 Q16*/, bandLengths[i] ); // Q15 - x[i] = Mpy_32_16_1( x[i], inv_bw ); // Q_in + (q_shift - 32) - move32(); - } + x[i] = W_extract_h( W_shl( x_64[i], q_shift ) ); // Q: Q_in+16+q_shift-32 = Q_in+q_shift-16 + move32(); } /* Smoothing */ - xs[0] = L_add( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[1], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32) + xs[0] = Madd_32_16( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), x[1], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16 move32(); FOR( i = 1; i < FDNS_NPTS - 1; i++ ) { - xs[i] = L_add( L_add( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), Mpy_32_16_1( x[i - 1], 8192 /* 0.25 in Q15 */ ) ), Mpy_32_16_1( x[i + 1], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32) + xs[i] = Madd_32_16( Madd_32_16( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), x[i - 1], 8192 /* 0.25 in Q15 */ ), x[i + 1], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16 move32(); } - xs[FDNS_NPTS - 1] = L_add( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32) + xs[FDNS_NPTS - 1] = Madd_32_16( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16 move32(); /* Pre-emphasis */ @@ -194,86 +184,83 @@ void sns_compute_scf_fx( FOR( i = 0; i < FDNS_NPTS; i++ ) { - xs[i] = Mpy_32_32( xs[i], pow_tilt[i] ); // Q_in + (q_shift - 32) + xs[i] = Mpy_32_32( xs[i], pow_tilt[i] ); // Q_in+q_shift-16+23-31 = Q_in+q_shift-24 move32(); } /* Noise floor at -40dB */ sum = 0; move64(); - FOR( Word16 ind = 0; ind < FDNS_NPTS; ind++ ) + FOR( i = 0; i < FDNS_NPTS; i++ ) { - sum = W_add( sum, W_deposit32_l( xs[ind] ) ); // Q_in + (q_shift - 32) + sum = W_mac_32_16( sum, xs[i], 1 ); // Q_in+q_shift-24+1 } - mean = W_extract_l( W_shr( sum, 6 ) ); // Q_in + (q_shift - 32) - nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // Q_in + (q_shift - 32) - nf = L_max( nf, 0 /* powf( 2.0f, -32.0f ) in Q31 */ ); // Q_in + (q_shift - 32) + q_out = sub( add( Q_in, q_shift ), 24 ); + + /* mean = sum / FDNS_NPTS; + -Q6 is for division with FDNS_NPTS and -Q1 is to reduce Q by one */ + mean = W_shl_sat_l( sum, -Q7 ); // q_out + nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // q_out + nf = L_max( nf, L_shl( 256, sub( q_out, 40 ) ) /* powf( 2.0f, -32.0f ) in Q40 */ ); // q_out FOR( i = 0; i < FDNS_NPTS; i++ ) { - if ( LT_32( xs[i], nf ) ) - { - xs[i] = nf; // Q_in + (q_shift - 32) - move32(); - } + xs[i] = L_max( xs[i], nf ); // q_out + move32(); } /* Log-domain */ FOR( i = 0; i < FDNS_NPTS; i++ ) { - Word16 e_tmp = norm_l( xs[i] ); - Word16 f_tmp = Log2_norm_lc( L_shl( xs[i], e_tmp ) ); /*Q16*/ - e_tmp = sub( sub( 34, e_tmp ), Q_in ); - /* Note: Mpy_32_16 is used temporarily for this computation, It needs to be replaced with appropriate BASOP. */ - xl[i] = Mpy_32_16( e_tmp, f_tmp, 16384 ); /* Q16 */ + /* xl[i] = logf( xs[i] ) * scale_log; + scale_log = INV_LOG_2 * 0.5f; */ + + exp = norm_l( xs[i] ); + f_tmp = Log2_norm_lc( L_shl( xs[i], exp ) ); // Q15 + exp = sub( sub( 30, exp ), q_out ); + L_tmp = L_mac( L_deposit_h( exp ), f_tmp, 1 ); // Q16 + xl[i] = L_shr( L_tmp, 1 ); // Q16 move32(); } /* Downsampling */ - L_tmp = L_deposit_l( 0 ); - L_tmp = Madd_32_16( L_tmp, xl[0], w_0 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[0], w_1 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[1], w_2 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[2], w_3 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[3], w_4 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[4], w_5 ); // Q16 - xl4[0] = L_tmp; // Q16 - move32(); + L_tmp = Madd_32_16( Mpy_32_16_1( xl[0], w_0 ), xl[0], w_1 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[1], w_2 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[2], w_3 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[3], w_4 ); // Q16 + xl4[0] = Madd_32_16( L_tmp, xl[4], w_5 ); // Q16 + FOR( n = 1; n < SNS_NPTS - 1; n++ ) { - Word16 n4 = shl( n, 2 ); - - L_tmp = L_deposit_l( 0 ); - L_tmp = Madd_32_16( L_tmp, xl[n4 - 1], w_0 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4], w_1 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 1], w_2 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 2], w_3 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 3], w_4 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 4], w_5 ); // Q16 - xl4[n] = L_tmp; // Q16 + L_tmp = Mpy_32_16_1( xl[4 * n - 1], w_0 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n], w_1 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n + 1], w_2 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n + 2], w_3 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n + 3], w_4 ); // Q16 + xl4[n] = Madd_32_16( L_tmp, xl[4 * n + 4], w_5 ); // Q16 move32(); } - L_tmp = L_deposit_l( 0 ); - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 5], w_0 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 4], w_1 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 3], w_2 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 2], w_3 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_4 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_5 ); // Q16 - xl4[SNS_NPTS - 1] = L_tmp; // Q16 + L_tmp = Mpy_32_16_1( xl[FDNS_NPTS - 5], w_0 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 4], w_1 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 3], w_2 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 2], w_3 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_4 ); // Q16 + xl4[SNS_NPTS - 1] = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_5 ); // Q16 move32(); /* Remove mean and scaling */ sum = 0; move64(); - FOR( Word16 ind = 0; ind < SNS_NPTS; ind++ ) + FOR( i = 0; i < SNS_NPTS; i++ ) { - sum = W_add( sum, W_deposit32_l( xl4[ind] ) ); // Q16 + sum = W_mac_32_16( sum, xl4[i], 1 ); // Q16+1 } - mean = W_extract_l( W_shr( sum, 4 ) ); // Q16 + /* mean = sum / SNS_NPTS; + -Q4 is for division with SNS_NPTS and -Q1 is to reduce Q by one */ + mean = W_shl_sat_l( sum, -Q5 ); // Q16 FOR( i = 0; i < SNS_NPTS; i++ ) { diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 96df64aa5..929eaa2c5 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -36,7 +36,6 @@ #include "basop_util.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "cnst.h" diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 8292de5c1..cfd03a3b3 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "math.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index 80e64c0cc..6d63bc6d1 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index d0ffff39c..958781473 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 9aa880842..8548797a4 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_stereo_mdct_bands_com_fx.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c index c21abcf8c..43f2f16c7 100644 --- a/lib_com/ivas_stereo_mdct_bands_com_fx.c +++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_mdct_stereo_com_fx.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c index dd94358af..0a773169d 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com_fx.c +++ b/lib_com/ivas_stereo_mdct_stereo_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include #include "prot_fx.h" diff --git a/lib_com/ivas_stereo_psychlpc_com_fx.c b/lib_com/ivas_stereo_psychlpc_com_fx.c index cb3c39df2..df5140895 100644 --- a/lib_com/ivas_stereo_psychlpc_com_fx.c +++ b/lib_com/ivas_stereo_psychlpc_com_fx.c @@ -33,9 +33,7 @@ #include #include "options.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index 9074473d7..b54c1d3de 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "stat_enc.h" #include "rom_com.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index e15db9a15..04d6f7bf5 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 97025b46f..3b9a8cfd7 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -36,7 +36,6 @@ #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_com.h" diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index 6bd8026c4..12234a4c0 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -40,7 +40,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d0f0efb72..db0953cd9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4701,6 +4701,7 @@ Word16 find_guarded_bits_fx( Word32 n ); Word16 L_norm_arr( const Word32 *arr, Word16 size ); Word16 norm_arr( Word16 *arr, Word16 size ); +Word16 W_norm_arr( Word64 *arr, Word16 size ); Word16 get_min_scalefactor( Word32 x, Word32 y ); diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 1f112c911..7905c7145 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -41,7 +41,6 @@ #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index 34e74a06f..22e9fff01 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -12,7 +12,6 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" /*-------------------------------------------------------------------* * ACcontextMapping_decode2_no_mem_s17_LC() diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 11379a62d..782654623 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -41,7 +41,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 191065855..d1ed7ad8c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -10,7 +10,6 @@ #include "stl.h" #include "options.h" #include "math.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 907a4a350..c1b0ce93a 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -9,7 +9,6 @@ #include "options.h" #include "stl.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "cnst.h" #include "stat_dec.h" @@ -2932,14 +2931,14 @@ static void IGF_getWhiteSpectralData_ivas( { ak = 0; move32(); - move16(); FOR( j = i - level; j < stop; j++ ) { tmp_16 = extract_h( L_shl( in[j], s_l ) ); // e: in_e - s_l ak = L_mac( ak, tmp_16, tmp_16 ); // e: 2 * (in_e - s_l) } - ak = Mult_32_16( ak, quo ); + ak = L_deposit_h( BASOP_Util_Divide3216_Scale( ak, sub( stop, sub( i, level ) ), &tmp_e ) ); + ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 n = sub( 30, add( norm_l( ak ), sub( 31, ak_e ) ) ); n = shr( n, 1 ); diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index e73d89158..a196a1abd 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 3c234c098..8527e6703 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "cnst.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 5bb4736e9..7b4e5f267 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 697f9d715..25c0bea42 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -32,7 +32,6 @@ #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 9bf53f1de..6a6294377 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index f7fd5e8e2..717bb3b93 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "stat_dec.h" #include "rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 59d9c9e38..d8288e561 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index e03913f8a..b247fd653 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -41,7 +41,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_entropy_decoder_fx.c b/lib_dec/ivas_entropy_decoder_fx.c index e637a6a93..f8bf3c091 100644 --- a/lib_dec/ivas_entropy_decoder_fx.c +++ b/lib_dec/ivas_entropy_decoder_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8db782c4e..b11669460 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 664e3eeac..643874a82 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index cbf088597..0f023a7ef 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index a6f5e47b6..3288903ab 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index eae0e9069..3aed4d3b1 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -34,7 +34,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "rom_com.h" diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index a19ba70ec..7cd93affa 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_stat_com.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 428c817ef..210425b88 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index e68c0142d..672d3fbe6 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 018f99fe7..210c266eb 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_ls_custom_dec_fx.c b/lib_dec/ivas_ls_custom_dec_fx.c index 45f59d82f..5ad390f9a 100644 --- a/lib_dec/ivas_ls_custom_dec_fx.c +++ b/lib_dec/ivas_ls_custom_dec_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include #include "options.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 806785c15..384865a1a 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index be2363469..697ae6345 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 9ea666237..3c2ba7587 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "rom_com.h" diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index c2228b610..1b1715c21 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index be457da47..fe39fd8e3 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -39,7 +39,6 @@ #include "cnst.h" #include "basop_proto_func.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 081eca88d..884a44c9e 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -38,7 +38,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 69f601724..c275820fb 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index a5855a0f6..35d38d03a 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -40,7 +40,6 @@ #include "cnst.h" #include "basop_proto_func.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index bb5dead22..2eb8d84df 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 391a27522..b88b68915 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index bf7fba094..afa604684 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_prot_rend.h" diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 07ea14ea2..6f1a233c9 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 4811911fd..84b6fe46d 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -35,7 +35,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index cb96d3b0d..3a0960960 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 08ac17799..98611ab7c 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 397f26bbc..9357394a5 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index 81768af44..c78c51c52 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_qspherical_dec_fx.c b/lib_dec/ivas_qspherical_dec_fx.c index d34b5402a..f6ac39a99 100644 --- a/lib_dec/ivas_qspherical_dec_fx.c +++ b/lib_dec/ivas_qspherical_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index e629111ce..9a49680e8 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_stat_dec.h" #include "cnst.h" diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index efd766f76..f04350366 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 573a9c17f..0c7544682 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index a42c67389..8748342ed 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 89581565c..a6be10c08 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 170256181..fd25e7ea7 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 812027468..34a194898 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -37,7 +37,6 @@ #include "ivas_stat_dec.h" #include "prot_fx.h" #include "string.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index bb79b956c..7f487a75c 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "math.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c index 8446af47d..2bade4786 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "rom_dec.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 4d50ba350..223860db0 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 166ac72e5..f0fd1978b 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "rom_dec.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 0781d49a6..e82005965 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index fb54476fa..1c18ffacb 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "rom_dec.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index d3415a8eb..90d9c5823 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "math.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c index 693df8c77..dfa411145 100644 --- a/lib_dec/ivas_stereo_eclvq_dec_fx.c +++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_stereo_esf_dec_fx.c b/lib_dec/ivas_stereo_esf_dec_fx.c index 80603f6c0..d4219f1e6 100644 --- a/lib_dec/ivas_stereo_esf_dec_fx.c +++ b/lib_dec/ivas_stereo_esf_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index b49ab5399..694aad0b4 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 22a8c4a90..3b32072f3 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #include "rom_com.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 04781a9cb..a6b350d33 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -37,7 +37,6 @@ #include "prot_fx.h" #include "cnst.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 69083a078..3f39bd9ac 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index e5e18083d..09b683a16 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "assert.h" diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index 8ab7da035..023c9a2e5 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "wmc_auto.h" @@ -338,45 +337,6 @@ void tdm_configure_dec_fx( return; } -/*-------------------------------------------------------------------* - * Function tdm_downmix_plain() - * - * downmix Left+Right to Primary+Secondary channel - *-------------------------------------------------------------------*/ - -void tdm_upmix_plain( - float Left[], /* o : left channel */ - float Right[], /* o : right channel */ - const float PCh_2_L[], /* i : primary channel */ - const float SCh_2_R[], /* i : secondary channel */ - const float LR_ratio, /* i : mixing ratio */ - const float inv_den_LR_ratio, /* i : inverse mixing ration */ - const int16_t start_index, /* i : start index */ - const int16_t end_index, /* i : end index */ - const int16_t plus_minus_flag /* i : plus/minus flag */ -) -{ - int16_t i; - - if ( plus_minus_flag == 1 ) - { - for ( i = start_index; i < end_index; i++ ) - { - Left[i] = ( LR_ratio * ( PCh_2_L[i] - SCh_2_R[i] ) + SCh_2_R[i] ) * inv_den_LR_ratio; - Right[i] = ( -LR_ratio * ( PCh_2_L[i] + SCh_2_R[i] ) + PCh_2_L[i] ) * inv_den_LR_ratio; - } - } - else - { - for ( i = start_index; i < end_index; i++ ) - { - Left[i] = ( LR_ratio * ( PCh_2_L[i] + SCh_2_R[i] ) - SCh_2_R[i] ) * inv_den_LR_ratio; - Right[i] = ( LR_ratio * ( PCh_2_L[i] - SCh_2_R[i] ) - PCh_2_L[i] ) * inv_den_LR_ratio; - } - } - - return; -} void tdm_upmix_plain_fx( Word32 Left_fx[], /* o : left channel Qx*/ Word32 Right_fx[], /* o : right channel Qx*/ diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index 375dbdad0..1467687d8 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index c908e4dc3..07eba9e64 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -40,7 +40,6 @@ #include "wmc_auto.h" #include "basop_proto_func.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------* diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 63819b056..98c1a6a79 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -38,7 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" void tdm_low_rate_dec_fx( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 66109b555..ef3baee3c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index d263e6dd3..21e8705f3 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* * Local functions diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 44439540f..c52fddf97 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -13,7 +13,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" /* Range coder header file */ #define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) /* evaulated at compile time */ #define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /* evaluated at run time */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0f58bcdad..782006108 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -13,7 +13,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index a901690e3..0e4c02744 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index c54e8ccf4..7c28c3309 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -16,7 +16,6 @@ #include "prot_fx_enc.h" #ifdef IVAS_FLOAT_FIXED_CONVERSIONS #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" #endif diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 9e6318591..f546c3ef8 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1165,18 +1165,30 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { + Word16 q_mdstWin, scale; L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */ test(); IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { wtda_ext_fx( hTcxEnc->new_speech_TCX, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 ); - Scale_sig( mdstWin, L_frameTCX, 1 ); + scale = sub( norm_arr( mdstWin, L_frameTCX ), 1 ); + scale = s_min( 1, scale ); // restricting the Q to zero or less + scale_sig( mdstWin, L_frameTCX, scale ); + q_mdstWin = add( -1, scale ); + move16(); } ELSE { + Word16 sig_len; /* Windowing for the MDST */ WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1 ); + sig_len = add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ); + scale = sub( norm_arr( mdstWin, sig_len ), 1 ); + scale = s_min( 0, scale ); // restricting the Q to zero or less + scale_sig( mdstWin, sig_len, scale ); + q_mdstWin = scale; + move16(); } IF( EQ_16( transform_type[frameno], TCX_5 ) ) @@ -1184,7 +1196,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outer left folding */ FOR( i = 0; i < left_overlap / 2; i++ ) { - mdstWin[left_overlap / 2 + i] = add_sat( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // Q0 + mdstWin[left_overlap / 2 + i] = add( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // q_mdstWin } test(); @@ -1197,16 +1209,16 @@ void core_signal_analysis_high_bitrate_ivas_fx( { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } } @@ -1214,7 +1226,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outer right folding */ FOR( i = 0; i < right_overlap / 2; i++ ) { - mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub_sat( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); // Q0 + mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); // q_mdstWin move16(); } @@ -1229,7 +1241,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE ); WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, mdstWin + i * tcx5SizeFB, &L_subframe, tcx5Win, 0, 1 ); - spectrum_e[frameno] = 16; + spectrum_e[frameno] = sub( 16, q_mdstWin ); move16(); TCX_MDST( tcx5Win, spectrum[frameno] + i * tcx5SizeFB, &spectrum_e[frameno], left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); /* high-band gain control in case of BWS */ @@ -1250,14 +1262,14 @@ void core_signal_analysis_high_bitrate_ivas_fx( } ELSE /* transform_type[frameno] != TCX_5 */ { - spectrum_e[frameno] = 16; + spectrum_e[frameno] = sub( 16, q_mdstWin ); test(); IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { Word16 Q; Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 ); - Q = 16; + Q = add( q_mdstWin, 16 ); move16(); edst_fx( L_tmpbuf, spectrum[frameno], L_subframe, &Q ); spectrum_e[frameno] = 31 - Q; @@ -1284,16 +1296,16 @@ void core_signal_analysis_high_bitrate_ivas_fx( { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index f6adb0f31..fc7c32fdb 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -39,7 +39,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "cnst.h" #include "stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 104eeb998..d74e10bda 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 5f318e959..f88288ea1 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -36,7 +36,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 46de4e232..42920a46a 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 73403a848..8d00e608c 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 32e3e7107..f21c8e262 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -35,7 +35,6 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "math.h" diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index a9d62a2b0..1152736f6 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" #ifdef DEBUGGING diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 1158f72fa..bd63553bd 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 7bfa9f268..ac0ce9556 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 576bbb2c6..c05d59b90 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 0a2d976e1..e8e1bc59e 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index a95f2884c..3c8cf92e2 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index f1aeb5398..8b76b37a4 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "prot_fx_enc.h" #include #include "wmc_auto.h" @@ -433,30 +432,6 @@ ivas_error front_vad_create_fx( return IVAS_ERR_OK; } -/*-----------------------------------------------------------------------------------------* - * Function front_vad_destroy() - * - * Deallocate Standalone front-VAD module - *-----------------------------------------------------------------------------------------*/ - -void front_vad_destroy( - FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ -) -{ - IF( *hFrontVad != NULL ) - { - free( ( *hFrontVad )->hNoiseEst ); - ( *hFrontVad )->hNoiseEst = NULL; - - free( ( *hFrontVad )->hVAD ); - ( *hFrontVad )->hVAD = NULL; - - free( *hFrontVad ); - *hFrontVad = NULL; - } - - return; -} void front_vad_destroy_fx( FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ ) diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index c65c85356..b49fc9716 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_enc.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 64b8991d6..b29b0c15b 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 22bf88df8..1b648cc98 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 4305e5bca..6a2e54db6 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index e6b23fcfc..cda8cffd6 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -34,7 +34,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "cnst.h" diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 11056b535..96959c9dd 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "math.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 21c23c34a..6960629c8 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 2797fa5e4..17fefec7e 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index abd09cbbd..fd5cb6217 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "basop_util.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index c4d3908ca..22f21dceb 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "options.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 439c227ae..71515571d 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index d6bc4c7f0..56f5e44db 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 88d773b53..a8ba9a320 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 70b2b0034..3272768e9 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -37,7 +37,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -705,8 +704,8 @@ static void applyStereoPreProcessingCplx( } ELSE { - dmxR2_fx = L_sub( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31 - dmxI2_fx = L_sub( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31 + dmxR2_fx = L_sub( Mpy_32_32( valR2_fx, factDe_fx ), Mpy_32_32( valR1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31 + dmxI2_fx = L_sub( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31 } } ELSE @@ -1923,7 +1922,6 @@ void ivas_mdct_core_whitening_enc_fx( tcx_subframe_coded_lines = shr( tcx_subframe_coded_lines, shift ); /*tcx_subframe_coded_lines / nSubframes*/ Word16 q_pow = 62, q_pow_tmp = sub( 63, shl( mdst_spectrum_e[0][0], 1 ) ); // add( shl( sub( Q31, mdst_spectrum_e[0][0] ), 1 ), 1 ); move16(); - FOR( n = 0; n < nSubframes; n++ ) { IF( st->hTcxEnc->fUseTns[n] ) @@ -1932,34 +1930,19 @@ void ivas_mdct_core_whitening_enc_fx( { powerSpec_fx64[i] = W_mult_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ); move64(); - IF( powerSpec_fx64[i] == 0 ) - { - q_pow = s_min( q_pow, 62 ); - } - ELSE - - { - q_pow = s_min( q_pow, W_norm( powerSpec_fx64[i] ) ); - } } + q_pow = W_norm_arr( powerSpec_fx64, L_subframeTCX ); } ELSE { FOR( i = 0; i < L_subframeTCX; i++ ) { - powerSpec_fx64[i] = W_add( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), W_mult_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ) ); + powerSpec_fx64[i] = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ); move64(); - IF( powerSpec_fx64[i] == 0 ) - { - q_pow = s_min( q_pow, 62 ); - } - ELSE - - { - q_pow = s_min( q_pow, W_norm( powerSpec_fx64[i] ) ); - } } + q_pow = W_norm_arr( powerSpec_fx64, L_subframeTCX ); } + FOR( i = 0; i < L_subframeTCX; i++ ) { powerSpec_fx64[i] = W_shl( powerSpec_fx64[i], q_pow ); diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 7c8b78ffb..5d79265f4 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 1229624de..2a6944c50 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 410d5dd52..2cb347a02 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include #include diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index b32c80404..2d6080995 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -36,7 +36,6 @@ #include #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index a6f40c8f0..2e7a289f9 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index cf32c644d..6c322a3d9 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_stat_enc.h" diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index 8fdca5815..e630a70d9 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -39,7 +39,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 8c2c945d6..2983ea2f0 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index e321f1c7c..93ee56461 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 674a80549..3b380f2eb 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 2ace35473..997581476 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "math.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 70c2165f8..8e79b2288 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index bfe683d6b..3e148a5ae 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -39,7 +39,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index 255b6e938..aa7c2d0aa 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index ede3d3ad9..3eb6c0e82 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -38,7 +38,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 862102d3b..8a887de89 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -38,7 +38,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 58e66a01a..df4fe3edd 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index c3cb68719..ae8a8203e 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index f4962c802..3abc07811 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 78c324cce..057798706 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 78891c5f7..bc84ba419 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 28b0e41b9..b68578542 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index 57bb18e80..851df60d5 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -38,7 +38,6 @@ #include "cnst.h" #include "stat_enc.h" #include "ivas_stat_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index b1213a750..a61b2b010 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index cbdbc0501..2fe8b6c84 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com_fx.h" #include "ivas_rom_com.h" #include "assert.h" diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index efae1e80d..44c08efa8 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "rom_enc.h" diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 979978c03..d2ff2c0c2 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 28044b45d..1e66c1488 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -39,7 +39,6 @@ #include "rom_com.h" #include "basop_proto_func.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" #include "rom_com_fx.h" diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 34215025f..2daa9ed50 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 9d4736368..9093ffc40 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -39,7 +39,6 @@ #include "debug.h" #endif #include "lib_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 0887698f7..01005f641 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -53,7 +53,8 @@ Word16 lp_filt_exc_enc_fx( Word16 wtmp, wtmp1; Word32 Ltmp; - Word16 use_prev_sf_pit_gain = 0; + Word16 use_prev_sf_pit_gain = 0; // Q0 + move16(); gain1 = 0; move16(); @@ -66,7 +67,8 @@ Word16 lp_filt_exc_enc_fx( test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( coder_type, 100 ) ) { - use_prev_sf_pit_gain = 1; + use_prev_sf_pit_gain = 1; // Q0 + move16(); } exp_ener = 0; move16(); @@ -75,7 +77,7 @@ Word16 lp_filt_exc_enc_fx( test(); IF( EQ_16( *lp_flag, FULL_BAND ) || EQ_16( *lp_flag, NORMAL_OPERATION ) ) { - wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); + wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); // exp_ener move16(); } @@ -89,7 +91,7 @@ Word16 lp_filt_exc_enc_fx( wtmp1 = 0; move16(); test(); - IF( ( EQ_16( *lp_flag, LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) + IF( ( ( *lp_flag == LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) { test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( L_frame, L_FRAME16k ) ) @@ -100,6 +102,7 @@ Word16 lp_filt_exc_enc_fx( Ltmp = L_mac( Ltmp, 19005, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 6881, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } ELSE @@ -110,20 +113,21 @@ Word16 lp_filt_exc_enc_fx( Ltmp = L_mac( Ltmp, 20972, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 5898, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); // exp_ener1 } if ( LT_16( exp_ener, exp_ener1 ) ) { - wtmp = shr( wtmp, 1 ); + wtmp = shr( wtmp, 1 ); // exp_ener + 1 } if ( GT_16( exp_ener, exp_ener1 ) ) { - wtmp1 = shr( wtmp1, 1 ); + wtmp1 = shr( wtmp1, 1 ); // exp_ener1 + 1 } /*-----------------------------------------------------------------* @@ -132,18 +136,18 @@ Word16 lp_filt_exc_enc_fx( test(); test(); - IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( EQ_16( *lp_flag, LOW_PASS ) ) ) + IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( ( *lp_flag == LOW_PASS ) ) ) { /* use the LP filter for pitch excitation prediction */ select = LOW_PASS; move16(); - Copy( exc_tmp, &exc[i_subfr], L_subfr ); - Copy( y1_tmp, y1, L_subfr ); - Copy( xn2_tmp, xn2, L_subfr ); + Copy( exc_tmp, &exc[i_subfr], L_subfr ); // Q_new + Copy( y1_tmp, y1, L_subfr ); // Q_new-1+shift + Copy( xn2_tmp, xn2, L_subfr ); // Q_new-1+shift IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain2; + *gain_pit = gain2; // Q14 move16(); g_corr[0] = g_corr2[0]; move16(); @@ -162,7 +166,7 @@ Word16 lp_filt_exc_enc_fx( move16(); IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain1; + *gain_pit = gain1; // Q14 move16(); } } @@ -193,7 +197,8 @@ Word16 lp_filt_exc_enc_ivas_fx( Word16 wtmp, wtmp1; Word32 Ltmp; - Word16 use_prev_sf_pit_gain = 0; + Word16 use_prev_sf_pit_gain = 0; // Q0 + move16(); gain1 = 0; move16(); @@ -206,7 +211,8 @@ Word16 lp_filt_exc_enc_ivas_fx( test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( coder_type, 100 ) ) { - use_prev_sf_pit_gain = 1; + use_prev_sf_pit_gain = 1; // Q0 + move16(); } exp_ener = 0; move16(); @@ -215,13 +221,13 @@ Word16 lp_filt_exc_enc_ivas_fx( test(); IF( EQ_16( *lp_flag, FULL_BAND ) || EQ_16( *lp_flag, NORMAL_OPERATION ) ) { - IF( use_prev_sf_pit_gain == 1 ) + IF( EQ_16( use_prev_sf_pit_gain, 1 ) ) { - wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, gain_pit, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); + wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, gain_pit, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); // exp_ener } - else + ELSE { - wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); + wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); // exp_ener } } @@ -235,7 +241,7 @@ Word16 lp_filt_exc_enc_ivas_fx( wtmp1 = 0; move16(); test(); - IF( ( EQ_16( *lp_flag, LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) + IF( ( ( *lp_flag == LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) { test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( L_frame, L_FRAME16k ) ) @@ -246,6 +252,7 @@ Word16 lp_filt_exc_enc_ivas_fx( Ltmp = L_mac( Ltmp, 19005, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 6881, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } ELSE @@ -256,15 +263,16 @@ Word16 lp_filt_exc_enc_ivas_fx( Ltmp = L_mac( Ltmp, 20972, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 5898, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } - IF( use_prev_sf_pit_gain == 1 ) + IF( EQ_16( use_prev_sf_pit_gain, 1 ) ) { - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); // exp_ener1 } ELSE { - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); // exp_ener1 } } @@ -284,18 +292,18 @@ Word16 lp_filt_exc_enc_ivas_fx( test(); test(); - IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( EQ_16( *lp_flag, LOW_PASS ) ) ) + IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( ( *lp_flag == LOW_PASS ) ) ) { /* use the LP filter for pitch excitation prediction */ select = LOW_PASS; move16(); - Copy( exc_tmp, &exc[i_subfr], L_subfr ); - Copy( y1_tmp, y1, L_subfr ); - Copy( xn2_tmp, xn2, L_subfr ); + Copy( exc_tmp, &exc[i_subfr], L_subfr ); // Q_new + Copy( y1_tmp, y1, L_subfr ); // Q_new-1+shift + Copy( xn2_tmp, xn2, L_subfr ); // Q_new-1+shift IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain2; + *gain_pit = gain2; // Q14 move16(); g_corr[0] = g_corr2[0]; move16(); @@ -314,7 +322,7 @@ Word16 lp_filt_exc_enc_ivas_fx( move16(); IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain1; + *gain_pit = gain1; // Q14 move16(); } } @@ -367,9 +375,9 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation { FOR( i = 0; i < L_subfr; i++ ) { - exc_tmp[i] = mult( exc[i], 8192 ); + exc_tmp[i] = mult( exc[i], 8192 /*0.25.Q15*/ ); // Q_new move16(); - xn_tmp[i] = mult( xn[i], 8192 ); + xn_tmp[i] = mult( xn[i], 8192 /*0.25.Q15*/ ); // Q_new move16(); } Overflow = 0; @@ -383,14 +391,14 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation test(); if ( EQ_16( clip_gain, 1 ) && GT_16( *gain, 15565 ) ) /* constant in Q14 */ { - *gain = 15565; + *gain = 15565; // 0.95.Q14 move16(); } test(); - if ( EQ_16( clip_gain, 2 ) && GT_16( *gain, 10650 ) ) + IF( EQ_16( clip_gain, 2 ) && GT_16( *gain, 10650 ) ) // 0.65.Q14 { - *gain = 10650; + *gain = 10650; // 0.65.Q14 move16(); } } @@ -403,14 +411,14 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation /* could possibly happen in GSC */ Ltmp = Calc_Energy_Autoscaled( xn2, 0, L_subfr, exp_ener ); i = norm_l( Ltmp ); - ener = extract_h( L_shl( Ltmp, i ) ); + ener = extract_h( L_shl( Ltmp, i ) ); // exp_ener i = sub( 31, i ); *exp_ener = sub( i, *exp_ener ); move16(); } ELSE { - ener = extract_h( Dot_product12( xn2, xn2, L_SUBFR, exp_ener ) ); + ener = extract_h( Dot_product12( xn2, xn2, L_SUBFR, exp_ener ) ); // Q15 } return ener; @@ -424,9 +432,9 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation *-------------------------------------------------------------------*/ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ - const Word16 xn_1[], /* i : target signal */ - const Word16 y1_1[], /* i : filtered adaptive codebook excitation */ - Word16 g_corr[], /* o : correlations and -2 */ + const Word16 xn_1[], /* i : target signal Q_new*/ + const Word16 y1_1[], /* i : filtered adaptive codebook excitation 12 bits*/ + Word16 g_corr[], /* o : correlations and -2 mant/exp*/ const Word16 L_subfr, /* i : vector length */ const Word16 norm_flag /* i : flag for constraining pitch contribution */ , @@ -446,7 +454,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) *----------------------------------------------------------------*/ /* Compute scalar product */ - Copy( xn_1, xn, L_subfr ); + Copy( xn_1, xn, L_subfr ); // Q_new Copy( y1_1, y1, L_subfr ); Overflow = 0; move16(); @@ -457,9 +465,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) { FOR( i = 0; i < L_subfr; i++ ) { - xn[i] = mult_r( xn_1[i], 4096 ); + xn[i] = mult_r( xn_1[i], 4096 /*0.125.Q15*/ ); // Q-new move16(); - y1[i] = mult_r( y1_1[i], 4096 ); + y1[i] = mult_r( y1_1[i], 4096 /*0.125.Q15*/ ); move16(); } @@ -484,7 +492,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) } ELSE { - yy = extract_h( Ltmp1 ); + yy = extract_h( Ltmp1 ); // exp_yy /* Ltmp1 = L_shr(Ltmp1, sub(30, exp_yy));*/ /* Compute scalar product */ @@ -499,7 +507,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) g_corr[1] = exp_yy; move16(); /* -2.0*temp1 + 0.01 is done in Gain_enc_2 function*/ - g_corr[2] = xy; + g_corr[2] = xy; // exp_xy move16(); g_corr[3] = exp_xy; move16(); @@ -510,8 +518,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) IF( xy >= 0 && NE_16( s_or( yy, xy ), 16384 ) ) { /* compute gain = xy/yy */ - xy = shr( xy, 1 ); /* be sure that xy < yy */ - gain = div_s( xy, yy ); + xy = shr( xy, 1 ); /* be sure that xy < yy */ + gain = div_s( xy, yy ); // Q15 i = sub( exp_xy, exp_yy ); gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ *Overflow_out |= Overflow; @@ -536,7 +544,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) /* gain_p_snr = sqrt(/) */ tmp = BASOP_Util_Divide1616_Scale( xx, yy, &exp_div ); exp_xx = add( sub( exp_xx, exp_yy ), exp_div ); - tmp = Sqrt16( tmp, &exp_xx ); + tmp = Sqrt16( tmp, &exp_xx ); // exp_xx /* Note: shl works as shl or shr. */ exp_xx = sub( exp_xx, 1 ); @@ -544,8 +552,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); BASOP_SATURATE_WARNING_ON_EVS - gain = s_min( gain, gain_p_snr ); + gain = s_min( gain, gain_p_snr ); // Q14 } - return gain; + return gain; // Q14 } diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 24179f375..6761dfb82 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -74,8 +74,10 @@ void lsf_enc_fx( const Word16 Q_new ) { Word16 nBits = 0; + move16(); Word16 int_fs; Word16 force_sf = 0; + move16(); Word16 fec_lsf[M], stab, i; Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -189,7 +191,7 @@ void lsf_enc_fx( lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) + IF( EQ_16( st_fx->last_core, HQ_CORE ) && ( st_fx->core == ACELP_CORE ) ) { /* don't use old LSF values if this is the first ACELP frame after HQ frames */ Copy( lsf_new, st_fx->lsf_old_fx, M ); @@ -216,7 +218,7 @@ void lsf_enc_fx( FEC_lsf_estim_enc_fx( st_fx, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ - stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); + stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 test(); test(); @@ -255,8 +257,8 @@ void lsf_enc_fx( if ( st_fx->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st_fx->lsp_old_fx, M ); - Copy( lsf_new, st_fx->lsf_old_fx, M ); + Copy( lsp_new, st_fx->lsp_old_fx, M ); // Q15 + Copy( lsf_new, st_fx->lsf_old_fx, M ); // Q15 } /* Mid-frame LSF encoding */ lsf_mid_enc_fx( st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); @@ -265,7 +267,7 @@ void lsf_enc_fx( IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) { /* don't use old LSP/LSF values if this is the first ACELP frame after HQ frames */ - Copy( lsp_mid, st_fx->lsp_old_fx, M ); + Copy( lsp_mid, st_fx->lsp_old_fx, M ); // Q15 lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, int_fs ); } @@ -299,10 +301,10 @@ void lsf_enc_fx( void lsf_enc_ivas_fx( Encoder_State *st, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ + Word16 *lsf_new, /* o : quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized Q15*/ + Word16 *lsp_mid, /* i/o : mid-frame LSP vector Q15*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ @@ -462,15 +464,15 @@ void lsf_enc_ivas_fx( IF( NE_16( st->last_L_frame, st->L_frame ) ) { /* FEC - in case of core switching, use old LSFs */ - Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); - Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); - Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); + Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); // Q15 + Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); // Q15 + Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); // Q15 } FEC_lsf_estim_enc_fx( st, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ - stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); + stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); // Q15 test(); test(); @@ -509,8 +511,8 @@ void lsf_enc_ivas_fx( IF( st->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st->lsp_old_fx, M ); - Copy( lsf_new, st->lsf_old_fx, M ); + Copy( lsp_new, st->lsp_old_fx, M ); // Q15 + Copy( lsf_new, st->lsf_old_fx, M ); // Q15 } /* Mid-frame LSF encoding */ lsf_mid_enc_ivas_fx( st->hBstr, st->acelp_cfg.mid_lsf_bits, st->sr_core, st->lsp_old_fx, lsp_new, lsp_mid, coder_type, st->bwidth, st->Bin_E_old_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); @@ -529,9 +531,9 @@ void lsf_enc_ivas_fx( { IF( EQ_16( st->active_cnt, 1 ) ) { - Copy( lsp_mid, st->lsp_old_fx, M ); + Copy( lsp_mid, st->lsp_old_fx, M ); // Q15 lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core ); - Copy( lsp_new, lsp_mid, M ); + Copy( lsp_new, lsp_mid, M ); // Q15 } /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ @@ -546,7 +548,7 @@ void lsf_enc_ivas_fx( *------------------------------------------------------------------*/ IF( NE_32( st->core_brate, SID_2k40 ) ) { - st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); + st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); // Q15 } return; } @@ -847,8 +849,8 @@ static Word16 qlsf_Mode_Select_fx( /*========================================================================*/ void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ - Word16 *qlsf, /* o : quantized LSF */ + const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ + Word16 *qlsf, /* o : quantized LSF x2.56*/ const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ const Word16 coder_type_org, /* i : coding type */ Word16 Q_ener, /* i : Q valuen for Bin_Ener */ @@ -1008,7 +1010,7 @@ void lsf_end_enc_fx( IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) { /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); + st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); // Q15 move16(); } @@ -1211,7 +1213,7 @@ void lsf_end_enc_fx( { lpc_param[i] = TCQIdx0[i]; move16(); - bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; + bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; // Q0 move16(); } } @@ -1352,8 +1354,8 @@ void lsf_end_enc_fx( void lsf_end_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ - Word16 *qlsf, /* o : quantized LSF */ + const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ + Word16 *qlsf, /* o : quantized LSF x2.56*/ const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ const Word16 coder_type_org, /* i : coding type */ Word16 Q_ener, /* i : Q valuen for Bin_Ener */ @@ -1944,10 +1946,10 @@ void lsf_end_enc_ivas_fx( static void first_VQstages( const Word16 *const *cb, - Word16 u[], /* i : vector to be encoded (prediction and mean removed) */ + Word16 u[], /* i : vector to be encoded (prediction and mean removed) x2.56*/ Word16 *levels, /* i : number of levels in each stage */ Word16 stagesVQ, /* i : number of stages */ - Word16 w[], /* i : weights */ + Word16 w[], /* i : weights Q8*/ Word16 N, /* i : vector dimension */ Word16 max_inner, /* i : maximum number of swaps in inner loop */ Word16 indices_VQstage[] ) @@ -2338,10 +2340,10 @@ static void first_VQstages_ivas_fx( static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, - Word16 u[], + Word16 u[], // x2.56 Word16 *levels, Word16 stages, - Word16 w[], + Word16 w[], // Q8 Word16 Idx[], const Word16 *lsf, const Word16 *pred, @@ -2370,13 +2372,13 @@ static Word32 vq_lvq_lsf_enc( { cb = &Quantizers_fx[CB_lsf[mode]]; move16(); - mode_glb = add( offset_lvq_modes_SN_fx[mode], offset_in_lvq_mode_SN_fx[mode][sub( levels[stagesVQ], min_lat_bits_SN_fx[mode] )] ); + mode_glb = add( offset_lvq_modes_SN_fx[mode], offset_in_lvq_mode_SN_fx[mode][( levels[stagesVQ] - min_lat_bits_SN_fx[mode] )] ); // Q0 } ELSE /* predictive */ { cb = &Quantizers_p_fx[CB_p_lsf[mode]]; move16(); - mode_glb = add( offset_lvq_modes_pred_fx[mode], offset_in_lvq_mode_pred_fx[mode][sub( levels[stagesVQ], min_lat_bits_pred_fx[mode] )] ); + mode_glb = add( offset_lvq_modes_pred_fx[mode], offset_in_lvq_mode_pred_fx[mode][( levels[stagesVQ] - min_lat_bits_pred_fx[mode] )] ); // Q0 } IF( stagesVQ > 0 ) { @@ -2421,7 +2423,7 @@ static Word32 vq_lvq_lsf_enc( { L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ } - e[i] = L_tmp; + e[i] = L_tmp; /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ move32(); } @@ -2447,10 +2449,10 @@ static Word32 vq_lvq_lsf_enc( static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, - Word16 u[], + Word16 u[], // x2.56 Word16 *levels, Word16 stages, - Word16 w[], + Word16 w[], // Q8 Word16 Idx[], const Word16 *lsf, const Word16 *pred, @@ -2478,7 +2480,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( IF( LT_16( mode, 6 ) ) { move16(); - mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][sub( levels[stagesVQ], min_lat_bits_SN[mode] )] ); + mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][( levels[stagesVQ] - min_lat_bits_SN[mode] )] ); } ELSE { @@ -2492,7 +2494,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( IF( LT_16( mode, 6 ) || EQ_16( mode, 12 ) ) { move16(); - mode_glb = add( offset_lvq_modes_pred[mode], offset_in_lvq_mode_pred[mode][sub( levels[stagesVQ], min_lat_bits_pred_fx[mode] )] ); + mode_glb = add( offset_lvq_modes_pred[mode], offset_in_lvq_mode_pred[mode][( levels[stagesVQ] - min_lat_bits_pred_fx[mode] )] ); } ELSE { @@ -2572,7 +2574,7 @@ static void BcTcvq_1st_fx( Word16 c[][16], Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2)*/ Word16 Q_fx[][16][2], - Word16 W_fx[][2] /*Q10*/ + Word16 W_fx[][2] /*Q8*/ ) { Word16 state, prev_state; @@ -2633,7 +2635,7 @@ static void BcTcvq_2nd_fx( Word16 c[][16], Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2) */ Word16 Q_fx[][16][2], /*x2.56*/ - Word16 W_fx[][2], /*Q10*/ + Word16 W_fx[][2], /*Q8*/ const Word16 itc_fx[][2][2] /*Q15*/ ) { @@ -2921,12 +2923,12 @@ static Word32 BcTcvq_FixSearch_fx( Q_fx[stage][*prev_state][1] = add( CB_fx[stage4][bestCode][1], pred_fx[1] ); move16(); - minDist_fx = L_shr( minDist_fx, 2 ); + minDist_fx = L_shr( minDist_fx, 2 ); /*2.56*2.56*Q(-5 - 2)*/ return minDist_fx; } static Word16 optimalPath_fx( - Word32 cDist_fx[][16], - Word32 blockDist_fx[], + Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2)*/ + Word32 blockDist_fx[], /*2.56*2.56*Q(-5 - 2)*/ Word16 blockCodeword[][4], Word16 bestCodeword[], Word16 codeWord[][16], @@ -2985,10 +2987,11 @@ static Word16 optimalPath_fx( static void quantEnc_fx( Word16 *y_fx, Word16 c[], - const Word16 CB_SUB1_fx[][128][2], - const Word16 CB_SUB2_fx[][64][2], - const Word16 CB_SUB3_fx[][32][2], - const Word16 itc_fx[][2][2] ) + const Word16 CB_SUB1_fx[][128][2], /*x2.56*/ + const Word16 CB_SUB2_fx[][64][2], /*x2.56*/ + const Word16 CB_SUB3_fx[][32][2], /*x2.56*/ + const Word16 itc_fx[][2][2] // Q15 +) { Word16 i, j; Word16 stage; @@ -3103,9 +3106,9 @@ static void buildCode_fx( } static void BcTcvq_fx( Word16 snFlag, - const Word16 *x_fx, - Word16 *y_fx, - const Word16 *weight_fx, + const Word16 *x_fx, // x2.65 + Word16 *y_fx, // x2.65 + const Word16 *weight_fx, // Q8 Word16 *ind ) { Word16 X_fx[N_STAGE_VQ][N_DIM], W_fx[N_STAGE_VQ][N_DIM]; @@ -3162,9 +3165,9 @@ static void BcTcvq_fx( { FOR( j = 0; j < N_DIM; j++ ) { - X_fx[i][j] = x_fx[( N_DIM * i ) + j]; + X_fx[i][j] = x_fx[( N_DIM * i ) + j]; // x2.65 move16(); - W_fx[i][j] = weight_fx[( N_DIM * i ) + j]; + W_fx[i][j] = weight_fx[( N_DIM * i ) + j]; // x2.56 move16(); } } @@ -3259,10 +3262,10 @@ static void BcTcvq_fx( } static Word16 SVQ_2d_fx( - Word16 *x_fx, - Word16 *y_fx, - const Word16 *W_fx, - const Word16 CB_fx[][8], + Word16 *x_fx, // x2.65 + Word16 *y_fx, // x2.65 + const Word16 *W_fx, // Q8 + const Word16 CB_fx[][8], // x2.65 Word16 Size ) { Word16 i, j; @@ -3280,7 +3283,7 @@ static Word16 SVQ_2d_fx( { temp16_fx = sub( x_fx[j], CB_fx[i][j] ); distortion_fx = L_add( distortion_fx, - L_shr( Mult_32_16( L_mult( temp16_fx, temp16_fx ), W_fx[j] ), 1 ) ); + L_shr( Mult_32_16( L_mult( temp16_fx, temp16_fx ), W_fx[j] ), 1 ) ); // (2*x2.65 + Q1 + Q8) - Q15 - Q1 } IF( LT_32( distortion_fx, temp_fx ) ) @@ -3403,9 +3406,9 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( } static void FFT_Mid_Interpol_16k_fx( - Word32 Bin_Ener_old[], /* i/o: Old 2nd FFT Bin energy (128) */ - Word32 Bin_Ener[], /* i : Current 2nd FFT Bin energy (128) */ - Word32 Bin_Ener_mid[] /* o : LP weighting filter (numerator) */ + Word32 Bin_Ener_old[], /* i/o: Old 2nd FFT Bin energy (128) Q_ener*/ + Word32 Bin_Ener[], /* i : Current 2nd FFT Bin energy (128) Q_ener*/ + Word32 Bin_Ener_mid[] /* o : LP weighting filter (numerator) Q_ener*/ ) { Word16 i; @@ -3642,12 +3645,12 @@ static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 nb_bits, /* i : number of bits */ const Word32 int_fs, /* i : internal (ACELP) sampling frequency*/ - const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ - const Word16 qlsp1[], /* i : quantized LSPs from frame end */ - Word16 lsp[], /* i/o: mid-frame LSP */ + const Word16 qlsp0[], /* i : quantized LSPs from frame beginning Q15*/ + const Word16 qlsp1[], /* i : quantized LSPs from frame end Q15*/ + Word16 lsp[], /* i/o: mid-frame LSP Q15*/ const Word16 coder_type, /* i : coding type */ const Word16 bwidth, /* i : input signal bandwidth */ - Word32 Bin_Ener[], /* i : per bin log energy spectrum */ + Word32 Bin_Ener[], /* i : per bin log energy spectrum Q_ener*/ Word16 Q_ener, /* i : Q value of Bin_ener */ Word16 ppp_mode, Word16 nelp_mode ) @@ -3681,19 +3684,19 @@ static void lsf_mid_enc_ivas_fx( { case 5: { - ratio = tbl_mid_voi_wb_5b_fx; + ratio = tbl_mid_voi_wb_5b_fx; // Q13 move16(); BREAK; } case 4: { - ratio = tbl_mid_voi_wb_4b_fx; + ratio = tbl_mid_voi_wb_4b_fx; // Q13 move16(); BREAK; } case 1: { - ratio = tbl_mid_voi_wb_1b_fx; + ratio = tbl_mid_voi_wb_1b_fx; // Q13 move16(); BREAK; } @@ -3701,7 +3704,7 @@ static void lsf_mid_enc_ivas_fx( } ELSE IF( EQ_16( coder_type, UNVOICED ) ) { - ratio = tbl_mid_unv_wb_5b_fx; + ratio = tbl_mid_unv_wb_5b_fx; // Q13 } ELSE { @@ -3710,19 +3713,19 @@ static void lsf_mid_enc_ivas_fx( { case 5: { - ratio = tbl_mid_gen_wb_5b_fx; + ratio = tbl_mid_gen_wb_5b_fx; // Q13 move16(); BREAK; } case 4: { - ratio = tbl_mid_gen_wb_4b_fx; + ratio = tbl_mid_gen_wb_4b_fx; // Q13 move16(); BREAK; } case 2: { - ratio = tbl_mid_gen_wb_2b_fx; + ratio = tbl_mid_gen_wb_2b_fx; // Q13 move16(); BREAK; } @@ -3734,7 +3737,7 @@ static void lsf_mid_enc_ivas_fx( } ELSE IF( EQ_16( ppp_mode, 1 ) ) { - ratio = tbl_mid_voi_wb_1b_fx; + ratio = tbl_mid_voi_wb_1b_fx; // Q13 move16(); nb_bits = 1; move16(); @@ -3743,7 +3746,7 @@ static void lsf_mid_enc_ivas_fx( } ELSE IF( EQ_16( nelp_mode, 1 ) ) { - ratio = tbl_mid_unv_wb_4b_fx; + ratio = tbl_mid_unv_wb_4b_fx; // Q13 move16(); nb_bits = 4; move16(); @@ -3765,7 +3768,7 @@ static void lsf_mid_enc_ivas_fx( FOR( j = 0; j < M; j++ ) { /* qlsf[j] = (1.0f - ratio[k*M+j]) * qlsf0[j] + ratio[k*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000, ratio[k1 + j] ), qlsf0[j] ); + L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[k1 + j] ), qlsf0[j] ); L_tmp = L_mac( L_tmp, ratio[k1 + j], qlsf1[j] ); qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); @@ -3802,7 +3805,7 @@ static void lsf_mid_enc_ivas_fx( FOR( j = 0; j < M; j++ ) { /* qlsf[j] = (1.0f - ratio[idx*M+j]) * qlsf0[j] + ratio[idx*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] ); + L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[idx * M + j] ), qlsf0[j] ); L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 28e1a39de..60375ddcc 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -37,7 +37,6 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "rom_com.h" #include "rom_enc.h" @@ -93,7 +92,7 @@ Word16 msvq_stage1_dct_search_fx( Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ Word16 *dist1_ptr_e ) { - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; + Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; // Q20 Word32 u_mr_fx[FDCNG_VQ_MAX_LEN]; Word16 dist1_ptr_e_buf[2 * LSFMBEST_MAX]; Word64 mse_trunc_segm_fx[FDCNG_VQ_DCT_NSEGM]; @@ -127,7 +126,7 @@ Word16 msvq_stage1_dct_search_fx( tmp_e = s_max( 12, u_e ); FOR( i = 0; i < n_ana; i++ ) { - u_mr_fx[i] = L_sub( L_shl( u_fx[i], sub( u_e, tmp_e ) ), L_shl( midQ_truncQ_fx[i], sub( Q31 - Q10, tmp_e ) ) ); + u_mr_fx[i] = L_sub( L_shl( u_fx[i], sub( u_e, tmp_e ) ), L_shl( midQ_truncQ_fx[i], sub( Q31 - Q10, tmp_e ) ) ); // tmp_e move32(); } @@ -136,9 +135,9 @@ Word16 msvq_stage1_dct_search_fx( /* init search state ptr's at the top */ set32_fx( dist1_ptr_fx, MAX_32, maxC_st1 ); set16_fx( dist1_ptr_e_buf, 32, maxC_st1 ); - st1_mse_pair_fx = &( dist1_ptr_fx[0] ); /* req. ptr post upd +=2 */ - st1_mse_pair_e = &( dist1_ptr_e_buf[0] ); /* req. ptr post upd +=2 */ - st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */ + st1_mse_pair_fx = &( dist1_ptr_fx[0] ); /* req. ptr post upd +=2 */ // st1_mse_pair_e + st1_mse_pair_e = &( dist1_ptr_e_buf[0] ); /* req. ptr post upd +=2 */ + st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */ set64_fx( mse_trunc_segm_fx, 0, n_segm ); // set16_fx( mse_trunc_segm_e, u_e, FDCNG_VQ_DCT_NSEGM ); @@ -152,7 +151,7 @@ Word16 msvq_stage1_dct_search_fx( FOR( i = 0; i < trunc_dct_cols_per_segment[segm]; i++ ) { - mse_trunc_segm_fx[segm] = W_mac_32_32( mse_trunc_segm_fx[segm], dct_target_fx[cols_per_segment[segm] + i], dct_target_fx[cols_per_segment[segm] + i] ); + mse_trunc_segm_fx[segm] = W_mac_32_32( mse_trunc_segm_fx[segm], dct_target_fx[cols_per_segment[segm] + i], dct_target_fx[cols_per_segment[segm] + i] ); // Q41 move64(); } @@ -163,7 +162,7 @@ Word16 msvq_stage1_dct_search_fx( /* unweighted segmented search DCT domain loop */ j_full = add( j, cum_entries_per_segment[segm] ); /* or simply use j_full++ */ - mse_fx = mse_trunc_segm_fx[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ + mse_fx = mse_trunc_segm_fx[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ // Q41 move64(); dct_col_shift_tab = col_syn_shift[segm]; /* ptr init */ @@ -176,10 +175,10 @@ Word16 msvq_stage1_dct_search_fx( SHIFT( 1 ); ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/ #undef WMC_TOOL_SKIP - mse_fx = W_mac_32_32( mse_fx, tmp_fx, tmp_fx ); /* L_mac or L_mac0() square Word16 -> Word32*/ + mse_fx = W_mac_32_32( mse_fx, tmp_fx, tmp_fx ); /* L_mac or L_mac0() square Word16 -> Word32*/ // Q41 } Word16 L_tmp = W_norm( mse_fx ); - st1_mse_ptr_fx[j_full] = W_extract_h( W_lshl( mse_fx, L_tmp ) ); /* save MSE in shared dynamic RAM, move32() in BASOP */ + st1_mse_ptr_fx[j_full] = W_extract_h( W_lshl( mse_fx, L_tmp ) ); /* save MSE in shared dynamic RAM, move32() in BASOP */ // st1_mse_ptr_e move32(); st1_mse_ptr_e[j_full] = sub( shl( tmp_e, 1 ), L_tmp ); move16(); @@ -362,9 +361,9 @@ Word16 msvq_stage1_dct_search_fx( /*! r: (updated p_max) */ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( - const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ + const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors st1_syn_vec_e*/ const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ - const Word32 *u_fx, /* i : target signal */ + const Word32 *u_fx, /* i : target signal u_e*/ const Word16 u_e, /* i : exp for target signal */ const Word16 maxC_st1, /* i : number of candidates in stage1 */ Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ @@ -390,7 +389,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ FOR( i = 0; i < FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB; i++ ) { - high_diff_fx[i] = L_sub( L_shr( p2_fx[i], sub( tmp_e, st1_syn_vec_e ) ), L_shr( u_fx[FDCNG_VQ_MAX_LEN_WB + i], sub( tmp_e, u_e ) ) ); + high_diff_fx[i] = L_sub( L_shr( p2_fx[i], sub( tmp_e, st1_syn_vec_e ) ), L_shr( u_fx[FDCNG_VQ_MAX_LEN_WB + i], sub( tmp_e, u_e ) ) ); // tmp_e move32(); } acc = 0; @@ -457,7 +456,7 @@ void msvq_enc_ivas_fx( Word16 j; const Word16 *cbp, *cb_stage; Word32 resid_buf_fx[2 * LSFMBEST_MAX * M_MAX], *resid_fx[2]; - Word32 *pTmp, *p1, *p2; + Word32 *pTmp, *p1, *p2; // pTmp_e Word16 pTmp_e; Word16 *indices[2], m, s, c, c2, p_max, i; Word16 idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX]; diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index b81cc18e8..aa2255c68 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -36,10 +36,10 @@ val2 = shr( ( cbp )[2], 4 ); \ val3 = add( add( shr( lshl( ( cbp )[2], 12 ), 4 ), lshr( lshl( ( cbp )[1], 12 ), 8 ) ), s_and( ( cbp )[0], 0xF ) ); /*--------------------------------------------------------------------------* - * depack_mul_values() + * depack_mul_values_fx() * *--------------------------------------------------------------------------*/ -static Word32 depack_mul_values( Word16 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N ) +static Word32 depack_mul_values_fx( Word16 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N ) { Word16 i, val0, val1, val2, val3; Word32 en; @@ -69,7 +69,7 @@ static Word32 depack_mul_values( Word16 *Tmp, const Word16 *w, const Word16 *cbp * depack_sub_values() * *--------------------------------------------------------------------------*/ -static void depack_sub_values( Word16 *pTmp, const Word16 *p1, const Word16 *cbp, const Word16 N ) +static void depack_sub_values_fx( Word16 *pTmp, const Word16 *p1, const Word16 *cbp, const Word16 N ) { Word16 j, val0, val1, val2, val3; @@ -93,7 +93,7 @@ static void depack_sub_values( Word16 *pTmp, const Word16 *p1, const Word16 *cbp * * Unroll of inner search loop for maxC == 8 *--------------------------------------------------------------------------*/ -static Word16 msvq_enc_find_p_max_8( Word32 dist[] ) +static Word16 msvq_enc_find_p_max_8_fx( Word32 dist[] ) { Word16 p_max; @@ -144,7 +144,7 @@ static Word16 msvq_enc_find_p_max_8( Word32 dist[] ) * * Unroll of inner search loop for maxC == 6 *--------------------------------------------------------------------------*/ -static Word16 msvq_enc_find_p_max_6( Word32 dist[] ) +static Word16 msvq_enc_find_p_max_6_fx( Word32 dist[] ) { Word16 p_max; @@ -194,7 +194,7 @@ void msvq_enc_fx( const Word16 maxC, /* i : Tree search size (number of candidates kept from */ /* one stage to the next == M-best) */ const Word16 stages, /* i : Number of stages */ - const Word16 w[], /* i : Weights */ + const Word16 w[], /* i : Weights Q8*/ const Word16 N, /* i : Vector dimension */ const Word16 maxN, /* i : Codebook dimension */ Word16 Idx[] /* o : Indices */ @@ -231,11 +231,11 @@ void msvq_enc_fx( set16_fx( parents, 0, maxC ); - func_ptr = msvq_enc_find_p_max_6; + func_ptr = msvq_enc_find_p_max_6_fx; move16(); if ( EQ_16( maxC, 8 ) ) { - func_ptr = msvq_enc_find_p_max_8; + func_ptr = msvq_enc_find_p_max_8_fx; move16(); } @@ -326,7 +326,7 @@ void msvq_enc_fx( FOR( j = 0; j < levels[s]; j++ ) { /* Compute weighted codebook element and its energy */ - en = depack_mul_values( Tmp + start, w + start, cbp, n ); + en = depack_mul_values_fx( Tmp + start, w + start, cbp, n ); cbp += N34; /* pointer is incremented */ @@ -378,7 +378,7 @@ void msvq_enc_fx( move16(); Copy( p1, pTmp, start ); - depack_sub_values( pTmp + start, p1 + start, &cb[s][p2i * N34], n ); + depack_sub_values_fx( pTmp + start, p1 + start, &cb[s][p2i * N34], n ); Copy( p1 + start + n, pTmp + start + n, sub( N, add( start, n ) ) ); pTmp += N; @@ -407,12 +407,12 @@ void msvq_enc_fx( *--------------------------------------------------------------------------*/ void midlsf_enc_fx( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 lsf[], /* i: lsf coefficients (3Q12) */ - Word16 *idx, /* o: codebook index */ - const Word16 lpcorder, /* i: order of the lpc */ - const Word32 *Bin_Ener_128_fx, + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 lsf[], /* i: lsf coefficients (3Q12) */ + Word16 *idx, /* o: codebook index */ + const Word16 lpcorder, /* i: order of the lpc */ + const Word32 *Bin_Ener_128_fx, // Q_ener const Word16 Q_ener, const Word8 narrowBand, const Word32 sr_core, @@ -502,8 +502,8 @@ void midlsf_enc_fx( * Returns: number of indices *--------------------------------------------------------------------------*/ Word16 Q_lsf_tcxlpc_fx( - /* const */ Word16 lsf[], /* i : original lsf */ - Word16 lsf_q[], /* o : quantized lsf */ + /* const */ Word16 lsf[], /* i : original lsf 14Q1 * 1.28 */ + Word16 lsf_q[], /* o : quantized lsf (14Q1*1.28)*/ Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ Word16 indices[], /* o : VQ indices */ const Word16 lpcorder, /* i : LPC order */ @@ -511,7 +511,7 @@ Word16 Q_lsf_tcxlpc_fx( const Word16 cdk, /* i : codebook selector */ const Word16 mem_MA[], /* i : MA memory */ const Word16 coder_type, - const Word32 *Bin_Ener, + const Word32 *Bin_Ener, // Q_ener const Word16 Q_ener ) { Word16 weights[M + 1]; @@ -578,7 +578,7 @@ Word16 Q_lsf_tcxlpc_fx( FOR( i = 0; i < lpcorder; ++i ) { - lsf_q_ind[i] = lsf_q[i]; + lsf_q_ind[i] = lsf_q[i]; /*(14Q1*1.28)*/ move16(); } @@ -891,7 +891,7 @@ Word16 enc_lsf_tcxlpc_ivas_fx( Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, + Word16 *param_lpc, // Q0 Word16 core, Word16 acelp_mode, Word16 acelp_midLpc, @@ -916,7 +916,7 @@ Word16 lsf_msvq_ma_encprm_fx( IF( NE_16( acelp_mode, VOICED ) ) { test(); - IF( EQ_16( core, ACELP_CORE ) && acelp_midLpc ) + IF( ( core == ACELP_CORE ) && acelp_midLpc ) { push_next_indice_fx( hBstr, *param_lpc, bits_midlpc ); @@ -928,7 +928,7 @@ Word16 lsf_msvq_ma_encprm_fx( } Word16 lsf_msvq_ma_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, + const Word16 *param_lpc, // Q0 const Word16 core, const Word16 acelp_mode, const Word16 acelp_midLpc, @@ -953,7 +953,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( IF( NE_16( acelp_mode, VOICED ) ) { test(); - IF( EQ_16( core, ACELP_CORE ) && acelp_midLpc ) + IF( ( core == ACELP_CORE ) && acelp_midLpc ) { push_next_indice( hBstr, *param_lpc, bits_midlpc ); @@ -971,7 +971,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( *--------------------------------------------------------------------------*/ Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, + Word16 *param_lpc, // Q0 Word16 *bits_param_lpc, Word16 no_indices ) { @@ -990,7 +990,7 @@ Word16 lsf_bctcvq_encprm_fx( } Word16 lsf_bctcvq_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, + const Word16 *param_lpc, // Q0 const Word16 *bits_param_lpc, const Word16 no_indices ) { diff --git a/lib_enc/ltd_stable_fx.c b/lib_enc/ltd_stable_fx.c index a6e3ae1cc..036fe2a7e 100644 --- a/lib_enc/ltd_stable_fx.c +++ b/lib_enc/ltd_stable_fx.c @@ -21,7 +21,7 @@ void ltd_stable_fx( VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ Word16 *ltd_stable_rate, /* o : time-domain stable rate*/ - const Word32 frame_energy, /* i : current frame energy*/ + const Word32 frame_energy, /* i : current frame energy Q_frames_power*/ const Word16 frameloop, /* i : amount of frames*/ const Word16 Q_frames_power /* i : the Scaling of frames_power*/ ) @@ -57,7 +57,7 @@ void ltd_stable_fx( move16(); Q_apow = 0; move16(); - frames_power_32 = hVAD_CLDFB->frames_power_32; + frames_power_32 = hVAD_CLDFB->frames_power_32; // Q_frames_power_last_32 Q_frames_power_last_32 = hVAD_CLDFB->Q_frames_power_32; move16(); leadingzero_midamp = 31; @@ -76,7 +76,7 @@ void ltd_stable_fx( IF( GE_16( Q_frames_power32, 40 ) ) { zerop001 = L_shr( CNT0P001, 1 ); - frame_energy_Sqr32 = L_shr( frame_energy_Sqr32, sub( Q_frames_power32, 39 ) ); + frame_energy_Sqr32 = L_shr( frame_energy_Sqr32, sub( Q_frames_power32, 39 ) ); // Q_frames_power32 Q_frames_power32 = 39; move16(); } @@ -86,14 +86,14 @@ void ltd_stable_fx( frame_energy_Sqr32 = L_shr( frame_energy_Sqr32, 1 ); zerop001 = L_shr( CNT0P001, sub( 40, Q_frames_power32 ) ); } - frames_power_32[0] = L_add( frame_energy_Sqr32, zerop001 ); + frames_power_32[0] = L_add( frame_energy_Sqr32, zerop001 ); // Q_frames_power32 move32(); IF( LT_16( frameloop, 3 ) ) { FOR( i = 1; i < 40; i++ ) { - frames_power_32[i] = frames_power_32[0]; + frames_power_32[i] = frames_power_32[0]; // Q_frames_power32 move32(); } } @@ -104,7 +104,7 @@ void ltd_stable_fx( move32(); FOR( i = 1; i < 40; i++ ) { - maxVal = L_max( maxVal, frames_power_32[i] ); + maxVal = L_max( maxVal, frames_power_32[i] ); // Q_frames_power32 } leadingzero = 31; move16(); @@ -119,7 +119,7 @@ void ltd_stable_fx( scale1 = sub( scale1, leadingzero ); FOR( i = 1; i < 40; i++ ) { - frames_power_32[i] = L_shr( frames_power_32[i], scale1 ); + frames_power_32[i] = L_shr( frames_power_32[i], scale1 ); // Q_frames_power32 move32(); } } @@ -140,7 +140,7 @@ void ltd_stable_fx( FOR( i = 0; i < 20; i++ ) { - mid_frame_ampadd32[i] = L_add( L_shr( frames_power_32[2 * i], 1 ), L_shr( frames_power_32[2 * i + 1], 1 ) ); + mid_frame_ampadd32[i] = L_add( L_shr( frames_power_32[2 * i], 1 ), L_shr( frames_power_32[2 * i + 1], 1 ) ); // Q_frames_power32 move32(); } @@ -148,16 +148,18 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 20; i++ ) { - maxVal = L_max( maxVal, mid_frame_ampadd32[i] ); + maxVal = L_max( maxVal, mid_frame_ampadd32[i] ); // Q_frames_power32 } leadingzero_midamp = 31; move16(); if ( maxVal ) + { leadingzero_midamp = norm_l( maxVal ); + } FOR( i = 0; i < 20; i++ ) { - mid_frame_amp32[i] = L_shl( mid_frame_ampadd32[i], leadingzero_midamp ); + mid_frame_amp32[i] = L_shl( mid_frame_ampadd32[i], leadingzero_midamp ); // Q_frames_power32 + leadingzero_midamp move32(); } @@ -165,19 +167,19 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 20; i++ ) { - seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 5 ) ); + seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 5 ) ); // Q_frames_power32 + leadingzero_midamp - 5 } - seg_amp32 = MUL_F( seg_amp32, 0x0666 ); + seg_amp32 = MUL_F( seg_amp32, 0x0666 /*(1/20).Q15*/ ); dif32 = 0; move32(); apow32 = 0; move32(); - seg_amp32tmp = L_shl( seg_amp32, 5 ); + seg_amp32tmp = L_shl( seg_amp32, 5 ); // Q_frames_power32 + leadingzero_midamp FOR( i = 0; i < 20; i++ ) { - tmp32[i] = L_sub( mid_frame_amp32[i], seg_amp32tmp ); + tmp32[i] = L_sub( mid_frame_amp32[i], seg_amp32tmp ); // Q_frames_power32 + leadingzero_midamp move32(); } @@ -185,22 +187,24 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 20; i++ ) { - maxVal = L_max( maxVal, L_abs( tmp32[i] ) ); + maxVal = L_max( maxVal, L_abs( tmp32[i] ) ); // Q_frames_power32 + leadingzero_midamp - 5 } leadingzero_tmp32 = 31; move16(); if ( maxVal ) + { leadingzero_tmp32 = norm_l( maxVal ); + } FOR( i = 0; i < 20; i++ ) { - tmp16[i] = extract_h( L_shl( tmp32[i], leadingzero_tmp32 ) ); + tmp16[i] = extract_h( L_shl( tmp32[i], leadingzero_tmp32 ) ); //// Q_frames_power32 + leadingzero_midamp + leadingzero_tmp32 - 16 } FOR( i = 0; i < 20; i++ ) { - tmp_mul = L_mult_sat( tmp16[i], tmp16[i] ); - tmp_mul = L_shr( tmp_mul, 5 ); + tmp_mul = L_mult_sat( tmp16[i], tmp16[i] ); // 2 * (Q_frames_power32 + leadingzero_midamp + leadingzero_tmp32 - 16) + 1 + tmp_mul = L_shr( tmp_mul, 5 ); // 2 * (Q_frames_power32 + leadingzero_midamp + leadingzero_tmp32 - 16) - 4 dif32 = L_add( dif32, tmp_mul ); tmp = extract_h( mid_frame_amp32[i] ); @@ -244,7 +248,9 @@ void ltd_stable_fx( leadingzero_midamp = 31; move16(); if ( maxVal ) + { leadingzero_midamp = norm_l( maxVal ); + } FOR( i = 0; i < 14; i++ ) { @@ -256,15 +262,15 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 14; i++ ) { - seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 4 ) ); + seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 4 ) ); // Q_frames_power32 - 4 } - seg_amp32 = MUL_F( seg_amp32, 0x0924 ); + seg_amp32 = MUL_F( seg_amp32, 0x0924 /*(1/14).Q15*/ ); dif32 = 0; move32(); apow32 = 0; move32(); - seg_amp32tmp = L_shl( seg_amp32, 4 ); + seg_amp32tmp = L_shl( seg_amp32, 4 ); // Q_frames_power32 FOR( i = 0; i < 14; i++ ) { tmp32[i] = L_sub( mid_frame_amp32[i], seg_amp32tmp ); @@ -280,7 +286,9 @@ void ltd_stable_fx( leadingzero_tmp32 = 31; move16(); if ( maxVal ) + { leadingzero_tmp32 = norm_l( maxVal ); + } FOR( i = 0; i < 14; i++ ) { @@ -367,8 +375,10 @@ void ltd_stable_fx( } leadingzero_midamp = 31; move16(); - if ( maxVal ) + IF( maxVal ) + { leadingzero_midamp = norm_l( maxVal ); + } FOR( i = 0; i < 8; i++ ) { @@ -382,7 +392,7 @@ void ltd_stable_fx( { seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 3 ) ); } - seg_amp32 = MUL_F( seg_amp32, 0x1000 ); + seg_amp32 = MUL_F( seg_amp32, 0x1000 /*(1/8).Q15*/ ); dif32 = 0; move32(); @@ -403,9 +413,10 @@ void ltd_stable_fx( } leadingzero_tmp32 = 31; move16(); - if ( maxVal ) + IF( maxVal ) + { leadingzero_tmp32 = norm_l( maxVal ); - + } FOR( i = 0; i < 8; i++ ) { tmp32[i] = L_shl( tmp32[i], leadingzero_tmp32 ); @@ -482,7 +493,7 @@ void ltd_stable_fx( ltd_stable_rate[2] = shr( ltd_stable_rate[2], ltd_stable_rate_Qtmp ); move16(); - ltd_stable_rate[3] = add( mult( ltd_stable_rate[3], 0x7333 ), mult( ltd_stable_rate[2], 0x0ccc ) ); + ltd_stable_rate[3] = add( mult( ltd_stable_rate[3], 0x7333 /*0.9.Q15*/ ), mult( ltd_stable_rate[2], 0x0ccc /*0.1.Q15*/ ) ); move16(); FOR( i = 55; i > 0; i-- ) diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index eec85c254..a4e19e040 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -46,7 +46,7 @@ * Square magnitude of fft spectrum *----------------------------------------------------------------------------*/ static void dft_mag_square_fx( - const Word16 x[], /* i : Input vector: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ + const Word16 x[], /* i : Input vector: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] Qx*/ Word32 magSq[], /* o : Magnitude square spectrum */ const Word16 n /* i : Input vector length */ ) @@ -57,7 +57,7 @@ static void dft_mag_square_fx( /* Magnitude square at 0. */ pMagSq = &magSq[0]; - pRe = &x[0]; + pRe = &x[0]; // Qx *pMagSq++ = L_mult0( *pRe, *pRe ); pRe++; move32(); @@ -70,13 +70,13 @@ static void dft_mag_square_fx( { acc = L_mult0( *pRe, *pRe ); pRe++; - *pMagSq++ = L_mac0( acc, *pIm, *pIm ); + *pMagSq++ = L_mac0( acc, *pIm, *pIm ); // 2*Qx pIm--; move32(); } /* The magnitude square at N/2 */ - *pMagSq = L_mult0( *pRe, *pRe ); + *pMagSq = L_mult0( *pRe, *pRe ); // 2*Qx move32(); return; } @@ -89,7 +89,7 @@ static void dft_mag_square_fx( Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ const Word16 *fft_buff, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ Encoder_State *st_fx, /* i/o: Encoder state variable */ - Word32 *cldfbBuf_Ener, + Word32 *cldfbBuf_Ener, // enerBuffer_exp Word16 enerBuffer_exp, const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) @@ -260,7 +260,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision { IF( max_i > 0 ) { - IF( GT_16( np, 0 ) ) + IF( ( np > 0 ) ) { d_acc = sub( add( d_acc, max_i ), pos_last ); } @@ -277,7 +277,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision IF( pe != 0 ) { expo = norm_l( pe ); - man = L_shl( pe, expo ); + man = L_shl( pe, expo ); // expo Mpy_32_32_ss( man, man, &man, &lsb32 ); /* pe square */ expo = shl( expo, 1 ); /* Multiply by 2 due to squaring. */ floating_point_add( &p_energy_man, &p_energy_exp, man, expo ); @@ -309,35 +309,35 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision /* gain11 = 8*(gain1 - cldfbBuf_Ener[0]/8)/7; */ acc = L_shr( cldfbBuf_Ener[0], 3 ); acc = L_sub( gain1, acc ); - acc = Mult_32_16( acc, 4681 ); + acc = Mult_32_16( acc, 4681 /*(1/7).Q15*/ ); gain11 = L_shl( acc, 3 ); gain4 = L_deposit_l( 0 ); FOR( k = 0; k < 12; k++ ) { - gain4 = L_add( gain4, Mult_32_16( cldfbBuf_Ener[k + 12], 2731 ) ); + gain4 = L_add( gain4, Mult_32_16( cldfbBuf_Ener[k + 12], 2731 /*(1/12).Q15*/ ) ); } peak_H1 = L_add( cldfbBuf_Ener[25], 0 ); - Mpy_32_16_ss( cldfbBuf_Ener[25], 6554, &avrg_H1, &lsb16 ); + Mpy_32_16_ss( cldfbBuf_Ener[25], 6554 /*0.4.Q15*/, &avrg_H1, &lsb16 ); FOR( k = 1; k < 5; k++ ) { IF( GT_32( cldfbBuf_Ener[k + 25], peak_H1 ) ) { peak_H1 = L_add( cldfbBuf_Ener[k + 25], 0 ); } - avrg_H1 = L_add( avrg_H1, Mult_32_16( cldfbBuf_Ener[k + 25], 6554 ) ); + avrg_H1 = L_add( avrg_H1, Mult_32_16( cldfbBuf_Ener[k + 25], 6554 /*0.4.Q15*/ ) ); } peak_H2 = L_add( cldfbBuf_Ener[20], 0 ); - Mpy_32_16_ss( cldfbBuf_Ener[20], 6554, &avrg_H2, &lsb16 ); + Mpy_32_16_ss( cldfbBuf_Ener[20], 6554 /*0.4.Q15*/, &avrg_H2, &lsb16 ); FOR( k = 1; k < 5; k++ ) { IF( GT_32( cldfbBuf_Ener[k + 20], peak_H2 ) ) { peak_H2 = L_add( cldfbBuf_Ener[k + 20], 0 ); } - avrg_H2 = L_add( avrg_H2, Mult_32_16( cldfbBuf_Ener[k + 20], 6554 ) ); + avrg_H2 = L_add( avrg_H2, Mult_32_16( cldfbBuf_Ener[k + 20], 6554 /*0.4.Q15*/ ) ); } // End peak_l = L_deposit_l( 0 ); @@ -400,7 +400,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision condition4 = 0; move16(); - L_tmp = Mult_32_16( peak_h, 12603 ); + L_tmp = Mult_32_16( peak_h, 12603 /*1/2.56.Q15*/ ); IF( GT_32( peak_l, L_tmp ) ) { exp = norm_l( peak_l ); @@ -418,7 +418,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision exp1 = norm_l( avrg_l ); } - L_tmp1 = Mult_32_16( peak_l, 12603 ); + L_tmp1 = Mult_32_16( peak_l, 12603 /*1/2.56.Q15*/ ); IF( GT_32( peak_h, L_tmp1 ) ) { exp2 = norm_l( peak_h ); @@ -438,7 +438,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision move16(); } - L_tmp = Mult_32_16( peak_h, 12800 ); + L_tmp = Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ); IF( GT_32( peak_l, L_tmp ) ) { exp = norm_l( peak_l ); @@ -448,7 +448,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision exp = norm_l( L_tmp ); } - L_tmp1 = Mult_32_16( peak_l, 6400 ); + L_tmp1 = Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ); IF( GT_32( peak_h, L_tmp1 ) ) { exp2 = norm_l( peak_h ); @@ -476,7 +476,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); test(); - IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 ) ) && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 ), avrg_H2 ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) ) + IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 /*0.8.Q15*/ ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 /*0.3.Q15*/ ) ) && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 /*(1/1.5).Q15*/ ), avrg_H2 ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 /*(1/2.56).Q15*/ ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) ) { condition4 = 1; move16(); @@ -498,21 +498,21 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision } /* Smooth decision from instantaneous decision*/ - acc = L_mult( hTcxEnc->clas_sec_old_fx, MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* st_fx->clas_sec_old_fx in Q13 */ - clas_sec = mac_r( acc, c, 0x7fff - MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* clas_sec and c are in Q13 */ + acc = L_mult( hTcxEnc->clas_sec_old_fx, MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* st_fx->clas_sec_old_fx in Q13 */ + clas_sec = mac_r( acc, c, 0x7fff /*1.Q15*/ - MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* clas_sec and c are in Q13 */ /* Do thresholding with hysteresis */ IF( GT_16( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ) { - gain1_tmp = L_shr( gain1, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); + gain1_tmp = L_shr( gain1, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); // st_fx->last_enerBuffer_exp move32(); - gain2_tmp = L_shr( gain2, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); + gain2_tmp = L_shr( gain2, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); // st_fx->last_enerBuffer_exp move32(); } ELSE { - hTcxEnc->last_gain1 = L_shr( hTcxEnc->last_gain1, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); + hTcxEnc->last_gain1 = L_shr( hTcxEnc->last_gain1, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); // enerBuffer_exp move32(); - hTcxEnc->last_gain2 = L_shr( hTcxEnc->last_gain2, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); + hTcxEnc->last_gain2 = L_shr( hTcxEnc->last_gain2, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); // enerBuffer_exp move32(); gain1_tmp = gain1; move32(); @@ -582,10 +582,11 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision return clas_final; /* Q0 */ } + Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ - const Word32 enerBuffer[], /* i : energy buffer */ + const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/ Word16 enerBuffer_exp, const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) @@ -772,7 +773,7 @@ Word16 mdct_classifier_ivas_fx( IF( pe != 0 ) { expo = norm_l( pe ); - man = L_shl( pe, expo ); + man = L_shl( pe, expo ); // expo Mpy_32_32_ss( man, man, &man, &lsb32 ); /* pe square */ expo = shl( expo, 1 ); /* Multiply by 2 due to squaring. */ floating_point_add( &p_energy_man, &p_energy_exp, man, expo ); @@ -795,32 +796,32 @@ Word16 mdct_classifier_ivas_fx( { IF( EQ_16( gain2_start, GAIN2_START_SWB ) ) { - gain1 = L_add( gain1, L_shr( enerBuffer[i], 3 ) ); - gain2 = L_add( gain2, L_shr( enerBuffer[gain2_start + i], 3 ) ); - gain3 = L_add( gain3, L_shr( enerBuffer[gain3_start + i], 3 ) ); + gain1 = L_add( gain1, L_shr( enerBuffer[i], 3 ) ); // enerBuffer_exp - 3 + gain2 = L_add( gain2, L_shr( enerBuffer[gain2_start + i], 3 ) ); // enerBuffer_exp - 3 + gain3 = L_add( gain3, L_shr( enerBuffer[gain3_start + i], 3 ) ); // enerBuffer_exp - 3 } ELSE { - gain1 = L_add( gain1, Mult_32_16( enerBuffer[i], 5461 ) ); - gain2 = L_add( gain2, Mult_32_16( enerBuffer[gain2_start + i], 5461 ) ); - gain3 = L_add( gain3, Mult_32_16( enerBuffer[gain3_start + i], 5461 ) ); + gain1 = L_add( gain1, Mult_32_16( enerBuffer[i], 5461 ) ); // enerBuffer_exp + gain2 = L_add( gain2, Mult_32_16( enerBuffer[gain2_start + i], 5461 /*0.16.Q15*/ ) ); // enerBuffer_exp + gain3 = L_add( gain3, Mult_32_16( enerBuffer[gain3_start + i], 5461 /*0.16.Q15*/ ) ); // enerBuffer_exp } } IF( EQ_16( gain2_start, GAIN2_START_SWB ) ) { - acc = L_shr( enerBuffer[0], 3 ); - acc = L_sub( gain1, acc ); - acc = Mult_32_16( acc, 4681 ); - gain11 = L_shl( acc, 3 ); + acc = L_shr( enerBuffer[0], 3 ); // enerBuffer_exp - 3 + acc = L_sub( gain1, acc ); // enerBuffer_exp - 3 + acc = Mult_32_16( acc, 4681 /*(1/7).Q15*/ ); // enerBuffer_exp - 3 + gain11 = L_shl( acc, 3 ); // enerBuffer_exp gain4 = L_deposit_l( 0 ); } ELSE { - acc = Mult_32_16( enerBuffer[0], 5461 ); - acc = L_sub( gain1, acc ); - acc = Mult_32_16( acc, 6553 ); + acc = Mult_32_16( enerBuffer[0], 5461 /*0.16.Q15*/ ); // enerBuffer_exp + acc = L_sub( gain1, acc ); // enerBuffer_exp + acc = Mult_32_16( acc, 6553 /*0.4.Q15*/ ); // enerBuffer_exp gain11 = (Word32) W_mult_32_16( acc, 6 ); gain4 = L_deposit_l( 0 ); } @@ -830,28 +831,28 @@ Word16 mdct_classifier_ivas_fx( { IF( EQ_16( gain4_start, GAIN4_START_SWB ) ) { - gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 2731 ) ); + gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 2731 /*(1/12).Q15*/ ) ); } ELSE { - gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 3641 ) ); + gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 3641 /*(1/9).Q1.15*/ ) ); } } - peak_H1 = enerBuffer[H1_start]; + peak_H1 = enerBuffer[H1_start]; // enerBuffer_exp move32(); - avrg_H1 = enerBuffer[H1_start]; + avrg_H1 = enerBuffer[H1_start]; // enerBuffer_exp move32(); FOR( i = 1; i < H_length; i++ ) { IF( GT_32( enerBuffer[H1_start + i], peak_H1 ) ) { - peak_H1 = enerBuffer[H1_start + i]; + peak_H1 = enerBuffer[H1_start + i]; // enerBuffer_exp move32(); } - avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); + avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); // enerBuffer_exp } peak_H2 = enerBuffer[H2_start]; @@ -969,7 +970,7 @@ Word16 mdct_classifier_ivas_fx( move16(); } - L_tmp = Mult_32_16( peak_h, 12800 ); + L_tmp = Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ); IF( GT_32( peak_l, L_tmp ) ) { exp = norm_l( peak_l ); @@ -979,7 +980,7 @@ Word16 mdct_classifier_ivas_fx( exp = norm_l( L_tmp ); } - L_tmp1 = Mult_32_16( peak_l, 6400 ); + L_tmp1 = Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ); IF( GT_32( peak_h, L_tmp1 ) ) { exp2 = norm_l( peak_h ); @@ -1007,8 +1008,8 @@ Word16 mdct_classifier_ivas_fx( test(); test(); test(); - IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 ) ) && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 ), avrg_H2 ) ) || - ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) ) + IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 /*0.8.Q15*/ ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 /*0.3.Q15*/ ) ) && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 /*(1/1.5).Q15*/ ), avrg_H2 ) ) || + ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 /*(1/2.56).Q15*/ ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) ) { condition4 = 1; move16(); diff --git a/lib_enc/mdct_selector_fx.c b/lib_enc/mdct_selector_fx.c index 52c30f7ef..c4cc7d0db 100644 --- a/lib_enc/mdct_selector_fx.c +++ b/lib_enc/mdct_selector_fx.c @@ -62,14 +62,14 @@ static Word16 get_sparseness( /* Returns sparseness measur FOR( i = 1; i < n - 1; ++i ) { - if ( GT_16( Bin_E[i], s_max( s_max( Bin_E[i - 1], Bin_E[i + 1] ), thr ) ) ) + IF( GT_16( Bin_E[i], s_max( s_max( Bin_E[i - 1], Bin_E[i + 1] ), thr ) ) ) { num_max = add( num_max, 1 ); } } n = shr( sub( n, 2 ), 1 ); - return div_s( sub( n, num_max ), n ); + return div_s( sub( n, num_max ), n ); // Q15 } /*--------------------------------------------------------------------------* * get_mean_ener() @@ -78,7 +78,7 @@ static Word16 get_sparseness( /* Returns sparseness measur *--------------------------------------------------------------------------*/ static Word16 get_mean_ener( /* Returns mean energy in dB (Q8) */ - const Word32 enerBuffer[], /* i : CLDFB buffers */ + const Word32 enerBuffer[], /* i : CLDFB buffers enerBuffer_exp*/ Word16 enerBuffer_exp, /* i : exponent of enerBuffer */ Word16 n /* i : number of bins */ ) @@ -87,8 +87,10 @@ static Word16 get_mean_ener( /* Returns mean energy i Word16 i, shift, frac_nrg, exp_nrg; shift = sub( 14, norm_s( n ) ); - if ( LT_16( shl( 1, shift ), n ) ) + IF( LT_16( shl( 1, shift ), n ) ) + { shift = add( shift, 1 ); + } L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < n; ++i ) @@ -104,7 +106,7 @@ static Word16 get_mean_ener( /* Returns mean energy i exp_nrg = sub( add( exp_nrg, shift ), sub( 31, enerBuffer_exp ) ); L_tmp = Mpy_32_16( exp_nrg, frac_nrg, 9864 ); /* log10(2) in Q15 */ - return round_fx( L_shl( L_tmp, 8 ) ); + return round_fx( L_shl( L_tmp, 8 ) ); // Q8 } /*--------------------------------------------------------------------------* * MDCT_selector_fx() @@ -117,7 +119,7 @@ void MDCT_selector_fx( Word16 sp_floor, /* i : Noise floor estimate Q7 */ const Word16 Etot, /* i : Total energy Q8 */ const Word16 cor_map_sum, /* i : harmonicity factor Q8 */ - const Word32 enerBuffer[], /* i : CLDFB buffers */ + const Word32 enerBuffer[], /* i : CLDFB buffers enerBuffer_exp*/ const Word16 enerBuffer_exp /* i : exponent of enerBuffer */ ) { @@ -135,7 +137,7 @@ void MDCT_selector_fx( sp_floor = shl( sp_floor, 1 ); /* convert to Q8 */ - IF( EQ_16( st->bwidth, NB ) ) + IF( ( st->bwidth == NB ) ) { lob_cldfb = 3200 / 400; move16(); @@ -188,7 +190,7 @@ void MDCT_selector_fx( frame_voicing = add( shr( st->voicing_fx[0], 1 ), shr( st->voicing_fx[1], 1 ) ); /* Spectral sparseness */ - sparseness = get_sparseness( st->lgBin_E_fx, lob_fft, sub( Etot, MDCT_SW_SIG_PEAK_THR ) ); + sparseness = get_sparseness( st->lgBin_E_fx, lob_fft, sub( Etot, MDCT_SW_SIG_PEAK_THR ) ); // Q15 /* Hi band energy */ hi_ener = get_mean_ener( &enerBuffer[lob_cldfb], enerBuffer_exp, sub( hib_cldfb, lob_cldfb ) ); @@ -255,23 +257,23 @@ void MDCT_selector_fx( IF( EQ_16( st->mdct_sw_enable, MODE1 ) ) { - sig_lo_level_thr = MDCT_SW_1_SIG_LO_LEVEL_THR; + sig_lo_level_thr = MDCT_SW_1_SIG_LO_LEVEL_THR; // Q8 move16(); - sig_hi_level_thr = MDCT_SW_1_SIG_HI_LEVEL_THR; + sig_hi_level_thr = MDCT_SW_1_SIG_HI_LEVEL_THR; // Q8 move16(); - cor_thr = MDCT_SW_1_COR_THR; + cor_thr = MDCT_SW_1_COR_THR; // Q8 move16(); - cor_thr2 = MDCT_SW_1_COR_THR2; + cor_thr2 = MDCT_SW_1_COR_THR2; // Q8 move16(); - voicing_thr = MDCT_SW_1_VOICING_THR; + voicing_thr = MDCT_SW_1_VOICING_THR; // Q15 move16(); - voicing_thr2 = MDCT_SW_1_VOICING_THR2; + voicing_thr2 = MDCT_SW_1_VOICING_THR2; // Q15 move16(); - sparseness_thr = MDCT_SW_1_SPARSENESS_THR; + sparseness_thr = MDCT_SW_1_SPARSENESS_THR; // Q15 move16(); - sparseness_thr2 = MDCT_SW_1_SPARSENESS_THR2; + sparseness_thr2 = MDCT_SW_1_SPARSENESS_THR2; // Q15 move16(); - hi_ener_lo_thr = MDCT_SW_1_HI_ENER_LO_THR; + hi_ener_lo_thr = MDCT_SW_1_HI_ENER_LO_THR; // Q8 move16(); } ELSE /* st->mdct_sw_enable == MODE2 */ diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index 771ef480b..af5a82b69 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -58,19 +58,19 @@ Word32 mslvq_fx( IF( pred_flag == 0 ) { - p_sigma = sigma_MSLVQ_fx[mode]; + p_sigma = sigma_MSLVQ_fx[mode]; // Qlog2(2.56) /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; - p_scales = scales_fx[mode_glb]; - p_no_lead = no_lead_fx[mode_glb]; + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 + p_scales = scales_fx[mode_glb]; // Q11 + p_no_lead = no_lead_fx[mode_glb]; // Q0 } ELSE { - p_sigma = sigma_p_fx[mode]; + p_sigma = sigma_p_fx[mode]; // Qlog2(2.56) /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_p_fx[mode]; - p_scales = scales_p_fx[mode_glb]; - p_no_lead = no_lead_p_fx[mode_glb]; + p_inv_sigma = inv_sigma_p_fx[mode]; // Q15 + p_scales = scales_p_fx[mode_glb]; // Q11 + p_no_lead = no_lead_p_fx[mode_glb]; // Q0 } /* first subvector */ @@ -184,15 +184,15 @@ Word32 mslvq_cng_fx( mode_glb = add( START_CNG, idx_cv ); move16(); - p_sigma = sigma_MSLVQ_fx[mode]; + p_sigma = sigma_MSLVQ_fx[mode]; // x2.56 move16(); - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 move16(); - p_scales = scales_fx[mode_glb]; + p_scales = scales_fx[mode_glb]; // Q11 move16(); - p_no_lead = no_lead_fx[mode_glb]; + p_no_lead = no_lead_fx[mode_glb]; // Q0 move16(); - p_no_scales = &no_scales[shl( mode_glb, 1 )]; + p_no_scales = &no_scales[( mode_glb << 1 )]; move16(); /* check if LSF component permutation is needed or not */ @@ -247,11 +247,11 @@ Word32 mslvq_cng_ivas_fx( mode_glb = add( START_CNG, idx_cv ); move16(); - p_sigma = sigma_MSLVQ_fx[mode]; + p_sigma = sigma_MSLVQ_fx[mode]; // x2.56 move16(); - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 move16(); - p_scales = scales_fx[mode_glb]; + p_scales = scales_fx[mode_glb]; // Q11 move16(); no_scales[0] = 0; @@ -773,7 +773,7 @@ static void sort_desc_ind_fx( move16(); } sorted = 0; - FOR( k = sub( len, 1 ); k > 0; k-- ) + FOR( k = ( len - 1 ); k > 0; k-- ) { IF( sorted ) { @@ -837,7 +837,7 @@ void index_lvq_fx( /* for first subvector */ IF( GT_16( idx_scale[0], -1 ) ) { - index1 = L_add( encode_comb_fx( quant, idx_lead[0] ), L_add( table_no_cv_fx[idx_lead[0]], p_offset_scale1[i_mult2( mode, len_offset ) + idx_scale[0]] ) ); + index1 = L_add( encode_comb_fx( quant, idx_lead[0] ), L_add( table_no_cv_fx[idx_lead[0]], p_offset_scale1[( mode * len_offset ) + idx_scale[0]] ) ); } /* for second subvector */ @@ -845,7 +845,7 @@ void index_lvq_fx( IF( GT_16( idx_scale[1], -1 ) ) { - index2 = L_add( encode_comb_fx( &quant[LATTICE_DIM], idx_lead[1] ), L_add( table_no_cv_fx[idx_lead[1]], p_offset_scale2[i_mult2( mode, len_offset ) + idx_scale[1]] ) ); + index2 = L_add( encode_comb_fx( &quant[LATTICE_DIM], idx_lead[1] ), L_add( table_no_cv_fx[idx_lead[1]], p_offset_scale2[( mode * len_offset ) + idx_scale[1]] ) ); } idx64 = W_mult0_32_32( index1, p_offset_scale2[mode * len_offset + p_no_scales[mode * 2 + 1]] ); index2_64 = W_deposit32_l( index2 ); @@ -854,9 +854,9 @@ void index_lvq_fx( /* convert to 3 short */ index[0] = ( ( idx64 ) & ( 0x7fff ) ); move16(); - index[1] = ( idx64 >> 15 ) & ( 0x7fff ); + index[1] = ( W_shr( idx64, 15 ) ) & ( 0x7fff ); move16(); - index[2] = ( idx64 >> 30 ) & ( 0x7fff ); + index[2] = ( W_shr( idx64, 30 ) ) & ( 0x7fff ); move16(); return; } @@ -900,9 +900,9 @@ void index_lvq_ivas_fx( /* convert to 3 short */ index[0] = ( ( idx64 ) & ( 0x7fff ) ); move16(); - index[1] = ( idx64 >> 15 ) & ( 0x7fff ); + index[1] = ( W_shr( idx64, 15 ) ) & ( 0x7fff ); move16(); - index[2] = ( idx64 >> 30 ) & ( 0x7fff ); + index[2] = ( W_shr( idx64, 30 ) ) & ( 0x7fff ); move16(); return; @@ -1059,7 +1059,7 @@ static Word16 encode_sign_pc1_fx( /* o : index of signs IF( cv[i] < 0 ) { idx_sign = add( idx_sign, ( shl( 1, cnt ) ) ); - cnt++; + cnt = add( cnt, 1 ); } if ( cv[i] > 0 ) @@ -1091,7 +1091,7 @@ static void take_out_val_fx( FOR( i = 0; i < len; i++ ) { - IF( NE_16( v[i], val ) ) + if ( NE_16( v[i], val ) ) { v_out[cnt++] = v[i]; move16(); @@ -1125,7 +1125,7 @@ Word16 c2idx_fx( /* o: index */ move16(); FOR( i = 1; i <= p[0]; i++ ) { - skip = add( skip, C_VQ[sub( n, i )][sub( k, 1 )] ); + skip = add( skip, C_VQ[( n - i )][( k - 1 )] ); // Q0 } p0 = p[0]; diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 78ef81c60..1bae597b6 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -53,7 +53,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity /* length of the useful part of the spectrum (up to 6.4kHz) */ L = L_FFT / 2; move16(); - if ( EQ_16( bwidth, NB ) ) + if ( ( bwidth == NB ) ) { /* length of the useful part of the spectrum (up to 3.6kHz) */ L = 76; @@ -170,14 +170,14 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity mean_dyn = round_fx( L_acc ); /*Q7*/ test(); - IF( LT_16( mean_dyn, 1229 ) /*9.6f*/ && *cor_strong_limit != 0 ) + IF( LT_16( mean_dyn, 1229 ) /*9.6f.Q7*/ && *cor_strong_limit != 0 ) { *cor_strong_limit = 0; move16(); *st_last_sw_dyn = mean_dyn; move16(); } - ELSE IF( GT_16( sub( mean_dyn, *st_last_sw_dyn ), 576 ) /*4.5f*/ ) + ELSE IF( GT_16( sub( mean_dyn, *st_last_sw_dyn ), 576 ) /*4.5f.Q7*/ ) { *cor_strong_limit = 1; move16(); @@ -290,7 +290,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity cor_strong = 0; move16(); - pt1 = cor_map_LT; + pt1 = cor_map_LT; // Q15 move16(); pt2 = cor_map; move16(); @@ -306,7 +306,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity /* cor_map_LT_sum += *pt1 */ Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */ - if ( GT_16( *pt1, 31130 ) /*0.95f*/ ) + if ( GT_16( *pt1, 31130 ) /*0.95f.Q15*/ ) { cor_strong = 1; move16(); @@ -316,7 +316,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity pt2++; } - IF( EQ_16( bwidth, NB ) ) + IF( ( bwidth == NB ) ) { /* cor_map_LT_sum *= 1.53f; */ /* tmp2 *= 1.53f; */ @@ -396,7 +396,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni /* length of the useful part of the spectrum (up to 6.4kHz) */ L = L_FFT / 2; move16(); - if ( EQ_16( bwidth, NB ) ) + if ( ( bwidth == NB ) ) { /* length of the useful part of the spectrum (up to 3.6kHz) */ L = 76; @@ -654,7 +654,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni } tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8 - IF( EQ_16( bwidth, NB ) ) + IF( ( bwidth == NB ) ) { /* cor_map_LT_sum *= 1.53f; */ /* tmp2 *= 1.53f; */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 353de8ec9..e04f5172b 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -17,7 +17,6 @@ #include "debug.h" #endif #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 7bbc54780..5c96a2f29 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" #include "stl.h" #include "prot_fx.h" /* Function prototypes */ -#include "ivas_prot.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 61ca9b101..ba8ee5aa8 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "ivas_prot.h" /* Function prototypes */ #include "stl.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 008e27d6c..770b62764 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -36,7 +36,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 81437c49d..e50ad32e1 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 9cc764afb..93a100e17 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -34,7 +34,6 @@ #include #include "ivas_cnst.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 730705ffd..0deb14c9b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -35,7 +35,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index e89414542..b8b3c3ac7 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index 4eae9c286..e9af8483a 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 29eac3635..40ed0ad58 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 958a23a3f..e254ed6dd 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 52ca3e6f9..7a74e62da 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -36,7 +36,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 5d53d2ae3..e3965fbff 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -36,7 +36,6 @@ #include "ivas_prot_rend.h" #include "ivas_error.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 8b7e6575d..430fab2c7 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "lib_rend.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 25fddaa80..8b56b6855 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "options.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 93fe67436..7b1e1fe91 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index d7387ecd4..2c28b32bd 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -35,7 +35,6 @@ #include #include "ivas_cnst.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index bb6f26346..a124bf4bd 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -33,7 +33,6 @@ #include "common_api_types.h" #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 054e5e981..6fba496d5 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -37,7 +37,6 @@ #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------------* diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index bbe6ae4b5..74be74497 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -1,6 +1,5 @@ #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef FIX_DISCLAIMER #include diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index a02a29d0d..d6e397234 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -39,7 +39,6 @@ #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "debug.h" diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index 44550803a..ab41b43c2 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 4323fc96f..d544acd13 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 6d5b23f12..0fc5c21df 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "math.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index 06cbd83a6..b90b3a456 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -35,7 +35,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ae3166520..2c81911a1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -33,7 +33,6 @@ #include "options.h" #include "lib_rend.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 930bb79dc..0316d8b30 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -34,7 +34,6 @@ #include #include "prot_fx.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 90d47b7c9..f4f43e496 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -33,7 +33,7 @@ #include "ls_custom_file_reader.h" #include #include -#include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 9351d9bc9..efab80b79 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "masa_file_reader.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include #include -- GitLab From 7027097814fca9e108640c2793a4620025705dfc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 19:41:16 +0530 Subject: [PATCH 304/329] Clang formatting changes --- lib_com/gs_bitallocation_ivas_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 71b30ea75..9243f640e 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -2,11 +2,11 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ -#include "assert.h" /* Debug prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com.h" /* Static table prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "assert.h" /* Debug prototypes */ #include "stl.h" #include "ivas_prot_fx.h" -- GitLab From a9c9fd5c18a642694f5e0ecd1ebc26d7cb82718e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 12:32:57 +0530 Subject: [PATCH 305/329] Fix for 3GPP issue 1341: Usage of open/deleteCldfb() functions - multiple variants Link #1341 --- lib_com/cldfb.c | 107 +++-------------------- lib_com/cnst.h | 6 +- lib_com/prot_fx.h | 15 +--- lib_dec/init_dec_fx.c | 6 +- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 4 +- lib_dec/ivas_init_dec.c | 4 +- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 +- lib_dec/ivas_stereo_switching_dec_fx.c | 10 +-- lib_enc/init_enc_fx.c | 4 +- lib_enc/ivas_masa_enc_fx.c | 4 +- lib_enc/ivas_omasa_enc_fx.c | 4 +- lib_enc/ivas_stereo_switching_enc_fx.c | 10 +-- lib_enc/ivas_stereo_td_enc_fx.c | 8 +- lib_rend/ivas_dirac_ana_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/lib_rend.c | 4 +- 19 files changed, 53 insertions(+), 147 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 38195b65d..7fc8026b5 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1364,8 +1364,8 @@ ivas_error openCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -) + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + CODE_TYPE code_type ) { HANDLE_CLDFB_FILTER_BANK hs; Word16 buf_len; @@ -1379,7 +1379,14 @@ ivas_error openCldfb_ivas_fx( move32(); hs->prototype = prototype; move32(); - configureCldfb_ivas_fx( hs, sampling_rate ); + IF( code_type == IVAS_ENC ) + { + configureCldfb_ivas_enc_fx( hs, sampling_rate ); + } + ELSE + { + configureCldfb_ivas_fx( hs, sampling_rate ); + } hs->memory32 = NULL; hs->FilterStates = NULL; hs->memory_length = 0; @@ -1413,65 +1420,6 @@ ivas_error openCldfb_ivas_fx( return IVAS_ERR_OK; } -ivas_error openCldfb_ivas_enc( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -) -{ - HANDLE_CLDFB_FILTER_BANK hs; - Word16 buf_len; - - IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - - hs->type = type; - move32(); - hs->prototype = prototype; - move32(); - - configureCldfb_ivas_enc_fx( hs, sampling_rate ); - hs->memory_length = 0; - move32(); - - IF( type == CLDFB_ANALYSIS ) - { - buf_len = sub( hs->p_filter_length, hs->no_channels ); - hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) ); - hs->FilterStates_eg = 0; - move16(); - } - ELSE - { - buf_len = hs->p_filter_length; - move16(); - hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) ); - hs->FilterStates_eg = 0; - move16(); - } - - if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer - move16(); - hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ - move16(); - set32_fx( hs->cldfb_state_fx, 0, buf_len ); - hs->Q_cldfb_state = 0; - move16(); - set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) ); - set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) ); - - *h_cldfb = hs; - - return IVAS_ERR_OK; -} - /*-------------------------------------------------------------------* * resampleCldfb_ivas() * @@ -1563,41 +1511,6 @@ void analysisCldfbEncoder_ivas_fx( return; } - -/*-------------------------------------------------------------------* - * GetEnergyCldfb_ivas() - * - * Remove handle - *--------------------------------------------------------------------*/ - -void deleteCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -) -{ - HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb; - - test(); - IF( h_cldfb == NULL || *h_cldfb == NULL ) - { - return; - } - - IF( hs->cldfb_state_fx ) - { - free( hs->cldfb_state_fx ); - } - - IF( hs->FilterStates ) - { - free( hs->FilterStates ); - } - - free( hs ); - *h_cldfb = NULL; - - return; -} - void deleteCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ ) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 7c93498af..3c014325e 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -803,7 +803,11 @@ typedef enum CLDFB_ANALYSIS, CLDFB_SYNTHESIS } CLDFB_TYPE; - +typedef enum +{ + IVAS_ENC, + IVAS_DEC_REND +} CODE_TYPE; typedef enum { CLDFB_PROTOTYPE_1_25MS, diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index db0953cd9..c1aefbe36 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9803,8 +9803,8 @@ ivas_error openCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + CODE_TYPE code_type ); Word32 rand_gauss_fx( Word32 *x, @@ -11944,13 +11944,6 @@ ivas_error openCldfb_ivas( CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ ); -ivas_error openCldfb_ivas_enc( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - void resampleCldfb_ivas( HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ const Word32 newSamplerate /* i : new samplerate to operate */ @@ -11960,10 +11953,6 @@ ivas_error cldfb_save_memory_ivas( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ); -void deleteCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -); - /*! r: flag indicating a valid bitrate */ Word16 is_EVS_bitrate( const Word32 ivas_total_brate, /* i : EVS total bitrate */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 3865cd61c..4e0cfda18 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1447,13 +1447,13 @@ ivas_error init_decoder_ivas_fx( IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -1465,7 +1465,7 @@ ivas_error init_decoder_ivas_fx( } /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 25c0bea42..111c0be0e 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -602,7 +602,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -622,7 +622,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b11669460..236eaad54 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2264,7 +2264,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -2276,7 +2276,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a6be10c08..cc3980b12 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -438,7 +438,7 @@ ivas_error create_sce_dec( IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 3f39bd9ac..c8dde0837 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -601,7 +601,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -610,7 +610,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 09b683a16..34eef94ed 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -205,7 +205,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -214,7 +214,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -752,7 +752,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbAna == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -761,7 +761,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -1100,7 +1100,7 @@ ivas_error stereo_memory_dec_fx( { IF( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */ { - IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 615ca1b33..f0338b461 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1695,7 +1695,7 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) { return error; } @@ -1809,7 +1809,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 6960629c8..9fdebed7a 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -152,7 +152,7 @@ ivas_error ivas_masa_enc_open_fx( FOR( i = 0; i < hMasa->data.num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -260,7 +260,7 @@ void ivas_masa_enc_close_fx( FOR( i = 0; i < ( *hMasa )->data.num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); } IF( ( *hMasa )->data.hOmasaData != NULL ) diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 5d79265f4..50fb49355 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -124,7 +124,7 @@ ivas_error ivas_omasa_enc_open_fx( move16(); FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_enc( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ) != IVAS_ERR_OK ) { return error; } @@ -227,7 +227,7 @@ void ivas_omasa_enc_close_fx( FOR( i = 0; i < ( *hOMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 2fe8b6c84..6c7a1e68d 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -366,8 +366,8 @@ ivas_error stereo_memory_enc_fx( IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) ) { /* Deallocate MDCT CNG structures */ - deleteCldfb_ivas( &hCPE->hCoreCoder[0]->cldfbAnaEnc ); - deleteCldfb_ivas( &hCPE->hCoreCoder[1]->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &hCPE->hCoreCoder[0]->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &hCPE->hCoreCoder[1]->cldfbAnaEnc ); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { @@ -417,7 +417,7 @@ ivas_error stereo_memory_enc_fx( /* allocate CLDFB for primary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -433,7 +433,7 @@ ivas_error stereo_memory_enc_fx( IF( st->cldfbSynTd == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -587,7 +587,7 @@ ivas_error stereo_memory_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = hCPE->hCoreCoder[i]; - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index d2ff2c0c2..de9bc09b5 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -263,7 +263,7 @@ ivas_error stereo_set_tdm_fx( /* deallocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc != NULL ) { - deleteCldfb_ivas( &st->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); } /* deallocate BWEs for secondary channel */ @@ -275,7 +275,7 @@ ivas_error stereo_set_tdm_fx( st->hBWE_TD = NULL; } - deleteCldfb_ivas( &st->cldfbSynTd ); + deleteCldfb_ivas_fx( &st->cldfbSynTd ); IF( st->hBWE_FD != NULL ) { @@ -309,7 +309,7 @@ ivas_error stereo_set_tdm_fx( /* allocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -322,7 +322,7 @@ ivas_error stereo_set_tdm_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 93a100e17..5dd3f8384 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -107,7 +107,7 @@ ivas_error ivas_dirac_ana_open_fx( move16(); FOR( i = 0; i < hDirAC->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 430fab2c7..3aa9f62a9 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -499,7 +499,7 @@ ivas_error masaPrerendOpen_fx( move16(); FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 8b56b6855..d56ba2685 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -224,7 +224,7 @@ ivas_error ivas_mcmasa_ana_open( move16(); FOR( i = 0; i < hMcMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 2c28b32bd..1d849a90f 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -133,7 +133,7 @@ ivas_error ivas_omasa_ana_open( hOMasa->num_Cldfb_instances = numAnalysisChannels; FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 2c81911a1..041f278f1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8187,7 +8187,7 @@ static ivas_error initMasaExtRenderer( { FOR( i = 0; i < hMasaExtRend->nchan_input; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -8195,7 +8195,7 @@ static ivas_error initMasaExtRenderer( FOR( i = 0; i < hMasaExtRend->nchan_output; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 0c4a9f1957c11cb72f48d19ccabeb118dec895e5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 11:42:57 +0530 Subject: [PATCH 306/329] Address review comments --- lib_com/cldfb.c | 10 ++++++---- lib_com/cnst.h | 6 +----- lib_com/prot_fx.h | 2 +- lib_dec/init_dec_fx.c | 6 +++--- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 4 ++-- lib_dec/ivas_init_dec.c | 4 ++-- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 ++-- lib_dec/ivas_stereo_switching_dec_fx.c | 10 +++++----- lib_enc/init_enc_fx.c | 4 ++-- lib_enc/ivas_masa_enc_fx.c | 2 +- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_stereo_switching_enc_fx.c | 6 +++--- lib_enc/ivas_stereo_td_enc_fx.c | 4 ++-- lib_rend/ivas_dirac_ana_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/lib_rend.c | 4 ++-- 19 files changed, 38 insertions(+), 40 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 7fc8026b5..246a8a8e8 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1365,7 +1365,7 @@ ivas_error openCldfb_ivas_fx( CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - CODE_TYPE code_type ) + const Word16 enc_dec ) /* i : encoder/decoder flag */ { HANDLE_CLDFB_FILTER_BANK hs; Word16 buf_len; @@ -1379,14 +1379,17 @@ ivas_error openCldfb_ivas_fx( move32(); hs->prototype = prototype; move32(); - IF( code_type == IVAS_ENC ) + IF( enc_dec == ENC ) { configureCldfb_ivas_enc_fx( hs, sampling_rate ); + hs->Q_cldfb_state = 0; } ELSE { configureCldfb_ivas_fx( hs, sampling_rate ); + hs->Q_cldfb_state = Q11; } + move16(); hs->memory32 = NULL; hs->FilterStates = NULL; hs->memory_length = 0; @@ -1412,8 +1415,7 @@ ivas_error openCldfb_ivas_fx( hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); - hs->Q_cldfb_state = Q11; - move16(); + *h_cldfb = hs; move16(); diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 3c014325e..7c93498af 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -803,11 +803,7 @@ typedef enum CLDFB_ANALYSIS, CLDFB_SYNTHESIS } CLDFB_TYPE; -typedef enum -{ - IVAS_ENC, - IVAS_DEC_REND -} CODE_TYPE; + typedef enum { CLDFB_PROTOTYPE_1_25MS, diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c1aefbe36..9fe14b5bd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9804,7 +9804,7 @@ ivas_error openCldfb_ivas_fx( CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - CODE_TYPE code_type ); + const Word16 enc_dec ); /* i : encoder/decoder flag */ Word32 rand_gauss_fx( Word32 *x, diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 4e0cfda18..bd8a2cbd3 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1447,13 +1447,13 @@ ivas_error init_decoder_ivas_fx( IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -1465,7 +1465,7 @@ ivas_error init_decoder_ivas_fx( } /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 111c0be0e..8333f146f 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -602,7 +602,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -622,7 +622,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 236eaad54..1ab797ded 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2264,7 +2264,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -2276,7 +2276,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index cc3980b12..12549f49d 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -438,7 +438,7 @@ ivas_error create_sce_dec( IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index c8dde0837..5b1378a89 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -601,7 +601,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -610,7 +610,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 34eef94ed..c70e606ac 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -205,7 +205,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -214,7 +214,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -752,7 +752,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbAna == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -761,7 +761,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -1100,7 +1100,7 @@ ivas_error stereo_memory_dec_fx( { IF( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */ { - IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index f0338b461..cd5db5377 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1695,7 +1695,7 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } @@ -1809,7 +1809,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 9fdebed7a..da1f836df 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -152,7 +152,7 @@ ivas_error ivas_masa_enc_open_fx( FOR( i = 0; i < hMasa->data.num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 50fb49355..b5258712b 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -124,7 +124,7 @@ ivas_error ivas_omasa_enc_open_fx( move16(); FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, ENC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 6c7a1e68d..0a526561a 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -417,7 +417,7 @@ ivas_error stereo_memory_enc_fx( /* allocate CLDFB for primary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -433,7 +433,7 @@ ivas_error stereo_memory_enc_fx( IF( st->cldfbSynTd == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -587,7 +587,7 @@ ivas_error stereo_memory_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = hCPE->hCoreCoder[i]; - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index de9bc09b5..1544aab76 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -309,7 +309,7 @@ ivas_error stereo_set_tdm_fx( /* allocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -322,7 +322,7 @@ ivas_error stereo_set_tdm_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 5dd3f8384..1a5013059 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -107,7 +107,7 @@ ivas_error ivas_dirac_ana_open_fx( move16(); FOR( i = 0; i < hDirAC->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 3aa9f62a9..c74477365 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -499,7 +499,7 @@ ivas_error masaPrerendOpen_fx( move16(); FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index d56ba2685..e17b2f9f6 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -224,7 +224,7 @@ ivas_error ivas_mcmasa_ana_open( move16(); FOR( i = 0; i < hMcMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 1d849a90f..5e175fae5 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -133,7 +133,7 @@ ivas_error ivas_omasa_ana_open( hOMasa->num_Cldfb_instances = numAnalysisChannels; FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 041f278f1..129f72388 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8187,7 +8187,7 @@ static ivas_error initMasaExtRenderer( { FOR( i = 0; i < hMasaExtRend->nchan_input; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -8195,7 +8195,7 @@ static ivas_error initMasaExtRenderer( FOR( i = 0; i < hMasaExtRend->nchan_output; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 3a76357964d1df534da0093c5c51d0cd9f9db74e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 11:49:56 +0530 Subject: [PATCH 307/329] Fix for 3GPP issue 1361: Assert in BASOP decoder function ivas_dirac_dec_render_sf_fx for LTV MASA bitstream Link #1361 --- lib_dec/ivas_cpe_dec_fx.c | 4 ---- lib_dec/ivas_dirac_dec_fx.c | 37 ++++++++++++++++++++------------ lib_dec/ivas_stereo_dft_dec_fx.c | 3 ++- lib_rend/ivas_dirac_rend_fx.c | 2 ++ 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 6a6294377..9e934cc88 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -352,10 +352,6 @@ ivas_error ivas_cpe_dec_fx( { sts[0]->total_brate = hCPE->element_brate; /* Only mono downmix was transmitted in this case */ move32(); -#ifdef MSAN_FIX - hCPE->hStereoDft->frame_sid_nodata = 0; - move16(); -#endif } ELSE { diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index d8288e561..422622552 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2204,13 +2204,15 @@ void ivas_dirac_dec_render_sf_fx( Word32 Cldfb_RealBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 cldfb_buf_q; - Word16 offset, buff_len; + Word16 offset = 0, buff_len = 0; + move16(); + move16(); Word16 q_cldfb, q_temp_cldfb = 0; move16(); Word16 proto_length = 0; move16(); - Word16 q_proto_direct_buffer[CLDFB_SLOTS_PER_SUBFRAME]; - Word16 q_proto_diffuse_buffer[CLDFB_SLOTS_PER_SUBFRAME]; + Word16 q_proto_direct_buffer[CLDFB_SLOTS_PER_SUBFRAME + 1]; + Word16 q_proto_diffuse_buffer[CLDFB_SLOTS_PER_SUBFRAME + 1]; Word16 size, size_ho; DIRAC_DEC_STACK_MEM DirAC_mem; @@ -2258,8 +2260,8 @@ void ivas_dirac_dec_render_sf_fx( } q_cldfb = Q11; move16(); - set16_fx( q_proto_direct_buffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); - set16_fx( q_proto_diffuse_buffer, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); + set16_fx( q_proto_direct_buffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME + 1 ); + set16_fx( q_proto_diffuse_buffer, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME + 1 ); set_zero_fx( surCohRatio_fx, CLDFB_NO_CHANNELS_MAX ); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) @@ -3252,22 +3254,21 @@ void ivas_dirac_dec_render_sf_fx( } } - minimum_s( q_proto_direct_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); + minimum_s( q_proto_direct_buffer, add( hSpatParamRendCom->subframe_nbslots[subframe_idx], 1 ), &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - minimum_s( q_proto_diffuse_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ); + minimum_s( q_proto_diffuse_buffer, add( hSpatParamRendCom->subframe_nbslots[subframe_idx], 1 ), &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ); } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ); - buff_len = i_mult( 2, i_mult( nchan_transport, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q - offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); buff_len = i_mult( 2, i_mult( hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); // proto_diffuse_buffer_f_q + offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ); + buff_len = i_mult( 2, i_mult( nchan_transport, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { @@ -3307,10 +3308,18 @@ void ivas_dirac_dec_render_sf_fx( BREAK; } } - q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; - move16(); } - + test(); + IF( EQ_16( slot_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx] ) && sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, add( offset, buff_len ) ) > 0 ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + add( offset, buff_len ), sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, add( offset, buff_len ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q + offset = i_mult( i_mult( sub( slot_idx, 1 ), 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + buff_len = i_mult( 2, i_mult( hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands ) ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) && sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, add( offset, buff_len ) ) > 0 ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + add( offset, buff_len ), sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, add( offset, buff_len ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); // proto_direct_buffer_f_q + } + } ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); size = i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 1c18ffacb..3d9e58ad1 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -258,7 +258,8 @@ void stereo_dft_dec_reset_fx( move16(); hStereoDft->ipd_xfade_prev_fx = 0; move32(); - + hStereoDft->frame_sid_nodata = 0; + move16(); #ifdef MSAN_FIX FOR( b = 0; b < 2 * IVAS_MAX_NUM_BANDS; b++ ) { diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index e254ed6dd..35fedfc81 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -871,6 +871,8 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = imult1616( imult1616( 2 * MAX_PARAM_SPATIAL_SUBFRAMES, num_protos_dir ), num_freq_bands ); move16(); + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q = Q31; + move16(); IF( hDirACRend->proto_signal_decorr_on ) { -- GitLab From 4d1e1c0534ed71289e06ca2e88d94e83e2a4dd82 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 11:52:47 +0530 Subject: [PATCH 308/329] Fix for 3GPP issue 1373: Decoder crash for stereo at 80kbps JBM decoding to Mono in get_scaling_quality_fx() Link #1373 --- lib_dec/jbm_pcmdsp_apa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index ac6a28b86..fc793dff0 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -900,7 +900,7 @@ UWord8 apa_exec_ivas_fx( UWord32 statsResetThreshold, statsResetShift; Word16 Q_a_out; - Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 ); + Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 - Q1 ); statsResetThreshold = 1637; move32(); statsResetShift = 2; -- GitLab From 29426491cb92052cc83785b30729f3e30e83c66e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 12:52:44 +0530 Subject: [PATCH 309/329] USAN fix for decoder --- lib_dec/ivas_lfe_plc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 210c266eb..8ed450435 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -387,7 +387,7 @@ static Word16 lfeplc_lev_dur_fx( s = W_extract_h( W_shl( s_fx, exp1 ) ); s_q_fx = sub( add( s_q_fx, exp1 ), 32 ); - rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( -s, err_fx, &temp_q2 ), 1 ); + rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate(s), err_fx, &temp_q2 ), 1 ); move32(); rc_q_fx[i - 1] = sub( add( sub( s_q_fx, err_q_fx ), sub( 31, temp_q2 ) ), 1 ); move16(); -- GitLab From 2e871041f0a632bd97de676a98e07331e2961624 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 12:55:14 +0530 Subject: [PATCH 310/329] Clang formatting changes --- lib_dec/ivas_lfe_plc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 8ed450435..d98603d2a 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -387,7 +387,7 @@ static Word16 lfeplc_lev_dur_fx( s = W_extract_h( W_shl( s_fx, exp1 ) ); s_q_fx = sub( add( s_q_fx, exp1 ), 32 ); - rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate(s), err_fx, &temp_q2 ), 1 ); + rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate( s ), err_fx, &temp_q2 ), 1 ); move32(); rc_q_fx[i - 1] = sub( add( sub( s_q_fx, err_q_fx ), sub( 31, temp_q2 ) ), 1 ); move16(); -- GitLab From 501aeb9eeb59fea7e379084771af936b51aabea8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Mar 2025 08:55:12 +0530 Subject: [PATCH 311/329] Cleanup of ivas_prot_rend.h, bug fixes and instrumentation changes --- Workspace_msvc/lib_rend.vcxproj | 2 +- Workspace_msvc/lib_rend.vcxproj.filters | 6 +- lib_com/ivas_prot.h | 4065 ----------------- lib_dec/ivas_binRenderer_internal_fx.c | 2 +- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_ism_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 2 +- lib_dec/ivas_ism_renderer_fx.c | 2 +- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_mc_param_dec_fx.c | 8 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 +- lib_dec/ivas_mcmasa_dec_fx.c | 2 +- lib_dec/ivas_mct_core_dec_fx.c | 14 +- lib_dec/ivas_mct_dec_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_objectRenderer_internal_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/ivas_osba_dec_fx.c | 2 +- lib_dec/ivas_out_setup_conversion_fx.c | 2 +- lib_dec/ivas_sba_dec_fx.c | 2 +- lib_dec/ivas_sba_rendering_internal_fx.c | 4 +- lib_dec/ivas_sns_dec_fx.c | 2 +- lib_dec/ivas_spar_decoder_fx.c | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_enc/cod_tcx_fx.c | 2 +- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- lib_enc/ivas_mdct_core_enc_fx.c | 10 +- lib_enc/ivas_sns_enc_fx.c | 2 +- lib_enc/swb_bwe_enc_fx.c | 9 +- lib_rend/ivas_allrad_dec_fx.c | 2 +- lib_rend/ivas_crend_fx.c | 2 +- lib_rend/ivas_dirac_ana_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 2 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 2 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 +- lib_rend/ivas_dirac_rend_fx.c | 2 +- lib_rend/ivas_efap_fx.c | 2 +- lib_rend/ivas_hrtf_fx.c | 2 +- lib_rend/ivas_limiter_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 2 +- lib_rend/ivas_objectRenderer_mix_fx.c | 2 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 2 +- lib_rend/ivas_objectRenderer_sources_fx.c | 2 +- lib_rend/ivas_objectRenderer_vec_fx.c | 43 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/ivas_orient_trk_fx.c | 2 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_output_init_fx.c | 2 +- .../{ivas_prot_rend.h => ivas_prot_rend_fx.h} | 571 +-- lib_rend/ivas_reflections_fx.c | 2 +- lib_rend/ivas_render_config_fx.c | 2 +- lib_rend/ivas_reverb_delay_line_fx.c | 2 +- lib_rend/ivas_reverb_fft_filter_fx.c | 2 +- lib_rend/ivas_reverb_filter_design_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 2 +- lib_rend/ivas_reverb_iir_filter_fx.c | 2 +- lib_rend/ivas_reverb_utils_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/ivas_sba_rendering_fx.c | 2 +- lib_rend/ivas_shoebox_fx.c | 2 +- lib_rend/ivas_td_decorr_fx.c | 2 +- lib_rend/ivas_vbap_fx.c | 2 +- lib_rend/lib_rend.c | 2 +- lib_util/hrtf_file_reader.c | 2 +- 70 files changed, 111 insertions(+), 4741 deletions(-) delete mode 100644 lib_com/ivas_prot.h rename lib_rend/{ivas_prot_rend.h => ivas_prot_rend_fx.h} (69%) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 1ffab139a..e47858ae3 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -179,7 +179,7 @@ - + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 47b4fee01..5c4a49011 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -125,9 +125,6 @@ - - rend_h - rend_h @@ -143,6 +140,9 @@ rend_h + + rend_h + diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h deleted file mode 100644 index 34f11c01f..000000000 --- a/lib_com/ivas_prot.h +++ /dev/null @@ -1,4065 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#ifndef IVAS_PROT_H -#define IVAS_PROT_H - -#include -#include "options.h" -#include -#include "typedef.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "stat_com.h" -#include "ivas_stat_enc.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_com.h" -#include "ivas_error_utils.h" - - -/* clang-format off */ - -/*----------------------------------------------------------------------------------* - * General IVAS prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_enc( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - const int16_t *data, /* i : input signal */ - const int16_t n_samples /* i : number of input samples */ -); - -void stereo_dmx_evs_enc( - STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ - const int16_t n_samples, /* i : number of input samples */ - const bool is_binaural /* i : indication that input is binaural audio */ -); - -/*! r: number of channels to be analysed */ - -void copy_encoder_config_ivas_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ -); - - - -ivas_error create_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - -ivas_error create_cpe_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - -ivas_error create_mct_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void destroy_cpe_enc( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void ivas_mct_enc_close_fx( - MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ -); - -ivas_error ivas_corecoder_enc_reconfig( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ - const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ -); - -ivas_error ivas_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const float data_f[], /* i : input signal for single channel */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - - -ivas_error ivas_cpe_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 cpe_id, /* i : CPE # identifier */ - float data_f_ch0[], /* i : input signal for channel 0 */ - float data_f_ch1[], /* i : input signal for channel 1 */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word16 nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_mct_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[MCT_MAX_CHANNELS], /* i : input signal buffers */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error pre_proc_front_ivas( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int32_t element_brate, /* i : SCE/CPE element bitrate */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int16_t input_frame, /* i : frame length */ - const int16_t n, /* i : channel number */ - float old_inp_12k8[], /* o : buffer of old input signal */ - float old_inp_16k[], /* o : buffer of old input signal @16kHz */ - float *ener, /* o : residual energy from Levinson-Durbin */ - float *relE, /* o : frame relative energy */ - float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* o : LP prediction errors */ - float lsp_new[M], /* o : LSPs at the end of the frame */ - float lsp_mid[M], /* o : LSPs in the middle of the frame */ - int16_t *vad_hover_flag, /* o : VAD hangover flag */ - int16_t *attack_flag, /* o : flag signaling attack */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - float old_wsp[], /* o : weighted input signal buffer */ - float pitch_fr[NB_SUBFR], /* o : fractional pitch values */ - float voicing_fr[NB_SUBFR], /* o : fractional pitch gains */ - int16_t *loc_harm, /* o : harmonicity flag */ - float *cor_map_sum, /* o : speech/music clasif. parameter */ - int16_t *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */ - float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */ - float fft_buff[2 * L_FFT], /* o : FFT buffer */ - const float tdm_A_PCh[M + 1], /* i : unq. LP coeff. of primary channel */ - const float tdm_lsp_new_PCh[M], /* i : unq. LSPs of primary channel */ - const float currFlatness, /* i : flatness parameter */ - const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */ - float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */ - const float Etot_LR[], /* i : total energy Left & Right channel */ - float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ - const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ - const int16_t force_front_vad, /* i : flag to force VAD decision */ - const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); - -ivas_error pre_proc_front_ivas_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 n, /* i : channel number Q0*/ - Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 *relE_fx, /* o : frame relative energy Q8*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, - Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ - Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ - Word16 *attack_flag, /* o : flag signaling attack Q0*/ - Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ - Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ - Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ - Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ - Word16 *q_old_wsp, - Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ - Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ - Word16 *loc_harm, /* o : harmonicity flag Q0*/ - Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ - Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 *enerBuffer_fx_exp, /* o : energy buffer */ - Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ - Word16 *fft_buff_fx_q, /* o : FFT buffer */ - const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ - const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ - const Word16 currFlatness_fx, /* i : flatness parameter Q7*/ - const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ - Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ - Word16 fr_bands_LR_fx_q[CPE_CHANNELS], - const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ - Word16 lf_E_LR_fx_q, - const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ - Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ - Word16 band_energies_LR_fx_q, - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ - const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ - const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ -#ifdef NONBE_1211_DTX_BR_SWITCHING - const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ -#endif - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ - Word16 *Q_new -#ifdef DEBUG_MODE_INFO - , - const Word16 ch_idx -#endif -); -ivas_error pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word32 last_element_brate, /* i : last element bitrate Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ - Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ - Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ - Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, /* i : LP prediction errors */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ - Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ - Word16 e_old_wsp, - const Word16 loc_harm, /* i : harmonicity flag Q0*/ - const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ - Word16 e_enerBuffer, - Word16 fft_buff_fx[2 * L_FFT], /* Qx */ - Word16 cor_map_sum_fx, /* Q8 */ - Word16 *Q_new -); -/*! r: number of clipped samples */ -void ivas_initialize_handles_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_init_encoder( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_destroy_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_initialize_MD_bstr_enc_fx( - BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */ - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_destroy_MD_bstr_enc_fx( - BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */ -); - -ivas_error ivas_init_decoder_front( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_init_decoder( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_output_buff_dec( - float *p_output_f[], /* i/o: output audio buffers */ - const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/ - const int16_t nchan_out_buff /* i : number of output channels */ -); -#endif - -ivas_error stereo_dmx_evs_init_encoder( - STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS, /* o : Stereo downmix for EVS encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void stereo_dmx_evs_close_encoder( - STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ -); - -ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - int16_t *data /* o : output synthesis signal */ -); - - -ivas_error mct_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t b_nchan_change /* i : flag indicating different channel count */ -); - - -void ivas_mct_dec_close( - MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ -); - -ivas_error ivas_corecoder_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ -); - -ivas_error ivas_hp20_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame*/ -); - -ivas_error ivas_sce_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - float *output[1], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_cpe_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ - float *output[CPE_CHANNELS], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_mct_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -/*! r: number of channels to be synthesised */ - -void copy_decoder_config( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - Decoder_State *st /* o : decoder state structure */ -); - -void destroy_core_dec( - DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ -); - - -void ivas_initialize_handles_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_core_enc_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ - Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ - Word16 Q_new[], - Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 epsP_fx_q[], /* i : LP prediction errors */ - Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/ - Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/ - Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/ - Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/ - Word16 *q_re_im_buf, - Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/ - Word16 e_old_wsp[], - const Word16 loc_harm[], /* i : harmonicity flag Q0*/ - const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ - const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 enerBuffer_fx_exp[], /* o : energy buffer */ - Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ - const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ - const Word16 ivas_format, /* i : IVAS format Q0*/ - const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ -); - - - -void decod_gen_2sbfr( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const float *Aq, /* i : LP filter coefficient */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : pitch values for primary channel */ -); - -void synchro_synthesis( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void synchro_synthesis_fixed( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void stereo_tcx_init_enc( - Encoder_State *st /* i/o: encoder state structure */ -); - - - - -void stereo_tcx_init_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t last_element_mode /* i : element mode of previous frame */ -); - -/*! r: S/M decision (0 = speech or noise, 1 = unclear, 2 = music) */ -int16_t ivas_smc_gmm( - Encoder_State *st, /* i/o: encoder state structure */ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const float Etot, /* i : total frame energy */ - const float lsp_new[M], /* i : LSPs in current frame */ - const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */ - const float epsP[M + 1], /* i : LP prediciton error */ - const float PS[], /* i : energy spectrum */ - const float non_sta, /* i : unbound non-stationarity */ - const float relE, /* i : relative frame energy */ - int16_t *high_lpn_flag, /* i/o: sp/mus LPN flag */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); - -void ivas_smc_mode_selection( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t element_brate, /* i : element bitrate */ - int16_t smc_dec, /* i : raw decision of the 1st stage classifier */ - const float relE, /* i : relative frame energy */ - const float Etot, /* i : total frame energy */ - int16_t *attack_flag, /* i/o: attack flag (GSC or TC) */ - const float *inp, /* i : input signal */ - const float S_map[], /* i : short-term correlation map */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); - -/*! r: S/M decision (0=speech or noise,1=unclear,2=music) */ -int16_t ivas_acelp_tcx20_switching( - Encoder_State *st, /* i/o: encoder state structure */ - const float *inp, /* i : new input signal */ - const float *wsp, /* i : input weighted signal */ - const float non_staX, /* i : unbound non-stationarity for sp/mu clas */ - const float *pitch_fr, /* i : fraction pitch values */ - const float *voicing_fr, /* i : fractional voicing values */ - const float currFlatness, /* i : flatness */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - const float stab_fac, /* i : LP filter stability */ - float *res_cod_SNR_M, - const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */ -); - - - -void ivas_decision_matrix_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *sharpFlag, /* o : formant sharpening flag */ - int16_t *core_switching_flag, /* o : ACELP->HQ switching frame flag */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t nchan_out /* i : Number of output channels */ -); - -void set_bw_stereo( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structures */ -); - -/*! r: flag indicating whether the coded BW has changed */ -int16_t set_bw_mct( - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ - const int16_t nCPE /* i : number of CPEs */ -); -void dec_acelp_fast( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t cdk_index, /* i : codebook index */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void set_transient_stereo( - CPE_ENC_HANDLE hCPE, /* i : CPE structure */ - float currFlatness[] /* i/o: current flatness */ -); - -/*! r: preliminary flag to force ACELP */ -int16_t transient_analysis( - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float cor_map_LT[], /* i : LT correlation map */ - const float multi_harm_limit /* i : multi harminic threshold */ -); - -void ivas_post_proc( - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float synth[], /* i/o: output synthesis signal */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void ivas_renderer_select( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_mc_enc_config_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_mc_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t idx, /* i : LS config. index */ - uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - -/*! r: MC format mode (MCT, McMASA, ParamMC) */ -MC_MODE ivas_mc_mode_select( - const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ - const int32_t total_brate /* i : IVAS total bitrate */ -); - -/*! r: number of loudspeaker channels */ -int16_t ivas_mc_ls_setup_get_num_channels( - const MC_LS_SETUP mc_ls_setup /* i : loudspeaker setup (CICP) */ -); - -/*! r: output configuration*/ -AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config( - const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ -); - -/*! r: multi channel loudspeaker setup */ -MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( - const AUDIO_CONFIG output_config /* i : output audio configuration */ -); - -void smooth_dft2td_transition( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ - const int16_t output_frame /* i : output frame length */ -); - - -/*! r: flag indicating a valid bitrate */ -Word16 is_IVAS_bitrate_fx( - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -int16_t is_DTXrate( - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); - - -void TonalMdctConceal_create_concealment_noise_ivas( - float concealment_noise[L_FRAME48k], - CPE_DEC_HANDLE hCPE, - const int16_t L_frameTCX, - const int16_t L_frame, - const int16_t idchan, - const int16_t subframe_idx, - const int16_t core, - const float crossfade_gain, - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode -); - -void TonalMdctConceal_whiten_noise_shape_ivas( - Decoder_State *st, - const int16_t L_frame, - const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE -); - -void dtx_read_padding_bits( - DEC_CORE_HANDLE st, - const int16_t num_bits -); - - - -/*----------------------------------------------------------------------------------* - * JBM prototypes - *----------------------------------------------------------------------------------*/ - - - -ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ -); - -void ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ -); - -ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ -); - -void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ -); - - - -int16_t ivas_jbm_dec_get_num_tc_channels( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -void ivas_jbm_dec_copy_tc_no_tsm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *tc[], /* i : transport channels */ - const int16_t output_frame /* i : output frame size */ -); - - -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -/*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity_flt( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ -); - -ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : number of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ -); - -ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ -); - -void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ -); - -void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_jbm_dec_metadata_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_jbm_masa_sf_to_sf_map( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -/*----------------------------------------------------------------------------------* - * ISM prototypes - *----------------------------------------------------------------------------------*/ - -void bitbudget_to_brate( - const Word16 x[], /* i : bitbudgets Q0 */ - Word32 y[], /* o : bitrates Q0 */ - const Word16 N /* i : number of entries to be converted */ -); - -void ivas_ism_reset_metadata( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ -); - -void ivas_ism_reset_metadata_enc( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ -); -void ivas_ism_reset_metadata_API( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ -); - -/*! r: index of the winning codeword */ -Word16 ism_quant_meta_fx( - const Word32 val, /* i : scalar value to quantize Q22 */ - Word32 *valQ, /* o : quantized value Q22 */ - const Word32 borders_fx[], /* i : level borders Q22 */ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */ - const Word16 cbsize /* i : codebook size */ -); - -ivas_error ivas_ism_metadata_enc_create_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t n_ISms, /* i : number of objects */ - int32_t element_brate_tmp[] /* o : element bitrate per object */ -); - -ivas_error ivas_ism_metadata_dec_create( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_ISms, /* i : number of objects */ - int32_t element_brate_tmp[] /* o : element bitrate per object */ -); - -ivas_error ivas_ism_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[], /* i : input signal [channels][samples] */ - const int16_t input_frame, /* i : input frame length per channel */ - int16_t *nb_bits_metadata, /* i : number of metadata bits */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ -); - -ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_ism, /* i : number of ISM channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ - const int16_t bfi, /* i : bfi flag */ - int16_t nb_bits_metadata[], /* o : number of metadata bits */ - ISM_MODE ism_mode, /* i : ISM mode */ - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ - const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ - int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ - int16_t *ism_extmeta_cnt, /* i/o: Number of change frames observed */ - DEC_CORE_HANDLE st0 /* i : core-coder handle */ -); - - -/*----------------------------------------------------------------------------------* - * Parametric ISM prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: ISM format mode */ - -ivas_error ivas_param_ism_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_param_ism_enc_close_fx( - PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ - const int32_t input_Fs /* i : input sampling_rate */ -); - -void ivas_ism_metadata_close( - ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ - const int16_t first_idx /* i : index of first handle to deallocate */ -); - - -ivas_error ivas_ism_enc_config( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - - - - -void ivas_param_ism_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -); - -void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - - -void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_param_ism_params_to_masa_param_mapping( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -/*----------------------------------------------------------------------------------* - * ISM DTX prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ism_dtx_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -/*! r: indication of DTX frame */ -int16_t ivas_ism_dtx_enc( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - int16_t vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - int16_t md_diff_flag[], /* o : metadata differential flag */ - int16_t *sid_flag /* o : indication of SID frame */ -); - -void ivas_ism_dtx_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t *nb_bits_metadata /* o : number of metadata bits */ -); - -void ivas_ism_metadata_sid_enc_fx( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - const int16_t flag_noisy_speech, /* i : noisy speech flag */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - const ISM_MODE ism_mode, /* i : ISM mode */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t sid_flag, /* i : indication of SID frame */ - const int16_t md_diff_flag[], /* i : metadata differental flag */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t nb_bits_metadata[] /* o : number of metadata bits */ -); - -void ivas_ism_metadata_sid_dec( - SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t bfi, /* i : bfi flag */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - const ISM_MODE ism_mode, /* i : ISM mode */ - int16_t *flag_noisy_speech, /* o : noisy speech flag */ - int16_t *sce_id_dtx, /* o : SCE DTX ID */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - int16_t nb_bits_metadata[] /* o : number of metadata bits */ -); - - -void ivas_param_ism_compute_noisy_speech_flag_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - - -void update_last_metadata( - const int16_t nchan_ism, /* i : number of objects */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t updt_flag[] /* i : last metadata update flag */ -); - -void ivas_ism_dtx_limit_noise_energy_for_near_silence( - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ - const int16_t sce_id_dtx, /* i : SCE DTX ID */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -/*----------------------------------------------------------------------------------* - * DFT Stereo prototypes - *----------------------------------------------------------------------------------*/ - - -void stereo_dft_enc_analyze( - Encoder_State **sts, /* i/o: encoder state structure */ - const int16_t n_channels, /* i : number of input channels */ - const int16_t input_frame, /* i : input frame length */ - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: encoder MDCT stereo handle */ - float DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */ - float *input_mem[CPE_CHANNELS] /* i/o: input buffer memory */ -); - -float stereo_dft_enc_synthesize( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - float *output, /* o : output synthesis */ - const int16_t chan, /* i : channel number */ - const int32_t input_Fs, /* i : input sampling rate */ - const int32_t output_sampling_rate, /* i : output sampling rate */ - const int16_t L_frame /* i : frame length at internal Fs */ -); - - - - -void stereo_dtf_cng( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ - const int16_t output_frame /* i : output frame size */ -); - -void stereo_dft_cng_side_gain( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo encoder handle */ - STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int32_t core_brate, /* i : core bitrate */ - const int32_t last_core_brate, /* i : last core bitrate */ - const int16_t bwidth /* i : audio band-width */ -); - - -void stereo_dft_dequantize_itd( - int16_t *ind, - float *out, - const int32_t output_Fs -); - - - -void stereo_dft_dec_sid_coh( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nbands, /* i : number of DFT stereo bands */ - float *coh, /* i/o: coherence */ - int16_t *nb_bits /* i/o: number of bits read */ -); - -ivas_error stereo_dft_dec_create( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ - const int32_t element_brate, /* i : element bitrate */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -void stereo_dft_dec_reset( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */ -); - -void stereo_dft_dec_update( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void stereo_dft_dec_destroy( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */ -); - -void stereo_dft_dec_analyze( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const float *input, /* i : input signal */ - float out_DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t chan, /* i : channel number */ - const int16_t input_frame, /* i : input frame size */ - const int16_t output_frame, /* i : output frame size */ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : signal type to analyze */ - const int16_t k_offset, /* i : offset of DFT */ - const int16_t delay /* i : delay in samples for input signal */ -); - -void stereo_dft_dec_synthesize( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i : DFT buffers */ - const int16_t chan, /* i : channel number */ - float output[L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length */ -); - - -void stereo_dft_res_ecu( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal */ - float *const DFT_PRED_RES, /* i/o: residual prediction signal */ - const int16_t k, /* i : Subframe index */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t prev_bfi, /* i : Previous BFI */ - const float dmx_nrg, /* i : Down-mix energy */ - int16_t *num_plocs, /* i/o: Number of peak locations */ - int16_t *plocs, /* i/o: Peak locations (bin) */ - float *plocsi, /* i/o: Peak locations (fractional) */ - float *input_mem /* o : Residual DFT buffer input mem */ -); - -void stereo_dft_res_subst_spec( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal */ - const float *const DFT_PRED_RES, /* i : residual prediction signal */ - const int16_t time_offs, /* i : Time offset for phase adjustm. */ - const int16_t L_res, /* i : bandwidth of residual signal */ - const int16_t L_ana, /* i : Length of FFT analysis */ - const int16_t k, /* i : Subframe index */ - int16_t *num_plocs, /* i/o: Number of peak locations */ - int16_t *plocs, /* i/o: Peak locations (bin) */ - float *plocsi, /* i/o: Peak locations (fractional) */ - const int16_t analysis_flag /* i : Flag for running peak analysis */ -); - -void stereo_dft_res_ecu_burst_att( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal /att. residual */ - const float dmx_nrg, /* i : dmx energy of current frame */ - const int16_t L_res, /* i : Bandwidth of residual */ - const int16_t L_ana /* i : Length of FFT analysis */ -); - -/*! r: total energy of downmix with maximum swb bandwidth max */ -float stereo_dft_dmx_swb_nrg( - const float *dmx_k0, /* i : first subframe spectrum */ - const float *dmx_k1, /* i : second subframe spectrum */ - const int16_t frame_length /* i : frame lanegth */ -); - -int16_t stereo_dft_sg_recovery( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: Decoder DFT stereo handle */ -); - -void stereo_dft_dec_res( - CPE_DEC_HANDLE hCPE, /* i/o: decoder CPE handle */ - float res_buf[STEREO_DFT_N_8k], /* i : residual buffer */ - float *output /* o : output frame */ -); - -/*! r: Decision to enable or disable BPF on DFT stereo residual */ - -void bpf_pitch_coherence( - Decoder_State *st, /* i/o: decoder state structure */ - const float pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ -); - -void stereo_dft_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t element_brate, /* i : element bitrate */ - int32_t *total_brate, /* o : total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t bwidth, /* i : bandwidth */ - const int16_t output_frame, /* i : output frame length */ - float res_buf[STEREO_DFT_N_8k], /* o : residual buffer */ - int16_t *nb_bits, /* o : number of bits read */ - float *coh, /* i/o: Coherence */ - const int16_t ivas_format /* i : ivas format */ -); - -void stereo_dft_dec_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t prev_sid_nodata, /* i : Previous SID/No data indicator */ - const int16_t active_frame_counter, /* i : Active frame counter */ - const int32_t element_brate /* i : Element bitrate */ -); - -void stereo_dft_generate_res_pred( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const float samp_ratio, /* i : sampling ratio */ - float *pDFT_DMX, /* i : downmix signal */ - float *DFT_PRED_RES, /* o : residual prediction signal */ - float *pPredGain, /* i : residual prediction gains */ - const int16_t k, /* i : subframe index */ - float *ap_filt_DMX, /* i : enhanced stereo filling signal */ - int16_t *stop, /* o : last FD stereo filling bin */ - const int16_t bfi /* i : BFI flag */ -); - -void stereo_dft_dec_core_switching( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[], /* i/o: synthesis @internal Fs */ - float synth[], /* i : synthesis @output Fs */ - float hb_synth[], /* i/o: hb synthesis */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t output_frame, /* i : output frame length */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t sba_dirac_stereo_dtx_flag /* i : DTX indicator for SBA DirAC stereo */ -); - -void init_basic_allpass( - basic_allpass_t *ap, /* i/o: basic allpass structure */ - const float *gains, /* i : allpass filter gains */ - const int16_t *delays /* i : allpass filter delays */ -); - -void filter_with_allpass( - const float *sig, /* i : allpass input signal */ - float *out, /* o : filtered output */ - const int16_t len, /* i : length of input */ - basic_allpass_t *ap /* i/o: basic allpass structure */ -); - -/*! r: used GR order */ - -/*! r: used GR order */ - - -/*! r: number of bits written */ - -/*! r: number of bits written */ - - -void stereo_dft_enc_compute_itd( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - float *DFT_L, - float *DFT_R, - const int16_t k_offset, - const int16_t input_frame, - const int16_t vad_flag_dtx[], - const int16_t vad_hover_flag[], - float *bin_nrgL, - float *bin_nrgR -); - -void stereo_dft_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig, /* o : DFT stereo configuration */ - const int32_t brate, /* i : IVAS/CPE/nominal total bitrate */ - int16_t *bits_frame_nominal, /* o : primary channel nominal bits per frame */ - int16_t *bits_frame_nominal_2 /* o : secondary channel nominal bits per frame*/ -); - -int16_t stereo_dft_band_config( - int16_t *band_limits, /* o : DFT band limits */ - const int16_t band_res, /* i : DFT band resolution */ - const int16_t NFFT, /* i : analysis/synthesis window length */ - const int16_t enc_dec /* i : flag to indicate enc vs dec */ -); - -void stereo_dft_dmx_out_reset( - STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ -); - -void stereo_dft_unify_dmx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ - Decoder_State *st0, /* i/o: decoder state structure */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ - float *input_mem, /* i/o: mem of buffer DFT analysis */ - const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ -); - -void add_HB_to_mono_dmx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[L_FRAME48k], /* i/o: output synthesis */ - float outputHB[L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t output_frame /* i : frame length */ -); - -/*----------------------------------------------------------------------------------* - * Range Coder prototypes - *----------------------------------------------------------------------------------*/ - -void rc_uni_dec_init( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - uint16_t *bit_buffer, /* i : Bit buffer */ - const int16_t max_available_bits /* i : Total maximum bits available */ -); - -/*! r: Read symbol */ -uint16_t rc_uni_dec_read_symbol_fastS( - RangeUniDecState *rc_st_dec, /* i/o: Decoder State */ - const uint16_t cum_freq_table[], /* i : Cumulative frequency up to symbol */ - const uint16_t sym_freq_table[], /* i : Symbol frequency */ - const uint16_t alphabet_size, /* i : Number of symbols in the alphabet */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -/*! r: Read bit */ -uint16_t rc_uni_dec_read_bit( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - -/*! r: Read bit */ -uint16_t rc_uni_dec_read_bit_prob_fast( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const int16_t freq0, /* i : Frequency for symbol 0 */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -/*! r: Read bits */ -uint16_t rc_uni_dec_read_bits( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const int16_t bits /* i : Number of bits */ -); - -/*! r: Total number of bits consumed */ -int16_t rc_uni_dec_virtual_finish( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - -/*! r: Total number of bits consumed */ -int16_t rc_uni_dec_finish( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - - -/*----------------------------------------------------------------------------------* - * ECLVQ Stereo prototypes - *----------------------------------------------------------------------------------*/ - -float ECSQ_dequantize_gain( - const int16_t index -); - - - -void ECSQ_init_instance( - ECSQ_instance *ecsq_inst, - const int16_t config_index, - void *ac_handle -); - - - -void ECSQ_dequantize_vector( - const int16_t *input, - const float global_gain, - const int16_t N, - float *output -); - - -/*----------------------------------------------------------------------------------* - * ICA Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_tca_init_enc( - STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA encoder handle */ - const int32_t input_Fs /* i : input sampling frequency */ -); - -void stereo_tca_enc( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int16_t input_frame /* i : length of a frame per channel */ -); - -void stereo_tca_init_dec( - STEREO_TCA_DEC_HANDLE hStereoTCA /* i/o: Stereo TCA handle */ -); - -void stereo_tca_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *synth[CPE_CHANNELS], /* i/o: output synth */ - const int16_t output_frame /* i : length of a frame per channel */ -); - -void stereo_tca_scale_R_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output, /* i/o: output synthesis, R channel */ - const int16_t output_frame /* i : frame length */ -); - -void adjustTargetSignal( - float *target, - const int16_t prevShift, - const int16_t currShift, - const int16_t L_shift_adapt, - const int16_t method -); - -/*----------------------------------------------------------------------------------* - * IC-BWE Stereo prototypes - *----------------------------------------------------------------------------------*/ - - -void stereo_icBWE_preproc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t input_frame, /* i : input frame length */ - float shb_speech_nonref[] /* o : SHB speech non-ref channel */ -); - -void stereo_icBWE_enc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const float shb_speech_ref[], /* i : SHB speech ref channel */ - float shb_speech_nonref[], /* i/o: SHB speech non-ref channel */ - const float *voice_factors /* i : voicing factors */ -); - -void stereo_icBWE_init_dec( - STEREO_ICBWE_DEC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */ -); - -void stereo_icBWE_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *synthRef, /* i/o: Reference channel HB synthesis at output Fs */ - float *synth, /* o : Non reference channel HB synthesis at output Fs */ - const float *fb_synth_ref, /* i : ref. high-band synthesis 16-20 kHz */ - const float *voice_factors, /* i : voicing factors */ - const int16_t output_frame /* i : frame length */ -); - -void stereo_icBWE_decproc( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output symthesis */ - float outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t last_bwidth, /* i : last bandwidth */ - const int16_t output_frame /* i : frame length */ -); - - -/*----------------------------------------------------------------------------------* - * Stereo classifiers prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_classifier_features( - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t vad_flag, /* i : VAD flag */ - const float lsf_new[], /* i : LSFs at the end of the frame */ - const float epsP[], /* i : LP analysis residual energies for each iteration*/ - const int16_t pitch[], /* i : open-loop pitch values for quantiz. */ - const float voicing[], /* i : OL maximum normalized correlation */ - const float cor_map_sum, /* i : speech/music clasif. parameter */ - const float non_staX, /* i : unbound non-stationarity for sp/mu clas. */ - const float sp_div, /* i : spectral diversity feature */ - const int16_t clas /* i : signal class */ -); - - -void xtalk_classifier_dft( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t itd, /* i : ITD from DFT stereo - used as a feature */ - const float gcc_phat[] /* i : GPHAT cross-channel correlation function */ -); - -/*----------------------------------------------------------------------------------* - * TD Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_td_init_enc( - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const int16_t last_element_mode /* i : last element mode */ -); - - - -void stereo_tdm_downmix( - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i : TD stereo IVAS encoder structure */ - float *Left_in, /* i/o: Left channel -> Primary channel */ - float *Right_in, /* i/o: Right channel -> Secondary channel */ - const int16_t input_frame, /* i : Number of samples */ - const int16_t tdm_ratio_idx, /* i : TDM ratio index */ - const int16_t tdm_SM_flag, /* i : channel combination scheme flag */ - const int16_t tdm_ratio_idx_SM /* i : TDM ratio index for SM mode */ -); - -void stereo_td_init_dec( - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const int16_t last_element_mode /* i : last element mode */ -); - -void tdm_configure_dec( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t *tdm_ratio_idx, /* o : ratio index */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -void tdm_upmix_plain( - float Left[], /* o : left channel */ - float Right[], /* o : right channel */ - const float PCh_2_L[], /* i : primary channel */ - const float SCh_2_R[], /* i : secondary channel */ - const float LR_ratio, /* i : mixing ratio */ - const float inv_den_LR_ratio, /* i : inverse mixing ration */ - const int16_t start_index, /* i : start index */ - const int16_t end_index, /* i : end index */ - const int16_t plus_minus_flag /* i : plus/minus flag */ -); - -void stereo_tdm_combine( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *PCh_2_L, /* i/o: Primary channel -> output as L channel */ - float *SCh_2_R, /* i/o: Seconday channel -> output as R channel */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ -); - -/*! r: replication decision; 1 = Use old LP */ -void tdm_ol_pitch_comparison( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - float pitch_fr[CPE_CHANNELS][NB_SUBFR], /* i/o: fractional pitch values */ - float voicing_fr[CPE_CHANNELS][NB_SUBFR] /* i/o: fractional pitch gains */ -); - -void tdm_configure_enc( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ - const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ - const int16_t tdm_ratio_idx, /* i : ratio index */ - const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ - const int16_t attack_flag, /* i : Primary channel attack flag */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - - -void tdm_bit_alloc( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ - const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ - int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ - int32_t *total_brate_sec, /* o : Allocated secondary channel bitrate */ - int16_t *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */ - const int16_t coder_type, /* i : secondary channel coder type */ - const int16_t ener_ratio_idx, /* i : correlation ratio indexe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const int16_t bwidth_pri, /* i : bandwidth of the primary channel */ - const int16_t bwidth_sec, /* i : bandwidth of the secondary channel */ - const int16_t flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ - const int16_t tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ -); - - -/*! r: value of the indice */ -uint16_t get_indice_st( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t pos, /* i : absolute position in the bitstream */ - const int16_t nb_bits /* i : number of bits to quantize the indice */ -); - -void tdm_low_rate_dec( - Decoder_State *st, /* i/o: decoder static memory */ - float dct_epit[], /* o : GSC excitation in DCT domain */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - const float *lsf_new /* i : ISFs at the end of the frame */ -); - -void tdm_SCh_LSF_intra_pred( - const int32_t element_brate, /* i : element bitrate */ - const float *tdm_lsfQ_PCh, /* i : primary channel LSFs */ - float *pred_lsf_SCh /* o : predicted secondary channel LSFs */ -); - - -void first_VQstages( - const float *const *cb, - const float u[], /* i : vector to be encoded (prediction and mean removed) */ - const int16_t *levels, /* i : number of levels in each stage */ - const int16_t stagesVQ, /* i : number of stages */ - const float w[], /* i : weights */ - const int16_t N, /* i : vector dimension */ - const int16_t max_inner, /* i : maximum number of swaps in inner loop */ - int16_t indices_VQstage[] -); - - -void deindex_lvq_SHB( - UWord32 index, - float *out, - const int16_t nbits, - const int16_t mode -); - -/*----------------------------------------------------------------------------------* - * MDCT Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ - const int16_t vad_hover_flag[], /* i : VAD hangover flags */ - const int16_t input_frame /* i : frame length */ -); - -void QuantizeTCXSpectrum( - Encoder_State *st, /* i : state handle */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const float *x_orig, /* i : shaped MDCT spectrum */ - const float *gainlpc, /* i : FDNS gains */ - const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) */ - const int16_t tnsSize, /* i : number of tns parameters put into prm */ - const int16_t nb_bits, /* i : bit budget */ - const int16_t vad_hover_flag, /* i : VAD hangover flag */ - int16_t *pL_frameTCX, /* o : full frame length */ - int16_t *pL_frame, /* o : frame length */ - int16_t *pL_spec, /* o : length of the coded spectrum */ - int16_t *ptcx_offset, /* o : folding point offset relative to the end of the previous frame */ - int16_t *pnoiseFillingBorder, /* o : noise filling border */ - float spectrum[], /* o : quantized MDCT spectrum */ - CONTEXT_HM_CONFIG *hm_cfg, /* o : Context-based harmonic model configuration */ - int16_t *hm_active, /* o : flag indicating if the harmonic model is active */ - float lf_deemph_fact[], /* o : low frequency deemphasis factors */ - int16_t *nf_seed, /* o : noise filling random seed */ - float *ener, /* o : energy of the quantized spectrum */ - float *gain_tcx, /* o : global gain */ - int16_t prm[] /* o : tcx parameters */ -); - -void EstimateStereoTCXNoiseLevel( - Encoder_State **sts, /* i : state handle */ - float *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */ - float gain_tcx[][NB_DIV], /* i : global gain */ - int16_t L_frame[][NB_DIV], /* i : frame length */ - int16_t noiseFillingBorder[][NB_DIV], /* i : noise filling border */ - int16_t hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */ - const int16_t ignore_chan[], /* i : flag indicating whether the channel should be ignored */ - float fac_ns[][NB_DIV], /* o : noise filling level */ - int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void TNSAnalysisStereo( - Encoder_State **sts, /* i : state handle */ - float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum */ - const int16_t bWhitenedDomain, /* i : whitened domain flag */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame */ - int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void InternalTCXDecoder( - Encoder_State *st, /* i/o: state handle */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t L_frameTCX, /* i : full frame length */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_spec, /* i : length of the coded spectrum */ - const int16_t tcx_offset, /* i : folding point offset relative to the end of the previous frame */ - const int16_t noiseFillingBorder, /* i : noise filling border */ - const float *x_quant, /* i : quantized spectrum */ - const float ener, /* i : energy of the quantized spectrum */ - float lf_deemph_fact[], /* i/o: low frequency deemphasis factors */ - const float fac_ns, /* i : noise filling level */ - const int16_t nf_seed, /* i : noise filling random seed */ - const float *A, /* i : LPC representation of the FDNS gains */ - float *gainlpc, /* i/o: FDNS gains */ - const int16_t hm_active, /* i : flag indicating if the harmonic model is active */ - float gain_tcx, /* i/o: global gain / quantized global gain */ - float spectrum[], /* o : dequantized spectrum */ - float synth[], /* o : time domain signal */ - int16_t *gain_tcx_q /* o : quantized global gain (at low bitrates) */ -); - -void stereo_mdct_core_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ - Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ - Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ -); - -void initMdctStereoEncData( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t bwidth, /* i : bandwidth */ - const int16_t igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - const int16_t mem_init /* i : initialize memory after malloc */ -); - -ivas_error initMdctItdHandling( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void stereo_mdct_enc_destroy( - STEREO_MDCT_ENC_DATA_HANDLE *hStereoMdct /* i/o: encoder MDCT stereo handle */ -); - -void initMdctStereoDecData( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const int16_t igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID igfGrid, /* i : IGF grid configuration */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void stereo_mdct_init_bands( - const int16_t L_frame, /* i : frame length */ - const int16_t tmp_tcx_mode, /* i : tcx mode (TCX10, TCX 20), -1 if transition frame */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t igf, /* i : flag indicating if IGF is used */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - int16_t *sfbOffset, /* o : sfb offset table */ - int16_t *sfbCnt /* o : number of sfbs */ -); - -void stereo_mdct_init_igf_start_band( - STEREO_MDCT_BAND_PARAMETERS *stbParams, /* i/o: stereo frequency band parameters */ - const float transFac, /* i : transform factor */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t element_brate /* i : element bitrate */ -); - -void init_tcx_enc_info( - Encoder_State *st, /* i : coder memory state */ - int16_t *L_frame, - int16_t *L_frameTCX, - int16_t *L_spec -); - -void decoder_tcx_invQ( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - float A[], /* i : coefficients NxAz[M+1] */ - Word16 Aind[], /* i : frame-independent coefficients Az[M+1] */ - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[], - float gainlpc2[], - float xn_buf[], - int16_t *fUseTns, /* o : flag that is set if TNS data is present */ - STnsData *tnsData, - float *gain_tcx, - const int16_t **prm_sqQ, - int16_t *nf_seed, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt /* i : frame counter in the super frame */ -); - -void decoder_tcx_noisefilling( - Decoder_State *st, /* i/o: coder memory state */ - float concealment_noise[L_FRAME48k], - const float A[], /* i : coefficients NxAz[M+1] */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[], - float gainlpc2[], - int16_t *temp_concealment_method, - const float gain_tcx, - const int16_t *prm_sqQ, - int16_t nf_seed, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t frame_cnt /* i : frame counter in the super frame */ -); - -void decoder_tcx_noiseshaping_igf( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, - float x[], - const float gainlpc2[], - int16_t *temp_concealment_method, - const int16_t bfi /* i : Bad frame indicator */ -); - -void decoder_tcx_tns( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[N_MAX], - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ - STnsData *tnsData, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t whitenedDomain -); - -void decoder_tcx_imdct( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : frame length */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t tcx_offset, - const int16_t tcx_offsetFB, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, - float x[N_MAX], - float xn_buf[], - const uint16_t kernelType, /* i : TCX transform kernel type */ - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ - float synth[], /* i/o: synth[-M..L_frame] */ - float synthFB[], - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void init_tcx_info( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : global frame length */ - const int16_t L_frameTCX_glob, /* i : FB global frame length */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t bfi, /* i : bad frame indicator */ - int16_t *tcx_offset, /* o : folding point offset relative to the end of the previous frame */ - int16_t *tcx_offsetFB, /* o : FB folding point offset relative to the end of the previous frame*/ - int16_t *L_frame, /* o : frame length */ - int16_t *L_frameTCX, /* o : TCX frame length */ - int16_t *left_rect, /* o : left part is rectangular */ - int16_t *L_spec /* o : spectrum length */ -); - -void decoder_tcx_IGF_mono( - Decoder_State *st, /* i/o: coder memory state */ - float x[], /* o : de-quatized coefficients */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t frame_cnt /* i : frame counter in the super_frame */ -); - -void decoder_tcx_IGF_stereo( - Decoder_State **sts, /* i/o: coder memory states */ - STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *x[CPE_CHANNELS][NB_DIV], /* o : de-quatized coefficients */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t k, /* i : Subframe index */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ms_processing( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - const int16_t iSubframe, /* i : subframe number */ - float x_0[], /* i/o: spectrum 1 */ - float x_1[], /* i/o: spectrum 2 */ - int16_t maxSfb /* i : number of stereo frequency bands */ -); - -void ms_inv_mask_processing( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - const int16_t iSubframe, /* i : subframe number */ - const float x_0[], /* i : spectrum 1 */ - const float x_1[], /* i : spectrum 2 */ - float x_inv_0[], /* o : inverse spectrum 1 */ - float x_inv_1[], /* o : inverse spectrum 2 */ - int16_t maxSfb /* i : number of stereo frequency bands */ -); - -void IGFDecApplyStereo_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - float *spectrumL, /* i/o: L MDCT spectrum */ - float *spectrumR, /* i/o: R MDCT spectrum */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t *coreMsMask, - const int16_t restrict_hopsize, - const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ - const int16_t bfi_apply_damping /* i : decoder element mode */ -); - -void IGFEncStereoEncoder( - STEREO_MDCT_BAND_PARAMETERS *sfbParam, /* i/o: sfb parameters for the right channel */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : IGF handle */ - const float *mdctSpectrumL, /* i : left spectrum */ - const float *mdctSpectrumR, /* i : right spectrum */ - int16_t *msMask, /* i/o: MS mask */ - int16_t *igfStereoMode, /* o : IGF stereo mode */ - const int16_t mdct_stereo_mode, /* i : MDCT stereo mode */ - const int16_t isTCX20, /* i : flag for indicating TCX20 */ - const int16_t isTransition /* i : flag for transtition */ -); - -void IGFDecReplicateTCX10State_flt( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: instance handle of IGF Decoder */ -); - - -void InitPsychLPC( - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t L_frame, /* i : frame length */ - const TCX_CONFIG_HANDLE hTcxCfg /* i : TCX configuration handle */ -); - - -void stereo_coder_tcx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ - float *inv_mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void stereo_decoder_tcx( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: MDCT stereo decoder structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *spec_r_0[NB_DIV], /* i/o: spectrum right channel */ - float *spec_l[], /* i/o: spectrum left channel [NB_DIV][N] */ - float *spec_r[], /* i/o: spectrum right channel [NB_DIV][N] */ - const int16_t mdct_stereo_mode[], /* i : stereo mode (FB/band wise MS, dual mono */ - const int16_t core_l, /* i : core for left channel (TCX20/TCX10) */ - const int16_t core_r, /* i : core for right channel (TCX20/TCX10) */ - const int16_t igf, /* i : flag for IGF activity */ - const int16_t L_frameTCX_l, /* i : TCX frame length of left channel */ - const int16_t L_frameTCX_r, /* i : TCX frame length of right channel */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t last_core_l, /* i : last core for left channel */ - const int16_t last_core_r, /* i : last core for right channel */ - const int16_t tmp_plc_upmix /* i : indicates temp upmix for PLC decision */ -); - -void stereo_mdct_core_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ - float signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ -); - -void splitAvailableBits( - const int16_t total_bits, /* i : total available bits for TCX coding */ - const int16_t split_ratio, /* i : split ratio */ - const int16_t isSBAStereoMode, /* i : signal core coding for SBA */ - int16_t *bits_ch0, /* o : bits for channel 0 */ - int16_t *bits_ch1 /* o : bits for channel 1 */ -); - -Word16 write_stereo_to_bitstream_fx -( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - - - -void ComputeSpectrumNoiseMeasure( - const float *powerSpec, - const int16_t L_frame, - const int16_t startLine, - const int16_t resetMemory, - int8_t *noiseFlags, - const int16_t lowpassLine -); - -void IGFSaveSpectrumForITF( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const int16_t igfGridIdx, /* i : IGF grid index */ - const float *pITFSpectrum /* i : MDCT spectrum */ -); - -void convert_coeffs_to_higher_res( - const float *in1, /* i : first subframe input */ - const float *in2, /* i : second subframe input */ - float *out, /* o : converted output */ - const int16_t len /* i : length of subframes */ -); - -int16_t quantize_sns( - float sns_in[CPE_CHANNELS][NB_DIV][M], - float snsQ_out[CPE_CHANNELS][NB_DIV][M], - Encoder_State **sts, - int16_t *indices, - int16_t *zero_side_flag, - int16_t *sns_stereo_mode -); - -void dequantize_sns( - int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW], - float snsQ_out[CPE_CHANNELS][NB_DIV][M], - Decoder_State **sts -); - -void sns_avq_dec( - int16_t *index, /* i : Quantization indices */ - float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, /* i : frame length */ - const int16_t numlpc /* i : Number of sets of lpc */ -); - -void sns_avq_dec_stereo( - int16_t *indexl, /* i : Quantization indices (left channel) */ - int16_t *indexr, /* i : Quantization indices (right channe) */ - const int16_t L_frame, /* i : frame length */ - float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ - float *SNS_Qr /* o : Quantized SNS vectors (right channe) */ -); - -void convertToMS( - const int16_t L_frame, /* i : frame length */ - float x0[], /* i/o: mid/left channel coefficients */ - float x1[], /* i/o: side/right channel coefficients */ - const float norm_fac /* i : normalization factor */ -); - -void inverseMS( - const int16_t L_frame, /* i : frame length */ - float x0[], /* i/o: mid/left channel coefficients */ - float x1[], /* i/o: side/right channel coefficients */ - const float norm_fac /* i : normalization factor */ -); - -void stereoFdCngCoherence( - Encoder_State **sts, /* i/o: core encoder structures */ - const int16_t last_element_mode, /* i : last element mode */ - float fft_buff[CPE_CHANNELS][2 * L_FFT] /* i : fft buffers for L and R channels */ -); - -void FdCngEncodeMDCTStereoSID( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -); - -void FdCngDecodeMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -); - -ivas_error initMdctStereoDtxData( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder handle */ -); - -void synchonize_channels_mdct_sid( - Decoder_State *sts[CPE_CHANNELS], /* i/o: decoder state structure */ - const int16_t n /* i : channel number */ -); - -void updateBuffersForDmxMdctStereo( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - const int16_t output_frame, /* i : output frame length */ - float *output[CPE_CHANNELS], /* i/o: decoder output */ - float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */ -); - -void applyDmxMdctStereo( - const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ - float *output[CPE_CHANNELS], /* o : output from core decoder */ - const int16_t output_frame /* i : output frame length */ -); - -/*----------------------------------------------------------------------------------* - * Front-VAD prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error front_vad_create( - FRONT_VAD_ENC_HANDLE *hFrontVad, /* i/o: front-VAD handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ -); - -void front_vad_destroy( - FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ -); - -ivas_error front_vad( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ - Encoder_State *st, /* i/o: encoder state structure */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: front-VAD handles */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t input_frame, /* i : frame length */ - int16_t vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */ - float fr_bands[][2 * NB_BANDS], /* i : energy in frequency bands */ - float Etot_LR[], /* o : total energy Left & Right channel */ - float lf_E[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - int16_t localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */ - int16_t vad_hover_flag[], /* o : VAD hangover flag */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - float *PS_out, /* o : energy spectrum */ - float *Bin_E_out /* o : log-energy spectrum of the current frame*/ -); - -ivas_error front_vad_spar( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ - const float *omni_in, /* i : omnidirectional input signal */ - ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ - const int16_t input_frame /* i : input frame length */ -); - - -/*----------------------------------------------------------------------------------* - * Stereo CNG prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_enc_cng_init( - STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */ -); - -void stereo_cng_upd_counters( - STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int32_t element_mode, /* i : element mode */ - const int16_t nbands, /* i : Number of bands in active */ - const float sidSideGain[], /* i : SID side gains */ - const int16_t burst_ho_count, /* i : Hang-over count */ - int16_t *coh_fade_counter /* i : Coherence fade counter */ -); - -void stereo_cng_init_dec( - STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ - const int16_t *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 */ -); - -void stereo_cng_compute_PScorr( - float *output[CPE_CHANNELS], /* i : Output signal */ - float *c_PS_LT, /* i/o: Correlation */ - const int16_t L_frame_0, /* i : L_frame channel 0 */ - const int16_t L_frame_1 /* i : L_frame channel 1 */ -); - -void stereo_cng_dec_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int32_t ivas_total_brate /* i : IVAS total bitrate Q0*/ -); - -void stereo_cna_update_params( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i : Output signal */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ -); - -void dtx_enc_init( - Encoder_State *st, /* i : Encoder state handle */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ -); - - -/*----------------------------------------------------------------------------------* - * Framework general prototypes - *----------------------------------------------------------------------------------*/ - -void mvc2c( - const uint8_t x[], /* i : input vector */ - uint8_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -/*! r: Adjusted value */ -ivas_error stereo_memory_dec( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int32_t output_Fs, /* i : output sampling rate */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -void stereo_switching_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ -); - -void stereo_td2dft_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float output[], /* i/o: synthesis @internal Fs */ - float synth[], /* i/o: synthesis @output Fs */ - float hb_synth[], /* i/o: hb synthesis */ - const int16_t output_frame /* i : frame length */ -); - -void stereo_mdct2dft_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output0[], /* i/o: synthesis @internal Fs, ch0 */ - float synth0[] /* i/o: synthesis @output Fs, ch0 */ -); - - -/*! r: number of bits written */ - - - -/*----------------------------------------------------------------------------------* - * MCT prototypes - *----------------------------------------------------------------------------------*/ -void ivas_mdct_core_whitening_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ - Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ - Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ - Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t nChannels, /* i : total number of coded channels */ -Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], -Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] -); -void ivas_mct_core_enc( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ - const int16_t nChannels, /* i : number of channels to be coded */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits, /* i : bits spent for LFE */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ -); - -void ivas_mdct_quant_coder( - CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void apply_MCT_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ - float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ - float *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t nchan /* i : number of channels */ -); - -void write_mct_bitstream( - Encoder_State **sts, /* i/o: encoder state structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const int16_t nchan /* i : number of channels */ -); - -void splitAvailableBitsMCT_fx( - void **sts, /* i/o: encoder/decoder state structure */ - const Word16 total_bits, /* i : total number of available bits */ - const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */ - const Word16 enc_dec, /* i : encoder or decoder flag */ - const Word16 nchan /* i : number of channels */ -); - -void getChannelEnergies( - Encoder_State **sts, /* i : Encoder state structure */ - float nrg[MCT_MAX_CHANNELS], /* o : energies */ - const int16_t nchan /* i : number of channels */ -); - -void mctStereoIGF_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */ - float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ - float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect. */ - float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ -); - -void ivas_mdct_dec_side_bits_frame_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */ - Decoder_State *st0, /* i : pointer to bitstream handle */ - int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */ - int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */ -); - -void ivas_mct_side_bits( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ - const int16_t nCPE, /* i : number of CPEs */ - Decoder_State *st0, /* i : decoder handle for Bstr */ - const int16_t bfi, /* i : BFI flag */ - uint16_t *bitstream, /* o : bitstream indices */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -void ivas_mdct_core_invQ( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */ - int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */ - int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i : param buffer */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ - STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ - float *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ - float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ - float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ivas_mdct_core_reconstruct( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */ - float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ivas_mdct_core_tns_ns( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */ - STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */ - float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ - float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - - -void ivas_mct_dec_mct( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - const int16_t nchan /* i : number of channels */ -); - -void apply_MCT_dec( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ -); - -void mctStereoIGF_dec( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequantized spectrum */ - const int16_t bfi /* i : bad frame flag */ -); - -void enc_prm_igf_mdct( - Encoder_State *st, /* i : Encoder state handle */ - BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */ -); - -void mdct_read_IGF_bits( - Decoder_State *st, /* i/o: Encoder state handle */ - Decoder_State *st0 /* i : pointer to handle where bstr is read */ -); - - -/*----------------------------------------------------------------------------------* - * Q Metadata prototypes for DirAC and MASA - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_qmetadata_enc_encode( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: q_metadata handle */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -ivas_error ivas_qmetadata_enc_encode_hr_384_512( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh -); - -void deindex_sph_idx( - const uint16_t sphIndex, /* i : Spherical index */ - const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ - float *theta, /* o : Elevation */ - float *phi /* o : Azimuth */ -); - -/*! r: output index for direction */ -uint16_t index_theta_phi_16( - float * p_theta, /* i/o: input elevation to be indexed */ - float * p_phi, /* i/o: input azimuth to be indexed */ - const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ -); - -void reset_metadata_spatial( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - const int32_t element_brate, /* i : element bitrate */ - int32_t *total_brate, /* o : total bitrate */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t nb_bits_metadata /* i : number of meatdata bits */ -); - -/*! r: number of bits written */ - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode_hr_384_512( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh, - const uint8_t ncoding_bands_config -); - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_sid_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const int16_t nchan_transport, /* i : number of transport channels */ - int16_t *element_mode, /* o : element mode */ - const int16_t ivas_format /* i : IVAS format */ -); - - - - -void restore_metadata_buffer( - BSTR_ENC_HANDLE hMetaData, - const int16_t next_ind_start, - const int16_t bit_pos_start -); - -/*! r: codeword index */ -int16_t masa_sq( - const float in, /* i : input value */ - const float *threshold, /* i : partition */ - const int16_t cb_sz /* i : codebook size */ -); - -void ivas_qmetadata_azimuth_elevation_to_direction_vector( - const float az, /* i : azimuth */ - const float el, /* i : elevation */ - float *dv /* o : direction vector */ -); - -ivas_error only_reduce_bits_direction( - int16_t *reduce_bits_out, - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - int16_t reduce_bits, - const int16_t coding_subbands, - const int16_t no_subframes, - int16_t *ind_order -); - -void quantize_direction_frame( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding*/ -); - -/*! r: quantized spherical index */ -uint16_t quantize_direction( - const float theta, /* i : input elevation value */ - float phi, /* i : input azimuth value */ - const int16_t no_bits, /* i : number of bits */ - float *theta_q, /* o : quantized elevation */ - float *phi_q, /* o : quantized azimuth */ - uint16_t *index_theta, /* o : quantized elevation index */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -int16_t quantize_direction2D( - float phi, /* i : input azimuth value */ - const int16_t no_cw, /* i : number of bits */ - float *phi_q, /* o : quantized azimuth value */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -void quantize_direction_frame2D( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */ - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] /* i : input elevation values */ -); - -void small_requantize_direction_frame( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */ - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input elevation values */ - const int16_t raw_flag[MASA_MAXIMUM_CODING_SUBBANDS], /* i : raw/EC encoding mode for each subband */ - int16_t bits_dir_bands[MASA_MAXIMUM_CODING_SUBBANDS], /* i/o: number of bits per subband */ - int16_t *diff /* i/o: number of bits to be reduced */ -); - -/*! r: index azimuth */ -int16_t quantize_phi( - float phi, /* i : azimuth value */ - const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - float *phi_hat, /* o : quantized azimuth */ - const int16_t n /* i : azimuth codebook size */ -); - -/*! r: decoded elevation value */ -float deindex_elevation( - uint16_t *id_th, /* i : input index */ - const int16_t no_bits, /* i : number of bits for the spherical grid */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -float deindex_azimuth( - int16_t id_phi, /* i : index */ - const int16_t no_bits, /* i : number of bits for the spherical grid */ - const int16_t id_th, /* i : elevation index */ - const int16_t remap, /* i : remapping flag */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -UWord16 ivas_qmetadata_reorder_generic_fx( - const Word16 signed_value -); - -void ivas_sba_config( - const int32_t sba_total_brate, /* i : SBA total bitrate */ - int16_t sba_order, /* i : Ambisonic (SBA) order */ - int16_t nb_channels, /* i : Number of Ambisonic (SBA) channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - const int16_t sba_planar, /* i : SBA planar flag */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - int16_t *element_mode /* o : element mode of the core coder */ -); - -void ivas_sba_set_cna_cng_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_sba_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ -); - -ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ -); - - - -/*! r: Ambisonic (SBA) order */ -int16_t ivas_sba_get_order( - const int16_t nb_channels, /* i : Number of ambisonic channels */ - const int16_t sba_planar /* i : SBA planar flag */ -); - -/*! r: number of Ambisonic channels */ -int16_t ivas_sba_get_nchan( - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t sba_planar /* i : SBA planar flag */ -); - -/*! r: number of ambisonics metadata channels */ - -void ivas_sba_getTCs( - float *sba_data[], /* i : SBA signals */ - Encoder_Struct *st_ivas, /* i/o: Encoder struct */ - const int16_t input_frame /* i : frame length */ -); - -int16_t ivas_sba_remapTCs( - float *sba_data[], /* i/o: SBA signals */ - Decoder_Struct *st_ivas, /* i/o: decoder struct */ - const int16_t output_frame /* i : frame length */ -); - -void ivas_sba_dirac_stereo_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[CPE_CHANNELS], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t mcmasa /* i : McMASA flag */ -); - -void ivas_sba_dirac_stereo_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ -); - - -Word16 ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_sba_dirac_stereo_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ - const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ - const int32_t output_Fs, /* i : Fs for delay calculation */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -); - - -/*----------------------------------------------------------------------------------* - * DirAC prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_dirac_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - - - -ivas_error ivas_dirac_config( - void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ - const int16_t enc_dec /* i : encoder or decoder flag */ -); - -void ivas_dirac_config_bands( - int16_t *band_grouping, /* o : band grouping */ - const int16_t nbands, /* i : number of bands */ - const int16_t max_band, /* i : maximal band index +1 */ - int16_t *dirac_to_spar_md_bands, /* o : mapping of DirAC parameter band index to SPAR FB band index */ - const int8_t useLowerBandRes, /* i : flag indicating lower band resolution for DirAC */ - const int16_t enc_param_start_band, /* i : band index of first DirAC parameter band */ - IVAS_FB_MIXER_HANDLE hFbMdft -); - -void ivas_get_dirac_sba_max_md_bits( - const int32_t sba_total_brate, - int16_t *bits_frame_nominal, - int16_t *metadata_max_bits, - int16_t *qmetadata_max_bit_req, - const int16_t nbands - , - IVAS_FORMAT ivas_format -); - -ivas_error ivas_dirac_sba_config( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* o : element mode of the core coder */ - int32_t sba_total_brate, /* i : SBA total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t nbands /* i : number of frequency bands */ - , - IVAS_FORMAT ivas_format -); - -ivas_error ivas_dirac_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ -); - -void ivas_dirac_dec_close( - DIRAC_DEC_HANDLE *hDirAC_out -); - -void ivas_dirac_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder Core state structure */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ - int16_t *nb_bits, /* o : number of bits read */ - const int16_t last_bit_pos, /* i : last read bitstream position */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ -); - -void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ -); - - -void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_dirac_dec_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] -); - - -void computeDirectionVectors( - float *intensity_real_x, - float *intensity_real_y, - float *intensity_real_z, - const int16_t enc_param_start_band, - const int16_t num_frequency_bands, - float *direction_vector_x, - float *direction_vector_y, - float *direction_vector_z -); - -void computeDiffuseness( - float *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], - const float *buffer_energy, - const int16_t num_freq_bands, - float *diffuseness -); - -void ivas_dirac_dec_get_response( - const int16_t azimuth, - const int16_t elevation, - float *response, - const int16_t ambisonics_order -); - - - -ivas_error ivas_mc_paramupmix_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_mc_paramupmix_enc_close_fx( - MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -ivas_error ivas_mc_paramupmix_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_mc_paramupmix_dec_close( - MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ -); - -void ivas_mc_paramupmix_dec_read_BS( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Decoder_State *st, /* i/o: decoder state structure */ - MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - int16_t *nb_bits /* o : number of bits written */ -); - -void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -void ivas_param_mc_set_coded_bands_fx( - HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ -); - -/*! r: number of IVAS transport channels */ - -ivas_error ivas_param_mc_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -ivas_error ivas_param_mc_enc_reconfig( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_param_mc_enc_close( - PARAM_MC_ENC_HANDLE *hParamMC, /* i/o: Parametric MC encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_param_mc_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float *data_f[], /* i/o: input/transport MC data */ - const int16_t input_frame /* i : input frame length */ -); - -ivas_error ivas_param_mc_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_param_mc_dec_reconfig( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - - -void ivas_param_mc_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ -); - -void ivas_param_mc_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_param_mc_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -); - -/*! r: number of cldfb synthesis instances */ -int16_t param_mc_get_num_cldfb_syntheses( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -); - -UWord16 ivas_param_mc_get_configuration_index_fx( - const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -ivas_error ivas_dirac_dec_output_synthesis_cov_open( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ - const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ - const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ - const int16_t num_param_bands, /* i : number of parameter bands */ - const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ -); - -void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length /* i : interpolator length */ -); - -void ivas_dirac_dec_output_synthesis_cov_init( - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t n_param_bands, /* i : number of total parameter bands */ - const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ -); - -void ivas_dirac_dec_output_synthesis_cov_close( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ -); - - -void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( - float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ - float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ - float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ - float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ - const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ - const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ - const int16_t nX, /* i : number of input channels */ - const int16_t nY, /* i : number of output channels */ - PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ -); - - -void FdCngEncodeDiracMDCTStereoSID( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -); - -void FdCngDecodeDiracMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -); - - -/*----------------------------------------------------------------------------------* - * SPAR prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_spar_enc_open( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - -ivas_error ivas_spar_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data_f[], /* i/o: input/transport audio channels */ - const int16_t input_frame, /* i : input frame length */ - int16_t *nb_bits_metadata, /* i : number of MD bits written */ - BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ -); - -ivas_error ivas_spar_dec_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - - -ivas_error ivas_spar_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - int16_t *nb_bits_read /* o : number of MD bits read */ -); - -void ivas_spar_config( - int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - int16_t *nchan_transport, /* o : number of transport channels */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - int32_t *core_nominal_brate, /* o : core-coding nominal bitrate */ - const int16_t sid_format /* i : IVAS format indicator from SID frame */ -); - -ivas_error ivas_sba_linear_renderer( - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, /* i : number of objects */ - const AUDIO_CONFIG output_config, /* i : output audio configuration */ - const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ -); - -void ivas_sba_mix_matrix_determiner( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - float *output[], /* i/o: transport/output audio channels */ - const int16_t bfi, /* i : BFI flag */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -); - -/* AGC */ -/*! r: AGC enable flag */ - -ivas_error ivas_spar_agc_enc_open( - ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ -); - -void ivas_spar_agc_enc_close( - ivas_agc_enc_state_t **hAgcEnc /* i/o: AGC encoder handle */ -); - -void ivas_agc_enc_process( - ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - float **ppPcm_in, /* i : input audio channels */ - float **ppPcm_out, /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ -); - -ivas_error ivas_spar_agc_dec_open( - ivas_agc_dec_state_t **hAgcDec, /* i/o: AGC decoder handle */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void ivas_spar_agc_dec_close( - ivas_agc_dec_state_t **hAgcDec /* i/o: AGC decoder handle */ -); - - -void ivas_agc_dec_process( - ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - float *pcm_in[], /* i : input audio channels */ - float *pcm_out[], /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const int16_t output_Fs /* i : output sampling rate */ -); - -void ivas_agc_read_bits( - ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const int16_t n_channels, /* i : number of channels */ - const int16_t AGC_flag /* i : AGC on/off flag */ -); - -void ivas_agc_initWindowFunc( - float *pWinFunc, - const int16_t length -); - -void ivas_agc_calcGainParams( - uint16_t *absEmin, - uint16_t *betaE, - uint16_t *maxAttExp, - const int16_t numCoeffs -); - -float ivas_get_mdct_scaling_gain( - const int16_t dct_len_by_2 -); - -void ivas_get_twid_factors( - const int16_t length, - const float **pTwid_re, - const float **pTwid_im -); - -int16_t ivas_get_bw_idx_from_sample_rate( - const int32_t sampling_rate /* i : sampling rate */ -); - -/*! r: config. table index */ -int16_t ivas_get_spar_table_idx( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order, /* i : IVAS SBA order */ - const int16_t bwidth, /* i : audio bandwidth */ - int16_t *bitlen, /* o : number of bits */ - int16_t *ind /* o : indice */ -); - -/*! r: number of transport channels */ -int16_t ivas_get_sba_num_TCs( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order /* i : IVAS SBA order */ -); - - -void ivas_spar_bitrate_dist( - int32_t core_brates_act[], /* o : bitrates per core-coder */ - const int16_t nAvailBits, /* i : number of available bits */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void ivas_mdct( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_dct_windowing( - const int16_t fade_len, - const int16_t full_len, - const int16_t dct_len, - const int16_t zero_pad_len, - const float *pWindow_coeffs, - const int16_t frame_len, - float *pOut_buf, - float *pBuffer_prev, - float *pTemp_lfe -); - -void ivas_tda( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_imdct( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_itda( - const float *re, - float *pOut, - const int16_t length -); - -void ivas_spar_get_cldfb_gains( - SPAR_DEC_HANDLE hSpar, - HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0, - HANDLE_CLDFB_FILTER_BANK cldfbSynDec0, - const DECODER_CONFIG_HANDLE hDecoderConfig -); - -/*! r: 1 if prediction residual channel */ - -void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: input/output audio channels */ - const Word16 output_frame /* i : output frame length */ -); - -void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nCldfbTs /* i : number of CLDFB time slots */ -); - -void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ -); - -void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -void ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -ivas_error ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ -); - -void ivas_spar_dec_upmixer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: input/output audio channels */ - const int16_t nchan_internal, /* i : number of internal channels */ - const int16_t output_frame /* i : output frame length */ -); - -/* MD module */ - -void ivas_spar_md_enc_close( - ivas_spar_md_enc_state_t **hMdEnc /* i/o: SPAR MD encoder handle */ -); - -void ivas_compute_spar_params( - float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - const int16_t i_ts, - float ***mixer_mat, - const int16_t start_band, - const int16_t end_band, - const int16_t dtx_vad, - const int16_t num_ch, - const int16_t bands_bw, - const int16_t active_w, - const int16_t active_w_vlbr, - ivas_spar_md_com_cfg *hSparCfg, - ivas_spar_md_t *hSparMd, - float *pWscale, - const int16_t from_dirac, - const int16_t dyn_active_w_flag -); - -void ivas_create_fullr_dmx_mat( - float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - float ***mixer_mat, - const int16_t in_chans, - const int16_t start_band, - const int16_t end_band, - const int16_t active_w, - ivas_spar_md_com_cfg *hMdCfg -); - -void ivas_calc_c_p_coeffs( - ivas_spar_md_t *pSparMd, - float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const int16_t i_ts, - float ***mixer_mat, - const int16_t num_ch, - const int16_t num_dmx, - const int16_t band_idx, - const int16_t dtx_vad, - const int16_t compute_p_flag, - const int16_t dyn_active_w_flag -); - -void ivas_get_spar_md_from_dirac( - float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float diffuseness[IVAS_MAX_NUM_BANDS], - const int16_t n_ts, - float ***mixer_mat, - ivas_spar_md_t *hSpar_md, - ivas_spar_md_com_cfg *hSpar_md_cfg, - const int16_t start_band, - const int16_t end_band, - const int16_t order, - const int16_t dtx_vad, - float Wscale_d[IVAS_MAX_NUM_BANDS], - const uint8_t useLowerRes, - const int16_t active_w_vlbr, - const int16_t dyn_active_w_flag -); - -/*! r: number of MD subframes */ - -ivas_error ivas_spar_md_dec_matrix_open( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t num_md_sub_frames -); - -void ivas_spar_md_dec_matrix_close( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ -); - -ivas_error ivas_spar_md_dec_open( - ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order, /* i : SBA order */ - const int16_t sid_format, /* i : SID format */ - const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ -); - -void ivas_spar_md_dec_close( - ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */ -); - -void ivas_spar_get_parameters( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t ts, /* i : time slot index */ - const int16_t num_ch_out, /* i : number of channels out */ - const int16_t num_ch_in, /* i : number of channels in */ - const int16_t num_spar_bands, /* i : number of SPAR bands */ - float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /* o : mixing matrix */ -); - -ivas_error ivas_spar_md_dec_init( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order /* i : SBA order */ -); - -void ivas_spar_md_dec_process( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t sba_order /* i : SBA order */ -); - -void ivas_spar_to_dirac( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bw, /* i : band joining factor */ - const int16_t dyn_active_w_flag /* i : dynamic active W flag */ -); - -void ivas_spar_update_md_hist( - ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ -); - -int16_t ivas_spar_chk_zero_coefs( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -void ivas_spar_smooth_md_dtx( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t num_md_sub_frames /* i : number of metadata subframes */ -); - -void ivas_spar_setup_md_smoothing( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t num_md_sub_frames /* i : number of metadata subframes */ -); - -void ivas_spar_dec_gen_umx_mat( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t num_md_sub_frames -); - - - - - -/* Transient detector module */ -ivas_error ivas_transient_det_open_fx( - ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void ivas_transient_det_close_fx( - ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ -); - -void ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - float *pIn_pcm, /* i : input audio channels */ - const int16_t frame_len, /* i : frame length in samples */ - int16_t transient_det[2] /* o : transient det outputs */ -); - -void ivas_td_decorr_get_ducking_gains( - ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ - float *pIn_pcm, - float *pIn_duck_gains, - float *pOut_duck_gains, - const int16_t frame_len, - const int16_t tdet_flag -); - -#define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ - out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); MAC(1); MULT(1); \ - out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); MAC(1); MULT(1); - -#define IVAS_CALCULATE_ABS( re, im, out ) \ - out = sqrtf( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); SQRT(1); - -#define IVAS_CALCULATE_RABS( re, out ) \ - out = sqrtf( re * re ); MULT(1); SQRT(1); - -#define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ - out = (float) ( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); - -#define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); DMULT(1); \ - -#define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ - out = (float) ( re * re ); MULT(1); - -#define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); MULT(1); - - -/* PCA */ -void ivas_pca_enc_init( - PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ -); - -void ivas_pca_read_bits( - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - PCA_DEC_STATE *hPCA /* i/o: PCA encoder structure */ -); - -void ivas_pca_dec_init( - PCA_DEC_STATE *hPCA /* i/o: PCA decoder structure */ -); - -void ivas_pca_dec( - PCA_DEC_STATE *hPCA, /* i/o: PCA decoder structure */ - const int16_t n_samples, /* i : output frame length */ - const int16_t n_channels, /* i : number of channels */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ - const int16_t bfi, /* i : bad frame indicator */ - float *pcm_out[] /* o : output audio channels */ -); - -void pca_dec_s3( - const int32_t index, - float *q -); - - -void ivas_huffman_encode_fx( - ivas_huffman_cfg_t *huff_cfg, - Word16 in, - Word16 *hcode, - Word16 *hlen -); - - - -ivas_error ivas_huffman_decode( - ivas_huffman_cfg_t *huff_cfg, - Decoder_State *st0, - int16_t *dec_out -); - -void ivas_arith_decode_cmplx_cell_array( - ivas_arith_t *pArith_re, - ivas_arith_t *pArith_re_diff, - Decoder_State *st0, - ivas_cell_dim_t *pCell_dims, - int16_t *pDo_diff, const int16_t nB, - int16_t *pSymbol_re, - int16_t *pSymbol_re_old -); - - - - -void ivas_ari_done_encoding_14bits( - BSTR_ENC_HANDLE hBstr, Tastat *s -); - - -void ivas_wrap_arround( - int16_t *pArr, - const int16_t min_val, - const int16_t max_val, - const int16_t length -); - -void ivas_get_cum_freq_model( - const int16_t *pFreq_model, - const int16_t length, - int16_t *pCum_freq_model -); - -int16_t ivas_map_num_pred_r_to_idx( - const int16_t num_quant_points_pred_r, - const int16_t active_w_flag -); - -int16_t ivas_map_num_drct_r_to_idx( - const int16_t num_quant_points_drct_r -); - -int16_t ivas_map_num_decd_r_to_idx( - const int16_t num_quant_points_decd_r -); - -/* Quantization utilities */ -void ivas_quantise_real_values( - const float *values, - const int16_t q_levels, - const float min_value, - const float max_value, - int16_t *index, - float *quant, - const int16_t dim -); - - -void ivas_spar_quant_dtx_init( - ivas_spar_md_t *spar_md, - float *min_max -); - -void ivas_map_prior_coeffs_quant( - ivas_spar_md_prev_t *pSpar_md_prior, - ivas_spar_md_com_cfg *pSpar_md_cfg, - const int16_t qsi, - const int16_t nB -); - - -void ivas_clear_band_coeffs( - ivas_band_coeffs_t *pband_coeffs, - const uint16_t num_bands -); - -void ivas_clear_band_coeff_idx( - ivas_band_coeffs_ind_t *pband_coeff_idx, - const uint16_t num_bands -); - - -/*----------------------------------------------------------------------------------* - * MASA prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_masa_decode( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *nb_bits_read /* o : number of bits read */ -); - -void generate_gridEq( - SPHERICAL_GRID_DATA *data /* o : data structure for grid */ -); - -ivas_error ivas_masa_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_masa_enc_close_fx( - MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ -); - -void ivas_masa_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_masa_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - -ivas_error ivas_masa_encode( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - int16_t *nb_bits_metadata, /* o : number of metadata bits written */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t Opt_DTX_ON, /* i : DTX on flag */ - const int16_t element_mode, /* i : element mode */ - const ISM_MODE ism_mode, /* i : ISM format mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ - ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata handle */ - const int16_t idx_separated_object, /* i : index of the separated object */ - OMASA_ENC_HANDLE hOMasa, /* i : OMASA encoder handle */ - const int16_t ism_imp, /* i : importance of separated object */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ -); - -void ivas_masa_estimate_energy( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - float *data_f[], /* i : Input audio channels */ - const int16_t input_frame, /* i : frame length */ - const int16_t nchan_transport /* i : number of MASA input/transport channels */ -); - - -void ivas_masa_set_elements( - const int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t mc_mode, /* i : MC format mode */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* o : element mode */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - const int16_t ivas_format, /* i : IVAS format */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int32_t ism_total_brate /* i : initial ISM total bitrate */ -); - -/*! r: valid or not 1/0 */ -int16_t valid_ratio_index( - int16_t index, /* i : index to be checked */ - const int16_t K, /* i : L1 norm to check against */ - const int16_t len /* i : vector length */ -); - -void reconstruct_ism_ratios( - int16_t *ratio_ism_idx, - const int16_t nchan_ism, - const float step, - float *q_energy_ratio_ism -); - -void distribute_evenly_ism( - int16_t *idx, - const int16_t K, - const int16_t nchan_ism -); - - -int16_t ivas_qmetadata_encode_extended_gr_length_fx( - const uint16_t value, - const uint16_t alphabet_size, - const int16_t gr_param); - -void ivas_qmetadata_encode_extended_gr_fx( - BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ - const uint16_t value, /* i : value to be encoded */ - const uint16_t alphabet_size, /* i : alphabet size */ - const int16_t gr_param); /* i : GR order */ - -/*! r: CPE bitrate value */ -int32_t calculate_cpe_brate_MASA_ISM( - const ISM_MODE ism_mode, /* i : ism mode */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism /* i : number of objects */ -); - -void ivas_merge_masa_metadata( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */ - OMASA_SPATIAL_META_HANDLE hOMasaMeta /* i : ISM-object metadata to be merged with the MASA metadata */ -); - - -/*!r : number of bits for ISM ratio index */ -int16_t bits_index_ism_ratio( - const int16_t nchan_ism /* i : number of objects */ -); - -void calculate_nbits_meta( - const int16_t nchan_ism, - float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - const int16_t numSf, - const int16_t numCodingBands, - int16_t* bits_ism, - const int16_t idx_sep_obj, - const int16_t ism_imp -); - -/*! r: limitation flag */ -int16_t calculate_brate_limit_flag( - const int16_t ism_imp[], /* i : ISM importance flags */ - const int16_t nchan_ism /* i : number of objects */ -); - -void ivas_masa_set_coding_config( - MASA_CODEC_CONFIG* config, /* i/o: MASA coding config structure */ - int16_t* band_mapping, /* o : Band mapping used */ - const int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t nchan_transport, /* i : number of transport channel (mono/stereo) */ - const uint8_t isMcMasa /* i : toggle for selecting McMASA specific config */ -); - -/*! r: Surround coherence significant flag */ -uint8_t ivas_masa_surrcoh_signicant( - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Surround coherence */ - float diffuse_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Diffuse to total ratio */ - const int16_t nSubFrames, /* i : Number of sub frames */ - const int16_t nBands /* i : Number of frequency bands */ -); - -void masa_compensate_two_dir_energy_ratio_index( - const int16_t ratio_index_1, /* i : Input ratio for direction 1 */ - const int16_t ratio_index_2, /* i : Input ratio for direction 2 */ - int16_t *ratio_index_mod1, /* o : Output modified ratio for direction 1 */ - int16_t *ratio_index_mod2, /* o : Output modified ratio for direction 2 */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -void ivas_set_qmetadata_maxbit_req_fx( - IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ - const IVAS_FORMAT ivas_format /* i : IVAS format */ -); - -void masa_sample_rate_band_correction( - MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ - int16_t *band_mapping, /* i/o: Band mapping used and modified */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ - const uint8_t maxBand, /* i : max band */ - uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ -); - -void invdct4_transform( - float *v, /* i : input vector */ - uint8_t *invdct_v /* o : transformed vector */ -); - - -void ivas_spar_param_to_masa_param_mapping( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to map */ -); - -/*---------------------------------------------------------------------------------* - * Binaural FastConv Renderer Prototypes -*-----------------------------------------------------------------------------------*/ - - -void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ -); - -void ivas_binRenderer( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ - const int16_t numTimeSlots, /* i : number of time slots to process */ - float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ -); - -void ivas_binaural_add_LFE( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t output_frame, /* i : length of input frame */ - float *input_f[], /* i : transport channels */ - float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ -); - -/*----------------------------------------------------------------------------------* - * renderer prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ism_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_ism_renderer_close( - ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ -); - -void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* i : output frame length per channel */ -); - - -void ivas_mc2sba( - IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ - float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ - float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t sba_order, /* i : SBA order */ - const float gain_lfe /* i : gain for LFE, 0=ignore LFE */ -); - -void ivas_param_mc_mc2sba_cldfb( - IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ - float *hoa_encoder, /* i : HOA3 encoder for the transported MC format */ - const int16_t slot_idx, /* i : current slot in the subframe */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - const int16_t nBands, /* i : number of synth CLDFB bands */ - const float gain_lfe /* i : gain applied to LFE */ -); - - -/*----------------------------------------------------------------------------------* - * Amplitude Panning VBAP prototypes - *----------------------------------------------------------------------------------*/ - -void panning_wrap_angles( - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - float *azi_wrapped, /* o : wrapped azimuth component */ - float *ele_wrapped /* o : wrapped elevation component */ -); - -/*----------------------------------------------------------------------------------* - * LS Renderer prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ls_setup_conversion_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_ls_setup_conversion_close( - LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */ -); - - -void ivas_ls_setup_conversion( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - const int16_t input_chans, /* i : number of input channels to the renderer */ - const int16_t output_frame, /* i : frame length */ - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ -); - -void ivas_ls_setup_conversion_process_mdct( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[] /* i/o: output synthesis signal */ -); - -void ivas_ls_setup_conversion_process_mdct_param_mc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *x[][NB_DIV] /* i/o: output synthesis signal */ -); - -void ivas_lssetupconversion_process_param_mc( - Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ - const int16_t num_timeslots, /* i : number of time slots to process */ - float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ -); - - -/*----------------------------------------------------------------------------------* - * Custom loudspeaker setup prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ls_custom_open( - LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ -); - - - -/*----------------------------------------------------------------------------------* - * McMASA prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_mcmasa_dec_reconfig( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -void ivas_mcmasa_setNumTransportChannels( - int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */ - int16_t* element_mode, /* o : Pointer to element mode to be set */ - const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ -); - -void ivas_mcmasa_set_separate_channel_mode( - uint8_t *separateChannelEnabled, /* o : Pointer to separate channel toggle */ - int16_t *separateChannelIndex, /* o : Pointer to separate channel index */ - const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ -); - -void ivas_mcmasa_split_brate( - const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */ - const int32_t ivas_total_brate, /* i : Total bitrate available to be split */ - const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */ - const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */ - int32_t *brate_sce, /* o : Pointer to SCE element bitrate */ - int32_t *brate_cpe /* o : Pointer to CPE element bitrate */ -); - - -void ivas_mcmasa_dmx_modify_fx( - const Word16 n_samples, /* i : input frame length in samples */ - Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ - Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ - const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ - const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ -); - -ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ -); - -void ivas_mono_downmix_render_passive( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ - const int16_t output_frame /* i : output frame length */ -); - - -/*----------------------------------------------------------------------------------* - * LFE encoder low pass filter prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_create_lfe_lpf_enc( - ivas_filters_process_state_t **hLfeLpf, /* o : LFE LPF handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_lfe_lpf_enc_close_fx( - ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */ -); - -void ivas_lfe_lpf_enc_apply( - ivas_filters_process_state_t *hLfeLpf, /* i/o: LFE LPF handle */ - float data_lfe_ch[], /* i/o: LFE signal */ - const int16_t input_frame /* i : input frame length per channel */ -); - - -/*----------------------------------------------------------------------------------* - * LFE Coding prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_create_lfe_enc_fx( - LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_lfe_enc_close_fx( - LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ -); - -void ivas_lfe_enc( - LFE_ENC_HANDLE hLFE, /* i/o: LFE encoder handle */ - float data_lfe_ch[], /* i : input LFE signal */ - const int16_t input_frame, /* i : input frame length per channel */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - -void ivas_lfe_tdplc( - LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ - float *prevsynth, /* i : previous frame synthesis */ - float *ytda, /* o : output time-domain buffer */ - const int16_t output_frame /* i : output frame length */ -); -void ivas_lfe_window_init( - LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ - const int32_t sampling_rate, /* i : sampling rate */ - const int16_t frame_len /* i : frame length in samples */ -); - -void ivas_lfe_lpf_select_filt_coeff( - const int32_t sampling_rate, /* i : sampling rate */ - const int16_t order, /* i : filter order */ - const float **ppFilt_coeff /* o : filter coefficients */ -); - -void ivas_filters_init( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const float *filt_coeff, /* i : filter coefficients */ - const int16_t order /* i : filter order */ -); - -void ivas_filters_init_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ - const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ - const Word16 order ) ; - -void ivas_filter_process( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - float *pIn_Out, /* i : signal subject to filtering */ - const int16_t length /* i : filter order */ -); - -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q_factor ); - -/*----------------------------------------------------------------------------------* - * OSBA prototypes - *----------------------------------------------------------------------------------*/ -ivas_error ivas_osba_enc_reconfig( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); -ivas_error ivas_osba_data_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - - -void ivas_osba_data_close( - SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ -); - - -/*----------------------------------------------------------------------------------* -* OMASA prototypes -*---------------------------------------------------------------------------------*/ - -ivas_error ivas_omasa_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_omasa_enc_close( - OMASA_ENC_HANDLE *hOMasa /* i/o: encoder OMASA handle */ -); - - -ivas_error ivas_omasa_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - - - - -void ivas_set_surplus_brate_enc( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -#ifdef DEBUG_MODE_INFO - , - const int16_t *nb_bits_metadata /* i : number of metadata bits */ -#endif -); - -void ivas_set_surplus_brate_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int32_t *ism_total_brate /* i : ISM total bitrate */ -); - - -void ivas_set_ism_importance_interformat( - const int32_t ism_total_brate, /* i/o: ISms total bitrate */ - const int16_t nchan_transport, /* i : number of transported channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ - const float lp_noise_CPE, /* i : LP filtered total noise estimation */ - int16_t ism_imp[] /* o : ISM importance flags */ -); - - -/*! r: adjusted bitrate */ -int32_t ivas_interformat_brate( - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t ism_imp, /* i : ISM importance flag */ - const int16_t limit_flag /* i : flag to limit the bitrate increase */ -); - -void ivas_combined_format_brate_sanity( - const int32_t element_brate, /* i : element bitrate */ - const int16_t core, /* i : core */ - const int32_t total_brate, /* i : total bitrate */ - int32_t *core_brate, /* i/o: core bitrate */ - int16_t *inactive_coder_type_flag, /* o : inactive coder_type flag */ - int16_t *diff_nBits /* o : number of differential bits */ -); - -ISM_MODE ivas_omasa_ism_mode_select( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism /* i : number of input ISM's */ -); - -void ivas_set_omasa_TC( - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t nchan_ism, /* i : number of input ISMs */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE /* o : number of CPEs */ -); - -void ivas_merge_masa_transports( - float data_in_f1[][L_FRAME48k], /* i : Transport audio signals 1 */ - float *data_in_f2[], /* i : Transport audio signals 2 */ - float *data_out_f[], /* o : Merged transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t num_transport_channels /* i : Number of transport audio signals */ -); - - -ivas_error ivas_omasa_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t *nchan_transport_ism, /* o : number of ISM TCs */ - const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ -); - -void ivas_omasa_preProcessStereoTransportsForMovedObjects( - Decoder_Struct *st_ivas, - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const int16_t nBins, - const int16_t subframe -); - -ivas_error ivas_omasa_separate_object_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_omasa_separate_object_renderer_close( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ - float input_f[][L_FRAME48k], /* i : separated object signal */ - float *output_f[], /* o : rendered time signal */ - const int16_t subframes_rendered, /* i : number of subframes rendered */ - const int16_t slots_rendered /* i : number of CLDFB slots rendered */ -); - -void ivas_omasa_encode_masa_to_total( - float masa_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - BSTR_ENC_HANDLE hMetaData, - const int16_t low_bitrate_mode, - const int16_t nbands, - const int16_t nblocks -); - -void ivas_omasa_decode_masa_to_total( - uint16_t *bit_stream, - int16_t *index, - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - const int16_t nbands, - const int16_t nblocks -); - -void ivas_omasa_modify_masa_energy_ratios( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] -); - - -/*----------------------------------------------------------------------------------* - * TD Binaural Object renderer - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_td_binaural_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ -); - -ivas_error ivas_td_binaural_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ -); - -/*----------------------------------------------------------------------------------* - * Filter-bank (FB) Mixer - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_fb_set_cfg( - IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ - const int16_t ivas_format, /* i : IVAS format */ - const int16_t num_in_chans, /* i : number of FB input channels */ - const int16_t num_out_chans, /* i : number of FB output channels */ - const int16_t active_w_mixing, /* i : active_w_mixing flag */ - const int32_t sampling_Fs, /* i : sampling rate */ - const int16_t nachan_dirac_ana /* i : number of DirAR analysis channels */ -); - -void ivas_fb_mixer_pcm_ingest( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - float **ppOut_pcm, /* o : output audio channels */ - const int16_t frame_length, /* i : frame length */ - const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] -); - -void ivas_fb_mixer_update_prior_input( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - const int16_t length, /* i : length of time slot */ - const int16_t nchan_fb_in /* i : number of analysis channels */ -); - -void ivas_fb_mixer_get_windowed_fr( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - float *frame_f_real[], /* o : real freq domain values */ - float *frame_f_imag[], /* o : imag freq domain values */ - const int16_t length, /* i : number of new samples in time slot */ - const int16_t mdft_len, /* i : MDFT frame length */ - const int16_t nchan_fb_in /* i : number of analysis channels */ -); - -/*! r: number of spectral bands */ - -/* clang-format on */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 8527e6703..85fefadbc 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 422622552..7c7d49381 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1ab797ded..292721723 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -35,7 +35,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 643874a82..44b7a0bec 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 3aed4d3b1..24e61c5f3 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -34,7 +34,7 @@ #include #include #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 7cd93affa..2535eb6ee 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -35,7 +35,7 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "rom_com.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 210425b88..fdf18e705 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -37,7 +37,7 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 384865a1a..dec4d3465 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -35,7 +35,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 697ae6345..ff895755d 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -37,7 +37,7 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" @@ -1656,7 +1656,7 @@ void ivas_param_mc_dec_digest_tc_fx( test(); IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; } IF( is_next_band ) { @@ -1697,7 +1697,7 @@ void ivas_param_mc_dec_digest_tc_fx( test(); IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; } /* Cx for transport channels */ IF( is_next_band ) @@ -1794,7 +1794,7 @@ void ivas_param_mc_dec_digest_tc_fx( test(); IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; } IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 3c2ba7587..762b350d1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index 1b1715c21..d12b190c6 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index fe39fd8e3..b42eb534b 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -88,9 +88,9 @@ void ivas_mct_side_bits_fx( FOR( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } mdct_read_IGF_bits_fx( st, st0 ); @@ -231,7 +231,7 @@ void ivas_mct_core_dec( { IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } i = add( i, 1 ); } @@ -258,15 +258,15 @@ void ivas_mct_core_dec( { st = sts[ch]; - if ( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) /*indicates LFE */ + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) /*indicates LFE */ { - continue; + CONTINUE; } test(); - if ( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ + IF( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ { - continue; + CONTINUE; } IF( EQ_16( st->core, TCX_10_CORE ) ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 884a44c9e..abf735b5a 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -38,7 +38,7 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 35d38d03a..151ba7d1e 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1549,7 +1549,7 @@ void ivas_mdct_core_tns_ns_fx( } /* nothing to do for missing LFE */ - continue; + CONTINUE; } FOR( k = 0; k < nSubframes[ch]; k++ ) diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index b88b68915..79683e402 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index afa604684..9975493fb 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -35,7 +35,7 @@ #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 6f1a233c9..b048470d4 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -34,7 +34,7 @@ #include #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 84b6fe46d..c7bf0655d 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -35,7 +35,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index f04350366..eb2a40ecb 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 8748342ed..bbe63e965 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include @@ -319,7 +319,7 @@ Word16 ivas_sba_remapTCs_fx( Copy32( sba_data_fx[2], sba_data_fx[3], output_frame ); /*Q11*/ } } - IF( GT_16( st_ivas->nchan_transport, 3 ) ) + IF( GE_16( st_ivas->nchan_transport, 3 ) ) { Word16 i = 0; move16(); diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index fd25e7ea7..3bc6d337e 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -372,7 +372,7 @@ void dequantize_sns_fx( IF( zero_side_flag[k] ) { set32_fx( snsQ_fx, 0, M ); - continue; + CONTINUE; } nStages = SNS_MSVQ_NSTAGES_SIDE; diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 34a194898..c6c7565a9 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -37,7 +37,7 @@ #include "ivas_stat_dec.h" #include "prot_fx.h" #include "string.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ef3baee3c..dc06ddc5a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -35,7 +35,7 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 7c28c3309..e6fc25e36 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5401,7 +5401,7 @@ void TNSAnalysisStereo_fx( st = sts[ch]; IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } hTcxEnc = st->hTcxEnc; diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 6623cfd45..9256be408 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -476,7 +476,7 @@ void ivas_ism_coh_estim_dtx_enc_fx( { hISMDTX->coh_fx[sce_id] = 32767; /* 1 in Q15 */ move16(); - continue; + CONTINUE; } st = hSCE[sce_id]->hCoreCoder[0]; diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 3272768e9..9027b2669 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2543,7 +2543,7 @@ void ivas_mdct_quant_coder_fx( { ignore_chan[ch] = 1; move16(); - continue; + CONTINUE; } IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) @@ -2615,7 +2615,7 @@ void ivas_mdct_quant_coder_fx( IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } FOR( n = 0; n < nSubframes; n++ ) @@ -2646,7 +2646,7 @@ void ivas_mdct_quant_coder_fx( IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } FOR( n = 0; n < nSubframes; n++ ) @@ -2730,9 +2730,9 @@ void ivas_mdct_quant_coder_fx( * Generate Bitstream *---------------------------------------------------------------*/ - if ( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } nbits_start = st->hBstr->nb_bits_tot; move16(); diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 93ee56461..dfd207c3e 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -680,7 +680,7 @@ Word16 quantize_sns_fx( IF( zero_side_flag[k] ) { set32_fx( snsQ_fx, 0, M ); - continue; + CONTINUE; } nStages = SNS_MSVQ_NSTAGES_SIDE; diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index b1a3f2f20..44f415dc7 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -586,7 +586,7 @@ void swb_bwe_enc_ivas_fx( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, - SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_exp, Q_synth ); + SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_exp, new_input_fx_exp ); } ELSE { @@ -3456,11 +3456,12 @@ static Word16 SWB_BWE_encoding_ivas_fx( global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ - Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, 0 ); - mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( Q_synth, Q16 ), Q_shb, st_fx ); + scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); + Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); + mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( add( Q_synth, scale ), Q16 ), Q_shb, st_fx ); push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); - energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( Q_synth_lf, Q16 ) ); + energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 770b62764..5023bee34 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -36,7 +36,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index e50ad32e1..36d18f859 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 1a5013059..8124c4967 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0deb14c9b..65a68889a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -35,7 +35,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index b8b3c3ac7..1ffe0da74 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index e9af8483a..80adebfdd 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 40ed0ad58..6cf11887e 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 35fedfc81..031a39855 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 7a74e62da..543decbdd 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -36,7 +36,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index e3965fbff..93f9fbd83 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_limiter_fx.c b/lib_rend/ivas_limiter_fx.c index b66127e09..b212e5445 100644 --- a/lib_rend/ivas_limiter_fx.c +++ b/lib_rend/ivas_limiter_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" #include diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index c74477365..fd20a9fab 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "lib_rend.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index e17b2f9f6..f3b4d1755 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -35,7 +35,7 @@ #include #include "ivas_cnst.h" #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 7b1e1fe91..1b5bc0d1b 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index a7f46b2a4..01e35efe1 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "prot_fx.h" #include -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 7ee6c828b..0e61282d4 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 971e2c2d1..210706d5b 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 307d38351..5787ded3f 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index 4d259a68e..0d8c11aab 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" @@ -87,28 +87,6 @@ Word32 TDREND_SPATIAL_VecNorm_fx( return tmp; } - -/*-------------------------------------------------------------------* - * TDREND_SPATIAL_VecNormalize() - * - * Normalize vector to unit norm - *-------------------------------------------------------------------*/ - -void TDREND_SPATIAL_VecNormalize( - const float *Vec_p, /* i : Input vector */ - float *VecNorm_p /* o : Output vector */ -) -{ - float scaler; - - scaler = inv_sqrt( Vec_p[0] * Vec_p[0] + Vec_p[1] * Vec_p[1] + Vec_p[2] * Vec_p[2] ); - VecNorm_p[0] = scaler * Vec_p[0]; - VecNorm_p[1] = scaler * Vec_p[1]; - VecNorm_p[2] = scaler * Vec_p[2]; - - return; -} - void TDREND_SPATIAL_VecNormalize_fx( const Word32 *Vec_p_fx, /* i : Input vector q */ Word16 q, /* i : Input vector Q-factor */ @@ -172,25 +150,6 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem_fx( return; } -void TDREND_SPATIAL_VecMapToNewCoordSystem( - const float *Vec_p, /* i : Input vector */ - const float *TranslVec_p, /* i : Translation vector */ - const float *DirVec_p, /* i : Direction vector */ - const float *UpVec_p, /* i : Up vector */ - const float *RightVec_p, /* i : Right vector */ - float *MappedVec_p, /* o : Transformed vector */ - float *LisRelPosAbs /* o : Transformed vector ignoring orientation */ -) -{ - v_sub( Vec_p, TranslVec_p, LisRelPosAbs, 3 ); - /* Evalute the relative Vec in the coordinates of the Orientation vectors, */ - /* which form an orthonormal basis */ - MappedVec_p[0] = dotp( LisRelPosAbs, DirVec_p, 3 ); - MappedVec_p[1] = dotp( LisRelPosAbs, RightVec_p, 3 ); - MappedVec_p[2] = dotp( LisRelPosAbs, UpVec_p, 3 ); - return; -} - /*-------------------------------------------------------------------* * TDREND_SPATIAL_EvalOrthonormOrient() * diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 5e175fae5..ba632c6ba 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -34,7 +34,7 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index a124bf4bd..a25a8db53 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -33,7 +33,7 @@ #include "common_api_types.h" #include #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include #include diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 6fba496d5..9945d630e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -34,7 +34,7 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 74be74497..8beb5a0ec 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -1,6 +1,6 @@ #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #ifdef FIX_DISCLAIMER #include #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend_fx.h similarity index 69% rename from lib_rend/ivas_prot_rend.h rename to lib_rend/ivas_prot_rend_fx.h index b642e05d7..04afce118 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -93,25 +93,6 @@ ivas_error get_channel_config( * Limiter prototypes *----------------------------------------------------------------------------------*/ - -ivas_error ivas_limiter_open( - IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ -); - -void ivas_limiter_close( - IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ -); - -void ivas_limiter_dec -( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ -); void ivas_limiter_dec_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ @@ -120,13 +101,7 @@ void ivas_limiter_dec_fx( const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor /* i : Q factor of the output samples */ ); -void limiter_process( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const float threshold, /* i : signal amplitude above which limiting starts to be applied */ - const int16_t BER_detect, /* i : BER detect flag */ - int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ -); + void limiter_process_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ const Word16 output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ @@ -140,9 +115,9 @@ void limiter_process_fx( *----------------------------------------------------------------------------------*/ ivas_error ivas_td_decorr_dec_open_fx( ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t nchan_internal, /* i : number of internal channels */ - const int16_t ducking_flag /* i : ducking flag */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_internal, /* i : number of internal channels */ + const Word16 ducking_flag /* i : ducking flag */ ); void ivas_td_decorr_dec_close( ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */ @@ -179,9 +154,6 @@ ivas_error efap_init_data_fx( const Word16 num_speaker_nodes, /* i : number of speaker nodes in the set */ const Word16 efap_mode /* i : indicates whether EFAP or EFIP is used */ ); -void efap_free_data( - EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */ -); void efap_determine_gains_fx( EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ @@ -224,14 +196,7 @@ void ivas_sba_prototype_renderer_fx( Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ Word16 q_cldfb[6][CLDFB_SLOTS_PER_SUBFRAME], - const int16_t subframe /* i : Subframe to render */ -); - -void ivas_sba_prototype_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to render */ + const Word16 subframe /* i : Subframe to render */ ); ivas_error ivas_sba_get_hoa_dec_matrix_fx( @@ -244,11 +209,7 @@ void ivas_dirac_dec_binaural_sba_gain_fx( const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ const Word16 output_frame /* i : output frame length */ ); -void ivas_dirac_dec_binaural_sba_gain( - float *output[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame /* i : output frame length */ -); + void ivas_dirac_dec_binaural_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -274,11 +235,6 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ); -ivas_error ivas_dirac_dec_binaural_copy_hrtfs( - HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ -); - - ivas_error ivas_dirac_alloc_mem_fx( DIRAC_REND_HANDLE hDirACRend, const RENDERER_TYPE renderer_type, @@ -286,20 +242,6 @@ ivas_error ivas_dirac_alloc_mem_fx( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem, const Word16 hodirac_flag); -void ivas_dirac_free_mem( - DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem -); - -void initDiffuseResponses( - float *diffuse_response_function, - const int16_t num_channels, - const AUDIO_CONFIG output_config, - const IVAS_OUTPUT_SETUP hOutSetup, - const int16_t ambisonics_order, - const IVAS_FORMAT ivas_format, - int16_t *num_ele_spk_no_diffuse_rendering, - const AUDIO_CONFIG transport_config -); void ivas_dirac_free_mem_fx( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ); @@ -341,18 +283,6 @@ void protoSignalComputation_shd_fx( Word32 *p_Rmat_fx, /* Q30 */ Word16 q_cldfb ); -void protoSignalComputation_shd( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_direct_buffer_f, - float *proto_diffuse_buffer_f, - float *reference_power, - const int16_t slot_index, - const int16_t num_inputs, - const int16_t num_outputs_diff, - const int16_t num_freq_bands, - float *p_Rmat -); void protoSignalComputation1_fx( Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ @@ -370,17 +300,6 @@ void protoSignalComputation1_fx( const Word16 num_freq_bands, Word16 q_cldfb ); -void protoSignalComputation1( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_frame_f, - float *proto_direct_buffer_f, - float *reference_power, - float *proto_power_smooth, - const int16_t slot_index, - const int16_t num_outputs_diff, - const int16_t num_freq_bands -); void protoSignalComputation2_fx( Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ @@ -399,18 +318,6 @@ void protoSignalComputation2_fx( MASA_STEREO_TYPE_DETECT *stereo_type_detect, Word16 q_cldfb ); -void protoSignalComputation2( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_frame_f, - float *proto_direct_buffer_f, - float *reference_power, - float *proto_power_smooth, - const int16_t isloudspeaker, - const int16_t slot_index, - const int16_t num_freq_bands, - MASA_STEREO_TYPE_DETECT *stereo_type_detect -); void protoSignalComputation4_fx( Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ @@ -432,11 +339,6 @@ void protoSignalComputation4_fx( Word16 q_cldfb ); -void ivas_dirac_dec_compute_diffuse_proto( - DIRAC_REND_HANDLE hDirACRend, - const int16_t num_freq_bands, - const int16_t slot_idx -); void ivas_dirac_dec_compute_diffuse_proto_fx( DIRAC_REND_HANDLE hDirACRend, const Word16 num_freq_bands, @@ -453,10 +355,6 @@ void computeDirectionAngles_fx( Word16 *elevation ); -void ivas_masa_init_stereotype_detection( - MASA_STEREO_TYPE_DETECT *stereo_type_detect -); - void ivas_masa_init_stereotype_detection_fx( MASA_STEREO_TYPE_DETECT *stereo_type_detect ); @@ -464,9 +362,6 @@ void ivas_masa_init_stereotype_detection_fx( void ivas_masa_stereotype_detection_fx( MASA_STEREO_TYPE_DETECT *stereo_type_detect ); -void ivas_masa_stereotype_detection( - MASA_STEREO_TYPE_DETECT *stereo_type_detect -); void ivas_lfe_synth_with_cldfb_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, @@ -487,21 +382,6 @@ void rotateAziEle_DirAC_fx( const Word16 band2, /* i : bands to work on (upper bound) */ const Word32 *p_Rmat_fx /* i : pointer to real-space rotation matrix q30*/ ); -void rotateAziEle_DirAC( - int16_t *azi, - int16_t *ele, - const int16_t band1, - const int16_t band2, - const float *p_Rmat -); - -ivas_error ivas_dirac_dec_onset_detection_open( - const int16_t num_channels, - const int16_t num_freq_bands, - const int16_t max_band_decorr, - DIRAC_ONSET_DETECTION_PARAMS *ph_dirac_onset_detection_params, - DIRAC_ONSET_DETECTION_STATE *ph_dirac_onset_detection_state -); ivas_error ivas_dirac_dec_onset_detection_open_fx( const Word16 num_protos_diff, //Q0 @@ -522,14 +402,6 @@ ivas_error ivas_dirac_dec_decorr_open_fx( const Word32 output_Fs /* i : output sampling rate */ ); -void ivas_dirac_dec_onset_detection_process( - const float *input_power_f, - float *onset_filter, - const int16_t num_protos_diff, - DIRAC_ONSET_DETECTION_PARAMS h_dirac_onset_detection_params, - DIRAC_ONSET_DETECTION_STATE h_dirac_onset_detection_state -); - void ivas_dirac_dec_onset_detection_process_fx( const Word32 *input_power_f, /* Q(0) */ Word32 *onset_filter, /* Q(0) */ @@ -538,33 +410,6 @@ void ivas_dirac_dec_onset_detection_process_fx( DIRAC_ONSET_DETECTION_STATE h_dirac_onset_detection_state ); -ivas_error ivas_dirac_dec_decorr_open( - DIRAC_DECORR_PARAMS **ph_freq_domain_decorr_ap_params, - DIRAC_DECORR_STATE **ph_freq_domain_decorr_ap_state, - const int16_t num_freq_bands, - int16_t num_outputs_diff, - const int16_t num_protos_diff, - const DIRAC_SYNTHESIS_CONFIG synthesisConf, - float *frequency_axis, - const int16_t nchan_transport, /* i : number of transport channels */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void ivas_dirac_dec_decorr_process( - const int16_t num_freq_bands, - int16_t num_channels, - const int16_t num_protos_diff, - const DIRAC_SYNTHESIS_CONFIG synthesisConf, - const int16_t nchan_transport, /* i : number of transport channels */ - const float *input_frame_f, - const int16_t num_protos_dir, - const int16_t *proto_index_dir, - float *frame_dec_f, - float *onset_filter, - HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params, - HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state -); - void ivas_dirac_dec_decorr_process_fx( const Word16 num_freq_bands, Word16 num_channels, @@ -582,32 +427,11 @@ void ivas_dirac_dec_decorr_process_fx( HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state ); -void ivas_dirac_dec_decorr_close( - HANDLE_DIRAC_DECORR_PARAMS *ph_dirac_decorr_params, - HANDLE_DIRAC_DECORR_STATE *ph_dirac_decorr_state -); void ivas_dirac_dec_decorr_close_fx( HANDLE_DIRAC_DECORR_PARAMS *ph_dirac_decorr_params, HANDLE_DIRAC_DECORR_STATE *ph_dirac_decorr_state ); - -ivas_error ivas_dirac_dec_output_synthesis_open( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -void ivas_dirac_dec_output_synthesis_init( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t nchan_out_woLFE, /* i : number of output audio channels without LFE */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - ivas_error ivas_dirac_dec_output_synthesis_open_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ @@ -627,9 +451,7 @@ void ivas_dirac_dec_output_synthesis_init_fx( void ivas_dirac_dec_output_synthesis_close_fx( DIRAC_REND_HANDLE hDirACRend /* i/o: DirAC handle */ ); -void ivas_dirac_dec_output_synthesis_close( - DIRAC_REND_HANDLE hDirACRend /* i/o: DirAC handle */ -); + void ivas_dirac_dec_output_synthesis_process_slot_fx( const Word32 *reference_power, /* i : Estimated power */ const Word16 q_reference_power, /* i : Estimated power */ @@ -648,23 +470,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( const Word16 md_idx, const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ const Word16 dec_param_estim); -void ivas_dirac_dec_output_synthesis_process_slot( - const float *reference_power, /* i : Estimated power */ - const float *onset, /* i : onset filter */ - const int16_t *azimuth, - const int16_t *elevation, - const float *diffuseness, - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t sh_rot_max_order, - const float *p_Rmat, /* i : rotation matrix */ - const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ - const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t ind_slot, /* i : index of the slot to be added to the input covariance */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - const int16_t dec_param_estim /* i : flag to indicate parameter estimation mode */ -); void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ @@ -681,19 +486,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Word16 *q_cy_auto_diff_smooth_prev ); -void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nbslots, /* i : number of slots to process */ - const float *onset_filter, - float *diffuseness, - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - const int16_t dec_param_estim /* i : flag to indicate parameter estimation mode */ -); - void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ Word32 ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ @@ -708,25 +500,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word16 *q_Cldfb ); -void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t nbslots, /* i : number of slots to process */ - float *diffuseness_vector, /* i : diffuseness (needed for direction smoothing)*/ - float *reference_power_smooth, - float qualityBasedSmFactor, - const int16_t enc_param_start_band -); - -void compute_hoa_encoder_mtx( - const float *azimuth, - const float *elevation, - float *response, - const int16_t num_responses, - const int16_t ambisonics_order ); - void compute_hoa_encoder_mtx_fx( const Word32 *azimuth, /*q22*/ const Word32 *elevation, /*q22*/ @@ -751,21 +524,6 @@ void ivas_dirac_dec_compute_power_factors_fx( Word32 *diffuse_power_factor ); -void ivas_dirac_dec_compute_directional_responses( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ - const int16_t *masa_band_mapping, /* i : Band mapping for MASA, NULL assumes not using MASA in any form */ - MASA_ISM_DATA_HANDLE hMasaIsm, /* i : MASA_ISM data structure */ - const int16_t *azimuth, - const int16_t *elevation, - const int16_t md_idx, - const float *surCohRatio, - const int16_t shd_rot_max_order, /* i : split-order rotation method */ - const float *p_Rmat, /* i : rotation matrix */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - void ivas_dirac_dec_compute_directional_responses_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ @@ -782,36 +540,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ); -void ivas_dirac_dec_get_frequency_axis( - float *frequency_axis, /* o : array of center frequencies of a real filter bank */ - const int32_t output_Fs, /* i : sampling frequency */ - const int16_t num_freq_bands /* i : number of frequency bands */ -); - -ivas_error ivas_spat_hSpatParamRendCom_config( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ - const int16_t dec_param_estim_flag, - const IVAS_FORMAT ivas_format, - const MC_MODE mc_mode, - const int32_t output_Fs, - const int16_t hodirac_flag, - const int16_t masa_ext_rend_flag -); - -void ivas_spat_hSpatParamRendCom_close( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out -); - -void ivas_dirac_rend_close( - DIRAC_REND_HANDLE *hDirACRend_out -); - -ivas_error ivas_dirac_allocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ -); - void ivas_dirac_rend_close_fx( DIRAC_REND_HANDLE *hDirACRend_out ); @@ -833,18 +561,14 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( ivas_error ivas_dirac_allocate_parameters_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + const Word16 params_flag /* i : set of parameters flag */ ); void ivas_dirac_deallocate_parameters_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + const Word16 params_flag /* i : set of parameters flag */ ); -void ivas_dirac_deallocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ -); void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ Word32 *output_f[], /* i/o: input/output signals in time domain q11*/ @@ -862,11 +586,6 @@ void ivas_HRTF_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); -ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ -); - - ivas_error ivas_HRTF_fastconv_binary_open_fx( HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); @@ -910,33 +629,6 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( const Word16 num_subframes /* i : number of subframes to render */ ); -ivas_error ivas_td_binaural_renderer_unwrap( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG transport_config, /* i : Transport configuration */ - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ - const int16_t num_src, /* i : number of sources to render */ - const int16_t lfe_idx, /* i : LFE channel index */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ - const int16_t ism_md_subframe_update, - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_subframes /* i : number of subframes to render */ -); - -ivas_error ivas_td_binaural_renderer_ext( - const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ - const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ - const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i : Combined head and external orientations */ - const IVAS_ISM_METADATA *currentPos, /* i : Object position */ - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const int16_t ism_md_subframe_update_ext, /* i : Metadata Delay in subframes to sync with audio delay */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t output_frame, /* i : output frame length */ - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ -); ivas_error ivas_td_binaural_renderer_ext_fx( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ @@ -964,24 +656,12 @@ ivas_error ivas_td_binaural_open_unwrap_fx( Word16 *SrcInd ); -ivas_error ivas_td_binaural_open_unwrap( - TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */ - const int32_t output_Fs, /* i : Output sampling rate */ - const int16_t nchan_transport, /* i : Number of channels */ - const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ - const AUDIO_CONFIG transport_config, /* i : Transport configuration */ - const float *directivity, /* i : Directivity pattern (used for ISM) */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ - BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ - int32_t *binaural_latency_ns /* i : Binauralization delay */ -); - ivas_error ivas_td_binaural_open_ext_fx( TDREND_WRAPPER *pTDRend, const AUDIO_CONFIG inConfig, RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t output_Fs, + const Word32 output_Fs, Word16 *SrcInd, Word16 *num_src ); @@ -990,17 +670,6 @@ void ivas_td_binaural_close_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ ); -void ivas_td_binaural_close( - BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ -); - -ivas_error TDREND_GetMix( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - float *output[], /* i/o: ISM object synth/rendered output in 0,1 */ - const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ - const int16_t ism_md_subframe_update /* i : Number of subframes to delay metadata to sync with audio */ -); ivas_error TDREND_GetMix_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ Word32 *output[], /* i/o: ISM object synth / rendered output in 0,1 */ @@ -1009,13 +678,6 @@ ivas_error TDREND_GetMix_fx( const Word16 ism_md_subframe_update /* i : Number of subframes to delay ism metadata to sync with audio */ ); - -ivas_error TDREND_Update_object_positions( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ - const int16_t num_src, /* i : number of sources to render */ - const IVAS_FORMAT in_format, /* i : Format of input sources */ - const ISM_METADATA_HANDLE *hIsmMetaData /* i : Input metadata for ISM objects */ -); void BSplineModelEvalDealloc_fx( ModelParams_t *model, /* i : Model parameters */ ModelEval_t *modelEval /* i : Model evaluation structure */ @@ -1057,16 +719,7 @@ ivas_error TDREND_MIX_SRC_SetPos_fx( const Word16 SrcInd, /* i : Source index */ const Word32 *Vec_p /* i : Position vector */ ); -ivas_error TDREND_MIX_SRC_SetPos( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float *Vec_p /* i : Position vector */ -); -ivas_error TDREND_MIX_SRC_SetDir( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float *Vec_p /* i : Direction vector */ -); + ivas_error TDREND_MIX_SRC_SetDir_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word16 SrcInd, /* i : Source index */ @@ -1116,19 +769,8 @@ void TDREND_SRC_Init_fx( TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ const TDREND_PosType_t PosType /* i : Position type specifier */ ); -void TDREND_SRC_Init( - TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ - const TDREND_PosType_t PosType /* i : Position type specifier */ -); /* ----- Object renderer - vec ----- */ - -void TDREND_SPATIAL_VecInit( - float *Pos_p, /* o : Output vector */ - const float PosX, /* i : X value */ - const float PosY, /* i : Y value */ - const float PosZ /* i : Z value */ -); void TDREND_SPATIAL_VecInit_fx( Word32 *Pos_p, /* o : Output vector */ const Word32 PosX, /* i : X value */ @@ -1144,21 +786,6 @@ void TDREND_SPATIAL_VecNormalize_fx( Word32 *VecNorm_p_fx /* o : Normalised output vector Q30 */ ); -void TDREND_SPATIAL_VecNormalize( - const float *Vec_p, /* i : Input vector */ - float *VecNorm_p /* o : Output vector */ -); - -void TDREND_SPATIAL_VecMapToNewCoordSystem( - const float *Vec_p, /* i : Input vector */ - const float *TranslVec_p, /* i : Translation vector */ - const float *DirVec_p, /* i : Direction vector */ - const float *UpVec_p, /* i : Up vector */ - const float *RightVec_p, /* i : Right vector */ - float *MappedVec_p, /* o : Transformed vector */ - float *LisRelPosAbs /* o : Transformed vector ignoring orientation */ -); - Word16 TDREND_SPATIAL_EvalOrthonormOrient_fx( Word32 *FrontVecON_p_fx, /* i/o: Normalized front vector Q30 */ Word32 *UpVecON_p_fx, /* i/o: Normalized up vector Q30 */ @@ -1167,14 +794,6 @@ Word16 TDREND_SPATIAL_EvalOrthonormOrient_fx( const Word32 *UpVec_p_fx, /* i : Input up vector orient_q */ const Word16 orient_q /* i : Input up Q-factor */ ); -/*! r: Flag if the orientation has been updated */ -int16_t TDREND_SPATIAL_EvalOrthonormOrient( - float *FrontVecON_p, /* o : Normalized front vector */ - float *UpVecON_p, /* o : Normalized up vector */ - float *RightVecON_p, /* o : Normalized right vector */ - const float *FrontVec_p, /* i : Input front vector */ - const float *UpVec_p /* i : Input up vector */ -); /* ----- Object renderer - mix ----- */ @@ -1183,11 +802,6 @@ ivas_error TDREND_MIX_AddSrc_fx( Word16 *SrcInd, /* o : Source index */ const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ ); -ivas_error TDREND_MIX_AddSrc( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - int16_t *SrcInd, /* o : Source index */ - const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ -); ivas_error TDREND_MIX_SetDistAttenModel( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ @@ -1198,35 +812,15 @@ void TDREND_MIX_Dealloc_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ ); -void TDREND_MIX_Dealloc( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ -); - ivas_error TDREND_MIX_Init_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ const Word32 output_Fs /* i : Output sampling rate */ ); -ivas_error TDREND_MIX_Init( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ - const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ - const int32_t output_Fs /* i : Output sampling rate */ -); /* ----- Object renderer - sfx ----- */ -void TDREND_Apply_ITD( - float *input, /* i : Input SCE subframe to be time adjusted */ - float *out_left, /* o : Output left channels with ITD applied */ - float *out_right, /* o : Output right channels with ITD applied */ - int16_t *previtd, /* i/o: Previous ITD value */ - const int16_t itd, /* i : Current subframe ITD value */ - float *mem_itd, /* i/o: ITD buffer memory */ - const int16_t length /* i : Subframe length */ -); - void TDREND_Apply_ITD_fx( Word32 *input_fx, /* i : Input subframe to be time adjusted Qx */ Word32 *out_left_fx, /* o : Output left channel with ITD applied Qx */ @@ -1319,10 +913,10 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( ivas_error ivas_binaural_reverb_open_parambin( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const int16_t numBins, /* i : number of CLDFB bins Q0 */ - const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ + const Word16 numBins, /* i : number of CLDFB bins Q0 */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const int32_t sampling_rate, /* i : sampling rate Q0 */ + const Word32 sampling_rate, /* i : sampling rate Q0 */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ); @@ -1333,16 +927,6 @@ void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ); -void ivas_binaural_reverb_processSubframe( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int16_t numInChannels, /* i : num input channels to be processed*/ - const int16_t numSlots, /* i : number of slots to be processed */ - float inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */ - float inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ - float outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ - float outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ -); - void ivas_binaural_reverb_processSubframe_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word16 numInChannels, /* i : num inputs to be processed */ @@ -1373,14 +957,7 @@ ivas_error ivas_reverb_process_fx( Word32 *pcm_out[], /* o : the PCM audio with reverb applied */ const Word16 i_ts /* i : (Q0) subframe index */ ); -ivas_error ivas_reverb_process( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const int16_t mix_signals, /* i : add reverb to output signal */ - float *pcm_in[], /* i : the PCM audio to apply reverb on */ - float *pcm_out[], /* o : the PCM audio with reverb applied */ - const int16_t i_ts /* i : subframe index */ -); + void ivas_rev_delay_line_init( ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ Word32 *memory_buffer, /* i : the memory buffer to use for the delay line Q11 */ @@ -1410,7 +987,7 @@ void ivas_rev_delay_line_feed_sample_blk_fx( ); void ivas_reverb_iir_filt_init( ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */ - const uint16_t maxTaps /* i : maximum number of filter taps */ + const UWord16 maxTaps /* i : maximum number of filter taps */ ); @@ -1469,17 +1046,6 @@ void ivas_reverb_fft_filter_CrossMix_fx( const Word16 fft_size ); -void ivas_reverb_fft_filter_CrossMix( - float *buffer0, - float *buffer1, - const int16_t fft_size -); - -void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( - rv_fftwf_type_complex *spectrum, - float *fft_real, - const int16_t fft_size -); void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( rv_fftwf_type_complex_fx *spectrum, // i: Qx Word32 *fft_real, // o: Qx @@ -1620,47 +1186,21 @@ void ivas_headTrack_close_fx( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); -void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -); void Euler2Quat_fx( const Word32 yaw, /* i : yaw (x) Q22 */ const Word32 pitch, /* i : pitch (y) Q22 */ const Word32 roll, /* i : roll (z) Q22 */ IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); -float deg2rad( - float degrees -); Word32 deg2rad_fx( Word32 degrees ); -float rad2deg( - float radians -); Word32 rad2deg_fx( Word32 radians ); -void QuatToRotMat( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ -); - - -void rotateAziEle( - float azi_in, /* i : output elevation */ - float ele_in, /* i : input elevation */ - int16_t *azi, /* o : rotated azimuth */ - int16_t *ele, /* o : rotated elevation */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is roation planar and elevation meaningless? */ -); void rotateAziEle_fx( Word16 azi_in, /* i : output elevation */ Word16 ele_in, /* i : input elevation */ @@ -1734,21 +1274,21 @@ void rotateFrame_sd_cldfb_fixed( Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t numTimeSlots, /* i : number of time slots to process */ - const int16_t nb_band /* i : number of CLDFB bands to process */ + const Word16 numTimeSlots, /* i : number of time slots to process */ + const Word16 nb_band /* i : number of CLDFB bands to process */ ); ivas_error ivas_external_orientation_open( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ - const int16_t num_subframes /* i : number of subframes */ + const Word16 num_subframes /* i : number of subframes */ ); void ivas_external_orientation_close_fx( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ ); ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ - const int32_t fs, /* i : sampling rate */ - const int16_t num_subframes /* i : number of subframes */ + const Word32 fs, /* i : sampling rate */ + const Word16 num_subframes /* i : number of subframes */ ); void ivas_combined_orientation_close_fx( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ @@ -1808,34 +1348,6 @@ void QuaternionSlerp_fx( * Orientation tracking *----------------------------------------------------------------------------------*/ -ivas_error ivas_orient_trk_Init( - ivas_orient_trk_state_t *pOTR /* i/o: orientation tracker handle */ -); - -ivas_error ivas_orient_trk_SetTrackingType( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i : orientation tracking type */ -); - -ivas_error ivas_orient_trk_SetReferenceRotation( - ivas_orient_trk_state_t *pOTR, /* i/o: orientatoin trakcer handle */ - const IVAS_QUATERNION refRot /* i : reference rotation */ -); - - -ivas_error ivas_orient_trk_GetTrackedRotation( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - IVAS_QUATERNION *pRotation /* i/o: processed rotation */ -); - -ivas_error ivas_orient_trk_Process( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - IVAS_QUATERNION absRot, /* i : absolute head rotation */ - float updateRate, /* i : rotation update rate [Hz] */ - IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ -); - - ivas_error ivas_orient_trk_Init_fx( ivas_orient_trk_state_t *pOTR /* i/o: orientation tracker handle */ ); @@ -1880,7 +1392,7 @@ ivas_error ivas_orient_trk_Process_fx( ivas_error ivas_mcmasa_ana_open( MCMASA_ANA_HANDLE *hMcMasaPtr, /* i/o: McMASA data handle pointer */ const AUDIO_CONFIG inConfig, /* i : Input config */ - int32_t input_Fs /* i : Sampling frequency */ + Word32 input_Fs /* i : Sampling frequency */ ); void ivas_mcmasa_ana_fx( MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ @@ -1901,14 +1413,6 @@ ivas_error ivas_omasa_ana_open( UWord16 total_num_objects /* i : Number of objects */ ); -void ivas_omasa_ana( - OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_transport, /* i : Number of transport channels */ - const int16_t nchan_ism /* i : Number of objects for parameter analysis*/ -); - void ivas_omasa_ana_fx( OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ Word32 data_in_f_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ @@ -1928,13 +1432,7 @@ void computeIntensityVector_ana_fx( const Word16 num_frequency_bands, /* i : Number of frequency bands */ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector 2 * Qx -31 */ ); -void computeIntensityVector_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - const int16_t num_frequency_bands, /* i : Number of frequency bands */ - float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ -); + void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ @@ -1942,13 +1440,6 @@ void computeReferencePower_ana_fx( Word32 *reference_power, /* o : Estimated power */ const Word16 num_freq_bands /* i : Number of frequency bands 2 * input_q - 31 */ ); -void computeReferencePower_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - float *reference_power, /* o : Estimated power */ - const int16_t num_freq_bands /* i : Number of frequency bands */ -); void ivas_create_masa_out_meta_fx( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ @@ -1964,17 +1455,6 @@ void ivas_create_masa_out_meta_fx( Word16 surroundingCoherence_q ); -void ivas_create_masa_out_meta( - MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ - SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ - const int16_t nchan_transport, /* i : Number of transport channels */ - float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated elevation */ - float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated azimuth */ - float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated direct-to-total ratio */ - float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated spread coherence */ - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : Estimated surround coherence */ -); - ivas_error ivas_dirac_ana_open_fx( DIRAC_ANA_HANDLE *hDirACPtr, /* i/o: DIRAC data handle pointer */ Word32 input_Fs @@ -2003,11 +1483,6 @@ void ivas_prerend_merge_masa_metadata_fx( Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ ); -void copy_masa_descriptive_meta( - MASA_DECRIPTIVE_META *outMeta, /* o : metadata to be written */ - MASA_DECRIPTIVE_META *inMeta /* i : input metadata */ -); - ivas_error masaPrerendOpen_fx( MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o : handle to the opened prerenderer */ Word16 numTransports, /* i : number of transport channels */ diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index d6e397234..310bc77e4 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -36,7 +36,7 @@ #include "prot_fx.h" #include "rom_dec.h" #include "lib_rend.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index b730b1510..056ae1651 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index ab41b43c2..d2a6a0c44 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "wmc_auto.h" #include "debug.h" diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index 2d0722ceb..bbe077f8b 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include "wmc_auto.h" #include "debug.h" diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 45e492fc8..62c97f88f 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include #include diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index c8e6aa12f..870f8795d 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "math.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index 98b66e0c7..e09ec7005 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index ee2bada9d..b3e1e72fa 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 8b352218b..aebb80a54 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -38,7 +38,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index d544acd13..5e097ab2b 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 7c930104a..1a4496085 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 0fc5c21df..0c842e5bd 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "math.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index b90b3a456..7495953e3 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -35,7 +35,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 129f72388..3ea159d7f 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -34,7 +34,7 @@ #include "lib_rend.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 0316d8b30..e667dcfe5 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -33,7 +33,7 @@ #include "hrtf_file_reader.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* -- GitLab From abd4aa4c51a795cf555d675ef976e4e369abef02 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Mar 2025 09:53:26 +0530 Subject: [PATCH 312/329] Fix for 3GPP issue 1371: Energy burst in MDCT-Stereo coded item at 48kbps Link #1371 Restricting the Q-factor of spectrum and mdst_spectrum to Q-factor 9 before enc_ste_pre_mdct to avoid truncation of the spectrums resolved the issue --- lib_enc/ivas_mdct_core_enc_fx.c | 34 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 9027b2669..9f674473e 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1556,27 +1556,30 @@ void ivas_mdct_core_whitening_enc_fx( } IF( EQ_16( hTcxEnc0->transform_type[n], TCX_5 ) ) { - Word16 length; + Word16 length, len_sbfr; const Word16 tcx5SizeFB = sts[1]->hTcxCfg->tcx5SizeFB; move16(); /* length = max(nSampCore / (2 * NB_DIV), L_subframeTCX / (2 * NB_DIV), NB_DIV = 2 */ length = shr( s_max( nSampCore, L_subframeTCX ), 2 ); + len_sbfr = shr( hTcxEnc0->L_frameTCX, shift ); + assert( hTcxEnc0->L_frameTCX == hTcxEnc1->L_frameTCX ); exp_max = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); exp_max = s_max( exp_max, mdst_spectrum_e[0][n] ); exp_max = s_max( exp_max, mdst_spectrum_e[1][n] ); // calculate the headroom available - exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], length ), L_norm_arr( hTcxEnc0->spectrum_fx[n], length ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], length ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], length ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], len_sbfr ), L_norm_arr( hTcxEnc0->spectrum_fx[n], len_sbfr ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], len_sbfr ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], len_sbfr ) ); q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 ); // 6 guarded bits + q_com = s_max( q_com, 9 ); // Keep the Q-factor at least 9 to avoid precision loss inside enc_ste_pre_mdct. exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc1->spectrum_e - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e + scale_sig32( hTcxEnc0->spectrum_fx[n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e + scale_sig32( hTcxEnc1->spectrum_fx[n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc1->spectrum_e + scale_sig32( mdst_spectrum_fx[0][n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e + scale_sig32( mdst_spectrum_fx[1][n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e Word16 q_com_orig = q_com; move16(); @@ -1600,17 +1603,18 @@ void ivas_mdct_core_whitening_enc_fx( exp_max = sub( Q31, q_com ); move16(); - exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); q_com = sub( s_min( Q31, add( q_com, exp_com ) ), 6 ); + q_com = s_max( q_com, 9 ); // Keep the Q-factor at least 9 to avoid precision loss inside enc_ste_pre_mdct. exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( hTcxEnc0->spectrum_fx[n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( hTcxEnc1->spectrum_fx[n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( mdst_spectrum_fx[0][n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( mdst_spectrum_fx[1][n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max q_com_orig = q_com; move16(); -- GitLab From 5d1c2b1c1706aaed8cc43bd85e1bc92a907ac963 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Mar 2025 10:27:26 +0530 Subject: [PATCH 313/329] Fix for 3GPP issue 1343: read_indices_fx() variants Link #1343 --- lib_com/bitstream.c | 196 ++++++++----- lib_com/bitstream_fx.c | 357 +---------------------- lib_com/prot_fx.h | 24 +- lib_dec/lib_dec_fx.c | 2 +- lib_enc/acelp_core_switch_enc_fx.c | 13 - lib_enc/dtx_fx.c | 8 +- lib_enc/enc_ppp_fx.c | 12 +- lib_enc/eval_pit_contr_fx.c | 8 - lib_enc/fd_cng_enc_fx.c | 4 +- lib_enc/init_enc_fx.c | 15 - lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 8 +- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_omasa_enc_fx.c | 4 +- lib_enc/ivas_qmetadata_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 2 +- lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stereo_td_enc_fx.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 11 - 21 files changed, 149 insertions(+), 529 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 90b49f8c2..79a659eb0 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1318,33 +1318,6 @@ UWord16 get_indice_st( } #define WMC_TOOL_SKIP -/*-------------------------------------------------------------------* - * reset_indices_enc() - * - * Reset the buffer of encoder indices - *-------------------------------------------------------------------*/ - -void reset_indices_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 max_num_indices /* i : max number of indices */ -) -{ - Word16 i; - - hBstr->nb_bits_tot = 0; - move16(); - hBstr->nb_ind_tot = 0; - move16(); - - FOR( i = 0; i < max_num_indices; i++ ) - { - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - - return; -} - /*-------------------------------------------------------------------* * reset_indices_dec() * @@ -1533,21 +1506,21 @@ static ivas_error write_indices_element_fx( { IF( st_ivas->hSCE[element_id]->hMetaData != NULL ) { - reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); } - reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); } ELSE { IF( st_ivas->hCPE[element_id]->hMetaData != NULL ) { - reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); } FOR( n = 0; n < n_channels; n++ ) { - reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); } } @@ -2059,67 +2032,84 @@ void ivas_set_bitstream_pointers( *-------------------------------------------------------------------*/ /*! r: 1 = reading OK, 0 = problem */ -ivas_error read_indices( +ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t bit_stream[], /* i : bitstream buffer */ + UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ - int16_t *prev_ft_speech, - int16_t *CNG, - int16_t bfi /* i : bad frame indicator */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ ) { - int16_t k; + Word16 k; Decoder_State **sts; - int32_t total_brate = 0; - int16_t curr_ft_good_sp, curr_ft_bad_sp; - int16_t g192_sid_first, sid_upd_bad, sid_update; - int16_t speech_bad, speech_lost; - int16_t n; + Word32 total_brate = 0; + move32(); + Word16 curr_ft_good_sp, curr_ft_bad_sp; + Word16 g192_sid_first, sid_upd_bad, sid_update; + Word16 speech_bad, speech_lost; + Word16 n; ivas_error error; error = IVAS_ERR_OK; + move32(); st_ivas->BER_detect = 0; + move16(); st_ivas->num_bits = num_bits; + move16(); sts = reset_elements( st_ivas ); st_ivas->bfi = bfi; + move16(); /* convert the frame length to total bitrate */ - total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); + total_brate = imult3216( num_bits, FRAMES_PER_SEC ); + move32(); /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */ - if ( st_ivas->ivas_format != MONO_FORMAT ) + IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) { k = 0; - while ( k < SIZE_IVAS_BRATE_TBL && total_brate != ivas_brate_tbl[k] ) + move16(); + + test(); + WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( total_brate, ivas_brate_tbl[k] ) ) { - k++; + k = add( k, 1 ); } - if ( st_ivas->ivas_format == ISM_FORMAT && ( k < SIZE_IVAS_BRATE_TBL || total_brate <= SID_2k40 ) ) + test(); + test(); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && ( LT_16( k, SIZE_IVAS_BRATE_TBL ) || LE_32( total_brate, SID_2k40 ) ) ) { st_ivas->element_mode_init = IVAS_SCE; + move16(); } - else if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) && ( total_brate <= SID_2k40 ) ) + ELSE IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( total_brate, SID_2k40 ) ) { st_ivas->element_mode_init = IVAS_SCE; + move16(); } - else if ( k == SIZE_IVAS_BRATE_TBL ) + ELSE IF( EQ_16( k, SIZE_IVAS_BRATE_TBL ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } - else + ELSE { st_ivas->element_mode_init = -1; + move16(); } } - else /* AMRWB or EVS */ + ELSE /* AMRWB or EVS */ { st_ivas->element_mode_init = EVS_MONO; + move16(); - if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ + IF( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } @@ -2129,47 +2119,58 @@ ivas_error read_indices( /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ curr_ft_good_sp = 0; + move16(); curr_ft_bad_sp = 0; + move16(); - if ( is_DTXrate( total_brate ) == 0 ) + IF( is_DTXrate( total_brate ) == 0 ) { - if ( st_ivas->bfi == 0 ) + IF( st_ivas->bfi == 0 ) { curr_ft_good_sp = 1; + move16(); } - else + ELSE { curr_ft_bad_sp = 1; + move16(); } } sid_update = 0; + move16(); sid_upd_bad = 0; - if ( is_SIDrate( total_brate ) == 1 ) + move16(); + IF( EQ_16( is_SIDrate( total_brate ), 1 ) ) { - if ( st_ivas->bfi == 0 ) + IF( st_ivas->bfi == 0 ) { sid_update = 1; + move16(); } - else + ELSE { sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames */ + move16(); } } /* all zero indices/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ /* all zero indices/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ - if ( total_brate == SID_1k75 && sid_update == 1 ) + test(); + IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) { /* valid sid_update received, check for very risky but formally valid content */ - int16_t sum = 0; - for ( k = 0; k < num_bits; ++k ) + Word16 sum = 0; + move16(); + FOR( k = 0; k < num_bits; ++k ) { - sum += ( bit_stream[k] == 1 ); /* check of 35 zeroes */ + sum = add( sum, extract_l( EQ_32( bit_stream[k], 1 ) ) ); /* check of 35 zeroes */ } if ( sum == 0 ) { /* all zeros */ sid_upd_bad = 1; /* initial signal as corrupt (BER likely) */ + move16(); } } @@ -2180,14 +2181,22 @@ ivas_error read_indices( Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . */ - if ( sid_upd_bad ) + IF( sid_upd_bad ) { sid_upd_bad = 0; + move16(); total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ + move32(); } g192_sid_first = 0; - if ( st_ivas->ivas_format == MONO_FORMAT && sts[0]->core == AMR_WB_CORE && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) + move16(); + + test(); + test(); + test(); + test(); + if ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( sts[0]->core, AMR_WB_CORE ) && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ /* It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: @@ -2195,104 +2204,135 @@ ivas_error read_indices( and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding */ + move16(); } speech_bad = 0; + move16(); + + test(); if ( st_ivas->bfi != 0 && ( is_DTXrate( total_brate ) == 0 ) ) { speech_bad = 1; /* initial ft assumption, CNG_state decides what to do */ + move16(); } speech_lost = 0; + move16(); + + test(); if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ + move16(); } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ - if ( *CNG != 0 ) + IF( *CNG != 0 ) { /* We were in CNG synthesis */ if ( curr_ft_good_sp != 0 ) { /* only a good speech frame makes you leave CNG synthesis */ *CNG = 0; + move16(); } } - else + ELSE { /* We were in SPEECH synthesis */ /* only a received/detected SID frame can make the decoder enter into CNG synthsis */ + test(); + test(); if ( g192_sid_first || sid_update || sid_upd_bad ) { *CNG = 1; + move16(); } } /* set bfi, total_brate pair for proper decoding */ /* handle the G.192 _simulated_ untransmitted NO_DATA frame, setting for decoder SPEECH synthesis */ + test(); + test(); if ( *CNG == 0 && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { st_ivas->bfi = 1; /* SPEECH PLC code will now become active as in a real system */ /* total_brate= 0 */ + move16(); } /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ - if ( ( - bfi != FRAMEMODE_FUTURE && - ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ - ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ + test(); + test(); + test(); + test(); + IF( ( + NE_16( bfi, FRAMEMODE_FUTURE ) && + ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ + ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ + move16(); total_brate = FRAME_NO_DATA; + move32(); } /* update for next frame's G.192 file format's odd SID_FIRST detection (primarily for AMRWBIO) */ + test(); *prev_ft_speech = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); + move16(); /* st->total brate= total_brate; updated in a good frame below */ - for ( k = 0; k < st_ivas->nCPE; k++ ) + FOR( k = 0; k < st_ivas->nCPE; k++ ) { sts = st_ivas->hCPE[k]->hCoreCoder; - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR( n = 0; n < CPE_CHANNELS; n++ ) { sts[n]->bfi = st_ivas->bfi; + move16(); } } - for ( k = 0; k < st_ivas->nSCE; k++ ) + FOR( k = 0; k < st_ivas->nSCE; k++ ) { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bfi = st_ivas->bfi; + move16(); } - if ( st_ivas->bfi == 0 ) + IF( st_ivas->bfi == 0 ) { /* select Mode 1 or Mode 2 */ - if ( st_ivas->ivas_format == MONO_FORMAT ) /* EVS mono */ + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) /* EVS mono */ { decoder_selectCodec( sts[0], total_brate, bit_stream[0] ); st_ivas->hDecoderConfig->Opt_AMR_WB = sts[0]->Opt_AMR_WB; + move16(); } - else /* IVAS */ + ELSE /* IVAS */ { st_ivas->codec_mode = MODE1; + move16(); st_ivas->hDecoderConfig->Opt_AMR_WB = 0; + move16(); } } /* GOOD frame */ - if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE ) + test(); + if ( st_ivas->bfi == 0 || EQ_16( st_ivas->bfi, FRAMEMODE_FUTURE ) ) { /* GOOD frame - convert ITU-T G.192 words to short values */ st_ivas->hDecoderConfig->ivas_total_brate = total_brate; + move32(); } st_ivas->bit_stream = bit_stream; - if ( st_ivas->ivas_format == MONO_FORMAT ) + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { ivas_set_bitstream_pointers( st_ivas ); } diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 6163fc4ff..d4938f399 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -543,7 +543,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ *-------------------------------------------------------------------*/ void reset_indices_enc_fx( - BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + const Word16 max_num_indices /* i : max number of indices */ ) { Word16 i; @@ -559,7 +560,7 @@ void reset_indices_enc_fx( hBstr->last_ind_fx = -1; move16(); - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) + FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; move16(); @@ -1547,358 +1548,6 @@ Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 t return L_temp; } - -/*-------------------------------------------------------------------* - * read_indices_fx() - * - * Read indices from an ITU-T G.192 bitstream to the buffer - * Simulate packet losses by inserting frame erasures - *-------------------------------------------------------------------*/ - -Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem */ - Decoder_State *st, /* i/o: decoder state structure */ - FILE *file, /* i : bitstream file */ - Word16 rew_flag /* i : rewind flag (rewind file after reading)*/ -) -{ - Word16 k; - UWord16 utmp, stream[2 + MAX_BITS_PER_FRAME], *pt_stream, *bit_stream_ptr; - Word16 num_bits; - Word32 total_brate; - Word32 L_tmp; - Word16 curr_ft_good_sp, curr_ft_bad_sp; - Word16 g192_sid_first, sid_upd_bad, sid_update; - Word16 speech_bad, speech_lost; - Word16 num_bits_read; - - st->bfi = 0; - move16(); - st->BER_detect = 0; - move16(); - st->mdct_sw_enable = 0; - move16(); - st->mdct_sw = 0; - move16(); - reset_indices_dec_fx( st ); - - /* read the Sync Header field from the bitstream */ - /* in case rew_flag is set, read until first good frame is encountered */ - test(); - test(); - DO - { - /* read the Sync header */ - IF( NE_32( fread( &utmp, sizeof( unsigned short ), 1, file ), 1 ) ) - { - IF( ferror( file ) ) - { - /* error during reading */ - fprintf( stderr, "\nError reading the bitstream !" ); - exit( -1 ); - } - ELSE - { - /* end of file reached */ - return 0; - } - } - - /* set the BFI indicator according the value of Sync Header */ - IF( EQ_16( utmp, SYNC_BAD_FRAME ) ) - { - st->bfi = 1; - move16(); - } - ELSE - { - st->bfi = 0; - move16(); - } - - /* read the Frame Length field from the bitstream */ - IF( NE_32( fread( &num_bits, sizeof( unsigned short ), 1, file ), 1 ) ) - { - IF( ferror( file ) ) - { - /* error during reading */ - fprintf( stderr, "\nError reading the bitstream !" ); - exit( -1 ); - } - ELSE - { - /* end of file reached */ - return 0; - } - } - /* convert the frame length to total bitrate */ - total_brate = L_mult0( num_bits, 50 ); - - /* read ITU-T G.192 serial stream of indices from file to the local buffer */ - /* Validate that the G.192 length is within the defined bit rate range - to not allow writing past the end of the "stream" buffer */ - IF( GT_16( num_bits, MAX_BITS_PER_FRAME ) ) - { - fprintf( stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits ); - exit( -1 ); - } - - /* verify that a valid num bits value is present in the G.192 file */ - /* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */ - IF( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ - { - fprintf( stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); - exit( -1 ); - } - pt_stream = stream; - - num_bits_read = (Word16) fread( pt_stream, sizeof( unsigned short ), num_bits, file ); - move16(); - - IF( NE_16( num_bits_read, num_bits ) ) - { - fprintf( stderr, "\nError, invalid number of bits read ! Exiting ! \n" ); - exit( -1 ); - } - } - WHILE( rew_flag && ( st->bfi || ( total_brate < 2800 ) ) ); - - /* G.192 RX DTX handler*/ - IF( !rew_flag ) - { - /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ - - /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ - curr_ft_good_sp = 0; - move16(); - curr_ft_bad_sp = 0; - move16(); - - IF( GT_32( total_brate, SID_2k40 ) ) - { - IF( st->bfi == 0 ) - { - curr_ft_good_sp = 1; - move16(); - } - ELSE - { - curr_ft_bad_sp = 1; - move16(); - } - } - sid_update = 0; - move16(); - sid_upd_bad = 0; - move16(); - - test(); - IF( total_brate == SID_1k75 || total_brate == SID_2k40 ) - { - IF( st->bfi == 0 ) - { - sid_update = 1; - move16(); - } - ELSE - { - sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */ - move16(); - } - } - - /* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ - /* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ - test(); - IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) - { - /* valid sid_update received, check for very risky but formally valid content */ - Word16 sum = 0; - move16(); - FOR( k = 0; k < num_bits; ++k ) - { - sum = add( sum, extract_l( EQ_16( pt_stream[k], G192_BIN1 ) ) ); /* check of 35 zeroes, 35 ones */ - } - if ( sum == 0 ) - { /* all zeros */ - sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */ - move16(); - } - } - - /* AMRWB 26.173 G.192 file reader (read_serial) does not declare/use SID_BAD ft, - it declares every bad synch marked frame initially as a lost_speech frame, - and then the RXDTX handler CNG state decides the decoding mode CNG/SPEECH. - While In the AMRWB ETSI/3GPP format eid a CRC error in a detected SID_UPDATE frame triggers SID_UPD_BAD. - - Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . - */ - IF( sid_upd_bad ) - { - sid_upd_bad = 0; - move16(); - total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ - move32(); - } - - g192_sid_first = 0; - move16(); - - test(); - test(); - test(); - if ( EQ_16( st->core, AMR_WB_CORE ) && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 ) - { - g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ - /* - It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: - the very first SID_FIRST detection is based on a past EVS active frame - and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, - , due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding - */ - move16(); - } - - speech_bad = 0; - move16(); - - test(); - if ( GT_32( total_brate, SID_2k40 ) && st->bfi != 0 ) /* CS-type of CRC failure frame */ - { - speech_bad = 1; /* initial assumption, CNG_state decides what to do */ - move16(); - } - - speech_lost = 0; - move16(); - - test(); - if ( total_brate == 0 && st->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ - { - speech_lost = 1; /* initial assumption, CNG_state decides what to do */ - move16(); - } - - /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame - as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ - - IF( st->CNG_fx != 0 ) - { - /* We were in CNG synthesis */ - if ( curr_ft_good_sp != 0 ) - { - /* only a good speech frame makes you leave CNG synthesis */ - st->CNG_fx = 0; - move16(); - } - } - ELSE - { - /* We were in SPEECH synthesis */ - /* only a received SID frame can make the decoder enter into CNG synthsis */ - test(); - test(); - if ( g192_sid_first || sid_update || sid_upd_bad ) - { - st->CNG_fx = 1; - move16(); - } - } - - /* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */ - test(); - test(); - if ( ( st->CNG_fx == 0 ) && ( total_brate == 0 && st->bfi == 0 ) ) - { - st->bfi = 1; - move16(); /* SPEECH PLC code will now become active as in a real system */ - /* total_brate= 0 */ - } - - /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ - test(); - test(); - test(); - IF( ( ( st->CNG_fx != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ - ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ - { - st->bfi = 0; - move16(); - total_brate = 0; - move32(); - } - /* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */ - test(); - st->prev_ft_speech_fx = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); - move16(); - - /* st->total brate= total_brate ; updated in a good frame below */ - } /* rew_flag */ - - /* get total bit-rate */ -#ifdef DEBUGGING - st->bfi |= file_read_FECpattern(); -#endif - test(); - IF( st->bfi == 0 && !rew_flag ) - { - /* select MODE1 or MODE2 */ - decoder_selectCodec( st, total_brate, *pt_stream ); - } - - Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ - st->total_num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ - move16(); - - /* in case rew_flag is set, rewind the file and return */ - /* (used in io_enc() to print out info about technologies and to initialize the codec) */ - IF( rew_flag ) - { - rewind( file ); - st->total_brate = total_brate; - move32(); - return 1; - } - - /* GOOD frame */ - IF( st->bfi == 0 ) - { - /* GOOD frame - convert ITU-T G.192 words to short values */ - bit_stream_ptr = st->bit_stream; - - FOR( k = 0; k < num_bits; ++k ) - { - *bit_stream_ptr++ = (UWord16) EQ_32( *pt_stream++, G192_BIN1 ); - move16(); - } - - /*add two zero bytes for arithmetic coder flush*/ - FOR( k = 0; k < 2 * 8; ++k ) - { - *bit_stream_ptr++ = 0; - move16(); - } - /*a change of the total bitrate should not be - known to the decoder, if the received frame was lost*/ - st->total_brate = total_brate; - move32(); - - mdct_switching_dec( st ); - } -#ifdef DEBUGGING - else - { - bit_stream_ptr = st->bit_stream; - - for ( k = 0; k < num_bits + 2 * 8; ++k ) - { - *bit_stream_ptr++ = 0; - } - } -#endif - return 1; -} - - /*-------------------------------------------------------------------* * read_indices_mime_handle_dtx() * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9fe14b5bd..1bd007e64 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1323,7 +1323,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ ); void reset_indices_enc_fx( - BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + const Word16 max_num_indices /* i : max number of indices */ ); void reset_indices_dec_fx( @@ -1367,12 +1368,6 @@ Word16 BRATE2IDX16k_fx( Word32 brate ); Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); -Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - FILE *file, /* i : bitstream file */ - Word16 rew_flag /* i : rewind flag (rewind file after reading) */ -); - Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */ Decoder_State *st, /* i/o: decoder state structure */ FILE *file, /* i : bitstream file */ @@ -11544,11 +11539,6 @@ uint16_t get_indice( int16_t nb_bits /* i : number of bits that were used to quantize the indice */ ); -void reset_indices_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t max_num_indices /* i : max number of indices */ -); - void reset_indices_dec( Decoder_State *st /* i/o: decoder state structure */ ); @@ -11560,13 +11550,13 @@ Word16 rate2EVSmode_float( /*! r: 1 = OK, 0 = something wrong */ -ivas_error read_indices( +ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t bit_stream[], /* i : bitstream buffer */ + UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ - int16_t *prev_ft_speech, - int16_t *CNG, - int16_t bfi /* i : bad frame indicator */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index dc06ddc5a..56ffe3924 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -923,7 +923,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } - IF( NE_32( ( error = read_indices( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = read_indices_fx( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 90768aca1..d88e1523e 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -160,18 +160,6 @@ void acelp_core_switch_enc_fx( /*----------------------------------------------------------------* * bit-stream: modify the layer of sub frame CELP *----------------------------------------------------------------*/ -#ifdef IVAS_CODE_BITSTREAM - i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); -#ifdef DEBUGGING - assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); -#endif - while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START ) - { - push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits ); - i++; - } - delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); -#else FOR( i = 0; i < 20; i++ ) { hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; /* Q0 */ @@ -181,7 +169,6 @@ void acelp_core_switch_enc_fx( hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */ move16(); } -#endif /*----------------------------------------------------------------* * BWE encoding *----------------------------------------------------------------*/ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 6e4d2a043..154b43c12 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -349,7 +349,7 @@ void dtx_ivas_fx( IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { - reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); } } #ifdef NONBE_1211_DTX_BR_SWITCHING @@ -863,11 +863,7 @@ void dtx_fx( /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { -#ifndef IVAS_CODE_BITSTREAM - reset_indices_enc_fx( st_fx->hBstr ); -#else - reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); -#endif + reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); } } diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index f1a87d2d2..c2aeaa7ca 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -189,11 +189,7 @@ ivas_error encod_ppp_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifndef IVAS_CODE_BITSTREAM - reset_indices_enc_fx( hBstr ); -#else - reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#endif + reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); @@ -377,11 +373,7 @@ ivas_error encod_ppp_ivas_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifndef IVAS_CODE_BITSTREAM - reset_indices_enc_fx( hBstr ); -#else - reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#endif + reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 75e82409e..d5f832f8c 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -381,19 +381,14 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) { -#ifndef IVAS_CODE_BITSTREAM IF( hBstr->ind_list[i].nb_bits != -1 ) { hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits ); /* Q0 */ hBstr->ind_list[i].nb_bits = -1; move16(); } -#else - delete_indice( hBstr, i ); -#endif } -#ifndef IVAS_CODE_BITSTREAM IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 ) { hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits ); /* Q0 */ @@ -401,9 +396,6 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit hBstr->ind_list[IND_ES_PRED].nb_bits = -1; move16(); } -#else - delete_indice( hBstr, i ); -#endif } IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 2db8b956b..757a69518 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2695,9 +2695,9 @@ void stereoFdCngCoherence_fx( ELSE IF( LE_32( sts[0]->core_brate, SID_2k40 ) && LE_32( sts[1]->core_brate, SID_2k40 ) ) { /* case: no VAD for both channels -> INACTIVE FRAME */ - reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); - reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); /* synchronize SID sending for variable SID rate */ IF( EQ_32( sts[0]->core_brate, sts[1]->core_brate ) ) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index cd5db5377..ebfd9c4a2 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -136,18 +136,6 @@ ivas_error init_encoder_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); } -#ifdef IVAS_CODE_BITSTREAM - - /* set pointer to the buffer of indices */ - st->hBstr->ind_list = st_ivas->ind_list; - st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st->hBstr->nb_ind_tot = 0; - move16(); - st->hBstr->nb_bits_tot = 0; - move16(); - st->hBstr->st_ivas = st_ivas; -#endif } ELSE { @@ -910,9 +898,6 @@ ivas_error init_encoder_fx( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), &st_fx->transientDetection ); - // reset_indices_enc_fx( st_fx->hBstr); - - st_fx->Q_syn2 = 0; move16(); st_fx->Q_syn = 0; diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index f88288ea1..cacbcabd3 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -309,7 +309,7 @@ ivas_error ivas_core_enc_fx( st->hBstr->nb_ind_tot = add( st->hBstr->nb_ind_tot, hStereoTD->tdm_hBstr_tmp.nb_ind_tot ); /* Q0 */ st->hBstr->nb_bits_tot = add( st->hBstr->nb_bits_tot, hStereoTD->tdm_hBstr_tmp.nb_bits_tot ); /* Q0 */ - reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); + reset_indices_enc_fx( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index f21c8e262..a1f2196fb 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -405,7 +405,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ IF( sce_id > 0 || EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) { - reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); } } @@ -449,7 +449,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->nSCE > 0 ) || ( EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } } } @@ -487,7 +487,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( test(); IF( add( i_mult( cpe_id, CPE_CHANNELS ), n ) > 0 || ( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } IF( hEncoderConfig->Opt_DTX_ON ) @@ -667,7 +667,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( } } - reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot ); FOR( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ ) { diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index b49fc9716..57858b03e 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -2151,7 +2151,7 @@ ivas_error ivas_initialize_MD_bstr_enc_fx( hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata; /* Q0 */ hMetaData->st_ivas = st_ivas; - reset_indices_enc( hMetaData, st_ivas->ivas_max_num_indices_metadata ); + reset_indices_enc_fx( hMetaData, st_ivas->ivas_max_num_indices_metadata ); *hMetaData_out = hMetaData; diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 9256be408..6aba283be 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -191,7 +191,7 @@ Word16 ivas_ism_dtx_enc_fx( IF( dtx_flag ) { /* reset the bitstream (IVAS format signaling was already written) */ - reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); } /*------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 6a2e54db6..8e6e0c93f 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -873,7 +873,7 @@ ivas_error ivas_ism_metadata_enc_fx( /* write metadata only in active frames */ IF( GT_32( hSCE[0]->hCoreCoder[0]->core_brate, SID_2k40 ) ) { - reset_indices_enc( hSCE[ch]->hMetaData, hSCE[ch]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( hSCE[ch]->hMetaData, hSCE[ch]->hMetaData->nb_ind_tot ); } } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index b5258712b..d31e6d53d 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -336,11 +336,11 @@ ivas_error ivas_omasa_enc_config_fx( /* re-write IVAS format signalling - actual 'ism_mode' was not known before */ IF( st_ivas->nSCE > 0 ) { - reset_indices_enc( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr, st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); + reset_indices_enc_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr, st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); } ELSE { - reset_indices_enc( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr, st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); + reset_indices_enc_fx( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr, st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); } ivas_write_format_fx( st_ivas ); diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 2d6080995..7de54c482 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -1209,7 +1209,7 @@ void reset_metadata_spatial_fx( ELSE { /*Reset metadata*/ - reset_indices_enc( hMetaData, hMetaData->nb_ind_tot ); + reset_indices_enc_fx( hMetaData, hMetaData->nb_ind_tot ); } *total_brate = element_brate; diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 2983ea2f0..35b65e4c1 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -608,7 +608,7 @@ ivas_error create_evs_sce_enc_fx( } st_fx->hBstr->ind_list = ind_list; // st_fx->hBstr->ind_list_fx = st->hBstr->ind_list; - reset_indices_enc_fx( st_fx->hBstr ); + reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); hSCE->hCoreCoder[0] = st_fx; st_ivas->hSCE[sce_id] = hSCE; diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 997581476..9c4fcc937 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -849,7 +849,7 @@ ivas_error ivas_spar_md_enc_process_fx( move16(); IF( NE_16( strat, NO_STRAT ) ) { - reset_indices_enc( &hMetaData_tmp, md_indices_allocated ); + reset_indices_enc_fx( &hMetaData_tmp, md_indices_allocated ); ivas_write_spar_md_bitstream_fx( hMdEnc, num_bands, bands_bw, &hMetaData_tmp, hEncoderConfig->ivas_total_brate, strat, qsi ); diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 1544aab76..378068827 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -195,7 +195,7 @@ void stereo_td_init_enc_fx( move32(); hStereoTD->tdm_hBstr_tmp.ivas_max_num_indices = &hStereoTD->max_ind_tdm_tmp; hStereoTD->tdm_hBstr_tmp.st_ivas = NULL; - reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); + reset_indices_enc_fx( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); return; } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 7247b6446..ce7f0e6a6 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3734,7 +3734,6 @@ void ProcessIGF_fx( } } - // IVAS_CODE_BITSTREAM bsStart = hBstr->next_ind_fx; move16(); @@ -3749,21 +3748,11 @@ void ProcessIGF_fx( IGFEncWriteBitstream_fx( hInstance, st->hBstr, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); } -#ifndef IVAS_CODE_BITSTREAM bsBits = sub( hBstr->next_ind_fx, bsStart ); IF( !isTCX20 ) { IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot, hBstr->ind_list ); } -#else - PMT( "New bit stream implementation to be checked" ) - bsBits = sub( hBstr->next_ind_fx, bsStart ); - IF( !isTCX20 ) - { - IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot_fx, hBstr->ind_list_fx ); - } - -#endif } void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) -- GitLab From 213f62ced4428c1b26300d0b0e37c9f43480d6eb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 13 Mar 2025 13:54:21 +0100 Subject: [PATCH 314/329] add missing defines not ported from ivas_prot.h to ivas_prot_fx.h into isar_prot.h --- lib_isar/isar_prot.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 82fbe631d..4f0967f14 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -445,6 +445,29 @@ void ivas_calculate_abs_fx( Word32 re_fx, Word16 exp_re, Word32 im_fx, Word16 ex void ivas_calculate_rabs_fx( Word32 re_fx, Word16 exp_re, Word32 *out_fx, Word16 *exp_out ); +#define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ + out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ + out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); + +#define IVAS_CALCULATE_ABS( re, im, out ) \ + out = sqrtf( ( re * re ) + ( im * im ) ); + +#define IVAS_CALCULATE_RABS( re, out ) \ + out = sqrtf( re * re ); + +#define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ + out = (float) ( ( re * re ) + ( im * im ) ); + +#define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ + out1_re = ( in1_re * in2_re ); \ + +#define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ + out = (float) ( re * re ); + +#define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ + out1_re = ( in1_re * in2_re ); + + /* clang-format on */ #endif /* IVAS_PROT_REND_H */ -- GitLab From a046f76786bbe1e6756e3925b0825a7a41096ee6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 13 Mar 2025 13:55:13 +0100 Subject: [PATCH 315/329] clang-format --- lib_dec/ivas_init_dec.c | 2 +- lib_isar/isar_prot.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 22a593746..cef1e45e9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -148,7 +148,7 @@ static ivas_error ivas_dec_reconfig_split_rend( FOR( ch = 0; ch < num_ch; ch++ ) { - IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS , DEC) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); } diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 4f0967f14..90a9d2763 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -446,26 +446,26 @@ void ivas_calculate_abs_fx( Word32 re_fx, Word16 exp_re, Word32 im_fx, Word16 ex void ivas_calculate_rabs_fx( Word32 re_fx, Word16 exp_re, Word32 *out_fx, Word16 *exp_out ); #define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ - out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ - out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); + out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ + out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); #define IVAS_CALCULATE_ABS( re, im, out ) \ - out = sqrtf( ( re * re ) + ( im * im ) ); + out = sqrtf( ( re * re ) + ( im * im ) ); #define IVAS_CALCULATE_RABS( re, out ) \ out = sqrtf( re * re ); #define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ - out = (float) ( ( re * re ) + ( im * im ) ); + out = (float) ( ( re * re ) + ( im * im ) ); #define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); \ + out1_re = ( in1_re * in2_re ); #define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ out = (float) ( re * re ); #define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); + out1_re = ( in1_re * in2_re ); /* clang-format on */ -- GitLab From 07b7b2db45859778ef0d6da3d1f6d455f9659b36 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Mar 2025 18:20:10 +0100 Subject: [PATCH 316/329] add git fetch before checking for float ref branch --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 886fa96f1..069131722 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1063,6 +1063,7 @@ check-naming-of-branch-for-main-pc-merges: script: - *update-scripts-repo - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - git fetch - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 1cf8c8882344da44d548c74d190b5c9a35669bca Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 08:15:53 +0100 Subject: [PATCH 317/329] increase timeout for split rendering comp test --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 069131722..c0a7d37b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1340,8 +1340,7 @@ split-rendering-pytest-on-merge-request: - .test-job-linux-needs-testv-dir - .rules-merge-request needs: ["build-codec-linux-make"] - # TODO: set reasonable timeout, will most likely take less - timeout: "30 minutes" + timeout: "45 minutes" stage: compare script: - *print-common-info -- GitLab From b23e6918ae00b6a51699c577faba9e72d3398243 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 14 Mar 2025 09:45:41 +0100 Subject: [PATCH 318/329] update --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0c5f94a40..109e81094 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -180,9 +180,9 @@ #define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif +#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ #define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ -#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ /* #################### End BASOP porting switches ############################ */ -- GitLab From e5067a7b89c47c7ccdd35eb75a56293e721887a4 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 13:47:59 +0100 Subject: [PATCH 319/329] move switch to correct section --- lib_com/options.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 348e4bc24..b2dd1e3e7 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,7 +79,6 @@ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/ -#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ #define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX #define FIX_ISSUE_987 @@ -184,7 +183,7 @@ #define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ #define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ #define FIX_921_OMASA_DELAY_PRINTOUT /* VA: issue 921: correct OMASA decoder delay printout */ - +#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ /* #################### End BASOP porting switches ############################ */ -- GitLab From 847c923ffd563692dad77bd8e0833ebd05dfef11 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 13:57:29 +0100 Subject: [PATCH 320/329] add debug output in CI job --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0a7d37b5..95f7c9959 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1062,6 +1062,7 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo + - git branch --list - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - git fetch - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME -- GitLab From a3a3f515ece52eeaa9184292fa8a68ac7e78b68f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:02:16 +0100 Subject: [PATCH 321/329] apply clang-format --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 8cee8c26d..95d9fb03e 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3401,7 +3401,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); -#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA +#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA if ( EQ_16( num_tc, 3 ) ) #else if ( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) -- GitLab From c796ec69f3dcbf2fe7604c1f48877359de1ffe65 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:03:22 +0100 Subject: [PATCH 322/329] add further debug printout --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95f7c9959..e6801b2c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1065,6 +1065,7 @@ check-naming-of-branch-for-main-pc-merges: - git branch --list - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - git fetch + - git branch --list - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 4455a51b8bdc2180cca085182bb0264801caa0cc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:07:08 +0100 Subject: [PATCH 323/329] use -av arg for git branch command --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e6801b2c5..d549fceab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1062,10 +1062,10 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - git branch --list + - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - git fetch - - git branch --list + - git branch -av - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From a3e33d36e9483f0e92a6db81fa879e75536574da Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:33:48 +0100 Subject: [PATCH 324/329] dummy commit to trigger CI -- GitLab From 8583d6677d115474e6978a801aff307bfc41cabd Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:38:24 +0100 Subject: [PATCH 325/329] more debug printout... --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d549fceab..d313d639d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1064,8 +1064,9 @@ check-naming-of-branch-for-main-pc-merges: - *update-scripts-repo - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - git fetch - - git branch -av + - float_ref_branchname="${branchname/basop/ref}" + - git_result=$(git branch -av --list "$float_ref_branchname") + - echo "$git_result" - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From d9721934c1922732da8dbef49a7cec346d6b97e6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:40:00 +0100 Subject: [PATCH 326/329] fix last commit --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d313d639d..ddd665f8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1064,6 +1064,7 @@ check-naming-of-branch-for-main-pc-merges: - *update-scripts-repo - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - branchname="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - float_ref_branchname="${branchname/basop/ref}" - git_result=$(git branch -av --list "$float_ref_branchname") - echo "$git_result" -- GitLab From 4c39492de6c619da105ceda2c4b7769f6c951b0f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:46:05 +0100 Subject: [PATCH 327/329] more debugging --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddd665f8f..59a7a99fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1062,12 +1062,17 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - set -euxo - branchname="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - float_ref_branchname="${branchname/basop/ref}" + - git branch -av + - git branch -av --list || true + - git branch -av --list $branchname + - git branch -av --list "$float_ref_branchname" - git_result=$(git branch -av --list "$float_ref_branchname") - echo "$git_result" + - set +euxo - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 2cf229b2d2e23183de25644cefb1a8d1f24c2343 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:54:31 +0100 Subject: [PATCH 328/329] try with different script branch from flaot repo --- .gitlab-ci.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59a7a99fc..00b954ca6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + BASOP_CI_BRANCH_PC_REPO: "basop-ci/fix-get-float-ref-script" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -1063,16 +1063,6 @@ check-naming-of-branch-for-main-pc-merges: script: - *update-scripts-repo - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - set -euxo - - branchname="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - - float_ref_branchname="${branchname/basop/ref}" - - git branch -av - - git branch -av --list || true - - git branch -av --list $branchname - - git branch -av --list "$float_ref_branchname" - - git_result=$(git branch -av --list "$float_ref_branchname") - - echo "$git_result" - - set +euxo - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 49de6d513ed5c6430389bfda073ab7ee8e0c188b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 15:21:22 +0100 Subject: [PATCH 329/329] change scripts branch back --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 00b954ca6..57ae48287 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci/fix-get-float-ref-script" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 -- GitLab